diff --git a/.gitignore b/.gitignore index dbe5f41..3a8982e 100755 --- a/.gitignore +++ b/.gitignore @@ -92,6 +92,7 @@ src/custom.settings.h src/profiles/* !src/profiles/generic.rower-profile.h !src/profiles/generic.board-profile.h +!src/profiles/lolinS3-mini.board-profile.h !src/profiles/kayakfirst.rower-profile.h !src/profiles/kayakfirstBlue.rower-profile.h !src/profiles/firebeetle.board-profile.h diff --git a/src/main.cpp b/src/main.cpp index 4727b22..e5e0790 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,9 +7,12 @@ void setup() { Serial.begin(static_cast(Configurations::baudRate)); + +#if ARDUINO_USB_CDC_ON_BOOT != 1 while (!Serial && !(bool)Serial.available()) { } +#endif Log.begin(static_cast(Configurations::defaultLogLevel), &Serial, false); Log.setPrefix(printPrefix); diff --git a/src/peripherals/peripherals.controller.cpp b/src/peripherals/peripherals.controller.cpp index e7c91a7..c7a97b4 100644 --- a/src/peripherals/peripherals.controller.cpp +++ b/src/peripherals/peripherals.controller.cpp @@ -236,7 +236,7 @@ void PeripheralsController::setupConnectionIndicatorLed() { if constexpr (Configurations::isRgb) { - FastLED.addLeds(Configurations::ledPin), GRB>(leds.data(), 1); + FastLED.addLeds(Configurations::ledPin), Configurations::ledColorChannelOrder>(leds.data(), 1); } else { diff --git a/src/profiles/firebeetle.board-profile.h b/src/profiles/firebeetle.board-profile.h index 7d07060..ff7ea68 100644 --- a/src/profiles/firebeetle.board-profile.h +++ b/src/profiles/firebeetle.board-profile.h @@ -11,6 +11,7 @@ #define LED_BLINK_FREQUENCY 1'000 #define LED_PIN GPIO_NUM_5 // Use GPIO_NUM_NC if no led is available #define IS_RGB true +#define RGB_LED_COLOR_CHANNEL_ORDER GRB // Hardware settings #define SENSOR_PIN_NUMBER GPIO_NUM_15 diff --git a/src/profiles/lolinS3-mini.board-profile.h b/src/profiles/lolinS3-mini.board-profile.h new file mode 100644 index 0000000..a523cfd --- /dev/null +++ b/src/profiles/lolinS3-mini.board-profile.h @@ -0,0 +1,33 @@ +#pragma once + +#include "../utils/enums.h" + +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + +// General settings +#define BAUD_RATE BaudRates::Baud1500000 +#define BLE_SIGNAL_STRENGTH BleSignalStrength::MaxPower +#define SUPPORT_SD_CARD_LOGGING false + +// LED settings +#define LED_BLINK_FREQUENCY 1'000 +#define LED_PIN GPIO_NUM_47 // Use GPIO_NUM_NC if no led is available +#define IS_RGB true + +// Hardware settings +#define SENSOR_PIN_NUMBER GPIO_NUM_16 +#define SENSOR_ON_SWITCH_PIN_NUMBER GPIO_NUM_NC // Use GPIO_NUM_NC if no sensor switch is available +#define WAKEUP_SENSOR_PIN_NUMBER GPIO_NUM_NC // Use GPIO_NUM_NC if no separate wakeup pin is available +#define SD_CARD_CHIP_SELECT_PIN GPIO_NUM_NC + +// Device power management settings +#define BATTERY_PIN_NUMBER GPIO_NUM_NC +#define VOLTAGE_DIVIDER_RATIO 2 +#define BATTERY_VOLTAGE_MIN 3.3 +#define BATTERY_VOLTAGE_MAX 4.00 +#define BATTERY_LEVEL_ARRAY_LENGTH 5 +#define INITIAL_BATTERY_LEVEL_MEASUREMENT_COUNT 10 +#define BATTERY_MEASUREMENT_FREQUENCY 10 +#define DEEP_SLEEP_TIMEOUT 4 + +// NOLINTEND(cppcoreguidelines-macro-usage) \ No newline at end of file diff --git a/src/utils/configuration.h b/src/utils/configuration.h index ed84fe5..88cc064 100644 --- a/src/utils/configuration.h +++ b/src/utils/configuration.h @@ -3,6 +3,7 @@ #include #include "Arduino.h" +#include "FastLED.h" #include "./macros.h" @@ -31,14 +32,19 @@ class Configurations // Hardware settings static const BaudRates baudRate = BAUD_RATE; + static const gpio_num_t sdCardChipSelectPin = SD_CARD_CHIP_SELECT_PIN; static const gpio_num_t sensorPinNumber = SENSOR_PIN_NUMBER; static const gpio_num_t wakeupPinNumber = WAKEUP_SENSOR_PIN_NUMBER; static const bool hasWakeupPinNumber = wakeupPinNumber != GPIO_NUM_NC; static const gpio_num_t sensorOnSwitchPinNumber = SENSOR_ON_SWITCH_PIN_NUMBER; static const bool hasSensorOnSwitchPinNumber = sensorOnSwitchPinNumber != GPIO_NUM_NC; + static const gpio_num_t ledPin = static_cast(LED_PIN); static const bool isRgb = ledPin == GPIO_NUM_NC ? false : IS_RGB; + static const bool rgbLed = ledPin == GPIO_NUM_NC ? false : IS_RGB; + static const EOrder ledColorChannelOrder = RGB_LED_COLOR_CHANNEL_ORDER; + static const unsigned char impulsesPerRevolution = IMPULSES_PER_REVOLUTION; static constexpr float flywheelInertia = FLYWHEEL_INERTIA; static const unsigned short ledBlinkFrequency = LED_BLINK_FREQUENCY; diff --git a/src/utils/macros.h b/src/utils/macros.h index 79c38be..b41da0c 100644 --- a/src/utils/macros.h +++ b/src/utils/macros.h @@ -69,6 +69,10 @@ constexpr unsigned int compileDateDay = (__DATE__[4] == ' ') ? (__DATE__[5] - '0 #endif #endif +#if !defined(RGB_LED_COLOR_CHANNEL_ORDER) + #define RGB_LED_COLOR_CHANNEL_ORDER RGB +#endif + #if !defined(BATTERY_PIN_NUMBER) #define BATTERY_PIN_NUMBER GPIO_NUM_NC #endif diff --git a/test/FastLED.h b/test/FastLED.h new file mode 100644 index 0000000..c192b8b --- /dev/null +++ b/test/FastLED.h @@ -0,0 +1,15 @@ + +/// RGB color channel orderings, used when instantiating controllers to determine +/// what order the controller should send data out in. The default ordering +/// is RGB. +/// Within this enum, the red channel is 0, the green channel is 1, and the +/// blue chanel is 2. +enum EOrder +{ + RGB = 0012, ///< Red, Green, Blue (0012) + RBG = 0021, ///< Red, Blue, Green (0021) + GRB = 0102, ///< Green, Red, Blue (0102) + GBR = 0120, ///< Green, Blue, Red (0120) + BRG = 0201, ///< Blue, Red, Green (0201) + BGR = 0210 ///< Blue, Green, Red (0210) +}; \ No newline at end of file