Compare commits
10 Commits
ef3e71dd40
...
PlatformIO
Author | SHA1 | Date | |
---|---|---|---|
959e2989ab
|
|||
7df248c624
|
|||
5ef43baaa0
|
|||
6aac53cc3b
|
|||
9ca5968e9f
|
|||
44c9147d68
|
|||
62c6eb270f
|
|||
99229c3650
|
|||
e946896363
|
|||
43c3b1de60
|
11
.github/workflows/esp32_build.yml
vendored
11
.github/workflows/esp32_build.yml
vendored
@@ -11,8 +11,8 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v1
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v3
|
||||
|
||||
- name: Install PlatformIO
|
||||
run: |
|
||||
@@ -22,3 +22,10 @@ jobs:
|
||||
|
||||
- name: Build bare metal
|
||||
run: platformio run
|
||||
|
||||
- name: Archive production artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dist-firmware ${{ matrix.os }}
|
||||
path: |
|
||||
.pio/build/**/*.bin
|
||||
|
@@ -78,7 +78,7 @@
|
||||
*====================*/
|
||||
|
||||
/*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*/
|
||||
#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/
|
||||
@@ -230,7 +230,7 @@
|
||||
*-----------*/
|
||||
|
||||
/*Enable the log module*/
|
||||
#define LV_USE_LOG 0
|
||||
#define LV_USE_LOG 1
|
||||
#if LV_USE_LOG
|
||||
|
||||
/*How important log should be added:
|
||||
@@ -244,7 +244,7 @@
|
||||
|
||||
/*1: Print the log with 'printf';
|
||||
*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*/
|
||||
#define LV_LOG_TRACE_MEM 1
|
||||
|
@@ -14,7 +14,7 @@ name = OS-Railway Remote Control
|
||||
default_envs = wt32-sc01_plus
|
||||
|
||||
[env]
|
||||
platform = espressif32 @ ^6.3.2
|
||||
platform = espressif32 @ ^6.5.0
|
||||
framework = arduino
|
||||
|
||||
[env:wt32-sc01_plus]
|
||||
@@ -35,3 +35,21 @@ lib_deps =
|
||||
lovyan03/LovyanGFX @ ^1.1.8
|
||||
lvgl/lvgl @ ^8.3.9
|
||||
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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
@@ -27,6 +27,15 @@
|
||||
|
||||
LGFX tft;
|
||||
|
||||
struct Timer
|
||||
{
|
||||
unsigned long time;
|
||||
long duration = 5000;
|
||||
bool active;
|
||||
};
|
||||
|
||||
Timer screenTimer;
|
||||
|
||||
void lv_handler()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
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->point.x = touchX;
|
||||
data->point.y = touchY;
|
||||
set_screen_timer(millis());
|
||||
}
|
||||
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)
|
||||
{
|
||||
log_d("%s", buf);
|
||||
ESP_LOGD("lv_log", "%s", buf);
|
||||
}
|
||||
|
||||
void lv_begin()
|
||||
@@ -80,7 +106,7 @@ void lv_begin()
|
||||
tft.startWrite();
|
||||
tft.setRotation(1);
|
||||
|
||||
#if LV_USE_LOG
|
||||
#if LV_LOG_PRINTF
|
||||
lv_log_register_print_cb(print_cb);
|
||||
#endif
|
||||
|
||||
@@ -103,6 +129,6 @@ void lv_begin()
|
||||
static lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
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);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
@@ -20,3 +20,6 @@
|
||||
|
||||
void lv_begin();
|
||||
void lv_handler();
|
||||
|
||||
void check_display_off();
|
||||
void set_screen_timer(unsigned long time);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// 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);
|
||||
|
||||
LaunchScreen::show();
|
||||
|
||||
set_screen_timer(millis());
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
lv_handler();
|
||||
|
||||
// check_display_off();
|
||||
}
|
||||
|
19
src/services/ble_service.cpp
Normal file
19
src/services/ble_service.cpp
Normal 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"
|
19
src/services/ble_service.h
Normal file
19
src/services/ble_service.h
Normal 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
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
@@ -17,3 +17,78 @@
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
@@ -17,3 +17,14 @@
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#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);
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
|
Reference in New Issue
Block a user