diff --git a/cpu/avr/dev/arduino/Arduino.h b/cpu/avr/dev/arduino/Arduino.h index e68ab99bc..19471c7a1 100644 --- a/cpu/avr/dev/arduino/Arduino.h +++ b/cpu/avr/dev/arduino/Arduino.h @@ -70,6 +70,7 @@ extern "C"{ #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) +#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) #define microsecondsToClockCycles(a) ( (a) * (F_CPU / 1000000L) ) typedef unsigned int word; diff --git a/examples/osd/arduino-servo/Servo.cpp b/examples/osd/arduino-servo/Servo.cpp index 539d1b360..96fdffc39 100644 --- a/examples/osd/arduino-servo/Servo.cpp +++ b/examples/osd/arduino-servo/Servo.cpp @@ -17,15 +17,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#if defined(ARDUINO_ARCH_AVR) - #include -extern "C" { - #include "Arduino.h" -} - +#include "Arduino.h" #include "Servo.h" +#if defined(ARDUINO_ARCH_AVR) + #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds diff --git a/examples/osd/arduino-servo/Servo.h b/examples/osd/arduino-servo/Servo.h index 147651e88..42d7822d4 100644 --- a/examples/osd/arduino-servo/Servo.h +++ b/examples/osd/arduino-servo/Servo.h @@ -50,6 +50,7 @@ #include #define ARDUINO_ARCH_AVR + /* * Defines for 16 bit timers used with Servo library * diff --git a/examples/osd/arduino-servo/project-conf.h b/examples/osd/arduino-servo/project-conf.h index e9e09f562..0289b9829 100644 --- a/examples/osd/arduino-servo/project-conf.h +++ b/examples/osd/arduino-servo/project-conf.h @@ -37,7 +37,7 @@ #define PLATFORM_HAS_BATTERY 1 -#define LOOP_INTERVAL (30 * CLOCK_SECOND) +#define LOOP_INTERVAL (CLOCK_SECOND/10) /* Save energy */ //#define RDC_CONF_PT_YIELD_OFF diff --git a/examples/osd/arduino-servo/sketch.pde b/examples/osd/arduino-servo/sketch.pde index b70714fbd..8d2125b74 100644 --- a/examples/osd/arduino-servo/sketch.pde +++ b/examples/osd/arduino-servo/sketch.pde @@ -9,27 +9,23 @@ * 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. */ +#include "Servo.h" extern "C" { - #include "arduino-process.h" #include "rest-engine.h" #include "net/netstack.h" -#include "Servo.h" extern resource_t res_led, res_battery, res_cputemp; +} uint8_t led_pin=4; uint8_t led_status; - int potpin = A5; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin -Servo servo(); // create servo object to control a servo - -} - +Servo servo; // create servo object to control a servo void setup (void) { @@ -48,7 +44,7 @@ void setup (void) #pragma GCC diagnostic pop // NETSTACK_MAC.off(1); - mcu_sleep_set(128); + // mcu_sleep_set(128); } void loop (void)