From 1892447080db8c03799e564b295d3986a0d1394e Mon Sep 17 00:00:00 2001 From: Roger Clark Date: Sat, 12 Nov 2016 18:34:58 +1100 Subject: [PATCH] Fix issue 196, for Servo library --- .../libraries/Servo/examples/Knob/Knob.ino | 27 ++++++++++++++++ .../libraries/Servo/examples/Sweep/Sweep.ino | 32 +++++++++++++++++++ STM32F1/libraries/Servo/keywords.txt | 24 ++++++++++++++ STM32F1/libraries/Servo/library.properties | 9 ++++++ STM32F1/libraries/Servo/rules.mk | 29 ----------------- STM32F1/libraries/Servo/{ => src}/Servo.cpp | 0 STM32F1/libraries/Servo/{ => src}/Servo.h | 0 7 files changed, 92 insertions(+), 29 deletions(-) create mode 100644 STM32F1/libraries/Servo/examples/Knob/Knob.ino create mode 100644 STM32F1/libraries/Servo/examples/Sweep/Sweep.ino create mode 100644 STM32F1/libraries/Servo/keywords.txt create mode 100644 STM32F1/libraries/Servo/library.properties delete mode 100644 STM32F1/libraries/Servo/rules.mk rename STM32F1/libraries/Servo/{ => src}/Servo.cpp (100%) rename STM32F1/libraries/Servo/{ => src}/Servo.h (100%) diff --git a/STM32F1/libraries/Servo/examples/Knob/Knob.ino b/STM32F1/libraries/Servo/examples/Knob/Knob.ino new file mode 100644 index 0000000..0db8770 --- /dev/null +++ b/STM32F1/libraries/Servo/examples/Knob/Knob.ino @@ -0,0 +1,27 @@ +/* + Controlling a servo position using a potentiometer (variable resistor) + by Michal Rinott + + modified on 8 Nov 2013 + by Scott Fitzgerald + http://www.arduino.cc/en/Tutorial/Knob +*/ + +#include + +Servo myservo; // create servo object to control a servo + +int potpin = 0; // analog pin used to connect the potentiometer +int val; // variable to read the value from the analog pin + +void setup() { + myservo.attach(9); // attaches the servo on pin 9 to the servo object +} + +void loop() { + val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) + val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180) + myservo.write(val); // sets the servo position according to the scaled value + delay(15); // waits for the servo to get there +} + diff --git a/STM32F1/libraries/Servo/examples/Sweep/Sweep.ino b/STM32F1/libraries/Servo/examples/Sweep/Sweep.ino new file mode 100644 index 0000000..df904af --- /dev/null +++ b/STM32F1/libraries/Servo/examples/Sweep/Sweep.ino @@ -0,0 +1,32 @@ +/* Sweep + by BARRAGAN + This example code is in the public domain. + + modified 8 Nov 2013 + by Scott Fitzgerald + http://www.arduino.cc/en/Tutorial/Sweep +*/ + +#include + +Servo myservo; // create servo object to control a servo +// twelve servo objects can be created on most boards + +int pos = 0; // variable to store the servo position + +void setup() { + myservo.attach(9); // attaches the servo on pin 9 to the servo object +} + +void loop() { + for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees + // in steps of 1 degree + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + } + for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + } +} + diff --git a/STM32F1/libraries/Servo/keywords.txt b/STM32F1/libraries/Servo/keywords.txt new file mode 100644 index 0000000..0a7ca1e --- /dev/null +++ b/STM32F1/libraries/Servo/keywords.txt @@ -0,0 +1,24 @@ +####################################### +# Syntax Coloring Map Servo +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +Servo KEYWORD1 Servo + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +attach KEYWORD2 +detach KEYWORD2 +write KEYWORD2 +read KEYWORD2 +attached KEYWORD2 +writeMicroseconds KEYWORD2 +readMicroseconds KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/STM32F1/libraries/Servo/library.properties b/STM32F1/libraries/Servo/library.properties new file mode 100644 index 0000000..68ac78d --- /dev/null +++ b/STM32F1/libraries/Servo/library.properties @@ -0,0 +1,9 @@ +name=Servo(STM32F1) +version=1.1.2 +author=Unknown (possibly LeafLabs) +maintainer=Roger Clark (roger@rogerclark.net) +sentence=Allows STM32 boards to control a variety of servo motors. +paragraph= +category=Device Control +url=http://www.arduino.cc/en/Reference/Servo +architectures=STM32F1 \ No newline at end of file diff --git a/STM32F1/libraries/Servo/rules.mk b/STM32F1/libraries/Servo/rules.mk deleted file mode 100644 index e013754..0000000 --- a/STM32F1/libraries/Servo/rules.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Local flags -CXXFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) - -# Local rules and targets -cSRCS_$(d) := - -cppSRCS_$(d) := Servo.cpp - -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) \ No newline at end of file diff --git a/STM32F1/libraries/Servo/Servo.cpp b/STM32F1/libraries/Servo/src/Servo.cpp similarity index 100% rename from STM32F1/libraries/Servo/Servo.cpp rename to STM32F1/libraries/Servo/src/Servo.cpp diff --git a/STM32F1/libraries/Servo/Servo.h b/STM32F1/libraries/Servo/src/Servo.h similarity index 100% rename from STM32F1/libraries/Servo/Servo.h rename to STM32F1/libraries/Servo/src/Servo.h