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
|
#define PRST_VERSION_1_2_X
|
||||||
|
|
||||||
// Built-in LED.
|
// 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)
|
#define PRST_LED_PIN NRF_GPIO_PIN_MAP(0, 28)
|
||||||
|
|
||||||
// Deep sleep.
|
// Deep sleep.
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,9 @@ static void power_manage(void) {
|
||||||
// - Turn on BLE advertising for a while;
|
// - Turn on BLE advertising for a while;
|
||||||
// - Turn everything off and return back to sleep.
|
// - Turn everything off and return back to sleep.
|
||||||
static void rtc_callback() {
|
static void rtc_callback() {
|
||||||
|
#if PRST_BLINK_LED
|
||||||
nrf_gpio_pin_set(PRST_LED_PIN);
|
nrf_gpio_pin_set(PRST_LED_PIN);
|
||||||
|
#endif
|
||||||
prst_shtc3_read_t temp_humi = prst_shtc3_read();
|
prst_shtc3_read_t temp_humi = prst_shtc3_read();
|
||||||
nrf_gpio_pin_set(PRST_FAST_DISCH_PIN);
|
nrf_gpio_pin_set(PRST_FAST_DISCH_PIN);
|
||||||
prst_pwm_init();
|
prst_pwm_init();
|
||||||
|
|
@ -81,7 +83,9 @@ static void rtc_callback() {
|
||||||
prst_adv_start();
|
prst_adv_start();
|
||||||
nrf_delay_ms(PRST_BLE_ADV_TIME_IN_MS);
|
nrf_delay_ms(PRST_BLE_ADV_TIME_IN_MS);
|
||||||
prst_adv_stop();
|
prst_adv_stop();
|
||||||
|
#if PRST_BLINK_LED
|
||||||
nrf_gpio_pin_clear(PRST_LED_PIN);
|
nrf_gpio_pin_clear(PRST_LED_PIN);
|
||||||
|
#endif
|
||||||
NRF_LOG_FLUSH();
|
NRF_LOG_FLUSH();
|
||||||
run_counter++;
|
run_counter++;
|
||||||
}
|
}
|
||||||
|
|
@ -94,6 +98,11 @@ int main(void) {
|
||||||
prst_adc_init();
|
prst_adc_init();
|
||||||
prst_shtc3_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
|
// Set up RTC. It will call our custom callback at a regular interval, defined
|
||||||
// by PRST_DEEP_SLEEP_IN_SECONDS.
|
// by PRST_DEEP_SLEEP_IN_SECONDS.
|
||||||
prst_rtc_set_callback(rtc_callback);
|
prst_rtc_set_callback(rtc_callback);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue