Exceptions added

This commit is contained in:
c3ma 2021-11-13 17:26:39 +01:00
parent f727971138
commit 66d69eab6b
3 changed files with 28 additions and 10 deletions

View File

@ -85,9 +85,9 @@
#define FIRMWARE_VERSION "sw 2.0 hw 0.10b" #define FIRMWARE_VERSION "sw 2.0 hw 0.10b"
#define TIMED_LIGHT_PIN CUSTOM1_PIN5 #define TIMED_LIGHT_PIN CUSTOM1_PIN5
//#define FLOWMETER_PIN CUSTOM1_PIN1 #define FLOWMETER_PIN CUSTOM1_PIN1
#ifdef FLOWMETER_PIN #ifdef FLOWMETER_PIN
#define FLOWMETER_FLOWFACTOR 22 /** F = 22 * Q;Q = L/min */ #define FLOWMETER_FLOWFACTOR 23 /** F = 22 * Q;Q = L/min */
#endif #endif
#define MOIST_SENSOR_MAX_FRQ 60000 // 60kHz (500Hz margin) #define MOIST_SENSOR_MAX_FRQ 60000 // 60kHz (500Hz margin)

View File

@ -12,9 +12,10 @@
platform = espressif32 platform = espressif32
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
framework = arduino framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -fexceptions -lstdc++-exc
board_build.partitions = defaultWithSmallerSpiffs.csv board_build.partitions = defaultWithSmallerSpiffs.csv
; the latest development brankitchen-lightch (convention V3.0.x) ; the latest development brankitchen-lightch (convention V3.0.x)
lib_deps = ArduinoJson@6.16.1 lib_deps = ArduinoJson@6.16.1
OneWire OneWire

View File

@ -69,7 +69,7 @@ RTC_DATA_ATTR long consecutiveWateringPlant[MAX_PLANTS] = {0};
bool volatile mDownloadMode = false; /**< Controller must not sleep */ bool volatile mDownloadMode = false; /**< Controller must not sleep */
bool volatile mSensorsRead = false; /**< Sensors are read without Wifi or MQTT */ bool volatile mSensorsRead = false; /**< Sensors are read without Wifi or MQTT */
int volatile pumpToRun = -1; /** pump to run at the end of the cycle */ int volatile pumpToRun = -1; /** pump to run at the end of the cycle */
int volatile selfTestPumpRun = -1; /** pump to run at the end of the cycle */ int volatile selfTestPumpRun = -1; /** pump to run at the end of the cycle */
bool mConfigured = false; bool mConfigured = false;
long nextBlink = 0; /**< Time needed in main loop to support expected blink code */ long nextBlink = 0; /**< Time needed in main loop to support expected blink code */
@ -639,12 +639,9 @@ void pumpActiveLoop()
} }
} }
/** void safeSetup()
* @brief Startup function
* Is called once, the controller is started
*/
void setup()
{ {
throw std::runtime_error("Shit happened");
/* reduce power consumption */ /* reduce power consumption */
setCpuFrequencyMhz(80); setCpuFrequencyMhz(80);
@ -829,6 +826,26 @@ void setup()
setupFinishedTimestamp = millis(); setupFinishedTimestamp = millis();
} }
/**
* @brief Startup function
* Is called once, the controller is started
*/
void setup()
{
try
{
safeSetup();
}
catch (const std::exception &e)
{
Serial.printf("Exception thrown: \"%s\"", e.what());
}
catch (...)
{
Serial.println("Other exception thrown.");
}
}
void selfTest() void selfTest()
{ {