Skip to content

Commit 8b08ceb

Browse files
committed
Add FIRE LED on/off.
1 parent 276625a commit 8b08ceb

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

LovyanLauncher/LovyanLauncher.bin

4.88 KB
Binary file not shown.

LovyanLauncher/LovyanLauncher.ino

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#include <vector>
23
#include <M5Stack.h>
34
#include <M5StackUpdater.h> // https://github.com/tobozo/M5Stack-SD-Updater/
@@ -25,6 +26,7 @@
2526

2627
M5TreeView treeView;
2728
M5OnScreenKeyboard osk;
29+
const uint8_t NEOPIXEL_pin = 15;
2830

2931
void drawFrame() {
3032
Rect16 r = treeView.clientRect;
@@ -171,6 +173,28 @@ void callBackBatteryIP5306CTL0(MenuItem* sender)
171173
setIP5306REG(0, mi->value ? (data | mi->tag) : (data & ~(mi->tag)));
172174
}
173175

176+
void sendNeoPixelBit(bool flg) {
177+
digitalWrite(NEOPIXEL_pin, HIGH);
178+
for (int i = 0; i < 4; ++i) digitalWrite(NEOPIXEL_pin, flg);
179+
digitalWrite(NEOPIXEL_pin, LOW);
180+
}
181+
void sendNeoPixelColor(uint32_t color) {
182+
for (uint8_t i = 0; i < 24; ++i) {
183+
sendNeoPixelBit(color & 0x800000);
184+
color = color << 1;
185+
}
186+
}
187+
188+
void callBackFIRELED(MenuItem* sender)
189+
{
190+
MenuItemToggle* mi((MenuItemToggle*)sender);
191+
if (mi->value) {
192+
sendNeoPixelColor(0xFFFFFF);
193+
} else {
194+
sendNeoPixelColor(0);
195+
}
196+
}
197+
174198
void callBackRollBack(MenuItem* sender)
175199
{
176200
if( Update.canRollBack() ) {
@@ -193,6 +217,12 @@ void setup() {
193217
M5.begin();
194218
M5.Speaker.begin();
195219
Wire.begin();
220+
// for fire LED off
221+
pinMode(NEOPIXEL_pin, OUTPUT);
222+
sendNeoPixelColor(1);
223+
delay(1);
224+
sendNeoPixelColor(0);
225+
196226
if(digitalRead(BUTTON_A_PIN) == 0) {
197227
Serial.println("Will Load menu binary");
198228
updateFromFS(SD);
@@ -261,6 +291,7 @@ void setup() {
261291
{ new MenuItemToggle("BatteryCharge" , getIP5306REG(0) & 0x10, 0x10, callBackBatteryIP5306CTL0)
262292
, new MenuItemToggle("BatteryOutput" , getIP5306REG(0) & 0x20, 0x20, callBackBatteryIP5306CTL0)
263293
, new MenuItemToggle("Boot on load" , getIP5306REG(0) & 0x04, 0x04, callBackBatteryIP5306CTL0)
294+
, new MenuItemToggle("FIRE LED", false, callBackFIRELED)
264295
, new MenuItem("DeepSleep", callBackDeepSleep)
265296
})
266297
, new MenuItem("OTA Rollback", callBackRollBack)
@@ -269,14 +300,14 @@ void setup() {
269300
drawFrame();
270301
}
271302

272-
uint8_t loopcnt = 0xf;
303+
uint8_t loopcnt = 0xF;
273304
void loop() {
274305
treeView.update();
275306
if (treeView.isRedraw()) {
276307
drawFrame();
277-
loopcnt = 0xf;
308+
loopcnt = 0xF;
278309
}
279-
if (0 == (++loopcnt & 0xf)) {
310+
if (0 == (++loopcnt & 0xF)) {
280311
Header.draw();
281312
}
282313
}

0 commit comments

Comments
 (0)