wled_json_api_library/structures/cfg/
cfg_light.rs

1use serde;
2use serde::{Serialize, Deserialize};
3use serde_repr::{Deserialize_repr, Serialize_repr};
4use crate::structures::none_function;
5
6
7
8
9
10#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct Light {
13    /// % of brightness to set (to limit power, if you set it to 50 and set bri to 255, actual brightness will be 127)
14    #[serde(skip_serializing_if = "Option::is_none")]
15    #[serde(default = "none_function")]
16    #[serde(rename = "scale-bri")]
17    pub scale_bri: Option<u8>,
18
19    /// paletteBlend: 0 - wrap when moving, 1 - always wrap, 2 - never wrap, 3 - none (undefined)
20    #[serde(skip_serializing_if = "Option::is_none")]
21    #[serde(default = "none_function")]
22    #[serde(rename = "pal-mode")]
23    pub pal_mode: Option<u8>,
24
25    /// If true, a segment per bus will be created on boot and LED settings save.
26    /// If false, only one segment spanning the total LEDs is created,
27    /// but not on LED settings save if there is more than one segment currently
28    #[serde(skip_serializing_if = "Option::is_none")]
29    #[serde(default = "none_function")]
30    pub aseg: Option<bool>,
31
32    #[serde(skip_serializing_if = "Option::is_none")]
33    #[serde(default = "none_function")]
34    pub gc: Option<Gc>,
35
36    #[serde(skip_serializing_if = "Option::is_none")]
37    #[serde(default = "none_function")]
38    pub tr: Option<Tr>,
39
40    #[serde(skip_serializing_if = "Option::is_none")]
41    #[serde(default = "none_function")]
42    pub nl: Option<Nl>,
43}
44
45/// gamma correction shit, tired of documenting speghetti
46#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
47#[serde(rename_all = "camelCase")]
48pub struct Gc {
49    /// see struct documentation
50    #[serde(skip_serializing_if = "Option::is_none")]
51    #[serde(default = "none_function")]
52    pub bri: Option<f64>,
53
54    /// see struct documentation
55    #[serde(skip_serializing_if = "Option::is_none")]
56    #[serde(default = "none_function")]
57    pub col: Option<f64>,
58
59    /// see struct documentation
60    #[serde(skip_serializing_if = "Option::is_none")]
61    #[serde(default = "none_function")]
62    pub val: Option<f64>,
63}
64
65/// transition stuff, tired of documenting speghetti
66#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
67#[serde(rename_all = "camelCase")]
68pub struct Tr {
69    /// see struct documentation
70    #[serde(skip_serializing_if = "Option::is_none")]
71    #[serde(default = "none_function")]
72    pub mode: Option<bool>,
73
74    /// default transition time / 100
75    #[serde(skip_serializing_if = "Option::is_none")]
76    #[serde(default = "none_function")]
77    pub dur: Option<u16>,
78
79    /// see struct documentation
80    #[serde(skip_serializing_if = "Option::is_none")]
81    #[serde(default = "none_function")]
82    pub pal: Option<u8>,
83
84    /// amount of time [s] between random palette changes (min: 1s, max: 255s)
85    #[serde(skip_serializing_if = "Option::is_none")]
86    #[serde(default = "none_function")]
87    pub rpc: Option<u8>,
88}
89
90/// night light stuff, tired of documenting speghetti
91#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
92#[serde(rename_all = "camelCase")]
93pub struct Nl {
94
95    /// see struct documentation
96    #[serde(skip_serializing_if = "Option::is_none")]
97    #[serde(default = "none_function")]
98    pub mode: Option<NightLightMode>,
99
100    /// see struct documentation
101    #[serde(skip_serializing_if = "Option::is_none")]
102    #[serde(default = "none_function")]
103    pub dur: Option<u8>,
104
105    /// brightness after nightlight is over
106    #[serde(skip_serializing_if = "Option::is_none")]
107    #[serde(default = "none_function")]
108    pub tbri: Option<u8>,
109
110    /// after nightlight delay over
111    #[serde(skip_serializing_if = "Option::is_none")]
112    #[serde(default = "none_function")]
113    #[serde(rename = "macro")]
114    pub macro_field: Option<u8>,
115}
116
117
118
119
120/// Modes for night light
121#[allow(non_camel_case_types)]
122#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
123#[repr(u8)]
124pub enum NightLightMode {
125    /// After nightlight time elapsed, set to target brightness
126    NL_MODE_SET,
127    /// Fade to target brightness gradually
128    NL_MODE_FADE,
129    /// Fade to target brightness and secondary color gradually
130    NL_MODE_COLORFADE,
131    /// Sunrise/sunset. Target brightness is set immediately, then Sunrise effect is started. Max 60 min.
132    NL_MODE_SUN,
133    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
134    RSVD1,
135    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
136    RSVD2,
137    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
138    RSVD3,
139    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
140    RSVD4,
141    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
142    RSVD5,
143    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
144    RSVD6,
145
146}