http://mbed.org/users/shintamainjp/notebook/starboard_expbrd-one_ex1_en/
Dependencies: mbed RemoteIR SuperTweet ConfigFile EthernetNetIf
mylib/MyHomeLight/MyHomeLight.h@0:db299c5a18ba, 2010-10-29 (annotated)
- Committer:
- shintamainjp
- Date:
- Fri Oct 29 23:17:01 2010 +0000
- Revision:
- 0:db299c5a18ba
- Child:
- 1:c4cfd136f9c7
Initial version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 0:db299c5a18ba | 1 | #include "mbed.h" |
shintamainjp | 0:db299c5a18ba | 2 | #include "TransmitterIR.h" |
shintamainjp | 0:db299c5a18ba | 3 | |
shintamainjp | 0:db299c5a18ba | 4 | class MyHomeLight { |
shintamainjp | 0:db299c5a18ba | 5 | public: |
shintamainjp | 0:db299c5a18ba | 6 | |
shintamainjp | 0:db299c5a18ba | 7 | /** |
shintamainjp | 0:db299c5a18ba | 8 | * Create. |
shintamainjp | 0:db299c5a18ba | 9 | * |
shintamainjp | 0:db299c5a18ba | 10 | * @param tx_pin Pin of IR transmitter. |
shintamainjp | 0:db299c5a18ba | 11 | */ |
shintamainjp | 0:db299c5a18ba | 12 | explicit MyHomeLight(PinName tx_pin); |
shintamainjp | 0:db299c5a18ba | 13 | |
shintamainjp | 0:db299c5a18ba | 14 | /** |
shintamainjp | 0:db299c5a18ba | 15 | * Dispose. |
shintamainjp | 0:db299c5a18ba | 16 | */ |
shintamainjp | 0:db299c5a18ba | 17 | ~MyHomeLight(); |
shintamainjp | 0:db299c5a18ba | 18 | |
shintamainjp | 0:db299c5a18ba | 19 | /** |
shintamainjp | 0:db299c5a18ba | 20 | * Toggle state. |
shintamainjp | 0:db299c5a18ba | 21 | * |
shintamainjp | 0:db299c5a18ba | 22 | * @param channel Target channel number. |
shintamainjp | 0:db299c5a18ba | 23 | * @return true if it succeed. |
shintamainjp | 0:db299c5a18ba | 24 | */ |
shintamainjp | 0:db299c5a18ba | 25 | bool toggle(const int channel); |
shintamainjp | 0:db299c5a18ba | 26 | |
shintamainjp | 0:db299c5a18ba | 27 | private: |
shintamainjp | 0:db299c5a18ba | 28 | TransmitterIR tx; |
shintamainjp | 0:db299c5a18ba | 29 | |
shintamainjp | 0:db299c5a18ba | 30 | typedef struct { |
shintamainjp | 0:db299c5a18ba | 31 | int channel; /**< Channel number. */ |
shintamainjp | 0:db299c5a18ba | 32 | char *signal; /**< Signal data. */ |
shintamainjp | 0:db299c5a18ba | 33 | } light_signal_t; |
shintamainjp | 0:db299c5a18ba | 34 | |
shintamainjp | 0:db299c5a18ba | 35 | /** |
shintamainjp | 0:db299c5a18ba | 36 | * Signal for a light. |
shintamainjp | 0:db299c5a18ba | 37 | */ |
shintamainjp | 0:db299c5a18ba | 38 | static const light_signal_t lights[8]; |
shintamainjp | 0:db299c5a18ba | 39 | |
shintamainjp | 0:db299c5a18ba | 40 | /** |
shintamainjp | 0:db299c5a18ba | 41 | * Get a signal for a light. |
shintamainjp | 0:db299c5a18ba | 42 | * |
shintamainjp | 0:db299c5a18ba | 43 | * @param channel Channel of a light. |
shintamainjp | 0:db299c5a18ba | 44 | * |
shintamainjp | 0:db299c5a18ba | 45 | * @return A pointer to a signal. |
shintamainjp | 0:db299c5a18ba | 46 | */ |
shintamainjp | 0:db299c5a18ba | 47 | uint8_t *getLightSignal(int channel); |
shintamainjp | 0:db299c5a18ba | 48 | }; |