commit 19c4c00ce68f3a76160f9533dc44f436df063450 Author: avery.babka Date: Fri Jul 25 14:02:45 2025 -0500 Upload files to "/" diff --git a/Timers_ADI.h b/Timers_ADI.h new file mode 100644 index 0000000..cc9a535 --- /dev/null +++ b/Timers_ADI.h @@ -0,0 +1,51 @@ +#ifndef Timers_ADI +#define Timers_ADI 1 + +#define TIMERCOUNT 40 +int32_t Timers[TIMERCOUNT]; // -1 is off, >= 0 is on + +#define RELAYSERVICE 1 +#define NTP_TIMER 2 +#define TENSECOND 3 +#define COMMSREPLYTIMER 4 +#define TIMER485 5 +#define ONEMINUTE 6 +#define TOUCH_DEBOUNCE 7 +#define DISPLAYTIMER 8 +#define WIFISERVICE 9 +#define GASKETTIMER 10 +#define SCREENTIMER 11 +#define PINGTIMER 12 +#define WIFITIMEOUT 13 +#define FLOWTIMER 14 +#define AT200RX 15 +#define SWITCH5TIMER 16 +#define WIFIRESPONSETIMER 17 +#define DOORTRAVELTIMER 18 +#define HEARTBEAT 19 +#define OBSTRUCTION 20 +#define DISPLAYSERVICETIMER 21 +#define SCREENTIMEOUTTIMER 22 +#define EXERCISETIMER 23 +#define AT200DATA 24 + +#define MOTOR_TIMER 25 + +#define VOLTAGETIMER 26 +#define LIDARTIMER 27 +#define BOOTPINTIMER 28 +#define ISIDLETIMER 29 + +#define OLEDBLANKTIMER 30 +#define OLEDHOLDTIMER 31 + +#define BLANKSCREENTIMER 32 // v525 + +uint16_t onehundredmstick = 0; // increments every 100ms + +#define OBSTRUCTIONPIN 35 +uint16_t obstructionCounter = 0; + +#define PARMFETCHTIMER 36 + +#endif diff --git a/Timers_ADI.ino b/Timers_ADI.ino new file mode 100644 index 0000000..265d37d --- /dev/null +++ b/Timers_ADI.ino @@ -0,0 +1,61 @@ + +// tenth second resolution timers + +#include +#include "Timers_ADI.h" + +Ticker tickerTenths; + +void init_timers(void) +{ + + // Interrupt .. Timers + + // ISR setup + tickerTenths.attach(0.1, onehundredms); // every 0.1 second + + // obstruction sensor + pinMode(OBSTRUCTIONPIN, INPUT_PULLUP); + /* + attachInterrupt(digitalPinToInterrupt(OBSTRUCTIONPIN), obstructionToggle, RISING); + */ + + // Setup timers the first time + int it; + for (it = 0; it < TIMERCOUNT; it++) // init all timers + Timers[it] = -1; + + Timers[HEARTBEAT] = 1; + Timers[COMMSREPLYTIMER] = 0; + Timers[PINGTIMER] = 0; + Timers[0] = 0; + Timers[RELAYSERVICE] = 5; + Timers[TENSECOND] = 1000; + Timers[TIMER485] = 0; + Timers[ONEMINUTE] = 0; // Screen update timer + Timers[WIFISERVICE] = 0; // turn it on + Timers[NTP_TIMER] = 200000; + Timers[AT200RX] = 0; + Timers[OBSTRUCTION] = 1; + Timers[DISPLAYSERVICETIMER] = 1; + Timers[AT200DATA] = 1; + Timers[OLEDHOLDTIMER] = 1; +} + +void onehundredms(void) +{ // ISR once per onehundredms ticker + onehundredmstick++; +} + +void timer_update(void) // call every 0.1 sec from mainline +{ + int i; + for (i = 0; i < TIMERCOUNT; i++) // update timers + if (Timers[i] > -1) + Timers[i]++; +} + +void obstructionToggle(void) // interrupt on pin rising +{ + obstructionCounter++; +} diff --git a/UPDATE.bin b/UPDATE.bin new file mode 100644 index 0000000..3d662ad Binary files /dev/null and b/UPDATE.bin differ diff --git a/Update_ADI.ino b/Update_ADI.ino new file mode 100644 index 0000000..976e0a9 --- /dev/null +++ b/Update_ADI.ino @@ -0,0 +1,101 @@ + +#include +#include "FileLib.h" + +//******************************************************* +// perform the actual update from a given stream- +//******************************************************* + +void performUpdate(Stream &updateSource, size_t updateSize) +{ + if (Update.begin(updateSize)) + { + size_t written = Update.writeStream(updateSource); // the update happens here + if (written == updateSize) + { + Serial.println("Written : " + String(written) + " successfully"); + } + else + { + Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?"); + } + + if (Update.end()) + { + displayText("OTA done!"); + if (Update.isFinished()) + { + Serial.println("Update successfully completed. Rebooting."); + } + else + { + Serial.println("Update not finished? Something went wrong!"); + } + } + else + { + Serial.println("Error Occurred. Error #: " + String(Update.getError())); + } + } + else + { + Serial.println("Not enough space to begin OTA"); + } +} + +//******************************************************* +// check given FS for valid update.bin and perform update if available +//******************************************************* + +void updateFromFS(void) +{ + FS fs = SD; + // kickDog(); + + // File updateBin = SD.open("EVO.bin"); + File updateBin = fs.open("/Update.bin"); + if (updateBin) + { + if (updateBin.isDirectory()) + { + Serial.println("Error, Update.bin is not a file"); + updateBin.close(); + return; + } + + size_t updateSize = updateBin.size(); + + if (updateSize > 0) + { + Serial.println("Try to start update"); + displayText("Beginning Update"); + performUpdate(updateBin, updateSize); + } + else + { + Serial.println("Error, file is empty"); + } + + updateBin.close(); + + // whe finished remove the binary from sd card to indicate end of the process + // fs.remove("/Update.bin"); + rebootEspWithReason("Eureka! Success!!"); + } + else + { + Serial.println("Could not load Update.bin from sd root"); + } +} + +//******************************************************* +// +//******************************************************* + +void rebootEspWithReason(String reason) +{ + Serial.println(reason); + // digitalWrite(SWITCH5,LOW); + delay(1000); + ESP.restart(); +} diff --git a/Wifi_ADI.h b/Wifi_ADI.h new file mode 100644 index 0000000..500384a --- /dev/null +++ b/Wifi_ADI.h @@ -0,0 +1,19 @@ +#ifndef Wifi_ADI_h +#define Wifi_ADI_h + +#include +#include + +// char ssid[48] = "Production"; // your network SSID (name) +// char pass[48] = "78CBC37735"; // your network password +// char ssid[48] = "Smith01"; // your network SSID (name) +// char pass[48] = "Smith211056"; // your network password + +// char pass[48] = "RenlitaPW2430"; // your network password +// char ssid[48] = "RenlitaWiFi"; // your network SSID (name) +char ssid[48] = "B6D9Access"; // your network SSID (name) +char pass[48] = "080456120173"; // your network password + + + +#endif