Display fixes and optimizations

This commit is contained in:
Noah Axon 2023-11-23 11:03:33 -06:00
parent 97666ba271
commit ad39c271f3
1 changed files with 51 additions and 39 deletions

View File

@ -7,12 +7,14 @@
//#define CARDPUTER //#define CARDPUTER
// -=-=- Uncommenting more than one at a time will result in errors -=-=- // -=-=- Uncommenting more than one at a time will result in errors -=-=-
String buildver="2.0.0rc2"; String buildver="2.0.2";
#define BGCOLOR BLACK #define BGCOLOR BLACK
#define FGCOLOR GREEN #define FGCOLOR GREEN
#if defined(STICK_C_PLUS) #if defined(STICK_C_PLUS)
#include <M5StickCPlus.h> #include <M5StickCPlus.h>
// -=-=- Display -=-=-
String platformName="StickC+";
#define BIG_TEXT 4 #define BIG_TEXT 4
#define MEDIUM_TEXT 3 #define MEDIUM_TEXT 3
#define SMALL_TEXT 2 #define SMALL_TEXT 2
@ -30,6 +32,8 @@ String buildver="2.0.0rc2";
#if defined(STICK_C) #if defined(STICK_C)
#include <M5StickC.h> #include <M5StickC.h>
// -=-=- Display -=-=-
String platformName="StickC";
#define BIG_TEXT 2 #define BIG_TEXT 2
#define MEDIUM_TEXT 2 #define MEDIUM_TEXT 2
#define SMALL_TEXT 1 #define SMALL_TEXT 1
@ -46,6 +50,8 @@ String buildver="2.0.0rc2";
#if defined(CARDPUTER) #if defined(CARDPUTER)
#include <M5Cardputer.h> #include <M5Cardputer.h>
// -=-=- Display -=-=-
String platformName="Cardputer";
#define BIG_TEXT 4 #define BIG_TEXT 4
#define MEDIUM_TEXT 3 #define MEDIUM_TEXT 3
#define SMALL_TEXT 2 #define SMALL_TEXT 2
@ -57,7 +63,16 @@ String buildver="2.0.0rc2";
#define DISP M5Cardputer.Display #define DISP M5Cardputer.Display
#endif #endif
#include <EEPROM.h> // -=-=-=-=-=- LIST OF CURRENTLY DEFINED FEATURES -=-=-=-=-=-
// M5LED - An LED exposed as M5_LED
// RTC - Real-time clock exposed as M5.Rtc
// AXP - AXP192 Power Management exposed as M5.Axp
// KB - Keyboard exposed as M5Cardputer.Keyboard
// HID - HID exposed as USBHIDKeyboard
// USE_EEPROM - Store settings in EEPROM
// ROTATION - Allow screen to be rotated
// DISP - Set to the API's Display class
#include <IRremoteESP8266.h> #include <IRremoteESP8266.h>
#include <IRsend.h> #include <IRsend.h>
#include "applejuice.h" #include "applejuice.h"
@ -76,6 +91,7 @@ bool sourApple = false; // Internal flag to place AppleJuice into SourApple iO
bool swiftPair = false; // Internal flag to place AppleJuice into Swift Pair random packet Mode bool swiftPair = false; // Internal flag to place AppleJuice into Swift Pair random packet Mode
bool maelstrom = false; // Internal flag to place AppleJuice into Bluetooth Maelstrom mode bool maelstrom = false; // Internal flag to place AppleJuice into Bluetooth Maelstrom mode
#if defined(USE_EEPROM) #if defined(USE_EEPROM)
#include <EEPROM.h>
#define EEPROM_SIZE 4 #define EEPROM_SIZE 4
#endif #endif
struct MENU { struct MENU {
@ -161,9 +177,11 @@ bool check_next_press(){
if (M5Cardputer.Keyboard.isKeyPressed(';')){ if (M5Cardputer.Keyboard.isKeyPressed(';')){
// hack to handle the up arrow // hack to handle the up arrow
cursor = cursor - 2; cursor = cursor - 2;
check_kb();
return true; return true;
} }
if (M5Cardputer.Keyboard.isKeyPressed(KEY_TAB) || M5Cardputer.Keyboard.isKeyPressed('.')){ if (M5Cardputer.Keyboard.isKeyPressed(KEY_TAB) || M5Cardputer.Keyboard.isKeyPressed('.')){
check_kb();
return true; return true;
} }
#else #else
@ -177,6 +195,7 @@ bool check_next_press(){
bool check_select_press(){ bool check_select_press(){
#if defined(KB) #if defined(KB)
if (M5Cardputer.Keyboard.isKeyPressed(KEY_ENTER) || M5Cardputer.Keyboard.isKeyPressed('/')){ if (M5Cardputer.Keyboard.isKeyPressed(KEY_ENTER) || M5Cardputer.Keyboard.isKeyPressed('/')){
return true; return true;
} }
#else #else
@ -373,7 +392,7 @@ MENU smenu[] = {
void smenu_drawmenu() { void smenu_drawmenu() {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 8, 1); DISP.setCursor(0, 8, 1);
for ( int i = 0 ; i < ( sizeof(smenu) / sizeof(MENU) ) ; i++ ) { for ( int i = 0 ; i < ( sizeof(smenu) / sizeof(MENU) ) ; i++ ) {
DISP.print((cursor == i) ? ">" : " "); DISP.print((cursor == i) ? ">" : " ");
@ -423,7 +442,7 @@ int rotation = 1;
void rmenu_drawmenu() { void rmenu_drawmenu() {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 8, 1); DISP.setCursor(0, 8, 1);
for ( int i = 0 ; i < ( sizeof(rmenu) / sizeof(MENU) ) ; i++ ) { for ( int i = 0 ; i < ( sizeof(rmenu) / sizeof(MENU) ) ; i++ ) {
DISP.print((cursor == i) ? ">" : " "); DISP.print((cursor == i) ? ">" : " ");
@ -463,7 +482,7 @@ int rotation = 1;
/// BATTERY INFO /// /// BATTERY INFO ///
void battery_drawmenu(int battery, int b, int c) { void battery_drawmenu(int battery, int b, int c) {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 8, 1); DISP.setCursor(0, 8, 1);
DISP.print("Battery: "); DISP.print("Battery: ");
DISP.print(battery); DISP.print(battery);
@ -500,7 +519,7 @@ int rotation = 1;
/// TV-B-GONE /// /// TV-B-GONE ///
void tvbgone_setup() { void tvbgone_setup() {
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("TV-B-Gone"); DISP.println("TV-B-Gone");
@ -539,7 +558,7 @@ MENU tvbgmenu[] = {
void tvbgmenu_drawmenu() { void tvbgmenu_drawmenu() {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 8, 1); DISP.setCursor(0, 8, 1);
for ( int i = 0 ; i < ( sizeof(tvbgmenu) / sizeof(MENU) ) ; i++ ) { for ( int i = 0 ; i < ( sizeof(tvbgmenu) / sizeof(MENU) ) ; i++ ) {
DISP.print((cursor == i) ? ">" : " "); DISP.print((cursor == i) ? ">" : " ");
@ -548,7 +567,7 @@ void tvbgmenu_drawmenu() {
} }
void tvbgmenu_setup() { void tvbgmenu_setup() {
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("TV-B-Gone"); DISP.println("TV-B-Gone");
@ -604,7 +623,7 @@ void sendAllCodes() {
} }
const uint8_t freq = powerCode->timer_val; const uint8_t freq = powerCode->timer_val;
const uint8_t numpairs = powerCode->numpairs; const uint8_t numpairs = powerCode->numpairs;
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("TV-B-Gone"); DISP.println("TV-B-Gone");
@ -660,7 +679,7 @@ void sendAllCodes() {
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
quickflashLEDx(8); quickflashLEDx(8);
} }
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("TV-B-Gone"); DISP.println("TV-B-Gone");
@ -672,7 +691,7 @@ void sendAllCodes() {
/// CLOCK /// /// CLOCK ///
#if defined(RTC) #if defined(RTC)
void clock_setup() { void clock_setup() {
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(MEDIUM_TEXT); DISP.setTextSize(MEDIUM_TEXT);
} }
@ -686,7 +705,7 @@ void sendAllCodes() {
/// TIMESET /// /// TIMESET ///
void timeset_drawmenu(int nums) { void timeset_drawmenu(int nums) {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 5, 1); DISP.setCursor(0, 5, 1);
// scrolling menu // scrolling menu
if (cursor > 5) { if (cursor > 5) {
@ -706,7 +725,7 @@ void sendAllCodes() {
/// TIME SETTING /// /// TIME SETTING ///
void timeset_setup() { void timeset_setup() {
rstOverride = true; rstOverride = true;
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 5, 1); DISP.setCursor(0, 5, 1);
DISP.println("SET HOUR"); DISP.println("SET HOUR");
delay(2000); delay(2000);
@ -725,7 +744,7 @@ void sendAllCodes() {
} }
} }
int hour = cursor; int hour = cursor;
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 5, 1); DISP.setCursor(0, 5, 1);
DISP.println("SET MINUTE"); DISP.println("SET MINUTE");
delay(2000); delay(2000);
@ -740,7 +759,7 @@ void sendAllCodes() {
} }
} }
int minute = cursor; int minute = cursor;
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 5, 1); DISP.setCursor(0, 5, 1);
RTC_TimeTypeDef TimeStruct; RTC_TimeTypeDef TimeStruct;
TimeStruct.Hours = hour; TimeStruct.Hours = hour;
@ -767,7 +786,7 @@ MENU btmenu[] = {
void btmenu_drawmenu() { void btmenu_drawmenu() {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 8, 1); DISP.setCursor(0, 8, 1);
for ( int i = 0 ; i < ( sizeof(btmenu) / sizeof(MENU) ) ; i++ ) { for ( int i = 0 ; i < ( sizeof(btmenu) / sizeof(MENU) ) ; i++ ) {
DISP.print((cursor == i) ? ">" : " "); DISP.print((cursor == i) ? ">" : " ");
@ -794,7 +813,7 @@ void btmenu_loop() {
} }
if (check_select_press()) { if (check_select_press()) {
int option = btmenu[cursor].command; int option = btmenu[cursor].command;
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(MEDIUM_TEXT); DISP.setTextSize(MEDIUM_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("BT Spam"); DISP.println("BT Spam");
@ -803,7 +822,7 @@ void btmenu_loop() {
switch(option) { switch(option) {
case 0: case 0:
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
rstOverride = false; rstOverride = false;
isSwitching = true; isSwitching = true;
current_proc = 8; current_proc = 8;
@ -833,7 +852,7 @@ void btmenu_loop() {
DISP.print("\n\nNext: Exit"); DISP.print("\n\nNext: Exit");
break; break;
case 4: case 4:
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
rstOverride = false; rstOverride = false;
isSwitching = true; isSwitching = true;
current_proc = 1; current_proc = 1;
@ -876,7 +895,7 @@ MENU ajmenu[] = {
void aj_drawmenu() { void aj_drawmenu() {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 5, 1); DISP.setCursor(0, 5, 1);
// scrolling menu // scrolling menu
if (cursor > 5) { if (cursor > 5) {
@ -894,7 +913,7 @@ void aj_drawmenu() {
} }
void aj_setup(){ void aj_setup(){
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(MEDIUM_TEXT); DISP.setTextSize(MEDIUM_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("AppleJuice"); DISP.println("AppleJuice");
@ -1013,7 +1032,7 @@ void aj_loop(){
break; break;
} }
if (current_proc == 8 && isSwitching == false){ if (current_proc == 8 && isSwitching == false){
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(MEDIUM_TEXT); DISP.setTextSize(MEDIUM_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("AppleJuice"); DISP.println("AppleJuice");
@ -1188,13 +1207,13 @@ void wifispam_setup() {
// set channel // set channel
esp_wifi_set_channel(channels[0], WIFI_SECOND_CHAN_NONE); esp_wifi_set_channel(channels[0], WIFI_SECOND_CHAN_NONE);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("WiFi Spam"); DISP.println("WiFi Spam");
delay(1000); delay(1000);
DISP.setTextSize(TINY_TEXT); DISP.setTextSize(TINY_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 0); DISP.setCursor(0, 0);
DISP.print("WiFi Spam"); DISP.print("WiFi Spam");
int ct = 0; int ct = 0;
@ -1288,7 +1307,7 @@ MENU wsmenu[] = {
void wsmenu_drawmenu() { void wsmenu_drawmenu() {
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 8, 1); DISP.setCursor(0, 8, 1);
for ( int i = 0 ; i < ( sizeof(wsmenu) / sizeof(MENU) ) ; i++ ) { for ( int i = 0 ; i < ( sizeof(wsmenu) / sizeof(MENU) ) ; i++ ) {
DISP.print((cursor == i) ? ">" : " "); DISP.print((cursor == i) ? ">" : " ");
@ -1340,7 +1359,7 @@ void wsmenu_loop() {
void wscan_drawmenu() { void wscan_drawmenu() {
char ssid[19]; char ssid[19];
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 5, 1); DISP.setCursor(0, 5, 1);
// scrolling menu // scrolling menu
if (cursor > 4) { if (cursor > 4) {
@ -1411,7 +1430,7 @@ void wscan_result_loop(){
if(WiFi.SSID(cursor).length() > 12){ if(WiFi.SSID(cursor).length() > 12){
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
} }
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println(WiFi.SSID(cursor)); DISP.println(WiFi.SSID(cursor));
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
@ -1425,7 +1444,7 @@ void wscan_result_loop(){
void wscan_setup(){ void wscan_setup(){
rstOverride = false; rstOverride = false;
cursor = 0; cursor = 0;
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("WiFi Scan"); DISP.println("WiFi Scan");
@ -1433,12 +1452,12 @@ void wscan_setup(){
} }
void wscan_loop(){ void wscan_loop(){
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(MEDIUM_TEXT); DISP.setTextSize(MEDIUM_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
DISP.println("Scanning..."); DISP.println("Scanning...");
wifict = WiFi.scanNetworks(); wifict = WiFi.scanNetworks();
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.setCursor(5, 1); DISP.setCursor(5, 1);
if(wifict > 0){ if(wifict > 0){
@ -1449,21 +1468,14 @@ void wscan_loop(){
void bootScreen(){ void bootScreen(){
// Boot Screen // Boot Screen
DISP.fillScreen(BLACK); DISP.fillScreen(BGCOLOR);
DISP.setTextSize(BIG_TEXT); DISP.setTextSize(BIG_TEXT);
DISP.setCursor(40, 0); DISP.setCursor(40, 0);
DISP.println("M5-NEMO"); DISP.println("M5-NEMO");
DISP.setCursor(10, 30); DISP.setCursor(10, 30);
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
DISP.print(buildver); DISP.printf("%s-%s\n",buildver,platformName);
#if defined(STICK_C_PLUS)
DISP.println("-StickC+");
#endif
#if defined(STICK_C)
DISP.println("-StickC");
#endif
#if defined(CARDPUTER) #if defined(CARDPUTER)
DISP.println("-Cardputer");
DISP.println("Next: Down Arrow"); DISP.println("Next: Down Arrow");
DISP.println("Prev: Up Arrow"); DISP.println("Prev: Up Arrow");
DISP.println("Sel : Enter or ->"); DISP.println("Sel : Enter or ->");