diff --git a/firmware/inc/hw_config/low-power-solar.h b/firmware/inc/hw_config/low-power-solar.h index c4d1d96..5f039ba 100644 --- a/firmware/inc/hw_config/low-power-solar.h +++ b/firmware/inc/hw_config/low-power-solar.h @@ -148,7 +148,15 @@ */ #define RECHARGABLE_BATTERY 1 #define CHG_ENABLE_PIN PIN_PA27 -#define RECHARGABLE_MIN_V (2.6) +#define RECHARGABLE_MIN_V (2.7) + +/** + * Power Bus + * bus is currently called solar + */ +/* bus is low when <2.5V, which corresponds to ~2.7V battery voltage */ +/* usually evaluated with minimal load on the battery */ +#define IS_BUS_LOW(dp) (get_solar() < 2.5) /** * Cold out diff --git a/firmware/src/main.c b/firmware/src/main.c index 4bcf45f..2378a57 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -343,25 +343,31 @@ int main(void) start_adc_sequence(); while (is_adc_sequence_done() == 0); /* wait for adc */ - - if (in_cold_out == 1) { - external_temperature = thermistor_ratio_to_temperature(get_thermistor()); /* read */ - if ((external_temperature < COLD_OUT_TEMPERATURE) && /* check temperature */ - (cold_out_count++ < COLD_OUT_COUNT_MAX)) { /* and max iterations */ - in_cold_out = 1; /* cold */ - - } else { - in_cold_out = 0; /* ready to go! */ - gps_init(); /* init the gps! */ - run_sequencer(n++, cycle_time_s); /* run for the first time! */ - } +#ifdef IS_BUS_LOW + if (IS_BUS_LOW()) { + set_cycle_time(1); /* set cycle time for cold out */ } else { - run_sequencer(n++, cycle_time_s); /* run */ +#endif + if (in_cold_out == 1) { + external_temperature = thermistor_ratio_to_temperature(get_thermistor()); /* read */ + if ((external_temperature < COLD_OUT_TEMPERATURE) && /* check temperature */ + (cold_out_count++ < COLD_OUT_COUNT_MAX)) { /* and max iterations */ + in_cold_out = 1; /* cold */ + + } else { + in_cold_out = 0; /* ready to go! */ + gps_init(); /* init the gps! */ + run_sequencer(n++, cycle_time_s); /* run for the first time! */ + } + } else { + run_sequencer(n++, cycle_time_s); /* run */ + } + + set_cycle_time(in_cold_out); /* set cycle time as required */ + +#ifdef IS_BUS_LOW } - - /* Hibernate timing */ - set_cycle_time(in_cold_out); - +#endif system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY); /* Lowest power */