initial upload
This commit is contained in:
parent
1e5163cbb3
commit
855bc65b8a
9 changed files with 407 additions and 0 deletions
46
examples/osd/arduino-distance/sketch.pde
Normal file
46
examples/osd/arduino-distance/sketch.pde
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Sample arduino sketch using contiki features.
|
||||
* We turn the LED off
|
||||
* We allow read the moisture sensor
|
||||
* Unfortunately sleeping for long times in loop() isn't currently
|
||||
* possible, something turns off the CPU (including PWM outputs) if a
|
||||
* Proto-Thread is taking too long. We need to find out how to sleep in
|
||||
* a Contiki-compatible way.
|
||||
* Note that for a normal arduino sketch you won't have to include any
|
||||
* of the contiki-specific files here, the sketch should just work.
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include "sketch.h"
|
||||
#include "rest-engine.h"
|
||||
#include "net/netstack.h"
|
||||
|
||||
extern volatile uint8_t mcusleepcycle; // default 16
|
||||
extern resource_t res_battery, res_distance;
|
||||
#define LED_PIN 4 /* LED Pin */
|
||||
|
||||
}
|
||||
|
||||
void setup (void)
|
||||
{
|
||||
NETSTACK_MAC.off(1);
|
||||
|
||||
// switch off the led
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
// init coap resourcen
|
||||
rest_init_engine ();
|
||||
rest_activate_resource (&res_battery, "s/battery");
|
||||
rest_activate_resource (&res_distance, "s/distance");
|
||||
|
||||
pinMode(TRIG_PIN, OUTPUT);
|
||||
pinMode(ECHO_PIN, INPUT);
|
||||
}
|
||||
|
||||
void loop (void)
|
||||
{
|
||||
mcusleepcycle=0; // dont sleep
|
||||
|
||||
mcusleepcycle=16; // sleep, wakeup every 32 cycles
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue