From 406d69a27cbcbf1a5babc9235269d65a989f9e14 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Sat, 23 Jan 2016 17:49:51 +0100 Subject: [PATCH] add RGBdriver --- examples/osd/arduino-ledstrip/Makefile | 2 +- examples/osd/arduino-ledstrip/sketch.pde | 35 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/examples/osd/arduino-ledstrip/Makefile b/examples/osd/arduino-ledstrip/Makefile index 7dc5c26a1..c867fa55e 100644 --- a/examples/osd/arduino-ledstrip/Makefile +++ b/examples/osd/arduino-ledstrip/Makefile @@ -15,7 +15,7 @@ CONTIKI_WITH_IPV6 = 1 CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" -PROJECT_SOURCEFILES += ${SKETCH}.cpp +PROJECT_SOURCEFILES += ${SKETCH}.cpp RGBdriver.cpp # automatically build RESTful resources REST_RESOURCES_DIR = ./resources diff --git a/examples/osd/arduino-ledstrip/sketch.pde b/examples/osd/arduino-ledstrip/sketch.pde index 67603c19a..8d51cfb56 100644 --- a/examples/osd/arduino-ledstrip/sketch.pde +++ b/examples/osd/arduino-ledstrip/sketch.pde @@ -10,9 +10,17 @@ * of the contiki-specific files here, the sketch should just work. */ +#include "RGBdriver.h" + +#define CLK 2//pins definitions for the driver +#define DIO 3 +RGBdriver Driver(CLK,DIO); + extern "C" { #include "rest-engine.h" +#include "net/netstack.h" +extern volatile uint8_t mcusleepcycle; // default 16 extern resource_t res_door, res_battery; uint8_t door_pin = 3; uint8_t door_status = 0; @@ -29,9 +37,36 @@ void setup (void) rest_init_engine (); rest_activate_resource (&res_door, "s/door"); rest_activate_resource (&res_battery, "s/battery"); + + NETSTACK_MAC.off(1); } void loop (void) { + static int a=1; + + mcusleepcycle=0; + switch(a) { + case 1: printf("a ist eins\n"); + Driver.begin(); // begin + Driver.SetColor(255, 0, 0); //Red. first node data + Driver.end(); + a++; + break; + case 2: printf("a ist zwei\n"); + Driver.begin(); // begin + Driver.SetColor(0, 255, 0); //Green. first node data + Driver.end(); + a++; + break; + case 3: printf("a ist drei\n"); + Driver.begin(); // begin + Driver.SetColor(0, 0, 255);//Blue. first node data + Driver.end(); + a=1; + break; + default: printf("a ist irgendwas\n"); break; + } + mcusleepcycle=16; }