Final project repo for ECE 495
Dependencies: Adafruit_GFX_MBED Adafruit_ILI9341 BurstSPI DS1820 mbed mbed-rtos ltc2991_lib
display/Display.cpp@5:c1c710391df2, 2016-12-14 (annotated)
- Committer:
- bdk9
- Date:
- Wed Dec 14 07:01:33 2016 +0000
- Revision:
- 5:c1c710391df2
- Parent:
- 0:7ba4e0775670
big update yo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bdk9 | 0:7ba4e0775670 | 1 | |
bdk9 | 0:7ba4e0775670 | 2 | |
bdk9 | 0:7ba4e0775670 | 3 | #include "Adafruit_ILI9341.h" |
bdk9 | 0:7ba4e0775670 | 4 | #include "Display.h" |
bdk9 | 0:7ba4e0775670 | 5 | #include "Screen.h" |
bdk9 | 0:7ba4e0775670 | 6 | |
bdk9 | 0:7ba4e0775670 | 7 | Display::Display() { }; |
bdk9 | 0:7ba4e0775670 | 8 | |
bdk9 | 0:7ba4e0775670 | 9 | void Display::set_screens(Screen **screens, int num) { |
bdk9 | 0:7ba4e0775670 | 10 | _screens = screens; |
bdk9 | 0:7ba4e0775670 | 11 | _num_screens = num; |
bdk9 | 0:7ba4e0775670 | 12 | _cur_screen_index = 0; |
bdk9 | 0:7ba4e0775670 | 13 | _cur_screen = _screens[_cur_screen_index]; |
bdk9 | 0:7ba4e0775670 | 14 | _needs_init = 1; |
bdk9 | 0:7ba4e0775670 | 15 | } |
bdk9 | 0:7ba4e0775670 | 16 | |
bdk9 | 5:c1c710391df2 | 17 | void Display::switch_screen() { |
bdk9 | 0:7ba4e0775670 | 18 | if (_cur_screen_index == _num_screens - 1) { |
bdk9 | 0:7ba4e0775670 | 19 | _cur_screen_index = 0; |
bdk9 | 0:7ba4e0775670 | 20 | } |
bdk9 | 0:7ba4e0775670 | 21 | else { |
bdk9 | 0:7ba4e0775670 | 22 | _cur_screen_index++; |
bdk9 | 0:7ba4e0775670 | 23 | } |
bdk9 | 0:7ba4e0775670 | 24 | _cur_screen = _screens[_cur_screen_index]; |
bdk9 | 0:7ba4e0775670 | 25 | _needs_init = 1; |
bdk9 | 0:7ba4e0775670 | 26 | } |
bdk9 | 0:7ba4e0775670 | 27 | |
bdk9 | 0:7ba4e0775670 | 28 | void Display::update() { |
bdk9 | 0:7ba4e0775670 | 29 | if (_needs_init) { |
bdk9 | 0:7ba4e0775670 | 30 | _cur_screen->init(); |
bdk9 | 0:7ba4e0775670 | 31 | _needs_init = 0; |
bdk9 | 0:7ba4e0775670 | 32 | } |
bdk9 | 0:7ba4e0775670 | 33 | _cur_screen->update(); |
bdk9 | 0:7ba4e0775670 | 34 | } |
bdk9 | 5:c1c710391df2 | 35 | |
bdk9 | 5:c1c710391df2 | 36 | void Display::error(char *msg) { |
bdk9 | 5:c1c710391df2 | 37 | _cur_screen->error(msg); |
bdk9 | 5:c1c710391df2 | 38 | } |