diff options
| author | Nick Brassel <nick@tzarc.org> | 2021-10-07 10:57:48 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-07 10:57:48 +1100 |
| commit | b2a186cf92d91bbb7f98fff68c4edf571909bf89 (patch) | |
| tree | c58eca68f1ca0797b8080c32be3d14b10abd286a /drivers | |
| parent | bc1f5ef38172bc77a802fb779e5da60f800c231b (diff) | |
| download | qmk_firmware-b2a186cf92d91bbb7f98fff68c4edf571909bf89.tar.gz qmk_firmware-b2a186cf92d91bbb7f98fff68c4edf571909bf89.zip | |
Purge uGFX. (#14720)
* Purge uGFX.
* Remove remnants of visualizer.
* Remove remnants of uGFX.
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h | 105 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/is31fl3731c/driver.mk | 3 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c | 302 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h | 36 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/st7565/board_st7565_template.h | 96 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/st7565/driver.mk | 3 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c | 314 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/st7565/gdisp_lld_config.h | 27 | ||||
| -rw-r--r-- | drivers/ugfx/gdisp/st7565/st7565.h | 39 |
9 files changed, 0 insertions, 925 deletions
diff --git a/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h b/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h deleted file mode 100644 index 0755ddf6c..000000000 --- a/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2016 Fred Sundvik <fsundvik@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef _GDISP_LLD_BOARD_H | ||
| 19 | #define _GDISP_LLD_BOARD_H | ||
| 20 | |||
| 21 | static const I2CConfig i2ccfg = { | ||
| 22 | 400000 // clock speed (Hz); 400kHz max for IS31 | ||
| 23 | }; | ||
| 24 | |||
| 25 | static const uint8_t led_mask[] = { | ||
| 26 | 0xFF, 0x00, /* C1-1 -> C1-16 */ | ||
| 27 | 0xFF, 0x00, /* C2-1 -> C2-16 */ | ||
| 28 | 0xFF, 0x00, /* C3-1 -> C3-16 */ | ||
| 29 | 0xFF, 0x00, /* C4-1 -> C4-16 */ | ||
| 30 | 0x3F, 0x00, /* C5-1 -> C5-16 */ | ||
| 31 | 0x00, 0x00, /* C6-1 -> C6-16 */ | ||
| 32 | 0x00, 0x00, /* C7-1 -> C7-16 */ | ||
| 33 | 0x00, 0x00, /* C8-1 -> C8-16 */ | ||
| 34 | 0x00, 0x00, /* C9-1 -> C9-16 */ | ||
| 35 | }; | ||
| 36 | |||
| 37 | // The address of the LED | ||
| 38 | #define LA(c, r) (c + r * 16) | ||
| 39 | // Need to be an address that is not mapped, but inside the range of the controller matrix | ||
| 40 | #define NA LA(8, 8) | ||
| 41 | |||
| 42 | // The numbers in the comments are the led numbers DXX on the PCB | ||
| 43 | // The mapping is taken from the schematic of left hand side | ||
| 44 | static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = { | ||
| 45 | // 45 44 43 42 41 40 39 | ||
| 46 | {LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)}, | ||
| 47 | // 52 51 50 49 48 47 46 | ||
| 48 | {LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2)}, | ||
| 49 | // 58 57 56 55 54 53 N/A | ||
| 50 | {LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA}, | ||
| 51 | // 67 66 65 64 63 62 61 | ||
| 52 | {LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2)}, | ||
| 53 | // 76 75 74 73 72 60 59 | ||
| 54 | {LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0)}, | ||
| 55 | // N/A N/A N/A N/A N/A N/A 68 | ||
| 56 | {NA, NA, NA, NA, NA, NA, LA(5, 4)}, | ||
| 57 | // N/A N/A N/A N/A 71 70 69 | ||
| 58 | {NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0)}, | ||
| 59 | }; | ||
| 60 | |||
| 61 | #define IS31_ADDR_DEFAULT 0x74 // AD connected to GND | ||
| 62 | #define IS31_TIMEOUT 5000 | ||
| 63 | |||
| 64 | static GFXINLINE void init_board(GDisplay* g) { | ||
| 65 | (void)g; | ||
| 66 | /* I2C pins */ | ||
| 67 | palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL | ||
| 68 | palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA | ||
| 69 | palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL); | ||
| 70 | palClearPad(GPIOB, 16); | ||
| 71 | /* start I2C */ | ||
| 72 | i2cStart(&I2CD1, &i2ccfg); | ||
| 73 | // try high drive (from kiibohd) | ||
| 74 | I2CD1.i2c->C2 |= I2Cx_C2_HDRS; | ||
| 75 | // try glitch fixing (from kiibohd) | ||
| 76 | I2CD1.i2c->FLT = 4; | ||
| 77 | } | ||
| 78 | |||
| 79 | static GFXINLINE void post_init_board(GDisplay* g) { (void)g; } | ||
| 80 | |||
| 81 | static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) { | ||
| 82 | (void)g; | ||
| 83 | return led_mask; | ||
| 84 | } | ||
| 85 | |||
| 86 | static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y) { | ||
| 87 | (void)g; | ||
| 88 | return led_mapping[y][x]; | ||
| 89 | } | ||
| 90 | |||
| 91 | static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) { | ||
| 92 | (void)g; | ||
| 93 | if (!shutdown) { | ||
| 94 | palSetPad(GPIOB, 16); | ||
| 95 | } else { | ||
| 96 | palClearPad(GPIOB, 16); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | static GFXINLINE void write_data(GDisplay* g, uint8_t* data, uint16_t length) { | ||
| 101 | (void)g; | ||
| 102 | i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT)); | ||
| 103 | } | ||
| 104 | |||
| 105 | #endif /* _GDISP_LLD_BOARD_H */ | ||
diff --git a/drivers/ugfx/gdisp/is31fl3731c/driver.mk b/drivers/ugfx/gdisp/is31fl3731c/driver.mk deleted file mode 100644 index a53131bf3..000000000 --- a/drivers/ugfx/gdisp/is31fl3731c/driver.mk +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | GFXINC += drivers/ugfx/gdisp/is31fl3731c | ||
| 2 | GFXSRC += drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c | ||
| 3 | GDISP_DRIVER_LIST += GDISPVMT_IS31FL3731C_QMK | ||
diff --git a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c b/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c deleted file mode 100644 index 718824402..000000000 --- a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c +++ /dev/null | |||
| @@ -1,302 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2016 Fred Sundvik <fsundvik@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "gfx.h" | ||
| 19 | |||
| 20 | #if GFX_USE_GDISP | ||
| 21 | |||
| 22 | # define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK | ||
| 23 | # define GDISP_SCREEN_HEIGHT LED_HEIGHT | ||
| 24 | # define GDISP_SCREEN_WIDTH LED_WIDTH | ||
| 25 | |||
| 26 | # include "gdisp_lld_config.h" | ||
| 27 | # include "src/gdisp/gdisp_driver.h" | ||
| 28 | |||
| 29 | # include "board_is31fl3731c.h" | ||
| 30 | |||
| 31 | // Can't include led_tables from here | ||
| 32 | extern const uint8_t CIE1931_CURVE[]; | ||
| 33 | |||
| 34 | /*===========================================================================*/ | ||
| 35 | /* Driver local definitions. */ | ||
| 36 | /*===========================================================================*/ | ||
| 37 | |||
| 38 | # ifndef GDISP_INITIAL_CONTRAST | ||
| 39 | # define GDISP_INITIAL_CONTRAST 0 | ||
| 40 | # endif | ||
| 41 | # ifndef GDISP_INITIAL_BACKLIGHT | ||
| 42 | # define GDISP_INITIAL_BACKLIGHT 0 | ||
| 43 | # endif | ||
| 44 | |||
| 45 | # define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) | ||
| 46 | |||
| 47 | # define IS31_ADDR_DEFAULT 0x74 | ||
| 48 | |||
| 49 | # define IS31_REG_CONFIG 0x00 | ||
| 50 | // bits in reg | ||
| 51 | # define IS31_REG_CONFIG_PICTUREMODE 0x00 | ||
| 52 | # define IS31_REG_CONFIG_AUTOPLAYMODE 0x08 | ||
| 53 | # define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18 | ||
| 54 | // D2:D0 bits are starting frame for autoplay mode | ||
| 55 | |||
| 56 | # define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode | ||
| 57 | |||
| 58 | # define IS31_REG_AUTOPLAYCTRL1 0x02 | ||
| 59 | // D6:D4 number of loops (000=infty) | ||
| 60 | // D2:D0 number of frames to be used | ||
| 61 | |||
| 62 | # define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms) | ||
| 63 | |||
| 64 | # define IS31_REG_DISPLAYOPT 0x05 | ||
| 65 | # define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames | ||
| 66 | # define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8 | ||
| 67 | // D2:D0 bits blink period time (*0.27s) | ||
| 68 | |||
| 69 | # define IS31_REG_AUDIOSYNC 0x06 | ||
| 70 | # define IS31_REG_AUDIOSYNC_ENABLE 0x1 | ||
| 71 | |||
| 72 | # define IS31_REG_FRAMESTATE 0x07 | ||
| 73 | |||
| 74 | # define IS31_REG_BREATHCTRL1 0x08 | ||
| 75 | // D6:D4 fade out time (26ms*2^i) | ||
| 76 | // D2:D0 fade in time (26ms*2^i) | ||
| 77 | |||
| 78 | # define IS31_REG_BREATHCTRL2 0x09 | ||
| 79 | # define IS31_REG_BREATHCTRL2_ENABLE 0x10 | ||
| 80 | // D2:D0 extinguish time (3.5ms*2^i) | ||
| 81 | |||
| 82 | # define IS31_REG_SHUTDOWN 0x0A | ||
| 83 | # define IS31_REG_SHUTDOWN_OFF 0x0 | ||
| 84 | # define IS31_REG_SHUTDOWN_ON 0x1 | ||
| 85 | |||
| 86 | # define IS31_REG_AGCCTRL 0x0B | ||
| 87 | # define IS31_REG_ADCRATE 0x0C | ||
| 88 | |||
| 89 | # define IS31_COMMANDREGISTER 0xFD | ||
| 90 | # define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine' | ||
| 91 | # define IS31_FUNCTIONREG_SIZE 0xD | ||
| 92 | |||
| 93 | # define IS31_FRAME_SIZE 0xB4 | ||
| 94 | |||
| 95 | # define IS31_PWM_REG 0x24 | ||
| 96 | # define IS31_PWM_SIZE 0x90 | ||
| 97 | |||
| 98 | # define IS31_LED_MASK_SIZE 0x12 | ||
| 99 | |||
| 100 | # define IS31 | ||
| 101 | |||
| 102 | /*===========================================================================*/ | ||
| 103 | /* Driver local functions. */ | ||
| 104 | /*===========================================================================*/ | ||
| 105 | |||
| 106 | typedef struct { | ||
| 107 | uint8_t write_buffer_offset; | ||
| 108 | uint8_t write_buffer[IS31_FRAME_SIZE]; | ||
| 109 | uint8_t frame_buffer[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH]; | ||
| 110 | uint8_t page; | ||
| 111 | } __attribute__((__packed__)) PrivData; | ||
| 112 | |||
| 113 | // Some common routines and macros | ||
| 114 | # define PRIV(g) ((PrivData *)g->priv) | ||
| 115 | |||
| 116 | /*===========================================================================*/ | ||
| 117 | /* Driver exported functions. */ | ||
| 118 | /*===========================================================================*/ | ||
| 119 | |||
| 120 | static GFXINLINE void write_page(GDisplay *g, uint8_t page) { | ||
| 121 | uint8_t tx[2] __attribute__((aligned(2))); | ||
| 122 | tx[0] = IS31_COMMANDREGISTER; | ||
| 123 | tx[1] = page; | ||
| 124 | write_data(g, tx, 2); | ||
| 125 | } | ||
| 126 | |||
| 127 | static GFXINLINE void write_register(GDisplay *g, uint8_t page, uint8_t reg, uint8_t data) { | ||
| 128 | uint8_t tx[2] __attribute__((aligned(2))); | ||
| 129 | tx[0] = reg; | ||
| 130 | tx[1] = data; | ||
| 131 | write_page(g, page); | ||
| 132 | write_data(g, tx, 2); | ||
| 133 | } | ||
| 134 | |||
| 135 | static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint16_t length) { | ||
| 136 | PRIV(g)->write_buffer_offset = offset; | ||
| 137 | write_page(g, page); | ||
| 138 | write_data(g, (uint8_t *)PRIV(g), length + 1); | ||
| 139 | } | ||
| 140 | |||
| 141 | LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | ||
| 142 | // The private area is the display surface. | ||
| 143 | g->priv = gfxAlloc(sizeof(PrivData)); | ||
| 144 | __builtin_memset(PRIV(g), 0, sizeof(PrivData)); | ||
| 145 | PRIV(g)->page = 0; | ||
| 146 | |||
| 147 | // Initialise the board interface | ||
| 148 | init_board(g); | ||
| 149 | gfxSleepMilliseconds(10); | ||
| 150 | |||
| 151 | // zero function page, all registers (assuming full_page is all zeroes) | ||
| 152 | write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE); | ||
| 153 | set_hardware_shutdown(g, false); | ||
| 154 | gfxSleepMilliseconds(10); | ||
| 155 | // software shutdown | ||
| 156 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); | ||
| 157 | gfxSleepMilliseconds(10); | ||
| 158 | // zero function page, all registers | ||
| 159 | write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE); | ||
| 160 | gfxSleepMilliseconds(10); | ||
| 161 | |||
| 162 | // zero all LED registers on all 8 pages, and enable the mask | ||
| 163 | __builtin_memcpy(PRIV(g)->write_buffer, get_led_mask(g), IS31_LED_MASK_SIZE); | ||
| 164 | for (uint8_t i = 0; i < 8; i++) { | ||
| 165 | write_ram(g, i, 0, IS31_FRAME_SIZE); | ||
| 166 | gfxSleepMilliseconds(1); | ||
| 167 | } | ||
| 168 | |||
| 169 | // software shutdown disable (i.e. turn stuff on) | ||
| 170 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); | ||
| 171 | gfxSleepMilliseconds(10); | ||
| 172 | |||
| 173 | // Finish Init | ||
| 174 | post_init_board(g); | ||
| 175 | |||
| 176 | /* Initialise the GDISP structure */ | ||
| 177 | g->g.Width = GDISP_SCREEN_WIDTH; | ||
| 178 | g->g.Height = GDISP_SCREEN_HEIGHT; | ||
| 179 | g->g.Orientation = GDISP_ROTATE_0; | ||
| 180 | g->g.Powermode = powerOff; | ||
| 181 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; | ||
| 182 | g->g.Contrast = GDISP_INITIAL_CONTRAST; | ||
| 183 | return TRUE; | ||
| 184 | } | ||
| 185 | |||
| 186 | # if GDISP_HARDWARE_FLUSH | ||
| 187 | LLDSPEC void gdisp_lld_flush(GDisplay *g) { | ||
| 188 | // Don't flush if we don't need it. | ||
| 189 | if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; | ||
| 190 | |||
| 191 | PRIV(g)->page++; | ||
| 192 | PRIV(g)->page %= 2; | ||
| 193 | // TODO: some smarter algorithm for this | ||
| 194 | // We should run only one physical page at a time | ||
| 195 | // This way we don't need to send so much data, and | ||
| 196 | // we could use slightly less memory | ||
| 197 | uint8_t *src = PRIV(g)->frame_buffer; | ||
| 198 | for (int y = 0; y < GDISP_SCREEN_HEIGHT; y++) { | ||
| 199 | for (int x = 0; x < GDISP_SCREEN_WIDTH; x++) { | ||
| 200 | uint8_t val = (uint16_t)*src * g->g.Backlight / 100; | ||
| 201 | PRIV(g)->write_buffer[get_led_address(g, x, y)] = CIE1931_CURVE[val]; | ||
| 202 | ++src; | ||
| 203 | } | ||
| 204 | } | ||
| 205 | write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE); | ||
| 206 | gfxSleepMilliseconds(1); | ||
| 207 | write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page); | ||
| 208 | |||
| 209 | g->flags &= ~GDISP_FLG_NEEDFLUSH; | ||
| 210 | } | ||
| 211 | # endif | ||
| 212 | |||
| 213 | # if GDISP_HARDWARE_DRAWPIXEL | ||
| 214 | LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { | ||
| 215 | coord_t x, y; | ||
| 216 | |||
| 217 | switch (g->g.Orientation) { | ||
| 218 | default: | ||
| 219 | case GDISP_ROTATE_0: | ||
| 220 | x = g->p.x; | ||
| 221 | y = g->p.y; | ||
| 222 | break; | ||
| 223 | case GDISP_ROTATE_180: | ||
| 224 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; | ||
| 225 | y = g->p.y; | ||
| 226 | break; | ||
| 227 | } | ||
| 228 | PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color); | ||
| 229 | g->flags |= GDISP_FLG_NEEDFLUSH; | ||
| 230 | } | ||
| 231 | # endif | ||
| 232 | |||
| 233 | # if GDISP_HARDWARE_PIXELREAD | ||
| 234 | LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { | ||
| 235 | coord_t x, y; | ||
| 236 | |||
| 237 | switch (g->g.Orientation) { | ||
| 238 | default: | ||
| 239 | case GDISP_ROTATE_0: | ||
| 240 | x = g->p.x; | ||
| 241 | y = g->p.y; | ||
| 242 | break; | ||
| 243 | case GDISP_ROTATE_180: | ||
| 244 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; | ||
| 245 | y = g->p.y; | ||
| 246 | break; | ||
| 247 | } | ||
| 248 | return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]); | ||
| 249 | } | ||
| 250 | # endif | ||
| 251 | |||
| 252 | # if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL | ||
| 253 | LLDSPEC void gdisp_lld_control(GDisplay *g) { | ||
| 254 | switch (g->p.x) { | ||
| 255 | case GDISP_CONTROL_POWER: | ||
| 256 | if (g->g.Powermode == (powermode_t)g->p.ptr) return; | ||
| 257 | switch ((powermode_t)g->p.ptr) { | ||
| 258 | case powerOff: | ||
| 259 | case powerSleep: | ||
| 260 | case powerDeepSleep: | ||
| 261 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); | ||
| 262 | break; | ||
| 263 | case powerOn: | ||
| 264 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON); | ||
| 265 | break; | ||
| 266 | default: | ||
| 267 | return; | ||
| 268 | } | ||
| 269 | g->g.Powermode = (powermode_t)g->p.ptr; | ||
| 270 | return; | ||
| 271 | |||
| 272 | case GDISP_CONTROL_ORIENTATION: | ||
| 273 | if (g->g.Orientation == (orientation_t)g->p.ptr) return; | ||
| 274 | switch ((orientation_t)g->p.ptr) { | ||
| 275 | /* Rotation is handled by the drawing routines */ | ||
| 276 | case GDISP_ROTATE_0: | ||
| 277 | case GDISP_ROTATE_180: | ||
| 278 | g->g.Height = GDISP_SCREEN_HEIGHT; | ||
| 279 | g->g.Width = GDISP_SCREEN_WIDTH; | ||
| 280 | break; | ||
| 281 | case GDISP_ROTATE_90: | ||
| 282 | case GDISP_ROTATE_270: | ||
| 283 | g->g.Height = GDISP_SCREEN_WIDTH; | ||
| 284 | g->g.Width = GDISP_SCREEN_HEIGHT; | ||
| 285 | break; | ||
| 286 | default: | ||
| 287 | return; | ||
| 288 | } | ||
| 289 | g->g.Orientation = (orientation_t)g->p.ptr; | ||
| 290 | return; | ||
| 291 | |||
| 292 | case GDISP_CONTROL_BACKLIGHT: | ||
| 293 | if (g->g.Backlight == (unsigned)g->p.ptr) return; | ||
| 294 | unsigned val = (unsigned)g->p.ptr; | ||
| 295 | g->g.Backlight = val > 100 ? 100 : val; | ||
| 296 | g->flags |= GDISP_FLG_NEEDFLUSH; | ||
| 297 | return; | ||
| 298 | } | ||
| 299 | } | ||
| 300 | # endif // GDISP_NEED_CONTROL | ||
| 301 | |||
| 302 | #endif // GFX_USE_GDISP | ||
diff --git a/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h b/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h deleted file mode 100644 index 403c6b040..000000000 --- a/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2016 Fred Sundvik <fsundvik@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef _GDISP_LLD_CONFIG_H | ||
| 19 | #define _GDISP_LLD_CONFIG_H | ||
| 20 | |||
| 21 | #if GFX_USE_GDISP | ||
| 22 | |||
| 23 | /*===========================================================================*/ | ||
| 24 | /* Driver hardware support. */ | ||
| 25 | /*===========================================================================*/ | ||
| 26 | |||
| 27 | # define GDISP_HARDWARE_FLUSH GFXON // This controller requires flushing | ||
| 28 | # define GDISP_HARDWARE_DRAWPIXEL GFXON | ||
| 29 | # define GDISP_HARDWARE_PIXELREAD GFXON | ||
| 30 | # define GDISP_HARDWARE_CONTROL GFXON | ||
| 31 | |||
| 32 | # define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256 | ||
| 33 | |||
| 34 | #endif /* GFX_USE_GDISP */ | ||
| 35 | |||
| 36 | #endif /* _GDISP_LLD_CONFIG_H */ | ||
diff --git a/drivers/ugfx/gdisp/st7565/board_st7565_template.h b/drivers/ugfx/gdisp/st7565/board_st7565_template.h deleted file mode 100644 index 875ed9e65..000000000 --- a/drivers/ugfx/gdisp/st7565/board_st7565_template.h +++ /dev/null | |||
| @@ -1,96 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * This file is subject to the terms of the GFX License. If a copy of | ||
| 3 | * the license was not distributed with this file, you can obtain one at: | ||
| 4 | * | ||
| 5 | * http://ugfx.org/license.html | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef _GDISP_LLD_BOARD_H | ||
| 9 | #define _GDISP_LLD_BOARD_H | ||
| 10 | |||
| 11 | #include "quantum.h" | ||
| 12 | |||
| 13 | #define ST7565_LCD_BIAS ST7565_LCD_BIAS_7 | ||
| 14 | #define ST7565_COM_SCAN ST7565_COM_SCAN_DEC | ||
| 15 | #define ST7565_PAGE_ORDER 0, 1, 2, 3 | ||
| 16 | /* | ||
| 17 | * Custom page order for several LCD boards, e.g. HEM12864-99 | ||
| 18 | * #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3 | ||
| 19 | */ | ||
| 20 | |||
| 21 | #define ST7565_A0_PIN C7 | ||
| 22 | #define ST7565_RST_PIN C8 | ||
| 23 | #define ST7565_MOSI_PIN C6 | ||
| 24 | #define ST7565_SCLK_PIN C5 | ||
| 25 | #define ST7565_SS_PIN C4 | ||
| 26 | |||
| 27 | // DSPI Clock and Transfer Attributes | ||
| 28 | // Frame Size: 8 bits | ||
| 29 | // MSB First | ||
| 30 | // CLK Low by default | ||
| 31 | static const SPIConfig spi1config = { | ||
| 32 | // Operation complete callback or @p NULL. | ||
| 33 | .end_cb = NULL, | ||
| 34 | // The chip select line port - when not using pcs. | ||
| 35 | .ssport = PAL_PORT(ST7565_SS_PIN), | ||
| 36 | // brief The chip select line pad number - when not using pcs. | ||
| 37 | .sspad = PAL_PAD(ST7565_SS_PIN), | ||
| 38 | // SPI initialization data. | ||
| 39 | .tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes | ||
| 40 | | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns | ||
| 41 | | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns | ||
| 42 | | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns | ||
| 43 | | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2 | ||
| 44 | | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns | ||
| 45 | }; | ||
| 46 | |||
| 47 | static GFXINLINE void acquire_bus(GDisplay *g) { | ||
| 48 | (void)g; | ||
| 49 | // Only the LCD is using the SPI bus, so no need to acquire | ||
| 50 | // spiAcquireBus(&SPID1); | ||
| 51 | spiSelect(&SPID1); | ||
| 52 | } | ||
| 53 | |||
| 54 | static GFXINLINE void release_bus(GDisplay *g) { | ||
| 55 | (void)g; | ||
| 56 | // Only the LCD is using the SPI bus, so no need to release | ||
| 57 | // spiReleaseBus(&SPID1); | ||
| 58 | spiUnselect(&SPID1); | ||
| 59 | } | ||
| 60 | |||
| 61 | static GFXINLINE void init_board(GDisplay *g) { | ||
| 62 | (void)g; | ||
| 63 | setPinOutput(ST7565_A0_PIN); | ||
| 64 | writePinHigh(ST7565_A0_PIN); | ||
| 65 | setPinOutput(ST7565_RST_PIN); | ||
| 66 | writePinHigh(ST7565_RST_PIN); | ||
| 67 | setPinOutput(ST7565_SS_PIN); | ||
| 68 | |||
| 69 | palSetPadMode(PAL_PORT(ST7565_MOSI_PIN), PAL_PAD(ST7565_MOSI_PIN), PAL_MODE_ALTERNATIVE_2); | ||
| 70 | palSetPadMode(PAL_PORT(ST7565_SCLK_PIN), PAL_PAD(ST7565_SCLK_PIN), PAL_MODE_ALTERNATIVE_2); | ||
| 71 | |||
| 72 | spiInit(); | ||
| 73 | spiStart(&SPID1, &spi1config); | ||
| 74 | release_bus(g); | ||
| 75 | } | ||
| 76 | |||
| 77 | static GFXINLINE void post_init_board(GDisplay *g) { (void)g; } | ||
| 78 | |||
| 79 | static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { | ||
| 80 | (void)g; | ||
| 81 | writePin(ST7565_RST_PIN, !state); | ||
| 82 | } | ||
| 83 | |||
| 84 | static GFXINLINE void write_cmd(GDisplay *g, gU8 cmd) { | ||
| 85 | (void)g; | ||
| 86 | writePinLow(ST7565_A0_PIN); | ||
| 87 | spiSend(&SPID1, 1, &cmd); | ||
| 88 | } | ||
| 89 | |||
| 90 | static GFXINLINE void write_data(GDisplay *g, gU8 *data, gU16 length) { | ||
| 91 | (void)g; | ||
| 92 | writePinHigh(ST7565_A0_PIN); | ||
| 93 | spiSend(&SPID1, length, data); | ||
| 94 | } | ||
| 95 | |||
| 96 | #endif /* _GDISP_LLD_BOARD_H */ | ||
diff --git a/drivers/ugfx/gdisp/st7565/driver.mk b/drivers/ugfx/gdisp/st7565/driver.mk deleted file mode 100644 index 799a986b0..000000000 --- a/drivers/ugfx/gdisp/st7565/driver.mk +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | GFXINC += drivers/ugfx/gdisp/st7565 | ||
| 2 | GFXSRC += drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c | ||
| 3 | GDISP_DRIVER_LIST += GDISPVMT_ST7565_QMK | ||
diff --git a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c b/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c deleted file mode 100644 index f586f97e3..000000000 --- a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c +++ /dev/null | |||
| @@ -1,314 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * This file is subject to the terms of the GFX License. If a copy of | ||
| 3 | * the license was not distributed with this file, you can obtain one at: | ||
| 4 | * | ||
| 5 | * http://ugfx.org/license.html | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include "gfx.h" | ||
| 9 | |||
| 10 | #if GFX_USE_GDISP | ||
| 11 | |||
| 12 | # define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK | ||
| 13 | # include "gdisp_lld_config.h" | ||
| 14 | # include "src/gdisp/gdisp_driver.h" | ||
| 15 | |||
| 16 | # include "board_st7565.h" | ||
| 17 | |||
| 18 | /*===========================================================================*/ | ||
| 19 | /* Driver local definitions. */ | ||
| 20 | /*===========================================================================*/ | ||
| 21 | |||
| 22 | # ifndef GDISP_SCREEN_HEIGHT | ||
| 23 | # define GDISP_SCREEN_HEIGHT LCD_HEIGHT | ||
| 24 | # endif | ||
| 25 | # ifndef GDISP_SCREEN_WIDTH | ||
| 26 | # define GDISP_SCREEN_WIDTH LCD_WIDTH | ||
| 27 | # endif | ||
| 28 | # ifndef GDISP_INITIAL_CONTRAST | ||
| 29 | # define GDISP_INITIAL_CONTRAST 35 | ||
| 30 | # endif | ||
| 31 | # ifndef GDISP_INITIAL_BACKLIGHT | ||
| 32 | # define GDISP_INITIAL_BACKLIGHT 100 | ||
| 33 | # endif | ||
| 34 | |||
| 35 | # define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) | ||
| 36 | |||
| 37 | # include "st7565.h" | ||
| 38 | |||
| 39 | /*===========================================================================*/ | ||
| 40 | /* Driver config defaults for backward compatibility. */ | ||
| 41 | /*===========================================================================*/ | ||
| 42 | # ifndef ST7565_LCD_BIAS | ||
| 43 | # define ST7565_LCD_BIAS ST7565_LCD_BIAS_7 | ||
| 44 | # endif | ||
| 45 | # ifndef ST7565_ADC | ||
| 46 | # define ST7565_ADC ST7565_ADC_NORMAL | ||
| 47 | # endif | ||
| 48 | # ifndef ST7565_COM_SCAN | ||
| 49 | # define ST7565_COM_SCAN ST7565_COM_SCAN_INC | ||
| 50 | # endif | ||
| 51 | # ifndef ST7565_PAGE_ORDER | ||
| 52 | # define ST7565_PAGE_ORDER 0, 1, 2, 3, 4, 5, 6, 7 | ||
| 53 | # endif | ||
| 54 | |||
| 55 | /*===========================================================================*/ | ||
| 56 | /* Driver local functions. */ | ||
| 57 | /*===========================================================================*/ | ||
| 58 | |||
| 59 | // Some common routines and macros | ||
| 60 | # define RAM(g) ((gU8 *)g->priv) | ||
| 61 | # define write_cmd2(g, cmd1, cmd2) \ | ||
| 62 | { \ | ||
| 63 | write_cmd(g, cmd1); \ | ||
| 64 | write_cmd(g, cmd2); \ | ||
| 65 | } | ||
| 66 | # define write_cmd3(g, cmd1, cmd2, cmd3) \ | ||
| 67 | { \ | ||
| 68 | write_cmd(g, cmd1); \ | ||
| 69 | write_cmd(g, cmd2); \ | ||
| 70 | write_cmd(g, cmd3); \ | ||
| 71 | } | ||
| 72 | |||
| 73 | // Some common routines and macros | ||
| 74 | # define delay(us) gfxSleepMicroseconds(us) | ||
| 75 | # define delay_ms(ms) gfxSleepMilliseconds(ms) | ||
| 76 | |||
| 77 | # define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) | ||
| 78 | # define xybit(y) (1 << ((y)&7)) | ||
| 79 | |||
| 80 | /*===========================================================================*/ | ||
| 81 | /* Driver exported functions. */ | ||
| 82 | /*===========================================================================*/ | ||
| 83 | |||
| 84 | /* | ||
| 85 | * As this controller can't update on a pixel boundary we need to maintain the | ||
| 86 | * the entire display surface in memory so that we can do the necessary bit | ||
| 87 | * operations. Fortunately it is a small display in monochrome. | ||
| 88 | * 64 * 128 / 8 = 1024 bytes. | ||
| 89 | */ | ||
| 90 | |||
| 91 | LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | ||
| 92 | // The private area is the display surface. | ||
| 93 | g->priv = gfxAlloc(GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8); | ||
| 94 | if (!g->priv) { | ||
| 95 | return gFalse; | ||
| 96 | } | ||
| 97 | |||
| 98 | // Initialise the board interface | ||
| 99 | init_board(g); | ||
| 100 | |||
| 101 | // Hardware reset | ||
| 102 | setpin_reset(g, TRUE); | ||
| 103 | gfxSleepMilliseconds(20); | ||
| 104 | setpin_reset(g, FALSE); | ||
| 105 | gfxSleepMilliseconds(20); | ||
| 106 | acquire_bus(g); | ||
| 107 | |||
| 108 | write_cmd(g, ST7565_LCD_BIAS); | ||
| 109 | write_cmd(g, ST7565_ADC); | ||
| 110 | write_cmd(g, ST7565_COM_SCAN); | ||
| 111 | |||
| 112 | write_cmd(g, ST7565_START_LINE | 0); | ||
| 113 | |||
| 114 | write_cmd2(g, ST7565_CONTRAST, GDISP_INITIAL_CONTRAST * 64 / 101); | ||
| 115 | write_cmd(g, ST7565_RESISTOR_RATIO | 0x1); | ||
| 116 | |||
| 117 | // turn on voltage converter (VC=1, VR=0, VF=0) | ||
| 118 | write_cmd(g, ST7565_POWER_CONTROL | 0x04); | ||
| 119 | delay_ms(50); | ||
| 120 | |||
| 121 | // turn on voltage regulator (VC=1, VR=1, VF=0) | ||
| 122 | write_cmd(g, ST7565_POWER_CONTROL | 0x06); | ||
| 123 | delay_ms(50); | ||
| 124 | |||
| 125 | // turn on voltage follower (VC=1, VR=1, VF=1) | ||
| 126 | write_cmd(g, ST7565_POWER_CONTROL | 0x07); | ||
| 127 | delay_ms(50); | ||
| 128 | |||
| 129 | write_cmd(g, ST7565_DISPLAY_ON); | ||
| 130 | write_cmd(g, ST7565_ALLON_NORMAL); | ||
| 131 | write_cmd(g, ST7565_INVERT_DISPLAY); // Disable Inversion of display. | ||
| 132 | |||
| 133 | write_cmd(g, ST7565_RMW); | ||
| 134 | |||
| 135 | // Finish Init | ||
| 136 | post_init_board(g); | ||
| 137 | |||
| 138 | // Release the bus | ||
| 139 | release_bus(g); | ||
| 140 | |||
| 141 | /* Initialise the GDISP structure */ | ||
| 142 | g->g.Width = GDISP_SCREEN_WIDTH; | ||
| 143 | g->g.Height = GDISP_SCREEN_HEIGHT; | ||
| 144 | g->g.Orientation = GDISP_ROTATE_0; | ||
| 145 | g->g.Powermode = powerOff; | ||
| 146 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; | ||
| 147 | g->g.Contrast = GDISP_INITIAL_CONTRAST; | ||
| 148 | return TRUE; | ||
| 149 | } | ||
| 150 | |||
| 151 | # if GDISP_HARDWARE_FLUSH | ||
| 152 | LLDSPEC void gdisp_lld_flush(GDisplay *g) { | ||
| 153 | unsigned p; | ||
| 154 | |||
| 155 | // Don't flush if we don't need it. | ||
| 156 | if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; | ||
| 157 | |||
| 158 | acquire_bus(g); | ||
| 159 | gU8 pagemap[] = {ST7565_PAGE_ORDER}; | ||
| 160 | for (p = 0; p < sizeof(pagemap); p++) { | ||
| 161 | write_cmd(g, ST7565_PAGE | pagemap[p]); | ||
| 162 | write_cmd(g, ST7565_COLUMN_MSB | 0); | ||
| 163 | write_cmd(g, ST7565_COLUMN_LSB | 0); | ||
| 164 | write_cmd(g, ST7565_RMW); | ||
| 165 | write_data(g, RAM(g) + (p * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); | ||
| 166 | } | ||
| 167 | release_bus(g); | ||
| 168 | |||
| 169 | g->flags &= ~GDISP_FLG_NEEDFLUSH; | ||
| 170 | } | ||
| 171 | # endif | ||
| 172 | |||
| 173 | # if GDISP_HARDWARE_DRAWPIXEL | ||
| 174 | LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { | ||
| 175 | coord_t x, y; | ||
| 176 | |||
| 177 | switch (g->g.Orientation) { | ||
| 178 | default: | ||
| 179 | case GDISP_ROTATE_0: | ||
| 180 | x = g->p.x; | ||
| 181 | y = g->p.y; | ||
| 182 | break; | ||
| 183 | case GDISP_ROTATE_90: | ||
| 184 | x = g->p.y; | ||
| 185 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.x; | ||
| 186 | break; | ||
| 187 | case GDISP_ROTATE_180: | ||
| 188 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; | ||
| 189 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.y; | ||
| 190 | break; | ||
| 191 | case GDISP_ROTATE_270: | ||
| 192 | x = GDISP_SCREEN_HEIGHT - 1 - g->p.y; | ||
| 193 | y = g->p.x; | ||
| 194 | break; | ||
| 195 | } | ||
| 196 | if (gdispColor2Native(g->p.color) != Black) | ||
| 197 | RAM(g)[xyaddr(x, y)] |= xybit(y); | ||
| 198 | else | ||
| 199 | RAM(g)[xyaddr(x, y)] &= ~xybit(y); | ||
| 200 | g->flags |= GDISP_FLG_NEEDFLUSH; | ||
| 201 | } | ||
| 202 | # endif | ||
| 203 | |||
| 204 | # if GDISP_HARDWARE_PIXELREAD | ||
| 205 | LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { | ||
| 206 | coord_t x, y; | ||
| 207 | |||
| 208 | switch (g->g.Orientation) { | ||
| 209 | default: | ||
| 210 | case GDISP_ROTATE_0: | ||
| 211 | x = g->p.x; | ||
| 212 | y = g->p.y; | ||
| 213 | break; | ||
| 214 | case GDISP_ROTATE_90: | ||
| 215 | x = g->p.y; | ||
| 216 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.x; | ||
| 217 | break; | ||
| 218 | case GDISP_ROTATE_180: | ||
| 219 | x = GDISP_SCREEN_WIDTH - 1 - g->p.x; | ||
| 220 | y = GDISP_SCREEN_HEIGHT - 1 - g->p.y; | ||
| 221 | break; | ||
| 222 | case GDISP_ROTATE_270: | ||
| 223 | x = GDISP_SCREEN_HEIGHT - 1 - g->p.y; | ||
| 224 | y = g->p.x; | ||
| 225 | break; | ||
| 226 | } | ||
| 227 | return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? White : Black; | ||
| 228 | } | ||
| 229 | # endif | ||
| 230 | |||
| 231 | # if GDISP_HARDWARE_BITFILLS | ||
| 232 | LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { | ||
| 233 | uint8_t *buffer = (uint8_t *)g->p.ptr; | ||
| 234 | int linelength = g->p.cx; | ||
| 235 | for (int i = 0; i < g->p.cy; i++) { | ||
| 236 | unsigned dstx = g->p.x; | ||
| 237 | unsigned dsty = g->p.y + i; | ||
| 238 | unsigned srcx = g->p.x1; | ||
| 239 | unsigned srcy = g->p.y1 + i; | ||
| 240 | unsigned srcbit = srcy * g->p.x2 + srcx; | ||
| 241 | for (int j = 0; j < linelength; j++) { | ||
| 242 | uint8_t src = buffer[srcbit / 8]; | ||
| 243 | uint8_t bit = 7 - (srcbit % 8); | ||
| 244 | uint8_t bitset = (src >> bit) & 1; | ||
| 245 | uint8_t *dst = &(RAM(g)[xyaddr(dstx, dsty)]); | ||
| 246 | if (bitset) { | ||
| 247 | *dst |= xybit(dsty); | ||
| 248 | } else { | ||
| 249 | *dst &= ~xybit(dsty); | ||
| 250 | } | ||
| 251 | dstx++; | ||
| 252 | srcbit++; | ||
| 253 | } | ||
| 254 | } | ||
| 255 | g->flags |= GDISP_FLG_NEEDFLUSH; | ||
| 256 | } | ||
| 257 | # endif | ||
| 258 | |||
| 259 | # if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL | ||
| 260 | LLDSPEC void gdisp_lld_control(GDisplay *g) { | ||
| 261 | switch (g->p.x) { | ||
| 262 | case GDISP_CONTROL_POWER: | ||
| 263 | if (g->g.Powermode == (powermode_t)g->p.ptr) return; | ||
| 264 | switch ((powermode_t)g->p.ptr) { | ||
| 265 | case powerOff: | ||
| 266 | case powerSleep: | ||
| 267 | case powerDeepSleep: | ||
| 268 | acquire_bus(g); | ||
| 269 | write_cmd(g, ST7565_DISPLAY_OFF); | ||
| 270 | release_bus(g); | ||
| 271 | break; | ||
| 272 | case powerOn: | ||
| 273 | acquire_bus(g); | ||
| 274 | write_cmd(g, ST7565_DISPLAY_ON); | ||
| 275 | release_bus(g); | ||
| 276 | break; | ||
| 277 | default: | ||
| 278 | return; | ||
| 279 | } | ||
| 280 | g->g.Powermode = (powermode_t)g->p.ptr; | ||
| 281 | return; | ||
| 282 | |||
| 283 | case GDISP_CONTROL_ORIENTATION: | ||
| 284 | if (g->g.Orientation == (orientation_t)g->p.ptr) return; | ||
| 285 | switch ((orientation_t)g->p.ptr) { | ||
| 286 | /* Rotation is handled by the drawing routines */ | ||
| 287 | case GDISP_ROTATE_0: | ||
| 288 | case GDISP_ROTATE_180: | ||
| 289 | g->g.Height = GDISP_SCREEN_HEIGHT; | ||
| 290 | g->g.Width = GDISP_SCREEN_WIDTH; | ||
| 291 | break; | ||
| 292 | case GDISP_ROTATE_90: | ||
| 293 | case GDISP_ROTATE_270: | ||
| 294 | g->g.Height = GDISP_SCREEN_WIDTH; | ||
| 295 | g->g.Width = GDISP_SCREEN_HEIGHT; | ||
| 296 | break; | ||
| 297 | default: | ||
| 298 | return; | ||
| 299 | } | ||
| 300 | g->g.Orientation = (orientation_t)g->p.ptr; | ||
| 301 | return; | ||
| 302 | |||
| 303 | case GDISP_CONTROL_CONTRAST: | ||
| 304 | if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; | ||
| 305 | acquire_bus(g); | ||
| 306 | write_cmd2(g, ST7565_CONTRAST, ((((unsigned)g->p.ptr) << 6) / 101) & 0x3F); | ||
| 307 | release_bus(g); | ||
| 308 | g->g.Contrast = (unsigned)g->p.ptr; | ||
| 309 | return; | ||
| 310 | } | ||
| 311 | } | ||
| 312 | # endif // GDISP_NEED_CONTROL | ||
| 313 | |||
| 314 | #endif // GFX_USE_GDISP | ||
diff --git a/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h b/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h deleted file mode 100644 index 6052058ec..000000000 --- a/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * This file is subject to the terms of the GFX License. If a copy of | ||
| 3 | * the license was not distributed with this file, you can obtain one at: | ||
| 4 | * | ||
| 5 | * http://ugfx.org/license.html | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef _GDISP_LLD_CONFIG_H | ||
| 9 | #define _GDISP_LLD_CONFIG_H | ||
| 10 | |||
| 11 | #if GFX_USE_GDISP | ||
| 12 | |||
| 13 | /*===========================================================================*/ | ||
| 14 | /* Driver hardware support. */ | ||
| 15 | /*===========================================================================*/ | ||
| 16 | |||
| 17 | # define GDISP_HARDWARE_FLUSH GFXON // This controller requires flushing | ||
| 18 | # define GDISP_HARDWARE_DRAWPIXEL GFXON | ||
| 19 | # define GDISP_HARDWARE_PIXELREAD GFXON | ||
| 20 | # define GDISP_HARDWARE_CONTROL GFXON | ||
| 21 | # define GDISP_HARDWARE_BITFILLS GFXON | ||
| 22 | |||
| 23 | # define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO | ||
| 24 | |||
| 25 | #endif /* GFX_USE_GDISP */ | ||
| 26 | |||
| 27 | #endif /* _GDISP_LLD_CONFIG_H */ | ||
diff --git a/drivers/ugfx/gdisp/st7565/st7565.h b/drivers/ugfx/gdisp/st7565/st7565.h deleted file mode 100644 index 3c77a8856..000000000 --- a/drivers/ugfx/gdisp/st7565/st7565.h +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * This file is subject to the terms of the GFX License. If a copy of | ||
| 3 | * the license was not distributed with this file, you can obtain one at: | ||
| 4 | * | ||
| 5 | * http://ugfx.org/license.html | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef _ST7565_H | ||
| 9 | #define _ST7565_H | ||
| 10 | |||
| 11 | #define ST7565_CONTRAST 0x81 | ||
| 12 | #define ST7565_ALLON_NORMAL 0xA4 | ||
| 13 | #define ST7565_ALLON 0xA5 | ||
| 14 | #define ST7565_POSITIVE_DISPLAY 0xA6 | ||
| 15 | #define ST7565_INVERT_DISPLAY 0xA7 | ||
| 16 | #define ST7565_DISPLAY_OFF 0xAE | ||
| 17 | #define ST7565_DISPLAY_ON 0xAF | ||
| 18 | |||
| 19 | #define ST7565_LCD_BIAS_7 0xA3 | ||
| 20 | #define ST7565_LCD_BIAS_9 0xA2 | ||
| 21 | |||
| 22 | #define ST7565_ADC_NORMAL 0xA0 | ||
| 23 | #define ST7565_ADC_REVERSE 0xA1 | ||
| 24 | |||
| 25 | #define ST7565_COM_SCAN_INC 0xC0 | ||
| 26 | #define ST7565_COM_SCAN_DEC 0xC8 | ||
| 27 | |||
| 28 | #define ST7565_START_LINE 0x40 | ||
| 29 | #define ST7565_PAGE 0xB0 | ||
| 30 | #define ST7565_COLUMN_MSB 0x10 | ||
| 31 | #define ST7565_COLUMN_LSB 0x00 | ||
| 32 | #define ST7565_RMW 0xE0 | ||
| 33 | |||
| 34 | #define ST7565_RESISTOR_RATIO 0x20 | ||
| 35 | #define ST7565_POWER_CONTROL 0x28 | ||
| 36 | |||
| 37 | #define ST7565_RESET 0xE2 | ||
| 38 | |||
| 39 | #endif /* _ST7565_H */ | ||
