new throttle bar :P
Diff: Dashboard.cpp
- Revision:
- 6:051411e193b0
- Parent:
- 5:3047f8d8321b
- Child:
- 7:2d1db37ca0c6
diff -r 3047f8d8321b -r 051411e193b0 Dashboard.cpp --- a/Dashboard.cpp Tue May 23 12:42:43 2017 +0000 +++ b/Dashboard.cpp Tue May 23 19:24:15 2017 +0000 @@ -21,8 +21,6 @@ //Dashboard instance Dashboard dash; - - bool error_alert; //internal error booleaan bool motor_temp_alert = true; //LED1 E01 motor temperature too high @@ -113,11 +111,12 @@ command(2, 0b01000011); command(3, 0xA0); command(3, 0b01000000); + + //full brightness + command(screen_number, 0x86); + command(screen_number, 0x81); + command(screen_number, 0x7F); - //when recalled, clear screens completely - clearDisplay(1); - clearDisplay(2); - clearDisplay(3); } void Dashboard::welcomeScreen() @@ -639,23 +638,41 @@ void Dashboard::clearDisplay(int screen_number) { - command(screen_number, 0x15); - command(screen_number, 0x00); - command(screen_number, 0xFF); + //internal Vdd regulator on + command(1, 0xAB); + command(1, 0x01); + command(3, 0xAB); + command(3, 0x01); - command(screen_number, 0x75); - command(screen_number, 0x00); - command(screen_number, 0xFF); + //give reset + wait(0.1); + RST = 0; + wait(0.1); + RST = 1; - if (screen_number == 2) { - for (int i = 0; i < (128*64); i++) { - data(screen_number, 0x00); - } - } else { - for (int i = 0; i < (128*128); i++) { - data(screen_number, 0x00); - } - } + //display on, normal mode + command(1, 0xAF); + command(1, 0xA4); + command(2, 0xAF); + command(2, 0xA4); + command(3, 0xAF); + command(3, 0xA4); + + //Enable COM remap + command(1, 0xA0); + command(1, 0b01000000); + command(2, 0xA0); + command(2, 0b01000011); + command(3, 0xA0); + command(3, 0b01000000); + + //full brightness + command(screen_number, 0x86); + command(screen_number, 0x81); + command(screen_number, 0x7F); + + //all pixels OFF + command(screen_number, 0xA6); } void Dashboard::updateProgressCircle(int screen_number, int percentage) @@ -757,6 +774,35 @@ } } +void Dashboard::updateThrottleBar(int screen_number, int percentage, int row, int col, int width, int height) +{ + + for (int i = col; i < width; i++) { + drawPixel(2, 48, i, 0xFF); + } + for (int i = col; i < width; i++) { + drawPixel(2, 52, i, 0xFF); + } + + drawPixel(2, 49, 30, 0xF0); + drawPixel(2, 49, 20, 0xF0); + drawPixel(2, 49, 10, 0x0F); + drawPixel(2, 49, 15, 0xF0); + drawPixel(2, 49, 25, 0x0F); + + //draw bar + for (int i = 0; i < (percentage*width/100); i++) { + for (int j = 0; j < height; j++) { + drawPixel(screen_number, row + j, width + col - i, 0xFF); + } + } + for (int i = (percentage*width/100); i < width; i++) { + for (int j = 0; j < height; j++) { + drawPixel(screen_number, row + j, width + col - i, 0x00); + } + } +} + void Dashboard::drawBitmap(int screen_number, int index_number, char row, char col, int width, int height) { command(screen_number, 0x15);