-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in development (pull request #22)
Development Approved-by: Fred Kummer
- Loading branch information
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2024 Vertiq, Inc [email protected] | ||
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<uint8_t> red_; | ||
ClientEntry<uint8_t> green_; | ||
ClientEntry<uint8_t> blue_; | ||
ClientEntryVoid update_color_; | ||
ClientEntry<uint8_t> strobe_active_; | ||
ClientEntry<float> strobe_period_; | ||
ClientEntry<uint32_t> 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 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; | ||
static const uint8_t kSubStrobePattern = 6; | ||
|
||
}; | ||
|
||
#endif // RGB_LED_CLIENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright 2024 Vertiq, Inc [email protected] | ||
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<uint8_t> intensity_; | ||
ClientEntry<uint8_t> strobe_active_; | ||
ClientEntry<float> strobe_period_; | ||
ClientEntry<uint32_t> 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 |