Skip to content

Commit

Permalink
Merge branch 'pr3y:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorcelli authored Feb 14, 2025
2 parents fcfd149 + 53d97a1 commit 989bdb9
Show file tree
Hide file tree
Showing 36 changed files with 262 additions and 184 deletions.
7 changes: 7 additions & 0 deletions boards/lilygo-t-display-s3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ build_flags =
-DRF_TX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}'
-DRF_RX_PINS='{{"Pin 43", 43}, {"Pin 44", 44}}'

;NRF24 support SPI
-DUSE_NRF24_VIA_SPI
-DNRF24_CE_PIN=3
-DNRF24_SS_PIN=SPI_SS_PIN
-DNRF24_MOSI_PIN=SPI_MOSI_PIN
-DNRF24_SCK_PIN=SPI_SCK_PIN
-DNRF24_MISO_PIN=SPI_MISO_PIN
lib_deps =
${env.lib_deps}
fastled/FastLED @3.9.4
39 changes: 14 additions & 25 deletions boards/lilygo-t-display-s3/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,35 +90,24 @@ void InputHandler(void)
UpPress = false;
DownPress = false;

if (digitalRead(SEL_BTN) == BTN_ACT || digitalRead(UP_BTN) == BTN_ACT || digitalRead(DW_BTN) == BTN_ACT)
{
if (!wakeUpScreen())
AnyKeyPress = true;
else
goto END;
}
bool upPressed = (digitalRead(UP_BTN) == BTN_ACT);
bool selPressed = (digitalRead(SEL_BTN) == BTN_ACT);
bool dwPressed = (digitalRead(DW_BTN) == BTN_ACT);

if (digitalRead(UP_BTN) == BTN_ACT)
{
PrevPress = true;
}
bool anyPressed = upPressed || selPressed || dwPressed;
if (anyPressed && wakeUpScreen()) return;

if (digitalRead(DW_BTN) == BTN_ACT)
{
NextPress = true;
}
AnyKeyPress = anyPressed;
PrevPress = upPressed;
EscPress = upPressed;
NextPress = dwPressed;
SelPress = selPressed;

if (digitalRead(SEL_BTN) == BTN_ACT)
{
SelPress = true;
}

END:
if (AnyKeyPress)
{
if (AnyKeyPress) {
long tmp = millis();
while ((millis() - tmp) < 200 && (digitalRead(SEL_BTN) == BTN_ACT || digitalRead(UP_BTN) == BTN_ACT || digitalRead(DW_BTN) == BTN_ACT))
;
while ((millis() - tmp) < 200 && (digitalRead(SEL_BTN) == BTN_ACT || digitalRead(UP_BTN) == BTN_ACT || digitalRead(DW_BTN) == BTN_ACT)) {
vTaskDelay(pdMS_TO_TICKS(5)); // Small delay instead of busy wait
}
}
}

