http://mbed.org/users/shintamainjp/notebook/starboard_expbrd-one_ex1_en/

Dependencies:   mbed RemoteIR SuperTweet ConfigFile EthernetNetIf

Committer:
shintamainjp
Date:
Thu Nov 04 14:33:07 2010 +0000
Revision:
1:c4cfd136f9c7
Parent:
0:db299c5a18ba
Added license terms.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shintamainjp 1:c4cfd136f9c7 1 /**
shintamainjp 1:c4cfd136f9c7 2 * =============================================================================
shintamainjp 1:c4cfd136f9c7 3 * My home light controller.
shintamainjp 1:c4cfd136f9c7 4 * http://mbed.org/users/shintamainjp/notebook/starboard_expbrd-one_ex1_en/
shintamainjp 1:c4cfd136f9c7 5 * =============================================================================
shintamainjp 1:c4cfd136f9c7 6 * Copyright (c) 2010 Shinichiro Nakamura (CuBeatSystems)
shintamainjp 1:c4cfd136f9c7 7 *
shintamainjp 1:c4cfd136f9c7 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
shintamainjp 1:c4cfd136f9c7 9 * of this software and associated documentation files (the "Software"), to deal
shintamainjp 1:c4cfd136f9c7 10 * in the Software without restriction, including without limitation the rights
shintamainjp 1:c4cfd136f9c7 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
shintamainjp 1:c4cfd136f9c7 12 * copies of the Software, and to permit persons to whom the Software is
shintamainjp 1:c4cfd136f9c7 13 * furnished to do so, subject to the following conditions:
shintamainjp 1:c4cfd136f9c7 14 *
shintamainjp 1:c4cfd136f9c7 15 * The above copyright notice and this permission notice shall be included in
shintamainjp 1:c4cfd136f9c7 16 * all copies or substantial portions of the Software.
shintamainjp 1:c4cfd136f9c7 17 *
shintamainjp 1:c4cfd136f9c7 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
shintamainjp 1:c4cfd136f9c7 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
shintamainjp 1:c4cfd136f9c7 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
shintamainjp 1:c4cfd136f9c7 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
shintamainjp 1:c4cfd136f9c7 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
shintamainjp 1:c4cfd136f9c7 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
shintamainjp 1:c4cfd136f9c7 24 * THE SOFTWARE.
shintamainjp 1:c4cfd136f9c7 25 * =============================================================================
shintamainjp 1:c4cfd136f9c7 26 */
shintamainjp 1:c4cfd136f9c7 27
shintamainjp 0:db299c5a18ba 28 #include "mbed.h"
shintamainjp 0:db299c5a18ba 29 #include "TransmitterIR.h"
shintamainjp 0:db299c5a18ba 30
shintamainjp 0:db299c5a18ba 31 class MyHomeLight {
shintamainjp 0:db299c5a18ba 32 public:
shintamainjp 0:db299c5a18ba 33
shintamainjp 0:db299c5a18ba 34 /**
shintamainjp 0:db299c5a18ba 35 * Create.
shintamainjp 0:db299c5a18ba 36 *
shintamainjp 0:db299c5a18ba 37 * @param tx_pin Pin of IR transmitter.
shintamainjp 0:db299c5a18ba 38 */
shintamainjp 0:db299c5a18ba 39 explicit MyHomeLight(PinName tx_pin);
shintamainjp 0:db299c5a18ba 40
shintamainjp 0:db299c5a18ba 41 /**
shintamainjp 0:db299c5a18ba 42 * Dispose.
shintamainjp 0:db299c5a18ba 43 */
shintamainjp 0:db299c5a18ba 44 ~MyHomeLight();
shintamainjp 0:db299c5a18ba 45
shintamainjp 0:db299c5a18ba 46 /**
shintamainjp 0:db299c5a18ba 47 * Toggle state.
shintamainjp 0:db299c5a18ba 48 *
shintamainjp 0:db299c5a18ba 49 * @param channel Target channel number.
shintamainjp 0:db299c5a18ba 50 * @return true if it succeed.
shintamainjp 0:db299c5a18ba 51 */
shintamainjp 0:db299c5a18ba 52 bool toggle(const int channel);
shintamainjp 0:db299c5a18ba 53
shintamainjp 0:db299c5a18ba 54 private:
shintamainjp 0:db299c5a18ba 55 TransmitterIR tx;
shintamainjp 0:db299c5a18ba 56
shintamainjp 0:db299c5a18ba 57 typedef struct {
shintamainjp 0:db299c5a18ba 58 int channel; /**< Channel number. */
shintamainjp 0:db299c5a18ba 59 char *signal; /**< Signal data. */
shintamainjp 0:db299c5a18ba 60 } light_signal_t;
shintamainjp 0:db299c5a18ba 61
shintamainjp 0:db299c5a18ba 62 /**
shintamainjp 0:db299c5a18ba 63 * Signal for a light.
shintamainjp 0:db299c5a18ba 64 */
shintamainjp 0:db299c5a18ba 65 static const light_signal_t lights[8];
shintamainjp 0:db299c5a18ba 66
shintamainjp 0:db299c5a18ba 67 /**
shintamainjp 0:db299c5a18ba 68 * Get a signal for a light.
shintamainjp 0:db299c5a18ba 69 *
shintamainjp 0:db299c5a18ba 70 * @param channel Channel of a light.
shintamainjp 0:db299c5a18ba 71 *
shintamainjp 0:db299c5a18ba 72 * @return A pointer to a signal.
shintamainjp 0:db299c5a18ba 73 */
shintamainjp 0:db299c5a18ba 74 uint8_t *getLightSignal(int channel);
shintamainjp 0:db299c5a18ba 75 };