Fixed a lot of little things with TVBG and WiFi Spam
This commit is contained in:
parent
150f23e389
commit
443bc64cf8
111
m5stick-nemo.ino
111
m5stick-nemo.ino
|
@ -18,7 +18,7 @@ int cursor = 0;
|
||||||
int rotation = 1;
|
int rotation = 1;
|
||||||
int brightness = 100;
|
int brightness = 100;
|
||||||
bool rstOverride = false;
|
bool rstOverride = false;
|
||||||
#define EEPROM_SIZE 32
|
#define EEPROM_SIZE 4
|
||||||
|
|
||||||
struct MENU {
|
struct MENU {
|
||||||
char name[19];
|
char name[19];
|
||||||
|
@ -44,7 +44,6 @@ struct MENU {
|
||||||
|
|
||||||
bool isSwitching = true;
|
bool isSwitching = true;
|
||||||
int current_proc = 0; // Start in Clock Mode
|
int current_proc = 0; // Start in Clock Mode
|
||||||
|
|
||||||
void switcher_button_proc() {
|
void switcher_button_proc() {
|
||||||
if (rstOverride == false) {
|
if (rstOverride == false) {
|
||||||
if (digitalRead(M5_BUTTON_RST) == LOW) {
|
if (digitalRead(M5_BUTTON_RST) == LOW) {
|
||||||
|
@ -84,7 +83,7 @@ void screen_dim_proc() {
|
||||||
/// MAIN MENU ///
|
/// MAIN MENU ///
|
||||||
MENU mmenu[] = {
|
MENU mmenu[] = {
|
||||||
{ "clock", 0},
|
{ "clock", 0},
|
||||||
{ "TV B-GONE", 5},
|
{ "TV B-GONE", 13}, // We jump to the region menu first
|
||||||
{ "AppleJuice", 8},
|
{ "AppleJuice", 8},
|
||||||
{ "WiFi Spam", 12},
|
{ "WiFi Spam", 12},
|
||||||
{ "settings", 2},
|
{ "settings", 2},
|
||||||
|
@ -128,7 +127,6 @@ MENU smenu[] = {
|
||||||
{ "brightness", 4},
|
{ "brightness", 4},
|
||||||
{ "set clock time", 3},
|
{ "set clock time", 3},
|
||||||
{ "rotation", 7},
|
{ "rotation", 7},
|
||||||
{ "tvbg region", 13},
|
|
||||||
{ "about", 10},
|
{ "about", 10},
|
||||||
{ "back", 1},
|
{ "back", 1},
|
||||||
};
|
};
|
||||||
|
@ -276,47 +274,6 @@ void rmenu_loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TVBG-Region MENU ///
|
|
||||||
MENU tvbgmenu[] = {
|
|
||||||
{ "North America", 0},
|
|
||||||
{ "Europe", 1},
|
|
||||||
{ "back", region},
|
|
||||||
};
|
|
||||||
|
|
||||||
void tvbgmenu_drawmenu() {
|
|
||||||
M5.Lcd.setTextSize(2);
|
|
||||||
M5.Lcd.fillScreen(BLACK);
|
|
||||||
M5.Lcd.setCursor(0, 8, 1);
|
|
||||||
for ( int i = 0 ; i < ( sizeof(tvbgmenu) / sizeof(MENU) ) ; i++ ) {
|
|
||||||
M5.Lcd.print((cursor == i) ? ">" : " ");
|
|
||||||
M5.Lcd.println(tvbgmenu[i].name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tvbgmenu_setup() {
|
|
||||||
cursor = 0;
|
|
||||||
rstOverride = true;
|
|
||||||
tvbgmenu_drawmenu();
|
|
||||||
delay(250); // Prevent switching after menu loads up
|
|
||||||
}
|
|
||||||
|
|
||||||
void tvbgmenu_loop() {
|
|
||||||
if (digitalRead(M5_BUTTON_RST) == LOW) {
|
|
||||||
cursor++;
|
|
||||||
cursor = cursor % ( sizeof(tvbgmenu) / sizeof(MENU) );
|
|
||||||
tvbgmenu_drawmenu();
|
|
||||||
delay(250);
|
|
||||||
}
|
|
||||||
if (digitalRead(M5_BUTTON_HOME) == LOW) {
|
|
||||||
rstOverride = false;
|
|
||||||
isSwitching = true;
|
|
||||||
region = tvbgmenu[cursor].command;
|
|
||||||
EEPROM.write(3, region);
|
|
||||||
EEPROM.commit();
|
|
||||||
current_proc = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// BATTERY INFO ///
|
/// BATTERY INFO ///
|
||||||
void battery_drawmenu(int battery, int b, int c) {
|
void battery_drawmenu(int battery, int b, int c) {
|
||||||
M5.Lcd.setTextSize(2);
|
M5.Lcd.setTextSize(2);
|
||||||
|
@ -361,18 +318,21 @@ void tvbgone_setup() {
|
||||||
M5.Lcd.setTextSize(4);
|
M5.Lcd.setTextSize(4);
|
||||||
M5.Lcd.setCursor(5, 1);
|
M5.Lcd.setCursor(5, 1);
|
||||||
M5.Lcd.println("TV-B-Gone");
|
M5.Lcd.println("TV-B-Gone");
|
||||||
|
M5.Lcd.setTextSize(2);
|
||||||
irsend.begin();
|
irsend.begin();
|
||||||
// Hack: Set IRLED high to turn it off after setup. Otherwise it stays on (active low)
|
// Hack: Set IRLED high to turn it off after setup. Otherwise it stays on (active low)
|
||||||
digitalWrite(IRLED, HIGH);
|
digitalWrite(IRLED, HIGH);
|
||||||
|
|
||||||
delay_ten_us(5000);
|
delay_ten_us(5000);
|
||||||
if(region == NA) {
|
if(region == NA) {
|
||||||
M5.Lcd.println("Region: NA");
|
M5.Lcd.print("Region:\nAmericas / Asia\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
M5.Lcd.println("Region: EU");
|
M5.Lcd.println("Region: EMEA");
|
||||||
}
|
}
|
||||||
delay(1000); // Give time after loading
|
M5.Lcd.println("Front Key: Go/Pause");
|
||||||
|
M5.Lcd.println("Side Key: Exit");
|
||||||
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tvbgone_loop()
|
void tvbgone_loop()
|
||||||
|
@ -389,6 +349,53 @@ void tvbgone_loop()
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TVBG-Region MENU ///
|
||||||
|
MENU tvbgmenu[] = {
|
||||||
|
{ "Americas / Asia", 0},
|
||||||
|
{ "EU/MidEast/Africa", 1},
|
||||||
|
};
|
||||||
|
|
||||||
|
void tvbgmenu_drawmenu() {
|
||||||
|
M5.Lcd.setTextSize(2);
|
||||||
|
M5.Lcd.fillScreen(BLACK);
|
||||||
|
M5.Lcd.setCursor(0, 8, 1);
|
||||||
|
for ( int i = 0 ; i < ( sizeof(tvbgmenu) / sizeof(MENU) ) ; i++ ) {
|
||||||
|
M5.Lcd.print((cursor == i) ? ">" : " ");
|
||||||
|
M5.Lcd.println(tvbgmenu[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tvbgmenu_setup() {
|
||||||
|
M5.Lcd.fillScreen(BLACK);
|
||||||
|
M5.Lcd.setTextSize(4);
|
||||||
|
M5.Lcd.setCursor(5, 1);
|
||||||
|
M5.Lcd.println("TV-B-Gone");
|
||||||
|
M5.Lcd.setTextSize(3);
|
||||||
|
M5.Lcd.println("Region");
|
||||||
|
cursor = region % 2;
|
||||||
|
rstOverride = true;
|
||||||
|
delay(1000);
|
||||||
|
tvbgmenu_drawmenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tvbgmenu_loop() {
|
||||||
|
if (digitalRead(M5_BUTTON_RST) == LOW) {
|
||||||
|
cursor++;
|
||||||
|
cursor = cursor % ( sizeof(tvbgmenu) / sizeof(MENU) );
|
||||||
|
tvbgmenu_drawmenu();
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
if (digitalRead(M5_BUTTON_HOME) == LOW) {
|
||||||
|
region = tvbgmenu[cursor].command;
|
||||||
|
EEPROM.write(3, region);
|
||||||
|
EEPROM.commit();
|
||||||
|
rstOverride = false;
|
||||||
|
isSwitching = true;
|
||||||
|
current_proc = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// CLOCK ///
|
/// CLOCK ///
|
||||||
void clock_setup() {
|
void clock_setup() {
|
||||||
M5.Lcd.setRotation(rotation);
|
M5.Lcd.setRotation(rotation);
|
||||||
|
@ -762,9 +769,7 @@ void wifispam_setup() {
|
||||||
M5.Lcd.print(rickrollssids);
|
M5.Lcd.print(rickrollssids);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
for(str = randoms; *str; ++str) ct += *str == '\n';
|
// placed here for consistency. no-op since display handled in loop.
|
||||||
M5.Lcd.printf(" - %d SSIDs:\n", ct);
|
|
||||||
M5.Lcd.print(randoms);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
M5.Lcd.setTextSize(2);
|
M5.Lcd.setTextSize(2);
|
||||||
|
@ -796,7 +801,7 @@ void wifispam_loop() {
|
||||||
beaconSpam(rickrollssids);
|
beaconSpam(rickrollssids);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
randoms = randomSSID();
|
char* randoms = randomSSID();
|
||||||
len = sizeof(randoms);
|
len = sizeof(randoms);
|
||||||
while(i < len){
|
while(i < len){
|
||||||
i++;
|
i++;
|
||||||
|
@ -886,7 +891,7 @@ void setup() {
|
||||||
Serial.printf("EEPROM 1: %d\n", EEPROM.read(1));
|
Serial.printf("EEPROM 1: %d\n", EEPROM.read(1));
|
||||||
Serial.printf("EEPROM 2: %d\n", EEPROM.read(2));
|
Serial.printf("EEPROM 2: %d\n", EEPROM.read(2));
|
||||||
Serial.printf("EEPROM 3: %d\n", EEPROM.read(3));
|
Serial.printf("EEPROM 3: %d\n", EEPROM.read(3));
|
||||||
if(EEPROM.read(0) > 3){
|
if(EEPROM.read(0) > 3 || EEPROM.read(1) > 30 || EEPROM.read(2) > 100 || EEPROM.read(3) > 1) {
|
||||||
// Let's just assume rotation > 3 is a fresh/corrupt EEPROM and write defaults for everything
|
// Let's just assume rotation > 3 is a fresh/corrupt EEPROM and write defaults for everything
|
||||||
Serial.println("EEPROM likely not properly configured. Writing defaults.");
|
Serial.println("EEPROM likely not properly configured. Writing defaults.");
|
||||||
EEPROM.write(0, 3); // Left rotation
|
EEPROM.write(0, 3); // Left rotation
|
||||||
|
|
8
tvbg.h
8
tvbg.h
|
@ -106,6 +106,7 @@ void sendAllCodes()
|
||||||
M5.Lcd.setCursor(5, 1);
|
M5.Lcd.setCursor(5, 1);
|
||||||
M5.Lcd.println("TV-B-Gone");
|
M5.Lcd.println("TV-B-Gone");
|
||||||
M5.Lcd.setTextSize(2);
|
M5.Lcd.setTextSize(2);
|
||||||
|
M5.Lcd.println("Front Key: Go/Pause");
|
||||||
const uint8_t bitcompression = powerCode->bitcompression;
|
const uint8_t bitcompression = powerCode->bitcompression;
|
||||||
code_ptr = 0;
|
code_ptr = 0;
|
||||||
for (uint8_t k = 0; k < numpairs; k++) {
|
for (uint8_t k = 0; k < numpairs; k++) {
|
||||||
|
@ -144,6 +145,13 @@ void sendAllCodes()
|
||||||
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
|
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
|
||||||
quickflashLEDx(8);
|
quickflashLEDx(8);
|
||||||
}
|
}
|
||||||
|
M5.Lcd.fillScreen(BLACK);
|
||||||
|
M5.Lcd.setTextSize(4);
|
||||||
|
M5.Lcd.setCursor(5, 1);
|
||||||
|
M5.Lcd.println("TV-B-Gone");
|
||||||
|
M5.Lcd.setTextSize(2);
|
||||||
|
M5.Lcd.println("Front Key: Go/Pause");
|
||||||
|
M5.Lcd.println("Side Key: Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
void delay_ten_us(uint16_t us) {
|
void delay_ten_us(uint16_t us) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ const char foobar[] PROGMEM = {
|
||||||
|
|
||||||
#define SSIDLEN 375 /* Change to whatever length you need */
|
#define SSIDLEN 375 /* Change to whatever length you need */
|
||||||
|
|
||||||
const char* randomSSID(){
|
char* randomSSID(){
|
||||||
/* Change to allowable characters */
|
/* Change to allowable characters */
|
||||||
const char possible[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -.!)(,?%";
|
const char possible[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -.!)(,?%";
|
||||||
static char ssid[SSIDLEN + 1];
|
static char ssid[SSIDLEN + 1];
|
||||||
|
@ -101,8 +101,6 @@ const char* randomSSID(){
|
||||||
return ssid;
|
return ssid;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* randoms = randomSSID();
|
|
||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
Loading…
Reference in New Issue