SSD2119: power control

All modes are working: powerOff, powerOn, powerSleep and powerDeepSleep.
This commit is contained in:
Mateusz Tomaszkiewicz 2013-02-25 00:35:13 +01:00
parent 51b292d3b9
commit bbdd57d9c1

View file

@ -525,8 +525,6 @@ void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
* that only supports off/on anything other * that only supports off/on anything other
* than zero is on. * than zero is on.
* GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
* GDISP_CONTROL_LLD - Low level driver control constants start at
* this value.
* *
* @param[in] what What to do. * @param[in] what What to do.
* @param[in] value The value to use (always cast to a void *). * @param[in] value The value to use (always cast to a void *).
@ -541,31 +539,61 @@ void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
switch((gdisp_powermode_t)value) { switch((gdisp_powermode_t)value) {
case powerOff: case powerOff:
acquire_bus(); acquire_bus();
write_reg(SSD2119_REG_SLEEP_MODE_1, 0x0001); // enter sleep mode write_reg(SSD2119_REG_SLEEP_MODE_1, 0x0001); // Enter sleep mode
write_reg(SSD2119_REG_DISPLAY_CTRL, 0x0000); // halt operation write_reg(SSD2119_REG_DISPLAY_CTRL, 0x0000); // Display off
write_reg(SSD2119_REG_OSC_START, 0x0000); // turn off oszcillator write_reg(SSD2119_REG_OSC_START, 0x0000); // Turn off oscillator
release_bus();
set_backlight(0); set_backlight(0);
delayms(500);
release_bus();
break; break;
case powerOn: case powerOn:
if (GDISP.Powermode == powerSleep) {
acquire_bus(); acquire_bus();
write_reg(0x0010, 0x0000); // leave sleep mode write_reg(SSD2119_REG_SLEEP_MODE_1, 0x0000); // Leave sleep mode
write_reg(SSD2119_REG_DISPLAY_CTRL, 0x0033); // Display on
release_bus();
delayms(170);
} else if (GDISP.Powermode == powerDeepSleep) {
acquire_bus();
write_reg(SSD2119_REG_SLEEP_MODE_2, 0x0999); // Disable deep sleep function
write_reg(SSD2119_REG_SLEEP_MODE_1, 0x0000); // Leave sleep mode
write_reg(SSD2119_REG_DISPLAY_CTRL, 0x0033); // Display on
release_bus();
delayms(170);
} else {
acquire_bus();
write_reg(SSD2119_REG_SLEEP_MODE_1, 0x0000); // Leave sleep mode
release_bus(); release_bus();
if (GDISP.Powermode != powerSleep)
gdisp_lld_init(); gdisp_lld_init();
}
set_backlight(100); set_backlight(100);
break; break;
case powerSleep: case powerSleep:
acquire_bus(); acquire_bus();
write_reg(0x0010, 0x0001); // enter sleep mode write_reg(SSD2119_REG_SLEEP_MODE_1, 0x0001); // Enter sleep mode
write_reg(SSD2119_REG_DISPLAY_CTRL, 0x0000); // Display off
release_bus(); release_bus();
set_backlight(0);
delayms(25);
break; break;
case powerDeepSleep:
acquire_bus();
write_reg(SSD2119_REG_SLEEP_MODE_1, 0x0001); // Enter sleep mode
write_reg(SSD2119_REG_SLEEP_MODE_2, 0x2999); // Enable deep sleep function
write_reg(SSD2119_REG_DISPLAY_CTRL, 0x0000); // Display off
release_bus();
set_backlight(0);
delayms(25);
break;
default: default:
return; return;
} }
GDISP.Powermode = (gdisp_powermode_t)value; GDISP.Powermode = (gdisp_powermode_t)value;
return; return;
case GDISP_CONTROL_ORIENTATION: case GDISP_CONTROL_ORIENTATION:
if (GDISP.Orientation == (gdisp_orientation_t)value) if (GDISP.Orientation == (gdisp_orientation_t)value)
return; return;
@ -579,6 +607,7 @@ void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_HEIGHT; GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH; GDISP.Width = GDISP_SCREEN_WIDTH;
break; break;
case GDISP_ROTATE_90: case GDISP_ROTATE_90:
acquire_bus(); acquire_bus();
write_reg(0x0001, 0x293F); write_reg(0x0001, 0x293F);
@ -588,6 +617,7 @@ void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_WIDTH; GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT; GDISP.Width = GDISP_SCREEN_HEIGHT;
break; break;
case GDISP_ROTATE_180: case GDISP_ROTATE_180:
acquire_bus(); acquire_bus();
write_reg(0x0001, 0x2B3F); write_reg(0x0001, 0x2B3F);
@ -597,6 +627,7 @@ void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_HEIGHT; GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH; GDISP.Width = GDISP_SCREEN_WIDTH;
break; break;
case GDISP_ROTATE_270: case GDISP_ROTATE_270:
acquire_bus(); acquire_bus();
write_reg(0x0001, 0x293F); write_reg(0x0001, 0x293F);
@ -606,9 +637,11 @@ void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_WIDTH; GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT; GDISP.Width = GDISP_SCREEN_HEIGHT;
break; break;
default: default:
return; return;
} }
#if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
GDISP.clipx0 = 0; GDISP.clipx0 = 0;
GDISP.clipy0 = 0; GDISP.clipy0 = 0;
@ -617,16 +650,18 @@ void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
#endif #endif
GDISP.Orientation = (gdisp_orientation_t)value; GDISP.Orientation = (gdisp_orientation_t)value;
return; return;
case GDISP_CONTROL_BACKLIGHT: case GDISP_CONTROL_BACKLIGHT:
if ((unsigned)value > 100) { if ((unsigned)value > 100)
value = (void *) 100; value = (void *)100;
}
set_backlight((unsigned)value); set_backlight((unsigned)value);
GDISP.Backlight = (unsigned)value; GDISP.Backlight = (unsigned)value;
break; return;
/*
case GDISP_CONTROL_CONTRAST: case GDISP_CONTROL_CONTRAST:
*/
default:
return;
} }
} }
#endif #endif