From 456edbd46fe8603992155a42b0f353930319874a Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 9 May 2025 20:09:18 +0200 Subject: [PATCH] Initial commit --- .gitignore | 8 +++++ CMakeLists.txt | 3 ++ partitions.csv | 6 ++++ platformio.ini | 53 +++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 3 ++ src/main.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++ src/main.h | 15 ++++++++++ 7 files changed, 161 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 partitions.csv create mode 100644 platformio.ini create mode 100644 src/CMakeLists.txt create mode 100644 src/main.cpp create mode 100644 src/main.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6801c95 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.pio +.piolibdeps +.vscode/.browse.c_cpp.db* +.vscode/*.json +build/ +setup/firmware/*/*.bin +!sdkconfig.defaults +sdkconfig.* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..17afb16 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16.0) +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(knobby) diff --git a/partitions.csv b/partitions.csv new file mode 100644 index 0000000..0efb94d --- /dev/null +++ b/partitions.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x1D0000, +app1, app, ota_1, 0x1E0000,0x1D0000, +spiffs, data, spiffs, 0x3B0000,0x50000, diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..0d07b08 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,53 @@ +[platformio] +default_envs = knobby + +[env] +board = ttgo-t1 +framework = arduino, espidf +platform = espressif32 @ 6.7.0 +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.17 +board_build.flash_mode = dio +board_build.partitions = partitions.csv +monitor_filters = default, esp32_exception_decoder +monitor_speed = 115200 +upload_protocol = esptool +upload_speed = 921600 + +[common] +build_flags = + -Os + -DARDUINO_ARCH_ESP32=y + -DARDUINO=100 + -DESP32=1 + -DSMOOTH_FONT=1 + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO + !echo "-DGIT_VERSION='\""$(git describe --match="" --dirty --always)"\"'" + -DPLATFORMIO_ENV='"$PIOENV"' + -Wno-error=unknown-pragmas +lib_deps = + TFT_eSPI=https://github.com/quadule/TFT_eSPI.git#066c4adcd95679da94e87221c30ab973048d71e4 + ricmoo/QRCode@^0.0.1 + dlloydev/Toggle@^3.1.8 + +[env:knobby] +build_flags = + ${common.build_flags} + -DARDUINO_WIFI_DISABLED + -DUSER_SETUP_LOADED=1 + -DSPI_FREQUENCY=40000000 + -DSPI_READ_FREQUENCY=6000000 + -DST7789_DRIVER=1 + -DTFT_WIDTH=135 + -DTFT_HEIGHT=240 + -DCGRAM_OFFSET=1 + -DTFT_MISO=-1 + -DTFT_MOSI=19 + -DTFT_SCLK=18 + -DTFT_CS=5 + -DTFT_DC=16 + -DTFT_RST=23 + -DTFT_BL=4 +lib_deps = + ${common.lib_deps} + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..28e2b97 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,3 @@ +FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) + +idf_component_register(SRCS ${app_sources}) diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..4928222 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,73 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "main.h" + +size_t qr_w = 0; +uint16_t qr_img[128*128]; + +int qr_version = 4; +int qr_scale = 3; +Toggle tog_a, tog_b; + +void setup() { + Serial.begin(115200); + + ledcSetup(backlightChannel, 12000, 8); + ledcAttachPin(TFT_BL, backlightChannel); + ledcWrite(backlightChannel, 255); + tft.init(); + tft.fillScreen(TFT_BLACK); + + tog_a(0); + tog_b(35); + + SPIFFS.begin(true); + + tft.fillScreen(TFT_RED); + + QRCode qrcode; + uint8_t *qr_buf = new uint8_t[qrcode_getBufferSize(qr_version)]; + qrcode_initText(&qrcode, qr_buf, qr_version, ECC_LOW, "otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"); + qr_w = qrcode.size * qr_scale; + + for (int y=0; y + +#include +#include +#include + +TFT_eSPI tft = TFT_eSPI(TFT_WIDTH, TFT_HEIGHT); + +const uint8_t backlightChannel = 4; + +// Events +void setup(); +void loop(); +