Expand Down
33 changes: 17 additions & 16 deletions boards/m5stack-core/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,26 @@ void _setBrightness(uint8_t brightval) {
**********************************************************************/
void InputHandler(void) {
M5.update();
if(M5.BtnA.isPressed() || M5.BtnB.isPressed() || M5.BtnC.isPressed()) {
if(!wakeUpScreen()) AnyKeyPress = true;
else goto END;
}
if(M5.BtnA.isPressed()) {
PrevPress = true;
EscPress = true;
}
if(M5.BtnC.isPressed()) {
NextPress = true;
}
if(M5.BtnB.isPressed()) {
SelPress = true;
}
END:
bool aPressed = (M5.BtnA.isPressed());
bool bPressed = (M5.BtnB.isPressed());
bool cPressed = (M5.BtnC.isPressed());

bool anyPressed = aPressed || bPressed || cPressed;
if (anyPressed && wakeUpScreen()) return;

AnyKeyPress = anyPressed;
PrevPress = aPressed;
EscPress = aPressed;
NextPress = cPressed;
SelPress = bPressed;

if(AnyKeyPress) {
long tmp=millis();
M5.update();
while((millis()-tmp)<200 && (M5.BtnA.isPressed() || M5.BtnB.isPressed() || M5.BtnC.isPressed())) { delay(50); M5.update(); };
while((millis()-tmp)<200 && (M5.BtnA.isPressed() || M5.BtnB.isPressed() || M5.BtnC.isPressed())) {
vTaskDelay(pdMS_TO_TICKS(50));
M5.update();
};
}
}

Expand Down
36 changes: 17 additions & 19 deletions boards/m5stack-cplus1_1/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,24 @@ void _setBrightness(uint8_t brightval) {
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
if(axp192.GetBtnPress()) {
if(!wakeUpScreen()) AnyKeyPress = true;
else goto END;
PrevPress = true;
EscPress = true;
}
if(digitalRead(DW_BTN)==LOW) {
if(!wakeUpScreen()) AnyKeyPress = true;
else goto END;
NextPress = true;
}
if(digitalRead(SEL_BTN)==LOW) {
if(!wakeUpScreen()) AnyKeyPress = true;
else goto END;
SelPress = true;
}
END:
bool upPressed = (axp192.GetBtnPress());
bool selPressed = (digitalRead(SEL_BTN)==LOW);
bool dwPressed = (digitalRead(DW_BTN)==LOW);

bool anyPressed = upPressed || selPressed || dwPressed;
if (anyPressed && wakeUpScreen()) return;

AnyKeyPress = anyPressed;
PrevPress = upPressed;
EscPress = upPressed;
NextPress = dwPressed;
SelPress = selPressed;

if(AnyKeyPress) {
long tmp=millis();
while((millis()-tmp)<200 && (axp192.GetBtnPress() || digitalRead(SEL_BTN)==LOW || digitalRead(DW_BTN)==LOW));
long tmp=millis();
while((millis()-tmp)<200 && (axp192.GetBtnPress() || digitalRead(SEL_BTN)==LOW || digitalRead(DW_BTN)==LOW)) {
vTaskDelay(pdMS_TO_TICKS(5)); // Small delay instead of busy wait
}
}
}

Expand Down
41 changes: 20 additions & 21 deletions boards/m5stack-cplus2/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ int getBattery() {
float mv = volt * 2;
percent = (mv - 3300) * 100 / (float)(4150 - 3350);

return (percent < 0) ? 0
: (percent >= 100) ? 100
: percent;
return (percent >= 100) ? 100 : percent;
}


Expand All @@ -70,25 +68,26 @@ void _setBrightness(uint8_t brightval) {
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
if(digitalRead(UP_BTN)==LOW || digitalRead(SEL_BTN)==LOW || digitalRead(DW_BTN)==LOW) {
if(!wakeUpScreen()) AnyKeyPress = true;
else goto END;
}
if(digitalRead(UP_BTN)==LOW) {
PrevPress = true;
EscPress = true;
}
if(digitalRead(DW_BTN)==LOW) {
NextPress = true;
}
if(digitalRead(SEL_BTN)==LOW) {
SelPress = true;
}
END:
if(AnyKeyPress) {
long tmp=millis();
while((millis()-tmp)<200 && (digitalRead(UP_BTN)==LOW || digitalRead(SEL_BTN)==LOW || digitalRead(DW_BTN)==LOW));
bool upPressed = (digitalRead(UP_BTN) == LOW);
bool selPressed = (digitalRead(SEL_BTN) == LOW);
bool dwPressed = (digitalRead(DW_BTN) == LOW);

bool anyPressed = upPressed || selPressed || dwPressed;
if (anyPressed && wakeUpScreen()) return;

AnyKeyPress = anyPressed;
PrevPress = upPressed;
EscPress = upPressed;
NextPress = dwPressed;
SelPress = selPressed;

if (AnyKeyPress) {
long startTime = millis();
while ((millis() - startTime) < 200) {
if (!(digitalRead(UP_BTN) == LOW || digitalRead(SEL_BTN) == LOW || digitalRead(DW_BTN) == LOW)) break;
vTaskDelay(pdMS_TO_TICKS(5)); // Small delay instead of busy wait
}
}
}


Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI_QRcode/src/qrencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void addfmt(unsigned char masknum)
unsigned fmtbits;
unsigned char i, lvl = ECCLEVEL - 1;

fmtbits = pgm_read_word(&fmtword[masknum + (lvl << 3)]);
fmtbits = pgm_read_word_qr(&fmtword[masknum + (lvl << 3)]);
// low byte
for (i = 0; i < 8; i++, fmtbits >>= 1)
if (fmtbits & 1) {
Expand Down
2 changes: 1 addition & 1 deletion lib/TFT_eSPI_QRcode/src/qrencode.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define PROGMEM
#define memcpy_P memcpy
#define __LPM(x) *x
#define pgm_read_word(x) *x
#define pgm_read_word_qr(x) *x
#else
#include <avr/pgmspace.h>
#define USEPRECALC
Expand Down
4 changes: 2 additions & 2 deletions lib/utility/bq27220.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bool BQ27220::unseal()
writeCtrlWord(BQ27220_UNSEAL_KEY2);
delayMicroseconds(5000);
status = OP_STATUS(readWord(BQ27220_CONTROL_CONTROL_STATUS));
if(status = OP_STATUS::UNSEALED)
if(status == OP_STATUS::UNSEALED)
{
return true;
}
Expand All @@ -25,7 +25,7 @@ bool BQ27220::seal()
writeCtrlWord(BQ27220_CONTROL_SEALED);
delayMicroseconds(5000);
status = OP_STATUS(readWord(BQ27220_CONTROL_CONTROL_STATUS));
if(status = OP_STATUS::SEALED)
if(status == OP_STATUS::SEALED)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utility/bq27220.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class BQ27220
uint16_t getId();

private:
TwoWire *wire;
uint8_t addr;
TwoWire *wire;
int scl;
int sda;
union battery_state bat_st;
Expand Down
15 changes: 14 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,19 @@ build_flags =
-DEEPROMSIZE=128
-DLH=8
-DLW=6
-w
-O2
; warnings:
-Wall
-Wclobbered
-Wempty-body
-Wignored-qualifiers
; -Wmissing-field-initializers
-Wsign-compare
-Wtype-limits
-Wno-unused-label
-Wno-comment
-Wno-unused-variable
; warnings end
-Wl,--print-memory-usage
-Wl,--gc-sections
-DGIT_COMMIT_HASH='"Homebrew"'
Expand Down Expand Up @@ -99,3 +111,4 @@ lib_deps =
;chegewara/EspTinyUSB
bitbank2/AnimatedGIF

monitor_speed = 115200
30 changes: 15 additions & 15 deletions src/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ JsonDocument BruceConfig::toJson() const {
setting["ledBright"] = ledBright;
setting["ledColor"] = String(ledColor, HEX);

JsonObject _webUI = setting.createNestedObject("webUI");
JsonObject _webUI = setting["webUI"].to<JsonObject>();
_webUI["user"] = webUI.user;
_webUI["pwd"] = webUI.pwd;

JsonObject _wifiAp = setting.createNestedObject("wifiAp");
JsonObject _wifiAp = setting["wifiAp"].to<JsonObject>();
_wifiAp["ssid"] = wifiAp.ssid;
_wifiAp["pwd"] = wifiAp.pwd;

setting["bleName"] = bleName;

JsonObject _wifi = setting.createNestedObject("wifi");
JsonObject _wifi = setting["wifi"].to<JsonObject>();
for (const auto& pair : wifi) {
_wifi[pair.first] = pair.second;
}
Expand All @@ -47,7 +47,7 @@ JsonDocument BruceConfig::toJson() const {

setting["rfidModule"] = rfidModule;

JsonArray _mifareKeys = setting.createNestedArray("mifareKeys");
JsonArray _mifareKeys = setting["mifareKeys"].to<JsonArray>();
for (auto key : mifareKeys) _mifareKeys.add(key);

setting["gpsBaudrate"] = gpsBaudrate;
Expand All @@ -56,14 +56,14 @@ JsonDocument BruceConfig::toJson() const {
setting["wigleBasicToken"] = wigleBasicToken;
setting["devMode"] = devMode;

JsonArray dm = setting.createNestedArray("disabledMenus");
JsonArray dm = setting["disabledMenus"].to<JsonArray>();
for(int i=0; i < disabledMenus.size(); i++){
dm.add(disabledMenus[i]);
}

JsonArray qrArray = setting.createNestedArray("qrCodes");
JsonArray qrArray = setting["qrCodes"].to<JsonArray>();
for (const auto& entry : qrCodes) {
JsonObject qrEntry = qrArray.createNestedObject();
JsonObject qrEntry = qrArray.add<JsonObject>();
qrEntry["menuName"] = entry.menuName;
qrEntry["content"] = entry.content;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ void BruceConfig::saveFile() {


void BruceConfig::validateConfig() {
validateTheme();
// validateTheme();
validateRotationValue();
validateDimmerValue();
validateBrightValue();
Expand All @@ -227,16 +227,16 @@ void BruceConfig::setTheme(uint16_t primary, uint16_t secondary, uint16_t backgr
priColor = primary;
secColor = secondary == NULL ? primary - 0x2000 : secondary;
bgColor = background == NULL ? 0x0 : background;
validateTheme();
// validateTheme();
saveFile();
}


void BruceConfig::validateTheme() {
if (priColor < 0 || priColor > 0xFFFF) priColor = DEFAULT_PRICOLOR;
if (secColor < 0 || secColor > 0xFFFF) secColor = priColor - 0x2000;
if (bgColor < 0 || bgColor > 0xFFFF) bgColor = 0;
}
// uint16_t can't be lower than 0 or greater than 0xFFFF, thats its limit
// void BruceConfig::validateTheme() {
// if (priColor < 0 || priColor > 0xFFFF) priColor = DEFAULT_PRICOLOR;
// if (secColor < 0 || secColor > 0xFFFF) secColor = priColor - 0x2000;
// if (bgColor < 0 || bgColor > 0xFFFF) bgColor = 0;
// }


void BruceConfig::setRotation(int value) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BruceConfig {

// Theme
void setTheme(uint16_t primary, uint16_t secondary = NULL, uint16_t background = NULL);
void validateTheme();
// void validateTheme();

// Settings
void setRotation(int value);
Expand Down
Loading

0 comments on commit 989bdb9

Please sign in to comment.