Skip to content

Commit 997ce5f

Browse files
committed
Merge branch 'main' of github.com:dddema/bruce
2 parents 30ed4ed + d043c6f commit 997ce5f

35 files changed

+1927
-38
lines changed

.github/workflows/PR_All_envs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ jobs:
192192
family: "ESP32-S3",
193193
partitions: { bootloader_addr: "0x0" },
194194
}
195+
- {
196+
vendor: "Lilygo",
197+
name: "Lilygo T-LoRa-Pager",
198+
env: "lilygo-t-lora-pager",
199+
family: "ESP32-S3",
200+
partitions: { bootloader_addr: "0x0" },
201+
}
195202
- {
196203
vendor: "Smoochiee",
197204
name: "Smoochiee-Board",

.github/workflows/buil_parallel.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@ jobs:
220220
family: "ESP32",
221221
partitions: { bootloader_addr: "0x1000" },
222222
}
223+
- {
224+
vendor: "Lilygo",
225+
name: "Lilygo T-HMI",
226+
env: "lilygo-t-hmi",
227+
family: "ESP32-S3",
228+
partitions: { bootloader_addr: "0x0" },
229+
}
230+
- {
231+
vendor: "Lilygo",
232+
name: "Lilygo T-LoRa-Pager",
233+
env: "lilygo-t-lora-pager",
234+
family: "ESP32-S3",
235+
partitions: { bootloader_addr: "0x0" },
236+
}
223237
- {
224238
vendor: "CUSTOM",
225239
name: "Smoochiee-Board (ESP32-S3)",

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ _*.sh
1010
tmp
1111
ISSUES.md
1212
include/webFiles.h
13+
include/current_year.h
1314
checksum.sha256
15+
/*.bin
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"build": {
3+
"arduino":{
4+
"ldscript": "esp32s3_out.ld",
5+
"memory_type": "qio_opi",
6+
"partitions": "default_16MB.csv"
7+
},
8+
"core": "esp32",
9+
"extra_flags": [
10+
"-DBOARD_HAS_PSRAM",
11+
"-DARDUINO_USB_CDC_ON_BOOT",
12+
"-DARDUINO_USB_MODE=1",
13+
"-DARDUINO_RUNNING_CORE=1",
14+
"-DARDUINO_EVENT_RUNNING_CORE=1",
15+
"-DLILYGO_T_HMI"
16+
],
17+
"f_cpu": "240000000L",
18+
"f_flash": "80000000L",
19+
"flash_mode": "qio",
20+
"hwids": [
21+
[
22+
"0X303A",
23+
"0x1001"
24+
]
25+
],
26+
"mcu": "esp32s3",
27+
"variant": "pinouts"
28+
},
29+
"connectivity": [
30+
"wifi",
31+
"bluetooth"
32+
],
33+
"debug": {
34+
"openocd_target": "esp32s3.cfg"
35+
},
36+
"frameworks": [
37+
"arduino",
38+
"espidf"
39+
],
40+
"name": "LILYGO T-HMI",
41+
"upload": {
42+
"flash_size": "16MB",
43+
"maximum_ram_size": 327680,
44+
"maximum_size": 16777216,
45+
"require_upload_port": true,
46+
"speed": 921600
47+
},
48+
"url": "https://www.adafruit.com/product/5290",
49+
"vendor": "LILYGO"
50+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "esp32s3_out.ld",
5+
"partitions": "default_16MB.csv",
6+
"memory_type": "qio_qspi"
7+
},
8+
"core": "esp32",
9+
"extra_flags": [
10+
"-DT_LORA_PAGER",
11+
"-DBOARD_HAS_PSRAM",
12+
"-DARDUINO_RUNNING_CORE=1",
13+
"-DARDUINO_EVENT_RUNNING_CORE=1",
14+
"-DARDUINO_USB_MODE=1",
15+
"-DARDUINO_USB_CDC_ON_BOOT=1"
16+
],
17+
"f_cpu": "240000000L",
18+
"f_flash": "80000000L",
19+
"flash_mode": "qio",
20+
"hwids": [
21+
[
22+
"0x303A",
23+
"0x82D4"
24+
]
25+
],
26+
"mcu": "esp32s3",
27+
"variant": "pinouts"
28+
},
29+
"connectivity": [
30+
"bluetooth",
31+
"wifi",
32+
"lora"
33+
],
34+
"debug": {
35+
"default_tool": "esp-builtin",
36+
"onboard_tools": [
37+
"esp-builtin"
38+
],
39+
"openocd_target": "esp32s3.cfg"
40+
},
41+
"frameworks": [
42+
"arduino",
43+
"espidf"
44+
],
45+
"name": "LilyGo T-LoRa-Pager (16M Flash 8M QSPI PSRAM)",
46+
"upload": {
47+
"flash_size": "16MB",
48+
"maximum_ram_size": 327680,
49+
"maximum_size": 16777216,
50+
"require_upload_port": true,
51+
"speed": 921600
52+
},
53+
"url": "https://www.lilygo.cc",
54+
"vendor": "LilyGo"
55+
}

boards/_boards_json/m5stack-cores3.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"core": "esp32",
88
"extra_flags": [
99
"-DARDUINO_M5STACK_CORES3",
10-
"-DM5STACK",
1110
"-DBOARD_HAS_PSRAM",
1211
"-DARDUINO_USB_MODE=1",
1312
"-DARDUINO_USB_CDC_ON_BOOT=1",
@@ -47,4 +46,4 @@
4746
},
4847
"url": "https://docs.m5stack.com/en/core/CoreS3",
4948
"vendor": "M5Stack"
50-
}
49+
}

boards/lilygo-t-hmi/connections.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Pinouts diagram to use Bruce
2+
This board can´t use SDCard Sniffer, as used in other boards, because the SDCard CS Pin is physically grounded, so the bus will be always unavailable.
3+
4+
For this board you must solder the MISO/MOSI/SCK pins to the touchscreen SPI line, which can lead to navigation problems, in some ways, so it needs to be tested.
5+
6+
The pins of the XPT2046 that must be connected to CC1101 and NRF24 or other SPI bus, are:
7+
```
8+
┌──────────────┐
9+
VCC ─┤ O ├─ CLK
10+
─┤ /¯¯¯\ ├─
11+
─┤ / XPT ├─ MOSI
12+
─┤ \ / ├─
13+
─┤ \___/ ├─ MISO
14+
GND ─┤ XPT2046 ├─
15+
─┤ ABD8D8 ├─
16+
─┤ ├─
17+
└──────────────┘
18+
```
19+
20+
21+
## USING CUSTOM BOARD, with SPI
22+
| Device | SCK | MISO | MOSI | CS | GDO0/CE |
23+
| --- | :---: | :---: | :---: | :---: | :---: |
24+
| CC1101 | 1 | 4 | 3 | 15 | 16 |
25+
| NRF24 | 1 | 4 | 3 | 15 | 16 |
26+
27+
| Device | RX | TX | GPIO |
28+
| --- | :---: | :---: | :---: |
29+
| GPS | 44 | 43 | --- |
30+
| IR RX | --- | --- | 18 |
31+
| IR TX | --- | --- | 17 |
32+
33+
FM Radio, PN532 on I2C, other I2C devices
34+
I2C SDA: 17
35+
I2C SCL: 18
36+
37+
GPS Connections
38+
SERIAL_TX: 44
39+
SERIAL_RX: 43
40+

boards/lilygo-t-hmi/interface.cpp

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#include "CYD28_TouchscreenR.h"
2+
#include "core/powerSave.h"
3+
#include "core/utils.h"
4+
#include <Arduino.h>
5+
#include <ELECHOUSE_CC1101_SRC_DRV.h>
6+
#include <driver/adc.h>
7+
#include <esp_adc_cal.h>
8+
#include <interface.h>
9+
#include <soc/adc_channel.h>
10+
#include <soc/soc_caps.h>
11+
CYD28_TouchR touch(320, 240);
12+
13+
/***************************************************************************************
14+
** Function name: _setup_gpio()
15+
** Location: main.cpp
16+
** Description: initial setup for the device
17+
***************************************************************************************/
18+
void _setup_gpio() {
19+
pinMode(XPT2046_SPI_CONFIG_CS_GPIO_NUM, OUTPUT);
20+
digitalWrite(XPT2046_SPI_CONFIG_CS_GPIO_NUM, HIGH);
21+
pinMode(PWR_ON_PIN, OUTPUT);
22+
digitalWrite(PWR_ON_PIN, HIGH);
23+
pinMode(PWR_EN_PIN, OUTPUT);
24+
digitalWrite(PWR_EN_PIN, HIGH);
25+
bruceConfig.colorInverted = 0;
26+
}
27+
28+
/***************************************************************************************
29+
** Function name: _post_setup_gpio()
30+
** Location: main.cpp
31+
** Description: second stage gpio setup to make a few functions work
32+
***************************************************************************************/
33+
void _post_setup_gpio() {
34+
CC_NRF_SPI.begin(XPT2046_SPI_BUS_SCLK_IO_NUM, XPT2046_SPI_BUS_MISO_IO_NUM, XPT2046_SPI_BUS_MOSI_IO_NUM);
35+
if (!touch.begin(&CC_NRF_SPI)) { Serial.println("Touchscreen initialization failed!"); }
36+
ELECHOUSE_cc1101.setSPIinstance(&CC_NRF_SPI);
37+
#define TFT_BRIGHT_CHANNEL 0
38+
#define TFT_BRIGHT_Bits 8
39+
#define TFT_BRIGHT_FREQ 5000
40+
// Brightness control must be initialized after tft in this case @Pirata
41+
pinMode(TFT_BL, OUTPUT);
42+
ledcSetup(TFT_BRIGHT_CHANNEL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits); // Channel 0, 10khz, 8bits
43+
ledcAttachPin(TFT_BL, TFT_BRIGHT_CHANNEL);
44+
ledcWrite(TFT_BRIGHT_CHANNEL, 255);
45+
}
46+
47+
/*********************************************************************
48+
** Function: setBrightness
49+
** location: settings.cpp
50+
** set brightness value
51+
**********************************************************************/
52+
void _setBrightness(uint8_t brightval) {
53+
int dutyCycle;
54+
if (brightval == 100) dutyCycle = 255;
55+
else if (brightval == 75) dutyCycle = 130;
56+
else if (brightval == 50) dutyCycle = 70;
57+
else if (brightval == 25) dutyCycle = 20;
58+
else if (brightval == 0) dutyCycle = 0;
59+
else dutyCycle = ((brightval * 255) / 100);
60+
61+
// log_i("dutyCycle for bright 0-255: %d", dutyCycle);
62+
ledcWrite(TFT_BRIGHT_CHANNEL, dutyCycle); // Channel 0
63+
}
64+
65+
/*********************************************************************
66+
** Function: InputHandler
67+
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
68+
**********************************************************************/
69+
void InputHandler(void) {
70+
static long d_tmp = 0;
71+
if (millis() - d_tmp > 200 || LongPress) {
72+
// I know R3CK.. I Should NOT nest if statements..
73+
// but it is needed to not keep SPI bus used without need, it save resources
74+
if (touch.touched()) {
75+
auto t = touch.getPointScaled();
76+
// Serial.printf("\nRAW: Touch Pressed on x=%d, y=%d", t.x, t.y);
77+
if (bruceConfig.rotation == 3) {
78+
// t.y = t.y;
79+
t.x = tftWidth - t.x;
80+
}
81+
if (bruceConfig.rotation == 1) {
82+
t.y = (tftHeight + 20) - t.y;
83+
// t.x = t.x;
84+
}
85+
if (bruceConfig.rotation == 0) {
86+
int tmp = t.x;
87+
t.x = t.y;
88+
t.y = tmp;
89+
}
90+
if (bruceConfig.rotation == 2) {
91+
int tmp = t.x;
92+
t.x = tftWidth - t.y;
93+
t.y = (tftHeight + 20) - tmp;
94+
}
95+
// Serial.printf("\nROT: Touch Pressed on x=%d, y=%d\n", t.x, t.y);
96+
97+
if (!wakeUpScreen()) AnyKeyPress = true;
98+
else goto END;
99+
100+
// Touch point global variable
101+
touchPoint.x = t.x;
102+
touchPoint.y = t.y;
103+
touchPoint.pressed = true;
104+
touchHeatMap(touchPoint);
105+
END:
106+
d_tmp = millis();
107+
}
108+
}
109+
}
110+
111+
/*********************************************************************
112+
** Function: powerOff
113+
** location: mykeyboard.cpp
114+
** Turns off the device (or try to)
115+
**********************************************************************/
116+
void powerOff() {
117+
esp_sleep_enable_ext0_wakeup(GPIO_NUM_0, LOW);
118+
esp_deep_sleep_start();
119+
}
120+
121+
/*********************************************************************
122+
** Function: checkReboot
123+
** location: mykeyboard.cpp
124+
** Btn logic to tornoff the device (name is odd btw)
125+
**********************************************************************/
126+
void checkReboot() {}
127+
128+
/***************************************************************************************
129+
** Function name: getBattery()
130+
** location: display.cpp
131+
** Description: Delivers the battery value from 1-100
132+
***************************************************************************************/
133+
int getBattery() {
134+
uint8_t percent;
135+
uint8_t _batAdcCh = ADC1_GPIO5_CHANNEL;
136+
uint8_t _batAdcUnit = 1;
137+
138+
adc1_config_width(ADC_WIDTH_BIT_12);
139+
adc1_config_channel_atten((adc1_channel_t)_batAdcCh, ADC_ATTEN_DB_12);
140+
static esp_adc_cal_characteristics_t *adc_chars = nullptr;
141+
static constexpr int BASE_VOLATAGE = 3600;
142+
adc_chars = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t));
143+
esp_adc_cal_characterize(
144+
(adc_unit_t)_batAdcUnit, ADC_ATTEN_DB_12, ADC_WIDTH_BIT_12, BASE_VOLATAGE, adc_chars
145+
);
146+
int raw;
147+
raw = adc1_get_raw((adc1_channel_t)_batAdcCh);
148+
uint32_t volt = esp_adc_cal_raw_to_voltage(raw, adc_chars);
149+
150+
float mv = volt * 2;
151+
percent = (mv - 3300) * 100 / (float)(4150 - 3350);
152+
153+
return (percent < 0) ? 0 : (percent >= 100) ? 100 : percent;
154+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[env:lilygo-t-hmi]
2+
board = lilygo-t-hmi
3+
board_build.partitions = custom_16Mb.csv
4+
build_src_filter =${env.build_src_filter} +<../boards/lilygo-t-hmi>
5+
build_flags =
6+
${env.build_flags}
7+
-Iboards/lilygo-t-hmi
8+
-Os
9+
-DCORE_DEBUG_LEVEL=5
10+
11+
-DRF_TX_PINS='{{"Pin 15", 15}, {"Pin 16", 16}, {"Pin 17", 17}, {"Pin 18", 18}, {"Pin 43", 43}, {"Pin 44", 44}}'
12+
-DRF_RX_PINS='{{"Pin 15", 15}, {"Pin 16", 16}, {"Pin 17", 17}, {"Pin 18", 18}, {"Pin 43", 43}, {"Pin 44", 44}}'
13+
-DIR_TX_PINS='{{"Pin 15", 15}, {"Pin 16", 16}, {"Pin 17", 17}, {"Pin 18", 18}, {"Pin 43", 43}, {"Pin 44", 44}}'
14+
-DIR_RX_PINS='{{"Pin 15", 15}, {"Pin 16", 16}, {"Pin 17", 17}, {"Pin 18", 18}, {"Pin 43", 43}, {"Pin 44", 44}}'
15+
16+
-D TOUCH_XPT2046_SPI
17+
-D XPT2046_TOUCH_CONFIG_INT_GPIO_NUM=9
18+
-D XPT2046_SPI_BUS_MISO_IO_NUM=4
19+
-D XPT2046_SPI_BUS_MOSI_IO_NUM=3
20+
-D XPT2046_SPI_BUS_SCLK_IO_NUM=1
21+
-D XPT2046_SPI_CONFIG_CS_GPIO_NUM=2
22+
23+
-DDISABLE_ALL_LIBRARY_WARNINGS
24+
-DDEVICE_NAME='"Lilygo T-HMI"'
25+

0 commit comments

Comments
 (0)