From 6268c5f6865fa7b316b8e7aa07da27ea20246862 Mon Sep 17 00:00:00 2001 From: Cody Ardoin Date: Sat, 21 Dec 2024 20:30:57 -0600 Subject: [PATCH 01/30] new pr: squashing commits of dev-cleanup --- .../platformio.ini => boards/CYD-2432S028.ini | 42 +-- boards/CYD-2432S028.json | 40 ++ {ports => boards}/CYD-2432S028/interface.cpp | 34 +- .../platformio.ini => boards/ESP-General.ini | 15 +- boards/ESP-General.json | 53 +++ {ports => boards}/ESP-General/interface.cpp | 0 boards/_New-Device-Model.ini | 25 ++ boards/_New-Device-Model.json | 47 +++ .../_New-Device-Model/interface.cpp | 0 .../lilygo-t-deck.ini | 19 +- boards/lilygo-t-deck.json | 55 +++ {ports => boards}/lilygo-t-deck/interface.cpp | 27 +- boards/lilygo-t-embed-cc1101.ini | 25 ++ boards/lilygo-t-embed-cc1101.json | 63 ++++ .../lilygo-t-embed-cc1101/interface.cpp | 31 +- boards/lilygo-t-embed.ini | 24 ++ boards/lilygo-t-embed.json | 64 ++++ .../m5stack-cardputer.ini | 13 +- boards/m5stack-cardputer.json | 48 +++ .../m5stack-cardputer/interface.cpp | 23 +- .../platformio.ini => boards/m5stack-core.ini | 17 +- boards/m5stack-core.json | 34 ++ {ports => boards}/m5stack-core/interface.cpp | 14 +- .../m5stack-core2.ini | 14 +- boards/m5stack-core2.json | 41 +++ {ports => boards}/m5stack-core2/interface.cpp | 18 +- boards/m5stack-cores3.ini | 28 ++ boards/m5stack-cores3.json | 52 +++ .../m5stack-cores3/interface.cpp | 34 +- .../m5stack-cplus1_1.ini | 11 +- boards/m5stack-cplus1_1.json | 36 ++ .../m5stack-cplus1_1/interface.cpp | 16 +- .../m5stack-cplus2.ini | 23 +- boards/m5stack-cplus2.json | 39 ++ .../m5stack-cplus2/interface.cpp | 27 +- boards/pinouts/CYD-2432S028.h | 48 +++ boards/pinouts/ESP-General.h | 69 ++++ boards/pinouts/_New-Device-Model.h | 133 +++++++ boards/pinouts/lilygo-t-deck.h | 70 ++++ boards/pinouts/lilygo-t-embed-cc1101.h | 147 ++++++++ boards/pinouts/lilygo-t-embed.h | 132 +++++++ boards/pinouts/m5stack-cardputer.h | 194 ++++++++++ boards/pinouts/m5stack-core.h | 47 +++ boards/pinouts/m5stack-core2.h | 52 +++ boards/pinouts/m5stack-cores3.h | 124 +++++++ boards/pinouts/m5stack-cplus1_1.h | 36 ++ boards/pinouts/m5stack-cplus2.h | 33 ++ boards/pinouts/pins_arduino.h | 23 ++ boards/pinouts/variant.cpp | 2 + build.bat | 13 - build.sh | 10 - clean.sh | 2 - deauth_setup.bat | 31 -- deauth_setup.sh | 41 --- {src/core => include}/globals.h | 17 +- .../_New-Device-Model => include}/interface.h | 0 include/precompiler_flags.h | 122 +++++++ lib/M5GFX/src/M5GFX.cpp | 2 +- lib/M5GFX/src/lgfx/v1/LGFXBase.hpp | 4 +- lib/TFT_eSPI/TFT_Drivers/ILI9341_Init.h | 2 +- lib/utility/Keyboard.cpp | 2 +- lib/utility/Keyboard.h | 3 +- patch.py | 27 ++ ports/CYD-2432S028/interface.h | 136 ------- ports/ESP-General/interface.h | 130 ------- ports/_New-Device-Model/platformio.ini | 153 -------- ports/lilygo-t-deck/interface.h | 130 ------- ports/lilygo-t-embed-cc1101/interface.h | 133 ------- ports/lilygo-t-embed-cc1101/platformio.ini | 345 ------------------ ports/m5stack-cardputer/interface.h | 130 ------- ports/m5stack-core/interface.h | 130 ------- ports/m5stack-core2/interface.h | 130 ------- ports/m5stack-cores3/interface.h | 130 ------- ports/m5stack-cores3/platformio.ini | 136 ------- ports/m5stack-cplus1_1/interface.h | 130 ------- ports/m5stack-cplus2/interface.h | 130 ------- src/core/VectorDisplay.h | 4 +- src/core/config.cpp | 2 +- src/core/config.h | 4 +- src/core/connect.h | 2 +- src/core/display.h | 11 +- src/core/globals.cpp | 31 -- src/core/i2c_finder.h | 2 +- src/core/main_menu.cpp | 4 +- src/core/menu_items/BleMenu.cpp | 3 +- src/core/menu_items/ConnectMenu.cpp | 1 + src/core/menu_items/FMMenu.cpp | 1 + src/core/menu_items/FileMenu.cpp | 1 + src/core/menu_items/GpsMenu.cpp | 1 + src/core/menu_items/IRMenu.cpp | 1 + src/core/menu_items/MenuItemInterface.h | 26 +- src/core/menu_items/NRF24.cpp | 1 + src/core/menu_items/OthersMenu.cpp | 3 +- src/core/menu_items/RFIDMenu.cpp | 1 + src/core/menu_items/RFMenu.cpp | 1 + src/core/menu_items/ScriptsMenu.cpp | 2 +- src/core/menu_items/WifiMenu.cpp | 1 + src/core/mykeyboard.cpp | 16 +- src/core/mykeyboard.h | 2 +- src/core/passwords.cpp | 2 +- src/core/powerSave.cpp | 27 +- src/core/powerSave.h | 7 +- src/core/serialcmds.cpp | 5 +- src/core/serialcmds.h | 3 + src/core/settings.cpp | 27 +- src/core/settings.h | 8 +- src/core/wg.cpp | 2 +- src/core/wifi_common.cpp | 4 +- src/main.cpp | 67 ++-- src/modules/NRF24/nrf_common.cpp | 4 +- src/modules/NRF24/nrf_common.h | 2 +- src/modules/NRF24/nrf_jammer.cpp | 2 +- src/modules/NRF24/nrf_spectrum.cpp | 12 +- src/modules/bjs_interpreter/interpreter.cpp | 14 +- src/modules/ble/bad_ble.cpp | 10 +- src/modules/ble/ble_common.cpp | 11 +- src/modules/ble/ble_common.h | 9 +- src/modules/ble/ble_spam.cpp | 2 +- src/modules/fm/fm.cpp | 13 +- src/modules/fm/fm.h | 12 +- src/modules/gps/gps_tracker.h | 6 +- src/modules/gps/wardriving.h | 6 +- src/modules/ir/TV-B-Gone.cpp | 2 +- src/modules/ir/TV-B-Gone.h | 2 +- src/modules/ir/custom_ir.h | 2 +- src/modules/ir/ir_read.cpp | 2 +- src/modules/ir/ir_read.h | 2 +- src/modules/others/bad_usb.cpp | 14 +- src/modules/others/led.cpp | 2 +- src/modules/others/mic.h | 2 +- src/modules/others/openhaystack.cpp | 2 +- src/modules/others/qrcode_menu.cpp | 2 +- src/modules/others/timer.cpp | 20 +- src/modules/others/tururururu.cpp | 22 +- src/modules/others/tururururu.h | 2 +- src/modules/others/webInterface.cpp | 12 +- src/modules/pwnagotchi/spam.cpp | 4 +- src/modules/pwnagotchi/ui.cpp | 4 +- src/modules/pwnagotchi/ui.h | 1 - src/modules/reverseShell/reverseShell.cpp | 2 +- src/modules/rf/rf.cpp | 40 +- src/modules/rfid/RFIDInterface.h | 2 +- src/modules/rfid/pn532ble.cpp | 14 +- src/modules/rfid/pn532ble.h | 1 - src/modules/rfid/rfid125.cpp | 2 +- src/modules/rfid/rfid125.h | 6 +- src/modules/wifi/ap_info.cpp | 58 +-- src/modules/wifi/ap_info.h | 7 +- src/modules/wifi/clients.cpp | 16 +- src/modules/wifi/clients.h | 7 +- src/modules/wifi/dpwo.cpp | 2 +- src/modules/wifi/evil_portal.h | 10 +- src/modules/wifi/scan_hosts.cpp | 11 +- src/modules/wifi/scan_hosts.h | 7 +- src/modules/wifi/sniffer.cpp | 10 +- src/modules/wifi/wifi_atks.cpp | 15 +- src/modules/wifi/wifi_atks.h | 7 +- src/modules/wifi/wigle.h | 8 +- 158 files changed, 2455 insertions(+), 2624 deletions(-) rename ports/CYD-2432S028/platformio.ini => boards/CYD-2432S028.ini (94%) create mode 100644 boards/CYD-2432S028.json rename {ports => boards}/CYD-2432S028/interface.cpp (95%) rename ports/ESP-General/platformio.ini => boards/ESP-General.ini (89%) create mode 100644 boards/ESP-General.json rename {ports => boards}/ESP-General/interface.cpp (100%) create mode 100644 boards/_New-Device-Model.ini create mode 100644 boards/_New-Device-Model.json rename {ports => boards}/_New-Device-Model/interface.cpp (100%) rename ports/lilygo-t-deck/platformio.ini => boards/lilygo-t-deck.ini (86%) create mode 100644 boards/lilygo-t-deck.json rename {ports => boards}/lilygo-t-deck/interface.cpp (96%) create mode 100644 boards/lilygo-t-embed-cc1101.ini create mode 100644 boards/lilygo-t-embed-cc1101.json rename {ports => boards}/lilygo-t-embed-cc1101/interface.cpp (94%) create mode 100644 boards/lilygo-t-embed.ini create mode 100644 boards/lilygo-t-embed.json rename ports/m5stack-cardputer/platformio.ini => boards/m5stack-cardputer.ini (90%) create mode 100644 boards/m5stack-cardputer.json rename {ports => boards}/m5stack-cardputer/interface.cpp (96%) rename ports/m5stack-core/platformio.ini => boards/m5stack-core.ini (84%) create mode 100644 boards/m5stack-core.json rename {ports => boards}/m5stack-core/interface.cpp (95%) rename ports/m5stack-core2/platformio.ini => boards/m5stack-core2.ini (85%) create mode 100644 boards/m5stack-core2.json rename {ports => boards}/m5stack-core2/interface.cpp (95%) create mode 100644 boards/m5stack-cores3.ini create mode 100644 boards/m5stack-cores3.json rename {ports => boards}/m5stack-cores3/interface.cpp (94%) rename ports/m5stack-cplus1_1/platformio.ini => boards/m5stack-cplus1_1.ini (92%) create mode 100644 boards/m5stack-cplus1_1.json rename {ports => boards}/m5stack-cplus1_1/interface.cpp (94%) rename ports/m5stack-cplus2/platformio.ini => boards/m5stack-cplus2.ini (81%) create mode 100644 boards/m5stack-cplus2.json rename {ports => boards}/m5stack-cplus2/interface.cpp (94%) create mode 100644 boards/pinouts/CYD-2432S028.h create mode 100644 boards/pinouts/ESP-General.h create mode 100644 boards/pinouts/_New-Device-Model.h create mode 100644 boards/pinouts/lilygo-t-deck.h create mode 100644 boards/pinouts/lilygo-t-embed-cc1101.h create mode 100644 boards/pinouts/lilygo-t-embed.h create mode 100644 boards/pinouts/m5stack-cardputer.h create mode 100644 boards/pinouts/m5stack-core.h create mode 100644 boards/pinouts/m5stack-core2.h create mode 100644 boards/pinouts/m5stack-cores3.h create mode 100644 boards/pinouts/m5stack-cplus1_1.h create mode 100644 boards/pinouts/m5stack-cplus2.h create mode 100644 boards/pinouts/pins_arduino.h create mode 100644 boards/pinouts/variant.cpp delete mode 100644 build.bat delete mode 100755 build.sh delete mode 100755 clean.sh delete mode 100644 deauth_setup.bat delete mode 100755 deauth_setup.sh rename {src/core => include}/globals.h (90%) rename {ports/_New-Device-Model => include}/interface.h (100%) create mode 100644 include/precompiler_flags.h create mode 100644 patch.py delete mode 100644 ports/CYD-2432S028/interface.h delete mode 100644 ports/ESP-General/interface.h delete mode 100644 ports/_New-Device-Model/platformio.ini delete mode 100644 ports/lilygo-t-deck/interface.h delete mode 100644 ports/lilygo-t-embed-cc1101/interface.h delete mode 100644 ports/lilygo-t-embed-cc1101/platformio.ini delete mode 100644 ports/m5stack-cardputer/interface.h delete mode 100644 ports/m5stack-core/interface.h delete mode 100644 ports/m5stack-core2/interface.h delete mode 100644 ports/m5stack-cores3/interface.h delete mode 100644 ports/m5stack-cores3/platformio.ini delete mode 100644 ports/m5stack-cplus1_1/interface.h delete mode 100644 ports/m5stack-cplus2/interface.h delete mode 100644 src/core/globals.cpp diff --git a/ports/CYD-2432S028/platformio.ini b/boards/CYD-2432S028.ini similarity index 94% rename from ports/CYD-2432S028/platformio.ini rename to boards/CYD-2432S028.ini index 7339683d..92b3c6ec 100644 --- a/ports/CYD-2432S028/platformio.ini +++ b/boards/CYD-2432S028.ini @@ -10,16 +10,13 @@ ##################################### CYD MODELS #################################################### [env:CYD-2432S028] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = esp32dev +board = CYD-2432S028 monitor_speed = 115200 -monitor_filters = esp32_exception_decoder -framework = arduino board_build.partitions = custom_4Mb_full.csv -build_src_filter =${env.build_src_filter} +<../ports/CYD-2432S028> +build_src_filter =${env.build_src_filter} +<../boards/CYD-2432S028> build_flags = ${env.build_flags} - -Iports/CYD-2432S028 + -Iboards/CYD-2432S028 -Os -DCORE_DEBUG_LEVEL=5 ;-DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work @@ -112,8 +109,6 @@ build_flags = ;Screen Setup -DHAS_SCREEN=1 -DROTATION=1 - -DWIDTH=320 - -DHEIGHT=220 ;240-20 lower margin -DBACKLIGHT=21 -DMINBRIGHT=160 @@ -121,6 +116,8 @@ build_flags = -DUSER_SETUP_LOADED=1 -DILI9341_2_DRIVER=1 -DUSE_HSPI_PORT=1 + -DTFT_HEIGHT=320 + -DTFT_WIDTH=220 ;240-20 lower margin -DTFT_MISO=12 -DTFT_MOSI=13 -DTFT_SCLK=14 @@ -174,6 +171,15 @@ build_flags = ${env:CYD-2432S028.build_flags} -DTFT_INVERSION_ON +[env:LAUNCHER_CYD-2USB] +extends=env:CYD-2432S028 +build_flags = + ${env:CYD-2432S028.build_flags} + -DTFT_INVERSION_ON + -DLITE_VERSION=1 + + + [env:CYD-2432W328C] extends = env:CYD-2432S028 build_flags = @@ -185,6 +191,13 @@ build_flags = -DSPI_TOUCH_FREQUENCY=2500000 -DHAS_CAPACITIVE_TOUCH=1 +[env:LAUNCHER_CYD-2432S028] +extends=env:CYD-2432S028 +build_flags = + ${env:CYD-2432S028.build_flags} + -DLITE_VERSION=1 + + [env:CYD-2432W328C_2] # commom to CYD-2432S024 Capacitive board extends = env:CYD-2432S028 build_flags = @@ -196,19 +209,6 @@ build_flags = -DSPI_TOUCH_FREQUENCY=2500000 -DHAS_CAPACITIVE_TOUCH=1 -[env:LAUNCHER_CYD-2432S028] -extends=env:CYD-2432S028 -build_flags = - ${env:CYD-2432S028.build_flags} - -DLITE_VERSION=1 - -[env:LAUNCHER_CYD-2USB] -extends=env:CYD-2432S028 -build_flags = - ${env:CYD-2432S028.build_flags} - -DTFT_INVERSION_ON - -DLITE_VERSION=1 - [env:LAUNCHER_CYD-2432W328C] extends=env:CYD-2432S028 build_flags = diff --git a/boards/CYD-2432S028.json b/boards/CYD-2432S028.json new file mode 100644 index 00000000..5d213cc6 --- /dev/null +++ b/boards/CYD-2432S028.json @@ -0,0 +1,40 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32_DEV", + "-DCYD_2432S028" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp-wroom-32.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Espressif ESP32 Dev Module", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://en.wikipedia.org/wiki/ESP32", + "vendor": "Espressif" +} diff --git a/ports/CYD-2432S028/interface.cpp b/boards/CYD-2432S028/interface.cpp similarity index 95% rename from ports/CYD-2432S028/interface.cpp rename to boards/CYD-2432S028/interface.cpp index e3bb6b81..62ecd7af 100644 --- a/ports/CYD-2432S028/interface.cpp +++ b/boards/CYD-2432S028/interface.cpp @@ -116,19 +116,19 @@ bool menuPress(int bot) { //0 - prev //1 - Sel //2 - next - int terco=WIDTH/3; + int terco=tftWidth/3; if (touch.touched()) { //touch.tirqTouched() && auto t = touch.getPointScaled(); t = touch.getPointScaled(); //log_i("Touchscreen Pressed at x=%d, y=%d, z=%d", t.x,t.y,t.z); if(bruceConfig.rotation==3) { - t.y = (HEIGHT+20)-t.y; - t.x = WIDTH-t.x; + t.y = (tftHeight+20)-t.y; + t.x = tftWidth-t.x; } - if(t.y>(HEIGHT) && ((t.x>terco*bot && t.x(tftHeight) && ((t.x>terco*bot && t.x19) { @@ -417,7 +417,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -469,11 +469,11 @@ String keyboard(String mytext, int maxSize, String msg) { auto t = touch.getPointScaled(); if(bruceConfig.rotation==3) { - t.y = (HEIGHT+20)-t.y; - t.x = WIDTH-t.x; + t.y = (tftHeight+20)-t.y; + t.x = tftWidth-t.x; } if (box_list[48].contain(t.x, t.y)) { break; } // Ok - if (box_list[49].contain(t.x, t.y)) { caps=!caps; tft.fillRect(0,54,WIDTH,HEIGHT-54,bruceConfig.bgColor); goto THIS_END; } // CAP + if (box_list[49].contain(t.x, t.y)) { caps=!caps; tft.fillRect(0,54,tftWidth,tftHeight-54,bruceConfig.bgColor); goto THIS_END; } // CAP if (box_list[50].contain(t.x, t.y)) goto DEL; // DEL if (box_list[51].contain(t.x, t.y)) { mytext += box_list[51].key; goto ADD; } // SPACE for(k=0;k<48;k++){ @@ -544,7 +544,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; diff --git a/ports/ESP-General/platformio.ini b/boards/ESP-General.ini similarity index 89% rename from ports/ESP-General/platformio.ini rename to boards/ESP-General.ini index 590dbb5f..1948ff3f 100644 --- a/ports/ESP-General/platformio.ini +++ b/boards/ESP-General.ini @@ -24,19 +24,12 @@ extends = env:esp32-s3-devkitc-1 [env:esp32-s3-devkitc-1] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = esp32-s3-devkitc-1 -framework = arduino -build_src_filter =${env.build_src_filter} +<../ports/ESP-General> +board = ESP-General +build_src_filter =${env.build_src_filter} +<../boards/ESP-General> build_flags = ${env.build_flags} - -Iports/ESP-General - -DESP32S3DEVKITC1 + -Iboards/ESP-General -DUSB_as_HID=1 - ; needed for serial - -DARDUINO_USB_CDC_ON_BOOT=1 - -DBOARD_HAS_PSRAM - ; grove pins ; defaults from https://github.com/espressif/arduino-esp32/blob/master/variants/esp32s3/pins_arduino.h -DGROVE_SDA=8 ; default RF TX pin @@ -64,8 +57,6 @@ build_flags = ; tft vars -DROTATION=1 -DBACKLIGHT=-1 ; tft backlight pin - -DWIDTH=240 - -DHEIGHT=135 -DMINBRIGHT=160 ; unused? -DSMOOTH_FONT=1 -DTFT_DISPON=0x29 diff --git a/boards/ESP-General.json b/boards/ESP-General.json new file mode 100644 index 00000000..e412fde5 --- /dev/null +++ b/boards/ESP-General.json @@ -0,0 +1,53 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "partitions": "default_8MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DESP32S3DEVKITC1", + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" + } \ No newline at end of file diff --git a/ports/ESP-General/interface.cpp b/boards/ESP-General/interface.cpp similarity index 100% rename from ports/ESP-General/interface.cpp rename to boards/ESP-General/interface.cpp diff --git a/boards/_New-Device-Model.ini b/boards/_New-Device-Model.ini new file mode 100644 index 00000000..529d3966 --- /dev/null +++ b/boards/_New-Device-Model.ini @@ -0,0 +1,25 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:NewDeviceModel] +board = _New-Device-Model +board_build.partitions = custom_8Mb.csv +build_flags = + ${env.build_flags} + -Iboards/_New-Device-Model + -Os + -DCORE_DEBUG_LEVEL=5 + ;-DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work + + + +lib_deps = + ${env.lib_deps} + xylopyrographer/LiteLED@^1.2.0 diff --git a/boards/_New-Device-Model.json b/boards/_New-Device-Model.json new file mode 100644 index 00000000..343018d2 --- /dev/null +++ b/boards/_New-Device-Model.json @@ -0,0 +1,47 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_8MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DNEW_DEVICE", // Device Flag + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "m5stack_stamp_s3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stack StampS3", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.m5stack.com/en/core/StampS3", + "vendor": "M5Stack" + } \ No newline at end of file diff --git a/ports/_New-Device-Model/interface.cpp b/boards/_New-Device-Model/interface.cpp similarity index 100% rename from ports/_New-Device-Model/interface.cpp rename to boards/_New-Device-Model/interface.cpp diff --git a/ports/lilygo-t-deck/platformio.ini b/boards/lilygo-t-deck.ini similarity index 86% rename from ports/lilygo-t-deck/platformio.ini rename to boards/lilygo-t-deck.ini index 96905f0c..0fea45b9 100644 --- a/ports/lilygo-t-deck/platformio.ini +++ b/boards/lilygo-t-deck.ini @@ -9,27 +9,16 @@ ; https://docs.platformio.org/page/projectconf.html [env:lilygo-t-deck-pro] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = lilygo-t-display-s3 -framework = arduino +board = lilygo-t-deck board_build.partitions = custom_16Mb.csv -build_src_filter =${env.build_src_filter} +<../ports/lilygo-t-deck> +build_src_filter =${env.build_src_filter} +<../boards/lilygo-t-deck> build_flags = ${env.build_flags} - -Iports/lilygo-t-deck - -DBOARD_HAS_PSRAM + -Iboards/lilygo-t-deck -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw -Os -DCORE_DEBUG_LEVEL=5 - -DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work - - -DT_DECK=1 ;key for new device, - ;mykeyboard.cpp: need map buttons an/or touchscreen and battery status value, - ;settings.cpp: need map brighness control - ;main.cpp: need set startup - ;serialcmds.cpp: need set power off command - ;Features Enabled # Config to use IRQ and RST pins of PN532, if needed @@ -118,8 +107,6 @@ build_flags = ;Screen Setup -DHAS_SCREEN=1 -DROTATION=1 - -DWIDTH=320 - -DHEIGHT=240 -DBACKLIGHT=42 -DMINBRIGHT=1 diff --git a/boards/lilygo-t-deck.json b/boards/lilygo-t-deck.json new file mode 100644 index 00000000..609f8eb0 --- /dev/null +++ b/boards/lilygo-t-deck.json @@ -0,0 +1,55 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DT_DECK", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "lora" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "LilyGo T-Deck (16M Flash 8M OPI PSRAM)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://www.lilygo.cc", + "vendor": "LilyGo" +} diff --git a/ports/lilygo-t-deck/interface.cpp b/boards/lilygo-t-deck/interface.cpp similarity index 96% rename from ports/lilygo-t-deck/interface.cpp rename to boards/lilygo-t-deck/interface.cpp index 44953292..b81b761c 100644 --- a/ports/lilygo-t-deck/interface.cpp +++ b/boards/lilygo-t-deck/interface.cpp @@ -130,13 +130,12 @@ int getBattery() { ** location: settings.cpp ** set brightness value **********************************************************************/ -void _setBrightness(uint8_t brightval) { - if(brightval>100) brightval=100; - if(brightval == 0){ - analogWrite(BACKLIGHT, brightval); +void _setBrightness(uint8_t brightval) { + if(brightval == 0){ + digitalWrite(TFT_BL, brightval); } else { - int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 )); - analogWrite(BACKLIGHT, bl); + int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 )); + digitalWrite(TFT_BL, bl); } } @@ -302,8 +301,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; #if defined(HAS_TOUCH) @@ -353,7 +352,7 @@ String keyboard(String mytext, int maxSize, String msg) { box_list[k].color = ~bruceConfig.bgColor; box_list[k].x=159; box_list[k].y=0; - box_list[k].w=WIDTH-164; + box_list[k].w=tftWidth-164; box_list[k].h=22; k=0; @@ -376,12 +375,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -411,7 +410,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -427,7 +426,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -525,7 +524,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; diff --git a/boards/lilygo-t-embed-cc1101.ini b/boards/lilygo-t-embed-cc1101.ini new file mode 100644 index 00000000..af6620dd --- /dev/null +++ b/boards/lilygo-t-embed-cc1101.ini @@ -0,0 +1,25 @@ + +[env:lilygo-t-embed-cc1101] +board = lilygo-t-embed-cc1101 +board_build.arduino.memory_type = qio_opi +board_build.partitions = custom_16Mb.csv +build_src_filter =${env.build_src_filter} +<../boards/lilygo-t-embed-cc1101> +build_flags = + ${env.build_flags} + -Iboards/lilygo-t-embed-cc1101 + -O2 + -DMIC_SPM1423 + -mfix-esp32-psram-cache-issue + -mfix-esp32-psram-cache-strategy=memw + -DCORE_DEBUG_LEVEL=5 + -DREDRAW_DELAY=1 # Used to improve navigation on menus for this device + + -DRF_TX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}' + -DRF_RX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}' + -DIR_TX_PINS='{{"Default", 2}, {"Pin 43", 43}, {"Pin 44", 44}}' + -DIR_RX_PINS='{{"Default", 1}, {"Pin 43", 43}, {"Pin 44", 44}}' + +lib_deps = + ${env.lib_deps} + lewisxhe/XPowersLib @0.2.6 + mathertel/RotaryEncoder @1.5.3 diff --git a/boards/lilygo-t-embed-cc1101.json b/boards/lilygo-t-embed-cc1101.json new file mode 100644 index 00000000..b11a4f7c --- /dev/null +++ b/boards/lilygo-t-embed-cc1101.json @@ -0,0 +1,63 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DT_EMBED_1101", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_RUNNING_CORE=0", + "-DARDUINO_EVENT_RUNNING_CORE=0", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x239A", + "0x811B" + ], + [ + "0x239A", + "0x011B" + ], + [ + "0x239A", + "0x811C" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi", + "lora" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "LilyGo T-Embed-PN532 (16M Flash 8M QSPI PSRAM)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.lilygo.cc", + "vendor": "LilyGo" +} diff --git a/ports/lilygo-t-embed-cc1101/interface.cpp b/boards/lilygo-t-embed-cc1101/interface.cpp similarity index 94% rename from ports/lilygo-t-embed-cc1101/interface.cpp rename to boards/lilygo-t-embed-cc1101/interface.cpp index dd87e145..76fe43d4 100644 --- a/ports/lilygo-t-embed-cc1101/interface.cpp +++ b/boards/lilygo-t-embed-cc1101/interface.cpp @@ -37,8 +37,8 @@ void _setup_gpio() { #ifdef T_EMBED_1101 // T-Embed CC1101 has a antenna circuit optimized to each frequency band, controlled by SW0 and SW1 //Set antenna frequency settings - pinMode(BOARD_LORA_SW1, OUTPUT); - pinMode(BOARD_LORA_SW0, OUTPUT); + pinMode(CC1101_SW1_PIN, OUTPUT); + pinMode(CC1101_SW0_PIN, OUTPUT); // Chip Select CC1101 to HIGH State pinMode(CC1101_SS_PIN, OUTPUT); @@ -120,12 +120,11 @@ int getBattery() { ** set brightness value **********************************************************************/ void _setBrightness(uint8_t brightval) { - if(brightval>100) brightval=100; - if(brightval == 0){ - analogWrite(BACKLIGHT, brightval); + if(brightval == 0){ + digitalWrite(TFT_BL, brightval); } else { - int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 )); - analogWrite(BACKLIGHT, bl); + int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 )); + digitalWrite(TFT_BL, bl); } } @@ -307,8 +306,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; int i=0; @@ -326,12 +325,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -361,7 +360,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -377,7 +376,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -499,7 +498,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; @@ -527,7 +526,7 @@ void checkReboot() { tft.setTextSize(1); tft.setTextColor(TFT_RED, TFT_BLACK); countDown = (millis() - time_count) / 1000 + 1; - if(countDown<4) tft.drawCentreString("PWR OFF IN "+String(countDown)+"/3",WIDTH/2,12,1); + if(countDown<4) tft.drawCentreString("PWR OFF IN "+String(countDown)+"/3",tftWidth/2,12,1); else { tft.fillScreen(TFT_BLACK); while(digitalRead(BK_BTN)==BTN_ACT); @@ -540,7 +539,7 @@ void checkReboot() { // Clear text after releasing the button delay(30); - tft.fillRect(60, 12, WIDTH - 60, tft.fontHeight(1), TFT_BLACK); + tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), TFT_BLACK); } #endif } diff --git a/boards/lilygo-t-embed.ini b/boards/lilygo-t-embed.ini new file mode 100644 index 00000000..a5614402 --- /dev/null +++ b/boards/lilygo-t-embed.ini @@ -0,0 +1,24 @@ +[env:lilygo-t-embed] +board = lilygo-t-embed +board_build.partitions = custom_16Mb.csv +build_src_filter =${env.build_src_filter} +<../boards/lilygo-t-embed-cc1101> +build_flags = + ${env.build_flags} + -Iboards/lilygo-t-embed-cc1101 + -Os + -DCORE_DEBUG_LEVEL=5 + -DREDRAW_DELAY=1 # Used to improve navigation on menus for this device + -DMIC_SPM1423 + + ;Infrared Led default pin and state + -DIR_TX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' + -DIR_RX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' + + ;Radio Frequency (one pin modules) pin setting + -DRF_TX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' + -DRF_RX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' + +lib_deps = + ${env.lib_deps} + lewisxhe/XPowersLib @0.2.6 + mathertel/RotaryEncoder @1.5.3 diff --git a/boards/lilygo-t-embed.json b/boards/lilygo-t-embed.json new file mode 100644 index 00000000..d2ac291a --- /dev/null +++ b/boards/lilygo-t-embed.json @@ -0,0 +1,64 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_16MB.csv", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DT_EMBED", + "-mfix-esp32-psram-cache-issue", + "-mfix-esp32-psram-cache-strategy=memw", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_RUNNING_CORE=0", + "-DARDUINO_EVENT_RUNNING_CORE=0", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x239A", + "0x811B" + ], + [ + "0x239A", + "0x011B" + ], + [ + "0x239A", + "0x811C" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "LilyGo T-Embed (16M Flash 8M QSPI PSRAM)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.lilygo.cc", + "vendor": "LilyGo" +} diff --git a/ports/m5stack-cardputer/platformio.ini b/boards/m5stack-cardputer.ini similarity index 90% rename from ports/m5stack-cardputer/platformio.ini rename to boards/m5stack-cardputer.ini index 8a6dad60..59d4f487 100644 --- a/ports/m5stack-cardputer/platformio.ini +++ b/boards/m5stack-cardputer.ini @@ -9,18 +9,13 @@ ; https://docs.platformio.org/page/projectconf.html [env:m5stack-cardputer] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = m5stack-stamps3 -framework = arduino +board = m5stack-cardputer board_build.partitions = custom_8Mb.csv -build_src_filter =${env.build_src_filter} +<../ports/m5stack-cardputer> +build_src_filter =${env.build_src_filter} +<../boards/m5stack-cardputer> build_flags = ${env.build_flags} - -Iports/m5stack-cardputer + -Iboards/m5stack-cardputer -DCORE_DEBUG_LEVEL=5 - -DARDUINO_USB_CDC_ON_BOOT=1 - - -DCARDPUTER=1 ;Features Enabled ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility @@ -92,8 +87,6 @@ build_flags = ;Screen Setup -DHAS_SCREEN=1 -DROTATION=1 - -DWIDTH=240 - -DHEIGHT=135 -DBACKLIGHT=38 -DMINBRIGHT=160 diff --git a/boards/m5stack-cardputer.json b/boards/m5stack-cardputer.json new file mode 100644 index 00000000..45e7d1d0 --- /dev/null +++ b/boards/m5stack-cardputer.json @@ -0,0 +1,48 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_8MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_M5STACK_CARDPUTER", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stack Cardputer", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.m5stack.com/en/core/StampS3", + "vendor": "M5Stack" + } \ No newline at end of file diff --git a/ports/m5stack-cardputer/interface.cpp b/boards/m5stack-cardputer/interface.cpp similarity index 96% rename from ports/m5stack-cardputer/interface.cpp rename to boards/m5stack-cardputer/interface.cpp index 4905a80b..24365b27 100644 --- a/ports/m5stack-cardputer/interface.cpp +++ b/boards/m5stack-cardputer/interface.cpp @@ -54,12 +54,11 @@ int getBattery() { ** set brightness value **********************************************************************/ void _setBrightness(uint8_t brightval) { - if(brightval>100) brightval=100; - if(brightval == 0){ - analogWrite(BACKLIGHT, brightval); + if(brightval == 0){ + digitalWrite(TFT_BL, brightval); } else { - int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 )); - analogWrite(BACKLIGHT, bl); + int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 )); + digitalWrite(TFT_BL, bl); } } @@ -225,8 +224,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; int i=0; @@ -244,12 +243,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -279,7 +278,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -295,7 +294,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -391,7 +390,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; diff --git a/ports/m5stack-core/platformio.ini b/boards/m5stack-core.ini similarity index 84% rename from ports/m5stack-core/platformio.ini rename to boards/m5stack-core.ini index 55ea1557..4c44e211 100644 --- a/ports/m5stack-core/platformio.ini +++ b/boards/m5stack-core.ini @@ -9,24 +9,15 @@ ; https://docs.platformio.org/page/projectconf.html [m5stack-core_base] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = m5stack-core-esp32 -framework = arduino +board = m5stack-core monitor_speed = 115200 board_build.partitions = custom_4Mb_full.csv -build_src_filter =${env.build_src_filter} +<../ports/m5stack-core> +build_src_filter =${env.build_src_filter} +<../boards/m5stack-core> build_flags = ${env.build_flags} - -Iports/m5stack-core + -Iboards/m5stack-core -DCORE_DEBUG_LEVEL=5 - -DM5STACK=1 ;key for new device, - -DCORE=1 ;mykeyboard.cpp: need map buttons an/or touchscreen, - ;display.cpp: need map battery status value, - ;settings.cpp: need map brighness control - ;main.cpp: need set startup - ;serialcmds.cpp: need set power off command - ;Features Enabled ;FM Radio ;-DFM_SI4713=1 ;Uncomment to activate FM Radio using Adafruit Si4713 @@ -93,8 +84,6 @@ build_flags = ;Screen Setup -DHAS_SCREEN=1 -DROTATION=1 - -DWIDTH=320 - -DHEIGHT=220 ;240 - 50 for bottom margin ;-DBACKLIGHT=38 ;-DMINBRIGHT=160 diff --git a/boards/m5stack-core.json b/boards/m5stack-core.json new file mode 100644 index 00000000..dff39bbd --- /dev/null +++ b/boards/m5stack-core.json @@ -0,0 +1,34 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": ["-DARDUINO_M5STACK_CORE", "-DM5STACK"], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "mcu": "esp32", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stack Core ESP32", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "http://www.m5stack.com", + "vendor": "M5Stack" + } \ No newline at end of file diff --git a/ports/m5stack-core/interface.cpp b/boards/m5stack-core/interface.cpp similarity index 95% rename from ports/m5stack-core/interface.cpp rename to boards/m5stack-core/interface.cpp index 02cf629a..0f7f6c30 100644 --- a/ports/m5stack-core/interface.cpp +++ b/boards/m5stack-core/interface.cpp @@ -204,8 +204,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; int i=0; @@ -223,12 +223,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -258,7 +258,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -274,7 +274,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -382,7 +382,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; diff --git a/ports/m5stack-core2/platformio.ini b/boards/m5stack-core2.ini similarity index 85% rename from ports/m5stack-core2/platformio.ini rename to boards/m5stack-core2.ini index d8e28880..ef476ff6 100644 --- a/ports/m5stack-core2/platformio.ini +++ b/boards/m5stack-core2.ini @@ -9,10 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [env:m5stack-core2] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -;board = m5stick-c board = m5stack-core2 -framework = arduino monitor_speed = 115200 board_build.partitions = custom_16Mb.csv board_build.f_flash = 40000000L @@ -20,19 +17,12 @@ board_upload.flash_size = 16MB board_upload.maximum_size = 16777216 ;board_upload.maximum_ram_size=532480 ;board_upload.maximum_ram_size=4521984 -build_src_filter =${env.build_src_filter} +<../ports/m5stack-core2> +build_src_filter =${env.build_src_filter} +<../boards/m5stack-core2> build_flags = ${env.build_flags} - -Iports/m5stack-core2 + -Iboards/m5stack-core2 -DCORE_DEBUG_LEVEL=5 - -DM5STACK=1 ;key for new device, - -DCORE2=1 ;mykeyboard.cpp: need map buttons an/or touchscreen, - ;display.cpp: need map battery status value, - ;settings.cpp: need map brighness control - ;main.cpp: need set startup - ;serialcmds.cpp: need set power off command - ;Features Enabled ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility ;FM Radio diff --git a/boards/m5stack-core2.json b/boards/m5stack-core2.json new file mode 100644 index 00000000..48b809e8 --- /dev/null +++ b/boards/m5stack-core2.json @@ -0,0 +1,41 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld", + "partitions": "default_16MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-mfix-esp32-psram-cache-issue", + "-mfix-esp32-psram-cache-strategy=memw", + "-DARDUINO_M5STACK_CORE2", + "-DM5STACK", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stack Core2", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 4521984, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800 + }, + "url": "http://www.m5stack.com", + "vendor": "M5Stack" +} diff --git a/ports/m5stack-core2/interface.cpp b/boards/m5stack-core2/interface.cpp similarity index 95% rename from ports/m5stack-core2/interface.cpp rename to boards/m5stack-core2/interface.cpp index 99a7a5d6..1465d95a 100644 --- a/ports/m5stack-core2/interface.cpp +++ b/boards/m5stack-core2/interface.cpp @@ -239,8 +239,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; int k=0; @@ -289,7 +289,7 @@ String keyboard(String mytext, int maxSize, String msg) { box_list[k].color = ~bruceConfig.bgColor; box_list[k].x=159; box_list[k].y=0; - box_list[k].w=WIDTH-164; + box_list[k].w=tftWidth-164; box_list[k].h=22; k=0; @@ -312,12 +312,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -347,7 +347,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -363,7 +363,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -420,7 +420,7 @@ String keyboard(String mytext, int maxSize, String msg) { if (t.isPressed() || t.isHolding()) { if (box_list[48].contain(t.x, t.y)) { break; } // Ok - if (box_list[49].contain(t.x, t.y)) { caps=!caps; tft.fillRect(0,54,WIDTH,HEIGHT-54,bruceConfig.bgColor); goto THIS_END; } // CAP + if (box_list[49].contain(t.x, t.y)) { caps=!caps; tft.fillRect(0,54,tftWidth,tftHeight-54,bruceConfig.bgColor); goto THIS_END; } // CAP if (box_list[50].contain(t.x, t.y)) goto DEL; // DEL if (box_list[51].contain(t.x, t.y)) { mytext += box_list[51].key; goto ADD; } // SPACE for(k=0;k<48;k++){ @@ -491,7 +491,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; diff --git a/boards/m5stack-cores3.ini b/boards/m5stack-cores3.ini new file mode 100644 index 00000000..95d6fe73 --- /dev/null +++ b/boards/m5stack-cores3.ini @@ -0,0 +1,28 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:m5stack-cores3] +board = m5stack-cores3 +monitor_speed = 115200 +board_build.partitions = custom_16Mb.csv +board_upload.flash_size = 16MB +board_upload.maximum_size = 16777216 +build_src_filter =${env.build_src_filter} +<../boards/m5stack-cores3> +build_flags = + ${env.build_flags} + -Os + -Iboards/m5stack-cores3 + -DIR_TX_PINS='{{"M5 IR Mod", GROVE_SDA}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' + -DIR_RX_PINS='{{"M5 IR Mod", GROVE_SCL}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' + -DRF_TX_PINS='{{"M5 RF433T", GROVE_SDA}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' + -DRF_RX_PINS='{{"M5 RF433R", GROVE_SCL}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' +lib_deps = + ${env.lib_deps} + diff --git a/boards/m5stack-cores3.json b/boards/m5stack-cores3.json new file mode 100644 index 00000000..b5ad3b57 --- /dev/null +++ b/boards/m5stack-cores3.json @@ -0,0 +1,52 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_16MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-mfix-esp32-psram-cache-issue", + "-mfix-esp32-psram-cache-strategy=memw", + "-DARDUINO_M5STACK_CORES3", + "-DM5STACK", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x8119" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stack CoreS3", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.m5stack.com/en/core/CoreS3", + "vendor": "M5Stack" +} \ No newline at end of file diff --git a/ports/m5stack-cores3/interface.cpp b/boards/m5stack-cores3/interface.cpp similarity index 94% rename from ports/m5stack-cores3/interface.cpp rename to boards/m5stack-cores3/interface.cpp index 0798d9f7..85f42dfb 100644 --- a/ports/m5stack-cores3/interface.cpp +++ b/boards/m5stack-cores3/interface.cpp @@ -43,19 +43,15 @@ void _setBrightness(uint8_t brightval) { #define NEXT 2 #define ALL 3 bool menuPress(int bot) { - //0 - prev - //1 - Sel - //2 - next - //3 - any - int terco=WIDTH/3; + int terco=tftWidth/3; M5.update(); auto t = M5.Touch.getDetail(); if (t.isPressed() || t.isHolding()) { - //if(bruceConfig.rotation==3) t.x = WIDTH-t.x; - //else if (bruceConfig.rotation==1) t.y = (HEIGHT+20)-t.y; - if(t.y>(HEIGHT) && (t.x>terco*bot && t.x(tftHeight) && (t.x>terco*bot && t.x19) { @@ -381,7 +377,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -435,7 +431,7 @@ String keyboard(String mytext, int maxSize, String msg) { { if (box_list[48].contain(t.x, t.y)) { break; } // Ok - if (box_list[49].contain(t.x, t.y)) { caps=!caps; tft.fillRect(0,54,WIDTH,HEIGHT-54,bruceConfig.bgColor); goto THIS_END; } // CAP + if (box_list[49].contain(t.x, t.y)) { caps=!caps; tft.fillRect(0,54,tftWidth,tftHeight-54,bruceConfig.bgColor); goto THIS_END; } // CAP if (box_list[50].contain(t.x, t.y)) goto DEL; // DEL if (box_list[51].contain(t.x, t.y)) { mytext += box_list[51].key; goto ADD; } // SPACE for(k=0;k<48;k++){ @@ -505,7 +501,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; diff --git a/ports/m5stack-cplus1_1/platformio.ini b/boards/m5stack-cplus1_1.ini similarity index 92% rename from ports/m5stack-cplus1_1/platformio.ini rename to boards/m5stack-cplus1_1.ini index d836e199..7282480c 100644 --- a/ports/m5stack-cplus1_1/platformio.ini +++ b/boards/m5stack-cplus1_1.ini @@ -9,16 +9,13 @@ ; https://docs.platformio.org/page/projectconf.html [env:m5stack-cplus1_1] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = m5stick-c -framework = arduino +board = m5stack-cplus1_1 board_build.partitions = custom_4Mb_full.csv -build_src_filter =${env.build_src_filter} +<../ports/m5stack-cplus1_1> +build_src_filter =${env.build_src_filter} +<../boards/m5stack-cplus1_1> build_flags = ${env.build_flags} - -Iports/m5stack-cplus1_1 + -Iboards/m5stack-cplus1_1 -Os - -DSTICK_C_PLUS=1 ;Features Enabled ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility @@ -94,8 +91,6 @@ build_flags = ;Screen Setup -DHAS_SCREEN=1 -DROTATION=3 - -DWIDTH=240 - -DHEIGHT=135 ;TFT_eSPI Setup -DUSER_SETUP_LOADED=1 diff --git a/boards/m5stack-cplus1_1.json b/boards/m5stack-cplus1_1.json new file mode 100644 index 00000000..037fba13 --- /dev/null +++ b/boards/m5stack-cplus1_1.json @@ -0,0 +1,36 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_M5STICK_C_PLUS" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stick-C", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 1500000 + }, + "url": "http://www.m5stack.com", + "vendor": "M5Stack" +} \ No newline at end of file diff --git a/ports/m5stack-cplus1_1/interface.cpp b/boards/m5stack-cplus1_1/interface.cpp similarity index 94% rename from ports/m5stack-cplus1_1/interface.cpp rename to boards/m5stack-cplus1_1/interface.cpp index ac876d22..5e67a425 100644 --- a/ports/m5stack-cplus1_1/interface.cpp +++ b/boards/m5stack-cplus1_1/interface.cpp @@ -165,8 +165,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; int i=0; @@ -184,12 +184,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -219,7 +219,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -235,7 +235,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -341,7 +341,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; @@ -371,6 +371,6 @@ void checkReboot() { } // Clear text after releasing the button delay(30); - tft.fillRect(60, 12, WIDTH - 60, tft.fontHeight(1), TFT_BLACK); + tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), TFT_BLACK); } } diff --git a/ports/m5stack-cplus2/platformio.ini b/boards/m5stack-cplus2.ini similarity index 81% rename from ports/m5stack-cplus2/platformio.ini rename to boards/m5stack-cplus2.ini index ed2673d8..53c617f5 100644 --- a/ports/m5stack-cplus2/platformio.ini +++ b/boards/m5stack-cplus2.ini @@ -9,29 +9,22 @@ ; https://docs.platformio.org/page/projectconf.html [env:m5stack-cplus2] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = m5stick-c -framework = arduino +board = m5stack-cplus2 board_build.partitions = custom_8Mb.csv board_build.f_flash = 40000000L board_upload.flash_size = 8MB board_upload.maximum_size = 8388608 -build_src_filter =${env.build_src_filter} +<../ports/m5stack-cplus2> +build_src_filter =${env.build_src_filter} +<../boards/m5stack-cplus2> build_flags = ${env.build_flags} - -Iports/m5stack-cplus2 + -Iboards/m5stack-cplus2 -DCORE_DEBUG_LEVEL=5 - -DBOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue - -mfix-esp32-psram-cache-strategy=memw - - -DSTICK_C_PLUS2=1 ;Features Enabled ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility -DMIC_SPM1423=1 ;Applicable for SPM1423 device ;FM Radio - -DFM_SI4713=1 ;Uncomment to activate FM Radio using Adafruit Si4713 + -DFM_SI4713=1 -DFM_RSTPIN=0 -DPIN_CLK=0 -DI2S_SCLK_PIN=0 @@ -72,16 +65,13 @@ build_flags = -DRF_TX_PINS='{ {"M5 RF433T", GROVE_SDA}, {"G26",26}, {"G25",25}, {"G0",0}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' -DRF_RX_PINS='{ {"M5 RF433R", GROVE_SCL}, {"G26",26}, {"G25",25}, {"G0",0}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' - ; connection pins for CC1101 https://github.com/bmorcelli/io433/blob/master/platformio.ini -DUSE_CC1101_VIA_SPI -DCC1101_GDO0_PIN=25 -DCC1101_SS_PIN=SPI_SS_PIN -DCC1101_MOSI_PIN=SPI_MOSI_PIN -DCC1101_SCK_PIN=SPI_SCK_PIN -DCC1101_MISO_PIN=SPI_MISO_PIN - ;-DCC1101_GDO2_PIN=-1 - ; connections are the same as CC1101 -DUSE_NRF24_VIA_SPI -DNRF24_CE_PIN=25 -DNRF24_SS_PIN=SPI_SS_PIN @@ -89,19 +79,14 @@ build_flags = -DNRF24_SCK_PIN=SPI_SCK_PIN -DNRF24_MISO_PIN=SPI_MISO_PIN - ;Battery ADC read pin -DBAT_PIN=38 - ;Font sizes, depending on device -DFP=1 -DFM=2 -DFG=3 - ;Screen Setup -DHAS_SCREEN=1 -DROTATION=3 - -DWIDTH=240 - -DHEIGHT=135 -DBACKLIGHT=27 -DMINBRIGHT=160 diff --git a/boards/m5stack-cplus2.json b/boards/m5stack-cplus2.json new file mode 100644 index 00000000..e81d57a0 --- /dev/null +++ b/boards/m5stack-cplus2.json @@ -0,0 +1,39 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_M5STICK_C_PLUS2", + "-DBOARD_HAS_PSRAM", + "-mfix-esp32-psram-cache-issue", + "-mfix-esp32-psram-cache-strategy=memw" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stick CPlus2", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 1500000 + }, + "url": "http://www.m5stack.com", + "vendor": "M5Stack" +} \ No newline at end of file diff --git a/ports/m5stack-cplus2/interface.cpp b/boards/m5stack-cplus2/interface.cpp similarity index 94% rename from ports/m5stack-cplus2/interface.cpp rename to boards/m5stack-cplus2/interface.cpp index 1d168a72..537ddac1 100644 --- a/ports/m5stack-cplus2/interface.cpp +++ b/boards/m5stack-cplus2/interface.cpp @@ -56,13 +56,12 @@ int getBattery() { ** location: settings.cpp ** set brightness value **********************************************************************/ -void _setBrightness(uint8_t brightval) { - if(brightval>100) brightval=100; - if(brightval == 0){ - analogWrite(BACKLIGHT, brightval); +void _setBrightness(uint8_t brightval) { + if(brightval == 0){ + digitalWrite(TFT_BL, brightval); } else { - int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 )); - analogWrite(BACKLIGHT, bl); + int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 )); + digitalWrite(TFT_BL, bl); } } @@ -219,8 +218,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; int i=0; @@ -238,12 +237,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -273,7 +272,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -289,7 +288,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -395,7 +394,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; @@ -440,6 +439,6 @@ void checkReboot() { // Clear text after releasing the button delay(30); - tft.fillRect(60, 12, WIDTH - 60, tft.fontHeight(1), TFT_BLACK); + tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), TFT_BLACK); } } \ No newline at end of file diff --git a/boards/pinouts/CYD-2432S028.h b/boards/pinouts/CYD-2432S028.h new file mode 100644 index 00000000..a4a0cc22 --- /dev/null +++ b/boards/pinouts/CYD-2432S028.h @@ -0,0 +1,48 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 21; +static const uint8_t SCL = 22; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 19; +static const uint8_t SCK = 18; + +static const uint8_t A0 = 36; +static const uint8_t A3 = 39; +static const uint8_t A4 = 32; +static const uint8_t A5 = 33; +static const uint8_t A6 = 34; +static const uint8_t A7 = 35; +static const uint8_t A10 = 4; +static const uint8_t A11 = 0; +static const uint8_t A12 = 2; +static const uint8_t A13 = 15; +static const uint8_t A14 = 13; +static const uint8_t A15 = 12; +static const uint8_t A16 = 14; +static const uint8_t A17 = 27; +static const uint8_t A18 = 25; +static const uint8_t A19 = 26; + +static const uint8_t T0 = 4; +static const uint8_t T1 = 0; +static const uint8_t T2 = 2; +static const uint8_t T3 = 15; +static const uint8_t T4 = 13; +static const uint8_t T5 = 12; +static const uint8_t T6 = 14; +static const uint8_t T7 = 27; +static const uint8_t T8 = 33; +static const uint8_t T9 = 32; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/ESP-General.h b/boards/pinouts/ESP-General.h new file mode 100644 index 00000000..b0961c0d --- /dev/null +++ b/boards/pinouts/ESP-General.h @@ -0,0 +1,69 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// Some boards have too low voltage on this pin (board design bug) +// Use different pin with 3V and connect with 48 +// and change this setup for the chosen pin (for example 38) +#define PIN_RGB_LED 48 +// BUILTIN_LED can be used in new Arduino API digitalWrite() like in Blink.ino +static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT + PIN_RGB_LED; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN +// RGB_BUILTIN and RGB_BRIGHTNESS can be used in new Arduino API rgbLedWrite() +#define RGB_BUILTIN LED_BUILTIN +#define RGB_BRIGHTNESS 64 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 8; +static const uint8_t SCL = 9; + +static const uint8_t SS = 10; +static const uint8_t MOSI = 11; +static const uint8_t MISO = 13; +static const uint8_t SCK = 12; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/_New-Device-Model.h b/boards/pinouts/_New-Device-Model.h new file mode 100644 index 00000000..b732b5c3 --- /dev/null +++ b/boards/pinouts/_New-Device-Model.h @@ -0,0 +1,133 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t TXD2 = 1; +static const uint8_t RXD2 = 2; + +static const uint8_t SDA = 13; +static const uint8_t SCL = 15; + +// Modified elsewhere +static const uint8_t SS = -1; +static const uint8_t MOSI = -1; +static const uint8_t MISO = -1; +static const uint8_t SCK = -1; + +static const uint8_t G0 = 0; +static const uint8_t G1 = 1; +static const uint8_t G2 = 2; +static const uint8_t G3 = 3; +static const uint8_t G4 = 4; +static const uint8_t G5 = 5; +static const uint8_t G6 = 6; +static const uint8_t G7 = 7; +static const uint8_t G8 = 8; +static const uint8_t G9 = 9; +static const uint8_t G10 = 10; +static const uint8_t G11 = 11; +static const uint8_t G12 = 12; +static const uint8_t G13 = 13; +static const uint8_t G14 = 14; +static const uint8_t G15 = 15; +static const uint8_t G39 = 39; +static const uint8_t G40 = 40; +static const uint8_t G41 = 41; +static const uint8_t G42 = 42; +static const uint8_t G43 = 43; +static const uint8_t G44 = 44; +static const uint8_t G46 = 46; + +static const uint8_t ADC1 = 7; +static const uint8_t ADC2 = 8; + +#define FM_RSTPIN 40 +#define PIN_CLK 43 +#define I2S_SCLK_PIN 43 +#define I2S_DATA_PIN 46 +#define PIN_DATA 46 + +#define RGB_LED 21 + +#define BCLK 41 +#define WCLK 43 +#define DOUT 42 + +#define BAD_TX GROVE_SDA +#define BAD_RX GROVE_SCL + +#define HAS_BTN 0 +#define BTN_ALIAS '"Ok"' +#define BTN_PIN 0 +#define BTN_ACT LOw + +#define IR_TX_PINS '{{"M5 IR Mod", GROVE_SDA}, {"Pin 1", 1}, {"Pin 2", 2}}' +#define IR_RX_PINS '{{"M5 IR Mod", GROVE_SCL}, {"Pin 1", 1}, {"Pin 2", 2}}' +#define LED -1 +#define LED_ON HIGH +#define LED_OFF LOW + +#define RF_TX_PINS '{{"M5 RF433T", GROVE_SDA}, {"Pin 1", 1}, {"Pin 2", 2}}' +#define RF_RX_PINS '{{"M5 FR433R", GROVE_SCL}, {"Pin 1", 1}, {"Pin 2", 2}}' + +#define CC1101_GDO0_PIN 9 +#define CC1101_SS_PIN 10 +#define CC1101_MOSI_PIN SPI_MOSI_PIN +#define CC1101_SCK_PIN SPI_SCK_PIN +#define CC1101_MISO_PIN SPI_MISO_PIN + +#define NRF24_CE_PIN 6 +#define NRF24_SS_PIN 7 +#define NRF24_MOSI_PIN SPI_MOSI_PIN +#define NRF24_SCK_PIN SPI_SCK_PIN +#define NRF24_MISO_PIN SPI_MISO_PIN + +#define FP 1 +#define FM 2 +#define FG 3 + +#define HAS_SCREEN 1 +#define ROTATION 1 +#define MINBRIGHT 160 + +#define USER_SETUP_LOADED 1 +#define USE_HSPI_PORT 1 +#define ST7789_2_DRIVER 1 +#define TFT_RGB_ORDER 1 +#define TFT_WIDTH 135 +#define TFT_HEIGHT 240 +#define TFT_BACKLIGHT_ON 1 +#define TFT_BL 38 +#define TFT_RST 33 +#define TFT_DC 34 +#define TFT_MOSI 35 +#define TFT_SCLK 36 +#define TFT_CS 37 +#define TOUCH_CS -1 +#define SMOOTH_FONT 1 +#define SPI_FREQUENCY 20000000 +#define SPI_READ_FREQUENCY 20000000 +#define SPI_TOUCH_FREQUENCY 2500000 + +#define SDCARD_CS 12 +#define SDCARD_SCK 40 +#define SDCARD_MISO 39 +#define SDCARD_MOSI 14 + +#define GROVE_SDA 2 +#define GROVE_SCL 1 + +#define SPI_SCK_PIN 12 +#define SPI_MOSI_PIN 11 +#define SPI_MISO_PIN 13 +#define SPI_SS_PIN 10 + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/lilygo-t-deck.h b/boards/pinouts/lilygo-t-deck.h new file mode 100644 index 00000000..339b47df --- /dev/null +++ b/boards/pinouts/lilygo-t-deck.h @@ -0,0 +1,70 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// Some boards have too low voltage on this pin (board design bug) +// Use different pin with 3V and connect with 48 +// and change this setup for the chosen pin (for example 38) +#define PIN_NEOPIXEL 48 +// BUILTIN_LED can be used in new Arduino API digitalWrite() like in Blink.ino +static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+PIN_NEOPIXEL; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN +// RGB_BUILTIN and RGB_BRIGHTNESS can be used in new Arduino API neopixelWrite() +#define RGB_BUILTIN LED_BUILTIN +#define RGB_BRIGHTNESS 64 + + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 8; +static const uint8_t SCL = 9; + +static const uint8_t SS = 10; +static const uint8_t MOSI = 11; +static const uint8_t MISO = 13; +static const uint8_t SCK = 12; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +#endif /* Pins_Arduino_h */ diff --git a/boards/pinouts/lilygo-t-embed-cc1101.h b/boards/pinouts/lilygo-t-embed-cc1101.h new file mode 100644 index 00000000..7744b772 --- /dev/null +++ b/boards/pinouts/lilygo-t-embed-cc1101.h @@ -0,0 +1,147 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h +#define T_EMBED + +#include +#include "soc/soc_caps.h" + +// Lite Version +// #define LITE_VERSION 1 + +// Main I2C Bus +#define SPI_SS_PIN 8 +#define SPI_MOSI_PIN 9 +#define SPI_MISO_PIN 10 +#define SPI_SCK_PIN 11 +static const uint8_t SS = SPI_SS_PIN; +static const uint8_t MOSI = SPI_MOSI_PIN; +static const uint8_t SCK = SPI_MISO_PIN; +static const uint8_t MISO = SPI_SCK_PIN; + +// Set Main I2C Bus +#define GROVE_SDA 8 +#define GROVE_SCL 18 +static const uint8_t SDA = GROVE_SDA; +static const uint8_t SCL = GROVE_SCL; + + +// TFT_eSPI display +#define ST7789_DRIVER 1 +#define USER_SETUP_LOADED +#define USE_HSPI_PORT +#define SMOOTH_FONT 1 +#define TFT_INVERSION_ON +#define TFT_WIDTH 170 +#define TFT_HEIGHT 320 +#define TFT_BL 21 +#define TFT_MISO SPI_MISO_PIN +#define TFT_MOSI SPI_MOSI_PIN +#define TFT_SCLK SPI_SCK_PIN +#define TFT_CS 41 +#define TFT_DC 16 +#define TFT_RST 40 +#define SPI_FREQUENCY 80000000 +#define SPI_READ_FREQUENCY 20000000 + +// Display Setup +#define HAS_SCREEN +#define ROTATION 3 +#define MINBRIGHT (uint8_t) 1 +#define PIN_POWER_ON 15 + +// Font Sizes +#define FP 1 +#define FM 2 +#define FG 3 + +// SD Card +#define SDCARD_CS 13 +#define SDCARD_MISO SPI_MISO_PIN +#define SDCARD_MOSI SPI_MOSI_PIN +#define SDCARD_SCK SPI_SCK_PIN + +// NRF24 - Over QWIIC Port #2 +#define USE_NRF24_VIA_SPI +#define NRF24_CE_PIN 43 +#define NRF24_SS_PIN 44 +#define NRF24_MOSI_PIN SDCARD_MOSI +#define NRF24_SCK_PIN SDCARD_SCK +#define NRF24_MISO_PIN SDCARD_MISO + +// CC1101 +#define USE_CC1101_VIA_SPI +#define CC1101_GDO0_PIN 3 +#define CC1101_GDO2_PIN 38 +#define CC1101_SW1_PIN 47 +#define CC1101_SW0_PIN 48 +#define CC1101_SS_PIN 12 +#define CC1101_MISO_PIN SPI_MISO_PIN +#define CC1101_MOSI_PIN SPI_MOSI_PIN +#define CC1101_SCK_PIN SPI_SCK_PIN + +//PN532 +#define PN532_RF_REST 45 +#define PN532_IRQ 17 + +// Mic +#define PIN_CLK 39 +#define PIN_DATA 42 + +// Speaker +#define HAS_NS4168_SPKR +#define BCLK 46 +#define WCLK 40 +#define DOUT 7 +#define MCLK PIN_CLK + +// Serial +#define SERIAL_TX 43 +#define SERIAL_RX 44 +static const uint8_t TX = SERIAL_TX; +static const uint8_t RX = SERIAL_RX; +#define TX1 TX +#define RX1 RX + +// Fuel Gauge +#define USE_BQ27220_VIA_I2C +#define BQ27220_I2C_ADDRESS 0x55 +#define BQ27220_I2C_SDA GROVE_SDA +#define BQ27220_I2C_SCL GROVE_SCL + +// Encoder +#define ENCODER_INA 4 +#define ENCODER_INB 5 +#define ENCODER_KEY 0 +#define HAS_BTN 1 +#define BTN_ALIAS '"Mid"' +#define SEL_BTN ENCODER_KEY +#define UP_BTN -1 +#define DW_BTN -1 +#define BK_BTN 6 +#define BTN_ACT LOW + +// IR +#define LED 2 +#define RXLED 1 +#define LED_ON HIGH +#define LED_OFF LOW + +// RF Module + +// FM +// #define FM_SI4713 +// #define FM_RSTPIN 40 + +// RTC +// #define HAS_RTC + +// RGB LED +// #define HAS_RGB_LED +// #define RGB_LED=21 + +// BadUSB +#define USB_as_HID 1 +// #define BAD_TX=GROVE_SDA +//#define BAD_RX=GROVE_SCL + +#endif /* Pins_Arduino_h */ diff --git a/boards/pinouts/lilygo-t-embed.h b/boards/pinouts/lilygo-t-embed.h new file mode 100644 index 00000000..d7aca8c2 --- /dev/null +++ b/boards/pinouts/lilygo-t-embed.h @@ -0,0 +1,132 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +// Lite Version +// #define LITE_VERSION 1 + +// Main I2C Bus +#define SPI_SS_PIN 17 +#define SPI_MOSI_PIN 41 +#define SPI_MISO_PIN 40 +#define SPI_SCK_PIN 38 +static const uint8_t SS = SPI_SS_PIN; +static const uint8_t MOSI = SPI_MOSI_PIN; +static const uint8_t SCK = SPI_MISO_PIN; +static const uint8_t MISO = SPI_SCK_PIN; + +// Set Main I2C Bus +#define GROVE_SDA 44 +#define GROVE_SCL 43 +static const uint8_t SDA = GROVE_SDA; +static const uint8_t SCL = GROVE_SCL; + +// TFT_eSPI display +#define ST7789_DRIVER 1 +#define USER_SETUP_LOADED +#define USE_HSPI_PORT +#define SMOOTH_FONT 1 +#define TFT_WIDTH 170 +#define TFT_HEIGHT 320 +#define TFT_BL 15 +#define TFT_MISO -1 +#define TFT_MOSI 11 +#define TFT_SCLK 12 +#define TFT_CS 10 +#define TFT_DC 13 +#define TFT_RST 9 +#define TOUCH_CS -1 +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 20000000 +#define SPI_TOUCH_FREQUENCY 2500000 + +// Display Setup# +#define HAS_SCREEN +#define ROTATION 3 +#define MINBRIGHT (uint8_t) 1 +#define PIN_POWER_ON 46 + +// Font Sizes# +#define FP 1 +#define FM 2 +#define FG 3 + +// SD Card# +#define SDCARD_CS 39 +#define SDCARD_MISO SPI_MISO_PIN +#define SDCARD_MOSI SPI_MOSI_PIN +#define SDCARD_SCK SPI_SCK_PIN + +// NRF24 - Over QWIIC Port # +#define USE_NRF24_VIA_SPI +#define NRF24_CE_PIN 44 +#define NRF24_SS_PIN 43 +#define NRF24_MOSI_PIN SDCARD_MOSI +#define NRF24_SCK_PIN SDCARD_SCK +#define NRF24_MISO_PIN SDCARD_MISO + +// CC1101# +#define USE_CC1101_VIA_SPI +#define CC1101_GDO0_PIN 44 +#define CC1101_SS_PIN 43 +#define CC1101_MISO_PIN SPI_MISO_PIN +#define CC1101_MOSI_PIN SPI_MOSI_PIN +#define CC1101_SCK_PIN SPI_SCK_PIN + +// Mic# +#define MIC_SPM1423 +#define PIN_CLK 21 +#define PIN_DATA 14 + +// Speaker# +#define HAS_NS4168_SPKR +#define BCLK 7 +#define WCLK 5 +#define DOUT 6 +#define MCLK 39 + +// Serial +#define SERIAL_TX 43 +#define SERIAL_RX 44 + +#define BAT_PIN 4 + + +// Encoder +#define ENCODER_INA 2 +#define ENCODER_INB 1 +#define ENCODER_KEY 0 +#define HAS_BTN 1 +#define BTN_ALIAS '"Mid"' +#define SEL_BTN ENCODER_KEY +#define UP_BTN 1 +#define DW_BTN 1 +#define BTN_ACT LOW + +// IR +#define LED 44 +#define RXLED 43 +#define LED_ON HIGH +#define LED_OFF LOW + +// RF Module + +// FM +// #define FM_SI4713 +// #define FM_RSTPIN 40 + +// RTC +// #define HAS_RTC + +// RGB LED +// #define HAS_RGB_LED +// #define RGB_LED=21 + +// BadUSB +#define USB_as_HID=1 +// #define BAD_TX=GROVE_SDA +//#define BAD_RX=GROVE_SCL + +#endif /* Pins_Arduino_h */ diff --git a/boards/pinouts/m5stack-cardputer.h b/boards/pinouts/m5stack-cardputer.h new file mode 100644 index 00000000..e28a11e8 --- /dev/null +++ b/boards/pinouts/m5stack-cardputer.h @@ -0,0 +1,194 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t TXD2 = 1; +static const uint8_t RXD2 = 2; + +static const uint8_t SDA = 13; +static const uint8_t SCL = 15; + +static const uint8_t SS = 12; +static const uint8_t MOSI = 14; +static const uint8_t MISO = 39; +static const uint8_t SCK = 40; + +static const uint8_t G0 = 0; +static const uint8_t G1 = 1; +static const uint8_t G2 = 2; +static const uint8_t G3 = 3; +static const uint8_t G4 = 4; +static const uint8_t G5 = 5; +static const uint8_t G6 = 6; +static const uint8_t G7 = 7; +static const uint8_t G8 = 8; +static const uint8_t G9 = 9; +static const uint8_t G10 = 10; +static const uint8_t G11 = 11; +static const uint8_t G12 = 12; +static const uint8_t G13 = 13; +static const uint8_t G14 = 14; +static const uint8_t G15 = 15; +static const uint8_t G39 = 39; +static const uint8_t G40 = 40; +static const uint8_t G41 = 41; +static const uint8_t G42 = 42; +static const uint8_t G43 = 43; +static const uint8_t G44 = 44; +static const uint8_t G46 = 46; + +static const uint8_t ADC1 = 7; +static const uint8_t ADC2 = 8; + +#define SHIFT 0x80 +#define KEY_LEFT_CTRL 0x80 +#define KEY_LEFT_SHIFT 0x81 +#define KEY_LEFT_ALT 0x82 +#define KEY_FN 0xff +#define KEY_OPT 0x00 +#define KEY_BACKSPACE 0x2a +#define KEY_TAB 0x2b +#define KEY_ENTER 0x28 + +static const uint8_t _kb_asciimap[128] = { + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + KEY_BACKSPACE, // BS Backspace + KEY_TAB, // TAB Tab + KEY_ENTER, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e | SHIFT, // ! + 0x34 | SHIFT, // " + 0x20 | SHIFT, // # + 0x21 | SHIFT, // $ + 0x22 | SHIFT, // % + 0x24 | SHIFT, // & + 0x34, // ' + 0x26 | SHIFT, // ( + 0x27 | SHIFT, // ) + 0x25 | SHIFT, // * + 0x2e | SHIFT, // + + 0x36, // , + 0x2d, // - + 0x37, // . + 0x38, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x33 | SHIFT, // : + 0x33, // ; + 0x36 | SHIFT, // < + 0x2e, // = + 0x37 | SHIFT, // > + 0x38 | SHIFT, // ? + 0x1f | SHIFT, // @ + 0x04 | SHIFT, // A + 0x05 | SHIFT, // B + 0x06 | SHIFT, // C + 0x07 | SHIFT, // D + 0x08 | SHIFT, // E + 0x09 | SHIFT, // F + 0x0a | SHIFT, // G + 0x0b | SHIFT, // H + 0x0c | SHIFT, // I + 0x0d | SHIFT, // J + 0x0e | SHIFT, // K + 0x0f | SHIFT, // L + 0x10 | SHIFT, // M + 0x11 | SHIFT, // N + 0x12 | SHIFT, // O + 0x13 | SHIFT, // P + 0x14 | SHIFT, // Q + 0x15 | SHIFT, // R + 0x16 | SHIFT, // S + 0x17 | SHIFT, // T + 0x18 | SHIFT, // U + 0x19 | SHIFT, // V + 0x1a | SHIFT, // W + 0x1b | SHIFT, // X + 0x1c | SHIFT, // Y + 0x1d | SHIFT, // Z + 0x2f, // [ + 0x31, // bslash + 0x30, // ] + 0x23 | SHIFT, // ^ + 0x2d | SHIFT, // _ + 0x35, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x2f | SHIFT, // { + 0x31 | SHIFT, // | + 0x30 | SHIFT, // } + 0x35 | SHIFT, // ~ + 0 // DEL +}; + + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/m5stack-core.h b/boards/pinouts/m5stack-core.h new file mode 100644 index 00000000..e2161ed9 --- /dev/null +++ b/boards/pinouts/m5stack-core.h @@ -0,0 +1,47 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t TXD2 = 17; +static const uint8_t RXD2 = 16; + +static const uint8_t SDA = 21; +static const uint8_t SCL = 22; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 19; +static const uint8_t SCK = 18; + +static const uint8_t G23 = 23; +static const uint8_t G19 = 19; +static const uint8_t G18 = 18; +static const uint8_t G3 = 3; +static const uint8_t G16 = 16; +static const uint8_t G21 = 21; +static const uint8_t G2 = 2; +static const uint8_t G12 = 12; +static const uint8_t G15 = 15; +static const uint8_t G35 = 35; +static const uint8_t G36 = 36; +static const uint8_t G25 = 25; +static const uint8_t G26 = 26; +static const uint8_t G1 = 1; +static const uint8_t G17 = 17; +static const uint8_t G22 = 22; +static const uint8_t G5 = 5; +static const uint8_t G13 = 13; +static const uint8_t G0 = 0; +static const uint8_t G34 = 34; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/m5stack-core2.h b/boards/pinouts/m5stack-core2.h new file mode 100644 index 00000000..dcfc9935 --- /dev/null +++ b/boards/pinouts/m5stack-core2.h @@ -0,0 +1,52 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define TX2 14 +#define RX2 13 + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 32; +static const uint8_t SCL = 33; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 38; +static const uint8_t SCK = 18; + +static const uint8_t G23 = 23; +static const uint8_t G38 = 38; +static const uint8_t G18 = 18; +static const uint8_t G3 = 3; +static const uint8_t G13 = 13; +static const uint8_t G21 = 21; +static const uint8_t G32 = 32; +static const uint8_t G27 = 27; +static const uint8_t G2 = 2; +static const uint8_t G35 = 35; +static const uint8_t G36 = 36; +static const uint8_t G25 = 25; +static const uint8_t G26 = 26; +static const uint8_t G1 = 1; +static const uint8_t G14 = 14; +static const uint8_t G22 = 22; +static const uint8_t G33 = 33; +static const uint8_t G19 = 19; +static const uint8_t G0 = 0; +static const uint8_t G34 = 34; + +static const uint8_t G12 = 12; +static const uint8_t G15 = 15; +static const uint8_t G17 = 17; +static const uint8_t G5 = 5; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/m5stack-cores3.h b/boards/pinouts/m5stack-cores3.h new file mode 100644 index 00000000..cba1883d --- /dev/null +++ b/boards/pinouts/m5stack-cores3.h @@ -0,0 +1,124 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// Some boards have too low voltage on this pin (board design bug) +// Use different pin with 3V and connect with 48 +// and change this setup for the chosen pin (for example 38) +static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT + 48; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN +#define RGB_BUILTIN LED_BUILTIN +#define RGB_BRIGHTNESS 64 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t TXD2 = 17; +static const uint8_t RXD2 = 18; + +static const uint8_t SDA = 12; +static const uint8_t SCL = 11; + +static const uint8_t SS = 15; +static const uint8_t MOSI = 37; +static const uint8_t MISO = 35; +static const uint8_t SCK = 36; + +static const uint8_t G0 = 0; +static const uint8_t G1 = 1; +static const uint8_t G2 = 2; +static const uint8_t G3 = 3; +static const uint8_t G4 = 4; +static const uint8_t G5 = 5; +static const uint8_t G6 = 6; +static const uint8_t G7 = 7; +static const uint8_t G8 = 8; +static const uint8_t G9 = 9; +static const uint8_t G11 = 11; +static const uint8_t G12 = 12; +static const uint8_t G13 = 13; +static const uint8_t G14 = 14; +static const uint8_t G17 = 17; +static const uint8_t G18 = 18; +static const uint8_t G19 = 19; +static const uint8_t G20 = 20; +static const uint8_t G21 = 21; +static const uint8_t G33 = 33; +static const uint8_t G34 = 34; +static const uint8_t G35 = 35; +static const uint8_t G36 = 36; +static const uint8_t G37 = 37; +static const uint8_t G38 = 38; +static const uint8_t G45 = 45; +static const uint8_t G46 = 46; + +static const uint8_t ADC = 10; + + +#define HAS_RTC +#define USB_as_HID + +#define HAS_TOUCH + +#define ALLOW_ALL_GPIO_FOR_IR_RF + +#define LED GROVE_SDA +#define LED_ON HIGH +#define LED_OFF LOW + +// Font sizes +#define FP 1 +#define FM 2 +#define FG 3 + +// Screen Setup +#define HAS_SCREEN +#define ROTATION 1 + +// TFT_eSPI Setup +#define USER_SETUP_LOADED +#define ILI9341_DRIVER +#define TFT_INVERSION_ON +#define USE_HSPI_PORT +#define M5STACK +#define TFT_HEIGHT 320 +#define TFT_WIDTH 220 +#define TFT_MOSI MOSI +#define TFT_MISO MISO +#define TFT_SCLK SCK +#define TFT_CS G3 +#define TFT_DC G35 +#define TFT_RST -1 +#define TFT_BL -1 +#define TOUCH_CS -1 +#define SMOOTH_FONT 1 +#define SPI_FREQUENCY 20000000 +#define SPI_READ_FREQUENCY 20000000 +#define SPI_TOUCH_FREQUENCY 2500000 + + +#define BTN_ALIAS '"Ok"' +#define BTN_PIN -1 +#define BTN_ACT LOW + +// SD Card Setup pins +#define SDCARD_CS G4 +#define SDCARD_SCK SCK +#define SDCARD_MISO MISO +#define SDCARD_MOSI MOSI + +// Default I2C port +#define GROVE_SDA 32 +#define GROVE_SCL 33 + +#define SPI_SCK_PIN 0 +#define SPI_MOSI_PIN GROVE_SDA +#define SPI_MISO_PIN GROVE_SCL +#define SPI_SS_PIN 26 +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/m5stack-cplus1_1.h b/boards/pinouts/m5stack-cplus1_1.h new file mode 100644 index 00000000..35092416 --- /dev/null +++ b/boards/pinouts/m5stack-cplus1_1.h @@ -0,0 +1,36 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t TXD2 = 33; +static const uint8_t RXD2 = 32; + +static const uint8_t SDA = 32; +static const uint8_t SCL = 33; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 15; +static const uint8_t MISO = 36; +static const uint8_t SCK = 13; + +static const uint8_t G9 = 9; +static const uint8_t G10 = 10; +static const uint8_t G37 = 37; +static const uint8_t G39 = 39; +static const uint8_t G32 = 32; +static const uint8_t G33 = 33; +static const uint8_t G26 = 26; +static const uint8_t G36 = 36; +static const uint8_t G0 = 0; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ diff --git a/boards/pinouts/m5stack-cplus2.h b/boards/pinouts/m5stack-cplus2.h new file mode 100644 index 00000000..91808918 --- /dev/null +++ b/boards/pinouts/m5stack-cplus2.h @@ -0,0 +1,33 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 32; +static const uint8_t SCL = 33; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 15; +static const uint8_t MISO = 36; +static const uint8_t SCK = 13; + +static const uint8_t G9 = 9; +static const uint8_t G10 = 10; +static const uint8_t G37 = 37; +static const uint8_t G39 = 39; +static const uint8_t G32 = 32; +static const uint8_t G33 = 33; +static const uint8_t G26 = 26; +static const uint8_t G36 = 36; +static const uint8_t G0 = 0; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/pins_arduino.h b/boards/pinouts/pins_arduino.h new file mode 100644 index 00000000..026ba536 --- /dev/null +++ b/boards/pinouts/pins_arduino.h @@ -0,0 +1,23 @@ +#ifdef T_EMBED_1101 +#include "lilygo-t-embed-cc1101.h" +#elif T_EMBED +#include "lilygo-t-embed.h" +#elif T_DECK +#include "lilygo-t-deck.h" +#elif ARDUINO_M5STACK_CARDPUTER +#include "m5stack-cardputer.h" +#elif CYD_2432S028 +#include "CYD-2432S028.h" +#elif ARDUINO_M5STACK_CORE +#include "m5stack-core.h" +#elif ARDUINO_M5STACK_CORES3 +#include "m5stack-cores3.h" +#elif ARDUINO_M5STACK_CORE2 +#include "m5stack-core2.h" +#elif ARDUINO_M5STICK_C_PLUS +#include "m5stack-cplus1_1.h" +#elif ARDUINO_M5STICK_C_PLUS2 +#include "m5stack-cplus2.h" +#elif ESP32S3DEVKITC1 +#include "ESP-General.h" +#endif diff --git a/boards/pinouts/variant.cpp b/boards/pinouts/variant.cpp new file mode 100644 index 00000000..ac53c414 --- /dev/null +++ b/boards/pinouts/variant.cpp @@ -0,0 +1,2 @@ +#define digitalWrite(pin, level) gpio_set_level((gpio_num_t)pin, level) +#define digitalRead(pin) gpio_get_level((gpio_num_t)pin) \ No newline at end of file diff --git a/build.bat b/build.bat deleted file mode 100644 index 603f1afa..00000000 --- a/build.bat +++ /dev/null @@ -1,13 +0,0 @@ -esptool --chip esp32s3 merge_bin --output Bruce3_Cardputer.bin 0x0 .pio\build\m5stack-cardputer\bootloader.bin 0x8000 .pio\build\m5stack-cardputer\partitions.bin 0x10000 .pio\build\m5stack-cardputer\firmware.bin - -esptool --chip esp32 merge_bin --output Bruce3_cplus2.bin 0x1000 .pio\build\m5stack-cplus2\bootloader.bin 0x8000 .pio\build\m5stack-cplus2\partitions.bin 0x10000 .pio\build\m5stack-cplus2\firmware.bin - -esptool --chip esp32 merge_bin --output Bruce3_cplus1_1.bin 0x1000 .pio\build\m5stack-cplus1_1\bootloader.bin 0x8000 .pio\build\m5stack-cplus1_1\partitions.bin 0x10000 .pio\build\m5stack-cplus1_1\firmware.bin - -esptool --chip esp32 merge_bin --output Bruce3_core2.bin 0x1000 .pio/build/m5stack-core2/bootloader.bin 0x8000 .pio/build/m5stack-core2/partitions.bin 0x10000 .pio/build/m5stack-core2/firmware.bin - -esptool --chip esp32 merge_bin --output Bruce3_core.bin 0x1000 .pio/build/m5stack-core/bootloader.bin 0x8000 .pio/build/m5stack-core/partitions.bin 0x10000 .pio/build/m5stack-core/firmware.bin - -esptool --chip esp32 merge_bin --output Bruce3_core4mb.bin 0x1000 .pio/build/m5stack-core4mb/bootloader.bin 0x8000 .pio/build/m5stack-core4mb/partitions.bin 0x10000 .pio/build/m5stack-core4mb/firmware.bin - -esptool --chip esp32s3 merge_bin --output Bruce3_T-Embed_CC1101.bin 0x0 .pio\build\lilygo-t-embed-cc1101\bootloader.bin 0x8000 .pio\build\lilygo-t-embed-cc1101\partitions.bin 0x10000 .pio\build\lilygo-t-embed-cc1101\firmware.bin \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index 7f5456d5..00000000 --- a/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -ESPTOOL_PATH="$HOME/.local/bin" -ESPTOOL=$([[ -f $ESPTOOL_PATH/esptool.py ]] && echo "$ESPTOOL_PATH/esptool.py" || echo "$ESPTOOL_PATH/esptool") - -$ESPTOOL --chip esp32s3 merge_bin --output Bruce3_Cardputer.bin 0x0 .pio/build/m5stack-cardputer/bootloader.bin 0x8000 .pio/build/m5stack-cardputer/partitions.bin 0x10000 .pio/build/m5stack-cardputer/firmware.bin -$ESPTOOL --chip esp32 merge_bin --output Bruce3_cplus2.bin 0x1000 .pio/build/m5stack-cplus2/bootloader.bin 0x8000 .pio/build/m5stack-cplus2/partitions.bin 0x10000 .pio/build/m5stack-cplus2/firmware.bin -$ESPTOOL --chip esp32 merge_bin --output Bruce3_cplus1_1.bin 0x1000 .pio/build/m5stack-cplus1_1/bootloader.bin 0x8000 .pio/build/m5stack-cplus1_1/partitions.bin 0x10000 .pio/build/m5stack-cplus1_1/firmware.bin -$ESPTOOL --chip esp32 merge_bin --output Bruce3_core2.bin 0x1000 .pio/build/m5stack-core2/bootloader.bin 0x8000 .pio/build/m5stack-core2/partitions.bin 0x10000 .pio/build/m5stack-core2/firmware.bin -$ESPTOOL --chip esp32 merge_bin --output Bruce3_core16mb.bin 0x1000 .pio/build/m5stack-core16mb/bootloader.bin 0x8000 .pio/build/m5stack-core16mb/partitions.bin 0x10000 .pio/build/m5stack-core16mb/firmware.bin -$ESPTOOL --chip esp32 merge_bin --output Bruce3_core4mb.bin 0x1000 .pio/build/m5stack-core4mb/bootloader.bin 0x8000 .pio/build/m5stack-core4mb/partitions.bin 0x10000 .pio/build/m5stack-core4mb/firmware.bin diff --git a/clean.sh b/clean.sh deleted file mode 100755 index 05da95ca..00000000 --- a/clean.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -rm -f Bruce3_* \ No newline at end of file diff --git a/deauth_setup.bat b/deauth_setup.bat deleted file mode 100644 index 0fb11fa6..00000000 --- a/deauth_setup.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem Define file paths -set "esp32_file=%userprofile%\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib\libnet80211.a" -set "esp32s3_file=%userprofile%\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32s3\lib\libnet80211.a" - -set "esp32_file2=%userprofile%\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib\libnet80211_temp.a" -set "esp32s3_file2=%userprofile%\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32s3\lib\libnet80211_temp.a" - -rem Now execute objcopy commands (only if backups were created) -"%userprofile%"\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\bin\objcopy --weaken-symbol=ieee80211_raw_frame_sanity_check "%esp32_file%" "%esp32_file2%" - -rem Rename the original file to .old -ren "%esp32_file%" "libnet80211.a.old" - -rem Rename the _temp to original -ren "%esp32_file2%" "libnet80211.a" - -rem Now execute objcopy commands (only if backups were created) -"%userprofile%"\.platformio\packages\toolchain-xtensa-esp32s3\xtensa-esp32s3-elf\bin\objcopy --weaken-symbol=ieee80211_raw_frame_sanity_check "%esp32s3_file%" "%esp32s3_file2%" - -rem Rename the original file to .old -ren "%esp32s3_file%" "libnet80211.a.old" - -rem Rename the _temp to original -ren "%esp32s3_file2%" "libnet80211.a" - - -PAUSE - diff --git a/deauth_setup.sh b/deauth_setup.sh deleted file mode 100755 index 8504357a..00000000 --- a/deauth_setup.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# Define paths with proper home expansion - -pio pkg install -p espressif32 -t toolchain-xtensa32 - -esp32_file="$HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/lib/libnet80211.a" -esp32s3_file="$HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32s3/lib/libnet80211.a" - -esp32_file_temp="$HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/lib/libnet80211_temp.a" -esp32s3_file_temp="$HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32s3/lib/libnet80211_temp.a" - -# Definir caminhos para as ferramentas objcopy -toolchain_esp32="$HOME/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/bin/objcopy" -toolchain_esp32s3="$HOME/.platformio/packages/toolchain-xtensa-esp32s3/xtensa-esp32s3-elf/bin/objcopy" - -# Verificar se os arquivos existem antes de executar os comandos -if [[ -f "$esp32_file" && -f "$esp32s3_file" ]]; then - # Execute objcopy commands for ESP32 - $toolchain_esp32 --weaken-symbol=ieee80211_raw_frame_sanity_check "$esp32_file" "$esp32_file_temp" - - # Rename the original file to .old - mv "$esp32_file" "${esp32_file}.old" - - # Rename the _temp to original - mv "$esp32_file_temp" "$esp32_file" - - # Execute objcopy commands for ESP32-S3 - $toolchain_esp32s3 --weaken-symbol=ieee80211_raw_frame_sanity_check "$esp32s3_file" "$esp32s3_file_temp" - - # Rename the original file to .old - mv "$esp32s3_file" "${esp32s3_file}.old" - - # Rename the _temp to original - mv "$esp32s3_file_temp" "$esp32s3_file" - - echo "Done." -else - echo "One or more specified files were not found." - exit 1 -fi diff --git a/src/core/globals.h b/include/globals.h similarity index 90% rename from src/core/globals.h rename to include/globals.h index 4c78510b..190392f2 100644 --- a/src/core/globals.h +++ b/include/globals.h @@ -1,6 +1,6 @@ #pragma once -#include "precompiler_flags.h" -#include "interface.h" +#include +#include // Globals.h #define ALCOLOR TFT_RED @@ -14,8 +14,8 @@ #include #include #include -#include "config.h" -#include "startup_app.h" +#include "core/config.h" +#include "core/startup_app.h" #if defined(HAS_RTC) #include "../lib/RTC/cplus_RTC.h" @@ -28,7 +28,7 @@ extern TFT_eSprite sprite; extern TFT_eSprite draw; #else - #include "VectorDisplay.h" + #include "core/VectorDisplay.h" extern SerialDisplayClass tft; extern SerialDisplayClass& sprite; extern SerialDisplayClass& draw; @@ -55,6 +55,9 @@ extern bool sdcardMounted; // inform if SD Cardis active or not extern bool wifiConnected; // inform if wifi is active or not +extern volatile int tftWidth; +extern volatile int tftHeight; + extern String wifiIP; extern bool BLEConnected; // inform if BLE is active or not @@ -87,10 +90,6 @@ extern unsigned long previousMillis; extern bool isSleeping; extern bool isScreenOff; -void backToMenu(); - -void updateTimeStr(struct tm timeInfo); - extern bool dimmer; void setup_gpio(); diff --git a/ports/_New-Device-Model/interface.h b/include/interface.h similarity index 100% rename from ports/_New-Device-Model/interface.h rename to include/interface.h diff --git a/include/precompiler_flags.h b/include/precompiler_flags.h new file mode 100644 index 00000000..ccc217e5 --- /dev/null +++ b/include/precompiler_flags.h @@ -0,0 +1,122 @@ +#pragma once +/* This file has the purpose to verify the existence of some default flags */ +/* Only PreCompiler code must be set in this file */ + + +#ifndef REDRAW_DELAY // Delay time used to "debounce" btns on screen interactions (specially next and previous checks) + #define REDRAW_DELAY 200 // 200ms is enough for all devices, but it's too large for Encodered devices such as T-Embed, that uses Zero +#endif + +#ifndef GROVE_SDA // Pin to be used in I2C communications + #define GROVE_SDA -1 +#endif +#ifndef GROVE_SCL // Pin to be used in I2C communications + #define GROVE_SCL -1 +#endif +#ifndef RXLED // Default RX Infrared LED + #define RXLED GROVE_SCL +#endif +#ifndef LED // Default TC Infrared Led + #define LED GROVE_SDA +#endif +#ifndef LED_ON // Infrared LED On state + #define LED_ON 1 +#endif +#ifndef LED_OFF // Infrared LED Off state + #define LED_OFF 0 +#endif +#ifndef FP // Small Font -> Font Pequena + #define FP 1 +#endif +#ifndef FM // Medium Font -> Fonte Media + #define FM 2 +#endif +#ifndef FG // LArge Font -> Fonte Grande + #define FG 3 +#endif +#ifndef ROTATION + #define ROTATION 1 +#endif +#ifndef TFT_WIDTH + #define TFT_WIDTH 240 +#endif +#ifndef TFT_HEIGHT + #define TFT_HEIGHT 135 +#endif + +// Default initializers +#ifndef TFT_CS + #define TFT_CS -1 +#endif +#ifndef TFT_RST + #define TFT_RST -1 +#endif +#ifndef TFT_SCLK + #define TFT_SCLK -1 +#endif +#ifndef TFT_MOSI + #define TFT_MOSI -1 +#endif +#ifndef TFT_BL + #define TFT_BL -1 +#endif +#ifndef TOUCH_CS + #define TOUCH_CS -1 +#endif +#ifndef SDCARD_MOSI + #define SDCARD_MOSI -1 +#endif +#ifndef SDCARD_MISO + #define SDCARD_MISO -1 +#endif +#ifndef SDCARD_CS + #define SDCARD_CS -1 +#endif +#ifndef SDCARD_SCK + #define SDCARD_SCK -1 +#endif + +#ifndef SERIAL_TX // Serial TX used for GPS communications -> To use in other boards + #define SERIAL_TX GROVE_SDA +#endif + +#ifndef SERIAL_RX // Serial RX used for GPS communications -> To use in other boards + #define SERIAL_RX GROVE_SCL +#endif + + +//This one sets an array to set create the options to devices that have all GPIO available to use (except tft and SD Card) +#define GPIO_PIN_LIST { \ + {"GPIO 1", 1}, {"GPIO 2", 2}, {"GPIO 3", 3}, {"GPIO 4", 4}, {"GPIO 6", 6}, {"GPIO 7", 7}, {"GPIO 8", 8}, {"GPIO 9", 9}, {"GPIO 10", 10}, \ + {"GPIO 11", 11}, {"GPIO 16", 16}, {"GPIO 17", 17}, {"GPIO 18", 18}, {"GPIO 19", 19}, {"GPIO 20", 20}, {"GPIO 21", 21}, {"GPIO 22", 22}, \ + {"GPIO 23", 23}, {"GPIO 24", 24}, {"GPIO 25", 25}, {"GPIO 28", 28}, {"GPIO 29", 29}, {"GPIO 30", 30}, {"GPIO 31", 31}, {"GPIO 32", 32}, \ + {"GPIO 33", 33}, {"GPIO 34", 34}, {"GPIO 35", 35}, {"GPIO 37", 37}, {"GPIO 38", 38}, {"GPIO 39", 39}, {"GPIO 40", 40}, {"GPIO 41", 41}, \ + {"GPIO 42", 42}, {"GPIO 43", 43}, {"GPIO 44", 44} \ +} +#ifdef ALLOW_ALL_GPIO_FOR_IR_RF + #undef IR_TX_PINS + #undef IR_RX_PINS + #undef RF_TX_PINS + #undef RF_RX_PINS + + #define IR_TX_PINS GPIO_PIN_LIST + #define IR_RX_PINS GPIO_PIN_LIST + #define RF_TX_PINS GPIO_PIN_LIST + #define RF_RX_PINS GPIO_PIN_LIST +#endif +#if !defined(IR_TX_PINS) || !defined(IR_RX_PINS) || !defined(RF_TX_PINS) || !defined(RF_RX_PINS) + #define IR_TX_PINS GPIO_PIN_LIST + #define IR_RX_PINS GPIO_PIN_LIST + #define RF_TX_PINS GPIO_PIN_LIST + #define RF_RX_PINS GPIO_PIN_LIST +#endif + + + +// Temporary, delete after finish Interfaces +#ifndef SEL_BTN +#define SEL_BTN -1 +#define UP_BTN -1 +#define DW_BTN -1 +#define BTN_ACT LOW +#endif \ No newline at end of file diff --git a/lib/M5GFX/src/M5GFX.cpp b/lib/M5GFX/src/M5GFX.cpp index 7ec726b2..b960e755 100644 --- a/lib/M5GFX/src/M5GFX.cpp +++ b/lib/M5GFX/src/M5GFX.cpp @@ -846,7 +846,7 @@ namespace m5gfx // fore Core2 1st gen (AXP192) // AXP192_LDO2 = LCD PWR // AXP192_IO4 = LCD RST - // AXP192_DC3 = LCD BL (Core2) + // AXP192_DC3 = LCD BL (ARDUINO_M5STACK_CORE2) // AXP192_LDO3 = LCD BL (Tough) // AXP192_IO1 = TP RST (Tough) static constexpr uint8_t reg_data_axp192_first[] = { diff --git a/lib/M5GFX/src/lgfx/v1/LGFXBase.hpp b/lib/M5GFX/src/lgfx/v1/LGFXBase.hpp index e52359c6..5afafffb 100644 --- a/lib/M5GFX/src/lgfx/v1/LGFXBase.hpp +++ b/lib/M5GFX/src/lgfx/v1/LGFXBase.hpp @@ -61,8 +61,8 @@ namespace lgfx public: LGFXBase(void) = default; virtual ~LGFXBase(void) = default; - static constexpr uint16_t tftwidth = WIDTH; - static constexpr uint16_t tftheight = HEIGHT; + static constexpr uint16_t tftwidth = TFT_WIDTH; + static constexpr uint16_t tftheight = TFT_HEIGHT; static constexpr uint16_t textsize = 2; static constexpr uint16_t textcolor = TFT_GREEN; static constexpr uint16_t textbgcolor = TFT_BLACK; diff --git a/lib/TFT_eSPI/TFT_Drivers/ILI9341_Init.h b/lib/TFT_eSPI/TFT_Drivers/ILI9341_Init.h index 5bb75ec8..3241724b 100644 --- a/lib/TFT_eSPI/TFT_Drivers/ILI9341_Init.h +++ b/lib/TFT_eSPI/TFT_Drivers/ILI9341_Init.h @@ -4,7 +4,7 @@ // This setup information uses simple 8-bit SPI writecommand() and writedata() functions // // See ST7735_Setup.h file for an alternative format -#if defined(CORE2) +#if defined(ARDUINO_M5STACK_CORE2) { writecommand(0xC8); writedata(0xFF); diff --git a/lib/utility/Keyboard.cpp b/lib/utility/Keyboard.cpp index cc4fe92c..c1d89680 100644 --- a/lib/utility/Keyboard.cpp +++ b/lib/utility/Keyboard.cpp @@ -1,4 +1,4 @@ -#ifdef CARDPUTER +#ifdef ARDUINO_M5STACK_CARDPUTER /** * @file keyboard.cpp * @author Forairaaaaa diff --git a/lib/utility/Keyboard.h b/lib/utility/Keyboard.h index c8d3f0d5..c7c9d461 100644 --- a/lib/utility/Keyboard.h +++ b/lib/utility/Keyboard.h @@ -1,4 +1,4 @@ -#ifdef CARDPUTER +#ifdef ARDUINO_M5STACK_CARDPUTER /** * @file keyboard.h * @author Forairaaaaa @@ -13,7 +13,6 @@ #include #include #include "Arduino.h" -#include "Keyboard_def.h" struct Chart_t { diff --git a/patch.py b/patch.py new file mode 100644 index 00000000..0e07d31f --- /dev/null +++ b/patch.py @@ -0,0 +1,27 @@ +from os.path import join, isfile +from os import rename, remove +import sys + +Import("env") + +FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoespressif32") +patchflag_path = join(FRAMEWORK_DIR, ".patched") +board_mcu = env.BoardConfig() +mcu = board_mcu.get("build.mcu", "") + +# patch file only if we didn't do it befored +if not isfile(join(FRAMEWORK_DIR, ".patched")): + original_file = join(FRAMEWORK_DIR, "tools", "sdk", mcu, "lib", "libnet80211.a") + patched_file = join(FRAMEWORK_DIR, "tools", "sdk", mcu, "lib", "libnet80211.a.patched") + + env.Execute("pio pkg exec -p toolchain-xtensa-%s -- xtensa-%s-elf-objcopy --weaken-symbol=s %s %s" % (mcu, mcu, original_file, patched_file)) + if(isfile("%s.old"%(original_file))): + remove("%s.old"%(original_file)) + rename(original_file,"%s.old"%(original_file)) + env.Execute("pio pkg exec -p toolchain-xtensa-%s -- xtensa-%s-elf-objcopy --weaken-symbol=ieee80211_raw_frame_sanity_check %s %s" % (mcu, mcu, patched_file, original_file)) + + def _touch(path): + with open(path, "w") as fp: + fp.write("") + + env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) diff --git a/ports/CYD-2432S028/interface.h b/ports/CYD-2432S028/interface.h deleted file mode 100644 index 863c20c0..00000000 --- a/ports/CYD-2432S028/interface.h +++ /dev/null @@ -1,136 +0,0 @@ -#pragma once -#include -#include - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - -/*************************************************************************************** -** Function name: _post_setup_gpio() -** Location: main.cpp -** Description: second stage gpio setup to make a few functions work -***************************************************************************************/ -void _post_setup_gpio(); - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/ESP-General/interface.h b/ports/ESP-General/interface.h deleted file mode 100644 index 844098c6..00000000 --- a/ports/ESP-General/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/_New-Device-Model/platformio.ini b/ports/_New-Device-Model/platformio.ini deleted file mode 100644 index 8f536120..00000000 --- a/ports/_New-Device-Model/platformio.ini +++ /dev/null @@ -1,153 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:NewDeviceModel] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = m5stack-stamps3 -framework = arduino -board_build.partitions = custom_8Mb.csv -build_flags = - ${env.build_flags} - -Iports/_New-Device-Model - -Os - -DCORE_DEBUG_LEVEL=5 - ;-DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work - - -DNEW_DEVICE=1 ;key for new device, - ;mykeyboard.cpp: need map buttons an/or touchscreen and battery status value, - ;settings.cpp: need map brighness control - ;main.cpp: need set startup - ;serialcmds.cpp: need set power off command - - ;Features Enabled - # Config to use IRQ and RST pins of PN532, if needed - ;-DPN532_RF_REST=-1 - ;-DPN532_IRQ=-1 - - ;FM Radio - ;-DFM_SI4713=1 ;Uncomment to activate FM Radio using Adafruit Si4713 - -DFM_RSTPIN=40 - ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility - ;Microphone - ;-DMIC_SPM1423=1 ;uncomment to enable Applicable for SPM1423 device - -DPIN_CLK=43 - -DI2S_SCLK_PIN=43 - -DI2S_DATA_PIN=46 - -DPIN_DATA=46 - - ;RGB LED runned by xylopyrographer/LiteLED@^1.2.0 library - ;-DHAS_RGB_LED=1 ;uncomment to enable - -DRGB_LED=21 - - ;Have RTC Chip - ;-DHAS_RTC=1 - - ;Speaker to run music, compatible with NS4168 - ;-DHAS_NS4168_SPKR=1 ;uncomment to enable - -DBCLK=41 - -DWCLK=43 - -DDOUT=42 - - ;Can run USB as HID - ;-DUSB_as_HID=1 ;uncomment to enable - -DBAD_TX=GROVE_SDA - -DBAD_RX=GROVE_SCL - - ;Battery ADC read pin - ;-DBAT_PIN=10 - - ;Buttons configuration - -DHAS_BTN=0 - -DBTN_ALIAS='"Ok"' - -DBTN_PIN=0 - -DBTN_ACT=LOw - - ;-DALLOW_ALL_GPIO_FOR_IR_RF=1 ; Set this option to make use of all GPIOs, from 1 to 44 to be chosen, except TFT and SD pins - - ;Infrared Led default pin and state - -DIR_TX_PINS='{{"M5 IR Mod", GROVE_SDA}, {"Pin 1", 1}, {"Pin 2", 2}}' - -DIR_RX_PINS='{{"M5 IR Mod", GROVE_SCL}, {"Pin 1", 1}, {"Pin 2", 2}}' - -DLED=-1 ;NEED TO SET SOMETHING HERE, at least -1 - -DLED_ON=HIGH - -DLED_OFF=LOW - - ;Radio Frequency (one pin modules) pin setting - -DRF_TX_PINS='{{"M5 RF433T", GROVE_SDA}, {"Pin 1", 1}, {"Pin 2", 2}}' - -DRF_RX_PINS='{{"M5 FR433R", GROVE_SCL}, {"Pin 1", 1}, {"Pin 2", 2}}' - - ;CC1101 SPI connection pins - ; best connection pins for higher speed https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/spi_master.html#gpio-matrix-and-io-mux - ;-DUSE_CC1101_VIA_SPI - -DCC1101_GDO0_PIN=9 - -DCC1101_SS_PIN=10 - -DCC1101_MOSI_PIN=SPI_MOSI_PIN - -DCC1101_SCK_PIN=SPI_SCK_PIN - -DCC1101_MISO_PIN=SPI_MISO_PIN - ;-DCC1101_GDO2_PIN=14 ; optional - - ; connections are the same as CC1101 - ;-DUSE_NRF24_VIA_SPI - -DNRF24_CE_PIN=6 - -DNRF24_SS_PIN=7 ; chip select - -DNRF24_MOSI_PIN=SPI_MOSI_PIN - -DNRF24_SCK_PIN=SPI_SCK_PIN - -DNRF24_MISO_PIN=SPI_MISO_PIN - - ;Font sizes, depending on device - -DFP=1 - -DFM=2 - -DFG=3 - - ;Screen Setup - -DHAS_SCREEN=1 - -DROTATION=1 - -DWIDTH=240 - -DHEIGHT=135 - -DBACKLIGHT=38 - -DMINBRIGHT=160 - - ;TFT_eSPI Setup - -DUSER_SETUP_LOADED=1 - -DUSE_HSPI_PORT=1 - -DST7789_2_DRIVER=1 - -DTFT_RGB_ORDER=1 - -DTFT_WIDTH=135 - -DTFT_HEIGHT=240 - -DTFT_BACKLIGHT_ON=1 - -DTFT_BL=38 - -DTFT_RST=33 - -DTFT_DC=34 - -DTFT_MOSI=35 - -DTFT_SCLK=36 - -DTFT_CS=37 - -DTOUCH_CS=-1 - -DSMOOTH_FONT=1 - -DSPI_FREQUENCY=20000000 - -DSPI_READ_FREQUENCY=20000000 - -DSPI_TOUCH_FREQUENCY=2500000 - - ;SD Card Setup pins - -DSDCARD_CS=12 - -DSDCARD_SCK=40 - -DSDCARD_MISO=39 - -DSDCARD_MOSI=14 - - ;Default I2C port - -DGROVE_SDA=2 - -DGROVE_SCL=1 - - -DSPI_SCK_PIN=12 - -DSPI_MOSI_PIN=11 - -DSPI_MISO_PIN=13 - -DSPI_SS_PIN=10 - -lib_deps = - ${env.lib_deps} - xylopyrographer/LiteLED@^1.2.0 diff --git a/ports/lilygo-t-deck/interface.h b/ports/lilygo-t-deck/interface.h deleted file mode 100644 index b4d3fa09..00000000 --- a/ports/lilygo-t-deck/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -#define HAS_KEYBOARD //has keyboard to use -#define HAS_KEYBOARD_HID //has keyboard to use -#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/lilygo-t-embed-cc1101/interface.h b/ports/lilygo-t-embed-cc1101/interface.h deleted file mode 100644 index 047e398f..00000000 --- a/ports/lilygo-t-embed-cc1101/interface.h +++ /dev/null @@ -1,133 +0,0 @@ -#pragma once -#include -#include - -#define RFID125_RX_PIN 44 -#define RFID125_TX_PIN 43 - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/lilygo-t-embed-cc1101/platformio.ini b/ports/lilygo-t-embed-cc1101/platformio.ini deleted file mode 100644 index 3b4ff79e..00000000 --- a/ports/lilygo-t-embed-cc1101/platformio.ini +++ /dev/null @@ -1,345 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -#################################### EStart OF LILYGO MODELS ####################################### -[env:lilygo-t-embed-cc1101] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = lilygo-t-display-s3 -framework = arduino -board_build.partitions = custom_16Mb.csv -build_src_filter =${env.build_src_filter} +<../ports/lilygo-t-embed-cc1101> -build_flags = - ${env.build_flags} - -Iports/lilygo-t-embed-cc1101 - -Os - -DBOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue - -mfix-esp32-psram-cache-strategy=memw - -DCORE_DEBUG_LEVEL=5 - -DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work - -DREDRAW_DELAY=1 # Used to improve navigation on menus for this device - - -DT_EMBED=1 ;key for new device, - -DT_EMBED_1101=1 ;mykeyboard.cpp: need map buttons an/or touchscreen and battery status value, - ;settings.cpp: need map brighness control - ;main.cpp: need set startup - ;serialcmds.cpp: need set power off command - -DBOARD_LORA_SW1=47 - -DBOARD_LORA_SW0=48 - - # Config to use IRQ and RST pins of PN532, if needed - -DPN532_RF_REST=45 - -DPN532_IRQ=17 - - ;Features Enabled - ;FM Radio - ;-DFM_SI4713=1 ;Uncomment to activate FM Radio using Adafruit Si4713 - -DFM_RSTPIN=40 - ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility - ;Microphone - -DMIC_SPM1423=1 ;uncomment to enable Applicable for SPM1423 device - -DPIN_CLK=39 - -DI2S_SCLK_PIN=39 - -DI2S_DATA_PIN=42 - -DPIN_DATA=42 - - ;RGB LED runned by xylopyrographer/LiteLED@^1.2.0 library - ;-DHAS_RGB_LED=1 ;uncomment to enable - -DRGB_LED=21 - - ;Have RTC Chip - ;-DHAS_RTC=1 - - ; SERIAL (GPS) dedicated pins - -DSERIAL_TX=43 ;may be wrong - -DSERIAL_RX=44 - - ;Speaker to run music, compatible with NS4168 - -DHAS_NS4168_SPKR=1 ;uncomment to enable - -DBCLK=46 - -DWCLK=40 - -DDOUT=7 - -DMCLK=39 # Microphone CLK - - ;Can run USB as HID - -DUSB_as_HID=1 ;uncomment to enable - ;-DBAD_TX=GROVE_SDA - ;-DBAD_RX=GROVE_SCL - - ;Battery ADC read pin - ;-DBAT_PIN=10 - - ;BQ27220 Fuel Gauge - -DBQ27220_I2C_ADDRESS=0x55 - -DBQ27220_I2C_SDA=GROVE_SDA - -DBQ27220_I2C_SCL=GROVE_SCL - - ;Buttons configuration - -DHAS_BTN=1 - -DBTN_ALIAS='"Mid"' - -DSEL_BTN=0 - -DUP_BTN=-1 ;Dont have btns, use a encoder - -DDW_BTN=-1 ;Dont have btns, use a encoder - -DBK_BTN=6 - -DBTN_ACT=LOW - - -DENCODER_INA=4 - -DENCODER_INB=5 - -DENCODER_KEY=0 - - ;-DALLOW_ALL_GPIO_FOR_IR_RF=1 ; Set this option to make use of all GPIOs, from 1 to 44 to be chosen, except TFT and SD pins - - ;Infrared Led default pin and state - -DIR_TX_PINS='{{"Default", 2}, {"Pin 43", 43}, {"Pin 44", 44}}' - -DIR_RX_PINS='{{"Default", 1}, {"Pin 43", 43}, {"Pin 44", 44}}' - -DLED=2 ;NEED TO SET SOMETHING HERE, at least -1 - -DRXLED=1 - -DLED_ON=HIGH - -DLED_OFF=LOW - - ;Radio Frequency (one pin modules) pin setting - -DRF_TX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}' - -DRF_RX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}' - - ;CC1101 SPI connection pins - ; best connection pins for higher speed https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/spi_master.html#gpio-matrix-and-io-mux - -DUSE_CC1101_VIA_SPI - -DCC1101_GDO0_PIN=3 ; or 38, or 47 or 48? - -DCC1101_SS_PIN=12 - -DCC1101_MOSI_PIN=SPI_MOSI_PIN - -DCC1101_SCK_PIN=SPI_SCK_PIN - -DCC1101_MISO_PIN=SPI_MISO_PIN - -DCC1101_GDO2_PIN=38 ; optional - - ; connections are the same as CC1101 - -DUSE_NRF24_VIA_SPI - -DNRF24_CE_PIN=43 ; left Grove - -DNRF24_SS_PIN=44 ; chip select - -DNRF24_MOSI_PIN=SDCARD_MOSI - -DNRF24_SCK_PIN=SDCARD_SCK - -DNRF24_MISO_PIN=SDCARD_MISO - - ;Font sizes, depending on device - -DFP=1 - -DFM=2 - -DFG=3 - - ;Screen Setup - -DHAS_SCREEN=1 - -DROTATION=3 - -DWIDTH=320 - -DHEIGHT=170 - -DBACKLIGHT=TFT_BL - -DMINBRIGHT=1 - -DPIN_POWER_ON=15 - - ;TFT_eSPI display - -DUSER_SETUP_LOADED=1 - -DUSE_HSPI_PORT=1 - -DST7789_DRIVER=1 - -DTFT_WIDTH=170 - -DTFT_HEIGHT=320 - -DTFT_INVERSION_ON - -DTFT_BL=21 - -DTFT_MISO=SPI_MISO_PIN - -DTFT_MOSI=SPI_MOSI_PIN - -DTFT_SCLK=SPI_SCK_PIN - -DTFT_CS=41 - -DTFT_DC=16 - -DTFT_RST=-1 - -DTOUCH_CS=-1 - -DSMOOTH_FONT=1 - -DSPI_FREQUENCY=80000000 - -DSPI_READ_FREQUENCY=20000000 - -DSPI_TOUCH_FREQUENCY=2500000 - - ;SD Card Setup pins - -DSDCARD_CS=13 - -DSDCARD_SCK=SPI_SCK_PIN - -DSDCARD_MISO=SPI_MISO_PIN - -DSDCARD_MOSI=SPI_MOSI_PIN - - ;Default I2C port - -DGROVE_SDA=8 - -DGROVE_SCL=18 - - -DSPI_SCK_PIN=11 - -DSPI_MOSI_PIN=9 - -DSPI_MISO_PIN=10 - -DSPI_SS_PIN=8 - -lib_deps = - ${env.lib_deps} - lewisxhe/XPowersLib @0.2.6 - mathertel/RotaryEncoder @1.5.3 - - -[env:lilygo-t-embed] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = lilygo-t-display-s3 -framework = arduino -board_build.partitions = custom_16Mb.csv -build_src_filter =${env.build_src_filter} +<../ports/lilygo-t-embed-cc1101> -build_flags = - ${env.build_flags} - -Iports/lilygo-t-embed-cc1101 - -Os - -DBOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue - -mfix-esp32-psram-cache-strategy=memw - -DCORE_DEBUG_LEVEL=5 - -DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work - -DREDRAW_DELAY=1 # Used to improve navigation on menus for this device - - -DT_EMBED=1 ;key for new device, - ;-DT_EMBED_1101=1 ;mykeyboard.cpp: need map buttons an/or touchscreen and battery status value, - ;settings.cpp: need map brighness control - ;main.cpp: need set startup - ;serialcmds.cpp: need set power off command - - ;Features Enabled - ;FM Radio - ;-DFM_SI4713=1 ;Uncomment to activate FM Radio using Adafruit Si4713 - -DFM_RSTPIN=40 - ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility - ;Microphone - -DMIC_SPM1423=1 ;uncomment to enable Applicable for SPM1423 device - -DPIN_CLK=21 - -DI2S_SCLK_PIN=21 - -DI2S_DATA_PIN=14 - -DPIN_DATA=14 - - ;RGB LED runned by xylopyrographer/LiteLED@^1.2.0 library - ;-DHAS_RGB_LED=1 ;uncomment to enable - -DRGB_LED=21 - - ;Have RTC Chip - ;-DHAS_RTC=1 - - ; SERIAL (GPS) dedicated pins - -DSERIAL_TX=43 ;may be wrong - -DSERIAL_RX=44 - - ;Speaker to run music, compatible with NS4168 - -DHAS_NS4168_SPKR=1 ;uncomment to enable - -DBCLK=7 - -DWCLK=5 - -DDOUT=6 - -DMCLK=39 # Microphone CLK - - ;Can run USB as HID - -DUSB_as_HID=1 ;uncomment to enable - ;-DBAD_TX=GROVE_SDA - ;-DBAD_RX=GROVE_SCL - - ;Battery ADC read pin - -DBAT_PIN=4 - - ;Buttons configuration - -DHAS_BTN=1 - -DBTN_ALIAS='"Mid"' - -DSEL_BTN=0 - -DUP_BTN=-1 ;Dont have btns, use a encoder - -DDW_BTN=-1 ;Dont have btns, use a encoder - ;-DBK_BTN=6 ;Dont have this btn at all! - -DBTN_ACT=LOW - - -DENCODER_INA=2 - -DENCODER_INB=1 - -DENCODER_KEY=0 - - ;-DALLOW_ALL_GPIO_FOR_IR_RF=1 ; Set this option to make use of all GPIOs, from 1 to 44 to be chosen, except TFT and SD pins - - ;Infrared Led default pin and state - -DIR_TX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' - -DIR_RX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' - -DLED=44 - -DRXLED=43 - -DLED_ON=HIGH - -DLED_OFF=LOW - - ;Radio Frequency (one pin modules) pin setting - -DRF_TX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' - -DRF_RX_PINS='{{"Pin 16", 16},{"Pin 17", 17}, {"Pin 43", 43}, {"Pin 44", 44}}' - - ;CC1101 SPI connection pins - ; best connection pins for higher speed https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/spi_master.html#gpio-matrix-and-io-mux - -DUSE_CC1101_VIA_SPI - -DCC1101_GDO0_PIN=44 - -DCC1101_SS_PIN=43 - -DCC1101_MOSI_PIN=SPI_MOSI_PIN - -DCC1101_SCK_PIN=SPI_SCK_PIN - -DCC1101_MISO_PIN=SPI_MISO_PIN - ;-DCC1101_GDO2_PIN=14 ; optional - - ; connections are the same as CC1101 - -DUSE_NRF24_VIA_SPI - -DNRF24_CE_PIN=44 - -DNRF24_SS_PIN=43 - -DNRF24_MOSI_PIN=SDCARD_MOSI - -DNRF24_SCK_PIN=SDCARD_SCK - -DNRF24_MISO_PIN=SDCARD_MISO - - ;Font sizes, depending on device - -DFP=1 - -DFM=2 - -DFG=3 - - ;Screen Setup - -DHAS_SCREEN=1 - -DROTATION=3 - -DWIDTH=320 - -DHEIGHT=170 - -DBACKLIGHT=TFT_BL - -DMINBRIGHT=1 - -DPIN_POWER_ON=46 - - ;TFT_eSPI display - -DUSER_SETUP_LOADED=1 - -DUSE_HSPI_PORT=1 - -DST7789_DRIVER=1 - -DTFT_WIDTH=170 - -DTFT_HEIGHT=320 - -DTFT_RGB_ORDER=TFT_RGB - -DTFT_INVERSION_ON - -DTFT_BL=15 - -DTFT_MISO=-1 - -DTFT_MOSI=11 - -DTFT_SCLK=12 - -DTFT_CS=10 - -DTFT_DC=13 - -DTFT_RST=9 - -DTOUCH_CS=-1 - -DSMOOTH_FONT=1 - -DSPI_FREQUENCY=40000000 - -DSPI_READ_FREQUENCY=20000000 - -DSPI_TOUCH_FREQUENCY=2500000 - - ;SD Card Setup pins - -DSDCARD_CS=39 - -DSDCARD_SCK=40 - -DSDCARD_MISO=38 - -DSDCARD_MOSI=41 - - ;Default I2C port - -DGROVE_SDA=44 - -DGROVE_SCL=43 - - -DSPI_SCK_PIN=40 - -DSPI_MOSI_PIN=41 - -DSPI_MISO_PIN=38 - -DSPI_SS_PIN=17 - -lib_deps = - ${env.lib_deps} - lewisxhe/XPowersLib @0.2.6 - mathertel/RotaryEncoder @1.5.3 - -#################################### END OF LILYGO MODELS ####################################### diff --git a/ports/m5stack-cardputer/interface.h b/ports/m5stack-cardputer/interface.h deleted file mode 100644 index a4cfd0a3..00000000 --- a/ports/m5stack-cardputer/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -#define HAS_KEYBOARD //has keyboard to use -#define HAS_KEYBOARD_HID //has keyboard to use -#define KB_HID_EXIT_MSG "fn + esc to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/m5stack-core/interface.h b/ports/m5stack-core/interface.h deleted file mode 100644 index 844098c6..00000000 --- a/ports/m5stack-core/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/m5stack-core2/interface.h b/ports/m5stack-core2/interface.h deleted file mode 100644 index 844098c6..00000000 --- a/ports/m5stack-core2/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/m5stack-cores3/interface.h b/ports/m5stack-cores3/interface.h deleted file mode 100644 index 844098c6..00000000 --- a/ports/m5stack-cores3/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/m5stack-cores3/platformio.ini b/ports/m5stack-cores3/platformio.ini deleted file mode 100644 index 444ea0a0..00000000 --- a/ports/m5stack-cores3/platformio.ini +++ /dev/null @@ -1,136 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:m5stack-cores3] -platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip -board = m5stack-cores3 -framework = arduino -monitor_speed = 115200 -board_build.partitions = custom_16Mb.csv -board_upload.flash_size = 16MB -board_upload.maximum_size = 16777216 -build_src_filter =${env.build_src_filter} +<../ports/m5stack-cores3> -build_flags = - ${env.build_flags} - -Iports/m5stack-cores3 - -DCORE_DEBUG_LEVEL=5 - -DARDUINO_USB_CDC_ON_BOOT=1 - - -DM5STACK=1 ;key for new device, - -DCORES3=1 ;mykeyboard.cpp: need map buttons an/or touchscreen, - ;display.cpp: need map battery status value, - ;settings.cpp: need map brighness control - ;main.cpp: need set startup - ;serialcmds.cpp: need set power off command - - ;Features Enabled - ;FM Radio - ;-DFM_SI4713=1 ;Uncomment to activate FM Radio using Adafruit Si4713 - -DFM_RSTPIN=18 - ;-DLITE_VERSION=1 ;limits some features to save space for M5Launcher Compatibility - - ;Microphone - ;-DMIC_SPM1423=1 ;uncomment to enable Applicable for SPM1423 device - -DPIN_CLK=-1 - -DI2S_SCLK_PIN=-1 - -DI2S_DATA_PIN=-1 - -DPIN_DATA=-1 - - ;RGB LED runned by xylopyrographer/LiteLED@^1.2.0 library - ;-DHAS_RGB_LED=1 ;uncomment to enable - -DRGB_LED=-1 - - ;Have RTC Chip - -DHAS_RTC=1 - - ;Speaker to run music, compatible with NS4168 - ;-DHAS_NS4168_SPKR=1 ;uncomment to enable - -DBCLK=-1 - -DWCLK=-1 - -DDOUT=-1 - - ;Can run USB as HID - -DUSB_as_HID=1 ;uncomment to enable - - ;Battery ADC read pin - ;-DBAT_PIN=10 - - ;Buttons configuration - ;-DHAS_BTN=1 - -DBTN_ALIAS='"Ok"' - -DBTN_PIN=-1 - -DBTN_ACT=LOw - - ;Touchscreen Config - -DHAS_TOUCH=1 - - -DALLOW_ALL_GPIO_FOR_IR_RF=1 ; Set this option to make use of all GPIOs, from 1 to 44 to be chosen, except TFT and SD pins - - ;Infrared Led default pin and state - -DIR_TX_PINS='{{"M5 IR Mod", GROVE_SDA}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' - -DIR_RX_PINS='{{"M5 IR Mod", GROVE_SCL}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' - -DLED=GROVE_SDA - -DLED_ON=HIGH - -DLED_OFF=LOW - - ;Radio Frequency (one pin modules) pin setting - -DRF_TX_PINS='{{"M5 RF433T", GROVE_SDA}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' - -DRF_RX_PINS='{{"M5 RF433R", GROVE_SCL}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}' - - ;Font sizes, depending on device - -DFP=1 - -DFM=2 - -DFG=3 - - ;Screen Setup - -DHAS_SCREEN=1 - -DROTATION=1 - -DWIDTH=320 - -DHEIGHT=220 ;240 - 50 for bottom margin - ;-DBACKLIGHT=38 - ;-DMINBRIGHT=160 - - ;TFT_eSPI Setup - -DUSER_SETUP_LOADED=1 - -DILI9341_DRIVER=1 - -DTFT_INVERSION_ON=1 - -DUSE_HSPI_PORT=1 - -DM5STACK=1 - -DTFT_MOSI=37 - -DTFT_MISO=35 - -DTFT_SCLK=36 - -DTFT_CS=3 - -DTFT_DC=35 - -DTFT_RST=-1 - -DTFT_BL=-1 - -DTOUCH_CS=-1 - -DSMOOTH_FONT=1 - -DSPI_FREQUENCY=20000000 - -DSPI_READ_FREQUENCY=20000000 - -DSPI_TOUCH_FREQUENCY=2500000 - - ;SD Card Setup pins - -DSDCARD_CS=4 - -DSDCARD_SCK=36 - -DSDCARD_MISO=35 - -DSDCARD_MOSI=37 - - ;Default I2C port - -DGROVE_SDA=32 - -DGROVE_SCL=33 - - -DSPI_SCK_PIN=0 - -DSPI_MOSI_PIN=GROVE_SDA - -DSPI_MISO_PIN=GROVE_SCL - -DSPI_SS_PIN=26 - -lib_deps = - ${env.lib_deps} - diff --git a/ports/m5stack-cplus1_1/interface.h b/ports/m5stack-cplus1_1/interface.h deleted file mode 100644 index 844098c6..00000000 --- a/ports/m5stack-cplus1_1/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/ports/m5stack-cplus2/interface.h b/ports/m5stack-cplus2/interface.h deleted file mode 100644 index 844098c6..00000000 --- a/ports/m5stack-cplus2/interface.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include -#include - -//#define HAS_KEYBOARD //has keyboard to use -//#define HAS_KEYBOARD_HID //has keyboard to use -//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" - -/*************************************************************************************** -** Function name: _setup_gpio() -** Location: main.cpp -** Description: initial setup for the device -***************************************************************************************/ -void _setup_gpio(); - - -/*************************************************************************************** -** Function name: getBattery() -** location: display.cpp -** Description: Delivers the battery value from 1-100 -***************************************************************************************/ -int getBattery(); - - -/********************************************************************* -** Function: setBrightness -** location: settings.cpp -** set brightness value -**********************************************************************/ -void _setBrightness(uint8_t brightval); - - -/********************************************************************* -** Function: checkNextPress -** location: mykeyboard.cpp -** Verifies Upper Btn to go to previous item -**********************************************************************/ -bool checkNextPress(); - - -/********************************************************************* -** Function: checkPrevPress -** location: mykeyboard.cpp -** Verifies Down Btn to go to next item -**********************************************************************/ -bool checkPrevPress(); - - -/********************************************************************* -** Function: checkSelPress -** location: mykeyboard.cpp -** Verifies if Select or OK was pressed -**********************************************************************/ -bool checkSelPress(); - - -/********************************************************************* -** Function: checkEscPress -** location: mykeyboard.cpp -** Verifies if Escape btn was pressed -**********************************************************************/ -bool checkEscPress(); - - -/********************************************************************* -** Function: checkAnyKeyPress -** location: mykeyboard.cpp -** Verifies id any of the keys was pressed -**********************************************************************/ -bool checkAnyKeyPress(); - - -/********************************************************************* -** Function: keyboard -** location: mykeyboard.cpp -** Starts keyboard to type data -**********************************************************************/ -String keyboard(String mytext, int maxSize, String msg); - - -/********************************************************************* -** Function: powerOff -** location: mykeyboard.cpp -** Turns off the device (or try to) -**********************************************************************/ -void powerOff(); - - -/********************************************************************* -** Function: checkReboot -** location: mykeyboard.cpp -** Btn logic to tornoff the device (name is odd btw) -**********************************************************************/ -void checkReboot(); - -struct keyStroke { // DO NOT CHANGE IT!!!!! - bool pressed=false; - bool exit_key=false; - bool fn = false; - bool del = false; - bool enter = false; - uint8_t modifiers = 0; - std::vector word; - std::vector hid_keys; - std::vector modifier_keys; -}; -#if defined(HAS_KEYBOARD) // related functions - -/********************************************************************* -** Function: _checkKeyPress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default - -/********************************************************************* -** Function: _checkNextPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkNextPagePress(); - -/********************************************************************* -** Function: _checkPrevPagePress -** location: mykeyboard.cpp -** returns the key from the keyboard -**********************************************************************/ -bool _checkPrevPagePress(); - -#endif diff --git a/src/core/VectorDisplay.h b/src/core/VectorDisplay.h index d11d1d2b..43b786d7 100755 --- a/src/core/VectorDisplay.h +++ b/src/core/VectorDisplay.h @@ -1,5 +1,5 @@ -#ifndef _VECTOR_DISPLAY_H -#define _VECTOR_DISPLAY_H +#ifndef __VECTOR_DISPLAY_H__ +#define __VECTOR_DISPLAY_H__ #ifndef ARDUINO #define NO_SERIAL diff --git a/src/core/config.cpp b/src/core/config.cpp index b02ce6eb..44821f86 100644 --- a/src/core/config.cpp +++ b/src/core/config.cpp @@ -243,7 +243,7 @@ void BruceConfig::validateDimmerValue() { } -void BruceConfig::setBright(int value) { +void BruceConfig::setBright(uint8_t value) { bright = value; validateBrightValue(); saveFile(); diff --git a/src/core/config.h b/src/core/config.h index 97eb4abd..203a38fa 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -1,7 +1,7 @@ #ifndef __BRUCE_CONFIG_H__ #define __BRUCE_CONFIG_H__ -// #include "globals.h" +// #include #include #include #include @@ -102,7 +102,7 @@ class BruceConfig { void validateRotationValue(); void setDimmer(int value); void validateDimmerValue(); - void setBright(int value); + void setBright(uint8_t value); void validateBrightValue(); void setTmz(int value); void validateTmzValue(); diff --git a/src/core/connect.h b/src/core/connect.h index e396e05a..ec0553ad 100644 --- a/src/core/connect.h +++ b/src/core/connect.h @@ -11,7 +11,7 @@ #define __DEVICE_CONNECTION_H__ #include -#include "core/globals.h" +#include #define PAGE_BYTES 150 diff --git a/src/core/display.h b/src/core/display.h index 6d94e82a..17978b30 100644 --- a/src/core/display.h +++ b/src/core/display.h @@ -1,9 +1,7 @@ -#pragma once -// display.h -#ifndef DISPLAY_H -#define DISPLAY_H +#ifndef __DISPLAY_H__ +#define __DISPLAY_H__ -#include "globals.h" +#include #include "sd_functions.h" // to catch FileList Struct #include #include @@ -30,6 +28,9 @@ uint16_t getColorVariation(uint16_t color, int delta = 10, int direction = 0); void resetTftDisplay(int x = 0, int y = 0, uint16_t fc = bruceConfig.priColor, int size = FM, uint16_t bg = bruceConfig.bgColor, uint16_t screen = bruceConfig.bgColor); void setTftDisplay(int x = 0, int y = 0, uint16_t fc = tft.textcolor, int size = tft.textsize, uint16_t bg = tft.textbgcolor); +void turnOffDisplay(); +bool wakeUpScreen(); + void displayRedStripe(String text, uint16_t fgcolor = TFT_WHITE, uint16_t bgcolor = TFT_RED); void displayError(String txt, bool waitKeyPress = false); // Red Stripe diff --git a/src/core/globals.cpp b/src/core/globals.cpp deleted file mode 100644 index 262c3621..00000000 --- a/src/core/globals.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "globals.h" - -/********************************************************************* -** Function: backToMenu -** sets the global var to be be used in the options second parameter -** and returnToMenu will be user do handle the breaks of all loops - -when using loopfunctions with an option to "Back to Menu", use: - -add this option: - options.push_back({"Main Menu", [=]() { backToMenu(); }}); - -while(1) { - if(returnToMenu) break; // stop this loop and return to the previous loop - - ... - loopOptions(options); - ... -} -*/ - - -void backToMenu() { - returnToMenu=true; -} - -void updateTimeStr(struct tm timeInfo) { - // Atualiza timeStr com a hora e minuto - snprintf(timeStr, sizeof(timeStr), "%02d:%02d:%02d", timeInfo.tm_hour, timeInfo.tm_min, timeInfo.tm_sec); -} - diff --git a/src/core/i2c_finder.h b/src/core/i2c_finder.h index fa40ef4f..29eabc99 100644 --- a/src/core/i2c_finder.h +++ b/src/core/i2c_finder.h @@ -1,4 +1,4 @@ -#include "globals.h" +#include void find_i2c_addresses(); uint8_t find_first_i2c_address(); diff --git a/src/core/main_menu.cpp b/src/core/main_menu.cpp index b163bc67..bc59c50b 100644 --- a/src/core/main_menu.cpp +++ b/src/core/main_menu.cpp @@ -1,5 +1,5 @@ #include "main_menu.h" -#include "globals.h" +#include #include "display.h" @@ -17,7 +17,7 @@ MainMenu::MainMenu() { &nrf24Menu, #endif #if !defined(LITE_VERSION) - #if !defined(CORE) && !defined(CORE2) + #if !defined(ARDUINO_M5STACK_CORE) && !defined(ARDUINO_M5STACK_CORE2) &scriptsMenu, #endif #endif diff --git a/src/core/menu_items/BleMenu.cpp b/src/core/menu_items/BleMenu.cpp index bdf2d574..7499af27 100644 --- a/src/core/menu_items/BleMenu.cpp +++ b/src/core/menu_items/BleMenu.cpp @@ -1,5 +1,6 @@ #include "BleMenu.h" -#include "../globals.h" +#include +#include "core/utils.h" #include "core/display.h" #include "modules/ble/ble_spam.h" #include "modules/ble/ble_common.h" diff --git a/src/core/menu_items/ConnectMenu.cpp b/src/core/menu_items/ConnectMenu.cpp index 4c2aac89..a69b711a 100644 --- a/src/core/menu_items/ConnectMenu.cpp +++ b/src/core/menu_items/ConnectMenu.cpp @@ -4,6 +4,7 @@ #include "core/settings.h" #include "core/connect.h" #include "core/wifi_common.h" +#include "core/utils.h" void ConnectMenu::optionsMenu() { diff --git a/src/core/menu_items/FMMenu.cpp b/src/core/menu_items/FMMenu.cpp index 933cbb32..c20e73b6 100644 --- a/src/core/menu_items/FMMenu.cpp +++ b/src/core/menu_items/FMMenu.cpp @@ -1,6 +1,7 @@ #include "FMMenu.h" #include "core/display.h" #include "modules/fm/fm.h" +#include "core/utils.h" void FMMenu::optionsMenu() { options = { diff --git a/src/core/menu_items/FileMenu.cpp b/src/core/menu_items/FileMenu.cpp index 253c47be..d97b49d3 100644 --- a/src/core/menu_items/FileMenu.cpp +++ b/src/core/menu_items/FileMenu.cpp @@ -2,6 +2,7 @@ #include "core/display.h" #include "core/sd_functions.h" #include "modules/others/webInterface.h" +#include "core/utils.h" void FileMenu::optionsMenu() { options = { diff --git a/src/core/menu_items/GpsMenu.cpp b/src/core/menu_items/GpsMenu.cpp index 74b7dfe3..80b7a2d8 100644 --- a/src/core/menu_items/GpsMenu.cpp +++ b/src/core/menu_items/GpsMenu.cpp @@ -4,6 +4,7 @@ #include "core/settings.h" #include "modules/gps/wardriving.h" #include "modules/gps/gps_tracker.h" +#include "core/utils.h" void GpsMenu::optionsMenu() { options = { diff --git a/src/core/menu_items/IRMenu.cpp b/src/core/menu_items/IRMenu.cpp index 1a8705d2..4112740c 100644 --- a/src/core/menu_items/IRMenu.cpp +++ b/src/core/menu_items/IRMenu.cpp @@ -4,6 +4,7 @@ #include "modules/ir/TV-B-Gone.h" #include "modules/ir/custom_ir.h" #include "modules/ir/ir_read.h" +#include "core/utils.h" void IRMenu::optionsMenu() { options = { diff --git a/src/core/menu_items/MenuItemInterface.h b/src/core/menu_items/MenuItemInterface.h index eaa65d48..bfdc3ce3 100644 --- a/src/core/menu_items/MenuItemInterface.h +++ b/src/core/menu_items/MenuItemInterface.h @@ -1,7 +1,7 @@ #ifndef __MENU_ITEM_INTERFACE_H__ #define __MENU_ITEM_INTERFACE_H__ -#include "core/globals.h" +#include #include "core/display.h" @@ -21,7 +21,7 @@ class MenuItemInterface { void drawArrows(float scale = 1) { tft.fillRect(arrowAreaX, iconAreaY, arrowAreaW, iconAreaH, bruceConfig.bgColor); - tft.fillRect(WIDTH - arrowAreaX - arrowAreaW, iconAreaY, arrowAreaW, iconAreaH, bruceConfig.bgColor); + tft.fillRect(tftWidth - arrowAreaX - arrowAreaW, iconAreaY, arrowAreaW, iconAreaH, bruceConfig.bgColor); int arrowSize = scale * 10; int lineWidth = scale * 3; @@ -31,7 +31,7 @@ class MenuItemInterface { // Left Arrow tft.drawWideLine( - arrowX, + arrowX, arrowY, arrowX + arrowSize, arrowY + arrowSize, @@ -51,18 +51,18 @@ class MenuItemInterface { // Right Arrow tft.drawWideLine( - WIDTH - arrowX, + tftWidth - arrowX, arrowY, - WIDTH - arrowX - arrowSize, + tftWidth - arrowX - arrowSize, arrowY + arrowSize, lineWidth, bruceConfig.priColor, bruceConfig.bgColor ); tft.drawWideLine( - WIDTH - arrowX, + tftWidth - arrowX, arrowY, - WIDTH - arrowX - arrowSize, + tftWidth - arrowX - arrowSize, arrowY - arrowSize, lineWidth, bruceConfig.priColor, @@ -76,7 +76,7 @@ class MenuItemInterface { tft.setTextSize(FM); tft.fillRect( arrowAreaX, titleY, - WIDTH - 2*arrowAreaX, LH*FM, + tftWidth - 2*arrowAreaX, LH*FM, bruceConfig.bgColor ); tft.drawCentreString(getName(), iconCenterX, titleY, 1); @@ -86,14 +86,14 @@ class MenuItemInterface { String _name = ""; int iconAreaH = ( - (HEIGHT - 2*BORDER_PAD_Y) % 2 == 0 - ? HEIGHT - 2*BORDER_PAD_Y - : HEIGHT - 2*BORDER_PAD_Y + 1 + (tftHeight - 2*BORDER_PAD_Y) % 2 == 0 + ? tftHeight - 2*BORDER_PAD_Y + : tftHeight - 2*BORDER_PAD_Y + 1 ); int iconAreaW = iconAreaH; - int iconCenterX = WIDTH/2; - int iconCenterY = HEIGHT/2; + int iconCenterX = tftWidth/2; + int iconCenterY = tftHeight/2; int iconAreaX = iconCenterX - iconAreaW/2; int iconAreaY = iconCenterY - iconAreaH/2; diff --git a/src/core/menu_items/NRF24.cpp b/src/core/menu_items/NRF24.cpp index 3a28e1b7..db129417 100644 --- a/src/core/menu_items/NRF24.cpp +++ b/src/core/menu_items/NRF24.cpp @@ -3,6 +3,7 @@ #include "modules/NRF24/nrf_common.h" #include "modules/NRF24/nrf_jammer.h" #include "modules/NRF24/nrf_spectrum.h" +#include "core/utils.h" void NRF24Menu::optionsMenu() { options.clear(); diff --git a/src/core/menu_items/OthersMenu.cpp b/src/core/menu_items/OthersMenu.cpp index 50cff0e6..84d74488 100644 --- a/src/core/menu_items/OthersMenu.cpp +++ b/src/core/menu_items/OthersMenu.cpp @@ -8,6 +8,7 @@ #include "modules/others/mic.h" #include "modules/bjs_interpreter/interpreter.h" #include "modules/others/timer.h" +#include "core/utils.h" #include "modules/others/bad_usb.h" #ifdef HAS_RGB_LED @@ -35,7 +36,7 @@ void OthersMenu::optionsMenu() { #ifndef LITE_VERSION {"Openhaystack", [=]() { openhaystack_setup(); }}, #endif - #if !defined(CORE) && !defined(CORE2) + #if !defined(ARDUINO_M5STACK_CORE) && !defined(ARDUINO_M5STACK_CORE2) {"Interpreter", [=]() { run_bjs_script(); }}, #endif {"Timer", [=]() { Timer(); }}, diff --git a/src/core/menu_items/RFIDMenu.cpp b/src/core/menu_items/RFIDMenu.cpp index c9e1bd93..279fd020 100644 --- a/src/core/menu_items/RFIDMenu.cpp +++ b/src/core/menu_items/RFIDMenu.cpp @@ -6,6 +6,7 @@ #include "modules/rfid/chameleon.h" #include "modules/rfid/amiibo.h" #include "modules/rfid/pn532ble.h" +#include "core/utils.h" void RFIDMenu::optionsMenu() { options = { diff --git a/src/core/menu_items/RFMenu.cpp b/src/core/menu_items/RFMenu.cpp index 84df6a6c..0b927c9d 100644 --- a/src/core/menu_items/RFMenu.cpp +++ b/src/core/menu_items/RFMenu.cpp @@ -2,6 +2,7 @@ #include "core/display.h" #include "core/settings.h" #include "modules/rf/rf.h" +#include "core/utils.h" void RFMenu::optionsMenu() { options = { diff --git a/src/core/menu_items/ScriptsMenu.cpp b/src/core/menu_items/ScriptsMenu.cpp index 602bb7e5..d1eee8b0 100644 --- a/src/core/menu_items/ScriptsMenu.cpp +++ b/src/core/menu_items/ScriptsMenu.cpp @@ -3,7 +3,7 @@ #include "core/display.h" #include "core/settings.h" #include "modules/bjs_interpreter/interpreter.h" // for JavaScript interpreter - +#include "core/utils.h" String getScriptsFolder(FS *&fs) { String folder; diff --git a/src/core/menu_items/WifiMenu.cpp b/src/core/menu_items/WifiMenu.cpp index 81ee5078..d98f0d10 100644 --- a/src/core/menu_items/WifiMenu.cpp +++ b/src/core/menu_items/WifiMenu.cpp @@ -9,6 +9,7 @@ #include "modules/wifi/sniffer.h" #include "modules/wifi/wifi_atks.h" #include "modules/wifi/ap_info.h" +#include "core/utils.h" #ifndef LITE_VERSION #include "modules/pwnagotchi/pwnagotchi.h" diff --git a/src/core/mykeyboard.cpp b/src/core/mykeyboard.cpp index de396ba6..9ab8ec7f 100644 --- a/src/core/mykeyboard.cpp +++ b/src/core/mykeyboard.cpp @@ -320,8 +320,8 @@ String keyboard(String mytext, int maxSize, String msg) { { '/', '/' } //12 } }; - int _x = WIDTH/12; - int _y = (HEIGHT - 54)/4; + int _x = tftWidth/12; + int _y = (tftHeight - 54)/4; int _xo = _x/2-3; #if defined(HAS_TOUCH) @@ -371,7 +371,7 @@ String keyboard(String mytext, int maxSize, String msg) { box_list[k].color = ~bruceConfig.bgColor; box_list[k].x=159; box_list[k].y=0; - box_list[k].w=WIDTH-164; + box_list[k].w=tftWidth-164; box_list[k].h=22; k=0; @@ -394,12 +394,12 @@ String keyboard(String mytext, int maxSize, String msg) { //Draw the rectangles if(y<0) { - tft.fillRect(0,1,WIDTH,22,bruceConfig.bgColor); + tft.fillRect(0,1,tftWidth,22,bruceConfig.bgColor); tft.drawRect(7,2,46,20,TFT_WHITE); // Ok Rectangle tft.drawRect(55,2,50,20,TFT_WHITE); // CAP Rectangle tft.drawRect(107,2,50,20,TFT_WHITE); // DEL Rectangle tft.drawRect(159,2,74,20,TFT_WHITE); // SPACE Rectangle - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle if(x==0 && y==-1) { tft.setTextColor(bruceConfig.bgColor, TFT_WHITE); tft.fillRect(7,2,50,20,TFT_WHITE); } @@ -429,7 +429,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.setTextSize(FM); // reseta o quadrado do texto - if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,bruceConfig.bgColor); // mystring Rectangle + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,tftWidth-3,20,bruceConfig.bgColor); // mystring Rectangle // escreve o texto tft.setTextColor(TFT_WHITE); if(mytext.length()>19) { @@ -445,7 +445,7 @@ String keyboard(String mytext, int maxSize, String msg) { tft.drawString(mytext, 5, 34); } //desenha o retangulo colorido - tft.drawRect(3,32,WIDTH-3,20,bruceConfig.priColor); // mystring Rectangle + tft.drawRect(3,32,tftWidth-3,20,bruceConfig.priColor); // mystring Rectangle tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); @@ -551,7 +551,7 @@ String keyboard(String mytext, int maxSize, String msg) { } //Resets screen when finished writing - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); resetTftDisplay(); return mytext; diff --git a/src/core/mykeyboard.h b/src/core/mykeyboard.h index e446474f..4fa61494 100644 --- a/src/core/mykeyboard.h +++ b/src/core/mykeyboard.h @@ -1,6 +1,6 @@ #pragma once #include "display.h" -#include "globals.h" +#include String __attribute__((weak)) keyboard(String mytext, int maxSize = 76, String msg = "Type your message:"); diff --git a/src/core/passwords.cpp b/src/core/passwords.cpp index 597ca9a3..3393d079 100644 --- a/src/core/passwords.cpp +++ b/src/core/passwords.cpp @@ -3,7 +3,7 @@ #include #include "passwords.h" -#include "globals.h" +#include #include "sd_functions.h" #include "mykeyboard.h" #include "modules/rf/rf.h" //for hexCharToDecimal diff --git a/src/core/powerSave.cpp b/src/core/powerSave.cpp index 03401936..075d7dc5 100644 --- a/src/core/powerSave.cpp +++ b/src/core/powerSave.cpp @@ -1,28 +1,6 @@ #include "powerSave.h" #include "settings.h" - -/* Turn off the display */ -void turnOffDisplay() { - setBrightness(0,false); -} - -/* If the device screen is off, turn on, else just refresh sleep timer */ -bool wakeUpScreen(){ - previousMillis = millis(); - if(isScreenOff){ - isScreenOff = false; - dimmer = false; - getBrightness(); - delay(200); - return true; - }else if(dimmer){ - dimmer = false; - getBrightness(); - delay(200); - return true; - } - return false; -} +#include "display.h" /* Check if it's time to put the device to sleep */ void checkPowerSaveTime(){ @@ -42,6 +20,7 @@ void sleepModeOn(){ isSleeping = true; setCpuFrequencyMhz(80); turnOffDisplay(); + disableLoopWDT(); delay(200); } @@ -50,5 +29,7 @@ void sleepModeOff(){ isSleeping = false; setCpuFrequencyMhz(240); getBrightness(); + enableLoopWDT(); + feedLoopWDT(); delay(200); } diff --git a/src/core/powerSave.h b/src/core/powerSave.h index 1c30ff27..58590070 100644 --- a/src/core/powerSave.h +++ b/src/core/powerSave.h @@ -1,11 +1,6 @@ -#include "globals.h" +#include #include "display.h" -//It is here to not create a new set of files just to use AXP192 library again -void turnOffDisplay(); - -bool wakeUpScreen(); - void checkPowerSaveTime(); void sleepModeOn(); diff --git a/src/core/serialcmds.cpp b/src/core/serialcmds.cpp index b77522fd..3b085e6b 100644 --- a/src/core/serialcmds.cpp +++ b/src/core/serialcmds.cpp @@ -1,6 +1,6 @@ #include "serialcmds.h" -#include "globals.h" +#include #include #include "cJSON.h" #include // for PRIu64 @@ -13,6 +13,7 @@ #include "settings.h" #include "display.h" #include "powerSave.h" +#include "core/utils.h" #include "wifi_common.h" #include "passwords.h" #include "modules/rf/rf.h" @@ -120,7 +121,7 @@ bool is_free_gpio_pin(int pin_no ){ // check if pin_no is usable for general GPIO std::vector usable_pins = {GROVE_SDA, GROVE_SCL}; - #if defined(STICK_C_PLUS2) || defined(STICK_C_PLUS) + #if defined(ARDUINO_M5STICK_C_PLUS2) || defined(ARDUINO_M5STICK_C_PLUS) usable_pins.insert(usable_pins.end(), { 25, 26, 32, 33, 0 }); #elif defined(ESP32S3DEVKITC1) usable_pins.insert(usable_pins.end(), { diff --git a/src/core/serialcmds.h b/src/core/serialcmds.h index cb5a1481..9d0e1f0d 100644 --- a/src/core/serialcmds.h +++ b/src/core/serialcmds.h @@ -1,3 +1,5 @@ +#ifndef __SERIAL_CMDS_H__ +#define __SERIAL_CMDS_H__ #include @@ -7,3 +9,4 @@ bool processSerialCommand(String cmd_str); void startSerialCommandsHandlerTask(); +#endif \ No newline at end of file diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 8ebb3d8f..708909ea 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -1,7 +1,8 @@ -#include "globals.h" +#include #include "settings.h" #include "display.h" // calling loopOptions(options, true); #include "wifi_common.h" +#include "utils.h" #include "mykeyboard.h" #include "sd_functions.h" #include "powerSave.h" @@ -18,10 +19,10 @@ void _setBrightness(uint8_t brightval) { } ** Function: setBrightness ** set brightness value **********************************************************************/ -void setBrightness(int brightval, bool save) { +void setBrightness(uint8_t brightval, bool save) { if(bruceConfig.bright>100) bruceConfig.setBright(100); - _setBrightness(brightval); - delay(10); + _setBrightness(brightval); + delay(10); if(save){ bruceConfig.setBright(brightval); @@ -82,11 +83,11 @@ void setBrightnessMenu() { else if(bruceConfig.bright== 1) idx=4; options = { - {"100%", [=]() { setBrightness(100); }, bruceConfig.bright == 100 }, - {"75 %", [=]() { setBrightness(75); }, bruceConfig.bright == 75 }, - {"50 %", [=]() { setBrightness(50); }, bruceConfig.bright == 50 }, - {"25 %", [=]() { setBrightness(25); }, bruceConfig.bright == 25 }, - {" 1 %", [=]() { setBrightness(1); }, bruceConfig.bright == 1 }, + {"100%", [=]() { setBrightness((uint8_t)100); }, bruceConfig.bright == 100 }, + {"75 %", [=]() { setBrightness((uint8_t)75); }, bruceConfig.bright == 75 }, + {"50 %", [=]() { setBrightness((uint8_t)50); }, bruceConfig.bright == 50 }, + {"25 %", [=]() { setBrightness((uint8_t)25); }, bruceConfig.bright == 25 }, + {" 1 %", [=]() { setBrightness((uint8_t)1); }, bruceConfig.bright == 1 }, {"Main Menu", [=]() { backToMenu(); }}, // this one bugs the brightness selection }; delay(200); @@ -411,17 +412,17 @@ void runClockLoop() { Serial.print("Current time: "); Serial.println(timeStr); tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); - tft.drawRect(10, 10, WIDTH-15,HEIGHT-15, bruceConfig.priColor); - tft.setCursor(64, HEIGHT/3+5); + tft.drawRect(10, 10, tftWidth-15,tftHeight-15, bruceConfig.priColor); + tft.setCursor(64, tftHeight/3+5); tft.setTextSize(4); #if defined(HAS_RTC) _rtc.GetBm8563Time(); _rtc.GetTime(&_time); char timeString[9]; // Buffer para armazenar a string formatada "HH:MM:SS" snprintf(timeString, sizeof(timeString), "%02d:%02d:%02d", _time.Hours, _time.Minutes, _time.Seconds); - tft.drawCentreString(timeString,WIDTH/2,HEIGHT/2-13,1); + tft.drawCentreString(timeString,tftWidth/2,tftHeight/2-13,1); #else - tft.drawCentreString(timeStr,WIDTH/2,HEIGHT/2-13,1); + tft.drawCentreString(timeStr,tftWidth/2,tftHeight/2-13,1); #endif tmp=millis(); } diff --git a/src/core/settings.h b/src/core/settings.h index 2d264789..c285ee57 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -1,9 +1,11 @@ -#pragma once +#ifndef __SETTINGS_H__ +#define __SETTINGS_H__ + #include void _setBrightness(uint8_t brightval) __attribute__((weak)); -void setBrightness(int bright, bool save = true); +void setBrightness(uint8_t brightval, bool save = true); void getBrightness(); @@ -44,3 +46,5 @@ void setWifiStartupConfig(); void setStartupApp(); void setGpsBaudrateMenu(); + +#endif \ No newline at end of file diff --git a/src/core/wg.cpp b/src/core/wg.cpp index 94e9df9d..edf159b1 100644 --- a/src/core/wg.cpp +++ b/src/core/wg.cpp @@ -1,5 +1,5 @@ #include "wg.h" -#include "globals.h" +#include #include "display.h" #include "sd_functions.h" #include "wifi_common.h" diff --git a/src/core/wifi_common.cpp b/src/core/wifi_common.cpp index 48ff7895..1a4f60ba 100644 --- a/src/core/wifi_common.cpp +++ b/src/core/wifi_common.cpp @@ -1,4 +1,4 @@ -#include "globals.h" +#include #include "wifi_common.h" #include "mykeyboard.h" // usinf keyboard when calling rename #include "display.h" // using displayRedStripe and loop options @@ -54,7 +54,7 @@ bool _connectToWifiNetwork(const String& ssid, const String& pwd) { int i = 1; while (WiFi.status() != WL_CONNECTED) { - if (tft.getCursorX() >= WIDTH-12) { + if (tft.getCursorX() >= tftWidth-12) { padprintln(""); padprint(""); } diff --git a/src/main.cpp b/src/main.cpp index df6c06d1..0e1f4f8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "core/globals.h" +#include #include "core/main_menu.h" #include @@ -6,6 +6,7 @@ #include #include #include "esp32-hal-psram.h" +#include "core/utils.h" BruceConfig bruceConfig; @@ -52,10 +53,14 @@ uint8_t buff[1024] = {0}; TFT_eSPI tft = TFT_eSPI(); // Invoke custom library TFT_eSprite sprite = TFT_eSprite(&tft); TFT_eSprite draw = TFT_eSprite(&tft); + volatile int tftWidth = TFT_HEIGHT; + volatile int tftHeight = TFT_WIDTH; #else - SerialDisplayClass tft; - SerialDisplayClass& sprite = tft; - SerialDisplayClass& draw = tft; + SerialDisplayClass tft; + SerialDisplayClass& sprite = tft; + SerialDisplayClass& draw = tft; + volatile int tftWidth = VECTOR_DISPLAY_DEFAULT_HEIGHT; + volatile int tftHeight = VECTOR_DISPLAY_DEFAULT_WIDTH; #endif @@ -78,6 +83,7 @@ uint8_t buff[1024] = {0}; void begin_storage() { if(!LittleFS.begin(true)) { LittleFS.format(), LittleFS.begin();} setupSdCard(); + bruceConfig.fromFile(); } /********************************************************************* @@ -100,19 +106,15 @@ void _post_setup_gpio() { } *********************************************************************/ void setup_gpio() { - #if defined(BACKLIGHT) - pinMode(BACKLIGHT, OUTPUT); - #endif - //init setup from /ports/*/interface.h _setup_gpio(); #ifdef USE_CC1101_VIA_SPI #if CC1101_MOSI_PIN==TFT_MOSI // (T_EMBED), CORE2 and others initCC1101once(&tft.getSPIinstance()); - #elif CC1101_MOSI_PIN==SDCARD_MOSI // (CARDPUTER) and (ESP32S3DEVKITC1) and devices that share CC1101 pin with only SDCard + #elif CC1101_MOSI_PIN==SDCARD_MOSI // (ARDUINO_M5STACK_CARDPUTER) and (ESP32S3DEVKITC1) and devices that share CC1101 pin with only SDCard initCC1101once(&sdcardSPI); - #else // (STICK_C_PLUS) || (STICK_C_PLUS2) and others that doesn´t share SPI with other devices (need to change it when Bruce board comes to shore) + #else // (ARDUINO_M5STICK_C_PLUS) || (ARDUINO_M5STICK_C_PLUS2) and others that doesn´t share SPI with other devices (need to change it when Bruce board comes to shore) initCC1101once(NULL); #endif #endif @@ -124,11 +126,10 @@ void setup_gpio() { ** Config tft *********************************************************************/ void begin_tft(){ -#if defined(HAS_SCREEN)// && !defined(CORE) //Need to test if it will work on Core Fire etc.. - tft.init(); -#endif tft.fillScreen(TFT_BLACK); tft.setRotation(bruceConfig.rotation); + tftWidth = tft.width(); + tftHeight = tft.height(); resetTftDisplay(); setBrightness(bruceConfig.bright); } @@ -142,11 +143,11 @@ void boot_screen() { tft.setTextColor(bruceConfig.priColor, TFT_BLACK); tft.setTextSize(FM); tft.drawPixel(0,0,TFT_BLACK); - tft.drawCentreString("Bruce", WIDTH / 2, 10, SMOOTH_FONT); + tft.drawCentreString("Bruce", tftWidth / 2, 10, SMOOTH_FONT); tft.setTextSize(FP); - tft.drawCentreString(BRUCE_VERSION, WIDTH / 2, 25, SMOOTH_FONT); + tft.drawCentreString(BRUCE_VERSION, tftWidth / 2, 25, SMOOTH_FONT); tft.setTextSize(FM); - tft.drawCentreString("PREDATORY FIRMWARE", WIDTH / 2, HEIGHT+2, SMOOTH_FONT); // will draw outside the screen on non touch devices + tft.drawCentreString("PREDATORY FIRMWARE", tftWidth / 2, tftHeight+2, SMOOTH_FONT); // will draw outside the screen on non touch devices } /********************************************************************* @@ -168,7 +169,7 @@ void boot_screen_anim() { while(millis()2000) && !drawn) { - tft.fillRect(0,45,WIDTH,HEIGHT-45,bruceConfig.bgColor); + tft.fillRect(0,45,tftWidth,tftHeight-45,bruceConfig.bgColor); if(boot_img > 0 && !drawn) { tft.fillScreen(bruceConfig.bgColor); if(boot_img==1) { showJpeg(SD,"/boot.jpg",0,0,true); Serial.println("Image from SD"); } @@ -179,11 +180,11 @@ void boot_screen_anim() { } drawn=true; } - if(!boot_img && (millis()-i>2200) && (millis()-i)<2700) tft.drawRect(2*WIDTH/3,HEIGHT/2,2,2,bruceConfig.priColor); - if(!boot_img && (millis()-i>2700) && (millis()-i)<2900) tft.fillRect(0,45,WIDTH,HEIGHT-45,bruceConfig.bgColor); - if(!boot_img && (millis()-i>2900) && (millis()-i)<3400) tft.drawXBitmap(2*WIDTH/3 - 30 ,5+HEIGHT/2,bruce_small_bits, bruce_small_width, bruce_small_height,TFT_BLACK,bruceConfig.priColor); - if(!boot_img && (millis()-i>3400) && (millis()-i)<3600) tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); - if(!boot_img && (millis()-i>3600)) tft.drawXBitmap((WIDTH-238)/2,(HEIGHT-133)/2,bits, bits_width, bits_height,TFT_BLACK,bruceConfig.priColor); + if(!boot_img && (millis()-i>2200) && (millis()-i)<2700) tft.drawRect(2*tftWidth/3,tftHeight/2,2,2,bruceConfig.priColor); + if(!boot_img && (millis()-i>2700) && (millis()-i)<2900) tft.fillRect(0,45,tftWidth,tftHeight-45,bruceConfig.bgColor); + if(!boot_img && (millis()-i>2900) && (millis()-i)<3400) tft.drawXBitmap(2*tftWidth/3 - 30 ,5+tftHeight/2,bruce_small_bits, bruce_small_width, bruce_small_height,TFT_BLACK,bruceConfig.priColor); + if(!boot_img && (millis()-i>3400) && (millis()-i)<3600) tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); + if(!boot_img && (millis()-i>3600)) tft.drawXBitmap((tftWidth-238)/2,(tftHeight-133)/2,bits, bits_width, bits_height,TFT_BLACK,bruceConfig.priColor); #endif if(checkAnyKeyPress()) // If any key or M5 key is pressed, it'll jump the boot screen { @@ -196,8 +197,6 @@ void boot_screen_anim() { // Clear splashscreen tft.fillScreen(TFT_BLACK); - - // Clear splashscreen tft.fillScreen(TFT_BLACK); } @@ -263,16 +262,19 @@ void setup() { setup_gpio(); bruceConfig.bright=100; // theres is no value yet - begin_tft(); + #if defined(HAS_SCREEN) + tft.init(); + #else + tft.begin(); + #endif begin_storage(); bruceConfig.fromFile(); - resetTftDisplay(); - tft.setRotation(bruceConfig.rotation); - setBrightness(bruceConfig.bright); - + begin_tft(); init_clock(); + disableCore0WDT(); + // Some GPIO Settings (such as CYD's brightness control must be set after tft and sdcard) _post_setup_gpio(); // end of post gpio begin @@ -293,7 +295,6 @@ void setup() { delay(200); previousMillis = millis(); - setBrightness(bruceConfig.bright); if (bruceConfig.startupApp != "" && !startupApp.startApp(bruceConfig.startupApp)) { bruceConfig.setStartupApp(""); @@ -316,7 +317,7 @@ void loop() { // Interpreter must be ran in the loop() function, otherwise it breaks // called by 'stack canary watchpoint triggered (loopTask)' #if !defined(LITE_VERSION) - #if !defined(CORE) && !defined(CORE2) + #if !defined(ARDUINO_M5STACK_CORE) && !defined(ARDUINO_M5STACK_CORE2) if(interpreter_start) { interpreter_start=false; interpreter(); @@ -325,7 +326,7 @@ void loop() { } #endif #endif - tft.fillRect(0,0,WIDTH,HEIGHT,bruceConfig.bgColor); + tft.fillRect(0,0,tftWidth,tftHeight,bruceConfig.bgColor); bruceConfig.fromFile(); @@ -338,7 +339,7 @@ void loop() { } if (redraw) { - mainMenu.draw(float((float)HEIGHT/(float)135)); + mainMenu.draw(float((float)tftHeight/(float)135)); clock_update=0; // forces clock drawing redraw = false; delay(REDRAW_DELAY); diff --git a/src/modules/NRF24/nrf_common.cpp b/src/modules/NRF24/nrf_common.cpp index e9c15eaa..bd083bb7 100644 --- a/src/modules/NRF24/nrf_common.cpp +++ b/src/modules/NRF24/nrf_common.cpp @@ -8,7 +8,7 @@ void nrf_info() { tft.fillScreen(bruceConfig.bgColor); tft.setTextSize(FM); tft.setTextColor(TFT_RED, bruceConfig.bgColor); - tft.drawCentreString("_Disclaimer_",WIDTH/2,10,1); + tft.drawCentreString("_Disclaimer_",tftWidth/2,10,1); tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); tft.setTextSize(FP); tft.setCursor(15,33); @@ -33,7 +33,7 @@ bool nrf_start() { #elif CC1101_MOSI_PIN==SDCARD_MOSI NRFSPI = &sdcardSPI; NRFSPI->begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN); - //#elif defined(STICK_C_PLUS) || defined(STICK_C_PLUS2) + //#elif defined(ARDUINO_M5STICK_C_PLUS) || defined(ARDUINO_M5STICK_C_PLUS2) // NRFSPI = &CC_NRF_SPI; // NRFSPI->begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN); #else diff --git a/src/modules/NRF24/nrf_common.h b/src/modules/NRF24/nrf_common.h index b734505b..f0e67ba5 100644 --- a/src/modules/NRF24/nrf_common.h +++ b/src/modules/NRF24/nrf_common.h @@ -1,5 +1,5 @@ #include -#include "../../core/globals.h" +#include //Define the Macros case it hasn't been declared #ifndef NRF24_CE_PIN diff --git a/src/modules/NRF24/nrf_jammer.cpp b/src/modules/NRF24/nrf_jammer.cpp index a4b78226..80c2134b 100644 --- a/src/modules/NRF24/nrf_jammer.cpp +++ b/src/modules/NRF24/nrf_jammer.cpp @@ -1,6 +1,6 @@ #include "nrf_common.h" #include "nrf_jammer.h" -#include "core/globals.h" +#include #include "core/mykeyboard.h" #include "core/display.h" diff --git a/src/modules/NRF24/nrf_spectrum.cpp b/src/modules/NRF24/nrf_spectrum.cpp index 5c6318bd..db349037 100644 --- a/src/modules/NRF24/nrf_spectrum.cpp +++ b/src/modules/NRF24/nrf_spectrum.cpp @@ -29,7 +29,7 @@ inline void powerDown(SPIClass &SSPI) { } // Scanning Channels -#define _BW WIDTH/CHANNELS +#define _BW tftWidth/CHANNELS String scanChannels(SPIClass* SSPI, bool web) { String result="{"; digitalWrite(NRF24_CE_PIN, LOW); @@ -45,8 +45,8 @@ String scanChannels(SPIClass* SSPI, bool web) { int level = (channel[i] > 125) ? 125 : channel[i]; // Clamp values tft.drawFastVLine(i*_BW, 0, 125, (i % 8) ? TFT_BLACK : RGB565(25, 25, 25)); - tft.drawFastVLine(i*_BW, HEIGHT-(10+level), level, (i % 2 == 0) ? bruceConfig.priColor : TFT_DARKGREY); // Use green for even indices - tft.drawFastVLine(i*_BW, 0, HEIGHT-(9+level), (i % 8) ? TFT_BLACK : RGB565(25, 25, 25)); + tft.drawFastVLine(i*_BW, tftHeight-(10+level), level, (i % 2 == 0) ? bruceConfig.priColor : TFT_DARKGREY); // Use green for even indices + tft.drawFastVLine(i*_BW, 0, tftHeight-(9+level), (i % 8) ? TFT_BLACK : RGB565(25, 25, 25)); tft.drawFastVLine(i*_BW, 0, rpd ? 2 : 0, TFT_DARKGREY); if(web) { if(i>0) result+=","; @@ -61,9 +61,9 @@ String scanChannels(SPIClass* SSPI, bool web) { void nrf_spectrum(SPIClass* SSPI) { tft.fillScreen(bruceConfig.bgColor); tft.setTextSize(FP); - tft.drawString("2.40Ghz",0,HEIGHT-LH); - tft.drawCentreString("2.44Ghz", WIDTH/2,HEIGHT-LH,1); - tft.drawRightString("2.48Ghz",WIDTH,HEIGHT-LH,1); + tft.drawString("2.40Ghz",0,tftHeight-LH); + tft.drawCentreString("2.44Ghz", tftWidth/2,tftHeight-LH,1); + tft.drawRightString("2.48Ghz",tftWidth,tftHeight-LH,1); memset(channel,0,CHANNELS); if(nrf_start()) { diff --git a/src/modules/bjs_interpreter/interpreter.cpp b/src/modules/bjs_interpreter/interpreter.cpp index ebf4d7bb..c04e7af5 100644 --- a/src/modules/bjs_interpreter/interpreter.cpp +++ b/src/modules/bjs_interpreter/interpreter.cpp @@ -69,22 +69,22 @@ static duk_ret_t native_exit(duk_context *ctx) { static duk_ret_t native_getBoard(duk_context *ctx) { String board = "Undefined"; -#if defined(STICK_C_PLUS) +#if defined(ARDUINO_M5STICK_C_PLUS) board = "StickCPlus"; #endif -#if defined(STICK_C_PLUS2) +#if defined(ARDUINO_M5STICK_C_PLUS2) board = "StickCPlus2"; #endif -#if defined(CARDPUTER) +#if defined(ARDUINO_M5STACK_CARDPUTER) board = "Cardputer"; #endif -#if defined(CORE2) +#if defined(ARDUINO_M5STACK_CORE2) board = "Core2"; #endif -#if defined(CORE) +#if defined(ARDUINO_M5STACK_CORE) board = "Core"; #endif -#if defined(CORES3) +#if defined(ARDUINO_M5STACK_CORES3) board = "CoreS3/SE"; #endif duk_push_string(ctx, board.c_str()); @@ -826,7 +826,7 @@ String readScriptFile(FS fs, String filename) { } // Code interpreter, must be called in the loop() function to work bool interpreter() { - tft.fillRect(0,0,WIDTH,HEIGHT,TFT_BLACK); + tft.fillRect(0,0,tftWidth,tftHeight,TFT_BLACK); tft.setRotation(bruceConfig.rotation); tft.setTextSize(FM); tft.setTextColor(TFT_WHITE); diff --git a/src/modules/ble/bad_ble.cpp b/src/modules/ble/bad_ble.cpp index 88c62c73..66cfd99c 100644 --- a/src/modules/ble/bad_ble.cpp +++ b/src/modules/ble/bad_ble.cpp @@ -1,4 +1,4 @@ -#include "core/globals.h" +#include #include "core/sd_functions.h" #include "core/main_menu.h" #include "core/display.h" @@ -169,7 +169,7 @@ void key_input_ble(FS fs, String bad_script) { Kble.releaseAll(); - if (tft.getCursorY()>(HEIGHT-LH)) { + if (tft.getCursorY()>(tftHeight-LH)) { tft.setCursor(0, 0); tft.fillScreen(bruceConfig.bgColor); } @@ -388,7 +388,7 @@ void ble_keyboard() { drawMainBorder(); tft.setCursor(10,28); tft.println("BLE Keyboard:"); - tft.drawCentreString("> " + String(KB_HID_EXIT_MSG) + " <", WIDTH / 2, HEIGHT-20,1); + tft.drawCentreString("> " + String(KB_HID_EXIT_MSG) + " <", tftWidth / 2, tftHeight-20,1); tft.setTextSize(FM); String _mymsg=""; keyStroke key; @@ -418,8 +418,8 @@ void ble_keyboard() { if (keyStr.length() > 0) { drawMainBorder(false); - if(_mymsg.length()>keyStr.length()) tft.drawCentreString(" ", WIDTH / 2, HEIGHT / 2,1); // clears screen - tft.drawCentreString("Pressed: " + keyStr, WIDTH / 2, HEIGHT / 2,1); + if(_mymsg.length()>keyStr.length()) tft.drawCentreString(" ", tftWidth / 2, tftHeight / 2,1); // clears screen + tft.drawCentreString("Pressed: " + keyStr, tftWidth / 2, tftHeight / 2,1); _mymsg=keyStr; } delay(200); diff --git a/src/modules/ble/ble_common.cpp b/src/modules/ble/ble_common.cpp index 2b754f68..4ccdb473 100644 --- a/src/modules/ble/ble_common.cpp +++ b/src/modules/ble/ble_common.cpp @@ -1,5 +1,6 @@ #include "ble_common.h" #include "core/mykeyboard.h" +#include "core/utils.h" #define SERVICE_UUID "1bc68b2a-f3e3-11e9-81b4-2a2ae2dbcce4" #define CHARACTERISTIC_RX_UUID "1bc68da0-f3e3-11e9-81b4-2a2ae2dbcce4" @@ -51,11 +52,11 @@ void ble_info(String name, String address, String signal) { drawMainBorder(); tft.setTextColor(bruceConfig.priColor); - tft.drawCentreString("-=Information=-", WIDTH/2, 28,SMOOTH_FONT); + tft.drawCentreString("-=Information=-", tftWidth/2, 28,SMOOTH_FONT); tft.drawString("Name: " + name, 10, 48); tft.drawString("Adresse: " + address, 10, 66); tft.drawString("Signal: " + String(signal) + " dBm", 10, 84); - tft.drawCentreString(" Press " + String(BTN_ALIAS) + " to act",WIDTH/2,HEIGHT-20,1); + tft.drawCentreString(" Press " + String(BTN_ALIAS) + " to act",tftWidth/2,tftHeight-20,1); delay(300); while(!checkSelPress()) { @@ -167,7 +168,7 @@ void disPlayBLESend() if (deviceConnected) { if (!wasConnected) { - tft.fillRect(10, 26, WIDTH-20, HEIGHT-36, TFT_BLACK); + tft.fillRect(10, 26, tftWidth-20, tftHeight-36, TFT_BLACK); drawBLE_beacon(180, 28, TFT_BLUE); tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); tft.setTextSize(FM); @@ -176,7 +177,7 @@ void disPlayBLESend() tft.printf("BLE Send\n"); tft.setTextSize(FM); } - tft.fillRect(10, 100, WIDTH-20, 28, TFT_BLACK); + tft.fillRect(10, 100, tftWidth-20, 28, TFT_BLACK); tft.setCursor(12, 100); if (senddata[0] % 4 == 0) { @@ -209,7 +210,7 @@ void disPlayBLESend() { if (wasConnected or first_run) { first_run = false; - tft.fillRect(10, 26, WIDTH-20, HEIGHT-36, TFT_BLACK); + tft.fillRect(10, 26, tftWidth-20, tftHeight-36, TFT_BLACK); tft.setTextSize(2); tft.setCursor(12, 50); tft.setTextColor(TFT_RED); diff --git a/src/modules/ble/ble_common.h b/src/modules/ble/ble_common.h index faa4faf9..1067d9a3 100644 --- a/src/modules/ble/ble_common.h +++ b/src/modules/ble/ble_common.h @@ -1,3 +1,5 @@ +#ifndef __BLE_COMMON_H__ +#define __BLE_COMMON_H__ //#include #include @@ -8,10 +10,13 @@ #include #include -#include "core/globals.h" +#include #include "core/display.h" void ble_test(); + void ble_scan(); -void DisPlayBLESend(); +void disPlayBLESend(); + +#endif \ No newline at end of file diff --git a/src/modules/ble/ble_spam.cpp b/src/modules/ble/ble_spam.cpp index 582f43db..39ff9353 100644 --- a/src/modules/ble/ble_spam.cpp +++ b/src/modules/ble/ble_spam.cpp @@ -1,6 +1,6 @@ #include "core/display.h" #include "core/mykeyboard.h" -#include "core/globals.h" +#include #include "ble_spam.h" // Bluetooth maximum transmit power diff --git a/src/modules/fm/fm.cpp b/src/modules/fm/fm.cpp index 3e7286c8..e83cf25d 100644 --- a/src/modules/fm/fm.cpp +++ b/src/modules/fm/fm.cpp @@ -1,4 +1,5 @@ #include "fm.h" +#include "core/utils.h" bool auto_scan = false; bool is_running = false; @@ -16,7 +17,7 @@ void set_frq(uint16_t frq) { void fm_banner() { tft.fillScreen(bruceConfig.bgColor); tft.setCursor(10, 10); - tft.drawCentreString("~== Bruce Radio ==~", WIDTH/2, 10, SMOOTH_FONT); + tft.drawCentreString("~== Bruce Radio ==~", tftWidth/2, 10, SMOOTH_FONT); delay(500); } @@ -208,14 +209,14 @@ void fm_spectrum() { noise_level = radio.currNoiseLevel; if (noise_level != 0) { // Clear the display area - tft.fillRect(0, 40, WIDTH, HEIGHT, TFT_BLACK); + tft.fillRect(0, 40, tftWidth, tftHeight, TFT_BLACK); // Draw waveform based on signal strength for (size_t i = 0; i < noise_level; i++) { - int lineHeight = map(noise_level, 0, SIGNAL_STRENGTH_THRESHOLD, 0, HEIGHT/2); - int lineX = map(i, 0, noise_level - 1, 0, WIDTH - 1); // Map i to within the display width + int lineHeight = map(noise_level, 0, SIGNAL_STRENGTH_THRESHOLD, 0, tftHeight/2); + int lineX = map(i, 0, noise_level - 1, 0, tftWidth - 1); // Map i to within the display width // Ensure drawing coordinates stay within the box bounds - int startY = constrain(20 + HEIGHT / 2 - lineHeight / 2, 20, 20 + HEIGHT); - int endY = constrain(20 + HEIGHT / 2 + lineHeight / 2, 20, 20 + HEIGHT); + int startY = constrain(20 + tftHeight / 2 - lineHeight / 2, 20, 20 + tftHeight); + int endY = constrain(20 + tftHeight / 2 + lineHeight / 2, 20, 20 + tftHeight); tft.drawLine(lineX, startY, lineX, endY, TFT_PURPLE); } } diff --git a/src/modules/fm/fm.h b/src/modules/fm/fm.h index fab2bfcb..7b10f5f9 100644 --- a/src/modules/fm/fm.h +++ b/src/modules/fm/fm.h @@ -1,11 +1,21 @@ +#ifndef __FM_H__ +#define __FM_H__ + #include -#include "core/globals.h" +#include #include "core/display.h" #include "core/mykeyboard.h" void fm_live_run(bool reserved=true); + void fm_ta_run(); + bool fm_begin(); + bool fm_setup(bool traffic_alert=false, bool silent=false); + void fm_stop(); + void fm_spectrum(); + +#endif \ No newline at end of file diff --git a/src/modules/gps/gps_tracker.h b/src/modules/gps/gps_tracker.h index ddcd24a4..882a90a9 100644 --- a/src/modules/gps/gps_tracker.h +++ b/src/modules/gps/gps_tracker.h @@ -6,10 +6,10 @@ * @date 2024-11-20 */ -#ifndef GPS_TRACKER_H -#define GPS_TRACKER_H +#ifndef __GPS_TRACKER_H__ +#define __GPS_TRACKER_H__ -#include "core/globals.h" +#include #include diff --git a/src/modules/gps/wardriving.h b/src/modules/gps/wardriving.h index 49bcfcd7..9560cffc 100644 --- a/src/modules/gps/wardriving.h +++ b/src/modules/gps/wardriving.h @@ -6,10 +6,10 @@ * @note Updated: 2024-08-28 by Rennan Cockles (https://github.com/rennancockles) */ -#ifndef WAR_DRIVING_H -#define WAR_DRIVING_H +#ifndef __WAR_DRIVING_H__ +#define __WAR_DRIVING_H__ -#include "core/globals.h" +#include #include #include #include diff --git a/src/modules/ir/TV-B-Gone.cpp b/src/modules/ir/TV-B-Gone.cpp index 8b0eb57f..c439061e 100644 --- a/src/modules/ir/TV-B-Gone.cpp +++ b/src/modules/ir/TV-B-Gone.cpp @@ -15,7 +15,7 @@ Distributed under Creative Commons 2.5 -- Attribution & Share Alike #include "core/settings.h" #include "WORLD_IR_CODES.h" #include "TV-B-Gone.h" - +#include "core/utils.h" /* Last Updated: 30 Mar. 2018 diff --git a/src/modules/ir/TV-B-Gone.h b/src/modules/ir/TV-B-Gone.h index c72cfcac..a0494535 100644 --- a/src/modules/ir/TV-B-Gone.h +++ b/src/modules/ir/TV-B-Gone.h @@ -55,7 +55,7 @@ Distributed under Creative Commons 2.5 -- Attribution & Share Alike #include #include #include -#include "core/globals.h" +#include //void xmitCodeElement(uint16_t ontime, uint16_t offtime, uint8_t PWM_code ); void quickflashLEDx( uint8_t x ); diff --git a/src/modules/ir/custom_ir.h b/src/modules/ir/custom_ir.h index 4886dca4..dabbb8aa 100644 --- a/src/modules/ir/custom_ir.h +++ b/src/modules/ir/custom_ir.h @@ -4,7 +4,7 @@ #include #include #include -#include "core/globals.h" +#include diff --git a/src/modules/ir/ir_read.cpp b/src/modules/ir/ir_read.cpp index 3ba354ae..a3214b21 100644 --- a/src/modules/ir/ir_read.cpp +++ b/src/modules/ir/ir_read.cpp @@ -10,7 +10,7 @@ #include #include #include "ir_read.h" -#include "core/globals.h" +#include #include "core/mykeyboard.h" #include "core/display.h" #include "core/sd_functions.h" diff --git a/src/modules/ir/ir_read.h b/src/modules/ir/ir_read.h index 00180f86..9b6e715a 100644 --- a/src/modules/ir/ir_read.h +++ b/src/modules/ir/ir_read.h @@ -7,7 +7,7 @@ */ #include -#include "core/globals.h" +#include class IrRead { diff --git a/src/modules/others/bad_usb.cpp b/src/modules/others/bad_usb.cpp index a73e28ab..794c8a7e 100644 --- a/src/modules/others/bad_usb.cpp +++ b/src/modules/others/bad_usb.cpp @@ -1,5 +1,5 @@ -#include "core/globals.h" +#include #include "core/sd_functions.h" #include "core/main_menu.h" #include "core/display.h" @@ -179,7 +179,7 @@ void key_input(FS fs, String bad_script) { Kb.releaseAll(); - if (tft.getCursorY()>(HEIGHT-LH)) { + if (tft.getCursorY()>(tftHeight-LH)) { tft.setCursor(0, 0); tft.fillScreen(bruceConfig.bgColor); } @@ -369,8 +369,8 @@ void usb_keyboard() { tft.setTextSize(2); tft.setTextColor(bruceConfig.priColor); tft.drawString("Keyboard Started", - WIDTH / 2, - HEIGHT / 2); + tftWidth / 2, + tftHeight / 2); options = { {"US Inter", [=]() { chooseKb(KeyboardLayout_en_US); }}, {"PT-BR ABNT2", [=]() { chooseKb(KeyboardLayout_pt_BR); }}, @@ -396,7 +396,7 @@ void usb_keyboard() { drawMainBorder(); tft.setCursor(10,28); tft.println("Usb Keyboard:"); - tft.drawCentreString("> " + String(KB_HID_EXIT_MSG) + " <", WIDTH / 2, HEIGHT-20,1); + tft.drawCentreString("> " + String(KB_HID_EXIT_MSG) + " <", tftWidth / 2, tftHeight-20,1); tft.setTextSize(FM); String _mymsg=""; keyStroke key; @@ -425,8 +425,8 @@ void usb_keyboard() { if (keyStr.length() > 0) { drawMainBorder(false); - if(_mymsg.length()>keyStr.length()) tft.drawCentreString(" ", WIDTH / 2, HEIGHT / 2,1); // clears screen - tft.drawCentreString("Pressed: " + keyStr, WIDTH / 2, HEIGHT / 2,1); + if(_mymsg.length()>keyStr.length()) tft.drawCentreString(" ", tftWidth / 2, tftHeight / 2,1); // clears screen + tft.drawCentreString("Pressed: " + keyStr, tftWidth / 2, tftHeight / 2,1); _mymsg=keyStr; } delay(200); diff --git a/src/modules/others/led.cpp b/src/modules/others/led.cpp index 2c8db175..04c31d10 100644 --- a/src/modules/others/led.cpp +++ b/src/modules/others/led.cpp @@ -2,7 +2,7 @@ // By @IncursioHack - github.com/IncursioHack #include #include "core/display.h" -#include "core/globals.h" +#include #include "led_control.h" // Escolha o tipo de LED na lista abaixo. diff --git a/src/modules/others/mic.h b/src/modules/others/mic.h index de92b91b..facbba3c 100644 --- a/src/modules/others/mic.h +++ b/src/modules/others/mic.h @@ -14,7 +14,7 @@ #include #include "driver/i2s.h" #include "core/display.h" -#include "core/globals.h" +#include /* Mic */ void mic_init(); diff --git a/src/modules/others/openhaystack.cpp b/src/modules/others/openhaystack.cpp index 97c9eb4d..a66ad81e 100644 --- a/src/modules/others/openhaystack.cpp +++ b/src/modules/others/openhaystack.cpp @@ -12,7 +12,7 @@ #include "esp_bt_main.h" #include "freertos/FreeRTOS.h" -#include "core/globals.h" +#include #include "core/display.h" #include "core/sd_functions.h" #include "openhaystack.h" diff --git a/src/modules/others/qrcode_menu.cpp b/src/modules/others/qrcode_menu.cpp index 923197e5..c3369780 100644 --- a/src/modules/others/qrcode_menu.cpp +++ b/src/modules/others/qrcode_menu.cpp @@ -4,7 +4,7 @@ #include "core/mykeyboard.h" #include "qrcode_menu.h" #include "core/config.h" - +#include "core/utils.h" uint16_t crc_ccitt_update(uint16_t crc, uint8_t data) { crc = (uint8_t)(crc >> 8) | (crc << 8); diff --git a/src/modules/others/timer.cpp b/src/modules/others/timer.cpp index 7438975c..c3ddb158 100644 --- a/src/modules/others/timer.cpp +++ b/src/modules/others/timer.cpp @@ -40,7 +40,7 @@ void Timer::loop() { tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); drawMainBorder(false); tft.setTextSize(4); - tft.drawCentreString(timeString, WIDTH / 2, HEIGHT / 2 - 13, 1); + tft.drawCentreString(timeString, tftWidth / 2, tftHeight / 2 - 13, 1); if (checkEscPress()) { duration = 0; @@ -66,8 +66,8 @@ void Timer::setup() { int minutes = 0; int seconds = 0; int settingMode = 0; - int underlineHeight = HEIGHT / 3 * 2; - int underlineWidth = WIDTH / 5; + int underlineHeight = tftHeight / 3 * 2; + int underlineWidth = tftWidth / 5; char timeString[9]; @@ -82,17 +82,17 @@ void Timer::setup() { tft.setTextSize(2); drawMainBorderWithTitle("Set a timer", false); tft.setTextSize(4); - tft.drawCentreString(timeString, WIDTH / 2, HEIGHT / 2 - 13, 1); + tft.drawCentreString(timeString, tftWidth / 2, tftHeight / 2 - 13, 1); if (settingMode == 0) { - tft.drawLine(WIDTH / 10 * 7, underlineHeight, WIDTH / 10 * 7 + underlineWidth, underlineHeight, bruceConfig.bgColor); - tft.drawLine(WIDTH / 10, underlineHeight, WIDTH / 10 + underlineWidth, underlineHeight, bruceConfig.priColor); + tft.drawLine(tftWidth / 10 * 7, underlineHeight, tftWidth / 10 * 7 + underlineWidth, underlineHeight, bruceConfig.bgColor); + tft.drawLine(tftWidth / 10, underlineHeight, tftWidth / 10 + underlineWidth, underlineHeight, bruceConfig.priColor); } else if (settingMode == 1) { - tft.drawLine(WIDTH / 10, underlineHeight, WIDTH / 10 + underlineWidth, underlineHeight, bruceConfig.bgColor); - tft.drawLine(WIDTH / 10 * 4, underlineHeight, WIDTH / 10 * 4 + underlineWidth, underlineHeight, bruceConfig.priColor); + tft.drawLine(tftWidth / 10, underlineHeight, tftWidth / 10 + underlineWidth, underlineHeight, bruceConfig.bgColor); + tft.drawLine(tftWidth / 10 * 4, underlineHeight, tftWidth / 10 * 4 + underlineWidth, underlineHeight, bruceConfig.priColor); } else if (settingMode == 2) { - tft.drawLine(WIDTH / 10 * 4, underlineHeight, WIDTH / 10 * 4 + underlineWidth, underlineHeight, bruceConfig.bgColor); - tft.drawLine(WIDTH / 10 * 7, underlineHeight, WIDTH / 10 * 7 + underlineWidth, underlineHeight, bruceConfig.priColor); + tft.drawLine(tftWidth / 10 * 4, underlineHeight, tftWidth / 10 * 4 + underlineWidth, underlineHeight, bruceConfig.bgColor); + tft.drawLine(tftWidth / 10 * 7, underlineHeight, tftWidth / 10 * 7 + underlineWidth, underlineHeight, bruceConfig.priColor); } if (checkNextPress()) { diff --git a/src/modules/others/tururururu.cpp b/src/modules/others/tururururu.cpp index 4e29518d..70862bd7 100644 --- a/src/modules/others/tururururu.cpp +++ b/src/modules/others/tururururu.cpp @@ -1,5 +1,5 @@ #include "core/mykeyboard.h" -#include "core/globals.h" +#include #include "core/display.h" #include "tururururu.h" @@ -22,7 +22,7 @@ int score = 0; void initSprites() { //sprite para desenhar a tela toda //tft.deleteSprite(); - //tft.createSprite(WIDTH,HEIGHT); + //tft.createSprite(tftWidth,tftHeight); tft.fillScreen(bruceConfig.bgColor); //menu_op para desenhar o tubarao @@ -65,7 +65,7 @@ void drawFish(Fish &f) { // Função para mover o tubarão void moveShark() { - #if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2) || defined(M5STACK) || defined(CYD) // checkEscPress is the same of checkPrevPress in these devices + #if defined(ARDUINO_M5STICK_C_PLUS) || defined(ARDUINO_M5STICK_C_PLUS2) || defined(M5STACK) || defined(CYD) // checkEscPress is the same of checkPrevPress in these devices if (checkSelPress()) #else if (checkPrevPress()) @@ -81,8 +81,8 @@ void moveShark() { if (sharkY < 0) { sharkY = 0; } - if (sharkY > HEIGHT - sharkSize) { - sharkY = HEIGHT - sharkSize; + if (sharkY > tftHeight - sharkSize) { + sharkY = tftHeight - sharkSize; } } @@ -91,8 +91,8 @@ void moveFish(Fish &f) { f.x -= 2; // Move o peixe para a esquerda if (f.x < -10) { tft.fillRect(f.x,f.y,22,11,bruceConfig.bgColor); - f.x = WIDTH + random(20, 100); - f.y = random(10, HEIGHT - 20); + f.x = tftWidth + random(20, 100); + f.y = random(10, tftHeight - 20); } } @@ -103,8 +103,8 @@ void checkCollisions() { (sharkY < fish[i].y + fish[i].size) && (sharkY + sharkSize > fish[i].y)) { // Colidiu com um peixe tft.fillRect(fish[i].x,fish[i].y,18,8,bruceConfig.bgColor); - fish[i].x = WIDTH + random(20, 100); - fish[i].y = random(10, HEIGHT - 20); + fish[i].x = tftWidth + random(20, 100); + fish[i].y = random(10, tftHeight - 20); score++; } } @@ -121,8 +121,8 @@ void displayScore() { void shark_setup() { // Inicializa a posição dos peixes for (int i = 0; i < 5; i++) { - fish[i].x = WIDTH + random(20, 100); - fish[i].y = random(10, HEIGHT - 20); + fish[i].x = tftWidth + random(20, 100); + fish[i].y = random(10, tftHeight - 20); fish[i].size = 8; } //desenha peixes e inicia o display diff --git a/src/modules/others/tururururu.h b/src/modules/others/tururururu.h index 343fab68..ce4b1fe1 100644 --- a/src/modules/others/tururururu.h +++ b/src/modules/others/tururururu.h @@ -1,4 +1,4 @@ -#include "core/globals.h" +#include #include "core/display.h" // Configuração do personagem principal (tubarão) diff --git a/src/modules/others/webInterface.cpp b/src/modules/others/webInterface.cpp index eafb6e51..df7f80bb 100644 --- a/src/modules/others/webInterface.cpp +++ b/src/modules/others/webInterface.cpp @@ -1,4 +1,4 @@ -#include "core/globals.h" +#include #include "core/sd_functions.h" // using sd functions called to rename and manage sd files #include "core/wifi_common.h" // using common wifisetup #include "core/mykeyboard.h" // using keyboard when calling rename @@ -236,19 +236,19 @@ void handleFileUpload(FS fs) { void drawWebUiScreen(bool mode_ap) { tft.fillScreen(bruceConfig.bgColor); tft.fillScreen(bruceConfig.bgColor); - tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,ALCOLOR); + tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,ALCOLOR); if(mode_ap) { setTftDisplay(0,0,bruceConfig.bgColor,FM); - tft.drawCentreString("BruceNet/brucenet",WIDTH/2,7,1); + tft.drawCentreString("BruceNet/brucenet",tftWidth/2,7,1); } setTftDisplay(0,0,ALCOLOR,FM); - tft.drawCentreString("BRUCE WebUI",WIDTH/2,27,1); + tft.drawCentreString("BRUCE WebUI",tftWidth/2,27,1); String txt; if(!mode_ap) txt = WiFi.localIP().toString(); else txt = WiFi.softAPIP().toString(); tft.setTextColor(bruceConfig.priColor); - tft.drawCentreString("http://bruce.local", WIDTH/2,45,1); + tft.drawCentreString("http://bruce.local", tftWidth/2,45,1); setTftDisplay(7,67); tft.setTextSize(FM); @@ -262,7 +262,7 @@ void drawWebUiScreen(bool mode_ap) { tft.setTextSize(FP); - tft.drawCentreString("press Esc to stop", WIDTH/2,HEIGHT-15,1); + tft.drawCentreString("press Esc to stop", tftWidth/2,tftHeight-15,1); } diff --git a/src/modules/pwnagotchi/spam.cpp b/src/modules/pwnagotchi/spam.cpp index e77f47a6..2c151245 100644 --- a/src/modules/pwnagotchi/spam.cpp +++ b/src/modules/pwnagotchi/spam.cpp @@ -152,7 +152,7 @@ void displaySpamStatus() { tft.fillScreen(TFT_BLACK); drawTopCanvas(); drawBottomCanvas(); - tft.fillRect(0, 20, WIDTH, HEIGHT - 40, bruceConfig.bgColor); + tft.fillRect(0, 20, tftWidth, tftHeight - 40, bruceConfig.bgColor); tft.setTextSize(1.5); tft.setCursor(0, 20); tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); @@ -356,7 +356,7 @@ void send_pwnagotchi_beacon_main() { spamRunning = true; // Clear screen - tft.fillRect(0, 20, WIDTH, HEIGHT - 40, bruceConfig.bgColor); + tft.fillRect(0, 20, tftWidth, tftHeight - 40, bruceConfig.bgColor); // Créer la tâche beacon xTaskCreate(&beacon_task, "beacon_task", 4096, NULL, 5, NULL); diff --git a/src/modules/pwnagotchi/ui.cpp b/src/modules/pwnagotchi/ui.cpp index df03f2fd..d16c495c 100644 --- a/src/modules/pwnagotchi/ui.cpp +++ b/src/modules/pwnagotchi/ui.cpp @@ -30,8 +30,8 @@ void initUi() { tft.fillScreen(bruceConfig.bgColor); tft.setTextColor(bruceConfig.priColor); - display_w = WIDTH; - display_h = HEIGHT; + display_w = tftWidth; + display_h = tftHeight; canvas_h = display_h * .8; canvas_center_x = display_w / 2; canvas_top_h = display_h * .1; diff --git a/src/modules/pwnagotchi/ui.h b/src/modules/pwnagotchi/ui.h index 47fcccb4..d0300dd6 100644 --- a/src/modules/pwnagotchi/ui.h +++ b/src/modules/pwnagotchi/ui.h @@ -13,7 +13,6 @@ Thanks to @bmorcelli for his help doing a better code. void initUi(); void wakeUp(); -void drawNearbyMenu(); void drawMood(String face, String phrase, bool broken = false); void drawTime(); void drawFooterData(uint8_t friends_run = 0, uint8_t friends_tot = 0, diff --git a/src/modules/reverseShell/reverseShell.cpp b/src/modules/reverseShell/reverseShell.cpp index 45f2a013..9d87c3dd 100644 --- a/src/modules/reverseShell/reverseShell.cpp +++ b/src/modules/reverseShell/reverseShell.cpp @@ -20,7 +20,7 @@ void ReverseShell() { tft.fillScreen(bruceConfig.bgColor); tft.setTextSize(FM); tft.setTextColor(TFT_RED, bruceConfig.bgColor); - tft.drawCentreString("Reverse Shell", WIDTH / 2, 10, 1); + tft.drawCentreString("Reverse Shell", tftWidth / 2, 10, 1); tft.setTextColor(TFT_WHITE, bruceConfig.bgColor); tft.setTextSize(FP); tft.setCursor(15,33); diff --git a/src/modules/rf/rf.cpp b/src/modules/rf/rf.cpp index 81c51be9..08190a8d 100644 --- a/src/modules/rf/rf.cpp +++ b/src/modules/rf/rf.cpp @@ -4,7 +4,7 @@ #include #include #include "PCA9554.h" -#include "core/globals.h" +#include #include "core/mykeyboard.h" #include "core/display.h" #include "core/sd_functions.h" @@ -96,14 +96,14 @@ void rf_spectrum() { //@IncursioHack - https://github.com/IncursioHack ----thank if (item != nullptr) { if (rx_size != 0) { // Clear the display area - tft.fillRect(0, 20, WIDTH, HEIGHT, bruceConfig.bgColor); + tft.fillRect(0, 20, tftWidth, tftHeight, bruceConfig.bgColor); // Draw waveform based on signal strength for (size_t i = 0; i < rx_size; i++) { - int lineHeight = map(item[i].duration0 + item[i].duration1, 0, SIGNAL_STRENGTH_THRESHOLD, 0, HEIGHT/2); - int lineX = map(i, 0, rx_size - 1, 0, WIDTH - 1); // Map i to within the display width + int lineHeight = map(item[i].duration0 + item[i].duration1, 0, SIGNAL_STRENGTH_THRESHOLD, 0, tftHeight/2); + int lineX = map(i, 0, rx_size - 1, 0, tftWidth - 1); // Map i to within the display width // Ensure drawing coordinates stay within the box bounds - int startY = constrain(20 + HEIGHT / 2 - lineHeight / 2, 20, 20 + HEIGHT); - int endY = constrain(20 + HEIGHT / 2 + lineHeight / 2, 20, 20 + HEIGHT); + int startY = constrain(20 + tftHeight / 2 - lineHeight / 2, 20, 20 + tftHeight); + int endY = constrain(20 + tftHeight / 2 + lineHeight / 2, 20, 20 + tftHeight); tft.drawLine(lineX, startY, lineX, endY, bruceConfig.priColor); } } @@ -144,17 +144,17 @@ void rf_SquareWave() { //@Pirata if (rcswitch.RAWavailable()) { raw=rcswitch.getRAWReceivedRawdata(); // Clear the display area - // tft.fillRect(0, 0, WIDTH, HEIGHT, bruceConfig.bgColor); + // tft.fillRect(0, 0, tftWidth, tftHeight, bruceConfig.bgColor); // Draw waveform based on signal strength for (int i = 0; i < RCSWITCH_RAW_MAX_CHANGES-1; i+=2) { if(raw[i]==0) break; - #define TIME_DIVIDER WIDTH/8 + #define TIME_DIVIDER tftWidth/8 if(raw[i]>20000) raw[i]=20000; if(raw[i+1]>20000) raw[i+1]=20000; - if(line_w+(raw[i]+raw[i+1])/TIME_DIVIDER>WIDTH) { line_w=10; line_h+=10; } - if(line_h>HEIGHT) { + if(line_w+(raw[i]+raw[i+1])/TIME_DIVIDER>tftWidth) { line_w=10; line_h+=10; } + if(line_h>tftHeight) { line_h = 15; - tft.fillRect(0, 12, WIDTH, HEIGHT, bruceConfig.bgColor); + tft.fillRect(0, 12, tftWidth, tftHeight, bruceConfig.bgColor); } tft.drawFastVLine(line_w ,line_h ,6 ,bruceConfig.priColor); tft.drawFastHLine(line_w ,line_h ,raw[i]/TIME_DIVIDER ,bruceConfig.priColor); @@ -187,18 +187,18 @@ void setMHZ(float frequency) { // SW1:1 SW0:1 --- 434MHz if (frequency <= 350) { - digitalWrite(BOARD_LORA_SW1, HIGH); - digitalWrite(BOARD_LORA_SW0, LOW); + digitalWrite(CC1101_SW1_PIN, HIGH); + digitalWrite(CC1101_SW0_PIN, LOW); } else if (frequency > 350 && frequency < 468 ) { - digitalWrite(BOARD_LORA_SW1, HIGH); - digitalWrite(BOARD_LORA_SW0, HIGH); + digitalWrite(CC1101_SW1_PIN, HIGH); + digitalWrite(CC1101_SW0_PIN, HIGH); } else if (frequency > 778) { - digitalWrite(BOARD_LORA_SW1, LOW); - digitalWrite(BOARD_LORA_SW0, HIGH); + digitalWrite(CC1101_SW1_PIN, LOW); + digitalWrite(CC1101_SW0_PIN, HIGH); } #endif @@ -549,7 +549,7 @@ void deinitRfModule() { #ifdef USE_CC1101_VIA_SPI #if CC1101_MOSI_PIN==TFT_MOSI || CC1101_MOSI_PIN==SDCARD_MOSI // (T_EMBED), CORE2 and others ELECHOUSE_cc1101.setSidle(); - #else // (STICK_C_PLUS) || (STICK_C_PLUS2) and others that doesn´t share SPI with other devices (need to change it when Bruce board comes to shore) + #else // (ARDUINO_M5STICK_C_PLUS) || (ARDUINO_M5STICK_C_PLUS2) and others that doesn´t share SPI with other devices (need to change it when Bruce board comes to shore) ELECHOUSE_cc1101.getSPIinstance()->end(); #endif #else @@ -564,9 +564,9 @@ void deinitRfModule() { bool initRfModule(String mode, float frequency) { #if CC1101_MOSI_PIN==TFT_MOSI // (T_EMBED), CORE2 and others initCC1101once(&tft.getSPIinstance()); - #elif CC1101_MOSI_PIN==SDCARD_MOSI // (CARDPUTER) and (ESP32S3DEVKITC1) and devices that share CC1101 pin with only SDCard + #elif CC1101_MOSI_PIN==SDCARD_MOSI // (ARDUINO_M5STACK_CARDPUTER) and (ESP32S3DEVKITC1) and devices that share CC1101 pin with only SDCard ELECHOUSE_cc1101.setSPIinstance(&sdcardSPI); - #else // (STICK_C_PLUS) || (STICK_C_PLUS2) and others that doesn´t share SPI with other devices (need to change it when Bruce board comes to shore) + #else // (ARDUINO_M5STICK_C_PLUS) || (ARDUINO_M5STICK_C_PLUS2) and others that doesn´t share SPI with other devices (need to change it when Bruce board comes to shore) ELECHOUSE_cc1101.setBeginEndLogic(true); // make sure to use BeginEndLogic for StickCs in the shared pins (not bus) config initCC1101once(NULL); #endif diff --git a/src/modules/rfid/RFIDInterface.h b/src/modules/rfid/RFIDInterface.h index 47531e17..050b912f 100644 --- a/src/modules/rfid/RFIDInterface.h +++ b/src/modules/rfid/RFIDInterface.h @@ -10,7 +10,7 @@ #ifndef __RFID_INTERFACE_H__ #define __RFID_INTERFACE_H__ -#include "core/globals.h" +#include class RFIDInterface { diff --git a/src/modules/rfid/pn532ble.cpp b/src/modules/rfid/pn532ble.cpp index 55041c26..1cf47bf2 100644 --- a/src/modules/rfid/pn532ble.cpp +++ b/src/modules/rfid/pn532ble.cpp @@ -436,7 +436,7 @@ void Pn532ble::hf14aMfReadDumpMode() mfd.clear(); padprintln("UID: " + tagInfo.uid_hex); - ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38); + ScrollableTextArea area(FP, 10, 28, tftWidth - 20, tftHeight - 38); if (tagInfo.sak == 0x08 || tagInfo.sak == 0x09 || tagInfo.sak == 0x18) { @@ -652,7 +652,7 @@ void Pn532ble::hf14aMfWriteDumpMode() } padprintln("UID: " + tagInfo.uid_hex); - ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38); + ScrollableTextArea area(FP, 10, 28, tftWidth - 20, tftHeight - 38); padprintln("Type: " + tagInfo.type); if (mfd.size() == 1024 && pn532_ble.isGen1A()) @@ -903,7 +903,7 @@ void Pn532ble::hf15ReadDumpMode() padprintln("UID: " + tagInfo.uid_hex); padprintln("Checking Tag..."); tagInfo = pn532_ble.hf15Info(); - ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38); + ScrollableTextArea area(FP, 10, 28, tftWidth - 20, tftHeight - 38); iso15dump.clear(); if (tagInfo.blockSize > 0) @@ -967,7 +967,7 @@ void Pn532ble::hf15WriteDumpMode() padprintln("UID: " + tagInfo.uid_hex); padprintln("Checking Tag..."); tagInfo = pn532_ble.hf15Info(); - ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38); + ScrollableTextArea area(FP, 10, 28, tftWidth - 20, tftHeight - 38); iso15dump.clear(); if (tagInfo.blockSize > 0) @@ -1057,7 +1057,7 @@ void Pn532ble::loadMifareClassicDumpFile() displayBanner(); - ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38); + ScrollableTextArea area(FP, 10, 28, tftWidth - 20, tftHeight - 38); area.addLine("Dump: " + filePath); area.addLine("Size: " + String(mfd.size())); area.addLine("------------"); @@ -1124,7 +1124,7 @@ void Pn532ble::loadMifareUltralightDumpFile() displayBanner(); - ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38); + ScrollableTextArea area(FP, 10, 28, tftWidth - 20, tftHeight - 38); area.addLine("Dump: " + filePath); area.addLine("Size: " + String(mfd.size())); area.addLine("------------"); @@ -1191,7 +1191,7 @@ void Pn532ble::loadIso15693DumpFile() displayBanner(); - ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38); + ScrollableTextArea area(FP, 10, 28, tftWidth - 20, tftHeight - 38); area.addLine("Dump: " + filePath); area.addLine("Size: " + String(iso15dump.size())); area.addLine("------------"); diff --git a/src/modules/rfid/pn532ble.h b/src/modules/rfid/pn532ble.h index e5735187..ba80fdbd 100644 --- a/src/modules/rfid/pn532ble.h +++ b/src/modules/rfid/pn532ble.h @@ -40,7 +40,6 @@ class Pn532ble PN532_BLE pn532_ble = PN532_BLE(true); std::vector buffer; - void onNotify(uint8_t *data, size_t length); void displayBanner(); void showDeviceInfo(); void hf14aScan(); diff --git a/src/modules/rfid/rfid125.cpp b/src/modules/rfid/rfid125.cpp index 1879bc48..46df5b9d 100644 --- a/src/modules/rfid/rfid125.cpp +++ b/src/modules/rfid/rfid125.cpp @@ -7,7 +7,7 @@ */ #include "rfid125.h" -#include "core/globals.h" +#include #include "core/mykeyboard.h" #include "core/display.h" #include "core/sd_functions.h" diff --git a/src/modules/rfid/rfid125.h b/src/modules/rfid/rfid125.h index e13d9e00..1a28da2a 100644 --- a/src/modules/rfid/rfid125.h +++ b/src/modules/rfid/rfid125.h @@ -6,10 +6,10 @@ * @date 2024-08-13 */ -#ifndef _RFID125_h_ -#define _RFID125_h_ +#ifndef __RFID125_H__ +#define __RFID125_H__ -#include "core/globals.h" +#include #define RFID125_PACKET_SIZE 14 #define RFID125_START_MARK 0x02 diff --git a/src/modules/wifi/ap_info.cpp b/src/modules/wifi/ap_info.cpp index bd2a20fd..7924469c 100644 --- a/src/modules/wifi/ap_info.cpp +++ b/src/modules/wifi/ap_info.cpp @@ -5,7 +5,7 @@ #include "core/display.h" #include "core/mykeyboard.h" #include "core/net_utils.h" -#include "core/globals.h" +#include #include "lwip/etharp.h" #include "core/scrollableTextArea.h" @@ -104,23 +104,24 @@ void fillInfo(ScrollableTextArea& area){ wifi_ap_record_t ap_info; err_t res; if( (res = esp_wifi_sta_get_ap_info(&ap_info)) != ESP_OK ){ - String err; - switch (res) { - case ESP_ERR_WIFI_CONN: - err = "iface is not initialized"; - break; - case ESP_ERR_WIFI_NOT_CONNECT: - err = "station disconnected"; - break; - default: - err = "failed with" + String(res); - break; - } - - tft.print(err); - - while(checkSelPress()) yield(); - while(!checkSelPress()) yield(); + String err; + switch (res) + { + case ESP_ERR_WIFI_CONN: + err = "iface is not initialized"; + break; + case ESP_ERR_WIFI_NOT_CONNECT: + err = "station disconnected"; + break; + default: + err = "failed with" + String(res); + break; + } + + tft.print(err); + + while(checkSelPress()) yield(); + while(!checkSelPress()) yield(); } const auto mac = MAC(ap_info.bssid); @@ -144,8 +145,23 @@ void fillInfo(ScrollableTextArea& area){ area.addLine("Antenna: " + String(ap_info.ant)); } +void update(ScrollableTextArea& area){ + if( checkPrevPress() ){ + area.scrollUp(); + } else if( checkNextPress() ){ + area.scrollDown(); + } + area.draw(); +} + void displayAPInfo(){ - ScrollableTextArea area = ScrollableTextArea("AP INFO"); + drawMainBorder(); + + // offset header and border + ScrollableTextArea area(FP, 10, 30, tftWidth - 20, tftHeight - 40); + fillInfo(area); - area.show(); -} + + while(checkSelPress()){ update(area); yield();} + while(!checkSelPress()){ update(area); yield();} +} \ No newline at end of file diff --git a/src/modules/wifi/ap_info.h b/src/modules/wifi/ap_info.h index 0ae4338a..3ca50db0 100644 --- a/src/modules/wifi/ap_info.h +++ b/src/modules/wifi/ap_info.h @@ -1 +1,6 @@ -void displayAPInfo(); \ No newline at end of file +#ifndef __AP_INFO_H__ +#define __AP_INFO_H__ + +void displayAPInfo(); + +#endif \ No newline at end of file diff --git a/src/modules/wifi/clients.cpp b/src/modules/wifi/clients.cpp index d5c202e3..e5ec92cd 100644 --- a/src/modules/wifi/clients.cpp +++ b/src/modules/wifi/clients.cpp @@ -15,7 +15,7 @@ #include #include #include -#include "core/globals.h" +#include #include "core/display.h" #include "core/mykeyboard.h" #include "core/wifi_common.h" @@ -227,9 +227,9 @@ void ssh_loop(void *pvParameters) { ssh_channel_write(channel_ssh, message.c_str(), message.length()); // Send the command } cursorY = tft.getCursorY(); // Update cursor position - if(cursorY > HEIGHT) { - tft.setCursor(0,HEIGHT-10); - tft.fillRect(0,HEIGHT-11,WIDTH,11, bruceConfig.bgColor); + if(cursorY > tftHeight) { + tft.setCursor(0,tftHeight-10); + tft.fillRect(0,tftHeight-11,tftWidth,11, bruceConfig.bgColor); } } @@ -270,7 +270,7 @@ void ssh_loop(void *pvParameters) { msg += char(buffer[i]); if (buffer[i] == '\r') continue; // Ignore carriage return tft.write(buffer[i]); - if(tft.getCursorY()>HEIGHT) { + if(tft.getCursorY()>tftHeight) { tft.fillScreen(bruceConfig.bgColor); tft.setCursor(0,0); tft.setTextColor(TFT_GREEN); @@ -282,9 +282,9 @@ void ssh_loop(void *pvParameters) { log_d("%s", msg); cursorY = tft.getCursorY(); // Update cursor position - if(cursorY > HEIGHT) { - tft.setCursor(0,HEIGHT-10); - tft.fillRect(0,HEIGHT-11,WIDTH,11, bruceConfig.bgColor); + if(cursorY > tftHeight) { + tft.setCursor(0,tftHeight-10); + tft.fillRect(0,tftHeight-11,tftWidth,11, bruceConfig.bgColor); } commandBuffer = "> "; // Reset command buffer tft.setTextColor(TFT_GREEN); diff --git a/src/modules/wifi/clients.h b/src/modules/wifi/clients.h index 1aa11809..1334ba38 100644 --- a/src/modules/wifi/clients.h +++ b/src/modules/wifi/clients.h @@ -1,3 +1,6 @@ +#ifndef __CLIENTS_H__ +#define __CLIENTS_H__ + #include void telnet_setup(); @@ -6,4 +9,6 @@ void ssh_setup(String host = ""); void ssh_loop(void *pvParameters); -char* stringTochar(String s); \ No newline at end of file +char* stringTochar(String s); + +#endif \ No newline at end of file diff --git a/src/modules/wifi/dpwo.cpp b/src/modules/wifi/dpwo.cpp index 09ee172c..e5579129 100644 --- a/src/modules/wifi/dpwo.cpp +++ b/src/modules/wifi/dpwo.cpp @@ -10,7 +10,7 @@ #define SD_CREDS_PATH "/dpwo_creds.txt" -#include "core/globals.h" +#include #include "core/sd_functions.h" #include "dpwo.h" diff --git a/src/modules/wifi/evil_portal.h b/src/modules/wifi/evil_portal.h index cb2fda84..19bebab7 100644 --- a/src/modules/wifi/evil_portal.h +++ b/src/modules/wifi/evil_portal.h @@ -1,9 +1,9 @@ -#ifndef EVIL_PORTAL_H -#define EVIL_PORTAL_H +#ifndef __EVIL_PORTAL_H__ +#define __EVIL_PORTAL_H__ #include #include -#include "core/globals.h" +#include class EvilPortal { @@ -64,6 +64,4 @@ class EvilPortal { String ssid_POST(void); }; -#endif // EVIL_PORTAL_H - - +#endif \ No newline at end of file diff --git a/src/modules/wifi/scan_hosts.cpp b/src/modules/wifi/scan_hosts.cpp index d8e52e36..c751d180 100644 --- a/src/modules/wifi/scan_hosts.cpp +++ b/src/modules/wifi/scan_hosts.cpp @@ -1,10 +1,11 @@ -#include "core/globals.h" +#include #include "core/display.h" #include "core/mykeyboard.h" #include "core/wifi_common.h" #include "scan_hosts.h" #include "clients.h" #include "wifi_atks.h" // to use Station Deauth +#include "core/utils.h" //thx to 7h30th3r0n3, which made scanHosts faster using ARP @@ -344,7 +345,7 @@ void arpSpoofing(const Host& host, bool mitm) { sendARPPacket(gatewayIP, gatewayMAC, victimIP, myMAC, pcapFile); tmp=millis(); count++; - tft.drawRightString("Spoofed " + String(count) + " times",WIDTH-12,HEIGHT-16,1); + tft.drawRightString("Spoofed " + String(count) + " times",tftWidth-12,tftHeight-16,1); } } @@ -411,10 +412,10 @@ void arpPoisoner() { sendARPPacket(gatewayIP, gatewayMAC, victimIP, victimMAC, pcapFile); delay(10); - tft.drawRightString(" " + String(victimIP[0]) + "." + String(victimIP[1]) + "." + String(victimIP[2]) + "." + String(i), WIDTH-12,HEIGHT-16,1); + tft.drawRightString(" " + String(victimIP[0]) + "." + String(victimIP[1]) + "." + String(victimIP[2]) + "." + String(i), tftWidth-12,tftHeight-16,1); } tmp=millis(); - tft.drawRightString(" Waiting...",WIDTH-12,HEIGHT-16,1); + tft.drawRightString(" Waiting...",tftWidth-12,tftHeight-16,1); } } pcapFile.close(); @@ -480,7 +481,7 @@ void stationDeauth(Host host) { cont+=3*4; delay(50); if(millis()-tmp>1000) { - tft.drawRightString(String(cont) + " fps", WIDTH-12,HEIGHT-16,1); + tft.drawRightString(String(cont) + " fps", tftWidth-12,tftHeight-16,1); cont=0; tmp=millis(); } diff --git a/src/modules/wifi/scan_hosts.h b/src/modules/wifi/scan_hosts.h index 7a6bf848..86c9e5da 100644 --- a/src/modules/wifi/scan_hosts.h +++ b/src/modules/wifi/scan_hosts.h @@ -1,3 +1,6 @@ +#ifndef __SCAN_HOSTS_H__ +#define __SCAN_HOSTS_H__ + #include #include #include @@ -35,4 +38,6 @@ void arpSpoofing(const Host& host, bool mitm); void arpPoisoner(); -void stationDeauth(Host host); \ No newline at end of file +void stationDeauth(Host host); + +#endif \ No newline at end of file diff --git a/src/modules/wifi/sniffer.cpp b/src/modules/wifi/sniffer.cpp index e61d0580..de49c096 100644 --- a/src/modules/wifi/sniffer.cpp +++ b/src/modules/wifi/sniffer.cpp @@ -21,7 +21,7 @@ #include #include "FS.h" #include "core/display.h" -#include "core/globals.h" +#include #include "core/sd_functions.h" #include "core/wifi_common.h" #include "core/mykeyboard.h" @@ -411,7 +411,7 @@ void sniffer_setup() { delay(200); #if !defined(HAS_KEYBOARD) long _tmp=millis(); - while(checkPrevPress()) tft.drawArc(WIDTH/2, HEIGHT/2, 25,15,0,360*(millis()-_tmp)/700,getColorVariation(bruceConfig.priColor),bruceConfig.bgColor); + while(checkPrevPress()) tft.drawArc(tftWidth/2, tftHeight/2, 25,15,0,360*(millis()-_tmp)/700,getColorVariation(bruceConfig.priColor),bruceConfig.bgColor); if(millis()-_tmp>700) { // longpress detected to exit returnToMenu=true; _pcap_file.close(); @@ -473,7 +473,7 @@ void sniffer_setup() { padprintln("Sniffer Mode: " + String(_only_HS?"Only EAPOL/HS":"All packets Sniff")); padprintln(deauth?"Deauth: ON":"Deauth: OFF"); padprintln(String(BTN_ALIAS) + ": Options Menu"); - tft.drawRightString("Ch." + String(ch<10?"0":"") + String(ch) + "(Next)",WIDTH-10, HEIGHT-18,1); + tft.drawRightString("Ch." + String(ch<10?"0":"") + String(ch) + "(Next)",tftWidth-10, tftHeight-18,1); } if(currentTime-lastTime>100) tft.drawPixel(0,0,0); @@ -481,8 +481,8 @@ void sniffer_setup() { if(fileOpen && currentTime - lastTime > 1000){ _pcap_file.flush(); //save file lastTime = currentTime; //update time - tft.drawString("EAPOL: " + String(num_EAPOL) + " HS: " + String(num_HS),10,HEIGHT-18); - tft.drawCentreString("Packets " + String(packet_counter),WIDTH/2, HEIGHT-26,1); + tft.drawString("EAPOL: " + String(num_EAPOL) + " HS: " + String(num_HS),10,tftHeight-18); + tft.drawCentreString("Packets " + String(packet_counter),tftWidth/2, tftHeight-26,1); } if(deauth && (millis()-deauth_tmp)>60000) { // deauths once every 60 seconds diff --git a/src/modules/wifi/wifi_atks.cpp b/src/modules/wifi/wifi_atks.cpp index 727b4a4c..7ae35e78 100644 --- a/src/modules/wifi/wifi_atks.cpp +++ b/src/modules/wifi/wifi_atks.cpp @@ -3,10 +3,11 @@ // Arduino IDE needs to be tweeked to work, follow the instructions: https://github.com/justcallmekoko/ESP32Marauder/wiki/arduino-ide-setup // But change the file in: C:\Users\\AppData\Local\Arduino15\packages\m5stack\hardware\esp32\2.0.9 #include -#include "core/globals.h" +#include #include "core/display.h" #include "core/main_menu.h" #include "core/mykeyboard.h" +#include "core/utils.h" #include "core/wifi_common.h" #include "wifi_atks.h" #include "esp_wifi.h" @@ -91,7 +92,7 @@ void wifi_atk_info(String tssid, String mac, uint8_t channel) tft.drawString("AP: " + tssid, 10, 48); tft.drawString("Channel: " + String(channel), 10, 66); tft.drawString(mac, 10, 84); - tft.drawString("Press " + String(BTN_ALIAS) + " to act", 10, HEIGHT - 20); + tft.drawString("Press " + String(BTN_ALIAS) + " to act", 10, tftHeight - 20); delay(300); while (!checkSelPress()) @@ -196,7 +197,7 @@ void deauthFloodAttack() { channel = record.primary; wsl_bypasser_send_raw_frame(&record, record.primary); // Sets channel to the same AP - tft.setCursor(10, HEIGHT - 45); + tft.setCursor(10, tftHeight - 45); tft.println("Channel " + String(record.primary) + " "); for (int i=0; i<100; i++) { send_raw_frame(deauth_frame, sizeof(deauth_frame_default)); @@ -207,11 +208,11 @@ void deauthFloodAttack() if (millis() - lastTime > 2000) { drawMainBorderWithTitle("Deauth Flood"); - tft.setCursor(10, HEIGHT - 25); + tft.setCursor(10, tftHeight - 25); tft.print("Frames: "); - tft.setCursor(10, HEIGHT - 25); + tft.setCursor(10, tftHeight - 25); tft.println("Frames: " + String(count / 2) + "/s "); - tft.setCursor(10, HEIGHT - 45); + tft.setCursor(10, tftHeight - 45); tft.println("Channel " + String(channel) + " "); count = 0; lastTime = millis(); @@ -301,7 +302,7 @@ void target_atk(String tssid, String mac, uint8_t channel) // atualize counter if (millis() - tmp > 2000) { - tft.setCursor(15, HEIGHT - 23); + tft.setCursor(15, tftHeight - 23); tft.print("Frames: " + String(count / 2) + "/s"); count = 0; tmp = millis(); diff --git a/src/modules/wifi/wifi_atks.h b/src/modules/wifi/wifi_atks.h index a85d9427..d08dc95e 100644 --- a/src/modules/wifi/wifi_atks.h +++ b/src/modules/wifi/wifi_atks.h @@ -1,3 +1,6 @@ +#ifndef __WIFI_ATKS_H__ +#define __WIFI_ATKS_H__ + #include extern wifi_ap_record_t ap_record; @@ -43,4 +46,6 @@ void target_atk(String tssid,String mac, uint8_t channel); void beaconAttack(); -void deauthFloodAttack(); \ No newline at end of file +void deauthFloodAttack(); + +#endif \ No newline at end of file diff --git a/src/modules/wifi/wigle.h b/src/modules/wifi/wigle.h index 8081b051..438e4e86 100644 --- a/src/modules/wifi/wigle.h +++ b/src/modules/wifi/wigle.h @@ -5,10 +5,10 @@ * @version 0.1 */ -#ifndef WIGLE_H -#define WIGLE_H +#ifndef __WIGLE_H__ +#define __WIGLE_H__ -#include "core/globals.h" +#include #include @@ -39,4 +39,4 @@ class Wigle { bool _upload_file(File file, String upload_message); }; -#endif // WIGLE_H +#endif From d1cf850f4eb42dc1e57ea78e0aee9eed943caa42 Mon Sep 17 00:00:00 2001 From: Cody Ardoin Date: Sat, 21 Dec 2024 20:39:07 -0600 Subject: [PATCH 02/30] fixed conflicts --- src/core/display.cpp | 168 ++++++++++++++++------------- src/core/menu_items/ConfigMenu.cpp | 2 +- src/core/scrollableTextArea.cpp | 32 +++--- src/core/scrollableTextArea.h | 10 +- src/core/sd_functions.cpp | 28 ++--- src/core/sd_functions.h | 6 +- src/core/utils.cpp | 30 +++++- src/core/utils.h | 7 +- 8 files changed, 170 insertions(+), 113 deletions(-) diff --git a/src/core/display.cpp b/src/core/display.cpp index c795512b..10a30bba 100644 --- a/src/core/display.cpp +++ b/src/core/display.cpp @@ -1,11 +1,12 @@ #include "display.h" -#include "mykeyboard.h" +#include "utils.h" +#include "mykeyboard.h" #include "wg.h" //for isConnectedWireguard to print wireguard lock #include "settings.h" //for timeStr #include "modules/others/webInterface.h" // for server #include -#define MAX_MENU_SIZE (int)(HEIGHT/25) +#define MAX_MENU_SIZE (int)(tftHeight/25) /*************************************************************************************** ** Function name: displayScrollingText @@ -39,24 +40,24 @@ void displayScrollingText(const String& text, Opt_Coord& coord) { ** Description: Draw touch screen footer ***************************************************************************************/ void TouchFooter(uint16_t color) { - tft.drawRoundRect(5,HEIGHT+2,WIDTH-10,43,5,color); + tft.drawRoundRect(5,tftHeight+2,tftWidth-10,43,5,color); tft.setTextColor(color); tft.setTextSize(FM); - tft.drawCentreString("PREV",WIDTH/6,HEIGHT+4,1); - tft.drawCentreString("SEL",WIDTH/2,HEIGHT+4,1); - tft.drawCentreString("NEXT",5*WIDTH/6,HEIGHT+4,1); + tft.drawCentreString("PREV",tftWidth/6,tftHeight+4,1); + tft.drawCentreString("SEL",tftWidth/2,tftHeight+4,1); + tft.drawCentreString("NEXT",5*tftWidth/6,tftHeight+4,1); } /*************************************************************************************** ** Function name: TouchFooter ** Description: Draw touch screen footer ***************************************************************************************/ void MegaFooter(uint16_t color) { - tft.drawRoundRect(5,HEIGHT+2,WIDTH-10,43,5,color); + tft.drawRoundRect(5,tftHeight+2,tftWidth-10,43,5,color); tft.setTextColor(color); tft.setTextSize(FM); - tft.drawCentreString("Exit",WIDTH/6,HEIGHT+4,1); - tft.drawCentreString("UP",WIDTH/2,HEIGHT+4,1); - tft.drawCentreString("DOWN",5*WIDTH/6,HEIGHT+4,1); + tft.drawCentreString("Exit",tftWidth/6,tftHeight+4,1); + tft.drawCentreString("UP",tftWidth/2,tftHeight+4,1); + tft.drawCentreString("DOWN",5*tftWidth/6,tftHeight+4,1); } /*************************************************************************************** @@ -82,6 +83,27 @@ void setTftDisplay(int x, int y, uint16_t fc, int size, uint16_t bg) { tft.setTextColor(fc,bg); } +void turnOffDisplay() { + setBrightness(0,false); +} + +bool wakeUpScreen(){ + previousMillis = millis(); + if(isScreenOff){ + isScreenOff = false; + dimmer = false; + getBrightness(); + delay(200); + return true; + }else if(dimmer){ + dimmer = false; + getBrightness(); + delay(200); + return true; + } + return false; +} + /*************************************************************************************** ** Function name: displayRedStripe ** Description: Display Red Stripe with information @@ -92,18 +114,18 @@ void displayRedStripe(String text, uint16_t fgcolor, uint16_t bgcolor) { int size; if(fgcolor==bgcolor && fgcolor==TFT_WHITE) fgcolor=TFT_BLACK; - if(text.length()*LW*FM<(WIDTH-2*FM*LW)) size = FM; + if(text.length()*LW*FM<(tftWidth-2*FM*LW)) size = FM; else size = FP; - tft.fillSmoothRoundRect(10,HEIGHT/2-13,WIDTH-20,26,7,bgcolor); - tft.fillSmoothRoundRect(10,HEIGHT/2-13,WIDTH-20,26,7,bgcolor); + tft.fillSmoothRoundRect(10,tftHeight/2-13,tftWidth-20,26,7,bgcolor); + tft.fillSmoothRoundRect(10,tftHeight/2-13,tftWidth-20,26,7,bgcolor); tft.setTextColor(fgcolor,bgcolor); if(size==FM) { tft.setTextSize(FM); - tft.setCursor(WIDTH/2 - FM*3*text.length(), HEIGHT/2-8); + tft.setCursor(tftWidth/2 - FM*3*text.length(), tftHeight/2-8); } else { tft.setTextSize(FP); - tft.setCursor(WIDTH/2 - FP*3*text.length(), HEIGHT/2-8); + tft.setCursor(tftWidth/2 - FP*3*text.length(), tftHeight/2-8); } tft.println(text); } @@ -235,8 +257,8 @@ void padprint(double n, int digits, int16_t padx) { void padprintln(const String &s, int16_t padx) { if (s.isEmpty()) { - tft.setCursor(padx * BORDER_PAD_X, tft.getCursorY()); - tft.println(s); + tft.setCursor(padx * BORDER_PAD_X, tft.getCursorY()); + tft.println(s); return; } @@ -253,8 +275,8 @@ void padprintln(const String &s, int16_t padx) { } void padprintln(const char str[], int16_t padx) { if (str == "") { - tft.setCursor(padx * BORDER_PAD_X, tft.getCursorY()); - tft.println(str); + tft.setCursor(padx * BORDER_PAD_X, tft.getCursorY()); + tft.println(str); return; } @@ -318,7 +340,7 @@ int loopOptions(std::vector