Whitespace changes

pull/86/head
Clayton Rogers 2021-08-08 16:53:17 -04:00
parent 80c4444576
commit c5c83300da
2 changed files with 185 additions and 187 deletions

View File

@ -114,12 +114,11 @@ void Watchy::_rtcConfig(String datetime){
void Watchy::handleButtonPress(){
uint64_t wakeupBit = esp_sleep_get_ext1_wakeup_status();
//Menu Button
if (wakeupBit & MENU_BTN_MASK){
if(guiState == WATCHFACE_STATE){//enter menu state if coming from watch face
if (wakeupBit & MENU_BTN_MASK) {
if (guiState == WATCHFACE_STATE) {//enter menu state if coming from watch face
showMenu(menuIndex, false);
}else if(guiState == MAIN_MENU_STATE){//if already in menu, then select menu item
switch(menuIndex)
{
} else if (guiState == MAIN_MENU_STATE) {//if already in menu, then select menu item
switch(menuIndex) {
case 0:
showBattery();
break;
@ -141,25 +140,25 @@ void Watchy::handleButtonPress(){
default:
break;
}
}else if(guiState == FW_UPDATE_STATE){
} else if(guiState == FW_UPDATE_STATE) {
updateFWBegin();
}
}
//Back Button
else if (wakeupBit & BACK_BTN_MASK){
if(guiState == MAIN_MENU_STATE){//exit to watch face if already in menu
else if (wakeupBit & BACK_BTN_MASK) {
if (guiState == MAIN_MENU_STATE) {//exit to watch face if already in menu
RTC.alarm(ALARM_2); //resets the alarm flag in the RTC
RTC.read(currentTime);
showWatchFace(false);
}else if(guiState == APP_STATE){
} else if (guiState == APP_STATE) {
showMenu(menuIndex, false);//exit to menu if already in app
}else if(guiState == FW_UPDATE_STATE){
} else if (guiState == FW_UPDATE_STATE) {
showMenu(menuIndex, false);//exit to menu if already in app
}
}
//Up Button
else if (wakeupBit & UP_BTN_MASK){
if(guiState == MAIN_MENU_STATE){//increment menu index
else if (wakeupBit & UP_BTN_MASK) {
if(guiState == MAIN_MENU_STATE) {//increment menu index
menuIndex--;
if(menuIndex < 0){
menuIndex = MENU_LENGTH - 1;
@ -168,10 +167,10 @@ void Watchy::handleButtonPress(){
}
}
//Down Button
else if (wakeupBit & DOWN_BTN_MASK){
else if (wakeupBit & DOWN_BTN_MASK) {
if(guiState == MAIN_MENU_STATE){//decrement menu index
menuIndex++;
if(menuIndex > MENU_LENGTH - 1){
if(menuIndex > MENU_LENGTH - 1) {
menuIndex = 0;
}
showMenu(menuIndex, true);
@ -185,15 +184,14 @@ void Watchy::handleButtonPress(){
pinMode(BACK_BTN_PIN, INPUT);
pinMode(UP_BTN_PIN, INPUT);
pinMode(DOWN_BTN_PIN, INPUT);
while(!timeout){
if(millis() - lastTimeout > 5000){
while(!timeout) {
if (millis() - lastTimeout > 5000) {
timeout = true;
}else{
if(digitalRead(MENU_BTN_PIN) == 1){
} else {
if (digitalRead(MENU_BTN_PIN) == 1) {
lastTimeout = millis();
if(guiState == MAIN_MENU_STATE){//if already in menu, then select menu item
switch(menuIndex)
{
if (guiState == MAIN_MENU_STATE) {//if already in menu, then select menu item
switch(menuIndex) {
case 0:
showBattery();
break;
@ -215,35 +213,35 @@ void Watchy::handleButtonPress(){
default:
break;
}
}else if(guiState == FW_UPDATE_STATE){
} else if (guiState == FW_UPDATE_STATE) {
updateFWBegin();
}
}else if(digitalRead(BACK_BTN_PIN) == 1){
} else if (digitalRead(BACK_BTN_PIN) == 1) {
lastTimeout = millis();
if(guiState == MAIN_MENU_STATE){//exit to watch face if already in menu
if (guiState == MAIN_MENU_STATE) {//exit to watch face if already in menu
RTC.alarm(ALARM_2); //resets the alarm flag in the RTC
RTC.read(currentTime);
showWatchFace(false);
break; //leave loop
}else if(guiState == APP_STATE){
} else if (guiState == APP_STATE) {
showMenu(menuIndex, false);//exit to menu if already in app
}else if(guiState == FW_UPDATE_STATE){
} else if (guiState == FW_UPDATE_STATE) {
showMenu(menuIndex, false);//exit to menu if already in app
}
}else if(digitalRead(UP_BTN_PIN) == 1){
} else if (digitalRead(UP_BTN_PIN) == 1) {
lastTimeout = millis();
if(guiState == MAIN_MENU_STATE){//increment menu index
if (guiState == MAIN_MENU_STATE) {//increment menu index
menuIndex--;
if(menuIndex < 0){
menuIndex = MENU_LENGTH - 1;
}
showFastMenu(menuIndex);
}
}else if(digitalRead(DOWN_BTN_PIN) == 1){
} else if (digitalRead(DOWN_BTN_PIN) == 1) {
lastTimeout = millis();
if(guiState == MAIN_MENU_STATE){//decrement menu index
if (guiState == MAIN_MENU_STATE) {//decrement menu index
menuIndex++;
if(menuIndex > MENU_LENGTH - 1){
if (menuIndex > MENU_LENGTH - 1) {
menuIndex = 0;
}
showFastMenu(menuIndex);
@ -265,15 +263,15 @@ void Watchy::showMenu(byte menuIndex, bool partialRefresh){
int16_t yPos;
const char *menuItems[] = {"Check Battery", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware"};
for(int i=0; i<MENU_LENGTH; i++){
for (int i=0; i<MENU_LENGTH; i++) {
yPos = 30+(MENU_HEIGHT*i);
display.setCursor(0, yPos);
if(i == menuIndex){
if (i == menuIndex) {
display.getTextBounds(menuItems[i], 0, yPos, &x1, &y1, &w, &h);
display.fillRect(x1-1, y1-10, 200, h+15, GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.println(menuItems[i]);
}else{
} else {
display.setTextColor(GxEPD_WHITE);
display.println(menuItems[i]);
}
@ -295,15 +293,15 @@ void Watchy::showFastMenu(byte menuIndex){
int16_t yPos;
const char *menuItems[] = {"Check Battery", "Vibrate Motor", "Show Accelerometer", "Set Time", "Setup WiFi", "Update Firmware"};
for(int i=0; i<MENU_LENGTH; i++){
for (int i=0; i<MENU_LENGTH; i++) {
yPos = 30+(MENU_HEIGHT*i);
display.setCursor(0, yPos);
if(i == menuIndex){
if (i == menuIndex) {
display.getTextBounds(menuItems[i], 0, yPos, &x1, &y1, &w, &h);
display.fillRect(x1-1, y1-10, 200, h+15, GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.println(menuItems[i]);
}else{
} else {
display.setTextColor(GxEPD_WHITE);
display.println(menuItems[i]);
}