aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-12-07 16:59:51 -0700
committerJosh Rahm <joshuarahm@gmail.com>2025-12-07 16:59:51 -0700
commita4930f91ced80d26758fae30f3e01eee7abe4345 (patch)
tree7814e178c3a13b7f3bbc03dd5ad4d97af744baf8 /include
parent44c7f7a675d2cdb0281322f38be3227ef4fb1df2 (diff)
downloadesp32-ws2812b-a4930f91ced80d26758fae30f3e01eee7abe4345.tar.gz
esp32-ws2812b-a4930f91ced80d26758fae30f3e01eee7abe4345.tar.bz2
esp32-ws2812b-a4930f91ced80d26758fae30f3e01eee7abe4345.zip
Add a couple different parameter types.
fraction_t: semantically represents a value 0.0-1.0. Internally this is represented as a uint8 with 255 being 1 and 0 being 0. ratio_t: represents a fracitonal number that can be larger than 1.0.
Diffstat (limited to 'include')
-rw-r--r--include/param.h4
-rw-r--r--include/state_params.i20
2 files changed, 14 insertions, 10 deletions
diff --git a/include/param.h b/include/param.h
index 5259e0a..d0b5bf0 100644
--- a/include/param.h
+++ b/include/param.h
@@ -6,6 +6,8 @@
typedef struct httpd_req httpd_req_t;
typedef uint32_t color_int_t;
+typedef uint8_t fraction_t;
+typedef uint16_t ratio_t;
#define DECL_PARAMETER_INSTANCE(ty) \
void handle_option__##ty(const char* attr, sockbuf_t* sockbuf, ty* ptr); \
@@ -24,5 +26,7 @@ DECL_PARAMETER_INSTANCE(uint8_t);
DECL_PARAMETER_INSTANCE(bool);
DECL_PARAMETER_INSTANCE(uint32_t);
DECL_PARAMETER_INSTANCE(color_int_t);
+DECL_PARAMETER_INSTANCE(fraction_t);
+DECL_PARAMETER_INSTANCE(ratio_t);
DECL_PARAMETER_INSTANCE(int);
DECL_PARAMETER_INSTANCE(int32_t);
diff --git a/include/state_params.i b/include/state_params.i
index e768768..854008d 100644
--- a/include/state_params.i
+++ b/include/state_params.i
@@ -4,16 +4,16 @@
// type name display name, default value
STATE_PARAM(int32_t, time, "Current Time", 0)
-STATE_PARAM(int, speed, "Speed", 1000)
-STATE_PARAM(uint8_t, brightness, "Brightness", 50)
+STATE_PARAM(ratio_t, speed, "Speed", 255)
+STATE_PARAM(fraction_t, brightness, "Brightness", 50)
STATE_PARAM(uint8_t, n_snow, "Snow Effect", 10)
-STATE_PARAM(uint8_t, n_red, "Desaturation", 32)
-STATE_PARAM(int, x_scale, "X Scale", 255)
-STATE_PARAM(bool, power, "Power", true)
-STATE_PARAM(bool, cool, "Cool", false)
-STATE_PARAM(bool, invert, "Invert", false)
+STATE_PARAM(fraction_t, n_red, "Desaturation", 32)
+STATE_PARAM(ratio_t, x_scale, "X Scale", 255)
+STATE_PARAM(bool, power, "Power", true)
+STATE_PARAM(bool, cool, "Cool", false)
+STATE_PARAM(bool, invert, "Invert", false)
STATE_PARAM(bool, use_static_color, "Use Static Color", false)
STATE_PARAM(color_int_t, static_color, "Static Color", 0xffddbb)
-STATE_PARAM(bool, twinkle, "Twinkle", true)
-STATE_PARAM(uint8_t, twink_amt, "Twinkle Amount", 0)
-STATE_PARAM(uint8_t, base_brightness, "Base Brightness", 0)
+STATE_PARAM(bool, twinkle, "Twinkle", true)
+STATE_PARAM(fraction_t, twink_amt, "Twinkle Amount", 0)
+STATE_PARAM(fraction_t, base_brightness, "Base Brightness", 0)