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@2:08836610bd4a, 2010-08-17 (annotated)
- Committer:
- shintamainjp
- Date:
- Tue Aug 17 10:37:41 2010 +0000
- Revision:
- 2:08836610bd4a
- Parent:
- 0:ec264f4ce158
- Child:
- 8:46e34d6ddbe4
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| shintamainjp | 0:ec264f4ce158 | 1 | /** |
| shintamainjp | 0:ec264f4ce158 | 2 | * IR transmitter (Version 0.0.3) |
| shintamainjp | 0:ec264f4ce158 | 3 | * |
| shintamainjp | 0:ec264f4ce158 | 4 | * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) |
| shintamainjp | 0:ec264f4ce158 | 5 | * http://shinta.main.jp/ |
| shintamainjp | 0:ec264f4ce158 | 6 | */ |
| shintamainjp | 0:ec264f4ce158 | 7 | |
| shintamainjp | 0:ec264f4ce158 | 8 | #ifndef _TRANSMITTER_IR_H_ |
| shintamainjp | 0:ec264f4ce158 | 9 | #define _TRANSMITTER_IR_H_ |
| shintamainjp | 0:ec264f4ce158 | 10 | |
| shintamainjp | 0:ec264f4ce158 | 11 | #include <mbed.h> |
| shintamainjp | 0:ec264f4ce158 | 12 | |
| shintamainjp | 0:ec264f4ce158 | 13 | #include "Semaphore.h" |
| shintamainjp | 0:ec264f4ce158 | 14 | #include "RemoteIR.h" |
| shintamainjp | 0:ec264f4ce158 | 15 | |
| shintamainjp | 0:ec264f4ce158 | 16 | class TransmitterIR { |
| shintamainjp | 0:ec264f4ce158 | 17 | public: |
| shintamainjp | 0:ec264f4ce158 | 18 | explicit TransmitterIR(PinName txpin); |
| shintamainjp | 0:ec264f4ce158 | 19 | ~TransmitterIR(); |
| shintamainjp | 0:ec264f4ce158 | 20 | |
| shintamainjp | 0:ec264f4ce158 | 21 | typedef enum { |
| shintamainjp | 0:ec264f4ce158 | 22 | Idle, |
| shintamainjp | 0:ec264f4ce158 | 23 | Leader, |
| shintamainjp | 0:ec264f4ce158 | 24 | Data, |
| shintamainjp | 0:ec264f4ce158 | 25 | Trailer |
| shintamainjp | 0:ec264f4ce158 | 26 | } State; |
| shintamainjp | 0:ec264f4ce158 | 27 | |
| shintamainjp | 0:ec264f4ce158 | 28 | State getState(void); |
| shintamainjp | 0:ec264f4ce158 | 29 | int setData(RemoteIR::Format format, uint8_t *buf, int bitlength); |
| shintamainjp | 0:ec264f4ce158 | 30 | |
| shintamainjp | 0:ec264f4ce158 | 31 | private: |
| shintamainjp | 0:ec264f4ce158 | 32 | |
| shintamainjp | 0:ec264f4ce158 | 33 | typedef struct { |
| shintamainjp | 0:ec264f4ce158 | 34 | State state; |
| shintamainjp | 0:ec264f4ce158 | 35 | int bitcount; |
| shintamainjp | 0:ec264f4ce158 | 36 | int leader; |
| shintamainjp | 0:ec264f4ce158 | 37 | int data; |
| shintamainjp | 0:ec264f4ce158 | 38 | int trailer; |
| shintamainjp | 0:ec264f4ce158 | 39 | } work_t; |
| shintamainjp | 0:ec264f4ce158 | 40 | |
| shintamainjp | 0:ec264f4ce158 | 41 | typedef struct { |
| shintamainjp | 0:ec264f4ce158 | 42 | RemoteIR::Format format; |
| shintamainjp | 0:ec264f4ce158 | 43 | int bitlength; |
| shintamainjp | 0:ec264f4ce158 | 44 | uint8_t buffer[64]; |
| shintamainjp | 0:ec264f4ce158 | 45 | } data_t; |
| shintamainjp | 0:ec264f4ce158 | 46 | |
| shintamainjp | 0:ec264f4ce158 | 47 | PwmOut tx; |
| shintamainjp | 0:ec264f4ce158 | 48 | Ticker ticker; |
| shintamainjp | 0:ec264f4ce158 | 49 | data_t data; |
| shintamainjp | 0:ec264f4ce158 | 50 | work_t work; |
| shintamainjp | 0:ec264f4ce158 | 51 | Semaphore sem; |
| shintamainjp | 0:ec264f4ce158 | 52 | |
| shintamainjp | 0:ec264f4ce158 | 53 | static const int TUS_NEC = 562; |
| shintamainjp | 0:ec264f4ce158 | 54 | static const int TUS_AEHA = 425; |
| shintamainjp | 0:ec264f4ce158 | 55 | static const int TUS_SONY = 600; |
| shintamainjp | 0:ec264f4ce158 | 56 | |
| shintamainjp | 0:ec264f4ce158 | 57 | void tick(); |
| shintamainjp | 0:ec264f4ce158 | 58 | |
| shintamainjp | 0:ec264f4ce158 | 59 | }; |
| shintamainjp | 0:ec264f4ce158 | 60 | |
| shintamainjp | 0:ec264f4ce158 | 61 | #endif |
