Skip to content

Commit

Permalink
Check if #POWER defined, thanks to @QDaniel !
Browse files Browse the repository at this point in the history
  • Loading branch information
tueddy committed Dec 18, 2024
1 parent dce79b1 commit 62e55a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@
#include "Port.h"

void Power_Init(void) {
#ifdef POWER
#if (POWER >= 0 && POWER <= MAX_GPIO)
pinMode(POWER, OUTPUT); // Only necessary for GPIO. For port-expander it's done (previously) via Port_init()
#endif
#endif
}

// Switch on peripherals. Please note: meaning of POWER_ON is HIGH per default. But is LOW in case of INVERT_POWER is enabled.
void Power_PeripheralOn(void) {
#ifdef POWER
Port_Write(POWER, POWER_ON, false);
#ifdef BUTTONS_LED
Port_Write(BUTTONS_LED, HIGH, false);
#endif
delay(50); // Give peripherals some time to settle down
#endif
}

// Switch off peripherals. Please note: meaning of POWER_OFF is LOW per default. But is HIGH in case of INVERT_POWER is enabled.
void Power_PeripheralOff(void) {
#ifdef POWER
Port_Write(POWER, POWER_OFF, false);
#ifdef BUTTONS_LED
Port_Write(BUTTONS_LED, LOW, false);
#endif
#endif
}

0 comments on commit 62e55a1

Please sign in to comment.