Skip to content

Commit e2a389c

Browse files
authored
Generalize ST7789 init. sequence (#312)
1 parent ec52f31 commit e2a389c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pio/st7789_lcd/st7789_lcd.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "st7789_lcd.pio.h"
1616
#include "raspberry_256x256_rgb565.h"
1717

18+
// Tested with the parts that have the height of 240 and 320
1819
#define SCREEN_WIDTH 240
1920
#define SCREEN_HEIGHT 240
2021
#define IMAGE_SIZE 256
@@ -32,16 +33,16 @@
3233
// Format: cmd length (including cmd byte), post delay in units of 5 ms, then cmd payload
3334
// Note the delays have been shortened a little
3435
static const uint8_t st7789_init_seq[] = {
35-
1, 20, 0x01, // Software reset
36-
1, 10, 0x11, // Exit sleep mode
36+
1, 20, 0x01, // Software reset
37+
1, 10, 0x11, // Exit sleep mode
3738
2, 2, 0x3a, 0x55, // Set colour mode to 16 bit
3839
2, 0, 0x36, 0x00, // Set MADCTL: row then column, refresh is bottom to top ????
39-
5, 0, 0x2a, 0x00, 0x00, 0x00, 0xf0, // CASET: column addresses from 0 to 240 (f0)
40-
5, 0, 0x2b, 0x00, 0x00, 0x00, 0xf0, // RASET: row addresses from 0 to 240 (f0)
40+
5, 0, 0x2a, 0x00, 0x00, SCREEN_WIDTH >> 8, SCREEN_WIDTH & 0xff, // CASET: column addresses
41+
5, 0, 0x2b, 0x00, 0x00, SCREEN_HEIGHT >> 8, SCREEN_HEIGHT & 0xff, // RASET: row addresses
4142
1, 2, 0x21, // Inversion on, then 10 ms delay (supposedly a hack?)
4243
1, 2, 0x13, // Normal display on, then 10 ms delay
4344
1, 2, 0x29, // Main screen turn on, then wait 500 ms
44-
0 // Terminate list
45+
0 // Terminate list
4546
};
4647

4748
static inline void lcd_set_dc_cs(bool dc, bool cs) {

0 commit comments

Comments
 (0)