RemoteIR.

Dependents:   RemoteIR_TestProgram SerialGPS_TestProgram StarBoardOrangeExpansion1 Door_Slamming_Device ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TransmitterIR.h Source File

TransmitterIR.h

00001 /**
00002  * IR transmitter (Version 0.0.4)
00003  *
00004  * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
00005  * http://shinta.main.jp/
00006  */
00007 
00008 #ifndef _TRANSMITTER_IR_H_
00009 #define _TRANSMITTER_IR_H_
00010 
00011 #include <mbed.h>
00012 
00013 #include "RemoteIR.h"
00014 
00015 /**
00016  * IR transmitter class.
00017  */
00018 class TransmitterIR {
00019 public:
00020 
00021     /**
00022      * Constructor.
00023      *
00024      * @param txpin Pin for transmit IR signal.
00025      */
00026     explicit TransmitterIR(PinName txpin);
00027 
00028     /**
00029      * Destructor.
00030      */
00031     ~TransmitterIR();
00032 
00033     typedef enum {
00034         Idle,
00035         Leader,
00036         Data,
00037         Trailer
00038     } State;
00039 
00040     /**
00041      * Get state.
00042      *
00043      * @return Current state.
00044      */
00045     State getState(void);
00046 
00047     /**
00048      * Set data.
00049      *
00050      * @param format Format.
00051      * @param buf Buffer of a data.
00052      * @param bitlength Bit length of the data.
00053      *
00054      * @return Data bit length.
00055      */
00056     int setData(RemoteIR::Format format, uint8_t *buf, int bitlength);
00057 
00058 private:
00059 
00060     typedef struct {
00061         State state;
00062         int bitcount;
00063         int leader;
00064         int data;
00065         int trailer;
00066     } work_t;
00067 
00068     typedef struct {
00069         RemoteIR::Format format;
00070         int bitlength;
00071         uint8_t buffer[64];
00072     } data_t;
00073 
00074     PwmOut tx;
00075     Ticker ticker;
00076     data_t data;
00077     work_t work;
00078 
00079     void tick();
00080 
00081 };
00082 
00083 #endif