Added line speeds (including display) and tx/rx arrow drawing
This commit is contained in:
parent
8291d91866
commit
bcd3bff931
|
@ -57,26 +57,121 @@ char* modeToText[] = {
|
|||
"Cisco console"
|
||||
};
|
||||
|
||||
// Line speeds supported
|
||||
// Abused in for loops / lookup talbes -- DO NOT CHANGE none or set values
|
||||
enum linespeed {
|
||||
twentyFourHundredBaud,
|
||||
ninetySixHundredBaud,
|
||||
nineteenTwoK,
|
||||
thirtyeightFourK,
|
||||
fiftysevenFiveK,
|
||||
oneNineteenTwoK,
|
||||
zero=-1
|
||||
};
|
||||
|
||||
// Description / speed scruct to use in lookup table
|
||||
struct linespeedinfo {
|
||||
char description[8];
|
||||
int linespeed;
|
||||
};
|
||||
|
||||
// Known and supported line speeds
|
||||
linespeedinfo linespeeds[] = {
|
||||
{"2400b", 2400},
|
||||
{"9600b", 9600},
|
||||
{"19.2k", 19200},
|
||||
{"38.4k", 38400},
|
||||
{"57.5k", 57600},
|
||||
{"115k", 115200}
|
||||
};
|
||||
|
||||
// Mode info needed
|
||||
serialmode currentMode = none;
|
||||
serialmode selectedMode = none;
|
||||
linespeed currentLineSpeed = zero;
|
||||
|
||||
// Printing text
|
||||
void printMode(serialmode aMode);
|
||||
void printLineSpeed(linespeedinfo linespeed);
|
||||
|
||||
// Various sets for mode/selection/linespeed
|
||||
void setMode(serialmode aMode);
|
||||
void setSelection(serialmode aMode);
|
||||
void setLineSpeed(linespeed aLineSpeed);
|
||||
|
||||
// Defaults
|
||||
void setDefaults() {
|
||||
setMode(phone);
|
||||
setSelection(phone);
|
||||
setLineSpeed(oneNineteenTwoK);
|
||||
}
|
||||
|
||||
// Figure out offsets
|
||||
int xLoc(int toSkip) { // Physically -- vertical
|
||||
// Figure out offsets for text printing
|
||||
int xLoc(float toSkip) { // Physically -- vertical
|
||||
return (CHAR_HEIGHT * toSkip) + (CHAR_HEIGHT / 2);
|
||||
}
|
||||
int yLoc (int toSkip) { // Physical -- horizontal
|
||||
int yLoc (float toSkip) { // Physical -- horizontal
|
||||
return (CHAR_WIDTH * toSkip) + (CHAR_WIDTH / 2);
|
||||
}
|
||||
|
||||
void printTitles() {
|
||||
lcd.setStr(" RX Ln Spd Tx ", xLoc(5), 0, TEXT, BACKGROUND);
|
||||
}
|
||||
|
||||
void printRx(bool show) {
|
||||
int vertXPosStart = xLoc(6.25);
|
||||
int vertYPosStart = yLoc(1.5);
|
||||
int vertXPosEnd = xLoc(7.25);
|
||||
int vertYPosEnd = yLoc(1.5);
|
||||
|
||||
int lftXPosStart = vertXPosEnd;
|
||||
int lftYPosStart = vertYPosStart;
|
||||
int lftXPosEnd = vertXPosStart + (CHAR_HEIGHT / 2);
|
||||
int lftYPosEnd = vertYPosStart - CHAR_WIDTH;
|
||||
|
||||
int rtXPosStart = vertXPosEnd;
|
||||
int rtYPosStart = vertYPosStart;
|
||||
int rtXPosEnd = vertXPosStart + (CHAR_HEIGHT / 2);
|
||||
int rtYPosEnd = vertYPosStart + CHAR_WIDTH;
|
||||
|
||||
int color = show ? EMERALD : BACKGROUND;
|
||||
|
||||
lcd.setLine(vertXPosStart, vertYPosStart, vertXPosEnd, vertYPosEnd, color);
|
||||
lcd.setLine(lftXPosStart, lftYPosStart, lftXPosEnd, lftYPosEnd, color);
|
||||
lcd.setLine(rtXPosStart, rtYPosStart, rtXPosEnd, rtYPosEnd, color);
|
||||
}
|
||||
|
||||
void printTx(bool show) {
|
||||
int vertXPosStart = xLoc(6.25);
|
||||
int vertYPosStart = yLoc(13.5);
|
||||
int vertXPosEnd = xLoc(7.25);
|
||||
int vertYPosEnd = yLoc(13.5);
|
||||
|
||||
int lftXPosStart = vertXPosStart;
|
||||
int lftYPosStart = vertYPosStart;
|
||||
int lftXPosEnd = vertXPosStart + (CHAR_HEIGHT / 2);
|
||||
int lftYPosEnd = vertYPosStart - CHAR_WIDTH;
|
||||
|
||||
int rtXPosStart = vertXPosStart;
|
||||
int rtYPosStart = vertYPosStart;
|
||||
int rtXPosEnd = vertXPosStart + (CHAR_HEIGHT / 2);
|
||||
int rtYPosEnd = vertYPosStart + CHAR_WIDTH;
|
||||
|
||||
int color = show ? SKYBLUE : BACKGROUND;
|
||||
|
||||
lcd.setLine(vertXPosStart, vertYPosStart, vertXPosEnd, vertYPosEnd, color);
|
||||
lcd.setLine(lftXPosStart, lftYPosStart, lftXPosEnd, lftYPosEnd, color);
|
||||
lcd.setLine(rtXPosStart, rtYPosStart, rtXPosEnd, rtYPosEnd, color);
|
||||
}
|
||||
|
||||
void printLineSpeed(linespeed aLineSpeed) {
|
||||
lcd.setStr(linespeeds[aLineSpeed].description, xLoc(6), yLoc(5), TEXT, BACKGROUND);
|
||||
}
|
||||
|
||||
void printMode(serialmode aMode) {
|
||||
lcd.setStr(" ", xLoc(aMode), yLoc(1), BACKGROUND, BACKGROUND);
|
||||
lcd.setStr(modeToText[aMode], xLoc(aMode), yLoc(1), TEXT, BACKGROUND);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ void setup() {
|
|||
printMode((serialmode)i);
|
||||
}
|
||||
|
||||
// Print the Rx/Tx/Speed titles
|
||||
printTitles();
|
||||
|
||||
// Setup defaults
|
||||
setDefaults();
|
||||
}
|
||||
|
@ -79,6 +82,11 @@ void loop() {
|
|||
}
|
||||
}
|
||||
|
||||
void setLineSpeed(linespeed aLineSpeed) {
|
||||
currentLineSpeed = aLineSpeed;
|
||||
printLineSpeed(aLineSpeed);
|
||||
}
|
||||
|
||||
void setMode(serialmode aMode) {
|
||||
serialmode previousMode = currentMode;
|
||||
currentMode = aMode;
|
||||
|
@ -100,8 +108,3 @@ void setSelection(serialmode aMode) {
|
|||
lcd.setLine(xSelected, yLocOne, xSelected, yLocOne + selectedLength, HILIGHT);
|
||||
lcd.setLine(xPrevious, yLocOne, xPrevious, yLocOne + previousLength, BACKGROUND);
|
||||
}
|
||||
|
||||
void printMode(serialmode aMode) {
|
||||
lcd.setStr(modeToText[aMode], xLoc(aMode), yLoc(1), TEXT, BACKGROUND);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue