Trying to move project->FreeRTOS (WIP)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
|
||||
set(APP_NAME "Listener")
|
||||
|
||||
add_executable(${APP_NAME}
|
||||
./main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${APP_NAME} LINK_PUBLIC
|
||||
pico_stdlib
|
||||
FreeRTOS
|
||||
)
|
||||
|
||||
pico_enable_stdio_usb(${APP_NAME} 1)
|
||||
pico_enable_stdio_uart(${APP_NAME} 0)
|
||||
|
||||
pico_add_extra_outputs(${APP_NAME})
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "Config/FreeRTOSConfig.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include <pico/error.h>
|
||||
#include <pico/stdio.h>
|
||||
#include <pico/time.h>
|
||||
#include <RadioLib/RadioLib.h>
|
||||
#include <RadioLib/>
|
||||
|
||||
const char NULLCHAR = '\0';
|
||||
|
||||
char* read_buffer;
|
||||
|
||||
int readInput() {
|
||||
unsigned int len = 0;
|
||||
int ret;
|
||||
unsigned char ret_char;
|
||||
while(true) {
|
||||
ret = getchar_timeout_us(0);
|
||||
if (ret == PICO_ERROR_TIMEOUT) {
|
||||
continue;
|
||||
} else {
|
||||
ret_char = (char)ret;
|
||||
printf("%c", ret);
|
||||
sleep_ms(50);
|
||||
if (ret_char & 0xE0) {
|
||||
memcpy(read_buffer+len*sizeof(char), &ret_char, sizeof(char));
|
||||
sleep_ms(50);
|
||||
len++;
|
||||
} else {
|
||||
bool should_break = false;
|
||||
if (len==0) { continue; }
|
||||
switch(ret_char) {
|
||||
case 8:
|
||||
len--;
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
should_break = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (should_break) { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
memcpy(read_buffer+len*sizeof(char), &NULLCHAR, sizeof(char));
|
||||
sleep_ms(50);
|
||||
return len;
|
||||
}
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
int num;
|
||||
int len;
|
||||
read_buffer = malloc(256 * sizeof(char));
|
||||
while(true) {
|
||||
printf("Give a number: \n");
|
||||
sleep_ms(50);
|
||||
num = readInput();
|
||||
if (num) {
|
||||
printf("Printed %d characters: ", num);
|
||||
printf("%s\n", read_buffer);
|
||||
} else {
|
||||
printf("Got empty line\n");
|
||||
}
|
||||
sleep_ms(50);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user