tcp_cmd
change include from <> to "" fix some aligning of the tcp_cmd_print_help remove endptr cast strtoul cast lcd_display_text
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* Created on: 13 Nov 2023
|
||||
* Author: Gert Roelandts
|
||||
*/
|
||||
#include <tcp_cmd.h>
|
||||
#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 \"<text>\" : puts text on the lcd\r\n"
|
||||
"color <r> <g> <b> : set the background color of the lcd\r\n"
|
||||
"textColor <r> <g> <b> : set the color of the text\r\n"
|
||||
"listImages : shows a list with images in the filesystem\r\n"
|
||||
"setImage <image_name> : put an image on the screen\r\n"
|
||||
"exit : closes the connection\r\n");
|
||||
"help : shows a list of commands\r\n"
|
||||
"text \"<text>\" : puts text on the lcd\r\n"
|
||||
"color <r> <g> <b> : set the background color of the lcd\r\n"
|
||||
"textColor <r> <g> <b> : set the color of the text\r\n"
|
||||
"listImages : shows a list with images in the filesystem\r\n"
|
||||
"setImage <image_name> : 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)) {
|
||||
|
||||
Reference in New Issue
Block a user