make mcusleep variable, use mcusleepcycle
This commit is contained in:
parent
7404e75213
commit
6b41f23d59
2 changed files with 10 additions and 3 deletions
|
@ -333,6 +333,8 @@ powercycle_turn_radio_on(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
volatile uint8_t mcusleepcycle=16;
|
||||
|
||||
static char
|
||||
powercycle(struct rtimer *t, void *ptr)
|
||||
{
|
||||
|
@ -458,7 +460,7 @@ powercycle(struct rtimer *t, void *ptr)
|
|||
be blocked until a packet is detected */
|
||||
#if RDC_CONF_MCU_SLEEP
|
||||
static uint8_t sleepcycle;
|
||||
if((sleepcycle++ < 16) && !we_are_sending && !radio_is_on) {
|
||||
if((sleepcycle++ < mcusleepcycle) && !we_are_sending && !radio_is_on) {
|
||||
rtimer_arch_sleep(CYCLE_TIME - (RTIMER_NOW() - cycle_start));
|
||||
} else {
|
||||
sleepcycle = 0;
|
||||
|
|
|
@ -18,10 +18,11 @@ extern "C" {
|
|||
|
||||
#include "rest-engine.h"
|
||||
|
||||
extern volatile uint8_t mcusleepcycle; // default 16
|
||||
|
||||
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
||||
|
||||
extern resource_t res_htu21dtemp, res_htu21dhum, res_battery;
|
||||
|
||||
float htu21d_hum;
|
||||
float htu21d_temp;
|
||||
char htu21d_hum_s[8];
|
||||
|
@ -50,10 +51,14 @@ void setup (void)
|
|||
// LOOP_INTERVAL (10 * CLOCK_SECOND)
|
||||
void loop (void)
|
||||
{
|
||||
mcusleepcycle=0; // dont sleep
|
||||
htu21d_temp = htu.readTemperature();
|
||||
htu21d_hum = htu.readHumidity();
|
||||
mcusleepcycle=32; // sleep, wakeup every 32 cycles
|
||||
dtostrf(htu21d_temp , 6, 2, htu21d_temp_s );
|
||||
dtostrf(htu21d_hum , 6, 2, htu21d_hum_s );
|
||||
dtostrf(htu21d_hum , 6, 2, htu21d_hum_s );
|
||||
|
||||
// debug only
|
||||
// printf("Temp: %s",htu21d_temp_s);
|
||||
// printf("\t\tHum: %s\n",htu21d_hum_s);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue