diff --git a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp index a7459f3..88dd183 100644 --- a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp @@ -41,8 +41,9 @@ CBasicScreen::CBasicScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr) { - _showSetMode = 0; - _showMode = 0; + _showSetModeTime = 0; + _showModeTime = 0; + _feedbackType = 0; _nModeSel = 0; } @@ -79,11 +80,11 @@ CBasicScreen::show() // Current heat demand setting // Run state of heater - if(_showMode) { + if(_showModeTime) { const int border = 3; const int radius = 4; // Show selection between Fixed or Thermostat mode - long tDelta = millis() - _showMode; + long tDelta = millis() - _showModeTime; if(tDelta < 0) { yPos = _display.height() - _display.textHeight() - border; // bottom of screen, with room for box @@ -102,35 +103,46 @@ CBasicScreen::show() } else { // cancel selection mode, apply whatever is boxed - _showMode = 0; - _showSetMode = millis() + 5000; // then make the new mode setting be shown + _showModeTime = 0; + _showSetModeTime = millis() + 5000; // then make the new mode setting be shown + _feedbackType = 0; + _ScreenManager.reqUpdate(); } } - if((_showMode == 0) && _showSetMode) { - long tDelta = millis() - _showSetMode; + if((_showModeTime == 0) && _showSetModeTime) { + long tDelta = millis() - _showSetModeTime; if(tDelta < 0) { - // Show current heat demand setting - if(getThermostatModeActive()) { - float fTemp = getTemperatureDesired(); - if(NVstore.getDegFMode()) { - fTemp = fTemp * 9 / 5 + 32; - sprintf(msg, "Setpoint = %.0f`F", fTemp); - } - else { - sprintf(msg, "Setpoint = %.0f`C", fTemp); - } - } - else { - sprintf(msg, "Setpoint = %.1fHz", getHeaterInfo().getPump_Fixed()); + switch(_feedbackType) { + case 0: + // Show current heat demand setting + + if(getThermostatModeActive()) { + float fTemp = getTemperatureDesired(); + if(NVstore.getDegFMode()) { + fTemp = fTemp * 9 / 5 + 32; + sprintf(msg, "Setpoint = %.0f`F", fTemp); + } + else { + sprintf(msg, "Setpoint = %.0f`C", fTemp); + } + } + else { + sprintf(msg, "Setpoint = %.1fHz", getHeaterInfo().getPump_Fixed()); + } + break; + case 1: + case 2: + sprintf(msg, "GPIO output #%d %s", _feedbackType, getGPIO(_feedbackType-1) ? "ON" : "OFF"); + break; } // centre message at bottom of screen _printMenuText(_display.xCentre(), _display.height() - _display.textHeight(), msg, false, eCentreJustify); } else { - _showSetMode = 0; + _showSetModeTime = 0; } } - if((_showMode == 0) && (_showSetMode == 0)) { + if((_showModeTime == 0) && (_showSetModeTime == 0)) { showRunState(); } return true; @@ -144,51 +156,11 @@ CBasicScreen::keyHandler(uint8_t event) if(event & keyPressed) { repeatCount = 0; // unlock tracking of repeat events -/* // press LEFT to select previous screen, or Fixed Hz mode when in mode select - if(event & key_Left) { - if(!_showMode) - _ScreenManager.prevMenu(); - else { - if(hasOEMcontroller()) - _reqOEMWarning(); - else { - _showMode = millis() + 5000; - _nModeSel = 0; - setThermostatMode(1); // set the new mode - NVstore.save(); - } - _ScreenManager.reqUpdate(); - } - }**/ -/* // press RIGHT to select next screen, or Thermostat mode when in mode select - if(event & key_Right) { - if(!_showMode) - _ScreenManager.nextMenu(); - else { - if(hasOEMcontroller()) - _reqOEMWarning(); - else { - _showMode = millis() + 5000; - _nModeSel = 1; - setThermostatMode(0); // set the new mode - NVstore.save(); - } - _ScreenManager.reqUpdate(); - } - }*/ - // press UP & DOWN to toggle thermostat / fixed Hz mode - // impossible with 5 way switch! - uint8_t doubleKey = key_Down | key_Up; - if((event & doubleKey) == doubleKey) { - if(reqThermoToggle()) { - _showSetMode = millis() + 2000; - NVstore.save(); - } - else - _reqOEMWarning(); - } } + + // // use repeat function for key hold detection + // if(event & keyRepeat) { if(repeatCount >= 0) { repeatCount++; @@ -197,6 +169,9 @@ CBasicScreen::keyHandler(uint8_t event) if(repeatCount > 2) { repeatCount = -1; // prevent double handling setGPIO(0, !getGPIO(0)); // toggle GPIO output #1 + _showSetModeTime = millis() + 2000; + _feedbackType = 1; + _ScreenManager.reqUpdate(); } } // hold RIGHT to toggle GPIO output #2 @@ -204,13 +179,16 @@ CBasicScreen::keyHandler(uint8_t event) if(repeatCount > 2) { repeatCount = -1; // prevent double handling setGPIO(1, !getGPIO(1)); // toggle GPIO output #2 + _showSetModeTime = millis() + 2000; + _feedbackType = 2; + _ScreenManager.reqUpdate(); } } // hold DOWN to enter thermostat / fixed mode selection if(event & key_Down) { if(repeatCount > 2) { repeatCount = -1; // prevent double handling - _showMode = millis() + 5000; + _showModeTime = millis() + 5000; _nModeSel = getThermostatModeActive() ? 0 : 1; } } @@ -218,7 +196,7 @@ CBasicScreen::keyHandler(uint8_t event) if(event & key_Up) { if(repeatCount > 2) { repeatCount = -1; // prevent double handling - _showMode = millis() + 5000; + _showModeTime = millis() + 5000; NVstore.setDegFMode(NVstore.getDegFMode() ? 0 : 1); } } @@ -241,33 +219,43 @@ CBasicScreen::keyHandler(uint8_t event) } } } + + // + // key released handling + // if(event & keyReleased) { - if(!_showMode) { + if(!_showModeTime) { // release DOWN key to reduce set demand, provided we are not in mode select if(event & key_Down) { - if(reqTempDelta(-1)) - _showSetMode = millis() + 2000; + if(reqTempDelta(-1)) { + _showSetModeTime = millis() + 2000; + _feedbackType = 0; + _ScreenManager.reqUpdate(); + } else _reqOEMWarning(); } // release UP key to increase set demand, provided we are not in mode select if(event & key_Up) { - if(reqTempDelta(+1)) - _showSetMode = millis() + 2000; + if(reqTempDelta(+1)) { + _showSetModeTime = millis() + 2000; + _feedbackType = 0; + _ScreenManager.reqUpdate(); + } else _reqOEMWarning(); } } if(event & key_Left) { if(repeatCount >= 0) { - if(!_showMode) { + if(!_showModeTime) { _ScreenManager.prevMenu(); } else { if(hasOEMcontroller()) _reqOEMWarning(); else { - _showMode = millis() + 5000; + _showModeTime = millis() + 5000; _nModeSel = 0; setThermostatMode(1); // set the new mode NVstore.save(); @@ -278,13 +266,13 @@ CBasicScreen::keyHandler(uint8_t event) } if(event & key_Right) { if(repeatCount >= 0) { - if(!_showMode) + if(!_showModeTime) _ScreenManager.nextMenu(); else { if(hasOEMcontroller()) _reqOEMWarning(); else { - _showMode = millis() + 5000; + _showModeTime = millis() + 5000; _nModeSel = 1; setThermostatMode(0); // set the new mode NVstore.save(); @@ -296,10 +284,11 @@ CBasicScreen::keyHandler(uint8_t event) // release CENTRE to accept new mode, and/or show current setting if(event & key_Centre) { if(repeatCount != -2) { // prevent after off commands - if(_showMode) { - _showMode = millis(); // force immediate cancellation of showmode (via screen update) + if(_showModeTime) { + _showModeTime = millis(); // force immediate cancellation of showmode (via screen update) } - _showSetMode = millis() + 2000; + _showSetModeTime = millis() + 2000; + _feedbackType = 0; } _ScreenManager.reqUpdate(); } diff --git a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.h b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.h index e9adfa0..d6d1bd4 100644 --- a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.h +++ b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.h @@ -28,8 +28,9 @@ class CProtocolPackage; class CBasicScreen : public CScreenHeader { - unsigned long _showSetMode; - unsigned long _showMode; + unsigned long _showSetModeTime; + unsigned char _feedbackType; + unsigned long _showModeTime; unsigned char _nModeSel; void showRunState(); public: diff --git a/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp index eda3196..68d79f1 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp @@ -79,14 +79,6 @@ CClockScreen::keyHandler(uint8_t event) { if(event & keyPressed) { _keyRepeatCount = 0; // unlock tracking of repeat events - // press LEFT -/* if(event & key_Left) { - _ScreenManager.prevMenu(); - } - // press RIGHT - if(event & key_Right) { - _ScreenManager.nextMenu(); - }*/ // press UP if(event & key_Up) { _ScreenManager.selectMenu(CScreenManager::BranchMenu, CScreenManager::SetClockUI); // switch to clock set screen diff --git a/Arduino/BTCDieselHeater/src/OLED/DetailedScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/DetailedScreen.cpp index 676e5f9..03ecb8a 100644 --- a/Arduino/BTCDieselHeater/src/OLED/DetailedScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/DetailedScreen.cpp @@ -176,12 +176,6 @@ CDetailedScreen::keyHandler(uint8_t event) if(event & keyPressed) { _keyRepeatCount = 0; // unlock tracking of repeat events -/* if(event & key_Left) { - _ScreenManager.prevMenu(); - } - if(event & key_Right) { - _ScreenManager.nextMenu(); - }*/ } // require hold to turn ON or OFF if(event & keyRepeat) { diff --git a/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp index df0043b..09c23c5 100644 --- a/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.cpp @@ -26,6 +26,7 @@ #include "../Utility/UtilClasses.h" #include "../Utility/NVStorage.h" #include "../Utility/GPIO.h" +#include "fonts/Icons.h" extern CGPIOout GPIOout; extern CGPIOin GPIOin; @@ -296,3 +297,100 @@ CGPIOScreen::_adjust(int dir) break; } } + + + +CGPIOInfoScreen::CGPIOInfoScreen(C128x64_OLED& display, CScreenManager& mgr) : CScreenHeader(display, mgr) +{ + _keyRepeatCount = -1; +} + +void +CGPIOInfoScreen::onSelect() +{ + CScreenHeader::onSelect(); +} + +void +CGPIOInfoScreen::_initUI() +{ +} + +bool +CGPIOInfoScreen::show() +{ + CScreenHeader::show(); + + _display.writeFillRect(49, 18, 30, 12, WHITE); + _printInverted(64, 20, "GPIO", true, eCentreJustify); + _printMenuText(22, 18, "In", false, eCentreJustify); + _printMenuText(104, 18, "Out", false, eCentreJustify); + _printMenuText(11, 20, "1", false, eCentreJustify); + _printMenuText(34, 20, "2", false, eCentreJustify); + _printMenuText(91, 20, "1", false, eCentreJustify); + _printMenuText(118, 20, "2", false, eCentreJustify); + + _printMenuText(55, Line1, "Analogue:", false, eRightJustify); + + _display.drawBitmap(4, 29, GPIOin.getState(0) ? CloseIcon : OpenIcon, CloseIconWidth, CloseIconHeight, WHITE); + _display.drawBitmap(27, 29, GPIOin.getState(1) ? CloseIcon : OpenIcon, CloseIconWidth, CloseIconHeight, WHITE); + + _display.drawBitmap(86, 29, GPIOout.getState(0) ? BulbOnIcon : BulbOffIcon, BulbOnIconWidth, BulbOnIconHeight, WHITE); + _display.drawBitmap(113, 29, GPIOout.getState(1) ? BulbOnIcon : BulbOffIcon, BulbOnIconWidth, BulbOnIconHeight, WHITE); + + _printMenuText(_display.xCentre(), 53, " \021 \030Edit \020 ", true, eCentreJustify); + return true; +} + + +bool +CGPIOInfoScreen::keyHandler(uint8_t event) +{ + if(event & keyPressed) { + _keyRepeatCount = 0; // unlock tracking of repeat events + // UP press + if(event & key_Up) { + } + // CENTRE press + if(event & key_Centre) { + } + } + if(event & keyRepeat) { + if(_keyRepeatCount >= 0) { + _keyRepeatCount++; + // hold LEFT to toggle GPIO output #1 + if(event & key_Left) { + if(_keyRepeatCount > 2) { + _keyRepeatCount = -1; // prevent double handling + setGPIO(0, !getGPIO(0)); // toggle GPIO output #1 + } + } + // hold RIGHT to toggle GPIO output #2 + if(event & key_Right) { + if(_keyRepeatCount > 2) { + _keyRepeatCount = -1; // prevent double handling + setGPIO(1, !getGPIO(1)); // toggle GPIO output #2 + } + } + } + } + + // release event + if(event & keyReleased) { + if(_keyRepeatCount == 0) { // short Up press - lower target + // press LEFT to select previous screen + if(event & key_Left) { + _ScreenManager.prevMenu(); + } + // press RIGHT to select next screen + if(event & key_Right) { + _ScreenManager.nextMenu(); + } + } + _keyRepeatCount = -1; + } + _ScreenManager.reqUpdate(); + + return true; +} + diff --git a/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.h b/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.h index 6125b59..70caa69 100644 --- a/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.h +++ b/Arduino/BTCDieselHeater/src/OLED/GPIOScreen.h @@ -46,4 +46,15 @@ public: void onSelect(); }; +class CGPIOInfoScreen : public CScreenHeader +{ + int _keyRepeatCount; + void _initUI(); +public: + CGPIOInfoScreen(C128x64_OLED& display, CScreenManager& mgr); + bool show(); + bool keyHandler(uint8_t event); + void onSelect(); +}; + #endif diff --git a/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp b/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp index aff479d..3cc52dc 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp @@ -35,17 +35,28 @@ #define MINIFONT miniFontInfo -#define X_BATT_ICON 103 -#define Y_BATT_ICON 0 -#define X_WIFI_ICON 19 -#define Y_WIFI_ICON 0 #define X_BT_ICON 10 #define Y_BT_ICON 0 -#define X_TIMER1_ICON 69 -#define X_TIMER2_ICON 83 -#define Y_TIMER_ICON 0 -#define X_CLOCK 52 +#define X_WIFI_ICON 19 +#define Y_WIFI_ICON 0 +#define X_CLOCK 50 #define Y_CLOCK 0 +#define X_TIMER_ICON 83 +#define Y_TIMER_ICON 0 +#define X_BATT_ICON 103 +#define Y_BATT_ICON 0 + +/*#define X_BT_ICON 20 +#define Y_BT_ICON 0 +#define X_WIFI_ICON 29 +#define Y_WIFI_ICON 0 +#define X_GPIO_ICON 9 +#define X_CLOCK 56 +#define Y_CLOCK 0 +#define X_TIMER_ICON 84 +#define Y_TIMER_ICON 0 +#define X_BATT_ICON 103 +#define Y_BATT_ICON 0*/ CScreenHeader::CScreenHeader(C128x64_OLED& disp, CScreenManager& mgr) : CScreen(disp, mgr) @@ -73,6 +84,9 @@ CScreenHeader::show() // timers int numTimers = showTimers(); +// // GPIO +// showGPIO(); + // clock showTime(numTimers); @@ -142,7 +156,7 @@ CScreenHeader::animate() void CScreenHeader::showBTicon() { - if(getBluetoothClient().isConnected()) { + if(getBluetoothClient().isConnected() || true) { _display.drawBitmap(X_BT_ICON, Y_BT_ICON, BTicon, W_BT_ICON, H_BT_ICON, WHITE); } } @@ -207,7 +221,7 @@ CScreenHeader::showTimers() { int nextTimer = CTimerManager::getNextTimer(); if(nextTimer) { - int xPos = X_TIMER2_ICON; // both are enabled - draw icon 1 to the left, otherwise leave to the right + int xPos = X_TIMER_ICON; _display.drawBitmap(xPos, Y_TIMER_ICON, largeTimerIcon, W_TIMER_ICON, H_TIMER_ICON, WHITE); if(nextTimer & 0x80) _display.drawBitmap(xPos-3, Y_TIMER_ICON, verticalRepeatIcon, verticalRepeatWidthPixels, verticalRepeatHeightPixels, WHITE); @@ -248,11 +262,31 @@ CScreenHeader::showTime(int numTimers) int xPos = X_WIFI_ICON + W_WIFI_ICON + W_WIFIIN_ICON; // rhs of wifi conglomeration if(isWifiAP()) xPos += 4; // add more if an Access Point - switch(numTimers) { +/* switch(numTimers) { case 0: xPos = _display.xCentre(); break; - case 1: xPos += (X_TIMER2_ICON - xPos) / 2; break; - case 2: xPos += (X_TIMER1_ICON - xPos) / 2; break; + case 1: xPos += (X_TIMER_ICON - xPos) / 2; break; } - _printMenuText(xPos, Y_CLOCK, msg, false, eCentreJustify); + _printMenuText(xPos, Y_CLOCK, msg, false, eCentreJustify);*/ + _printMenuText(X_CLOCK, Y_CLOCK, msg); } -} \ No newline at end of file +} + +void +CScreenHeader::showGPIO() +{ +/* int xPos = X_GPIO_ICON; // both are enabled - draw icon 1 to the left, otherwise leave to the right + CTransientFont AF(_display, &MINIFONT); // temporarily use a mini font + _display.setCursor(xPos, 0); + _display.print("1"); + _display.drawBitmap(xPos + 4, 0, getGPIO(0) ? TickIcon : CrossIcon, TickIconWidth, TickIconHeight, WHITE); + _display.setCursor(xPos, 6); + _display.print("2"); + _display.drawBitmap(xPos + 4, 6, getGPIO(1) ? TickIcon : CrossIcon, TickIconWidth, TickIconHeight, WHITE);*/ +} +/*void +CScreenHeader::showGPIO() +{ + int xPos = X_GPIO_ICON; // both are enabled - draw icon 1 to the left, otherwise leave to the right + _display.drawBitmap(xPos, 0, getGPIO(0) ? GPIO1ONIcon : GPIO1OFFIcon, GPIOIconWidthPixels, GPIOIconHeightPixels, WHITE); + _display.drawBitmap(xPos, 8, getGPIO(1) ? GPIO2ONIcon : GPIO2OFFIcon, GPIOIconWidthPixels, GPIOIconHeightPixels, WHITE); +}*/ diff --git a/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.h b/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.h index 78e2f6d..494f45a 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.h +++ b/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.h @@ -38,6 +38,7 @@ protected: void showBatteryIcon(float voltage); int showTimers(); virtual void showTime(int numTimers); // x location depends upon how many timers are active + void showGPIO(); public: CScreenHeader(C128x64_OLED& disp, CScreenManager& mgr); bool show(); diff --git a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp index bf14c20..fc4fe50 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp @@ -180,7 +180,8 @@ CScreenManager::begin(bool bNoClock) menuloop.push_back(new CClockScreen(*_pDisplay, *this)); // clock menuloop.push_back(new CPrimingScreen(*_pDisplay, *this)); // mode / priming menuloop.push_back(new CWiFiScreen(*_pDisplay, *this)); // comms info - menuloop.push_back(new CSettingsScreen(*_pDisplay, *this)); // tuning info + menuloop.push_back(new CGPIOInfoScreen(*_pDisplay, *this)); // GPIO info + menuloop.push_back(new CSettingsScreen(*_pDisplay, *this)); // Tuning info _Screens.push_back(menuloop); // create timer screens loop menuloop.clear(); diff --git a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.h b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.h index b5c835d..14c707d 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.h +++ b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.h @@ -44,7 +44,7 @@ class CScreenManager { void _changeSubMenu(int dir); public: enum eUIMenuSets { RootMenuLoop, TimerMenuLoop, TuningMenuLoop, UserSettingsLoop, BranchMenu }; - enum eUIRootMenus { DetailedControlUI, BasicControlUI, ClockUI, ModeUI, CommsUI, SettingsUI }; + enum eUIRootMenus { DetailedControlUI, BasicControlUI, ClockUI, ModeUI, CommsUI, GPIOInfoUI, SettingsUI }; enum eUITimerMenus { TimerOverviewUI, Timer1UI, Timer2UI, Timer3UI, Timer4UI, Timer5UI, Timer6UI, Timer7UI, Timer8UI, Timer9UI, Timer10UI, Timer11UI, Timer12UI, Timer13UI, Timer14UI }; enum eUITuningMenus { MixtureUI, HeaterSettingsUI }; diff --git a/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.cpp b/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.cpp index caea9c3..982a225 100644 --- a/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.cpp @@ -178,4 +178,120 @@ const uint8_t PROGMEM verticalRepeatIcon [] = 0x20, // # }; +const uint8_t PROGMEM GPIO1OFFIcon[] = +{ + 0x3E, 0x00, // ##### + 0x41, 0x00, // # # + 0x88, 0x80, // # # # + 0x98, 0x80, // # ## # + 0x88, 0x80, // # # # + 0x88, 0x80, // # # # + 0x9C, 0x80, // # ### # + 0x41, 0x00, // # # + 0x3E, 0x00, // ##### +}; + +const uint8_t PROGMEM GPIO1ONIcon[] = +{ + 0x3E, 0x00, // ##### + 0x7F, 0x00, // ####### + 0xF7, 0x80, // #### #### + 0xE7, 0x80, // ### #### + 0xF7, 0x80, // #### #### + 0xF7, 0x80, // #### #### + 0xE3, 0x80, // ### ### + 0x7F, 0x00, // ####### + 0x3E, 0x00, // ##### +}; + +const uint8_t PROGMEM GPIO2OFFIcon[] = +{ + 0x3E, 0x00, // ##### + 0x41, 0x00, // # # + 0x9C, 0x80, // # ### # + 0x84, 0x80, // # # # + 0x9C, 0x80, // # ### # + 0x90, 0x80, // # # # + 0x9C, 0x80, // # ### # + 0x41, 0x00, // # # + 0x3E, 0x00, // ##### +}; + +const uint8_t PROGMEM GPIO2ONIcon[] = +{ + 0x3E, 0x00, // ##### + 0x7F, 0x00, // ####### + 0xE3, 0x80, // ### ### + 0xFB, 0x80, // ##### ### + 0xE3, 0x80, // ### ### + 0xEF, 0x80, // ### ##### + 0xE3, 0x80, // ### ### + 0x7F, 0x00, // ####### + 0x3E, 0x00, // ##### +}; + +const uint8_t PROGMEM CrossIcon[] = +{ + 0x88, // # # + 0x50, // # # + 0x20, // # + 0x50, // # # + 0x88, // # # +}; + +const uint8_t PROGMEM TickIcon[] = +{ + 0x00, // + 0x08, // # + 0x10, // # + 0xa0, // # # + 0x40, // # +}; + +const uint8_t PROGMEM OpenIcon[] = +{ + 0x1F, 0xC0, // ####### + 0x02, 0x00, // # + 0x02, 0x00, // # + 0x3A, 0xE0, // ### # ### + 0xEA, 0xB8, // ### # # # ### + 0x3A, 0xE0, // ### # ### + 0x00, 0x00, // +}; + +const uint8_t PROGMEM CloseIcon[] = +{ + 0x00, 0x00, // + 0x00, 0x00, // + 0x3F, 0xE0, // ######### + 0x3A, 0xE0, // ### # ### + 0xFA, 0xF8, // ##### # ##### + 0x3A, 0xE0, // ### # ### + 0x02, 0x00, // # +}; + + +const uint8_t PROGMEM BulbOnIcon[] = +{ + 0x08, 0x00, // # + 0x41, 0x00, // # # + 0x1C, 0x00, // ### + 0x22, 0x00, // # # + 0xA2, 0x80, // # # # # + 0x1C, 0x00, // ### + 0x14, 0x00, // # # + 0x1C, 0x00, // ### +}; + +const uint8_t PROGMEM BulbOffIcon[] = +{ + 0x00, 0x00, // + 0x00, 0x00, // + 0x1C, 0x00, // ### + 0x22, 0x00, // # # + 0x22, 0x00, // # # + 0x1C, 0x00, // ### + 0x14, 0x00, // # # + 0x1C, 0x00, // ### +}; diff --git a/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.h b/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.h index 0eedbc5..9f3f717 100644 --- a/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.h +++ b/Arduino/BTCDieselHeater/src/OLED/fonts/Icons.h @@ -95,7 +95,41 @@ extern const unsigned char timerID2Icon []; extern const unsigned char timerIcon []; extern const unsigned char largeTimerIcon []; extern const uint8_t verticalRepeatIcon []; +extern const uint8_t GPIO1OFFIcon[]; +extern const uint8_t GPIO1ONIcon[]; +extern const uint8_t GPIO2OFFIcon[]; +extern const uint8_t GPIO2ONIcon[]; +extern const uint8_t CrossIcon[]; +extern const uint8_t TickIcon[]; // Bitmap sizes for verticalRepeat const uint8_t verticalRepeatWidthPixels = 6; const uint8_t verticalRepeatHeightPixels = 15; +// Bitmap sizes for GPIOIcons +const uint8_t GPIOIconWidthPixels = 9; +const uint8_t GPIOIconHeightPixels = 9; + +// Bitmap sizes for TickIcons +const uint8_t TickIconWidth = 5; +const uint8_t TickIconHeight = 5; + +// Bitmap for open +extern const uint8_t OpenIcon[]; +const uint8_t OpenIconWidth = 13; +const uint8_t OpenIconHeight = 7; + +// Bitmap for close +extern const uint8_t CloseIcon[]; +const uint8_t CloseIconWidth = 13; +const uint8_t CloseIconHeight = 7; + +// Bitmap for BulbOn +extern const uint8_t BulbOnIcon[]; +const uint8_t BulbOnIconWidth = 9; +const uint8_t BulbOnIconHeight = 8; + +// Bitmap for BulbOff +extern const uint8_t BulbOffIcon[]; +const uint8_t BulbOffIconWidth = 9; +const uint8_t BulbOffIconHeight = 8; + diff --git a/Arduino/BTCDieselHeater/src/Utility/GPIO.cpp b/Arduino/BTCDieselHeater/src/Utility/GPIO.cpp index 3aedf4b..2829e73 100644 --- a/Arduino/BTCDieselHeater/src/Utility/GPIO.cpp +++ b/Arduino/BTCDieselHeater/src/Utility/GPIO.cpp @@ -49,6 +49,13 @@ CGPIOin::begin(int pin1, int pin2, GPIOinModes mode) setMode(mode); } +uint8_t +CGPIOin::getState(int channel) +{ + int mask = 0x01 << (channel & 0x01); + return (_debouncedPins & mask) != 0; +} + void CGPIOin::manage() { diff --git a/Arduino/BTCDieselHeater/src/Utility/GPIO.h b/Arduino/BTCDieselHeater/src/Utility/GPIO.h index ca47559..5a8a655 100644 --- a/Arduino/BTCDieselHeater/src/Utility/GPIO.h +++ b/Arduino/BTCDieselHeater/src/Utility/GPIO.h @@ -55,6 +55,7 @@ public: void setMode(GPIOinModes mode) { _Mode = mode; }; void begin(int pin1, int pin2, GPIOinModes mode); void manage(); + uint8_t getState(int channel); }; class CGPIOout { diff --git a/Bootload/COM.bat b/Bootload/COM.bat new file mode 100644 index 0000000..f3263ee --- /dev/null +++ b/Bootload/COM.bat @@ -0,0 +1 @@ +esptool.exe --chip esp32 --port COM11 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader_qio_80m.bin 0x10000 BTCDieselHeater.ino.bin 0x8000 BTCDieselHeater.ino.partitions.bin diff --git a/Bootload/OTA.bat b/Bootload/OTA.bat new file mode 100644 index 0000000..678ba8b --- /dev/null +++ b/Bootload/OTA.bat @@ -0,0 +1 @@ +espota.exe -i 192.168.20.40 -p 3232 --auth= -f BTCDieselHeater.ino.bin diff --git a/Bootload/bootload.zip b/Bootload/bootload.zip new file mode 100644 index 0000000..92b53b1 Binary files /dev/null and b/Bootload/bootload.zip differ diff --git a/Bootload/espota.exe b/Bootload/espota.exe new file mode 100644 index 0000000..3de3791 Binary files /dev/null and b/Bootload/espota.exe differ diff --git a/Bootload/esptool.exe b/Bootload/esptool.exe new file mode 100644 index 0000000..3f866dc Binary files /dev/null and b/Bootload/esptool.exe differ