Implementation of llfs and display API
Implementation of llfs and display API. Using the functions from the llfs and display API in my code
This commit is contained in:
@@ -6,13 +6,16 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "llfs.h"
|
||||
#include "cmd.h"
|
||||
#include "log.h"
|
||||
#include <tcp.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
uint32_t result_txt = 0xff000000;
|
||||
uint32_t result_bg = 0xff000000;
|
||||
|
||||
|
||||
static void echo_close (struct tcp_pcb *pcb )
|
||||
{
|
||||
@@ -32,8 +35,17 @@ static err_t echo_recv( void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t er
|
||||
|
||||
char tcp_buffer[1024];
|
||||
char text[256];
|
||||
char color[11];
|
||||
char textColor[11];
|
||||
char colorR[3];
|
||||
char colorG[3];
|
||||
char colorB[3];
|
||||
|
||||
|
||||
char textColorR[3];
|
||||
char textColorG[3];
|
||||
char textColorB[3];
|
||||
|
||||
|
||||
char *endptr;
|
||||
|
||||
if ( err == ERR_OK && p != NULL )
|
||||
{
|
||||
@@ -62,46 +74,56 @@ static err_t echo_recv( void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t er
|
||||
for (i = 0; i < len - 4; i++){
|
||||
text[i] = tcp_buffer[i + 5];
|
||||
}
|
||||
text[i-1]='\r';
|
||||
text[i]='\n';
|
||||
text[i+1]='\0';
|
||||
tcp_write( pcb, text, len_text, 0);
|
||||
tcp_output(pcb);
|
||||
text[i-1]='\0';
|
||||
lcd_display_text(text, 10, 10, result_txt, result_bg, LCD_FONT16);
|
||||
|
||||
check = 1;
|
||||
}
|
||||
else if( strncmp(tcp_buffer, "color", 5) == 0 ) {
|
||||
for (i = 0; i < 3; i++){
|
||||
color[i] = tcp_buffer[i + 6];
|
||||
color[i+3] = tcp_buffer[i + 10];
|
||||
color[i+6] = tcp_buffer[i + 14];
|
||||
colorR[i] = tcp_buffer[i + 6];
|
||||
colorG[i] = tcp_buffer[i + 10];
|
||||
colorB[i] = tcp_buffer[i + 14];
|
||||
}
|
||||
color[9]='\r';
|
||||
color[10]='\n';
|
||||
tcp_write( pcb, color, 11, 0);
|
||||
tcp_output(pcb);
|
||||
result_txt |= strtoul(colorR, &endptr, 10) << 16;
|
||||
result_txt |= strtoul(colorG, &endptr, 10) << 8;
|
||||
result_txt |= strtoul(colorB, &endptr, 10);
|
||||
|
||||
|
||||
check = 1;
|
||||
}
|
||||
else if( strncmp(tcp_buffer, "textColor", 9) == 0 ) {
|
||||
for (i = 0; i < 3; i++){
|
||||
textColor[i] = tcp_buffer[i + 10];
|
||||
textColor[i+3] = tcp_buffer[i + 14];
|
||||
textColor[i+6] = tcp_buffer[i + 18];
|
||||
textColorR[i] = tcp_buffer[i + 10];
|
||||
textColorG[i] = tcp_buffer[i + 14];
|
||||
textColorB[i] = tcp_buffer[i + 18];
|
||||
}
|
||||
textColor[9]='\r';
|
||||
textColor[10]='\n';
|
||||
tcp_write( pcb, textColor, 11, 0);
|
||||
tcp_output(pcb);
|
||||
check = 1;
|
||||
}
|
||||
else if( strcmp(tcp_buffer, "listImages") == 0 ) {
|
||||
result_bg |= strtoul(textColorR, &endptr, 10) << 16;
|
||||
result_bg |= strtoul(textColorG, &endptr, 10) << 8;
|
||||
result_bg |= strtoul(textColorB, &endptr, 10);
|
||||
|
||||
check = 1;
|
||||
}
|
||||
else if( strcmp(tcp_buffer, "setImages") == 0 ) {
|
||||
else if( strncmp(tcp_buffer, "listImages", 10) == 0 ) {
|
||||
size_t number_of_files = llfs_file_count();
|
||||
|
||||
llfs_file_t file_list[number_of_files];
|
||||
|
||||
number_of_files = llfs_file_list(file_list, number_of_files, NULL);
|
||||
|
||||
|
||||
for(int i = 0; i < number_of_files; i++){
|
||||
tcp_write( pcb, file_list[i].name, strlen(file_list[i].name), TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE);
|
||||
tcp_write( pcb, "\r\n", 2, TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE);
|
||||
}
|
||||
|
||||
check = 1;
|
||||
}
|
||||
else if( strcmp(tcp_buffer, "exit") == 0 ) {
|
||||
else if( strncmp(tcp_buffer, "setImages", 9) == 0 ) {
|
||||
|
||||
check = 1;
|
||||
}
|
||||
else if( strncmp(tcp_buffer, "exit", 4) == 0 ) {
|
||||
echo_close( pcb );
|
||||
check = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user