AD-128160-UART制御用のライブラリ http://www.aitendo.co.jp/product/3119 gingaxさんのプログラムを参考に作らせてもらっています。 http://mbed.org/users/akira/libraries/AD128160/m159hi
Dependents: AD128160_HelloWorld
AD128160.h@3:d15cda2a5e91, 2011-12-13 (annotated)
- Committer:
- nucho
- Date:
- Tue Dec 13 15:37:06 2011 +0000
- Revision:
- 3:d15cda2a5e91
- Parent:
- 2:6f2db745808e
add textsetting(color,font size)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:2e2f3b389d8a | 1 | #ifndef AD128160_H_ |
nucho | 0:2e2f3b389d8a | 2 | #define AD128160_H_ |
nucho | 0:2e2f3b389d8a | 3 | |
nucho | 0:2e2f3b389d8a | 4 | #include "mbed.h" |
nucho | 0:2e2f3b389d8a | 5 | |
nucho | 3:d15cda2a5e91 | 6 | //#define LCD_ROWS 10 |
nucho | 3:d15cda2a5e91 | 7 | //#define LCD_COLS 16 |
nucho | 2:6f2db745808e | 8 | #define LCD_WIDTH 128 |
nucho | 2:6f2db745808e | 9 | #define LCD_HEIGHT 160 |
nucho | 0:2e2f3b389d8a | 10 | /** An interface for the AD128160 LCD display |
nucho | 0:2e2f3b389d8a | 11 | * |
nucho | 0:2e2f3b389d8a | 12 | */ |
nucho | 1:328d8c8f804e | 13 | |
nucho | 0:2e2f3b389d8a | 14 | class AD128160: public Stream { |
nucho | 0:2e2f3b389d8a | 15 | public: |
nucho | 0:2e2f3b389d8a | 16 | /** Create and AD128160 interface, using a tx and one DigitalOut interfaces |
nucho | 0:2e2f3b389d8a | 17 | * |
nucho | 3:d15cda2a5e91 | 18 | * @param tx A serialport(tx) |
nucho | 0:2e2f3b389d8a | 19 | * @param reset A DigitalOut |
nucho | 0:2e2f3b389d8a | 20 | */ |
nucho | 0:2e2f3b389d8a | 21 | AD128160(PinName tx,PinName reset); |
nucho | 0:2e2f3b389d8a | 22 | |
nucho | 0:2e2f3b389d8a | 23 | /** Set a pixel on te screen |
nucho | 0:2e2f3b389d8a | 24 | * |
nucho | 0:2e2f3b389d8a | 25 | * @param x horizontal position from left |
nucho | 0:2e2f3b389d8a | 26 | * @param y vertical position from top |
nucho | 0:2e2f3b389d8a | 27 | */ |
nucho | 0:2e2f3b389d8a | 28 | void pixel(int x0,int y0); |
nucho | 0:2e2f3b389d8a | 29 | |
nucho | 0:2e2f3b389d8a | 30 | /** Draw a box on the screen |
nucho | 0:2e2f3b389d8a | 31 | * |
nucho | 0:2e2f3b389d8a | 32 | * @param x0 start point of box(X) |
nucho | 0:2e2f3b389d8a | 33 | * @param y0 start point of box(Y) |
nucho | 0:2e2f3b389d8a | 34 | * @param x1 end point of box(X) |
nucho | 0:2e2f3b389d8a | 35 | * @param y1 end poinrt of box(Y) |
nucho | 0:2e2f3b389d8a | 36 | * @param paint Setting the fill.If set of 1, fill of box. |
nucho | 0:2e2f3b389d8a | 37 | */ |
nucho | 0:2e2f3b389d8a | 38 | void box(int x0,int y0,int x1,int y1,int paint); |
nucho | 0:2e2f3b389d8a | 39 | |
nucho | 0:2e2f3b389d8a | 40 | /** Draw a line on the screen |
nucho | 0:2e2f3b389d8a | 41 | * |
nucho | 0:2e2f3b389d8a | 42 | * @param x0 start point of line(X) |
nucho | 0:2e2f3b389d8a | 43 | * @param y0 start point of line(Y) |
nucho | 0:2e2f3b389d8a | 44 | * @param x1 end point of line(X) |
nucho | 0:2e2f3b389d8a | 45 | * @param y1 end point of line(Y) |
nucho | 0:2e2f3b389d8a | 46 | */ |
nucho | 0:2e2f3b389d8a | 47 | void line(int x0,int y0,int x1,int y1); |
nucho | 0:2e2f3b389d8a | 48 | |
nucho | 0:2e2f3b389d8a | 49 | /** Draw a circle on the screen |
nucho | 0:2e2f3b389d8a | 50 | * |
nucho | 0:2e2f3b389d8a | 51 | * @param x0 center point of circle(X) |
nucho | 0:2e2f3b389d8a | 52 | * @param y0 centor point of circle(Y) |
nucho | 0:2e2f3b389d8a | 53 | * @param r circle of radius |
nucho | 0:2e2f3b389d8a | 54 | * @param paint Setting the fill.If set of 1, fill of circle. |
nucho | 0:2e2f3b389d8a | 55 | */ |
nucho | 0:2e2f3b389d8a | 56 | void circle(int x0,int y0,int r,int paint); |
nucho | 0:2e2f3b389d8a | 57 | |
nucho | 0:2e2f3b389d8a | 58 | /** Locate to a screen column and row |
nucho | 0:2e2f3b389d8a | 59 | * |
nucho | 0:2e2f3b389d8a | 60 | * @param column The horizontal position from the left, indexed from 0 |
nucho | 0:2e2f3b389d8a | 61 | * @param row The vertical position from the top, indexed from 0 |
nucho | 0:2e2f3b389d8a | 62 | */ |
nucho | 0:2e2f3b389d8a | 63 | void locate(int column, int row); |
nucho | 0:2e2f3b389d8a | 64 | |
nucho | 0:2e2f3b389d8a | 65 | /** Configure of the LCD's back light blightness |
nucho | 0:2e2f3b389d8a | 66 | * |
nucho | 0:2e2f3b389d8a | 67 | * @param value brightness value. range of 0-500 |
nucho | 0:2e2f3b389d8a | 68 | */ |
nucho | 0:2e2f3b389d8a | 69 | void brightness(int value); |
nucho | 0:2e2f3b389d8a | 70 | |
nucho | 0:2e2f3b389d8a | 71 | /** Set a color |
nucho | 0:2e2f3b389d8a | 72 | * |
nucho | 3:d15cda2a5e91 | 73 | * @param rgb 2byte colour in format RGB:56 |
nucho | 0:2e2f3b389d8a | 74 | */ |
nucho | 0:2e2f3b389d8a | 75 | void color(int rgb); |
nucho | 0:2e2f3b389d8a | 76 | |
nucho | 3:d15cda2a5e91 | 77 | /** Setting a text back ground |
nucho | 0:2e2f3b389d8a | 78 | * |
nucho | 3:d15cda2a5e91 | 79 | * @param mode If mode is true,text'backgroud is on. |
nucho | 3:d15cda2a5e91 | 80 | * @param rgb 2byte colour in format RGB:565 |
nucho | 0:2e2f3b389d8a | 81 | */ |
nucho | 3:d15cda2a5e91 | 82 | void textBackground(bool mode,int rgb); |
nucho | 3:d15cda2a5e91 | 83 | |
nucho | 0:2e2f3b389d8a | 84 | /** Configure of the LCD speed |
nucho | 0:2e2f3b389d8a | 85 | * |
nucho | 0:2e2f3b389d8a | 86 | * @param baud baudrate of the LCD |
nucho | 0:2e2f3b389d8a | 87 | */ |
nucho | 0:2e2f3b389d8a | 88 | void speed(int baud); |
nucho | 0:2e2f3b389d8a | 89 | |
nucho | 0:2e2f3b389d8a | 90 | /** Clear the screen and locate to 0,0 */ |
nucho | 0:2e2f3b389d8a | 91 | void cls(); |
nucho | 0:2e2f3b389d8a | 92 | |
nucho | 0:2e2f3b389d8a | 93 | /** Reset of the LCD */ |
nucho | 0:2e2f3b389d8a | 94 | void reset(); |
nucho | 0:2e2f3b389d8a | 95 | |
nucho | 0:2e2f3b389d8a | 96 | /** Write a string to the LCD |
nucho | 0:2e2f3b389d8a | 97 | * |
nucho | 0:2e2f3b389d8a | 98 | * @param s The string to write to the display |
nucho | 0:2e2f3b389d8a | 99 | */ |
nucho | 3:d15cda2a5e91 | 100 | void puts(char* s); |
nucho | 3:d15cda2a5e91 | 101 | |
nucho | 3:d15cda2a5e91 | 102 | /** Setting a text size and color.If this function, column and row is 0,0. |
nucho | 3:d15cda2a5e91 | 103 | * |
nucho | 3:d15cda2a5e91 | 104 | * @param size text size(0:6x10 1:7x13 2:8x16 3:10x20 4:16x32) |
nucho | 3:d15cda2a5e91 | 105 | * @param rgb 2byte colour in format RGB:565 |
nucho | 3:d15cda2a5e91 | 106 | */ |
nucho | 3:d15cda2a5e91 | 107 | void textSetting(int size,int rgb); |
nucho | 0:2e2f3b389d8a | 108 | |
nucho | 0:2e2f3b389d8a | 109 | #if DOXYGEN_ONLY |
nucho | 0:2e2f3b389d8a | 110 | /** Write a character to the LCD |
nucho | 0:2e2f3b389d8a | 111 | * |
nucho | 0:2e2f3b389d8a | 112 | * @param c The character to write to the display |
nucho | 0:2e2f3b389d8a | 113 | */ |
nucho | 0:2e2f3b389d8a | 114 | int putc(int c); |
nucho | 0:2e2f3b389d8a | 115 | |
nucho | 0:2e2f3b389d8a | 116 | /** Write a formated string to the LCD |
nucho | 0:2e2f3b389d8a | 117 | * |
nucho | 0:2e2f3b389d8a | 118 | * @param format A printf-style format string, followed by the |
nucho | 0:2e2f3b389d8a | 119 | * variables to use in formating the string. |
nucho | 0:2e2f3b389d8a | 120 | */ |
nucho | 0:2e2f3b389d8a | 121 | int printf(const char* format, ...); |
nucho | 0:2e2f3b389d8a | 122 | #endif |
nucho | 2:6f2db745808e | 123 | /** get of the LCD width |
nucho | 2:6f2db745808e | 124 | * |
nucho | 2:6f2db745808e | 125 | * @return LCD width |
nucho | 2:6f2db745808e | 126 | */ |
nucho | 2:6f2db745808e | 127 | int width(); |
nucho | 2:6f2db745808e | 128 | |
nucho | 2:6f2db745808e | 129 | /** get of the LCD height |
nucho | 2:6f2db745808e | 130 | * |
nucho | 2:6f2db745808e | 131 | * @return LCD height |
nucho | 2:6f2db745808e | 132 | */ |
nucho | 2:6f2db745808e | 133 | int height(); |
nucho | 2:6f2db745808e | 134 | |
nucho | 3:d15cda2a5e91 | 135 | /** get of the LCD colums |
nucho | 2:6f2db745808e | 136 | * |
nucho | 2:6f2db745808e | 137 | * @return LCD colums |
nucho | 2:6f2db745808e | 138 | */ |
nucho | 2:6f2db745808e | 139 | int columns(); |
nucho | 2:6f2db745808e | 140 | |
nucho | 3:d15cda2a5e91 | 141 | /** get of the LCD rows |
nucho | 2:6f2db745808e | 142 | * |
nucho | 2:6f2db745808e | 143 | * @return LCD rows |
nucho | 2:6f2db745808e | 144 | */ |
nucho | 2:6f2db745808e | 145 | int rows(); |
nucho | 0:2e2f3b389d8a | 146 | |
nucho | 0:2e2f3b389d8a | 147 | void bmp(int x0,int y0,int bmp_n); |
nucho | 0:2e2f3b389d8a | 148 | |
nucho | 0:2e2f3b389d8a | 149 | protected: |
nucho | 3:d15cda2a5e91 | 150 | void init(); |
nucho | 3:d15cda2a5e91 | 151 | void newline(); |
nucho | 3:d15cda2a5e91 | 152 | void cwrite(int command,unsigned char* data,int length); |
nucho | 0:2e2f3b389d8a | 153 | virtual int _putc(int c); |
nucho | 0:2e2f3b389d8a | 154 | virtual int _getc() { |
nucho | 0:2e2f3b389d8a | 155 | return 0; |
nucho | 0:2e2f3b389d8a | 156 | } |
nucho | 0:2e2f3b389d8a | 157 | |
nucho | 3:d15cda2a5e91 | 158 | Serial _device; // tx |
nucho | 0:2e2f3b389d8a | 159 | DigitalOut _rst; // LCD RST (Reset) |
nucho | 3:d15cda2a5e91 | 160 | int _row, _column;//now row and col |
nucho | 3:d15cda2a5e91 | 161 | int _font_x,_font_y;//font size |
nucho | 3:d15cda2a5e91 | 162 | int _max_columns,_max_rows;//max row and col |
nucho | 0:2e2f3b389d8a | 163 | |
nucho | 0:2e2f3b389d8a | 164 | }; |
nucho | 0:2e2f3b389d8a | 165 | |
nucho | 0:2e2f3b389d8a | 166 | |
nucho | 0:2e2f3b389d8a | 167 | #endif |