rsiot/components/cmp_esp_led/
config.rs1use esp_idf_svc::hal::{gpio::AnyIOPin, rmt::RmtChannel};
2use serde::{Deserialize, Serialize};
3use ws2812_esp32_rmt_driver::RGB8;
4
5use crate::message::{Message, MsgDataBound};
6
7pub type FnInput<TMsg> = fn(&Message<TMsg>) -> Option<Vec<(u8, ConfigRgb)>>;
8
9pub struct Config<TMsg, TRmt>
11where
12 TMsg: MsgDataBound,
13 TRmt: RmtChannel + 'static,
14{
15 pub pin: AnyIOPin<'static>,
17
18 pub rmt_channel: TRmt,
20
21 pub fn_input: FnInput<TMsg>,
23}
24
25#[derive(Deserialize, Clone, Copy, Debug, Default, PartialEq, Serialize)]
27pub struct ConfigRgb
28where
29 Self: Sized,
30{
31 pub r: u8,
33 pub g: u8,
35 pub b: u8,
37}
38
39impl From<ConfigRgb> for RGB8 {
40 fn from(value: ConfigRgb) -> Self {
41 RGB8 {
42 r: value.r,
43 g: value.g,
44 b: value.b,
45 }
46 }
47}