Skip to content
Snippets Groups Projects
Commit 04452758 authored by George Oikonomou's avatar George Oikonomou
Browse files

Change Zoul examples to use the button HAL

parent a5ea8d44
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@
#include "ipv6/ip64-addr.h"
#include "dev/leds.h"
#include "net/routing/routing.h"
#include "dev/button-sensor.h"
#include "dev/button-hal.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
static struct http_socket s;
......@@ -138,13 +138,10 @@ PROCESS_THREAD(http_example_process, ev, data)
while(1) {
PROCESS_YIELD();
if((ev == sensors_event) && (data == &button_sensor)) {
if(button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) ==
BUTTON_SENSOR_PRESSED_LEVEL) {
leds_on(LEDS_GREEN);
printf("Button pressed! sending a POST to IFTTT\n");
http_socket_post(&s, url_buffer, NULL, 0, NULL, callback, NULL);
}
if(ev == button_hal_release_event) {
leds_on(LEDS_GREEN);
printf("Button pressed! sending a POST to IFTTT\n");
http_socket_post(&s, url_buffer, NULL, 0, NULL, callback, NULL);
}
}
......
......@@ -47,7 +47,7 @@
#include <stdio.h>
#include "contiki.h"
#include "dev/rgb-bl-lcd.h"
#include "dev/button-sensor.h"
#include "dev/button-hal.h"
/*---------------------------------------------------------------------------*/
#define SCROLL_PERIOD (CLOCK_SECOND / 6)
/*---------------------------------------------------------------------------*/
......@@ -104,18 +104,13 @@ PROCESS_THREAD(remote_lcd_process, ev, data)
printf("Counter: %05u\n", counter);
counter++;
etimer_restart(&et);
} else if(ev == sensors_event) {
if(data == &button_sensor) {
if(button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) ==
BUTTON_SENSOR_PRESSED_LEVEL) {
printf("Button pressed!!\n");
lcd_set_cursor(0, LCD_RGB_1ST_ROW);
lcd_write("Button pressed!!");
} else {
lcd_set_cursor(0, LCD_RGB_1ST_ROW);
lcd_write("Press the button!");
}
}
} else if(ev == button_hal_press_event) {
printf("Button pressed!!\n");
lcd_set_cursor(0, LCD_RGB_1ST_ROW);
lcd_write("Button pressed!!");
} else if(ev == button_hal_release_event) {
lcd_set_cursor(0, LCD_RGB_1ST_ROW);
lcd_write("Press the button!");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment