diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2021-12-01 00:34:18 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2021-12-01 00:34:18 -0700 |
commit | b1ca00800f34ab86c0a99c46796c73a8028157ff (patch) | |
tree | 60b90da71bf12c034ecec08eced9f07d825ad92a /main/tcp_server.c | |
parent | d89195e2144df51ca02a860f4b46fd38b4dfeb29 (diff) | |
download | esp32-ws2812b-b1ca00800f34ab86c0a99c46796c73a8028157ff.tar.gz esp32-ws2812b-b1ca00800f34ab86c0a99c46796c73a8028157ff.tar.bz2 esp32-ws2812b-b1ca00800f34ab86c0a99c46796c73a8028157ff.zip |
Port the code from my STM project over to ESP32.
There is still definitely some jenk to it. For one I still
need to figure out how to protect critical sections to prevent stutter.
I do need to set up a timer to control the time incrementer rather than
depending on the speed of the spi bus.
Diffstat (limited to 'main/tcp_server.c')
-rw-r--r-- | main/tcp_server.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/main/tcp_server.c b/main/tcp_server.c index 1ff9b62..f50dc21 100644 --- a/main/tcp_server.c +++ b/main/tcp_server.c @@ -34,10 +34,22 @@ portTASK_FUNCTION(tcp_server, params) printf("Accepted connection\n"); ssize_t len; - while ((len = read(sock, ws_params->color, sizeof(ws_params->color) - 1)) > + char buf[128]; + while ((len = read(sock, buf, sizeof(buf) - 1)) > 0) { - ws_params->color[len] = 0; - printf("Read %s\n", ws_params->color); + buf[len] = 0; + printf("Read %s\n", buf); + + for (int i = 0; i < len; ++ i) { + switch (buf[i]) { + case '+': + ws_params->state.brightness += 10; + break; + case '-': + ws_params->state.brightness -= 10; + break; + } + } } } } |