diff --git a/examples/osd/pir-sensor/er-example-server.c b/examples/osd/pir-sensor/er-example-server.c index 3b8829913..55ad98d4a 100644 --- a/examples/osd/pir-sensor/er-example-server.c +++ b/examples/osd/pir-sensor/er-example-server.c @@ -45,15 +45,15 @@ /* Define which resources to include to meet memory constraints. */ #define REST_RES_INFO 1 -#define REST_RES_DS1820 1 -#define REST_RES_DHT11 1 -#define REST_RES_TEMPERATURE 1 +#define REST_RES_DS1820 0 +#define REST_RES_DHT11 0 +#define REST_RES_TEMPERATURE 0 #define REST_RES_HELLO 0 #define REST_RES_MIRROR 0 /* causes largest code size */ #define REST_RES_CHUNKS 0 #define REST_RES_SEPARATE 0 #define REST_RES_PUSHING 0 -#define REST_RES_EVENT 0 +#define REST_RES_EVENT 1 #define REST_RES_SUB 0 #define REST_RES_LEDS 0 #define REST_RES_TOGGLE 0 @@ -765,7 +765,7 @@ pushing_periodic_handler(resource_t *r) * Additionally takes a period parameter that defines the interval to call [name]_periodic_handler(). * A default post_handler takes care of subscriptions and manages a list of subscribers to notify. */ -EVENT_RESOURCE(event, METHOD_GET, "sensors/button", "title=\"Event demo\";obs"); +EVENT_RESOURCE(event, METHOD_GET, "sensors/pir", "title=\"Event demo\";obs"); void event_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) diff --git a/platform/osd-er-lp24/button-sensor.c b/platform/osd-er-lp24/button-sensor.c deleted file mode 100644 index 4daf2237e..000000000 --- a/platform/osd-er-lp24/button-sensor.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Dummy sensor routine */ - -#include "lib/sensors.h" -#include "dev/button-sensor.h" -const struct sensors_sensor button_sensor; -static int status(int type); -struct sensors_sensor *sensors[1]; -unsigned char sensors_flags[1]; - - -static int -value(int type) -{ - return 0; -} - -static int -configure(int type, int c) -{ - switch (type) { - case SENSORS_ACTIVE: - if (c) { - if(!status(SENSORS_ACTIVE)) { - } - } else { - } - return 1; - } - return 0; -} - -static int -status(int type) -{ - switch (type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return 1; - } - return 0; -} - -SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, - value, configure, status); - diff --git a/platform/osd-er-lp24/dev/button-sensor.c b/platform/osd-er-lp24/dev/button-sensor.c index d9cab0c1e..98339ab28 100644 --- a/platform/osd-er-lp24/dev/button-sensor.c +++ b/platform/osd-er-lp24/dev/button-sensor.c @@ -1,56 +1,20 @@ -/* -* Copyright (c) 2005, Swedish Institute of Computer Science -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the Institute nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -* -* This file is part of the Contiki operating system. -* -* @(#)$Id: button-sensor.c,v 1.4 2010/01/14 20:01:19 nifi Exp $ -*/ -#include "contiki.h" +/* Sensor routine */ + #include "lib/sensors.h" #include "dev/button-sensor.h" -//#include "dev/leds.h" #include - -//#include "dev/hwconf.h" -//#include "isr_compat.h" +#include "led.h" // debug const struct sensors_sensor button_sensor; static struct timer debouncetimer; static int status(int type); - static int enabled = 0; +struct sensors_sensor *sensors[1]; +unsigned char sensors_flags[1]; -//HWCONF_PIN(BUTTON, 2, 7); -//HWCONF_IRQ(BUTTON, 2, 7); - -#define BUTTON_BIT INTF5 +#define BUTTON_BIT INTF6 #define BUTTON_CHECK_IRQ() (EIFR & BUTTON_BIT) ? 0 : 1 #define PRINTF(...) printf(__VA_ARGS__) @@ -62,63 +26,64 @@ ISR(INT6_vect) if(BUTTON_CHECK_IRQ()) { if(timer_expired(&debouncetimer)) { + led1_on(); timer_set(&debouncetimer, CLOCK_SECOND / 4); sensors_changed(&button_sensor); - + led1_off(); } } } /*---------------------------------------------------------------------------*/ -static int value(int type) + +static int +value(int type) { - return (PORTE & _BV(PE5) ? 0 : 1) || !timer_expired(&debouncetimer); + return (PORTE & _BV(PE6) ? 0 : 1) || !timer_expired(&debouncetimer); + //return 0; } -/*---------------------------------------------------------------------------*/ -static int configure(int type, int c) + +static int +configure(int type, int c) { PRINTF("Sensor Button Configure called: %d, %d\n",type,c); - - switch (type) { - case SENSORS_ACTIVE: - if (c) { - if(!status(SENSORS_ACTIVE)) { -timer_set(&debouncetimer, 0); - -PRINTF("Setup sensor started\n"); - -DDRE |= (0<