summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-h100-remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-h100-remote.c')
-rw-r--r--firmware/drivers/lcd-h100-remote.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c
index 2850712a91..04a4b7f7a0 100644
--- a/firmware/drivers/lcd-h100-remote.c
+++ b/firmware/drivers/lcd-h100-remote.c
@@ -38,6 +38,9 @@ static const unsigned char ones[8] = {
38static int curfont = FONT_SYSFIXED; 38static int curfont = FONT_SYSFIXED;
39static int xmargin = 0; 39static int xmargin = 0;
40static int ymargin = 0; 40static int ymargin = 0;
41#ifndef SIMULATOR
42static int xoffset; /* needed for flip */
43#endif
41 44
42unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH] 45unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]
43#ifndef SIMULATOR 46#ifndef SIMULATOR
@@ -70,6 +73,7 @@ static bool remote_initialized = false;
70 73
71/* cached settings values, for hotplug init */ 74/* cached settings values, for hotplug init */
72static bool cached_invert = false; 75static bool cached_invert = false;
76static bool cached_flip = false;
73static int cached_contrast = 32; 77static int cached_contrast = 32;
74static int cached_roll = 0; 78static int cached_roll = 0;
75 79
@@ -206,7 +210,7 @@ void lcd_remote_write_command_ex(int cmd, int data)
206#define LCD_REMOTE_CNTL_DISPLAY_ON_OFF 0xae 210#define LCD_REMOTE_CNTL_DISPLAY_ON_OFF 0xae
207#define LCD_REMOTE_CNTL_ENTIRE_ON_OFF 0xa4 211#define LCD_REMOTE_CNTL_ENTIRE_ON_OFF 0xa4
208#define LCD_REMOTE_CNTL_REVERSE_ON_OFF 0xa6 212#define LCD_REMOTE_CNTL_REVERSE_ON_OFF 0xa6
209#define LCD_REMOTE_CTNL_NOP 0xe3 213#define LCD_REMOTE_CNTL_NOP 0xe3
210#define LCD_REMOTE_CNTL_POWER_CONTROL 0x2b 214#define LCD_REMOTE_CNTL_POWER_CONTROL 0x2b
211#define LCD_REMOTE_CNTL_SELECT_REGULATOR 0x20 215#define LCD_REMOTE_CNTL_SELECT_REGULATOR 0x20
212#define LCD_REMOTE_CNTL_SELECT_BIAS 0xa2 216#define LCD_REMOTE_CNTL_SELECT_BIAS 0xa2
@@ -214,6 +218,9 @@ void lcd_remote_write_command_ex(int cmd, int data)
214#define LCD_REMOTE_CNTL_INIT_LINE 0x40 218#define LCD_REMOTE_CNTL_INIT_LINE 0x40
215#define LCD_REMOTE_CNTL_SET_PAGE_ADDRESS 0xB0 219#define LCD_REMOTE_CNTL_SET_PAGE_ADDRESS 0xB0
216 220
221#define LCD_REMOTE_CNTL_HIGHCOL 0x10 /* Upper column address */
222#define LCD_REMOTE_CNTL_LOWCOL 0x00 /* Lower column address */
223
217void lcd_remote_powersave(bool on) 224void lcd_remote_powersave(bool on)
218{ 225{
219 if (remote_initialized) 226 if (remote_initialized)
@@ -237,6 +244,30 @@ void lcd_remote_set_invert_display(bool yesno)
237 lcd_remote_write_command(LCD_REMOTE_CNTL_REVERSE_ON_OFF | yesno); 244 lcd_remote_write_command(LCD_REMOTE_CNTL_REVERSE_ON_OFF | yesno);
238} 245}
239 246
247/* turn the display upside down (call lcd_remote_update() afterwards) */
248void lcd_remote_set_flip(bool yesno)
249{
250 cached_flip = yesno;
251 if (yesno)
252 {
253 xoffset = 0;
254 if (remote_initialized)
255 {
256 lcd_remote_write_command(LCD_REMOTE_CNTL_ADC_NORMAL);
257 lcd_remote_write_command(LCD_REMOTE_CNTL_SHL_NORMAL);
258 }
259 }
260 else
261 {
262 xoffset = 132 - LCD_REMOTE_WIDTH;
263 if (remote_initialized)
264 {
265 lcd_remote_write_command(LCD_REMOTE_CNTL_ADC_REVERSE);
266 lcd_remote_write_command(LCD_REMOTE_CNTL_SHL_REVERSE);
267 }
268 }
269}
270
240int lcd_remote_default_contrast(void) 271int lcd_remote_default_contrast(void)
241{ 272{
242 return 32; 273 return 32;
@@ -394,8 +425,6 @@ void lcd_remote_clear_display(void)
394 425
395static void remote_lcd_init(void) 426static void remote_lcd_init(void)
396{ 427{
397 lcd_remote_write_command(LCD_REMOTE_CNTL_ADC_REVERSE);
398 lcd_remote_write_command(LCD_REMOTE_CNTL_SHL_REVERSE);
399 lcd_remote_write_command(LCD_REMOTE_CNTL_SELECT_BIAS | 0x0); 428 lcd_remote_write_command(LCD_REMOTE_CNTL_SELECT_BIAS | 0x0);
400 429
401 lcd_remote_write_command(LCD_REMOTE_CNTL_POWER_CONTROL | 0x5); 430 lcd_remote_write_command(LCD_REMOTE_CNTL_POWER_CONTROL | 0x5);
@@ -416,6 +445,7 @@ static void remote_lcd_init(void)
416 445
417 remote_initialized = true; 446 remote_initialized = true;
418 447
448 lcd_remote_set_flip(cached_flip);
419 lcd_remote_set_contrast(cached_contrast); 449 lcd_remote_set_contrast(cached_contrast);
420 lcd_remote_set_invert_display(cached_invert); 450 lcd_remote_set_invert_display(cached_invert);
421 lcd_remote_roll(cached_roll); 451 lcd_remote_roll(cached_roll);
@@ -490,7 +520,8 @@ void lcd_remote_update (void)
490 for (y = 0; y < LCD_REMOTE_HEIGHT / 8; y++) 520 for (y = 0; y < LCD_REMOTE_HEIGHT / 8; y++)
491 { 521 {
492 lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y); 522 lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y);
493 lcd_remote_write_command_ex(0x10, 0x04); 523 lcd_remote_write_command(LCD_REMOTE_CNTL_HIGHCOL | ((xoffset>>4) & 0xf));
524 lcd_remote_write_command(LCD_REMOTE_CNTL_LOWCOL | (xoffset & 0xf));
494 lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH); 525 lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH);
495 } 526 }
496} 527}
@@ -522,8 +553,11 @@ void lcd_remote_update_rect (int x_start, int y,
522 for (; y <= ymax; y++) 553 for (; y <= ymax; y++)
523 { 554 {
524 lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y); 555 lcd_remote_write_command(LCD_REMOTE_CNTL_SET_PAGE_ADDRESS | y);
525 lcd_remote_write_command_ex(0x10, 0x00); 556 lcd_remote_write_command(LCD_REMOTE_CNTL_HIGHCOL
526 lcd_remote_write_data(&lcd_remote_framebuffer[y][x_start], width); 557 | (((x_start+xoffset)>>4) & 0xf));
558 lcd_remote_write_command(LCD_REMOTE_CNTL_LOWCOL
559 | ((x_start+xoffset) & 0xf));
560 lcd_remote_write_data(&lcd_remote_framebuffer[y][x_start], width);
527 } 561 }
528} 562}
529 563