Skip to content

Commit 94db350

Browse files
authored
Add LOG_POWERFSM and LOG_INPUT debug macros (#8791)
1 parent 2f0fe4e commit 94db350

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

src/PowerFSM.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ static bool isPowered()
5757

5858
static void sdsEnter()
5959
{
60-
LOG_DEBUG("State: SDS");
60+
LOG_POWERFSM("State: SDS");
6161
// FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw
6262
doDeepSleep(Default::getConfiguredOrDefaultMs(config.power.sds_secs), false, false);
6363
}
6464

6565
static void lowBattSDSEnter()
6666
{
67-
LOG_DEBUG("State: Lower batt SDS");
67+
LOG_POWERFSM("State: Lower batt SDS");
6868
doDeepSleep(Default::getConfiguredOrDefaultMs(config.power.sds_secs), false, true);
6969
}
7070
extern Power *power;
7171

7272
static void shutdownEnter()
7373
{
74-
LOG_DEBUG("State: SHUTDOWN");
74+
LOG_POWERFSM("State: SHUTDOWN");
7575
shutdownAtMsec = millis();
7676
}
7777

@@ -81,7 +81,7 @@ static uint32_t secsSlept;
8181

8282
static void lsEnter()
8383
{
84-
LOG_INFO("lsEnter begin, ls_secs=%u", config.power.ls_secs);
84+
LOG_POWERFSM("lsEnter begin, ls_secs=%u", config.power.ls_secs);
8585
if (screen)
8686
screen->setOn(false);
8787
secsSlept = 0; // How long have we been sleeping this time
@@ -155,12 +155,12 @@ static void lsIdle()
155155

156156
static void lsExit()
157157
{
158-
LOG_INFO("Exit state: LS");
158+
LOG_POWERFSM("State: lsExit");
159159
}
160160

161161
static void nbEnter()
162162
{
163-
LOG_DEBUG("State: NB");
163+
LOG_POWERFSM("State: nbEnter");
164164
if (screen)
165165
screen->setOn(false);
166166
#ifdef ARCH_ESP32
@@ -173,14 +173,15 @@ static void nbEnter()
173173

174174
static void darkEnter()
175175
{
176+
LOG_POWERFSM("State: darkEnter");
176177
setBluetoothEnable(true);
177178
if (screen)
178179
screen->setOn(false);
179180
}
180181

181182
static void serialEnter()
182183
{
183-
LOG_DEBUG("State: SERIAL");
184+
LOG_POWERFSM("State: serialEnter");
184185
setBluetoothEnable(false);
185186
if (screen) {
186187
screen->setOn(true);
@@ -189,13 +190,14 @@ static void serialEnter()
189190

190191
static void serialExit()
191192
{
193+
LOG_POWERFSM("State: serialExit");
192194
// Turn bluetooth back on when we leave serial stream API
193195
setBluetoothEnable(true);
194196
}
195197

196198
static void powerEnter()
197199
{
198-
// LOG_DEBUG("State: POWER");
200+
LOG_POWERFSM("State: powerEnter");
199201
if (!isPowered()) {
200202
// If we got here, we are in the wrong state - we should be in powered, let that state handle things
201203
LOG_INFO("Loss of power in Powered");
@@ -210,6 +212,7 @@ static void powerEnter()
210212

211213
static void powerIdle()
212214
{
215+
// LOG_POWERFSM("State: powerIdle"); // very chatty
213216
if (!isPowered()) {
214217
// If we got here, we are in the wrong state
215218
LOG_INFO("Loss of power in Powered");
@@ -219,19 +222,21 @@ static void powerIdle()
219222

220223
static void powerExit()
221224
{
225+
LOG_POWERFSM("State: powerExit");
222226
setBluetoothEnable(true);
223227
}
224228

225229
static void onEnter()
226230
{
227-
LOG_DEBUG("State: ON");
231+
LOG_POWERFSM("State: onEnter");
228232
if (screen)
229233
screen->setOn(true);
230234
setBluetoothEnable(true);
231235
}
232236

233237
static void onIdle()
234238
{
239+
LOG_POWERFSM("State: onIdle");
235240
if (isPowered()) {
236241
// If we got here, we are in the wrong state - we should be in powered, let that state handle things
237242
powerFSM.trigger(EVENT_POWER_CONNECTED);
@@ -240,7 +245,7 @@ static void onIdle()
240245

241246
static void bootEnter()
242247
{
243-
LOG_DEBUG("State: BOOT");
248+
LOG_POWERFSM("State: bootEnter");
244249
}
245250

246251
State stateSHUTDOWN(shutdownEnter, NULL, NULL, "SHUTDOWN");
@@ -317,11 +322,6 @@ void PowerFSM_setup()
317322
// if any packet destined for phone arrives, turn on bluetooth at least
318323
powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone");
319324

320-
// Removed 2.7: we don't show the nodes individually for every node on the screen anymore
321-
// powerFSM.add_transition(&stateNB, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
322-
// powerFSM.add_transition(&stateDARK, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
323-
// powerFSM.add_transition(&stateON, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
324-
325325
// Show the received text message
326326
powerFSM.add_transition(&stateLS, &stateON, EVENT_RECEIVED_MSG, NULL, "Received text");
327327
powerFSM.add_transition(&stateNB, &stateON, EVENT_RECEIVED_MSG, NULL, "Received text");

src/PowerFSM.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
#include "configuration.h"
44

5+
#ifdef PowerFSMDebug
6+
#define LOG_POWERFSM(...) LOG_DEBUG(__VA_ARGS__)
7+
#else
8+
#define LOG_POWERFSM(...)
9+
#endif
10+
511
// See sw-design.md for documentation
612

713
#define EVENT_PRESS 1

src/graphics/Screen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,7 @@ int Screen::handleUIFrameEvent(const UIFrameEvent *event)
16051605

16061606
int Screen::handleInputEvent(const InputEvent *event)
16071607
{
1608+
LOG_INPUT("Screen Input event %u! kb %u", event->inputEvent, event->kbchar);
16081609
if (!screenOn)
16091610
return 0;
16101611

src/input/InputBroker.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
#include "Observer.h"
44
#include "freertosinc.h"
55

6+
#ifdef InputBrokerDebug
7+
#define LOG_INPUT(...) LOG_DEBUG(__VA_ARGS__)
8+
#else
9+
#define LOG_INPUT(...)
10+
#endif
11+
612
enum input_broker_event {
713
INPUT_BROKER_NONE = 0,
814
INPUT_BROKER_SELECT = 10,

src/modules/SystemCommandsModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "SystemCommandsModule.h"
2+
#include "input/InputBroker.h"
23
#include "meshUtils.h"
34
#if HAS_SCREEN
45
#include "graphics/Screen.h"
@@ -22,7 +23,7 @@ SystemCommandsModule::SystemCommandsModule()
2223

2324
int SystemCommandsModule::handleInputEvent(const InputEvent *event)
2425
{
25-
LOG_INFO("Input event %u! kb %u", event->inputEvent, event->kbchar);
26+
LOG_INPUT("SystemCommands Input event %u! kb %u", event->inputEvent, event->kbchar);
2627
// System commands (all others fall through)
2728
switch (event->kbchar) {
2829
// Fn key symbols

0 commit comments

Comments
 (0)