From 797c3da2398b29c05e404cf05bf2ab12b1b8545f Mon Sep 17 00:00:00 2001 From: harald42 Date: Mon, 15 Apr 2013 10:28:03 +0200 Subject: [PATCH] add isr --- examples/osd/light-actor/er-example-server.c | 22 ++++++++---- examples/osd/light-actor/pcintkey.c | 36 ++++++++++++++++++-- examples/osd/light-actor/pcintkey.h | 5 +-- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/examples/osd/light-actor/er-example-server.c b/examples/osd/light-actor/er-example-server.c index 8de83cddf..d861e025c 100644 --- a/examples/osd/light-actor/er-example-server.c +++ b/examples/osd/light-actor/er-example-server.c @@ -144,6 +144,7 @@ extbutton_handler(void* request, void* response, uint8_t *buffer, uint16_t prefe { static char bname1[17]="button1"; static char bname2[17]="button2"; + static char bname3[17]="button3"; int success = 1; char temp[100]; @@ -156,12 +157,17 @@ extbutton_handler(void* request, void* response, uint8_t *buffer, uint16_t prefe case METHOD_GET: // jSON Format index += sprintf(temp + index,"{\n \"%s\" : ",bname1); - if(is_button_ext1()) + if(is_button_ext4()) index += sprintf(temp + index,"\"on\",\n"); else index += sprintf(temp + index,"\"off\",\n"); - index += sprintf(temp + index," \"%s\" : ",bname2); - if(is_button_ext2()) + index += sprintf(temp + index,"{\n \"%s\" : ",bname2); + if(is_button_ext5()) + index += sprintf(temp + index,"\"on\",\n"); + else + index += sprintf(temp + index,"\"off\",\n"); + index += sprintf(temp + index," \"%s\" : ",bname3); + if(is_button_ext6()) index += sprintf(temp + index,"\"on\"\n"); else index += sprintf(temp + index,"\"off\"\n"); @@ -540,10 +546,12 @@ AUTOSTART_PROCESSES(&rest_server_example, &sensors_process); PROCESS_THREAD(rest_server_example, ev, data) { static struct etimer ds_periodic_timer; - static int ext1; - static int ext2; - ext1 = is_button_ext1(); - ext2 = is_button_ext2(); + static int ext4; + static int ext5; + static int ext6; + ext4 = is_button_ext4(); + ext5 = is_button_ext5(); + ext6 = is_button_ext6(); PROCESS_BEGIN(); diff --git a/examples/osd/light-actor/pcintkey.c b/examples/osd/light-actor/pcintkey.c index 4f147ab8f..b152da6da 100644 --- a/examples/osd/light-actor/pcintkey.c +++ b/examples/osd/light-actor/pcintkey.c @@ -38,22 +38,41 @@ * */ -#include "key.h" +#include +#include "dev/led.h" +#include "pcintkey.h" /*---------------------------------------------------------------------------*/ +ISR(PCINT0_vect) +{ +// if(BUTTON_CHECK_IRQ()) { +// if(timer_expired(&debouncetimer)) { + led1_on(); +// timer_set(&debouncetimer, CLOCK_SECOND / 4); +// sensors_changed(&button_sensor); + led1_off(); +// } +// } +} /** * \brief This will intialize the KEY for button readings. */ void key_init(void) { + // Pairing Button + DDRB |= (0< void key_init(void); -uint8_t is_button_ext1(void); -uint8_t is_button_ext2(void); +uint8_t is_button_ext4(void); +uint8_t is_button_ext5(void); +uint8_t is_button_ext6(void); #endif /* __KEY_H__ */