Added timeout management screen

This commit is contained in:
Mike C 2013-04-07 00:49:23 -04:00
parent ceb50fbdb5
commit d96b20c81d
7 changed files with 80 additions and 4 deletions

View file

@ -15,6 +15,7 @@ Config::Config() {
currentMode = none;
currentLineSpeed = zero;
currentVoltage = negOne;
currentTimeout = never;
}
serialmode Config::getSerialMode() {
@ -29,6 +30,10 @@ ttlvoltage Config::getVoltage() {
return currentVoltage;
}
timeout Config::getTimeout() {
return currentTimeout;
}
void Config::setMode(serialmode mode) {
currentMode = mode;
}
@ -41,8 +46,13 @@ void Config::setVoltage(ttlvoltage voltage) {
currentVoltage = voltage;
}
void Config::setTimeout(timeout aTimeout) {
currentTimeout = aTimeout;
}
void Config::setDefaults() {
setMode(ttl);
setLineSpeed(oneNineteenTwoK);
setVoltage(onePointEight);
setTimeout(thirtyseconds);
}

View file

@ -19,6 +19,7 @@ private:
serialmode currentMode;
linespeed currentLineSpeed;
ttlvoltage currentVoltage;
timeout currentTimeout;
public:
Config();
@ -26,9 +27,11 @@ public:
void setMode(serialmode mode);
void setLineSpeed(linespeed speed);
void setVoltage(ttlvoltage voltage);
void setTimeout(timeout aTimeout);
serialmode getSerialMode();
linespeed getLineSpeed();
ttlvoltage getVoltage();
timeout getTimeout();
};
#endif

View file

@ -32,3 +32,11 @@ linespeedinfo linespeeds[6] = {
{ "57.5k", 57600 },
{ "115k", 115200 }
};
char* timeoutToText[5] = {
"10s",
"30s",
"1m",
"5m",
"Never"
};

View file

@ -82,4 +82,15 @@ struct linespeedinfo {
// Known and supported line speeds
extern linespeedinfo linespeeds[];
enum timeout {
tenseconds,
thirtyseconds,
oneminute,
fiveminutes,
never,
maxtimeout
};
extern char* timeoutToText[];
#endif

View file

@ -76,6 +76,10 @@ void UILCD::handleOkButtonEvent() {
config->setVoltage((ttlvoltage)(currentLine - 3));
drawVoltageScreen(true);
break;
case 5: // timeoutScreen
config->setTimeout((timeout)(currentLine - 3));
drawTimeoutScreen(true);
break;
}
}
@ -113,6 +117,9 @@ void UILCD::mainScreenOkButton() {
// break;
// case 7: // configure rtc
// break;
case 8:
drawTimeoutScreen(false);
break;
}
}
@ -223,6 +230,11 @@ void UILCD::configScreenHighlight(joyDirection direction) {
return;
}
break;
case 5: // timeoutScreen
if (currentLine == maxtimeout + 2) {
return;
}
break;
}
unHilightLine(currentLine);
@ -233,6 +245,38 @@ void UILCD::configScreenHighlight(joyDirection direction) {
}
}
void UILCD::drawTimeoutScreen(bool keepCurrentLine) {
currentScreen = timeoutscreen;
if (!keepCurrentLine) {
currentLine = 3;
}
tft->setCursor(0,0);
tft->fillScreen(BACKGROUND);
tft->setTextColor(TEXT);
tft->setTextWrap(true);
tft->println("Timout selection");
tft->println(" Current value is yellow");
tft->println();
for (int i=0; i<maxtimeout; i++) {
if (config->getTimeout() == i) {
tft->setTextColor(HILIGHT);
}
tft->print(" ");
tft->println(timeoutToText[i]);
tft->setTextColor(TEXT);
}
if (keepCurrentLine) {
hilightLine(currentLine);
}
else {
hilightLine(3);
}
}
void UILCD::drawConnectionScreen(bool keepCurrentLine) {
currentScreen = connectionScreen;
if (!keepCurrentLine) {

View file

@ -29,7 +29,8 @@ enum screen {
mainScreen,
connectionScreen,
lineSpeedScreen,
voltageScreen
voltageScreen,
timeoutscreen
};
class UILCD {
@ -48,6 +49,7 @@ private:
void drawConnectionScreen(bool keepCurrentLine);
void drawLineSpeedScreen(bool keepCurrentLine);
void drawVoltageScreen(bool keepCurrentLine);
void drawTimeoutScreen(bool keepCurrentLine);
void hilightLine(int line);
void unHilightLine(int line);
void mainScreenHilight(joyDirection direction);

View file

@ -28,8 +28,6 @@ UIJoystickPSP* pspJoystick;
joyDirection joyStickEvent;
void setup() {
Serial.begin(9600);
Serial.println("Setup!");