diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2025-12-07 15:37:04 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2025-12-07 15:37:04 -0700 |
| commit | c9efee6f3ffcf19e139d72d946aa4d837bbcbb9e (patch) | |
| tree | dc1c5c4c78e9758140029118a7f7c969703572b5 /main/param | |
| parent | b2b344ebec8f7b55506deb0c2138a1e2b9ffeb46 (diff) | |
| download | esp32-ws2812b-c9efee6f3ffcf19e139d72d946aa4d837bbcbb9e.tar.gz esp32-ws2812b-c9efee6f3ffcf19e139d72d946aa4d837bbcbb9e.tar.bz2 esp32-ws2812b-c9efee6f3ffcf19e139d72d946aa4d837bbcbb9e.zip | |
Better timing.
No longer hammering the SPI bus, but rather being more controlled, and
interpolation is handled better.
Diffstat (limited to 'main/param')
| -rw-r--r-- | main/param/int32_t.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/main/param/int32_t.c b/main/param/int32_t.c new file mode 100644 index 0000000..ebf9d4e --- /dev/null +++ b/main/param/int32_t.c @@ -0,0 +1,43 @@ +#include "param.h" +#include "http_server.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void handle_option__int32_t( + const char* attr, sockbuf_t* sockbuf, int32_t* ptr) +{ + int tmp = (int)(*ptr); + handle_option__int(attr, sockbuf, &tmp); + *ptr = (int32_t)tmp; +} + +size_t serialize_to_json__int32_t( + char** out, size_t len, const char* attr, const char* dn, int32_t value) +{ + size_t newlen = snprintf( + *out, + len, + "\"%s\":{\"type\":\"int\",\"value\":\"%ld\",\"disp\":\"%s\"}", + attr, + (long)value, + dn); + *out += newlen; + return len - newlen; +} + +#define TAG "param_int32" +void http_handle__int32_t(httpd_req_t* req, int32_t* val) +{ + int tmp = (int)(*val); + http_handle__int(req, &tmp); + *val = (int32_t)tmp; +} + +void print__int32_t(sockbuf_t* sockbuf, const char* attr, int32_t val) +{ + char buf[128]; + snprintf(buf, sizeof(buf), "%s: %ld :: int32_t\n", attr, (long)val); + sockbuf_write(sockbuf, buf); +} |