From b1ca00800f34ab86c0a99c46796c73a8028157ff Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 1 Dec 2021 00:34:18 -0700 Subject: 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. --- main/tcp_server.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'main/tcp_server.c') 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; + } + } } } } -- cgit