tcp_cmd
add argb capability to color and bgcolor
This commit is contained in:
@@ -46,15 +46,15 @@ static void tcp_cmd_print_header(struct tcp_pcb* pcb) {
|
|||||||
* @param pcb The tcp_pcb struct to write to
|
* @param pcb The tcp_pcb struct to write to
|
||||||
*/
|
*/
|
||||||
static void tcp_cmd_print_help(struct tcp_pcb* pcb) {
|
static void tcp_cmd_print_help(struct tcp_pcb* pcb) {
|
||||||
tcp_cmd_write(pcb, "help : shows a list of commands\n"
|
tcp_cmd_write(pcb, "help : shows a list of commands\n"
|
||||||
"clear text/images : clears the text or images on the lcd\n"
|
"clear text/images : clears the text or images on the lcd\n"
|
||||||
"text \"<text>\" : puts text on the lcd\n"
|
"text \"<text>\" : puts text on the lcd\n"
|
||||||
"bgColor <r> <g> <b> : set the background color of the lcd\n"
|
"bgColor (<a>) <r> <g> <b> : set the background color of the lcd\n"
|
||||||
"color <r> <g> <b> : set the color of the text\n"
|
"color (<a>) <r> <g> <b> : set the color of the text\n"
|
||||||
"listFiles : shows a list with images in the filesystem\n"
|
"listFiles : shows a list with images in the filesystem\n"
|
||||||
"setImage <image_name> : put an image on the screen\n"
|
"setImage <image_name> : put an image on the screen\n"
|
||||||
"setGif <image_name> : put a gif on the screen\n"
|
"setGif <image_name> : put a gif on the screen\n"
|
||||||
"exit : closes the connection\n");
|
"exit : closes the connection\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,7 +218,7 @@ static bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv) {
|
|||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
LOG_INFO(TAG, "Setting background color to %s", argv[1]);
|
LOG_INFO(TAG, "Setting background color to %s", argv[1]);
|
||||||
color_bg = (uint32_t)strtoul(argv[1], NULL, 16);
|
color_bg = (uint32_t)strtoul(argv[1], NULL, 16);
|
||||||
color_bg |= 0xff000000;
|
color_bg ^= 0xff000000;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (argc == 4) {
|
if (argc == 4) {
|
||||||
@@ -229,16 +229,27 @@ static bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv) {
|
|||||||
color_bg |= (uint32_t)strtoul(argv[3], NULL, 10);
|
color_bg |= (uint32_t)strtoul(argv[3], NULL, 10);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (argc == 5) {
|
||||||
|
LOG_INFO(TAG, "Setting text color to %s %s %s %s", argv[1], argv[2], argv[3], argv[4]);
|
||||||
|
color_txt = 0xff000000;
|
||||||
|
color_txt ^= (uint32_t)strtoul(argv[1], NULL, 10) << 24;
|
||||||
|
color_txt |= (uint32_t)strtoul(argv[2], NULL, 10) << 16;
|
||||||
|
color_txt |= (uint32_t)strtoul(argv[3], NULL, 10) << 8;
|
||||||
|
color_txt |= (uint32_t)strtoul(argv[4], NULL, 10);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
LOG_WARN(TAG, "Bad usage of bgcolor");
|
LOG_WARN(TAG, "Bad usage of bgcolor");
|
||||||
tcp_cmd_write(pcb, "Usage: bgcolor <background color>\n");
|
tcp_cmd_write(pcb, "Usage: bgcolor 0x<rrggbb>\n");
|
||||||
|
tcp_cmd_write(pcb, "Usage: bgcolor 0x<aarrggbb>\n");
|
||||||
tcp_cmd_write(pcb, "Usage: bgcolor r g b\n");
|
tcp_cmd_write(pcb, "Usage: bgcolor r g b\n");
|
||||||
|
tcp_cmd_write(pcb, "Usage: bgcolor a r g b\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (strcmp(argv[0], "color") == 0) {
|
if (strcmp(argv[0], "color") == 0) {
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
LOG_INFO(TAG, "Setting text color to %s", argv[1]);
|
LOG_INFO(TAG, "Setting text color to %s", argv[1]);
|
||||||
color_txt = (uint32_t)strtoul(argv[1], NULL, 16);
|
color_txt = (uint32_t)strtoul(argv[1], NULL, 16);
|
||||||
color_txt |= 0xff000000;
|
color_txt ^= 0xff000000;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (argc == 4) {
|
if (argc == 4) {
|
||||||
@@ -249,9 +260,20 @@ static bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv) {
|
|||||||
color_txt |= (uint32_t)strtoul(argv[3], NULL, 10);
|
color_txt |= (uint32_t)strtoul(argv[3], NULL, 10);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (argc == 5) {
|
||||||
|
LOG_INFO(TAG, "Setting text color to %s %s %s %s", argv[1], argv[2], argv[3], argv[4]);
|
||||||
|
color_txt = 0xff000000;
|
||||||
|
color_txt ^= (uint32_t)strtoul(argv[1], NULL, 10) << 24;
|
||||||
|
color_txt |= (uint32_t)strtoul(argv[2], NULL, 10) << 16;
|
||||||
|
color_txt |= (uint32_t)strtoul(argv[3], NULL, 10) << 8;
|
||||||
|
color_txt |= (uint32_t)strtoul(argv[4], NULL, 10);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
LOG_WARN(TAG, "Bad usage of color");
|
LOG_WARN(TAG, "Bad usage of color");
|
||||||
tcp_cmd_write(pcb, "Usage: color 0x<txt color>\n");
|
tcp_cmd_write(pcb, "Usage: color 0x<rrggbb>\n");
|
||||||
|
tcp_cmd_write(pcb, "Usage: color 0x<aarrggbb>\n");
|
||||||
tcp_cmd_write(pcb, "Usage: color <r> <g> <b>\n");
|
tcp_cmd_write(pcb, "Usage: color <r> <g> <b>\n");
|
||||||
|
tcp_cmd_write(pcb, "Usage: color <a> <r> <g> <b>\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (strcmp(argv[0], "listfiles") == 0) {
|
if (strcmp(argv[0], "listfiles") == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user