Only Yesterday 制御プログラム
Dependencies: mbed FATFileSystem
Fork of OnlyYestaerday by
eDisp.h@0:5975af170e43, 2014-04-02 (annotated)
- Committer:
- jksoft
- Date:
- Wed Apr 02 01:43:55 2014 +0000
- Revision:
- 0:5975af170e43
1st Prototype
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:5975af170e43 | 1 | /* mbed eDISP Library |
jksoft | 0:5975af170e43 | 2 | * Copyright (c) 2010 todotani |
jksoft | 0:5975af170e43 | 3 | * Version 0.1 (March 6, 2010) |
jksoft | 0:5975af170e43 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
jksoft | 0:5975af170e43 | 5 | */ |
jksoft | 0:5975af170e43 | 6 | |
jksoft | 0:5975af170e43 | 7 | #ifndef MBED_EDISP_H |
jksoft | 0:5975af170e43 | 8 | #define MBED_EDISP_H |
jksoft | 0:5975af170e43 | 9 | |
jksoft | 0:5975af170e43 | 10 | #include "mbed.h" |
jksoft | 0:5975af170e43 | 11 | #include "Stream.h" |
jksoft | 0:5975af170e43 | 12 | |
jksoft | 0:5975af170e43 | 13 | // Text Color code |
jksoft | 0:5975af170e43 | 14 | #define BLACK 30 |
jksoft | 0:5975af170e43 | 15 | #define RED 31 |
jksoft | 0:5975af170e43 | 16 | #define GREEN 32 |
jksoft | 0:5975af170e43 | 17 | #define YELLOW 33 |
jksoft | 0:5975af170e43 | 18 | #define BLUE 34 |
jksoft | 0:5975af170e43 | 19 | #define PURPLE 35 |
jksoft | 0:5975af170e43 | 20 | #define AQUA 36 |
jksoft | 0:5975af170e43 | 21 | #define WHITE 37 |
jksoft | 0:5975af170e43 | 22 | #define TRANSPARENT 49 // default background color |
jksoft | 0:5975af170e43 | 23 | |
jksoft | 0:5975af170e43 | 24 | // RGB555 color code (converted from 32bit color code) |
jksoft | 0:5975af170e43 | 25 | #define RGB_Black (0 << 10) + (0 << 5) + 0 |
jksoft | 0:5975af170e43 | 26 | #define RGB_Navy (0 << 10) + (0 << 5) + 0x80/8 |
jksoft | 0:5975af170e43 | 27 | #define RGB_Silver (0xc0/8 << 10) + (0xc0/8 << 5) + 0xc0/8 |
jksoft | 0:5975af170e43 | 28 | #define RGB_Blue (0 << 10) + (0 << 5) + 0xff/8 |
jksoft | 0:5975af170e43 | 29 | #define RGB_Maroon (0x80/8 << 10) + (0 << 5) + 0 |
jksoft | 0:5975af170e43 | 30 | #define RGB_Purple (0x80/8 << 10) + (0 << 5) + 0x80/8 |
jksoft | 0:5975af170e43 | 31 | #define RGB_Red (0xff/8 << 10) + (0 << 5) + 0 |
jksoft | 0:5975af170e43 | 32 | #define RGB_Fuchsia (0xff/8 << 10) + (0 << 5) + 0xff/8 |
jksoft | 0:5975af170e43 | 33 | #define RGB_Green (0 << 10) + (0x80/8 << 5) + 0 |
jksoft | 0:5975af170e43 | 34 | #define RGB_Teal (0 << 10) + (0x80/8 << 5) + 0x80/8 |
jksoft | 0:5975af170e43 | 35 | #define RGB_Lime (0 << 10) + (0xff/8 << 5) + 0 |
jksoft | 0:5975af170e43 | 36 | #define RGB_Aqua (0 << 10) + (0xff/8 << 5) + 0xff/8 |
jksoft | 0:5975af170e43 | 37 | #define RGB_Olive (0x80/8 << 10) + (0x80/8 << 5) + 0 |
jksoft | 0:5975af170e43 | 38 | #define RGB_Gray (0x80/8 << 10) + (0x80/8 << 5) + 0x80/8 |
jksoft | 0:5975af170e43 | 39 | #define RGB_Yellow (0xff/8 << 10) + (0xff/8 << 5) + 0 |
jksoft | 0:5975af170e43 | 40 | #define RGB_White (0xff/8 << 10) + (0xff/8 << 5) + 0xff/8 |
jksoft | 0:5975af170e43 | 41 | |
jksoft | 0:5975af170e43 | 42 | |
jksoft | 0:5975af170e43 | 43 | namespace mbed { |
jksoft | 0:5975af170e43 | 44 | |
jksoft | 0:5975af170e43 | 45 | /* Class: eDisp |
jksoft | 0:5975af170e43 | 46 | * Driver for eDISP (http://www.ddlab.jp/shop/edisp/syouhin.cgi) |
jksoft | 0:5975af170e43 | 47 | * |
jksoft | 0:5975af170e43 | 48 | * Allows you to print to a Text LCD screen, set color and locate/cls. |
jksoft | 0:5975af170e43 | 49 | * Also support graphics functions fillRect, drawLine |
jksoft | 0:5975af170e43 | 50 | * |
jksoft | 0:5975af170e43 | 51 | */ |
jksoft | 0:5975af170e43 | 52 | class eDisp : public Stream { |
jksoft | 0:5975af170e43 | 53 | public: |
jksoft | 0:5975af170e43 | 54 | /* Constructor: eDisp |
jksoft | 0:5975af170e43 | 55 | * Create a eDisp object, connected to the specified pins |
jksoft | 0:5975af170e43 | 56 | * |
jksoft | 0:5975af170e43 | 57 | * All signals must be connected to pair of Serial Tx/Rx pin |
jksoft | 0:5975af170e43 | 58 | * (p9/p10, p13/p14 or p28/p27) |
jksoft | 0:5975af170e43 | 59 | * |
jksoft | 0:5975af170e43 | 60 | * Variables: |
jksoft | 0:5975af170e43 | 61 | * tx - Used to specify tx of Serial port |
jksoft | 0:5975af170e43 | 62 | * rx - Used to specify rx of Serial port (acturally not used) |
jksoft | 0:5975af170e43 | 63 | * baud - baudrate of serial port |
jksoft | 0:5975af170e43 | 64 | */ |
jksoft | 0:5975af170e43 | 65 | eDisp(PinName tx, PinName rx, int baud = 19200, |
jksoft | 0:5975af170e43 | 66 | int columns = 40, int rows = 15); |
jksoft | 0:5975af170e43 | 67 | |
jksoft | 0:5975af170e43 | 68 | #if 0 // Inhereted from Stream, for documentation only |
jksoft | 0:5975af170e43 | 69 | /* Function: putc |
jksoft | 0:5975af170e43 | 70 | * Write a character |
jksoft | 0:5975af170e43 | 71 | * |
jksoft | 0:5975af170e43 | 72 | * Variables: |
jksoft | 0:5975af170e43 | 73 | * c - The character to write to the serial port |
jksoft | 0:5975af170e43 | 74 | */ |
jksoft | 0:5975af170e43 | 75 | int putc(int c); |
jksoft | 0:5975af170e43 | 76 | |
jksoft | 0:5975af170e43 | 77 | /* Function: printf |
jksoft | 0:5975af170e43 | 78 | * Write a formated string |
jksoft | 0:5975af170e43 | 79 | * |
jksoft | 0:5975af170e43 | 80 | * Variables: |
jksoft | 0:5975af170e43 | 81 | * format - A printf-style format string, followed by the |
jksoft | 0:5975af170e43 | 82 | * variables to use in formating the string. |
jksoft | 0:5975af170e43 | 83 | */ |
jksoft | 0:5975af170e43 | 84 | int printf(const char* format, ...); |
jksoft | 0:5975af170e43 | 85 | #endif |
jksoft | 0:5975af170e43 | 86 | |
jksoft | 0:5975af170e43 | 87 | /* Function: locate |
jksoft | 0:5975af170e43 | 88 | * set cursor position |
jksoft | 0:5975af170e43 | 89 | * Variables: |
jksoft | 0:5975af170e43 | 90 | * colum - x position (0 - 39) |
jksoft | 0:5975af170e43 | 91 | * row - y position (0 - 14) |
jksoft | 0:5975af170e43 | 92 | */ |
jksoft | 0:5975af170e43 | 93 | void locate(int column, int row); |
jksoft | 0:5975af170e43 | 94 | |
jksoft | 0:5975af170e43 | 95 | /* Function: textColor |
jksoft | 0:5975af170e43 | 96 | * Set text color |
jksoft | 0:5975af170e43 | 97 | * Variables: |
jksoft | 0:5975af170e43 | 98 | * color - Text color code |
jksoft | 0:5975af170e43 | 99 | */ |
jksoft | 0:5975af170e43 | 100 | void textColor(int color); |
jksoft | 0:5975af170e43 | 101 | |
jksoft | 0:5975af170e43 | 102 | /* Function: backgroundColor |
jksoft | 0:5975af170e43 | 103 | * Set backgound color |
jksoft | 0:5975af170e43 | 104 | * Variables: |
jksoft | 0:5975af170e43 | 105 | * color - Text color code |
jksoft | 0:5975af170e43 | 106 | */ |
jksoft | 0:5975af170e43 | 107 | void backgroundColor(int color); |
jksoft | 0:5975af170e43 | 108 | |
jksoft | 0:5975af170e43 | 109 | /* Function: cls |
jksoft | 0:5975af170e43 | 110 | * Clear the screen, and locate to 0,0 |
jksoft | 0:5975af170e43 | 111 | */ |
jksoft | 0:5975af170e43 | 112 | void cls(); |
jksoft | 0:5975af170e43 | 113 | |
jksoft | 0:5975af170e43 | 114 | /* Function: reset |
jksoft | 0:5975af170e43 | 115 | * Set default text/backgroudn color, clear the screen, and locate to 0,0 |
jksoft | 0:5975af170e43 | 116 | */ |
jksoft | 0:5975af170e43 | 117 | void reset(); |
jksoft | 0:5975af170e43 | 118 | |
jksoft | 0:5975af170e43 | 119 | /* Function: fillRect |
jksoft | 0:5975af170e43 | 120 | * Fill secreen with specified color |
jksoft | 0:5975af170e43 | 121 | * Variables: |
jksoft | 0:5975af170e43 | 122 | * buffer - number of screen buffer (0 - 3) |
jksoft | 0:5975af170e43 | 123 | * width - width of rectangle (1 - 320) |
jksoft | 0:5975af170e43 | 124 | * hight - hight of rectangle (1 - 240) |
jksoft | 0:5975af170e43 | 125 | * x - x coordinate (0 - 319) of upper left point |
jksoft | 0:5975af170e43 | 126 | * y - y coordinate (0 - 239) of upper left point |
jksoft | 0:5975af170e43 | 127 | * color - RGB555 color code 0rrrrrgggggbbbbb |
jksoft | 0:5975af170e43 | 128 | */ |
jksoft | 0:5975af170e43 | 129 | void fillRect(int buffer, int width, int hight, int x, int y, int color ); |
jksoft | 0:5975af170e43 | 130 | |
jksoft | 0:5975af170e43 | 131 | /* Function: drawLine |
jksoft | 0:5975af170e43 | 132 | * draw line from (x0, y0) to (x1, y1) |
jksoft | 0:5975af170e43 | 133 | * Variables: |
jksoft | 0:5975af170e43 | 134 | * buffer - number of screen buffer (0 - 3) |
jksoft | 0:5975af170e43 | 135 | * x0 - coordinate x (0 - 319) of start point |
jksoft | 0:5975af170e43 | 136 | * y0 - coordinate y (0 - 319) of start point |
jksoft | 0:5975af170e43 | 137 | * x1 - coordinate x (0 - 319) of end point |
jksoft | 0:5975af170e43 | 138 | * y1 - coordinate y (0 - 319) of end point |
jksoft | 0:5975af170e43 | 139 | * color - RGB555 color code 0rrrrrgggggbbbbb |
jksoft | 0:5975af170e43 | 140 | */ |
jksoft | 0:5975af170e43 | 141 | void drawLine(int buffer, int x0, int y0, int x1, int y1, int color); |
jksoft | 0:5975af170e43 | 142 | void pic(int buffer ,int num); |
jksoft | 0:5975af170e43 | 143 | void chg_buff(int buffer); |
jksoft | 0:5975af170e43 | 144 | protected: |
jksoft | 0:5975af170e43 | 145 | virtual int _putc(int c); |
jksoft | 0:5975af170e43 | 146 | virtual int _getc(); |
jksoft | 0:5975af170e43 | 147 | void newline(); |
jksoft | 0:5975af170e43 | 148 | |
jksoft | 0:5975af170e43 | 149 | Serial _serial; |
jksoft | 0:5975af170e43 | 150 | int _baud; |
jksoft | 0:5975af170e43 | 151 | int _row; |
jksoft | 0:5975af170e43 | 152 | int _column; |
jksoft | 0:5975af170e43 | 153 | int _columns; // Number of max columns |
jksoft | 0:5975af170e43 | 154 | int _rows; // Number of max rows |
jksoft | 0:5975af170e43 | 155 | }; |
jksoft | 0:5975af170e43 | 156 | |
jksoft | 0:5975af170e43 | 157 | #endif |
jksoft | 0:5975af170e43 | 158 | } |