Adds PRST_BLINK_LED config to save battery
This commit is contained in:
parent
03dab21dca
commit
1abff035cb
2 changed files with 12 additions and 0 deletions
|
|
@ -11,6 +11,9 @@
|
|||
#define PRST_VERSION_1_2_X
|
||||
|
||||
// Built-in LED.
|
||||
// Wether or not to turn the LED on/off during the wake-up cycle. Impacts
|
||||
// battery life.
|
||||
#define PRST_BLINK_LED 0
|
||||
#define PRST_LED_PIN NRF_GPIO_PIN_MAP(0, 28)
|
||||
|
||||
// Deep sleep.
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ static void power_manage(void) {
|
|||
// - Turn on BLE advertising for a while;
|
||||
// - Turn everything off and return back to sleep.
|
||||
static void rtc_callback() {
|
||||
#if PRST_BLINK_LED
|
||||
nrf_gpio_pin_set(PRST_LED_PIN);
|
||||
#endif
|
||||
prst_shtc3_read_t temp_humi = prst_shtc3_read();
|
||||
nrf_gpio_pin_set(PRST_FAST_DISCH_PIN);
|
||||
prst_pwm_init();
|
||||
|
|
@ -81,7 +83,9 @@ static void rtc_callback() {
|
|||
prst_adv_start();
|
||||
nrf_delay_ms(PRST_BLE_ADV_TIME_IN_MS);
|
||||
prst_adv_stop();
|
||||
#if PRST_BLINK_LED
|
||||
nrf_gpio_pin_clear(PRST_LED_PIN);
|
||||
#endif
|
||||
NRF_LOG_FLUSH();
|
||||
run_counter++;
|
||||
}
|
||||
|
|
@ -94,6 +98,11 @@ int main(void) {
|
|||
prst_adc_init();
|
||||
prst_shtc3_init();
|
||||
|
||||
// Quick LED flash.
|
||||
nrf_gpio_pin_set(PRST_LED_PIN);
|
||||
nrf_delay_ms(200);
|
||||
nrf_gpio_pin_clear(PRST_LED_PIN);
|
||||
|
||||
// Set up RTC. It will call our custom callback at a regular interval, defined
|
||||
// by PRST_DEEP_SLEEP_IN_SECONDS.
|
||||
prst_rtc_set_callback(rtc_callback);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue