commit
d27b3b4769
|
@ -18,7 +18,7 @@ int cursor = 0;
|
|||
int rotation = 1;
|
||||
int brightness = 100;
|
||||
bool rstOverride = false;
|
||||
#define EEPROM_SIZE 32
|
||||
#define EEPROM_SIZE 4
|
||||
|
||||
struct MENU {
|
||||
char name[19];
|
||||
|
@ -40,10 +40,10 @@ struct MENU {
|
|||
// 10 - Credits
|
||||
// 11 - Wifi beacon spam
|
||||
// 12 - Wifi spam menu
|
||||
// 13 - TV-B-Gone Region Setting
|
||||
|
||||
bool isSwitching = true;
|
||||
int current_proc = 0; // Start in Clock Mode
|
||||
|
||||
void switcher_button_proc() {
|
||||
if (rstOverride == false) {
|
||||
if (digitalRead(M5_BUTTON_RST) == LOW) {
|
||||
|
@ -83,7 +83,7 @@ void screen_dim_proc() {
|
|||
/// MAIN MENU ///
|
||||
MENU mmenu[] = {
|
||||
{ "clock", 0},
|
||||
{ "TV B-GONE", 5},
|
||||
{ "TV B-GONE", 13}, // We jump to the region menu first
|
||||
{ "AppleJuice", 8},
|
||||
{ "WiFi Spam", 12},
|
||||
{ "settings", 2},
|
||||
|
@ -123,11 +123,11 @@ void mmenu_loop() {
|
|||
|
||||
/// SETTINGS MENU ///
|
||||
MENU smenu[] = {
|
||||
{ "set clock time", 3},
|
||||
{ "brightness", 4},
|
||||
{ "battery info", 6},
|
||||
{ "brightness", 4},
|
||||
{ "set clock time", 3},
|
||||
{ "rotation", 7},
|
||||
{ "credits", 10},
|
||||
{ "about", 10},
|
||||
{ "back", 1},
|
||||
};
|
||||
|
||||
|
@ -318,20 +318,21 @@ void tvbgone_setup() {
|
|||
M5.Lcd.setTextSize(4);
|
||||
M5.Lcd.setCursor(5, 1);
|
||||
M5.Lcd.println("TV-B-Gone");
|
||||
M5.Lcd.setTextSize(2);
|
||||
irsend.begin();
|
||||
// Hack: Set IRLED high to turn it off after setup. Otherwise it stays on (active low)
|
||||
digitalWrite(IRLED, HIGH);
|
||||
|
||||
delay_ten_us(5000);
|
||||
if (digitalRead(REGIONSWITCH)) {
|
||||
region = NA;
|
||||
M5.Lcd.println("Region: NA");
|
||||
if(region == NA) {
|
||||
M5.Lcd.print("Region:\nAmericas / Asia\n");
|
||||
}
|
||||
else {
|
||||
region = EU;
|
||||
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()
|
||||
|
@ -348,6 +349,53 @@ void tvbgone_loop()
|
|||
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 ///
|
||||
void clock_setup() {
|
||||
M5.Lcd.setRotation(rotation);
|
||||
|
@ -721,9 +769,7 @@ void wifispam_setup() {
|
|||
M5.Lcd.print(rickrollssids);
|
||||
break;
|
||||
case 3:
|
||||
for(str = randoms; *str; ++str) ct += *str == '\n';
|
||||
M5.Lcd.printf(" - %d SSIDs:\n", ct);
|
||||
M5.Lcd.print(randoms);
|
||||
// placed here for consistency. no-op since display handled in loop.
|
||||
break;
|
||||
}
|
||||
M5.Lcd.setTextSize(2);
|
||||
|
@ -755,7 +801,7 @@ void wifispam_loop() {
|
|||
beaconSpam(rickrollssids);
|
||||
break;
|
||||
case 3:
|
||||
randoms = randomSSID();
|
||||
char* randoms = randomSSID();
|
||||
len = sizeof(randoms);
|
||||
while(i < len){
|
||||
i++;
|
||||
|
@ -836,24 +882,28 @@ void setup() {
|
|||
M5.begin();
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
// Uncomment these to blow away EEPROM to factory settings - for testing purposes
|
||||
//EEPROM.write(0, 255);
|
||||
//EEPROM.write(1, 255);
|
||||
//EEPROM.write(2, 255);
|
||||
//EEPROM.write(0, 255); // Rotation
|
||||
//EEPROM.write(1, 255); // dim time
|
||||
//EEPROM.write(2, 255); // brightness
|
||||
//EEPROM.write(2, 255); // TV-B-Gone Region
|
||||
//EEPROM.commit();
|
||||
Serial.printf("EEPROM 0: %d\n", EEPROM.read(0));
|
||||
Serial.printf("EEPROM 1: %d\n", EEPROM.read(1));
|
||||
Serial.printf("EEPROM 2: %d\n", EEPROM.read(2));
|
||||
if(EEPROM.read(0) > 3){
|
||||
Serial.printf("EEPROM 3: %d\n", EEPROM.read(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
|
||||
Serial.println("EEPROM likely not properly configured. Writing defaults.");
|
||||
EEPROM.write(0, 3); // Left rotation
|
||||
EEPROM.write(1, 15); // 15 second auto dim time
|
||||
EEPROM.write(2, 100); // 100% brightness
|
||||
EEPROM.write(3, 0); // TVBG NA Region
|
||||
EEPROM.commit();
|
||||
}
|
||||
rotation = EEPROM.read(0);
|
||||
screen_dim_time = EEPROM.read(1);
|
||||
brightness = EEPROM.read(2);
|
||||
region = EEPROM.read(3);
|
||||
M5.Axp.ScreenBreath(brightness);
|
||||
M5.Lcd.setRotation(rotation);
|
||||
M5.Lcd.setTextColor(GREEN, BLACK);
|
||||
|
@ -929,6 +979,10 @@ void loop() {
|
|||
break;
|
||||
case 12:
|
||||
wsmenu_setup();
|
||||
break;
|
||||
case 13:
|
||||
tvbgmenu_setup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -971,5 +1025,9 @@ void loop() {
|
|||
break;
|
||||
case 12:
|
||||
wsmenu_loop();
|
||||
break;
|
||||
case 13:
|
||||
tvbgmenu_loop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
15
tvbg.h
15
tvbg.h
|
@ -86,12 +86,9 @@ uint8_t region;
|
|||
void sendAllCodes()
|
||||
{
|
||||
bool endingEarly = false; //will be set to true if the user presses the button during code-sending
|
||||
if (digitalRead(REGIONSWITCH)) {
|
||||
region = NA;
|
||||
if (region == NA) {
|
||||
num_codes = num_NAcodes;
|
||||
}
|
||||
else {
|
||||
region = EU;
|
||||
} else {
|
||||
num_codes = num_EUcodes;
|
||||
}
|
||||
for (i = 0 ; i < num_codes; i++)
|
||||
|
@ -109,6 +106,7 @@ void sendAllCodes()
|
|||
M5.Lcd.setCursor(5, 1);
|
||||
M5.Lcd.println("TV-B-Gone");
|
||||
M5.Lcd.setTextSize(2);
|
||||
M5.Lcd.println("Front Key: Go/Pause");
|
||||
const uint8_t bitcompression = powerCode->bitcompression;
|
||||
code_ptr = 0;
|
||||
for (uint8_t k = 0; k < numpairs; k++) {
|
||||
|
@ -147,6 +145,13 @@ void sendAllCodes()
|
|||
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
|
||||
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) {
|
||||
|
|
|
@ -81,7 +81,7 @@ const char foobar[] PROGMEM = {
|
|||
|
||||
#define SSIDLEN 375 /* Change to whatever length you need */
|
||||
|
||||
const char* randomSSID(){
|
||||
char* randomSSID(){
|
||||
/* Change to allowable characters */
|
||||
const char possible[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -.!)(,?%";
|
||||
static char ssid[SSIDLEN + 1];
|
||||
|
@ -101,8 +101,6 @@ const char* randomSSID(){
|
|||
return ssid;
|
||||
}
|
||||
|
||||
const char* randoms = randomSSID();
|
||||
|
||||
#include <WiFi.h>
|
||||
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in New Issue