From 17ccf34eb7b1a027b317826bd07d26181c5574b1 Mon Sep 17 00:00:00 2001 From: Matti Airas Date: Sat, 1 Jun 2024 16:57:55 +0300 Subject: [PATCH] Update examples --- examples/analog_input.cpp | 4 +--- examples/async_repeat_sensor.cpp | 5 +---- examples/chain_counter.cpp | 2 +- examples/constant_sensor.cpp | 5 +---- examples/freertos_tasks.cpp | 5 +---- .../fuel_level_sensor_example.cpp | 4 +--- examples/hysteresis.cpp | 2 +- examples/lambda_transform.cpp | 2 +- examples/manual_networking.cpp | 2 +- .../milone_level_sensor/milone_level_sensor.cpp | 4 +--- examples/minimal_app.cpp | 2 +- examples/platformio.ini | 16 ++++++++++++---- examples/raw_json.cpp | 4 +--- examples/relay_control.cpp | 4 +--- examples/repeat_sensor_analog_input.cpp | 5 +---- examples/rpm_counter.cpp | 4 +--- examples/smart_switch/remote_switch_example.cpp | 5 +---- examples/smart_switch/smart_switch_example.cpp | 5 +---- examples/temperature_sender.cpp | 5 +---- examples/time_counter.cpp | 5 +---- 20 files changed, 31 insertions(+), 59 deletions(-) diff --git a/examples/analog_input.cpp b/examples/analog_input.cpp index 68200e9ce..d52003f6f 100644 --- a/examples/analog_input.cpp +++ b/examples/analog_input.cpp @@ -17,9 +17,7 @@ reactesp::ReactESP app; // The setup function performs one-time application initialization. void setup() { // Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create the global SensESPApp() object. SensESPAppBuilder builder; diff --git a/examples/async_repeat_sensor.cpp b/examples/async_repeat_sensor.cpp index 1a0cf2b8a..de1fc9d2d 100644 --- a/examples/async_repeat_sensor.cpp +++ b/examples/async_repeat_sensor.cpp @@ -17,10 +17,7 @@ reactesp::ReactESP app; // The setup function performs one-time application initialization. void setup() { -// Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create the global SensESPApp() object. SensESPAppBuilder builder; diff --git a/examples/chain_counter.cpp b/examples/chain_counter.cpp index b0f20c903..c48faee4d 100644 --- a/examples/chain_counter.cpp +++ b/examples/chain_counter.cpp @@ -25,7 +25,7 @@ using namespace sensesp; ReactESP app; void setup() { - SetupSerialDebug(115200); + SetupLogging(); SensESPAppBuilder builder; sensesp_app = builder.set_hostname("ChainCounter") diff --git a/examples/constant_sensor.cpp b/examples/constant_sensor.cpp index 05bce5e17..77e26e313 100644 --- a/examples/constant_sensor.cpp +++ b/examples/constant_sensor.cpp @@ -20,10 +20,7 @@ using namespace sensesp; reactesp::ReactESP app; void setup() { - // Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create the builder object SensESPAppBuilder builder; diff --git a/examples/freertos_tasks.cpp b/examples/freertos_tasks.cpp index 33c17b232..7055cbbd9 100644 --- a/examples/freertos_tasks.cpp +++ b/examples/freertos_tasks.cpp @@ -35,10 +35,7 @@ void ToggleTestOutputPin(void *parameter) { // The setup function performs one-time application initialization. void setup() { -// Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); SensESPMinimalAppBuilder builder; SensESPMinimalApp *sensesp_app = builder.set_hostname("async")->get_app(); diff --git a/examples/fuel_level_sensor/fuel_level_sensor_example.cpp b/examples/fuel_level_sensor/fuel_level_sensor_example.cpp index a622efd15..81033b66d 100644 --- a/examples/fuel_level_sensor/fuel_level_sensor_example.cpp +++ b/examples/fuel_level_sensor/fuel_level_sensor_example.cpp @@ -10,9 +10,7 @@ using namespace sensesp; ReactESP app; void setup() { -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Set up sensesp SensESPAppBuilder builder; diff --git a/examples/hysteresis.cpp b/examples/hysteresis.cpp index 864c85392..0633507a7 100644 --- a/examples/hysteresis.cpp +++ b/examples/hysteresis.cpp @@ -12,7 +12,7 @@ using namespace sensesp; ReactESP app; void setup() { - SetupSerialDebug(115200); + SetupLogging(); SensESPAppBuilder builder; sensesp_app = builder.set_hostname("sensesp-hysteresis-example") diff --git a/examples/lambda_transform.cpp b/examples/lambda_transform.cpp index c41b8c644..3337ad42b 100644 --- a/examples/lambda_transform.cpp +++ b/examples/lambda_transform.cpp @@ -11,7 +11,7 @@ using namespace sensesp; ReactESP app; void setup() { - SetupSerialDebug(115200); + SetupLogging(); // Create a new SensESPApp object. This is the direct constructor call, and // an equivalent alternative to using the SensESPAppBuilder class. diff --git a/examples/manual_networking.cpp b/examples/manual_networking.cpp index 01e0b7f52..609f68ad2 100644 --- a/examples/manual_networking.cpp +++ b/examples/manual_networking.cpp @@ -24,7 +24,7 @@ const uint8_t input_pin1 = 0; ReactESP app; void setup() { - SetupSerialDebug(115200); + SetupLogging(); SensESPMinimalAppBuilder builder; auto sensesp_app = builder.set_hostname("counter-test")->get_app(); diff --git a/examples/milone_level_sensor/milone_level_sensor.cpp b/examples/milone_level_sensor/milone_level_sensor.cpp index 52dadf904..53120516d 100644 --- a/examples/milone_level_sensor/milone_level_sensor.cpp +++ b/examples/milone_level_sensor/milone_level_sensor.cpp @@ -47,9 +47,7 @@ ReactESP app; void setup() { // Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create a builder object SensESPAppBuilder builder; diff --git a/examples/minimal_app.cpp b/examples/minimal_app.cpp index 86614852c..9282817f0 100644 --- a/examples/minimal_app.cpp +++ b/examples/minimal_app.cpp @@ -29,7 +29,7 @@ const uint8_t output_pin2 = 21; ReactESP app; void setup() { - SetupSerialDebug(115200); + SetupLogging(); SensESPMinimalAppBuilder builder; auto sensesp_app = builder.set_hostname("counter-test")->get_app(); diff --git a/examples/platformio.ini b/examples/platformio.ini index 346a721b9..386bc72a8 100644 --- a/examples/platformio.ini +++ b/examples/platformio.ini @@ -15,7 +15,7 @@ [platformio] ;set default_envs to whichever board(s) you use. Build/Run/etc processes those envs -default_envs = +default_envs = esp32dev [env] @@ -46,11 +46,19 @@ monitor_filters = esp32_exception_decoder [env:esp32dev] extends = espressif32_base board = esp32dev -; Verify that this is the correct pin number for your board! -build_flags = + +build_flags = + ; Verify that this is the correct pin number for your board! -D LED_BUILTIN = 2 + ; Max (and default) debugging level in Arduino ESP32 Core + -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE + ; Arduino Core bug workaround: define the log tag for the Arduino + ; logging macros. + -D TAG='"Arduino"' + ; Use the ESP-IDF logging library - required by SensESP. + -D USE_ESP_IDF_LOG + ; uncomment and change these if PlatformIO can't auto-detect ; the ports ;upload_port = /dev/tty.SLAB_USBtoUART ;monitor_port = /dev/tty.SLAB_USBtoUART - diff --git a/examples/raw_json.cpp b/examples/raw_json.cpp index e06975bf5..78ffb7077 100644 --- a/examples/raw_json.cpp +++ b/examples/raw_json.cpp @@ -14,9 +14,7 @@ reactesp::ReactESP app; ObservableValue toggler; void setup() { -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); SensESPAppBuilder builder; SensESPApp *sensesp_app = builder.set_hostname("json_demo") diff --git a/examples/relay_control.cpp b/examples/relay_control.cpp index 7d3b5ef7a..3ba345539 100644 --- a/examples/relay_control.cpp +++ b/examples/relay_control.cpp @@ -23,9 +23,7 @@ ReactESP app; void setup() { // Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create a builder object SensESPAppBuilder builder; diff --git a/examples/repeat_sensor_analog_input.cpp b/examples/repeat_sensor_analog_input.cpp index c59ec847d..766a96ebd 100644 --- a/examples/repeat_sensor_analog_input.cpp +++ b/examples/repeat_sensor_analog_input.cpp @@ -30,10 +30,7 @@ float analog_read_callback() { return analogRead(kAnalogInputPin) / 4096.0; } // The setup function performs one-time application initialization. void setup() { -// Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create the global SensESPApp() object. SensESPAppBuilder builder; diff --git a/examples/rpm_counter.cpp b/examples/rpm_counter.cpp index 45e23ffb6..459ba791e 100644 --- a/examples/rpm_counter.cpp +++ b/examples/rpm_counter.cpp @@ -14,9 +14,7 @@ using namespace sensesp; ReactESP app; void setup() { -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); SensESPAppBuilder builder; sensesp_app = builder.get_app(); diff --git a/examples/smart_switch/remote_switch_example.cpp b/examples/smart_switch/remote_switch_example.cpp index 781f10248..3d0a4ea9d 100644 --- a/examples/smart_switch/remote_switch_example.cpp +++ b/examples/smart_switch/remote_switch_example.cpp @@ -40,10 +40,7 @@ using namespace sensesp; ReactESP app; void setup() { -// Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create a builder object SensESPAppBuilder builder; diff --git a/examples/smart_switch/smart_switch_example.cpp b/examples/smart_switch/smart_switch_example.cpp index 31c1ad50d..c48e36ad2 100644 --- a/examples/smart_switch/smart_switch_example.cpp +++ b/examples/smart_switch/smart_switch_example.cpp @@ -43,10 +43,7 @@ using namespace sensesp; ReactESP app; void setup() { -// Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create a builder object SensESPAppBuilder builder; diff --git a/examples/temperature_sender.cpp b/examples/temperature_sender.cpp index d1920a410..a048b2884 100644 --- a/examples/temperature_sender.cpp +++ b/examples/temperature_sender.cpp @@ -60,10 +60,7 @@ class TemperatureInterpreter : public CurveInterpolator { ReactESP app; void setup() { -// Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create the global SensESPApp() object by first creating a // SensESPAppBuilder object, then setting some hard-coded diff --git a/examples/time_counter.cpp b/examples/time_counter.cpp index b7b0a0d53..ebec86c2d 100644 --- a/examples/time_counter.cpp +++ b/examples/time_counter.cpp @@ -31,10 +31,7 @@ unsigned long freq_start_time = 0; int freq = 0; void setup() { - // Some initialization boilerplate when in debug mode... -#ifndef SERIAL_DEBUG_DISABLED - SetupSerialDebug(115200); -#endif + SetupLogging(); // Create the builder object SensESPAppBuilder builder;