Big Mouth Billy Bass automation library
billybass.hpp@0:84aaade0de8f, 2013-06-17 (annotated)
- Committer:
- bikeNomad
- Date:
- Mon Jun 17 22:17:59 2013 +0000
- Revision:
- 0:84aaade0de8f
- Child:
- 3:6c91a6232c4a
Mostly working; hangs when reading actions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bikeNomad | 0:84aaade0de8f | 1 | #ifndef __included_billybass_hpp |
bikeNomad | 0:84aaade0de8f | 2 | #define __included_billybass_hpp |
bikeNomad | 0:84aaade0de8f | 3 | |
bikeNomad | 0:84aaade0de8f | 4 | #include "mbed.h" |
bikeNomad | 0:84aaade0de8f | 5 | #include "config.hpp" |
bikeNomad | 0:84aaade0de8f | 6 | #include <list> |
bikeNomad | 0:84aaade0de8f | 7 | #include <vector> |
bikeNomad | 0:84aaade0de8f | 8 | #include <cmath> |
bikeNomad | 0:84aaade0de8f | 9 | |
bikeNomad | 0:84aaade0de8f | 10 | extern AnalogOut speaker; |
bikeNomad | 0:84aaade0de8f | 11 | extern Serial pc; |
bikeNomad | 0:84aaade0de8f | 12 | |
bikeNomad | 0:84aaade0de8f | 13 | class BillyBass |
bikeNomad | 0:84aaade0de8f | 14 | { |
bikeNomad | 0:84aaade0de8f | 15 | public: |
bikeNomad | 0:84aaade0de8f | 16 | |
bikeNomad | 0:84aaade0de8f | 17 | BillyBass(PinName tailPin, PinName mouthPin, PinName bodyPin) : |
bikeNomad | 0:84aaade0de8f | 18 | tail(tailPin), mouth(mouthPin), body(bodyPin) |
bikeNomad | 0:84aaade0de8f | 19 | { |
bikeNomad | 0:84aaade0de8f | 20 | tail.write(0); |
bikeNomad | 0:84aaade0de8f | 21 | mouth.write(0); |
bikeNomad | 0:84aaade0de8f | 22 | body.write(0); |
bikeNomad | 0:84aaade0de8f | 23 | if (numFish < MAX_FISH) fish[numFish++] = this; |
bikeNomad | 0:84aaade0de8f | 24 | // else error |
bikeNomad | 0:84aaade0de8f | 25 | } |
bikeNomad | 0:84aaade0de8f | 26 | |
bikeNomad | 0:84aaade0de8f | 27 | // if *_pName, it will get the string name of the output |
bikeNomad | 0:84aaade0de8f | 28 | DigitalOut *outputNamed(char const *_outputName, char const **_pName = 0); |
bikeNomad | 0:84aaade0de8f | 29 | |
bikeNomad | 0:84aaade0de8f | 30 | static BillyBass *bassNumber(unsigned which) { return (which >= numFish) ? 0 : fish[which]; } |
bikeNomad | 0:84aaade0de8f | 31 | static unsigned getNumFish() { return numFish; } |
bikeNomad | 0:84aaade0de8f | 32 | |
bikeNomad | 0:84aaade0de8f | 33 | protected: |
bikeNomad | 0:84aaade0de8f | 34 | static BillyBass* fish[ MAX_FISH ]; |
bikeNomad | 0:84aaade0de8f | 35 | static unsigned numFish; |
bikeNomad | 0:84aaade0de8f | 36 | static char const * mouthName; |
bikeNomad | 0:84aaade0de8f | 37 | static char const * bodyName; |
bikeNomad | 0:84aaade0de8f | 38 | static char const * tailName; |
bikeNomad | 0:84aaade0de8f | 39 | |
bikeNomad | 0:84aaade0de8f | 40 | DigitalOut tail; |
bikeNomad | 0:84aaade0de8f | 41 | DigitalOut mouth; |
bikeNomad | 0:84aaade0de8f | 42 | DigitalOut body; |
bikeNomad | 0:84aaade0de8f | 43 | }; |
bikeNomad | 0:84aaade0de8f | 44 | |
bikeNomad | 0:84aaade0de8f | 45 | #endif |