From e9bcf0e712447e129ab8103aba962cc02b648183 Mon Sep 17 00:00:00 2001 From: Sani7 Date: Wed, 29 Nov 2023 21:24:17 +0100 Subject: [PATCH] tcp_cmd change include from <> to "" fix some aligning of the tcp_cmd_print_help remove endptr cast strtoul cast lcd_display_text --- project/Core/Src/tcp_cmd.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/project/Core/Src/tcp_cmd.c b/project/Core/Src/tcp_cmd.c index e4c56ba..01cd147 100644 --- a/project/Core/Src/tcp_cmd.c +++ b/project/Core/Src/tcp_cmd.c @@ -4,7 +4,7 @@ * Created on: 13 Nov 2023 * Author: Gert Roelandts */ -#include +#include "tcp_cmd.h" static uint32_t result_txt = 0xff000000; // Store text color static uint32_t result_bg = 0xff000000; // Store background color @@ -30,13 +30,13 @@ void tcp_cmd_print_header(struct tcp_pcb* pcb) { void tcp_cmd_print_help(struct tcp_pcb* pcb) { tcp_cmd_write(pcb, - "help : shows a list of commands\r\n" - "text \"\" : puts text on the lcd\r\n" - "color : set the background color of the lcd\r\n" - "textColor : set the color of the text\r\n" - "listImages : shows a list with images in the filesystem\r\n" - "setImage : put an image on the screen\r\n" - "exit : closes the connection\r\n"); + "help : shows a list of commands\r\n" + "text \"\" : puts text on the lcd\r\n" + "color : set the background color of the lcd\r\n" + "textColor : set the color of the text\r\n" + "listImages : shows a list with images in the filesystem\r\n" + "setImage : put an image on the screen\r\n" + "exit : closes the connection\r\n"); } static err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err) { @@ -58,8 +58,6 @@ static err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t char extension[4]; - char* endptr; - LWIP_UNUSED_ARG(arg); if (err == ERR_OK && p != NULL) { @@ -76,7 +74,7 @@ static err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t } text[i - 1] = '\0'; lcd_clear_text(); - lcd_display_text(text, 10, 10, result_txt, result_bg, LCD_FONT24); + lcd_display_text((uint8_t*)text, 10, 10, result_txt, result_bg, LCD_FONT24); check = 1; } else if (!strncmp(pc, "color", 5)) { @@ -85,9 +83,9 @@ static err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t color_g[i] = pc[i + 10]; color_b[i] = pc[i + 14]; } - result_bg |= strtoul(color_r, &endptr, 10) << 16; - result_bg |= strtoul(color_g, &endptr, 10) << 8; - result_bg |= strtoul(color_b, &endptr, 10); + result_bg |= (uint32_t)strtoul(color_r, NULL, 10) << 16; + result_bg |= (uint32_t)strtoul(color_g, NULL, 10) << 8; + result_bg |= (uint32_t)strtoul(color_b, NULL, 10); check = 1; } else if (!strncmp(pc, "textColor", 9)) { @@ -96,9 +94,9 @@ static err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t text_color_g[i] = pc[i + 14]; text_color_b[i] = pc[i + 18]; } - result_txt |= strtoul(text_color_r, &endptr, 10) << 16; - result_txt |= strtoul(text_color_g, &endptr, 10) << 8; - result_txt |= strtoul(text_color_b, &endptr, 10); + result_txt |= (uint32_t)strtoul(text_color_r, NULL, 10) << 16; + result_txt |= (uint32_t)strtoul(text_color_g, NULL, 10) << 8; + result_txt |= (uint32_t)strtoul(text_color_b, NULL, 10); check = 1; } else if (!strncmp(pc, "listImages", 10)) {