From 6b41f23d59ad81a7b82a69635db57e5504177304 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Tue, 15 Sep 2015 09:52:06 +0200 Subject: [PATCH] make mcusleep variable, use mcusleepcycle --- core/net/mac/contikimac/contikimac.c | 4 +++- examples/osd/arduino-climate3/sketch.pde | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/net/mac/contikimac/contikimac.c b/core/net/mac/contikimac/contikimac.c index 7362fb527..2a28905d4 100644 --- a/core/net/mac/contikimac/contikimac.c +++ b/core/net/mac/contikimac/contikimac.c @@ -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; diff --git a/examples/osd/arduino-climate3/sketch.pde b/examples/osd/arduino-climate3/sketch.pde index a36d4ff94..9de6d6717 100644 --- a/examples/osd/arduino-climate3/sketch.pde +++ b/examples/osd/arduino-climate3/sketch.pde @@ -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); }