Skip to content

Commit

Permalink
added "progress bar" as you cycle through the settings screens
Browse files Browse the repository at this point in the history
  • Loading branch information
barry-ha committed Jan 22, 2024
1 parent 74ea9c6 commit 42062e0
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 36 deletions.
7 changes: 4 additions & 3 deletions cfg_audio_type.h
Expand Up @@ -70,7 +70,7 @@ class ViewCfgAudioType : public View {
const int yRow1 = 80; // "Announcements", "Morse code"
const int yRow2 = yRow1 + 52; // "Spoken word"
const int yRow3 = yRow2 + 52; // "No audio"
const int yRow9 = gScreenHeight - 12; // "v1.11, Dec 13 2022"
const int yRow9 = gScreenHeight - 10; // "v1.14, Jan 22 2024"

#define col1 10 // left-adjusted column of text
#define xButton 160 // indented column of buttons
Expand All @@ -85,14 +85,14 @@ class ViewCfgAudioType : public View {
};

// clang-format off
#define nTxtSettings5 5
#define nTxtSettings5 4
TextField txtSettings5[nTxtSettings5] = {
// text x, y color
{"Audio Type", -1, 20, cHIGHLIGHT, ALIGNCENTER}, // [SETTINGS]
{"Announce", col1, yRow1, cVALUE}, // [ANNOUNCEMENTS]
{"grids using:", col1, yRow1 + 20, cVALUE}, // [ANNOUNCEMENTS2]
{PROGRAM_VERDATE, -1, yRow9, cLABEL, ALIGNCENTER}, // [COMPILED]
{"2 of 6", xPanel, 20, cFAINT}, // [PANEL]
//{"2 of 6", xPanel, 20, cFAINT}, // [PANEL]
};
// clang-format on

Expand Down Expand Up @@ -204,6 +204,7 @@ void ViewCfgAudioType::startScreen() {
txtSettings5[ii].print();
}

showProgressBar(2, 6); // draw marker for advancing through settings
showScreenBorder(); // optionally outline visible area
showScreenCenterline(); // optionally draw alignment bar

Expand Down
7 changes: 4 additions & 3 deletions cfg_crossing.h
Expand Up @@ -61,7 +61,7 @@ class ViewCfgCrossing : public View {
const int yRow1 = 70; // "Announce at", "4-Digit"
const int yRow2 = yRow1 + 24; // "grid crossing"
const int yRow3 = yRow1 + 68; // "6-Digit"
const int yRow9 = gScreenHeight - 12; // "v0.38, Apr 13 2021"
const int yRow9 = gScreenHeight - 10; // "v1.14, Jan 22 2024"

#define col1 10 // left-adjusted column of text
#define xButton 160 // indented column of buttons
Expand All @@ -78,7 +78,7 @@ class ViewCfgCrossing : public View {
};

// clang-format off
#define nTextCrossing 7
#define nTextCrossing 6
TextField txtSettings4[nTextCrossing] = {
// text x, y color
{"Announcements", -1, 20, cHIGHLIGHT, ALIGNCENTER}, // [SETTINGS]
Expand All @@ -87,7 +87,7 @@ class ViewCfgCrossing : public View {
{"70 - 100 mi", xButton + 24, yRow1 + 22, cVALUE}, // [DISTANCE4]
{"3 - 4 mi", xButton + 38, yRow3 + 22, cVALUE}, // [DISTANCE6]
{PROGRAM_VERDATE, -1, yRow9, cLABEL, ALIGNCENTER}, // [COMPILED]
{"3 of 6", xPanel, 20, cFAINT}, // [PANEL]
//{"3 of 6", xPanel, 20, cFAINT}, // [PANEL]
};
// clang-format on

Expand Down Expand Up @@ -197,6 +197,7 @@ void ViewCfgCrossing::startScreen() {
txtSettings4[ii].print();
}

showProgressBar(3, 6); // draw marker for advancing through settings
showScreenBorder(); // optionally outline visible area
showScreenCenterline(); // optionally draw alignment bar

Expand Down
9 changes: 5 additions & 4 deletions cfg_gps.h
Expand Up @@ -63,7 +63,7 @@ class ViewCfgGPS : public View {
const int yRow2 = yRow1 + 20; // "%d of %d"
const int yRow3 = yRow2 + 52; // "Route", "GPS Receiver"
const int yRow4 = yRow3 + 48; // "Simulator"
const int yRow9 = gScreenHeight - 12; // "v0.32, Feb 2 2021"
const int yRow9 = gScreenHeight - 10; // "v1.14, Jan 22 2024"

#define col1 10 // left-adjusted column of text
#define xButton 160 // indented column of buttons
Expand All @@ -79,15 +79,15 @@ class ViewCfgGPS : public View {
};

// clang-format off
#define nTextGPS 6
#define nTextGPS 5
TextField txtSettings2[nTextGPS] = {
// text x, y color
{"GPS", -1, 20, cHIGHLIGHT, ALIGNCENTER}, // [SETTINGS]
{"Breadcrumb trail", col1, yRow1, cVALUE}, // [TRAIL]
{"%d crumbs", col1, yRow2, cLABEL}, // [TRAILCOUNT]
{"Route", col1, yRow3, cVALUE}, // [GPSTYPE]
{PROGRAM_VERDATE, -1, yRow9, cLABEL, ALIGNCENTER}, // [COMPILED]
{"4 of 6", xPanel, 20, cFAINT}, // [PANEL]
//{"4 of 6", xPanel, 20, cFAINT}, // [PANEL]
};
// clang-format on

Expand Down Expand Up @@ -205,7 +205,8 @@ void ViewCfgGPS::startScreen() {
tft->drawCircle(xCenter, yCenter, 7, cVALUE);
}

updateScreen(); // fill in values immediately, don't wait for the main loop to eventually get around to it
showProgressBar(4, 6); // draw marker for advancing through settings
updateScreen(); // fill in values immediately, don't wait for the main loop to eventually get around to it

showScreenCenterline(); // optionally draw alignment bar
}
Expand Down
23 changes: 12 additions & 11 deletions cfg_reboot.h
Expand Up @@ -69,12 +69,12 @@ class ViewCfgReboot : public View {
const int space = 30;
const int half = space / 2;

const int yRow1 = 20; // title "Firmware Update"
const int yRow2 = yRow1 + space; // "This option starts bootloader mode."
const int yRow3 = yRow2 + space; // "Do you have a UF2 file?"
const int yRow4 = yRow3 + space; // "Do you want to install it?""
const int yRow5 = yRow4 + half; // "Cancel", "Install UF2" buttons
const int yRow9 = gScreenHeight - 4; // "v1.12, Mar 30 2023"
const int yRow1 = 20; // title "Firmware Update"
const int yRow2 = yRow1 + space; // "This option starts bootloader mode."
const int yRow3 = yRow2 + space; // "Do you have a UF2 file?"
const int yRow4 = yRow3 + space; // "Do you want to install it?""
const int yRow5 = yRow4 + half; // "Cancel", "Install UF2" buttons
const int yRow9 = gScreenHeight - 10; // "v1.14, Jan 22 2024"

// ----- screen text
// names for the array indexes, must be named in same order as array below
Expand All @@ -90,17 +90,17 @@ class ViewCfgReboot : public View {
const int left = 30; // x: left text edge
const int top = 40; // y: top text row

// ----- static screen text
// clang-format off
#define nRebootValues 6
// ----- static screen text
// clang-format off
#define nRebootValues 5
TextField txtValues[nRebootValues] = {
// text x, y color
{"7. Firmware Update", -1, yRow1, cHIGHLIGHT, ALIGNCENTER, eFONTSMALLEST}, // [TITLE] centered
{"This option starts bootloader mode.", -1, yRow2, cLABEL, ALIGNCENTER, eFONTSMALLEST}, // [LINE1] centered
{"Do you have a UF2 file?", left, yRow3, cVALUE, ALIGNLEFT, eFONTSMALL}, // [LINE2]
{"Do you want to install it?", left, yRow4, cVALUE, ALIGNLEFT, eFONTSMALL}, // [LINE3]
{PROGRAM_VERDATE, -1, yRow9, cLABEL, ALIGNCENTER}, // [COMPILED]
{"7 of 6", xPanel, 20, cFAINT, ALIGNLEFT}, // [PANEL]
//{"7 of 6", xPanel, 20, cFAINT, ALIGNLEFT}, // [PANEL]
};

enum buttonID {
Expand Down Expand Up @@ -207,7 +207,8 @@ void ViewCfgReboot::startScreen() {
tft->print(item.text);
}

updateScreen(); // update UI immediately, don't wait for the main loop to eventually get around to it
showProgressBar(7, 6); // draw marker for advancing through settings
updateScreen(); // update UI immediately, don't wait for the main loop to eventually get around to it
} // end startScreen()

bool ViewCfgReboot::onTouch(Point touch) {
Expand Down
11 changes: 6 additions & 5 deletions cfg_rotation.h
Expand Up @@ -57,7 +57,7 @@ class ViewCfgRotation : public View {
// vertical placement of text rows ---label--- ---button---
const int yRow1 = 70; // "Screen Orientation", "This edge up"
const int yRow2 = yRow1 + 70; // "That edge up"
const int yRow9 = gScreenHeight - 12; // "v1.03, Jul 9 2021"
const int yRow9 = gScreenHeight - 10; // "v1.14, Jan 22 2024"

#define col1 10 // left-adjusted column of text
#define xButton 160 // indented column of buttons
Expand All @@ -72,14 +72,14 @@ class ViewCfgRotation : public View {
};

// clang-format off
#define nFields 5
#define nFields 4
TextField txtSettings6[nFields] = {
// text x, y color
{"Rotation", -1, 20, cHIGHLIGHT, ALIGNCENTER}, // [SETTINGS]
{"Screen", col1, yRow1, cVALUE}, // [SCREEN]
{"Orientation", col1, yRow1 + 20, cVALUE}, // [ORIENTATION]
{PROGRAM_VERDATE, -1, yRow9, cLABEL, ALIGNCENTER}, // [COMPILED]
{"6 of 6", xPanel, 20, cFAINT}, // [PANEL]
//{"6 of 6", xPanel, 20, cFAINT}, // [PANEL]
};
// clang-format on

Expand All @@ -97,7 +97,7 @@ class ViewCfgRotation : public View {
};
// clang-format on

#define xLine (xButton + 80)
#define xLine (xButton + 92)
#define topY 8
#define botY (gScreenHeight - 6)

Expand Down Expand Up @@ -194,7 +194,8 @@ void ViewCfgRotation::startScreen() {
tft->drawCircle(xCenter, yCenter, 7, cVALUE);
}

updateScreen(); // update UI immediately, don't wait for laggy mainline loop
showProgressBar(6, 6); // draw marker for advancing through settings
updateScreen(); // update UI immediately, don't wait for laggy mainline loop
} // end startScreen()

bool ViewCfgRotation::onTouch(Point touch) {
Expand Down
17 changes: 9 additions & 8 deletions cfg_units.h
Expand Up @@ -56,7 +56,7 @@ class ViewCfgUnits : public View {
// vertical placement of text rows ---label--- ---button---
const int yRow1 = 84; // "English", "Miles, inHg"
const int yRow2 = yRow1 + 50; // "Metric", "Kilometers, hPa"
const int yRow9 = gScreenHeight - 12; // "v0.35, Feb 25 2021"
const int yRow9 = gScreenHeight - 10; // "v1.14, Jan 22 2024"

#define col1 10 // left-adjusted column of text
#define xButton 160 // indented column of buttons
Expand All @@ -71,14 +71,14 @@ class ViewCfgUnits : public View {
};

// clang-format off
#define nTextUnits 5
#define nTextUnits 4
TextField txtSettings3[nTextUnits] = {
// text x, y color
{"Units", -1, 20, cHIGHLIGHT, ALIGNCENTER}, // [SETTINGS]
{"English", col1, yRow1, cVALUE}, // [ENGLISH]
{"Metric", col1, yRow2, cVALUE}, // [METRIC]
{PROGRAM_VERDATE, -1, yRow9, cLABEL, ALIGNCENTER}, // [COMPILED]
{"5 of 6", xPanel, 20, cFAINT, ALIGNLEFT}, // [PANEL]
//{"5 of 6", xPanel, 20, cFAINT, ALIGNLEFT}, // [PANEL]
};
// clang-format on

Expand Down Expand Up @@ -136,11 +136,11 @@ void ViewCfgUnits::startScreen() {
TextField::setTextDirty(txtSettings3, nTextUnits); // make sure all fields get re-printed on screen change
setFontSize(eFONTSMALLEST);

drawAllIcons(); // draw gear (settings) and arrow (next screen)
showDefaultTouchTargets(); // optionally draw box around default button-touch areas
drawAllIcons(); // draw gear (settings) and arrow (next screen)
showDefaultTouchTargets(); // optionally draw box around default button-touch areas
showMyTouchTargets(settings3Buttons, nButtonsUnits); // optionally show this view's touch targets
showScreenBorder(); // optionally outline visible area
showScreenCenterline(); // optionally draw visual alignment bar
showScreenBorder(); // optionally outline visible area
showScreenCenterline(); // optionally draw visual alignment bar

// ----- draw text fields
for (int ii = 0; ii < nTextUnits; ii++) {
Expand Down Expand Up @@ -173,7 +173,8 @@ void ViewCfgUnits::startScreen() {
tft->drawCircle(xCenter, yCenter, 7, cVALUE);
}

updateScreen(); // update UI immediately, don't wait for laggy mainline loop
showProgressBar(5, 6); // draw marker for advancing through settings
updateScreen(); // update UI immediately, don't wait for laggy mainline loop
} // end startScreen()

void ViewCfgUnits::endScreen() {
Expand Down
5 changes: 3 additions & 2 deletions cfg_volume.h
Expand Up @@ -70,8 +70,9 @@ class ViewVolume : public View {
// color scheme: see constants.h

// vertical placement of text rows
const int yRow1 = 50; // label: "Audio Volume"
const int yRow2 = yRow1 + 30; // text: "of 10"
const int yRow1 = 50; // label: "Audio Volume"
const int yRow2 = yRow1 + 30; // text: "of 10"
const int yRow9 = gScreenHeight - 10; // "v1.14, Jan 22 2024"

#define xButton 160 // indented column of buttons

Expand Down
19 changes: 19 additions & 0 deletions view.h
Expand Up @@ -116,6 +116,25 @@ class View {
tft->print(sName);
}

void showProgressBar(int screen, int numScreens) {
// draw marker for advancing through settings, eg, 1 of 6, 2 of 6, etc.
int x0 = 74; // lhs bounding box
int y0 = 28; // top bounding box
int w = 320 - x0 - x0; // width of bounding box
int h = 10; // height bounding box
int c = cBUTTONOUTLINE;

int wi = w / numScreens; // width of each item
for (int ii = 0; ii < numScreens; ii++) {
if (ii == (screen - 1)) {
// x, y, w, h, color
tft->fillRect(x0 + ii * wi, y0, wi, h, cFAINT);
} else {
tft->drawRect(x0 + ii * wi, y0, wi, h, cFAINTER);
}
}
}

/**
* Rotate screen right-side-up / upside-down
* 1=landscape, 3=landscape 180-degrees
Expand Down

0 comments on commit 42062e0

Please sign in to comment.