Compare commits

...

10 Commits

Author SHA1 Message Date
959e2989ab latest code changes
Some checks failed
Remote Control Build / build (ubuntu-latest) (push) Failing after 13m2s
Remote Control Build / build (macos-latest) (push) Has been cancelled
2024-06-04 21:56:44 +02:00
7df248c624 implement display timeout 2023-08-16 22:35:23 +02:00
5ef43baaa0 Revert "restructure folders"
This reverts commit 6aac53cc3b.
2023-08-16 22:25:32 +02:00
6aac53cc3b restructure folders 2023-08-16 16:07:30 +02:00
9ca5968e9f enhanced github action 2023-08-15 22:50:50 +02:00
44c9147d68 enhanced github action 2023-08-15 22:49:44 +02:00
62c6eb270f enhanced github action 2023-08-15 22:48:06 +02:00
99229c3650 enhanced github action 2023-08-15 22:39:40 +02:00
e946896363 enhanced github action 2023-08-15 22:30:43 +02:00
43c3b1de60 update lvgl config 2023-08-15 15:07:44 +02:00
18 changed files with 205 additions and 23 deletions

View File

@@ -11,8 +11,8 @@ jobs:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-python@v1 - uses: actions/setup-python@v3
- name: Install PlatformIO - name: Install PlatformIO
run: | run: |
@@ -22,3 +22,10 @@ jobs:
- name: Build bare metal - name: Build bare metal
run: platformio run run: platformio run
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist-firmware ${{ matrix.os }}
path: |
.pio/build/**/*.bin

View File

@@ -78,7 +78,7 @@
*====================*/ *====================*/
/*Default display refresh period. LVG will redraw changed areas with this period time*/ /*Default display refresh period. LVG will redraw changed areas with this period time*/
#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ #define LV_DISP_DEF_REFR_PERIOD 16 /*[ms]*/
/*Input device read period in milliseconds*/ /*Input device read period in milliseconds*/
#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ #define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/
@@ -230,7 +230,7 @@
*-----------*/ *-----------*/
/*Enable the log module*/ /*Enable the log module*/
#define LV_USE_LOG 0 #define LV_USE_LOG 1
#if LV_USE_LOG #if LV_USE_LOG
/*How important log should be added: /*How important log should be added:
@@ -244,7 +244,7 @@
/*1: Print the log with 'printf'; /*1: Print the log with 'printf';
*0: User need to register a callback with `lv_log_register_print_cb()`*/ *0: User need to register a callback with `lv_log_register_print_cb()`*/
#define LV_LOG_PRINTF 0 #define LV_LOG_PRINTF 1
/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/
#define LV_LOG_TRACE_MEM 1 #define LV_LOG_TRACE_MEM 1

View File

