Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RemoteIR by
TransmitterIR.h
- Committer:
- shintamainjp
- Date:
- 2010-08-21
- Revision:
- 8:46e34d6ddbe4
- Parent:
- 2:08836610bd4a
- Child:
- 9:dcfdac59ef74
File content as of revision 8:46e34d6ddbe4:
/**
* IR transmitter (Version 0.0.3)
*
* Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
* http://shinta.main.jp/
*/
#ifndef _TRANSMITTER_IR_H_
#define _TRANSMITTER_IR_H_
#include <mbed.h>
#include "Semaphore.h"
#include "RemoteIR.h"
/**
* IR transmitter class.
*/
class TransmitterIR {
public:
/**
* Constructor.
*
* @param txpin Pin for transmit IR signal.
*/
explicit TransmitterIR(PinName txpin);
/**
* Destructor.
*/
~TransmitterIR();
typedef enum {
Idle,
Leader,
Data,
Trailer
} State;
/**
* Get state.
*
* @return Current state.
*/
State getState(void);
/**
* Set data.
*
* @param format Format.
* @param buf Buffer of a data.
* @param bitlength Bit length of the data.
*
* @return Data bit length.
*/
int setData(RemoteIR::Format format, uint8_t *buf, int bitlength);
private:
typedef struct {
State state;
int bitcount;
int leader;
int data;
int trailer;
} work_t;
typedef struct {
RemoteIR::Format format;
int bitlength;
uint8_t buffer[64];
} data_t;
PwmOut tx;
Ticker ticker;
data_t data;
work_t work;
Semaphore sem;
static const int TUS_NEC = 562;
static const int TUS_AEHA = 425;
static const int TUS_SONY = 600;
void tick();
};
#endif
