Skip to content

Commit

Permalink
Add an "About Watchy" menu item.
Browse files Browse the repository at this point in the history
This replaces "Check Battery" and adds the following info:

  * Firmware version
  * RTC chip type

The firmware version is #defined in Watchy.h.  There might be a
way to do this that's friendlier to the library release process,
but I'll leave that up to the people who actually build the releases.

I plan to extend the About menu with some radio-related info as
I work on getting BLE pairing working with my iPhone.
  • Loading branch information
Lyndon Nerenberg committed Jan 5, 2022
1 parent 26f5ac2 commit bf7425c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
29 changes: 21 additions & 8 deletions src/Watchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void Watchy::handleButtonPress(){
switch(menuIndex)
{
case 0:
showBattery();
showAbout();
break;
case 1:
showBuzz();
Expand Down Expand Up @@ -154,7 +154,7 @@ void Watchy::handleButtonPress(){
switch(menuIndex)
{
case 0:
showBattery();
showAbout();
break;
case 1:
showBuzz();
Expand Down Expand Up @@ -223,7 +223,7 @@ void Watchy::showMenu(byte menuIndex, bool partialRefresh){
uint16_t w, h;
int16_t yPos;

const char *menuItems[] = {"Check Battery", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware", "Sync NTP"};
const char *menuItems[] = {"About Watchy", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware", "Sync NTP"};
for(int i=0; i<MENU_LENGTH; i++){
yPos = MENU_HEIGHT+(MENU_HEIGHT*i);
display.setCursor(0, yPos);
Expand Down Expand Up @@ -252,7 +252,7 @@ void Watchy::showFastMenu(byte menuIndex){
uint16_t w, h;
int16_t yPos;

const char *menuItems[] = {"Check Battery", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware", "Sync NTP"};
const char *menuItems[] = {"About Watchy", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware", "Sync NTP"};
for(int i=0; i<MENU_LENGTH; i++){
yPos = MENU_HEIGHT+(MENU_HEIGHT*i);
display.setCursor(0, yPos);
Expand All @@ -272,17 +272,30 @@ void Watchy::showFastMenu(byte menuIndex){
guiState = MAIN_MENU_STATE;
}

void Watchy::showBattery(){
void Watchy::showAbout(){
display.setFullWindow();
display.fillScreen(GxEPD_BLACK);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_WHITE);
display.setCursor(20, 30);
display.println("Battery Voltage:");
display.setCursor(0, 20);

display.print("FW Ver: ");
display.println(Watchy_Version);

const char *rtc_hw_type;
switch (RTC.rtcType) {
case 0: rtc_hw_type = "DS3231"; break;
case 1: rtc_hw_type = "PCF8563"; break;
default: rtc_hw_type = "<unknown>";
}
display.print("RTC: ");
display.println(rtc_hw_type);

display.print("Batt: ");
float voltage = getBatteryVoltage();
display.setCursor(70, 80);
display.print(voltage);
display.println("V");

display.display(false); //full refresh

guiState = APP_STATE;
Expand Down
6 changes: 4 additions & 2 deletions src/Watchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "bma.h"
#include "config.h"

#define Watchy_Version "1.3.1"

typedef struct weatherData{
int8_t temperature;
int16_t weatherConditionCode;
Expand Down Expand Up @@ -54,7 +56,7 @@ class Watchy {
void handleButtonPress();
void showMenu(byte menuIndex, bool partialRefresh);
void showFastMenu(byte menuIndex);
void showBattery();
void showAbout();
void showBuzz();
void showAccelerometer();
void showUpdateFW();
Expand Down Expand Up @@ -84,4 +86,4 @@ extern RTC_DATA_ATTR BMA423 sensor;
extern RTC_DATA_ATTR bool WIFI_CONFIGURED;
extern RTC_DATA_ATTR bool BLE_CONFIGURED;

#endif
#endif
2 changes: 1 addition & 1 deletion src/WatchyRTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ String WatchyRTC::_getValue(String data, char separator, int index)
}

return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}
}

0 comments on commit bf7425c

Please sign in to comment.