Merge pull request #15 from n0xa/brightness-fix

Brightness fix
This commit is contained in:
Noah Axon 2023-10-01 00:34:57 -05:00 committed by GitHub
commit ab3d3128b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 8 deletions

View File

@ -1,8 +1,9 @@
# M5Stick-NEMO
M5 Stick C firmware for high-tech pranks
## Name
NEMO is named after the small, clever and headstrong fish in Finding Nemo. This project stands in contrast to other gadgets that have become associated with certain sea-dwelling creatures.
## Name and Background
NEMO started a personal project to help me learn more about ESP32 development with the Arduino IDE. I decided to replicate a few common, trending pranks that were getting a lot of attention in the tech community, as a challenge to myself, and to also better understand these attacks.
NEMO is named after the small, clever and stubborn fish in Finding Nemo. This project stands in contrast to another high-tech gadget that's associated with certain sea-dwelling creatures. I did want to prove that there are a lot of things you can do with a small development kit and some curiosity. I have no delusions of superseding the capabilities of any similar device with this project. It's just for fun, and my own education.
## Features
* [TV B-Gone](http://www.righto.com/2010/11/improved-arduino-tv-b-gone.html) port (thanks to MrArm's [HAKRWATCH](https://github.com/MrARM/hakrwatch)) to shut off many infrared-controlled TVs, projectors and other devices
@ -12,6 +13,32 @@ NEMO is named after the small, clever and headstrong fish in Finding Nemo. This
* EEPROM-backed Settings for rotation, brightness and, automatic dimming
* Battery level and credits in settings menu
## Install from M5Burner
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.
* Launch M5Burner
* Select "StickC" from the menu on the left
* Use the search at the top of the app to look for "NEMO For M5Stick C Plus"
* Click Download
* Click Burn
## Install .bin files manually with esptool.py
* Install ESP-IDF tools per the [Espressif Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/)
* Open the esp-idf CMD tool (on Windows) - on Mac or Linux, esp-idf.py and esptool.py should be in the system path.
* esptool.py --port COMPORT -b 115200 write_flash -z 0x0 M5Nemo-VERSION.bin
* port may be a COM port e.g. COM4, COM11 on Windows. On Mac and Linux it will usually be in /dev such as /dev/ttyUSB0, /dev/ttyACM0 or /dev/cu.usbserial-3
* M5Nemo-VERSION.bin should be a version you downloaded from a GitHub Release -- preferably the latest available.
## Building from Source
* I have compiled successfully using Arduino IDE on Linux and Windows
* If app size is too large, you must switch partition schemes. Tools -> Partition Scheme -> No OTA (Large APP)
If you want to customize NEMO or contribute to the project, you should be familiar with building NEMO from source.
* Install Arduino IDE. I've used Arduino 1.8 on Linux and Windows, and Arduino 2.2 on Windows successfully.
* Install the M5Stack boards for Arduino IDE: In File -> Preferences, paste this URL into the "Boards Manager URLs" text box. Use commas between URLs if there are already URLs present. https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
* If M5Stack -> M5Stick-C-Plus doesn't show up under Tools -> Boards, then use Tools -> Boards -> Boards Manager and search for M5Stack. This will install support for most of the M5Stack boards including the Stick C Plus.
* Ensure the M5Stick-C-Plus is selected in the boards menu.
* Install necessary libraries. In Sketch -> Include Library -> Library Manager, search for and install the following libraries and any dependencies they require:
* M5StickCPlus
* IRRemoteESP8266
* Switch partition schemes. Tools -> Partition Scheme -> No OTA (Large APP)
* Compile and upload the project

View File

@ -9,6 +9,13 @@
#include "wifispam.h"
#include <BLEUtils.h>
#include <BLEServer.h>
bool pct_brightness = true; /* set to false if the screen goes
to full brightness over level 2.
Useful range is about 7-15.
Set to true if the screen is too
dim no matter what level is set.
Some versions of the M5Stack lib
have a percentage range 0-100. */
int advtime = 0;
String formattedDate;
@ -211,19 +218,31 @@ void dmenu_loop() {
M5.Lcd.setCursor(0, 5, 1);
M5.Lcd.println("SET BRIGHTNESS");
delay(1000);
cursor = brightness / 10;
if(pct_brightness){
cursor = brightness / 10;
} else {
cursor = brightness + 5;
}
timeset_drawmenu(11);
while(digitalRead(M5_BUTTON_HOME) == HIGH) {
if (digitalRead(M5_BUTTON_RST) == LOW) {
cursor++;
cursor = cursor % 11 ;
timeset_drawmenu(11);
M5.Axp.ScreenBreath(10 * cursor);
if(pct_brightness){
M5.Axp.ScreenBreath(10 * cursor);
} else {
M5.Axp.ScreenBreath(5 + cursor);
}
delay(250);
}
}
brightness = 10 * cursor;
M5.Axp.ScreenBreath(brightness);
if(pct_brightness){
brightness = cursor * 10;
} else {
brightness = cursor + 5;
}
M5.Axp.ScreenBreath(brightness);
EEPROM.write(2, brightness);
EEPROM.commit();
rstOverride = false;