Final project repo for ECE 495

Dependencies:   Adafruit_GFX_MBED Adafruit_ILI9341 BurstSPI DS1820 mbed mbed-rtos ltc2991_lib

display/Display.cpp

Committer:
bdk9
Date:
2016-11-29
Revision:
0:7ba4e0775670
Child:
5:c1c710391df2

File content as of revision 0:7ba4e0775670:



#include "Adafruit_ILI9341.h"
#include "Display.h"
#include "Screen.h"

Display::Display() { };

void Display::set_screens(Screen **screens, int num) {
    _screens = screens;
    _num_screens = num;
    _cur_screen_index = 0;
    _cur_screen = _screens[_cur_screen_index];
    _needs_init = 1;
}

void Display::next_screen() {
    if (_cur_screen_index == _num_screens - 1) {
        _cur_screen_index = 0;
    }
    else {
        _cur_screen_index++;
    }
    _cur_screen = _screens[_cur_screen_index];
    _needs_init = 1;
}
        
void Display::update() {
    if (_needs_init) {
        _cur_screen->init();
        _needs_init = 0;
    }
    _cur_screen->update(); 
}