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:
@@ -8,6 +8,8 @@
|
|||||||
#ifndef INC_CMD_H_
|
#ifndef INC_CMD_H_
|
||||||
#define INC_CMD_H_
|
#define INC_CMD_H_
|
||||||
|
|
||||||
|
#include "lcd_api.h"
|
||||||
|
|
||||||
|
|
||||||
void echo_init( void );
|
void echo_init( void );
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "llfs.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include <tcp.h>
|
#include <tcp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
uint32_t result_txt = 0xff000000;
|
||||||
|
uint32_t result_bg = 0xff000000;
|
||||||
|
|
||||||
|
|
||||||
static void echo_close (struct tcp_pcb *pcb )
|
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 tcp_buffer[1024];
|
||||||
char text[256];
|
char text[256];
|
||||||
char color[11];
|
char colorR[3];
|
||||||
char textColor[11];
|
char colorG[3];
|
||||||
|
char colorB[3];
|
||||||
|
|
||||||
|
|
||||||
|
char textColorR[3];
|
||||||
|
char textColorG[3];
|
||||||
|
char textColorB[3];
|
||||||
|
|
||||||
|
|
||||||
|
char *endptr;
|
||||||
|
|
||||||
if ( err == ERR_OK && p != NULL )
|
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++){
|
for (i = 0; i < len - 4; i++){
|
||||||
text[i] = tcp_buffer[i + 5];
|
text[i] = tcp_buffer[i + 5];
|
||||||
}
|
}
|
||||||
text[i-1]='\r';
|
text[i-1]='\0';
|
||||||
text[i]='\n';
|
lcd_display_text(text, 10, 10, result_txt, result_bg, LCD_FONT16);
|
||||||
text[i+1]='\0';
|
|
||||||
tcp_write( pcb, text, len_text, 0);
|
|
||||||
tcp_output(pcb);
|
|
||||||
check = 1;
|
check = 1;
|
||||||
}
|
}
|
||||||
else if( strncmp(tcp_buffer, "color", 5) == 0 ) {
|
else if( strncmp(tcp_buffer, "color", 5) == 0 ) {
|
||||||
for (i = 0; i < 3; i++){
|
for (i = 0; i < 3; i++){
|
||||||
color[i] = tcp_buffer[i + 6];
|
colorR[i] = tcp_buffer[i + 6];
|
||||||
color[i+3] = tcp_buffer[i + 10];
|
colorG[i] = tcp_buffer[i + 10];
|
||||||
color[i+6] = tcp_buffer[i + 14];
|
colorB[i] = tcp_buffer[i + 14];
|
||||||
}
|
}
|
||||||
color[9]='\r';
|
result_txt |= strtoul(colorR, &endptr, 10) << 16;
|
||||||
color[10]='\n';
|
result_txt |= strtoul(colorG, &endptr, 10) << 8;
|
||||||
tcp_write( pcb, color, 11, 0);
|
result_txt |= strtoul(colorB, &endptr, 10);
|
||||||
tcp_output(pcb);
|
|
||||||
|
|
||||||
check = 1;
|
check = 1;
|
||||||
}
|
}
|
||||||
else if( strncmp(tcp_buffer, "textColor", 9) == 0 ) {
|
else if( strncmp(tcp_buffer, "textColor", 9) == 0 ) {
|
||||||
for (i = 0; i < 3; i++){
|
for (i = 0; i < 3; i++){
|
||||||
textColor[i] = tcp_buffer[i + 10];
|
textColorR[i] = tcp_buffer[i + 10];
|
||||||
textColor[i+3] = tcp_buffer[i + 14];
|
textColorG[i] = tcp_buffer[i + 14];
|
||||||
textColor[i+6] = tcp_buffer[i + 18];
|
textColorB[i] = tcp_buffer[i + 18];
|
||||||
}
|
}
|
||||||
textColor[9]='\r';
|
result_bg |= strtoul(textColorR, &endptr, 10) << 16;
|
||||||
textColor[10]='\n';
|
result_bg |= strtoul(textColorG, &endptr, 10) << 8;
|
||||||
tcp_write( pcb, textColor, 11, 0);
|
result_bg |= strtoul(textColorB, &endptr, 10);
|
||||||
tcp_output(pcb);
|
|
||||||
check = 1;
|
|
||||||
}
|
|
||||||
else if( strcmp(tcp_buffer, "listImages") == 0 ) {
|
|
||||||
|
|
||||||
check = 1;
|
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;
|
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 );
|
echo_close( pcb );
|
||||||
check = 1;
|
check = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user