StateChart for behavior of FlippityFlappity in presentation. Behavior here is predictable and deterministic.

Dependencies:   MMA8451Q Multi_WS2811_Demo TSI mbed

Committer:
ryanfeng
Date:
Mon Apr 06 20:29:33 2015 +0000
Revision:
0:8f759cbfc3c9
Demo Code for presentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryanfeng 0:8f759cbfc3c9 1 #ifndef STATECHART_H
ryanfeng 0:8f759cbfc3c9 2 #define STATECHART_H
ryanfeng 0:8f759cbfc3c9 3
ryanfeng 0:8f759cbfc3c9 4 #define MINBRITE (0.2)
ryanfeng 0:8f759cbfc3c9 5 #define MAXBRITE (0.5)
ryanfeng 0:8f759cbfc3c9 6 #define PI (3.141592653589793)
ryanfeng 0:8f759cbfc3c9 7
ryanfeng 0:8f759cbfc3c9 8 class Statechart{
ryanfeng 0:8f759cbfc3c9 9 public:
ryanfeng 0:8f759cbfc3c9 10 enum actState_t {
ryanfeng 0:8f759cbfc3c9 11 REST,
ryanfeng 0:8f759cbfc3c9 12 LOOK_LEFT,
ryanfeng 0:8f759cbfc3c9 13 LOOK_RIGHT,
ryanfeng 0:8f759cbfc3c9 14 FLOP,
ryanfeng 0:8f759cbfc3c9 15 WALK,
ryanfeng 0:8f759cbfc3c9 16 FLAP,
ryanfeng 0:8f759cbfc3c9 17 BATTERY_LOW
ryanfeng 0:8f759cbfc3c9 18 };
ryanfeng 0:8f759cbfc3c9 19
ryanfeng 0:8f759cbfc3c9 20 enum emoState_t {
ryanfeng 0:8f759cbfc3c9 21 CURIOUS,
ryanfeng 0:8f759cbfc3c9 22 MAD,
ryanfeng 0:8f759cbfc3c9 23 HAPPY,
ryanfeng 0:8f759cbfc3c9 24 SAD
ryanfeng 0:8f759cbfc3c9 25 };
ryanfeng 0:8f759cbfc3c9 26
ryanfeng 0:8f759cbfc3c9 27 void fishStatechart(int netTime, int capNum, int prox, float* xyz, Serial &maestro, WS2811 &lightStrip1, WS2811 &lightStrip2, float battery);
ryanfeng 0:8f759cbfc3c9 28
ryanfeng 0:8f759cbfc3c9 29 private:
ryanfeng 0:8f759cbfc3c9 30 void showRainbow(WS2811 &strip, float sat, float brite, float hueShift);
ryanfeng 0:8f759cbfc3c9 31 void showSolidColor(WS2811 &strip, uint8_t r, uint8_t g, uint8_t b);
ryanfeng 0:8f759cbfc3c9 32 void showSolidColorBright(WS2811 &strip, uint8_t r, uint8_t g, uint8_t b, float newBrite);
ryanfeng 0:8f759cbfc3c9 33 void showSomeRainbow(WS2811 &strip, float hueLow, float hueHigh, float sat, float brite);
ryanfeng 0:8f759cbfc3c9 34 void setMaestroSubroutine(Serial &maestro, int subNum, int parameter, bool withParameter);
ryanfeng 0:8f759cbfc3c9 35 void setServoValue(Serial &maestro, int index, uint16_t x0, uint16_t x1, uint16_t x2);
ryanfeng 0:8f759cbfc3c9 36 };
ryanfeng 0:8f759cbfc3c9 37
ryanfeng 0:8f759cbfc3c9 38 #endif