Added display/button led timeout functionality

This commit is contained in:
Mike C 2013-04-09 17:56:19 -04:00
parent bfa639d5a2
commit 8de1dd39bf
3 changed files with 18 additions and 19 deletions

View file

@ -8,6 +8,8 @@
attribute. attribute.
*/ */
#include <Metro.h>
#include "Project.h" #include "Project.h"
#include "UI.h" #include "UI.h"
@ -20,6 +22,8 @@ UI::UI(Config* aConfig) {
lcd = new UILCD(config); lcd = new UILCD(config);
uiTimeout = new Metro(config->getTimeoutMilis());
startUI(); startUI();
} }
@ -40,6 +44,13 @@ void UI::enableUI() {
lcd->turnOn(); lcd->turnOn();
okButton->turnOnLed(); okButton->turnOnLed();
cancelButton->turnOnLed(); cancelButton->turnOnLed();
uiTimeout->reset();
}
void UI::processTimeoutEvents() {
if (uiTimeout->check() == 1) {
disableUI();
}
} }
void UI::processInputEvents() { void UI::processInputEvents() {

View file

@ -8,14 +8,7 @@
attribute. attribute.
*/ */
// UI State machine (current element = config / stats / inline display of data) #include <Metro.h>
// Configuration state machine (speed, pinout, logic level, sd card on/off, boot logo on/off)
// Message to config (element + new value)
// Message to UI (element + success/fail)
// Button's controlling UI
// UIButton* okButton = new UIButton(22, 23);
// UIButton* cancelButton = new UIButton(24, 25);
#include "Project.h" #include "Project.h"
#include "UIButton.h" #include "UIButton.h"
@ -35,11 +28,14 @@ private:
Config* config; Config* config;
Metro* uiTimeout;
public: public:
UI(Config* aConfig); UI(Config* aConfig);
void startUI(); void startUI();
void processInputEvents(); void processInputEvents();
void processTimeoutEvents();
void disableUI(); void disableUI();
void enableUI(); void enableUI();

View file

@ -8,6 +8,8 @@
attribute. attribute.
*/ */
#include <Metro.h>
#include "Project.h" #include "Project.h"
#include "Config.h" #include "Config.h"
#include "UIButton.h" #include "UIButton.h"
@ -20,13 +22,9 @@
#include <SD.h> #include <SD.h>
#include <SPI.h> #include <SPI.h>
#include <Metro.h>
UI* ui; UI* ui;
Config* config; Config* config;
//Metro uiTimeout = Metro(250);
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
Serial.println("Setup!"); Serial.println("Setup!");
@ -35,16 +33,10 @@ void setup() {
config->setDefaults(); config->setDefaults();
ui = new UI(config); ui = new UI(config);
//uiTimeout = Metro(config->getTimeoutMilis());
} }
void loop() { void loop() {
// FIXME: Move timer to UI under its own method
// if (uiTimeout.check() == 1) {
// ui->disableUI();
// }
ui->processInputEvents(); ui->processInputEvents();
ui->processTimeoutEvents();
} }