@@ -14,7 +14,7 @@ name = OS-Railway Remote Control
default_envs = wt32-sc01_plus default_envs = wt32-sc01_plus
[env] [env]
platform = espressif32 @ ^6.3.2 platform = espressif32 @ ^6.5.0
framework = arduino framework = arduino
[env:wt32-sc01_plus] [env:wt32-sc01_plus]
@@ -35,3 +35,21 @@ lib_deps =
lovyan03/LovyanGFX @ ^1.1.8 lovyan03/LovyanGFX @ ^1.1.8
lvgl/lvgl @ ^8.3.9 lvgl/lvgl @ ^8.3.9
me-no-dev/AsyncTCP @ ^1.1.1 me-no-dev/AsyncTCP @ ^1.1.1
[env:waveshare-esp32s3-43]
board = wt32-sc01_plus
board_build.partitions = partitions.csv
build_flags =
-D CORE_DEBUG_LEVEL=4
-D SCREEN_WIDTH=800
-D SCREEN_HEIGHT=480
-D ESP32S3
-D BOARD_HAS_PSRAM
-D ARDUINO_USB_CDC_ON_BOOT
-D LV_CONF_INCLUDE_SIMPLE
-I include/
lib_ldf_mode = deep
lib_deps =
lovyan03/LovyanGFX @ ^1.1.8
lvgl/lvgl @ ^8.3.9
me-no-dev/AsyncTCP @ ^1.1.1

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@@ -27,6 +27,15 @@
LGFX tft; LGFX tft;
struct Timer
{
unsigned long time;
long duration = 5000;
bool active;
};
Timer screenTimer;
void lv_handler() void lv_handler()
{ {
static uint32_t previousUpdate = 0; static uint32_t previousUpdate = 0;
@@ -39,6 +48,22 @@ void lv_handler()
} }
} }
void check_display_off()
{
if (screenTimer.active && millis() - screenTimer.time > screenTimer.duration)
{
tft.setBrightness(0);
screenTimer.active = false;
}
}
void set_screen_timer(unsigned long time)
{
tft.setBrightness(255);
screenTimer.time = time;
screenTimer.active = true;
}
void flush_cb(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) void flush_cb(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{ {
uint32_t w = (area->x2 - area->x1 + 1); uint32_t w = (area->x2 - area->x1 + 1);
@@ -52,7 +77,7 @@ void flush_cb(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
lv_disp_flush_ready(disp); lv_disp_flush_ready(disp);
} }
void read_cb(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) void touch_cb(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{ {
uint16_t touchX, touchY; uint16_t touchX, touchY;
bool touched = tft.getTouch(&touchX, &touchY); bool touched = tft.getTouch(&touchX, &touchY);
@@ -61,6 +86,7 @@ void read_cb(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
data->state = LV_INDEV_STATE_PR; data->state = LV_INDEV_STATE_PR;
data->point.x = touchX; data->point.x = touchX;
data->point.y = touchY; data->point.y = touchY;
set_screen_timer(millis());
} }
else else
{ {
@@ -70,7 +96,7 @@ void read_cb(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
void print_cb(const char *buf) void print_cb(const char *buf)
{ {
log_d("%s", buf); ESP_LOGD("lv_log", "%s", buf);
} }
void lv_begin() void lv_begin()
@@ -80,7 +106,7 @@ void lv_begin()
tft.startWrite(); tft.startWrite();
tft.setRotation(1); tft.setRotation(1);
#if LV_USE_LOG #if LV_LOG_PRINTF
lv_log_register_print_cb(print_cb); lv_log_register_print_cb(print_cb);
#endif #endif
@@ -103,6 +129,6 @@ void lv_begin()
static lv_indev_drv_t indev_drv; static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = read_cb; indev_drv.read_cb = touch_cb;
lv_indev_drv_register(&indev_drv); lv_indev_drv_register(&indev_drv);
} }

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@@ -20,3 +20,6 @@
void lv_begin(); void lv_begin();
void lv_handler(); void lv_handler();
void check_display_off();
void set_screen_timer(unsigned long time);

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@@ -44,9 +44,13 @@ void setup()
lv_disp_set_theme(display, theme); lv_disp_set_theme(display, theme);
LaunchScreen::show(); LaunchScreen::show();
set_screen_timer(millis());
} }
void loop() void loop()
{ {
lv_handler(); lv_handler();
// check_display_off();
} }

View File

@@ -0,0 +1,19 @@
//----------------------------------------------------------------------------
// OS-Railway - Remote Control
// Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//----------------------------------------------------------------------------
#include "ble_service.h"

View File

@@ -0,0 +1,19 @@
//----------------------------------------------------------------------------
// OS-Railway - Remote Control
// Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//----------------------------------------------------------------------------
#pragma once

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@@ -17,3 +17,78 @@
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#include "esp_now_service.h" #include "esp_now_service.h"
#include <esp32-hal-log.h>
#include <WiFi.h>
namespace ESPNow
{
enum MessageType
{
PAIRING,
META,
FEATURES,
COMMAND,
};
MessageType messageType;
typedef struct struct_pairing
{
uint8_t msgType;
uint8_t id;
uint8_t macAddr[6];
uint8_t channel;
} struct_pairing;
typedef struct struct_meta
{
uint8_t msgType;
uint8_t id;
/// data?
} struct_meta;
typedef struct struct_features
{
uint8_t msgType;
uint8_t id;
/// data?
} struct_features;
typedef struct struct_command
{
uint8_t msgType;
uint8_t id;
/// data?
} struct_command;
void init()
{
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK)
{
Serial.println("Error initializing ESP-NOW");
ESP.restart();
}
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataRecv);
}
void onDataSent(const uint8_t *mac_addr, esp_now_send_status_t status)
{
char macStr[18];
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
ESP_LOGD("espnow", "Last Packet Sent to: %s", macStr);
ESP_LOGD("espnow", "Last Packet Send Status: %s", status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}
void onDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len)
{
char macStr[18];
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
ESP_LOGD("espnow", "Last Packet Recv from: %s", macStr);
ESP_LOGD("espnow", "Last Packet Recv Data: %s", *data);
}
}

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@@ -17,3 +17,14 @@
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#pragma once #pragma once
#include <Arduino.h>
#include <esp_now.h>
namespace ESPNow
{
void init();
void onDataSent(const uint8_t *mac_addr, esp_now_send_status_t status);
void onDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len);
}

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by

View File

@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// OS-Railway - Remote Control // OS-Railway - Remote Control
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev) // Copyright (C) 2023-2024 Peter Siegmund (https://mars3142.dev)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by