Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.
Dependents: afero_poc15_180216 afero_poc15_180223 afero_poc15_180302 afero_poc15_180403R ... more
Fork of UniGraphic by
UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.
Inits/SEPS225.cpp@31:ef4225cef157, 2016-04-01 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Apr 01 06:00:02 2016 +0000
- Revision:
- 31:ef4225cef157
- Parent:
- 24:1a2ebae1d289
The width and height of SEPS225 are 0x80, but I mistook it to 0x7F in the first version and have fixed them in later version, but in the newest version we had the return of 0x7F, so I try to fix them to 0x80 again.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 23:d0eb35bbd2f3 | 1 | #include "mbed.h" |
Rhyme | 23:d0eb35bbd2f3 | 2 | |
Rhyme | 23:d0eb35bbd2f3 | 3 | #include "SEPS225.h" |
Rhyme | 23:d0eb35bbd2f3 | 4 | |
Rhyme | 23:d0eb35bbd2f3 | 5 | #ifndef OLED_LCD_REG_H_ |
Rhyme | 23:d0eb35bbd2f3 | 6 | #define OLED_LCD_REG_H_ |
Rhyme | 23:d0eb35bbd2f3 | 7 | |
Rhyme | 23:d0eb35bbd2f3 | 8 | #define CMD_INDEX 0x00 |
Rhyme | 23:d0eb35bbd2f3 | 9 | #define CMD_STATUS_RD 0x01 |
Rhyme | 23:d0eb35bbd2f3 | 10 | #define CMD_OSC_CTL 0x02 |
Rhyme | 23:d0eb35bbd2f3 | 11 | #define CMD_CLOCK_DIV 0x03 |
Rhyme | 23:d0eb35bbd2f3 | 12 | #define CMD_REDUCE_CURRENT 0x04 |
Rhyme | 23:d0eb35bbd2f3 | 13 | #define CMD_SOFT_RST 0x05 |
Rhyme | 23:d0eb35bbd2f3 | 14 | #define CMD_DISP_ON_OFF 0x06 |
Rhyme | 23:d0eb35bbd2f3 | 15 | #define CMD_PRECHARGE_TIME_R 0x08 |
Rhyme | 23:d0eb35bbd2f3 | 16 | #define CMD_PRECHARGE_TIME_G 0x09 |
Rhyme | 23:d0eb35bbd2f3 | 17 | #define CMD_PRECHARGE_TIME_B 0x0A |
Rhyme | 23:d0eb35bbd2f3 | 18 | #define CMD_PRECHARGE_CURRENT_R 0x0B |
Rhyme | 23:d0eb35bbd2f3 | 19 | #define CMD_PRECHARGE_CURRENT_G 0x0C |
Rhyme | 23:d0eb35bbd2f3 | 20 | #define CMD_PRECHARGE_CURRENT_B 0x0D |
Rhyme | 23:d0eb35bbd2f3 | 21 | #define CMD_DRIVING_CURRENT_R 0x10 |
Rhyme | 23:d0eb35bbd2f3 | 22 | #define CMD_DRIVING_CURRENT_G 0x11 |
Rhyme | 23:d0eb35bbd2f3 | 23 | #define CMD_DRIVING_CURRENT_B 0x12 |
Rhyme | 23:d0eb35bbd2f3 | 24 | #define CMD_DISPLAY_MODE_SET 0x13 |
Rhyme | 23:d0eb35bbd2f3 | 25 | #define CMD_RGB_IF 0x14 |
Rhyme | 23:d0eb35bbd2f3 | 26 | #define CMD_RGB_POL 0x15 |
Rhyme | 23:d0eb35bbd2f3 | 27 | #define CMD_MEMORY_WRITE_MODE 0x16 |
Rhyme | 23:d0eb35bbd2f3 | 28 | #define CMD_MX1_ADDR 0x17 |
Rhyme | 23:d0eb35bbd2f3 | 29 | #define CMD_MX2_ADDR 0x18 |
Rhyme | 23:d0eb35bbd2f3 | 30 | #define CMD_MY1_ADDR 0x19 |
Rhyme | 23:d0eb35bbd2f3 | 31 | #define CMD_MY2_ADDR 0x1A |
Rhyme | 23:d0eb35bbd2f3 | 32 | #define CMD_MEMORY_ACCESS_POINTER_X 0x20 |
Rhyme | 23:d0eb35bbd2f3 | 33 | #define CMD_MEMORY_ACCESS_POINTER_Y 0x21 |
Rhyme | 23:d0eb35bbd2f3 | 34 | #define CMD_DDRAM_DATA_ACCESS_PORT 0x22 |
Rhyme | 23:d0eb35bbd2f3 | 35 | #define CMD_DUTY 0x28 |
Rhyme | 23:d0eb35bbd2f3 | 36 | #define CMD_DSL 0x29 |
Rhyme | 23:d0eb35bbd2f3 | 37 | #define CMD_D1_DDRAM_FAC 0x2E |
Rhyme | 23:d0eb35bbd2f3 | 38 | #define CMD_D1_DDRAM_FAR 0x2F |
Rhyme | 23:d0eb35bbd2f3 | 39 | #define CMD_D2_DDRAM_SAC 0x31 |
Rhyme | 23:d0eb35bbd2f3 | 40 | #define CMD_D2_DDRAM_SAR 0x32 |
Rhyme | 23:d0eb35bbd2f3 | 41 | #define CMD_SCR1_FX1 0x33 |
Rhyme | 23:d0eb35bbd2f3 | 42 | #define CMD_SCR1_FX2 0x34 |
Rhyme | 23:d0eb35bbd2f3 | 43 | #define CMD_SCR1_FY1 0x35 |
Rhyme | 23:d0eb35bbd2f3 | 44 | #define CMD_SCR1_FY2 0x36 |
Rhyme | 23:d0eb35bbd2f3 | 45 | #define CMD_SCR2_SX1 0x37 |
Rhyme | 23:d0eb35bbd2f3 | 46 | #define CMD_SCR2_SX2 0x38 |
Rhyme | 23:d0eb35bbd2f3 | 47 | #define CMD_SCR2_SY1 0x39 |
Rhyme | 23:d0eb35bbd2f3 | 48 | #define CMD_SCR2_SY2 0x3A |
Rhyme | 23:d0eb35bbd2f3 | 49 | #define CMD_SCREEN_SAVER_CONTEROL 0x3B |
Rhyme | 23:d0eb35bbd2f3 | 50 | #define CMD_SS_SLEEP_TIMER 0x3C |
Rhyme | 23:d0eb35bbd2f3 | 51 | #define CMD_SCREEN_SAVER_MODE 0x3D |
Rhyme | 23:d0eb35bbd2f3 | 52 | #define CMD_SS_SCR1_FU 0x3E |
Rhyme | 23:d0eb35bbd2f3 | 53 | #define CMD_SS_SCR1_MXY 0x3F |
Rhyme | 23:d0eb35bbd2f3 | 54 | #define CMD_SS_SCR2_FU 0x40 |
Rhyme | 23:d0eb35bbd2f3 | 55 | #define CMD_SS_SCR2_MXY 0x41 |
Rhyme | 23:d0eb35bbd2f3 | 56 | #define CMD_MOVING_DIRECTION 0x42 |
Rhyme | 23:d0eb35bbd2f3 | 57 | #define CMD_SS_SCR2_SX1 0x47 |
Rhyme | 23:d0eb35bbd2f3 | 58 | #define CMD_SS_SCR2_SX2 0x48 |
Rhyme | 23:d0eb35bbd2f3 | 59 | #define CMD_SS_SCR2_SY1 0x49 |
Rhyme | 23:d0eb35bbd2f3 | 60 | #define CMD_SS_SCR2_SY2 0x4A |
Rhyme | 23:d0eb35bbd2f3 | 61 | #define CMD_IREF 0x80 |
Rhyme | 23:d0eb35bbd2f3 | 62 | |
Rhyme | 23:d0eb35bbd2f3 | 63 | |
Rhyme | 23:d0eb35bbd2f3 | 64 | #define LCD_RESET 0 |
Rhyme | 23:d0eb35bbd2f3 | 65 | #define LCD_CLEAR 1 |
Rhyme | 23:d0eb35bbd2f3 | 66 | #define LCD_PRINT 2 |
Rhyme | 23:d0eb35bbd2f3 | 67 | |
Rhyme | 23:d0eb35bbd2f3 | 68 | |
Rhyme | 23:d0eb35bbd2f3 | 69 | #define COLOR_RED 0xF100 |
Rhyme | 23:d0eb35bbd2f3 | 70 | #define COLOR_GREEN 0x07E0 |
Rhyme | 23:d0eb35bbd2f3 | 71 | #define COLOR_BLUE 0x001F |
Rhyme | 23:d0eb35bbd2f3 | 72 | #define COLOR_CYAN 0x07FF |
Rhyme | 23:d0eb35bbd2f3 | 73 | #define COLOR_MAGENTA 0xF11F |
Rhyme | 23:d0eb35bbd2f3 | 74 | #define COLOR_YELLOW 0xFFE0 |
Rhyme | 23:d0eb35bbd2f3 | 75 | #define COLOR_BLACK 0x0000 |
Rhyme | 23:d0eb35bbd2f3 | 76 | #define COLOR_WHITE 0xFFFF |
Rhyme | 23:d0eb35bbd2f3 | 77 | |
Rhyme | 31:ef4225cef157 | 78 | #define OLED_WIDTH 0x80 |
Rhyme | 31:ef4225cef157 | 79 | #define OLED_HEIGHT 0x80 |
Rhyme | 23:d0eb35bbd2f3 | 80 | |
Rhyme | 23:d0eb35bbd2f3 | 81 | #endif /* OLED_LCD_REG_H_ */ |
Rhyme | 23:d0eb35bbd2f3 | 82 | |
Rhyme | 23:d0eb35bbd2f3 | 83 | SEPS225::SEPS225(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) |
Rhyme | 23:d0eb35bbd2f3 | 84 | : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name) |
Rhyme | 23:d0eb35bbd2f3 | 85 | { |
Rhyme | 23:d0eb35bbd2f3 | 86 | hw_reset(); |
Rhyme | 23:d0eb35bbd2f3 | 87 | BusEnable(true); |
Rhyme | 23:d0eb35bbd2f3 | 88 | identify(); // will collect tftID and set mipistd flag |
Rhyme | 23:d0eb35bbd2f3 | 89 | init(); |
Rhyme | 23:d0eb35bbd2f3 | 90 | auto_gram_read_format(); |
Rhyme | 23:d0eb35bbd2f3 | 91 | set_orientation(0); |
Rhyme | 23:d0eb35bbd2f3 | 92 | cls(); |
Rhyme | 23:d0eb35bbd2f3 | 93 | FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. |
Rhyme | 23:d0eb35bbd2f3 | 94 | locate(0,0); |
Rhyme | 23:d0eb35bbd2f3 | 95 | } |
Rhyme | 23:d0eb35bbd2f3 | 96 | SEPS225::SEPS225(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) |
Rhyme | 23:d0eb35bbd2f3 | 97 | : TFT(displayproto, buspins, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name) |
Rhyme | 23:d0eb35bbd2f3 | 98 | { |
Rhyme | 23:d0eb35bbd2f3 | 99 | hw_reset(); |
Rhyme | 23:d0eb35bbd2f3 | 100 | BusEnable(true); |
Rhyme | 23:d0eb35bbd2f3 | 101 | identify(); // will collect tftID and set mipistd flag |
Rhyme | 23:d0eb35bbd2f3 | 102 | init(); |
Rhyme | 23:d0eb35bbd2f3 | 103 | auto_gram_read_format(); |
Rhyme | 23:d0eb35bbd2f3 | 104 | set_orientation(0); |
Rhyme | 23:d0eb35bbd2f3 | 105 | cls(); |
Rhyme | 23:d0eb35bbd2f3 | 106 | FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. |
Rhyme | 23:d0eb35bbd2f3 | 107 | locate(0,0); |
Rhyme | 23:d0eb35bbd2f3 | 108 | } |
Rhyme | 23:d0eb35bbd2f3 | 109 | SEPS225::SEPS225(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X , unsigned int LCDSIZE_Y) |
Rhyme | 23:d0eb35bbd2f3 | 110 | : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name) |
Rhyme | 23:d0eb35bbd2f3 | 111 | { |
Rhyme | 23:d0eb35bbd2f3 | 112 | _cs = new DigitalOut(CS, 1) ; |
Rhyme | 23:d0eb35bbd2f3 | 113 | _rs = new DigitalOut(DC, 1) ; |
Rhyme | 23:d0eb35bbd2f3 | 114 | |
Rhyme | 23:d0eb35bbd2f3 | 115 | hw_reset(); //TFT class forwards to Protocol class |
Rhyme | 23:d0eb35bbd2f3 | 116 | BusEnable(true); //TFT class forwards to Protocol class |
Rhyme | 23:d0eb35bbd2f3 | 117 | identify(); // will collect tftID and set mipistd flag |
Rhyme | 23:d0eb35bbd2f3 | 118 | init(); // per display custom init cmd sequence, implemented here |
Rhyme | 23:d0eb35bbd2f3 | 119 | auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly |
Rhyme | 23:d0eb35bbd2f3 | 120 | set_orientation(0); //TFT class does for MIPI standard and some ILIxxx |
Rhyme | 23:d0eb35bbd2f3 | 121 | FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. |
Rhyme | 23:d0eb35bbd2f3 | 122 | cls(); |
Rhyme | 23:d0eb35bbd2f3 | 123 | locate(0,0); |
Rhyme | 23:d0eb35bbd2f3 | 124 | } |
Rhyme | 23:d0eb35bbd2f3 | 125 | |
Rhyme | 23:d0eb35bbd2f3 | 126 | // reset and init the lcd controller |
Rhyme | 23:d0eb35bbd2f3 | 127 | void SEPS225::init() |
Rhyme | 23:d0eb35bbd2f3 | 128 | { |
Rhyme | 23:d0eb35bbd2f3 | 129 | #if 0 |
Rhyme | 23:d0eb35bbd2f3 | 130 | oled = new SPI(PIN_OLED_MOSI, PIN_OLED_MISO, PIN_OLED_SCLK) ; |
Rhyme | 23:d0eb35bbd2f3 | 131 | oled_cs = new DigitalOut(PIN_OLED_CS, 1) ; |
Rhyme | 23:d0eb35bbd2f3 | 132 | oled_rs = new DigitalOut(PIN_OLED_RS, 1) ; |
Rhyme | 23:d0eb35bbd2f3 | 133 | oled->format(8, 0) ; |
Rhyme | 23:d0eb35bbd2f3 | 134 | oled->frequency(1000000) ; |
Rhyme | 23:d0eb35bbd2f3 | 135 | #endif |
Rhyme | 23:d0eb35bbd2f3 | 136 | |
Rhyme | 23:d0eb35bbd2f3 | 137 | reg_write(CMD_REDUCE_CURRENT, 0x01) ; wait(0.01) ; // oled_delay(100000) ; |
Rhyme | 23:d0eb35bbd2f3 | 138 | reg_write(CMD_REDUCE_CURRENT, 0x00) ; wait(0.01) ; // oled_delay(100000) ; |
Rhyme | 23:d0eb35bbd2f3 | 139 | |
Rhyme | 23:d0eb35bbd2f3 | 140 | reg_write(CMD_OSC_CTL, 0x01) ; |
Rhyme | 23:d0eb35bbd2f3 | 141 | reg_write(CMD_CLOCK_DIV, 0x30) ; |
Rhyme | 24:1a2ebae1d289 | 142 | // reg_write(CMD_PRECHARGE_TIME_R, 0x03) ; |
Rhyme | 24:1a2ebae1d289 | 143 | // reg_write(CMD_PRECHARGE_TIME_G, 0x04) ; |
Rhyme | 24:1a2ebae1d289 | 144 | // reg_write(CMD_PRECHARGE_TIME_B, 0x05) ; |
Rhyme | 24:1a2ebae1d289 | 145 | reg_write(CMD_PRECHARGE_TIME_R, 0x0E) ; |
Rhyme | 24:1a2ebae1d289 | 146 | reg_write(CMD_PRECHARGE_TIME_G, 0x0E) ; |
Rhyme | 24:1a2ebae1d289 | 147 | reg_write(CMD_PRECHARGE_TIME_B, 0x0E) ; |
Rhyme | 24:1a2ebae1d289 | 148 | // reg_write(CMD_PRECHARGE_CURRENT_R, 0x0B) ; |
Rhyme | 24:1a2ebae1d289 | 149 | // reg_write(CMD_PRECHARGE_CURRENT_G, 0x0B) ; |
Rhyme | 24:1a2ebae1d289 | 150 | // reg_write(CMD_PRECHARGE_CURRENT_B, 0x0B) ; |
Rhyme | 24:1a2ebae1d289 | 151 | reg_write(CMD_PRECHARGE_CURRENT_R, 0x3E) ; |
Rhyme | 24:1a2ebae1d289 | 152 | reg_write(CMD_PRECHARGE_CURRENT_G, 0x32) ; |
Rhyme | 24:1a2ebae1d289 | 153 | reg_write(CMD_PRECHARGE_CURRENT_B, 0x3D) ; |
Rhyme | 24:1a2ebae1d289 | 154 | reg_write(CMD_DRIVING_CURRENT_R, 0x3E) ; |
Rhyme | 24:1a2ebae1d289 | 155 | reg_write(CMD_DRIVING_CURRENT_G, 0x32) ; |
Rhyme | 24:1a2ebae1d289 | 156 | reg_write(CMD_DRIVING_CURRENT_B, 0x3D) ; |
Rhyme | 24:1a2ebae1d289 | 157 | // reg_write(CMD_DRIVING_CURRENT_R, 0x0B) ; |
Rhyme | 24:1a2ebae1d289 | 158 | // reg_write(CMD_DRIVING_CURRENT_G, 0x0B) ; |
Rhyme | 24:1a2ebae1d289 | 159 | // reg_write(CMD_DRIVING_CURRENT_B, 0x0B) ; |
Rhyme | 23:d0eb35bbd2f3 | 160 | // Memory Write Mode |
Rhyme | 23:d0eb35bbd2f3 | 161 | // 16bit * 1 transfer mode, R[5], G[6], B[5] |
Rhyme | 23:d0eb35bbd2f3 | 162 | // H:Inc, V:Inc, Method:V |
Rhyme | 23:d0eb35bbd2f3 | 163 | // reg_write(CMD_MEMORY_WRITE_MODE, 0x27) ; |
Rhyme | 23:d0eb35bbd2f3 | 164 | reg_write(CMD_RGB_IF, 0x11) ; |
Rhyme | 23:d0eb35bbd2f3 | 165 | // reg_write(CMD_MEMORY_WRITE_MODE, 0x66) ; |
Rhyme | 23:d0eb35bbd2f3 | 166 | reg_write(CMD_MEMORY_WRITE_MODE, 0x26) ; |
Rhyme | 23:d0eb35bbd2f3 | 167 | reg_write(CMD_IREF, 0x01) ; // Voltage ctrl by internal |
Rhyme | 23:d0eb35bbd2f3 | 168 | // |
Rhyme | 23:d0eb35bbd2f3 | 169 | reg_write(CMD_MX1_ADDR, 0x00) ; |
Rhyme | 23:d0eb35bbd2f3 | 170 | reg_write(CMD_MX2_ADDR, 0x7F) ; |
Rhyme | 23:d0eb35bbd2f3 | 171 | reg_write(CMD_MY1_ADDR, 0x00) ; |
Rhyme | 23:d0eb35bbd2f3 | 172 | reg_write(CMD_MY2_ADDR, 0x7F) ; |
Rhyme | 23:d0eb35bbd2f3 | 173 | reg_write(CMD_SCR1_FX1, 0x00) ; |
Rhyme | 23:d0eb35bbd2f3 | 174 | reg_write(CMD_SCR1_FX2, 0x7F) ; |
Rhyme | 23:d0eb35bbd2f3 | 175 | reg_write(CMD_SCR1_FY1, 0x00) ; |
Rhyme | 23:d0eb35bbd2f3 | 176 | reg_write(CMD_SCR1_FY2, 0x7F) ; |
Rhyme | 23:d0eb35bbd2f3 | 177 | reg_write(CMD_DSL, 0x00) ; // display start line |
Rhyme | 23:d0eb35bbd2f3 | 178 | reg_write(CMD_DUTY, 0x7F) ; // |
Rhyme | 23:d0eb35bbd2f3 | 179 | reg_write(CMD_DISPLAY_MODE_SET, 0x04) ; // was 0x00 |
Rhyme | 23:d0eb35bbd2f3 | 180 | // reg_write(CMD_DISPLAY_MODE_SET, 0x00) ; // was 0x00 |
Rhyme | 23:d0eb35bbd2f3 | 181 | reg_write(CMD_D1_DDRAM_FAC, 0x00) ; |
Rhyme | 23:d0eb35bbd2f3 | 182 | reg_write(CMD_D1_DDRAM_FAR, 0x00) ; |
Rhyme | 23:d0eb35bbd2f3 | 183 | // Clear |
Rhyme | 23:d0eb35bbd2f3 | 184 | // oled_lcd_clear() ; |
Rhyme | 23:d0eb35bbd2f3 | 185 | cls() ; |
Rhyme | 23:d0eb35bbd2f3 | 186 | |
Rhyme | 23:d0eb35bbd2f3 | 187 | // DISP_ON_OFF |
Rhyme | 23:d0eb35bbd2f3 | 188 | // reg_write(CMD_DISP_ON_OFF, 0x01) ; |
Rhyme | 23:d0eb35bbd2f3 | 189 | } |
Rhyme | 23:d0eb35bbd2f3 | 190 | |
Rhyme | 23:d0eb35bbd2f3 | 191 | /** Draw a pixel in the specified color. |
Rhyme | 23:d0eb35bbd2f3 | 192 | * @param x is the horizontal offset to this pixel. |
Rhyme | 23:d0eb35bbd2f3 | 193 | * @param y is the vertical offset to this pixel. |
Rhyme | 23:d0eb35bbd2f3 | 194 | * @param color defines the color for the pixel. |
Rhyme | 23:d0eb35bbd2f3 | 195 | */ |
Rhyme | 23:d0eb35bbd2f3 | 196 | void SEPS225::pixel(int x, int y, unsigned short color) |
Rhyme | 23:d0eb35bbd2f3 | 197 | { |
Rhyme | 23:d0eb35bbd2f3 | 198 | unsigned char data[2] ; |
Rhyme | 23:d0eb35bbd2f3 | 199 | data[0] = (unsigned char)((color & 0xFF00) >> 8) ; |
Rhyme | 23:d0eb35bbd2f3 | 200 | data[1] = (unsigned char)(color & 0x00FF) ; |
Rhyme | 23:d0eb35bbd2f3 | 201 | |
Rhyme | 23:d0eb35bbd2f3 | 202 | reg_write(CMD_MEMORY_ACCESS_POINTER_X, x) ; |
Rhyme | 23:d0eb35bbd2f3 | 203 | reg_write(CMD_MEMORY_ACCESS_POINTER_Y, y) ; |
Rhyme | 23:d0eb35bbd2f3 | 204 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 205 | *_rs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 206 | wr_cmd8(CMD_DDRAM_DATA_ACCESS_PORT) ; |
Rhyme | 23:d0eb35bbd2f3 | 207 | *_rs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 208 | |
Rhyme | 23:d0eb35bbd2f3 | 209 | wr_data8(data[0]) ; |
Rhyme | 23:d0eb35bbd2f3 | 210 | wr_data8(data[1]) ; |
Rhyme | 23:d0eb35bbd2f3 | 211 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 212 | } |
Rhyme | 23:d0eb35bbd2f3 | 213 | |
Rhyme | 23:d0eb35bbd2f3 | 214 | void SEPS225::window(int x, int y, int w, int h) |
Rhyme | 23:d0eb35bbd2f3 | 215 | { |
Rhyme | 23:d0eb35bbd2f3 | 216 | reg_write(CMD_MX1_ADDR, x) ; |
Rhyme | 23:d0eb35bbd2f3 | 217 | reg_write(CMD_MX2_ADDR, x+w-1) ; |
Rhyme | 23:d0eb35bbd2f3 | 218 | reg_write(CMD_MY1_ADDR, y) ; |
Rhyme | 23:d0eb35bbd2f3 | 219 | reg_write(CMD_MY2_ADDR, y+h-1) ; |
Rhyme | 24:1a2ebae1d289 | 220 | reg_write(CMD_MEMORY_ACCESS_POINTER_X, x) ; |
Rhyme | 24:1a2ebae1d289 | 221 | reg_write(CMD_MEMORY_ACCESS_POINTER_Y, y) ; |
Rhyme | 23:d0eb35bbd2f3 | 222 | } |
Rhyme | 23:d0eb35bbd2f3 | 223 | |
Rhyme | 23:d0eb35bbd2f3 | 224 | void SEPS225::cls(void) |
Rhyme | 23:d0eb35bbd2f3 | 225 | { |
Rhyme | 23:d0eb35bbd2f3 | 226 | window(0, 0, OLED_WIDTH, OLED_HEIGHT) ; |
Rhyme | 23:d0eb35bbd2f3 | 227 | reg_write(CMD_MEMORY_ACCESS_POINTER_X, 0) ; |
Rhyme | 23:d0eb35bbd2f3 | 228 | reg_write(CMD_MEMORY_ACCESS_POINTER_Y, 0) ; |
Rhyme | 23:d0eb35bbd2f3 | 229 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 230 | *_rs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 231 | wr_cmd8(CMD_DDRAM_DATA_ACCESS_PORT) ; |
Rhyme | 23:d0eb35bbd2f3 | 232 | *_rs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 233 | for (int i = 0 ; i < OLED_WIDTH * OLED_HEIGHT ; i++ ) { |
Rhyme | 23:d0eb35bbd2f3 | 234 | write16(COLOR_BLACK) ; |
Rhyme | 23:d0eb35bbd2f3 | 235 | } |
Rhyme | 23:d0eb35bbd2f3 | 236 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 237 | } |
Rhyme | 23:d0eb35bbd2f3 | 238 | |
Rhyme | 23:d0eb35bbd2f3 | 239 | unsigned short SEPS225::pixelread(int x, int y) |
Rhyme | 23:d0eb35bbd2f3 | 240 | { |
Rhyme | 23:d0eb35bbd2f3 | 241 | unsigned short value = 0x0000 ; |
Rhyme | 23:d0eb35bbd2f3 | 242 | //printf("SEPS225::pixelread not implemented\n\r") ; |
Rhyme | 23:d0eb35bbd2f3 | 243 | return(value) ; |
Rhyme | 23:d0eb35bbd2f3 | 244 | } |
Rhyme | 23:d0eb35bbd2f3 | 245 | |
Rhyme | 24:1a2ebae1d289 | 246 | void SEPS225::rect(int x0, int y0, int x1, int y1, unsigned short color) |
Rhyme | 24:1a2ebae1d289 | 247 | { |
Rhyme | 24:1a2ebae1d289 | 248 | float interval = 0.01 ; |
Rhyme | 24:1a2ebae1d289 | 249 | // window(x0, y0, x1-x0+1, y1-y0+1) ; |
Rhyme | 24:1a2ebae1d289 | 250 | *_cs = 0 ; |
Rhyme | 24:1a2ebae1d289 | 251 | wait(interval) ; |
Rhyme | 24:1a2ebae1d289 | 252 | line(x0, y0, x1, y0, color) ; |
Rhyme | 24:1a2ebae1d289 | 253 | *_cs = 1 ; |
Rhyme | 24:1a2ebae1d289 | 254 | wait(interval) ; |
Rhyme | 24:1a2ebae1d289 | 255 | *_cs = 0 ; |
Rhyme | 24:1a2ebae1d289 | 256 | line(x1, y0, x1, y1, color) ; |
Rhyme | 24:1a2ebae1d289 | 257 | *_cs = 1 ; |
Rhyme | 24:1a2ebae1d289 | 258 | wait(interval) ; |
Rhyme | 24:1a2ebae1d289 | 259 | *_cs = 0 ; |
Rhyme | 24:1a2ebae1d289 | 260 | line(x0, y0, x0, y1, color) ; |
Rhyme | 24:1a2ebae1d289 | 261 | *_cs = 1 ; |
Rhyme | 24:1a2ebae1d289 | 262 | wait(interval) ; |
Rhyme | 24:1a2ebae1d289 | 263 | *_cs = 0 ; |
Rhyme | 24:1a2ebae1d289 | 264 | line(x0, y1, x1, y1, color) ; |
Rhyme | 24:1a2ebae1d289 | 265 | wait(interval) ; |
Rhyme | 24:1a2ebae1d289 | 266 | *_cs = 1 ; |
Rhyme | 24:1a2ebae1d289 | 267 | // *_cs = 1 ; |
Rhyme | 24:1a2ebae1d289 | 268 | } |
Rhyme | 24:1a2ebae1d289 | 269 | |
Rhyme | 23:d0eb35bbd2f3 | 270 | void SEPS225::window4read(int x, int y, int w, int h) |
Rhyme | 23:d0eb35bbd2f3 | 271 | { |
Rhyme | 23:d0eb35bbd2f3 | 272 | //printf("SEPS225::window4read not implemented\n\r") ; |
Rhyme | 23:d0eb35bbd2f3 | 273 | } |
Rhyme | 23:d0eb35bbd2f3 | 274 | |
Rhyme | 23:d0eb35bbd2f3 | 275 | void SEPS225::window_pushpixel(unsigned short color) |
Rhyme | 23:d0eb35bbd2f3 | 276 | { |
Rhyme | 23:d0eb35bbd2f3 | 277 | //printf("SEPS225::window_pushpixel(unsigned short color) not implemented\n\r") ; |
Rhyme | 23:d0eb35bbd2f3 | 278 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 279 | *_rs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 280 | wr_cmd8(CMD_DDRAM_DATA_ACCESS_PORT) ; |
Rhyme | 23:d0eb35bbd2f3 | 281 | *_rs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 282 | wr_data16(color) ; |
Rhyme | 23:d0eb35bbd2f3 | 283 | // write16(color) ; |
Rhyme | 23:d0eb35bbd2f3 | 284 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 285 | } |
Rhyme | 23:d0eb35bbd2f3 | 286 | |
Rhyme | 23:d0eb35bbd2f3 | 287 | void SEPS225::window_pushpixel(unsigned short color, unsigned int count) |
Rhyme | 23:d0eb35bbd2f3 | 288 | { |
Rhyme | 23:d0eb35bbd2f3 | 289 | //printf("SEPS225::window_pushpixel(unsigned short color, unsigned int count) not implemented\n\r") ; |
Rhyme | 23:d0eb35bbd2f3 | 290 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 291 | *_rs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 292 | wr_cmd8(CMD_DDRAM_DATA_ACCESS_PORT) ; |
Rhyme | 23:d0eb35bbd2f3 | 293 | *_rs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 294 | for (unsigned int i = 0 ; i < count ; i++ ) { |
Rhyme | 23:d0eb35bbd2f3 | 295 | // write16(color) ; |
Rhyme | 23:d0eb35bbd2f3 | 296 | wr_data16(color) ; |
Rhyme | 23:d0eb35bbd2f3 | 297 | } |
Rhyme | 23:d0eb35bbd2f3 | 298 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 299 | } |
Rhyme | 23:d0eb35bbd2f3 | 300 | |
Rhyme | 23:d0eb35bbd2f3 | 301 | void SEPS225::window_pushpixelbuf(unsigned short* color, unsigned int lenght) |
Rhyme | 23:d0eb35bbd2f3 | 302 | { |
Rhyme | 23:d0eb35bbd2f3 | 303 | //printf("SEPS225::window_pushpixelbuf(unsigned short color, unsigned int length) not implemented\n\r") ; |
Rhyme | 23:d0eb35bbd2f3 | 304 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 305 | *_rs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 306 | wr_cmd8(CMD_DDRAM_DATA_ACCESS_PORT) ; |
Rhyme | 23:d0eb35bbd2f3 | 307 | *_rs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 308 | for (unsigned int i = 0 ; i < lenght ; i++ ) { |
Rhyme | 23:d0eb35bbd2f3 | 309 | // write16(color[i]) ; |
Rhyme | 23:d0eb35bbd2f3 | 310 | wr_data16(color[i]) ; |
Rhyme | 23:d0eb35bbd2f3 | 311 | } |
Rhyme | 23:d0eb35bbd2f3 | 312 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 313 | } |
Rhyme | 23:d0eb35bbd2f3 | 314 | |
Rhyme | 23:d0eb35bbd2f3 | 315 | void SEPS225::reg_write(unsigned char cmd, unsigned char data) |
Rhyme | 23:d0eb35bbd2f3 | 316 | { |
Rhyme | 23:d0eb35bbd2f3 | 317 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 318 | *_rs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 319 | wr_cmd8(cmd) ; |
Rhyme | 23:d0eb35bbd2f3 | 320 | *_rs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 321 | wr_data8(data) ; |
Rhyme | 23:d0eb35bbd2f3 | 322 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 323 | } |
Rhyme | 23:d0eb35bbd2f3 | 324 | |
Rhyme | 23:d0eb35bbd2f3 | 325 | void SEPS225::display(int onoff) |
Rhyme | 23:d0eb35bbd2f3 | 326 | { |
Rhyme | 23:d0eb35bbd2f3 | 327 | reg_write(CMD_DISP_ON_OFF, onoff) ; |
Rhyme | 23:d0eb35bbd2f3 | 328 | } |
Rhyme | 23:d0eb35bbd2f3 | 329 | |
Rhyme | 23:d0eb35bbd2f3 | 330 | void SEPS225::cmd_write(unsigned char cmd) |
Rhyme | 23:d0eb35bbd2f3 | 331 | { |
Rhyme | 23:d0eb35bbd2f3 | 332 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 333 | *_rs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 334 | wr_cmd8(cmd) ; |
Rhyme | 23:d0eb35bbd2f3 | 335 | *_rs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 336 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 337 | } |
Rhyme | 23:d0eb35bbd2f3 | 338 | |
Rhyme | 23:d0eb35bbd2f3 | 339 | void SEPS225::data_write(unsigned char data) |
Rhyme | 23:d0eb35bbd2f3 | 340 | { |
Rhyme | 23:d0eb35bbd2f3 | 341 | *_cs = 0 ; |
Rhyme | 23:d0eb35bbd2f3 | 342 | wr_data8(data) ; |
Rhyme | 23:d0eb35bbd2f3 | 343 | *_cs = 1 ; |
Rhyme | 23:d0eb35bbd2f3 | 344 | } |
Rhyme | 23:d0eb35bbd2f3 | 345 | |
Rhyme | 23:d0eb35bbd2f3 | 346 | void SEPS225::write8(unsigned char data) |
Rhyme | 23:d0eb35bbd2f3 | 347 | { |
Rhyme | 23:d0eb35bbd2f3 | 348 | wr_data8(data) ; |
Rhyme | 23:d0eb35bbd2f3 | 349 | } |
Rhyme | 23:d0eb35bbd2f3 | 350 | |
Rhyme | 23:d0eb35bbd2f3 | 351 | void SEPS225::write16(unsigned short sdata) |
Rhyme | 23:d0eb35bbd2f3 | 352 | { |
Rhyme | 23:d0eb35bbd2f3 | 353 | wr_data8((sdata >> 8)&0xFF) ; |
Rhyme | 23:d0eb35bbd2f3 | 354 | wr_data8(sdata & 0xFF) ; |
Rhyme | 23:d0eb35bbd2f3 | 355 | } |
Rhyme | 23:d0eb35bbd2f3 | 356 | |
Rhyme | 23:d0eb35bbd2f3 | 357 | void SEPS225::bufwrite8(unsigned char *data, unsigned long len) |
Rhyme | 23:d0eb35bbd2f3 | 358 | { |
Rhyme | 23:d0eb35bbd2f3 | 359 | unsigned long i; |
Rhyme | 23:d0eb35bbd2f3 | 360 | for (i = 0 ; i < len ; i++ ) { |
Rhyme | 23:d0eb35bbd2f3 | 361 | wr_data8(data[i]) ; |
Rhyme | 23:d0eb35bbd2f3 | 362 | } |
Rhyme | 23:d0eb35bbd2f3 | 363 | } |
Rhyme | 23:d0eb35bbd2f3 | 364 | |
Rhyme | 23:d0eb35bbd2f3 | 365 | void SEPS225::bufwrite16(unsigned short *sdata, unsigned long len) |
Rhyme | 23:d0eb35bbd2f3 | 366 | { |
Rhyme | 23:d0eb35bbd2f3 | 367 | unsigned long i ; |
Rhyme | 23:d0eb35bbd2f3 | 368 | for (i = 0 ; i < len ; i++) { |
Rhyme | 23:d0eb35bbd2f3 | 369 | write8((*sdata >> 8)&0xFF) ; |
Rhyme | 23:d0eb35bbd2f3 | 370 | write8(*sdata & 0xFF) ; |
Rhyme | 23:d0eb35bbd2f3 | 371 | } |
Rhyme | 23:d0eb35bbd2f3 | 372 | } |