This commit is contained in:
2026-05-18 22:59:45 +02:00
parent aed00ceda2
commit 77c9d4a4d5
10 changed files with 1185 additions and 119 deletions
+40 -2
View File
@@ -1,9 +1,12 @@
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "driver/gpio.h"
#include "drivers/fonts.h"
#include "drivers/i2c.h"
#include "drivers/sim800.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@@ -21,13 +24,19 @@
#include "hal/gpio_types.h"
#include "projdefs.h"
char linebuf[1024];
char *linebufPtr = linebuf;
void app_main(void) {
memset(linebuf, 0, sizeof(linebuf));
printf("boot\n");
set_pin_dirs();
battery_start_task();
i2c_init(BUS_I2C_SDA, BUS_I2C_SCL);
ws2812_init();
sim800_uart_init();
xTaskCreate(init_modem, "init_modem", 4096, NULL, 10, NULL);
audio_i2s_init();
vTaskDelay(pdMS_TO_TICKS(10));
es8311_init();
@@ -66,13 +75,40 @@ void app_main(void) {
font5x7);
while (tca8418_read(&key, &pressed)) {
char c = getKeyboardChar(key);
if (!pressed) {
if (isprint(c)) {
*(linebufPtr++) = c;
} else {
switch (c) {
case '\n':
sim800_tcp_send(linebuf, linebufPtr - linebuf);
linebufPtr = linebuf;
memset(linebuf, 0, sizeof(linebuf));
break;
case '\b':
if (linebufPtr > linebuf) {
*(linebufPtr--) = 0;
}
}
}
if (linebufPtr > linebuf + 1023) {
linebufPtr = linebuf + 1023;
}
}
/*
snprintf(buf, sizeof(buf), "key=%c %s %d %s", getKeyboardChar(key),
getKeyboardKeyName(key), key, pressed ? "pressed" : "released");
printf("%s\n", buf);
st7789_draw_string(30, 30, buf, 0x07E0, 0x0000, true, fontHitachi);
audio_beep();
*/
// audio_beep();
}
st7789_draw_string(30, 30, linebuf, 0x07E0, 0x0000, true, fontHitachi);
bmi270_data_t bmiData;
@@ -88,6 +124,8 @@ void app_main(void) {
snprintf(buf, sizeof(buf), "BAT: %d%%(%.3fV)", getBatteryPercentage(),
getBatteryVoltage());
st7789_draw_string(140, 10, buf, 0x07E0, 0x0000, true, fontHitachi);
st7789_draw_string(30, 90, linebufIn, 0x07E0, 0x0000, true, fontHitachi);
st7789_flush();
vTaskDelay(pdMS_TO_TICKS(20)); // 50 fps max