add button code

This commit is contained in:
Harald Pichler 2016-12-08 22:22:56 +01:00
parent 52c26d31c4
commit d41197e1e7
2 changed files with 15 additions and 15 deletions

View file

@ -36,7 +36,7 @@
#define PLATFORM_HAS_BUTTON 1 #define PLATFORM_HAS_BUTTON 1
#define PLATFORM_HAS_BATTERY 1 #define PLATFORM_HAS_BATTERY 1
#define LOOP_INTERVAL (CLOCK_SECOND/10) #define LOOP_INTERVAL (CLOCK_SECOND/4)
/* Seeping nodes are host nodes without routing features */ /* Seeping nodes are host nodes without routing features */
#define UIP_CONF_ROUTER 0 #define UIP_CONF_ROUTER 0

View file

@ -38,6 +38,9 @@ extern resource_t
uint8_t led_pin=4; uint8_t led_pin=4;
uint8_t led_status; uint8_t led_status;
uint8_t but2_pin=8;
uint8_t but2_status;
// coap_server_post // coap_server_post
#define REMOTE_PORT UIP_HTONS(COAP_DEFAULT_PORT) #define REMOTE_PORT UIP_HTONS(COAP_DEFAULT_PORT)
// should be the same :-) // should be the same :-)
@ -128,6 +131,8 @@ void setup (void)
pinMode(led_pin, OUTPUT); pinMode(led_pin, OUTPUT);
digitalWrite(led_pin, HIGH); digitalWrite(led_pin, HIGH);
led_status=0; led_status=0;
// init button2
pinMode(but2_pin, INPUT);
// init chainable led // init chainable led
leds.init(); leds.init();
leds.setColorRGB(0,color_rgb [0], color_rgb [1], color_rgb [2]); leds.setColorRGB(0,color_rgb [0], color_rgb [1], color_rgb [2]);
@ -188,22 +193,17 @@ void button (void)
res_separate1.resume(); res_separate1.resume();
/* Call the Coap Server */ /* Call the Coap Server */
coap_server_post(); //coap_server_post();
} }
void loop (void) void loop (void)
{ {
if(digitalRead(but2_pin)==0)
// test chainable led {
/* // printf("0\n");
static byte power=0; digitalWrite(led_pin, LOW);
for (byte i=0; i<NUM_LEDS; i++) }else{
{ // printf("1\n");
if (i%2 == 0) digitalWrite(led_pin, HIGH);
leds.setColorRGB(i, power, 0, 0); }
else
leds.setColorRGB(i, 0, 255-power, 0);
}
power+= 10;
*/
} }