aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2017-04-07 10:55:29 +0300
committerFred Sundvik <fsundvik@gmail.com>2017-04-09 18:34:59 +0300
commit995002fa912545128625ec2d8c53cff5de560b97 (patch)
tree255e7ba3b57739544028efda52be570d4dfdaf03
parent3994fb1e79615af849aa03378293831f59c9b259 (diff)
downloadqmk_firmware-995002fa912545128625ec2d8c53cff5de560b97.tar.gz
qmk_firmware-995002fa912545128625ec2d8c53cff5de560b97.zip
LCD initialization sequence according to the docs
The LCD initialization show now be much better and faster with no flickering at the startup. Also fix the contrast control.
-rw-r--r--keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c40
-rw-r--r--keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/st7565.h2
2 files changed, 13 insertions, 29 deletions
diff --git a/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c b/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c
index 2c8a168e7..0de457a7a 100644
--- a/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c
+++ b/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c
@@ -26,7 +26,7 @@
26#define GDISP_SCREEN_WIDTH 128 26#define GDISP_SCREEN_WIDTH 128
27#endif 27#endif
28#ifndef GDISP_INITIAL_CONTRAST 28#ifndef GDISP_INITIAL_CONTRAST
29#define GDISP_INITIAL_CONTRAST 0 29#define GDISP_INITIAL_CONTRAST 35
30#endif 30#endif
31#ifndef GDISP_INITIAL_BACKLIGHT 31#ifndef GDISP_INITIAL_BACKLIGHT
32#define GDISP_INITIAL_BACKLIGHT 100 32#define GDISP_INITIAL_BACKLIGHT 100
@@ -111,41 +111,25 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
111 gfxSleepMilliseconds(20); 111 gfxSleepMilliseconds(20);
112 setpin_reset(g, FALSE); 112 setpin_reset(g, FALSE);
113 gfxSleepMilliseconds(20); 113 gfxSleepMilliseconds(20);
114
115 acquire_bus(g); 114 acquire_bus(g);
116 enter_cmd_mode(g); 115 enter_cmd_mode(g);
117 write_cmd(g, ST7565_DISPLAY_OFF); 116
117 write_cmd(g, ST7565_RESET);
118 write_cmd(g, ST7565_LCD_BIAS); 118 write_cmd(g, ST7565_LCD_BIAS);
119 write_cmd(g, ST7565_ADC); 119 write_cmd(g, ST7565_ADC);
120 write_cmd(g, ST7565_COM_SCAN); 120 write_cmd(g, ST7565_COM_SCAN);
121 121
122 write_cmd(g, ST7565_START_LINE | 0); 122 write_cmd(g, ST7565_RESISTOR_RATIO | 0x1);
123 123 write_cmd2(g, ST7565_CONTRAST, GDISP_INITIAL_CONTRAST);
124 write_cmd(g, ST7565_RESISTOR_RATIO | 0x6);
125
126 // turn on voltage converter (VC=1, VR=0, VF=0)
127 write_cmd(g, ST7565_POWER_CONTROL | 0x04);
128 flush_cmd(g);
129 delay_ms(50);
130
131 // turn on voltage regulator (VC=1, VR=1, VF=0)
132 write_cmd(g, ST7565_POWER_CONTROL | 0x06);
133 flush_cmd(g);
134 delay_ms(50);
135 124
136 // turn on voltage follower (VC=1, VR=1, VF=1) 125 // turn on internal power supply (VC=1, VR=1, VF=1)
137 write_cmd(g, ST7565_POWER_CONTROL | 0x07); 126 write_cmd(g, ST7565_POWER_CONTROL | 0x07);
138 flush_cmd(g);
139 delay_ms(50);
140 127
141 write_cmd(g, 0xE2);
142 write_cmd(g, ST7565_COM_SCAN);
143 write_cmd2(g, ST7565_CONTRAST, GDISP_INITIAL_CONTRAST*64/101);
144 //write_cmd2(g, ST7565_CONTRAST, 0);
145 write_cmd(g, ST7565_DISPLAY_ON);
146 write_cmd(g, ST7565_ALLON_NORMAL);
147 write_cmd(g, ST7565_INVERT_DISPLAY); 128 write_cmd(g, ST7565_INVERT_DISPLAY);
129 write_cmd(g, ST7565_ALLON_NORMAL);
130 write_cmd(g, ST7565_DISPLAY_ON);
148 131
132 write_cmd(g, ST7565_START_LINE | 0);
149 write_cmd(g, ST7565_RMW); 133 write_cmd(g, ST7565_RMW);
150 flush_cmd(g); 134 flush_cmd(g);
151 135
@@ -331,14 +315,12 @@ LLDSPEC void gdisp_lld_control(GDisplay *g) {
331 return; 315 return;
332 316
333 case GDISP_CONTROL_CONTRAST: 317 case GDISP_CONTROL_CONTRAST:
334 if ((unsigned)g->p.ptr > 100) 318 g->g.Contrast = (unsigned)g->p.ptr & 63;
335 g->p.ptr = (void *)100;
336 acquire_bus(g); 319 acquire_bus(g);
337 enter_cmd_mode(g); 320 enter_cmd_mode(g);
338 write_cmd2(g, ST7565_CONTRAST, ((((unsigned)g->p.ptr)<<6)/101) & 0x3F); 321 write_cmd2(g, ST7565_CONTRAST, g->g.Contrast);
339 flush_cmd(g); 322 flush_cmd(g);
340 release_bus(g); 323 release_bus(g);
341 g->g.Contrast = (unsigned)g->p.ptr;
342 return; 324 return;
343 } 325 }
344} 326}
diff --git a/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/st7565.h b/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/st7565.h
index 48636b33d..24924ff05 100644
--- a/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/st7565.h
+++ b/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/st7565.h
@@ -34,4 +34,6 @@
34#define ST7565_RESISTOR_RATIO 0x20 34#define ST7565_RESISTOR_RATIO 0x20
35#define ST7565_POWER_CONTROL 0x28 35#define ST7565_POWER_CONTROL 0x28
36 36
37#define ST7565_RESET 0xE2
38
37#endif /* _ST7565_H */ 39#endif /* _ST7565_H */