Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom WifiBeacon, Portrait orientation #637

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/extensions.json
.vscode/ipch
Bruce3_*.bin
bruce.conf
Expand Down
63 changes: 41 additions & 22 deletions boards/CYD-2432S028/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,21 @@ bool menuPress(int bot) {
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 = (tftHeight+20)-t.y;
t.x = tftWidth-t.x;
}

if(bruceConfig.rotation==3) {
t.y = (tftHeight+20)-t.y;
t.x = tftWidth-t.x;
}
if(bruceConfig.rotation==0) {
int tmp=t.x;
t.x = tftWidth-t.y;
t.y = tmp;
}
if(bruceConfig.rotation==2) {
int tmp=t.x;
t.x = t.y;
t.y = (tftHeight+20)-tmp;
}
//log_i("Touchscreen Pressed at x=%d, y=%d, z=%d, rotation=%d", t.x,t.y,t.z,bruceConfig.rotation);
if(t.y>(tftHeight) && ((t.x>terco*bot && t.x<terco*(1+bot)) || bot==ALL)) {
t.x=tftWidth+1;
t.y=tftHeight+11;
Expand Down Expand Up @@ -365,7 +374,7 @@ String keyboard(String mytext, int maxSize, String msg) {
tft.setTextSize(FM);

//Draw the rectangles
if(y<0) {
if(y<0 || y2<0) {
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
Expand Down Expand Up @@ -469,23 +478,33 @@ String keyboard(String mytext, int maxSize, String msg) {

auto t = touch.getPointScaled();
if(bruceConfig.rotation==3) {
t.y = (tftHeight+20)-t.y;
t.x = tftWidth-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,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++){
if (box_list[k].contain(t.x, t.y)) {
if(caps) mytext += box_list[k].key_sh;
else mytext += box_list[k].key;
if(bruceConfig.rotation==0) {
int tmp=t.x;
t.x = tftWidth-t.y;
t.y = tmp;
}
}
wakeUpScreen();
THIS_END:
redraw=true;
delay(200);
if(bruceConfig.rotation==2) {
int tmp=t.x;
t.x = t.y;
t.y = (tftHeight+20)-tmp;
}
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,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++){
if (box_list[k].contain(t.x, t.y)) {
if(caps) mytext += box_list[k].key_sh;
else mytext += box_list[k].key;
}
}
wakeUpScreen();
THIS_END:
redraw=true;
delay(200);
}

if(checkSelPress()) {
Expand Down
17 changes: 8 additions & 9 deletions boards/lilygo-t-embed-cc1101/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ String keyboard(String mytext, int maxSize, String msg) {
tft.setTextSize(FM);

//Draw the rectangles
if(y<0) {
if(y<0 || y2<0) {
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
Expand Down Expand Up @@ -467,9 +467,9 @@ String keyboard(String mytext, int maxSize, String msg) {
// To handle Encoder devices such as T-EMBED
#ifdef T_EMBED_1101
if(digitalRead(BK_BTN) == BTN_ACT) { y++; }
#else
if(x==11) { y++; x++; }
#endif
if(x==3 && y<0) {y++; x=0;}
else if(x==11) { y++; x++; }
else x++;

if(y>3) { y=-1; }
Expand All @@ -485,12 +485,11 @@ String keyboard(String mytext, int maxSize, String msg) {
// To handle Encoder devices such as T-EMBED
#ifdef T_EMBED_1101
if(digitalRead(BK_BTN) == BTN_ACT) { y--; }
#else
if(x==0) { y--; x--; }
#endif
if(x==0) { y--; x--; }
else x--;

if(y<0 && x<0) x=3;
if(y<0 && x<0) x=11;
if(x>11) x=0;
else if (x<0) x=11;

Expand Down Expand Up @@ -529,11 +528,11 @@ void checkReboot() {
// Display poweroff bar only if holding button
if (millis() - time_count > 500) {
tft.setTextSize(1);
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
countDown = (millis() - time_count) / 1000 + 1;
if(countDown<4) tft.drawCentreString("PWR OFF IN "+String(countDown)+"/3",tftWidth/2,12,1);
else {
tft.fillScreen(TFT_BLACK);
tft.fillScreen(bruceConfig.bgColor);
while(digitalRead(BK_BTN)==BTN_ACT);
delay(200);
powerOff();
Expand All @@ -544,7 +543,7 @@ void checkReboot() {

// Clear text after releasing the button
delay(30);
tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), TFT_BLACK);
tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), bruceConfig.bgColor);
}
#endif
}
2 changes: 1 addition & 1 deletion boards/m5stack-core/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ String keyboard(String mytext, int maxSize, String msg) {
tft.setTextSize(FM);

//Draw the rectangles
if(y<0) {
if(y<0 || y2<0) {
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
Expand Down
63 changes: 58 additions & 5 deletions boards/m5stack-core2/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,53 @@ void _setBrightness(uint8_t brightval) {
M5.Display.setBrightness(brightval);
}

#define PREV 0
#define SEL 1
#define NEXT 2
#define ALL 3

bool menuPress(int bot) {
//0 - prev
//1 - Sel
//2 - next
//3 - all
M5.update();
auto t = M5.Touch.getDetail();
int terco=tftWidth/3;
if (t.isPressed() || t.isHolding()) {

if(bruceConfig.rotation==3) {
t.y = (tftHeight+20)-t.y;
t.x = tftWidth-t.x;
}
if(bruceConfig.rotation==0) {
int tmp=t.x;
t.x = tftWidth-t.y;
t.y = tmp;
}
if(bruceConfig.rotation==2) {
int tmp=t.x;
t.x = t.y;
t.y = (tftHeight+20)-tmp;
}
//log_i("Touchscreen Pressed at x=%d, y=%d, z=%d, rotation=%d", t.x,t.y,t.z,bruceConfig.rotation);
if(t.y>(tftHeight) && ((t.x>terco*bot && t.x<terco*(1+bot)) || bot==ALL)) {
t.x=tftWidth+1;
t.y=tftHeight+11;
return true;
} else return false;
} else return false;

}

/*********************************************************************
** Function: checkNextPress
** location: mykeyboard.cpp
** Verifies Upper Btn to go to previous item
**********************************************************************/
bool checkNextPress(){
M5.update();
if(M5.BtnC.isPressed())
if(M5.BtnC.isPressed() || menuPress(NEXT))
{
if(wakeUpScreen()){
delay(200);
Expand All @@ -63,7 +102,7 @@ bool checkNextPress(){
**********************************************************************/
bool checkPrevPress() {
M5.update();
if(M5.BtnA.isPressed())
if(M5.BtnA.isPressed() || menuPress(PREV))
{
if(wakeUpScreen()){
delay(200);
Expand All @@ -84,7 +123,7 @@ bool checkPrevPress() {
bool checkSelPress(){
checkPowerSaveTime();
M5.update();
if(M5.BtnB.isPressed())
if(M5.BtnB.isPressed() || menuPress(SEL))
{
if(wakeUpScreen()){
delay(200);
Expand Down Expand Up @@ -123,7 +162,7 @@ bool checkEscPress(){
**********************************************************************/
bool checkAnyKeyPress() {
M5.update();
if(M5.BtnA.isPressed() || M5.BtnB.isPressed() || M5.BtnC.isPressed()) return true;
if(M5.BtnA.isPressed() || M5.BtnB.isPressed() || M5.BtnC.isPressed() || menuPress(ALL)) return true;

return false;
}
Expand Down Expand Up @@ -311,7 +350,7 @@ String keyboard(String mytext, int maxSize, String msg) {
tft.setTextSize(FM);

//Draw the rectangles
if(y<0) {
if(y<0 || y2<0) {
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
Expand Down Expand Up @@ -419,6 +458,20 @@ String keyboard(String mytext, int maxSize, String msg) {
auto t = M5.Touch.getDetail();
if (t.isPressed() || t.isHolding())
{
if(bruceConfig.rotation==0) {
int tmp=t.x;
t.x = tftWidth-t.y;
t.y = tmp;
}
if(bruceConfig.rotation==2) {
int tmp=t.x;
t.x = t.y;
t.y = (tftHeight+20)-tmp;
}
if(bruceConfig.rotation==3) {
t.x=tftWidth-t.x;
t.y=(tftHeight+20)-t.y;
}
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,tftWidth,tftHeight-54,bruceConfig.bgColor); goto THIS_END; } // CAP
if (box_list[50].contain(t.x, t.y)) goto DEL; // DEL
Expand Down
45 changes: 39 additions & 6 deletions boards/m5stack-cores3/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,40 @@ void _setBrightness(uint8_t brightval) {
#define SEL 1
#define NEXT 2
#define ALL 3

bool menuPress(int bot) {
int terco=tftWidth/3;
//0 - prev
//1 - Sel
//2 - next
//3 - all
M5.update();
auto t = M5.Touch.getDetail();
int terco=tftWidth/3;
if (t.isPressed() || t.isHolding()) {
//if(bruceConfig.rotation==3) t.x = tftWidth-t.x;
//else if (bruceConfig.rotation==1) t.y = (tftHeight+20)-t.y;
if(t.y>(tftHeight) && (t.x>terco*bot && t.x<terco*(1+bot) || bot==ALL)) {

if(bruceConfig.rotation==3) {
t.y = (tftHeight+20)-t.y;
t.x = tftWidth-t.x;
}
if(bruceConfig.rotation==0) {
int tmp=t.x;
t.x = tftWidth-t.y;
t.y = tmp;
}
if(bruceConfig.rotation==2) {
int tmp=t.x;
t.x = t.y;
t.y = (tftHeight+20)-tmp;
}
//log_i("Touchscreen Pressed at x=%d, y=%d, z=%d, rotation=%d", t.x,t.y,t.z,bruceConfig.rotation);
if(t.y>(tftHeight) && ((t.x>terco*bot && t.x<terco*(1+bot)) || bot==ALL)) {
t.x=tftWidth+1;
t.y=tftHeight+11;
return true;
} else return false;
} else return false;
}

/*********************************************************************
** Function: checkNextPress
** location: mykeyboard.cpp
Expand Down Expand Up @@ -325,7 +345,7 @@ String keyboard(String mytext, int maxSize, String msg) {
tft.setTextSize(FM);

//Draw the rectangles
if(y<0) {
if(y<0 || y2<0) {
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
Expand Down Expand Up @@ -429,7 +449,20 @@ String keyboard(String mytext, int maxSize, String msg) {
auto t = M5.Touch.getDetail();
if (t.isPressed() || t.isHolding())
{

if(bruceConfig.rotation==0) {
int tmp=t.x;
t.x = tftWidth-t.y;
t.y = tmp;
}
if(bruceConfig.rotation==2) {
int tmp=t.x;
t.x = t.y;
t.y = (tftHeight+20)-tmp;
}
if(bruceConfig.rotation==3) {
t.x=tftWidth-t.x;
t.y=(tftHeight+20)-t.y;
}
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,tftWidth,tftHeight-54,bruceConfig.bgColor); goto THIS_END; } // CAP
if (box_list[50].contain(t.x, t.y)) goto DEL; // DEL
Expand Down
6 changes: 3 additions & 3 deletions boards/m5stack-cplus1_1/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ String keyboard(String mytext, int maxSize, String msg) {
tft.setTextSize(FM);

//Draw the rectangles
if(y<0) {
if(y<0 || y2<0) {
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
Expand Down Expand Up @@ -363,14 +363,14 @@ void checkReboot() {
if (millis() - time_count > 500) {
tft.setCursor(60, 12);
tft.setTextSize(1);
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
countDown = (millis() - time_count) / 1000 + 1;
tft.printf(" PWR OFF IN %d/3\n", countDown);
delay(10);
}
}
// Clear text after releasing the button
delay(30);
tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), TFT_BLACK);
tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), bruceConfig.bgColor);
}
}
Loading
Loading