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

View file

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

View file

@ -31,4 +31,12 @@ linespeedinfo linespeeds[6] = {
{ "38.4k", 38400 }, { "38.4k", 38400 },
{ "57.5k", 57600 }, { "57.5k", 57600 },
{ "115k", 115200 } { "115k", 115200 }
}; };
char* timeoutToText[5] = {
"10s",
"30s",
"1m",
"5m",
"Never"
};

View file

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

View file

@ -76,6 +76,10 @@ void UILCD::handleOkButtonEvent() {
config->setVoltage((ttlvoltage)(currentLine - 3)); config->setVoltage((ttlvoltage)(currentLine - 3));
drawVoltageScreen(true); drawVoltageScreen(true);
break; break;
case 5: // timeoutScreen
config->setTimeout((timeout)(currentLine - 3));
drawTimeoutScreen(true);
break;
} }
} }
@ -113,6 +117,9 @@ void UILCD::mainScreenOkButton() {
// break; // break;
// case 7: // configure rtc // case 7: // configure rtc
// break; // break;
case 8:
drawTimeoutScreen(false);
break;
} }
} }
@ -223,6 +230,11 @@ void UILCD::configScreenHighlight(joyDirection direction) {
return; return;
} }
break; break;
case 5: // timeoutScreen
if (currentLine == maxtimeout + 2) {
return;
}
break;
} }
unHilightLine(currentLine); 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) { void UILCD::drawConnectionScreen(bool keepCurrentLine) {
currentScreen = connectionScreen; currentScreen = connectionScreen;
if (!keepCurrentLine) { if (!keepCurrentLine) {

View file

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

View file

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