Fix: timeout configuration is now used to control UI timeout

This commit is contained in:
Mike C 2013-04-17 19:59:03 -04:00
parent 6b4f698d02
commit ebd4ac5d04
6 changed files with 39 additions and 11 deletions

View file

@ -12,11 +12,13 @@
#include "Project.h"
#include "Config.h"
#include "UI.h"
Config::Config() {
if (DEBUG) {
Serial.println("Config::Config()");
}
currentMode = none;
currentLineSpeed = zero;
currentVoltage = negOne;
@ -198,6 +200,7 @@ void Config::setLCDTimeout(timeout aTimeout) {
Serial.println("Config::setTimeout()");
}
currentTimeout = aTimeout;
ui->setLCDTimeout();
}
void Config::setDefaults() {

View file

@ -8,11 +8,18 @@
attribute.
*/
#include "Project.h"
#ifndef Config_h
#define Config_h
#include "Project.h"
#include "UI.h"
// Forward declaration of UI
class UI;
// Use global config and ui objects defined / initialized in main ino file
extern UI* ui;
class Config {
private:
// Mode info needed

View file

@ -13,11 +13,10 @@
#include "Project.h"
#include "UI.h"
UI::UI(Config* aConfig) {
UI::UI() {
if (DEBUG) {
Serial.println("Config::UI()");
}
config = aConfig;
okButton = new UIButton(okButtonPin, okButtonLed);
cancelButton = new UIButton(cancelButtonPin, cancelButtonLed);
@ -30,6 +29,10 @@ UI::UI(Config* aConfig) {
startUI();
}
void UI::setLCDTimeout() {
uiTimeout->interval(config->getTimeoutMilis());
}
void UI::startUI() {
if (DEBUG) {
Serial.println("Config::startUI()");
@ -60,7 +63,7 @@ void UI::enableUI() {
}
void UI::processTimeoutEvents() {
if (uiTimeout->check() == 1) {
if (uiTimeout->check()) {
disableUI();
}
}

View file

@ -8,6 +8,9 @@
attribute.
*/
#ifndef UI_h
#define UI_h
#include <Metro.h>
#include "Project.h"
@ -16,6 +19,13 @@
#include "UILCD.h"
#include "Config.h"
// Forward declaration of Config
class Config;
class UILCD;
// Use global config and ui objects defined / initialized in main ino file
extern Config* config;
class UI {
private:
UIButton* okButton;
@ -26,12 +36,10 @@ private:
UILCD* lcd;
Config* config;
Metro* uiTimeout;
public:
UI(Config* aConfig);
UI();
void startUI();
void processInputEvents();
@ -39,4 +47,8 @@ public:
void disableUI();
void enableUI();
void setLCDTimeout();
};
#endif

View file

@ -8,6 +8,9 @@
attribute.
*/
#ifndef UILCD_h
#define UILCD_h
#include "Arduino.h"
#include <Adafruit_GFX.h>
@ -19,8 +22,8 @@
#include "UIJoystickPSP.h"
#include "Config.h"
#ifndef UILCD_h
#define UILCD_h
// Forward declaration of Config
class Config;
#define BUFFPIXEL 20

View file

@ -31,7 +31,7 @@ void setup() {
config = new Config();
config->setDefaults();
ui = new UI(config);
ui = new UI();
}
void loop() {