Tweaks to TV-B-Gone to work with power button menu

This commit is contained in:
Noah Axon 2023-10-08 00:01:23 -05:00
parent ec47d8bd01
commit 614a9ada71
3 changed files with 83 additions and 71 deletions

View File

@ -13,6 +13,14 @@ NEMO is named after the small, clever and stubborn fish in Finding Nemo. This pr
* EEPROM-backed Settings for rotation, brightness and, automatic dimming * EEPROM-backed Settings for rotation, brightness and, automatic dimming
* Battery level and credits in settings menu * Battery level and credits in settings menu
## User Interface
* A quick tap of the power button (closest to the USB port) will bring up the main menu from anywhere.
* Long pressing the power button for 6 seconds turns off the unit.
* In Function modes, the side button stops or pauses the process and brings up a menu.
* In Menu mode, the side button scrolls the cursor to the next option in the menu.
* In Function modes, the front M5 button wakes up the dim screen.
* In Menu mode, the front M5 button activates the selected menu item next to the cursor.
## Install from M5Burner ## Install from M5Burner
This is the absolute easiest way to get NEMO This is the absolute easiest way to get NEMO
* [M5Stick C Plus Quick Start](https://docs.m5stack.com/en/quick_start/m5stickc_plus/uiflow) has links to the M5Burner app for Linux, MacOS and Windows. This is the official tool to install UIFlow and other official firmware. I provide up-to-date binaries for NEMO there. * [M5Stick C Plus Quick Start](https://docs.m5stack.com/en/quick_start/m5stickc_plus/uiflow) has links to the M5Burner app for Linux, MacOS and Windows. This is the official tool to install UIFlow and other official firmware. I provide up-to-date binaries for NEMO there.

View File

@ -426,6 +426,81 @@ void tvbgmenu_loop() {
} }
} }
void sendAllCodes()
{
bool endingEarly = false; //will be set to true if the user presses the button during code-sending
if (region == NA) {
num_codes = num_NAcodes;
} else {
num_codes = num_EUcodes;
}
for (i = 0 ; i < num_codes; i++)
{
if (region == NA) {
powerCode = NApowerCodes[i];
}
else {
powerCode = EUpowerCodes[i];
}
const uint8_t freq = powerCode->timer_val;
const uint8_t numpairs = powerCode->numpairs;
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");
const uint8_t bitcompression = powerCode->bitcompression;
code_ptr = 0;
for (uint8_t k = 0; k < numpairs; k++) {
uint16_t ti;
ti = (read_bits(bitcompression)) * 2;
offtime = powerCode->times[ti]; // read word 1 - ontime
ontime = powerCode->times[ti + 1]; // read word 2 - offtime
M5.Lcd.setTextSize(1);
M5.Lcd.printf("rti = %d Pair = %d, %d\n", ti >> 1, ontime, offtime);
rawData[k * 2] = offtime * 10;
rawData[(k * 2) + 1] = ontime * 10;
yield();
}
irsend.sendRaw(rawData, (numpairs * 2) , freq);
// Hack: Set IRLED high to turn it off after each burst. Otherwise it stays on (active low)
digitalWrite(IRLED, HIGH);
yield();
bitsleft_r = 0;
delay_ten_us(20500);
if (M5.Axp.GetBtnPress()){
// duplicate code here, sadly, since this is a blocking loop
endingEarly = true;
current_proc = 1;
isSwitching = true;
rstOverride = false;
break;
}
if (digitalRead(TRIGGER) == BUTTON_PRESSED){
while (digitalRead(TRIGGER) == BUTTON_PRESSED) {
yield();
}
endingEarly = true;
quickflashLEDx(4);
break;
}
}
if (endingEarly == false)
{
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
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");
}
/// CLOCK /// /// CLOCK ///
void clock_setup() { void clock_setup() {

71
tvbg.h
View File

@ -83,77 +83,6 @@ uint16_t ontime, offtime;
uint8_t i, num_codes; uint8_t i, num_codes;
uint8_t region; uint8_t region;
void sendAllCodes()
{
bool endingEarly = false; //will be set to true if the user presses the button during code-sending
if (region == NA) {
num_codes = num_NAcodes;
} else {
num_codes = num_EUcodes;
}
for (i = 0 ; i < num_codes; i++)
{
if (region == NA) {
powerCode = NApowerCodes[i];
}
else {
powerCode = EUpowerCodes[i];
}
const uint8_t freq = powerCode->timer_val;
const uint8_t numpairs = powerCode->numpairs;
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");
const uint8_t bitcompression = powerCode->bitcompression;
code_ptr = 0;
for (uint8_t k = 0; k < numpairs; k++) {
uint16_t ti;
ti = (read_bits(bitcompression)) * 2;
offtime = powerCode->times[ti]; // read word 1 - ontime
ontime = powerCode->times[ti + 1]; // read word 2 - offtime
M5.Lcd.setTextSize(1);
M5.Lcd.printf("rti = %d Pair = %d, %d\n", ti >> 1, ontime, offtime);
rawData[k * 2] = offtime * 10;
rawData[(k * 2) + 1] = ontime * 10;
yield();
}
irsend.sendRaw(rawData, (numpairs * 2) , freq);
// Hack: Set IRLED high to turn it off after each burst. Otherwise it stays on (active low)
digitalWrite(IRLED, HIGH);
yield();
bitsleft_r = 0;
delay_ten_us(20500);
if (digitalRead(TRIGGER) == BUTTON_PRESSED)
{
while (digitalRead(TRIGGER) == BUTTON_PRESSED) {
yield();
}
endingEarly = true;
delay_ten_us(50000); //500ms delay
quickflashLEDx(4);
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
break; //exit the POWER code "for" loop
}
}
if (endingEarly == false)
{
delay_ten_us(MAX_WAIT_TIME); // wait 655.350ms
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) { void delay_ten_us(uint16_t us) {
uint8_t timer; uint8_t timer;
while (us != 0) { while (us != 0) {