Change Zoul examples to use the button HAL
This commit is contained in:
parent
a5ea8d44e9
commit
0445275825
@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user