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

View file

@ -8,14 +8,7 @@
attribute.
*/
// UI State machine (current element = config / stats / inline display of data)
// 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 <Metro.h>
#include "Project.h"
#include "UIButton.h"
@ -35,11 +28,14 @@ private:
Config* config;
Metro* uiTimeout;
public:
UI(Config* aConfig);
void startUI();
void processInputEvents();
void processTimeoutEvents();
void disableUI();
void enableUI();

View file

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