Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: garbear/mecanum
base: 066455e498
...
head fork: garbear/mecanum
compare: c4e415e3ac
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 27, 2012
@garbear [arm] Install ntp daemon by default
No more stupid 1969 commits on github
427787e
@garbear [avr] Add new "Fade" state machine c4e415e
View
6 arm/settings.xml
@@ -4,10 +4,13 @@
<password>password</password>
<fqdn>mecanum</fqdn>
<mmc>/dev/mmcblk0</mmc>
+
<packages for="mecanum/avr">arduino-core</packages>
- <!-- todo: does network-manager pull in dbus? -->
<packages for="mecanum/wifi">network-manager python-dbus</packages>
+
+ <packages for="ntp">ntp</packages>
<!--<packages for="samba">samba</packages>-->
+
<packages for="ROS bootstrap">build-essential python-yaml cmake subversion wget python-setuptools mercurial git-core</packages>
<packages for="ROS base">python-yaml libapr1-dev libaprutil1-dev libbz2-dev python-dev libgtest-dev python-paramiko liblog4cxx10-dev pkg-config python-empy python-nose</packages>
<!-- ROS base specifies libboost1.40-all-dev -->
@@ -18,5 +21,6 @@
<packages for="mobile variant">freeglut3-dev python-wxgtk2.8 libcurl4-openssl-dev unzip libxext-dev python-imaging libtinyxml-dev python-numpy libfltk1.1-dev libeigen3-dev libnetpbm10-dev python-sip-dev libcppunit-dev libxml2-dev libsdl-image1.2-dev libassimp-dev</packages>
<!--<packages for="mobile variant (error configuring)">graphviz</packages>-->
<!--<packages for="mobile variant (missing)">ros-fuerte-pcl yaml-cpp</packages>-->
+
<macaddress>00:80:54:15:58:01</macaddress>
</settings>
View
1  avr/CMakeLists.txt
@@ -38,6 +38,7 @@ generate_arduino_firmware(avr_base
SRCS src/base.cpp
src/BatteryMonitor.cpp
src/Blink.cpp
+ src/Fade.cpp
src/FSMVector.cpp
# HDRS src/FiniteStateMachine.h # For project-based systems
# LIBS lib/main_lib
View
36 avr/src/Fade.cpp
@@ -0,0 +1,36 @@
+#include "Fade.h"
+
+#include <Arduino.h>
+
+Fade::Fade(uint8_t pin, unsigned long period, unsigned long updateFrequency) :
+ m_pin(pin), m_dir(true), m_brightness(0), m_delay(1000 / updateFrequency)
+{
+ m_brightnessStep = 255 * (period / 2) * 1000 / m_delay;
+ pinMode(pin, OUTPUT);
+ analogWrite(m_pin, 0);
+}
+
+void Fade::Step()
+{
+ // Use half the period to calculate brightness increments
+ if (m_dir)
+ {
+ m_brightness += m_brightnessStep;
+ if (m_brightness > 255)
+ {
+ m_brightness = 255;
+ m_dir = false; // down
+ }
+ }
+ else
+ {
+ m_brightness -= m_brightnessStep;
+ if (m_brightness < 0)
+ {
+ m_brightness = 0;
+ m_dir = true; // up
+ }
+ }
+
+ analogWrite(m_pin, m_brightness);
+}
View
33 avr/src/Fade.h
@@ -0,0 +1,33 @@
+#ifndef FADE_H
+#define FADE_H
+
+#include "FiniteStateMachine.h"
+
+#include <stdint.h> // for uint8_t
+
+/**
+ * Fade a light on a PWM pin.
+ */
+class Fade : public FiniteStateMachine
+{
+public:
+ /**
+ *
+ * @param pin The PWM pin, supposedly connected to an LED
+ * @param delay The delay -- the blinking period is twice the delay
+ */
+ Fade(uint8_t pin, unsigned long period /* ms */, unsigned long updateFrequency /* s^-1 */);
+
+ virtual void Step();
+
+ virtual unsigned long Delay() const { return m_delay; }
+
+private:
+ uint8_t m_pin;
+ bool m_dir; // true = brighter
+ uint8_t m_brightness; // 0 to 255
+ uint8_t m_brightnessStep;
+ unsigned long m_delay; // ms
+};
+
+#endif // FADE_H
View
4 avr/src/base.cpp
@@ -1,5 +1,6 @@
#include "FSMVector.h"
#include "Blink.h"
+#include "Fade.h"
#include "BatteryMonitor.h"
#include "hardware_interface.h"
@@ -9,7 +10,7 @@
static FSMVector fsmv;
static struct pt ptv[FSMVector::MAX_FSM];
// Previously this was an int[]. The Arduino would crash after 32 seconds.
-// 32,767 ms is half of 65,355. 65,355 is the upper limit of a 2-byte int.
+// 32,767 ms is half of 65,355; 65,355 is the upper limit of a 2-byte int...
// Coincidence??
unsigned long fsm_delay[FSMVector::MAX_FSM];
@@ -48,6 +49,7 @@ void setup()
// Test FSMs
fsmv.PushBack(new BatteryMonitor());
+ fsmv.PushBack(new Fade(LED_EMERGENCY, 2, 20));
}
void loop()

No commit comments for this range

Something went wrong with that request. Please try again.