From 833cef7d5ea14e16ada2d16335f7af691a602064 Mon Sep 17 00:00:00 2001 From: Fred Kummer Date: Mon, 5 Aug 2024 17:37:32 -0400 Subject: [PATCH 1/4] Add led support headers --- inc/rgb_led.hpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++ inc/white_led.hpp | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 inc/rgb_led.hpp create mode 100644 inc/white_led.hpp diff --git a/inc/rgb_led.hpp b/inc/rgb_led.hpp new file mode 100644 index 0000000..9976f23 --- /dev/null +++ b/inc/rgb_led.hpp @@ -0,0 +1,63 @@ +/* + Copyright 2024 Vertiq, Inc support@vertiq.co + + This file is part of the Vertiq C++ API. + + This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) +*/ + +#ifndef RGB_LED_CLIENT_H +#define RGB_LED_CLIENT_H + +#include "client_communication.hpp" + +const uint8_t kTypeRgbLed = 100; + +class RgbLedClient : public ClientAbstract { + public: + RgbLedClient(uint8_t obj_idn) + : ClientAbstract(kTypeRgbLed, obj_idn), + red_(kTypeRgbLed, obj_idn, kSubRed), + green_(kTypeRgbLed, obj_idn, kSubGreen), + blue_(kTypeRgbLed, obj_idn, kSubBlue), + update_color_(kTypeRgbLed, obj_idn, kSubUpdateColor), + strobe_active_(kTypeRgbLed, obj_idn, kSubStrobeActive), + strobe_period_(kTypeRgbLed, obj_idn, kSubStrobePeriod), + strobe_pattern_(kTypeRgbLed, obj_idn, kSubStrobePattern){}; + + // Client Entries + ClientEntry red_; + ClientEntry green_; + ClientEntry blue_; + ClientEntryVoid update_color_; + ClientEntry strobe_active_; + ClientEntry strobe_period_; + ClientEntry strobe_pattern_; + + void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { + static const uint8_t kEntryLength = kSubStrobePattern + 1; + ClientEntryAbstract* entry_array[kEntryLength] = { + &red_, // 0 + &green_, // 1 + &blue_, // 2 + &update_color_, // 3 + &strobe_active_, // 4 + &strobe_period_, // 5 + &strobe_pattern_ // 6 + }; + + ParseMsg(rx_data, rx_length, entry_array, kEntryLength); + } + + private: + static const uint8_t kSubRed = 0; + static const uint8_t kSubBlue = 1; + static const uint8_t kSubGreen = 2; + static const uint8_t kSubUpdateColor = 3; + static const uint8_t kSubStrobeActive = 4; + static const uint8_t kSubStrobePeriod = 5; + static const uint8_t kSubStrobePattern = 6; + +}; + +#endif // RGB_LED_CLIENT_H diff --git a/inc/white_led.hpp b/inc/white_led.hpp new file mode 100644 index 0000000..32216b2 --- /dev/null +++ b/inc/white_led.hpp @@ -0,0 +1,51 @@ +/* + Copyright 2024 Vertiq, Inc support@vertiq.co + + This file is part of the Vertiq C++ API. + + This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) +*/ + +#ifndef WHITE_LED_CLIENT_H +#define WHITE_LED_CLIENT_H + +#include "client_communication.hpp" + +const uint8_t kTypeWhiteLed = 101; + +class WhiteLedClient : public ClientAbstract { + public: + WhiteLedClient(uint8_t obj_idn) + : ClientAbstract(kTypeWhiteLed, obj_idn), + intensity_(kTypeWhiteLed, obj_idn, kSubIntensity), + strobe_active_(kTypeWhiteLed, obj_idn, kSubStrobeActive), + strobe_period_(kTypeWhiteLed, obj_idn, kSubStrobePeriod), + strobe_pattern_(kTypeWhiteLed, obj_idn, kSubStrobePattern){}; + + // Client Entries + ClientEntry intensity_; + ClientEntry strobe_active_; + ClientEntry strobe_period_; + ClientEntry strobe_pattern_; + + void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { + static const uint8_t kEntryLength = kSubStrobePattern + 1; + ClientEntryAbstract* entry_array[kEntryLength] = { + &intensity_, // 0 + &strobe_active_, // 1 + &strobe_period_, // 2 + &strobe_pattern_ // 3 + }; + + ParseMsg(rx_data, rx_length, entry_array, kEntryLength); + } + + private: + static const uint8_t kSubIntensity = 0; + static const uint8_t kSubStrobeActive = 1; + static const uint8_t kSubStrobePeriod = 2; + static const uint8_t kSubStrobePattern = 3; + +}; + +#endif // WHITE_LED_CLIENT_H From 64d0654e337b5d74dcfca8a5e20ac921a7d12546 Mon Sep 17 00:00:00 2001 From: Fred Kummer Date: Mon, 5 Aug 2024 17:39:59 -0400 Subject: [PATCH 2/4] Fix indentation --- inc/rgb_led.hpp | 6 +++--- inc/white_led.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/rgb_led.hpp b/inc/rgb_led.hpp index 9976f23..4360332 100644 --- a/inc/rgb_led.hpp +++ b/inc/rgb_led.hpp @@ -20,9 +20,9 @@ class RgbLedClient : public ClientAbstract { red_(kTypeRgbLed, obj_idn, kSubRed), green_(kTypeRgbLed, obj_idn, kSubGreen), blue_(kTypeRgbLed, obj_idn, kSubBlue), - update_color_(kTypeRgbLed, obj_idn, kSubUpdateColor), - strobe_active_(kTypeRgbLed, obj_idn, kSubStrobeActive), - strobe_period_(kTypeRgbLed, obj_idn, kSubStrobePeriod), + update_color_(kTypeRgbLed, obj_idn, kSubUpdateColor), + strobe_active_(kTypeRgbLed, obj_idn, kSubStrobeActive), + strobe_period_(kTypeRgbLed, obj_idn, kSubStrobePeriod), strobe_pattern_(kTypeRgbLed, obj_idn, kSubStrobePattern){}; // Client Entries diff --git a/inc/white_led.hpp b/inc/white_led.hpp index 32216b2..363a583 100644 --- a/inc/white_led.hpp +++ b/inc/white_led.hpp @@ -17,9 +17,9 @@ class WhiteLedClient : public ClientAbstract { public: WhiteLedClient(uint8_t obj_idn) : ClientAbstract(kTypeWhiteLed, obj_idn), - intensity_(kTypeWhiteLed, obj_idn, kSubIntensity), - strobe_active_(kTypeWhiteLed, obj_idn, kSubStrobeActive), - strobe_period_(kTypeWhiteLed, obj_idn, kSubStrobePeriod), + intensity_(kTypeWhiteLed, obj_idn, kSubIntensity), + strobe_active_(kTypeWhiteLed, obj_idn, kSubStrobeActive), + strobe_period_(kTypeWhiteLed, obj_idn, kSubStrobePeriod), strobe_pattern_(kTypeWhiteLed, obj_idn, kSubStrobePattern){}; // Client Entries From c5ef8d9255728fb66d0e7aad5e4410c858ff4ac6 Mon Sep 17 00:00:00 2001 From: Fred Kummer Date: Mon, 5 Aug 2024 18:24:54 -0400 Subject: [PATCH 3/4] Fix green blue order --- inc/rgb_led.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/rgb_led.hpp b/inc/rgb_led.hpp index 4360332..b0817b3 100644 --- a/inc/rgb_led.hpp +++ b/inc/rgb_led.hpp @@ -51,8 +51,8 @@ class RgbLedClient : public ClientAbstract { private: static const uint8_t kSubRed = 0; - static const uint8_t kSubBlue = 1; - static const uint8_t kSubGreen = 2; + static const uint8_t kSubGreen = 1; + static const uint8_t kSubBlue = 2; static const uint8_t kSubUpdateColor = 3; static const uint8_t kSubStrobeActive = 4; static const uint8_t kSubStrobePeriod = 5; From acf5be0f2999693c20cd41dfd86abf34acdbcf06 Mon Sep 17 00:00:00 2001 From: Fred Kummer Date: Mon, 5 Aug 2024 18:28:59 -0400 Subject: [PATCH 4/4] Fix indent --- inc/rgb_led.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/rgb_led.hpp b/inc/rgb_led.hpp index b0817b3..b5d3771 100644 --- a/inc/rgb_led.hpp +++ b/inc/rgb_led.hpp @@ -37,7 +37,7 @@ class RgbLedClient : public ClientAbstract { void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { static const uint8_t kEntryLength = kSubStrobePattern + 1; ClientEntryAbstract* entry_array[kEntryLength] = { - &red_, // 0 + &red_, // 0 &green_, // 1 &blue_, // 2 &update_color_, // 3