Initial commit
This commit is contained in:
commit
456edbd46f
7 changed files with 161 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.pio
|
||||
.piolibdeps
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/*.json
|
||||
build/
|
||||
setup/firmware/*/*.bin
|
||||
!sdkconfig.defaults
|
||||
sdkconfig.*
|
||||
3
CMakeLists.txt
Normal file
3
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(knobby)
|
||||
6
partitions.csv
Normal file
6
partitions.csv
Normal file
|
|
@ -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,
|
||||
|
53
platformio.ini
Normal file
53
platformio.ini
Normal file
|
|
@ -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}
|
||||
|
||||
3
src/CMakeLists.txt
Normal file
3
src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
|
||||
|
||||
idf_component_register(SRCS ${app_sources})
|
||||
73
src/main.cpp
Normal file
73
src/main.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#include <Arduino.h>
|
||||
#include <base64.h>
|
||||
#include <qrcode.h>
|
||||
#include <esp_adc_cal.h>
|
||||
#include <esp_pm.h>
|
||||
#include <Toggle.h>
|
||||
#include <esp_system.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include <mbedtls/md.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <StreamString.h>
|
||||
#include <time.h>
|
||||
|
||||
#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<qrcode.size; y++) {
|
||||
for (int sy=0; sy<qr_scale; sy++) {
|
||||
for(int x=0; x<qrcode.size; x++) {
|
||||
for (int sx=0; sx<qr_scale; sx++) {
|
||||
qr_img[x*qr_scale + sx +qr_w*(y*qr_scale + sy)] = qrcode_getModule(&qrcode, x, y) ? TFT_BLACK : TFT_WHITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete qr_buf;
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.startWrite();
|
||||
tft.pushImage((TFT_WIDTH - qr_w)/2, (TFT_HEIGHT - qr_w)/2, qr_w, qr_w, (uint16_t*)qr_img);
|
||||
tft.endWrite();
|
||||
}
|
||||
|
||||
int flag = 0;
|
||||
void loop() {
|
||||
flag = !flag;
|
||||
/*
|
||||
tft.fillScreen(flag ? TFT_RED : TFT_BLUE);
|
||||
tft.startWrite();
|
||||
tft.pushImage(0, 0, qr_w, qr_w, (uint16_t*)qr_img);
|
||||
tft.endWrite();
|
||||
*/
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
15
src/main.h
Normal file
15
src/main.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include "sdkconfig.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <list>
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI(TFT_WIDTH, TFT_HEIGHT);
|
||||
|
||||
const uint8_t backlightChannel = 4;
|
||||
|
||||
// Events
|
||||
void setup();
|
||||
void loop();
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue