From 7786637f026d690d6886326003a8aedf0ce64e33 Mon Sep 17 00:00:00 2001 From: Paul Andrews Date: Fri, 5 Apr 2019 21:34:58 -0400 Subject: [PATCH] Add movement sensor support --- .cproject | 8 ++-- .project | 4 +- .settings/org.eclipse.cdt.core.prefs | 54 ++++++++++++++++++++++++--- SingleTubeClock.ino | 56 ++++++++++++++++++++++++++-- web/extra.html | 10 +++++ 5 files changed, 117 insertions(+), 15 deletions(-) diff --git a/.cproject b/.cproject index 5ce7113..0bad2a5 100644 --- a/.cproject +++ b/.cproject @@ -39,7 +39,6 @@ - @@ -54,6 +53,7 @@ + @@ -79,7 +79,6 @@ - @@ -94,6 +93,7 @@ + @@ -119,7 +119,6 @@ - @@ -134,6 +133,7 @@ + @@ -144,7 +144,7 @@ - + diff --git a/.project b/.project index af14915..be1484e 100644 --- a/.project +++ b/.project @@ -117,9 +117,9 @@ C:/Users/mpand/Documents/Arduino/libraries/ESPAsyncWebServer - libraries/ESPAsyncWiFiManager + libraries/ESPAsyncWiFiManagerOTC 2 - C:/Users/mpand/Documents/Arduino/libraries/ESPAsyncWiFiManager + C:/Users/mpand/Documents/Arduino/libraries/ESPAsyncWiFiManagerOTC libraries/Hash diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs index e4c5c2d..e675b20 100644 --- a/.settings/org.eclipse.cdt.core.prefs +++ b/.settings/org.eclipse.cdt.core.prefs @@ -181,10 +181,10 @@ environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.DT environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.DTS/value=0 environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.LOCAL/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.LOCAL/operation=replace -environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.LOCAL/value=1546280819 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.LOCAL/value=1551816442 environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.UTC/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.UTC/operation=replace -environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.UTC/value=1546298819 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.UTC/value=1551834442 environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.ZONE/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.ZONE/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.EXTRA.TIME.ZONE/value=-18000 @@ -302,27 +302,45 @@ environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.REFER environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA-1.1.1.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA-1.1.1.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA-1.1.1.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.1.1 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA-1.2.1.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA-1.2.1.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA-1.2.1.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.2.1 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA.PATH/operation=replace -environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.1.1 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.2.1 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA1.1.1.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA1.1.1.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA1.1.1.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.1.1 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA1.2.1.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA1.2.1.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ARDUINOOTA1.2.1.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/arduinoOTA/1.2.1 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.4-ARDUINO2.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.4-ARDUINO2.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.4-ARDUINO2.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC-5.4.0-ATMEL3.6.1-ARDUINO2.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC-5.4.0-ATMEL3.6.1-ARDUINO2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC-5.4.0-ATMEL3.6.1-ARDUINO2.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC.PATH/operation=replace -environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.4-ARDUINO2.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.4-ARDUINO2.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.4-ARDUINO2.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC5.4.0-ATMEL3.6.1-ARDUINO2.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC5.4.0-ATMEL3.6.1-ARDUINO2.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVR-GCC5.4.0-ATMEL3.6.1-ARDUINO2.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO14.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO14.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO14.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino14 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO9.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO9.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO9.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino9 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE.PATH/operation=replace -environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino9 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino14 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO14.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO14.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO14.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino14 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO9.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO9.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO9.PATH/value=${eclipse_home}/arduinoPlugin/packages/arduino/tools/avrdude/6.3.0-arduino9 @@ -341,12 +359,24 @@ environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL0.4.9.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL0.4.9.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL0.4.9.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/esptool/0.4.9 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY-2.6.0.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY-2.6.0.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY-2.6.0.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/esptool_py/2.6.0 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/esptool_py/2.6.0 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY2.6.0.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY2.6.0.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.ESPTOOL_PY2.6.0.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/esptool_py/2.6.0 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.1.2.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.1.2.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.1.2.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/mkspiffs/0.1.2 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.2.0.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.2.0.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.2.0.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/mkspiffs/0.2.0 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.2.3.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.2.3.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS-0.2.3.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/mkspiffs/0.2.3 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/mkspiffs/0.2.0 @@ -356,6 +386,18 @@ environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS0.2.0.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS0.2.0.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS0.2.0.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/mkspiffs/0.2.0 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS0.2.3.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS0.2.3.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.MKSPIFFS0.2.3.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/mkspiffs/0.2.3 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC-1.22.0-80-G6C4433A-5.2.0.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC-1.22.0-80-G6C4433A-5.2.0.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC-1.22.0-80-G6C4433A-5.2.0.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0 +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC1.22.0-80-G6C4433A-5.2.0.PATH/delimiter=; +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC1.22.0-80-G6C4433A-5.2.0.PATH/operation=replace +environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-ESP32-ELF-GCC1.22.0-80-G6C4433A-5.2.0.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0 environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC-1.20.0-26-GB404FB9-2.PATH/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC-1.20.0-26-GB404FB9-2.PATH/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/A.RUNTIME.TOOLS.XTENSA-LX106-ELF-GCC-1.20.0-26-GB404FB9-2.PATH/value=${eclipse_home}/arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 @@ -466,7 +508,7 @@ environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.BOARD_NA environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.BOARD_NAME/value=Generic ESP8285 Module environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.COM_PORT/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.COM_PORT/operation=replace -environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.COM_PORT/value=COM21 +environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.COM_PORT/value=COM10 environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.ECLIPSE_LOCATION/delimiter=; environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.ECLIPSE_LOCATION/operation=replace environment/project/io.sloeber.core.toolChain.release.1732618002/JANTJE.ECLIPSE_LOCATION/value= diff --git a/SingleTubeClock.ino b/SingleTubeClock.ino index c6a304c..ddd545b 100644 --- a/SingleTubeClock.ino +++ b/SingleTubeClock.ino @@ -29,7 +29,7 @@ Print *debugPrint = &Serial; #include #include #include -#include +#include #include #include @@ -76,6 +76,43 @@ const byte VADJpin = 4; // const byte DIpin = 13; // MOSI, D7 const byte CLpin = 14; // SCK, D5 const byte LEpin = 12; // MISO, D6 +const byte MovPin = 16; // PIR/Radar etc. + +class MovementSensor { +public: + MovementSensor(const byte pin) : onTime(0), delayMs(0), pin(pin) { + } + + void setDelay(byte delayMinutes) { + delayMs = delayMinutes * 60000; + } + + void setOnTime(unsigned long onTime) { + this->onTime = onTime; + } + + bool isOn() { + return !isOff(); + } + + bool isOff() { + int state = digitalRead(pin); + + unsigned long nowMs = millis(); + + if (state) { + onTime = nowMs; // Sensor will stay high while movement is detected + } + + return (delayMs != 0) && (nowMs - onTime >= delayMs); // So zero = always off + } + +private: + unsigned long onTime; + unsigned long delayMs; + + const byte pin; +}; const byte ADCpin = A0; @@ -231,6 +268,8 @@ namespace CurrentConfig { IntConfigItem *digit = &ConfigSet1::digit; ByteConfigItem *count_speed = &ConfigSet1::count_speed; StringConfigItem *pin_order = &ConfigSet1::pin_order; + IntConfigItem *pwm_freq = &ConfigSet1::pwm_freq; + ByteConfigItem *mov_delay = &ConfigSet1::mov_delay; // UPS config values ByteConfigItem *charge_rate = &ConfigSet1::charge_rate; @@ -288,6 +327,8 @@ namespace CurrentConfig { digit = static_cast(config->get("digit")); count_speed = static_cast(config->get("count_speed")); pin_order = static_cast(config->get("pin_order")); + pwm_freq = static_cast(config->get("pwm_freq")); + mov_delay = static_cast(config->get("mov_delay")); // UPS config values charge_rate = static_cast(config->get("charge_rate")); @@ -871,7 +912,7 @@ void setTimeFromWifiManager() { } } -const byte numLEDs = 4; +const byte numLEDs = 17; LEDRGB leds(numLEDs, LEDpin); LDR ldr(ADCpin, 50); @@ -961,8 +1002,11 @@ SoftMSTimer::TimerInfo *infos[] = { }; SoftMSTimer timedFunctions(infos); +MovementSensor mov(MovPin); + byte oldVoltage = 176; bool oldHV = true; + void setup() { chipId.toUpperCase(); @@ -1019,6 +1063,10 @@ void setup() nowMs = millis(); + pinMode(MovPin, INPUT); + mov.setDelay(1); + mov.setOnTime(nowMs); + DEBUG("Voltage on") oldHV = *CurrentConfig::hv; digitalWrite(VENpin, oldHV ? LOW : HIGH); @@ -1117,6 +1165,8 @@ void loop() pDriver->setBrightness(ldr.getNormalizedBrightness(*CurrentConfig::dimming)); pDriver->setIndicator(*CurrentConfig::indicator); pDriver->setDigitMap(((String)(*CurrentConfig::pin_order)).c_str()); + NixieDriver::setPWMFreq(*CurrentConfig::pwm_freq); + mov.setDelay(*CurrentConfig::mov_delay); if (timeInitialized || !*CurrentConfig::display) { pNixieClock->setClockMode(*CurrentConfig::display); @@ -1134,7 +1184,7 @@ void loop() pNixieClock->setOnOff(*CurrentConfig::display_on, *CurrentConfig::display_off); pNixieClock->setDigitsOn(*CurrentConfig::digits_on); pNixieClock->setScrollback(*CurrentConfig::scrollback); - bool clockOn = woke || ((ups.getVBus() || (*CurrentConfig::lpm == false)) && pNixieClock->isOn()); + bool clockOn = woke || ((ups.getVBus() || (*CurrentConfig::lpm == false)) && pNixieClock->isOn() && mov.isOn()); bool newHV = *CurrentConfig::hv && clockOn; diff --git a/web/extra.html b/web/extra.html index c4828c8..3df0c04 100644 --- a/web/extra.html +++ b/web/extra.html @@ -51,6 +51,16 @@

Extra

+
+
+
+ + +
+
+
+ +