Skip to content

Commit

Permalink
Merged in development (pull request #22)
Browse files Browse the repository at this point in the history
Development

Approved-by: Fred Kummer
  • Loading branch information
Vertiq-Ben committed Aug 13, 2024
2 parents a9b700d + 0e9f7cd commit c488af4
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
63 changes: 63 additions & 0 deletions inc/rgb_led.hpp
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
51 changes: 51 additions & 0 deletions inc/white_led.hpp
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

0 comments on commit c488af4

Please sign in to comment.