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.
Revision 3:469de11d1e1d, committed 2010-09-17
- Comitter:
- shintamainjp
- Date:
- Fri Sep 17 22:05:34 2010 +0000
- Parent:
- 2:d4625043c895
- Commit message:
Changed in this revision
--- a/RemoteIR/ReceiverIR.cpp Sun Aug 15 10:41:12 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,243 +0,0 @@
-/**
- * IR receiver (Version 0.0.2)
- *
- * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
- * http://shinta.main.jp/
- */
-
-#include "ReceiverIR.h"
-
-#define InRange(x,y) ((((y) * 0.7) < (x)) && ((x) < ((y) * 1.3)))
-#define IRQ_ENABLE() sem.release(); __enable_irq()
-#define IRQ_DISABLE() __disable_irq(); sem.take()
-
-ReceiverIR::ReceiverIR(PinName rx) : evt(rx) {
- IRQ_DISABLE();
- evt.fall(this, &ReceiverIR::isr_fall);
- evt.rise(this, &ReceiverIR::isr_rise);
- ticker.attach_us(this, &ReceiverIR::isr_wdt, 1 * 1000);
- init_state();
- IRQ_ENABLE();
-}
-
-ReceiverIR::~ReceiverIR() {}
-
-ReceiverIR::State ReceiverIR::getState() {
- IRQ_DISABLE();
- State s = data.state;
- IRQ_ENABLE();
- return s;
-}
-
-int ReceiverIR::getData(ReceiverIR::Format *format, uint8_t *buf, int bufsiz) {
- IRQ_DISABLE();
-
- const int bc = data.bitcount;
- if (bufsiz < (bc / 8)) {
- IRQ_ENABLE();
- return -1;
- }
-
- *format = data.format;
- for (int i = 0; i < (bc / 8); i++) {
- buf[i] = data.buffer[i];
- }
-
- init_state();
-
- IRQ_ENABLE();
- return bc;
-}
-
-void ReceiverIR::init_state(void) {
- work.c1 = -1;
- work.c2 = -1;
- work.c3 = -1;
- work.d1 = -1;
- work.d2 = -1;
- data.state = Idle;
- data.format = UNKNOWN;
- data.bitcount = 0;
- timer.stop();
- timer.reset();
- for (int i = 0; i < sizeof(data.buffer); i++) {
- data.buffer[i] = 0;
- }
-}
-
-void ReceiverIR::isr_wdt(void) {
- IRQ_DISABLE();
- static int cnt = 0;
- if ((Receiving == data.state) || ((0 <= work.c1) || (0 <= work.c2) || (0 <= work.c3))) {
- cnt++;
- if (cnt > 500) {
- printf("# WDT [c1=%d, c2=%d, c3=%d, d1=%d, d2=%d, state=%d, format=%d, bitcount=%d]\n",
- work.c1,
- work.c2,
- work.c3,
- work.d1,
- work.d2,
- data.state,
- data.format,
- data.bitcount);
- init_state();
- cnt = 0;
- }
- } else {
- cnt = 0;
- }
- IRQ_ENABLE();
-}
-
-void ReceiverIR::isr_fall(void) {
- IRQ_DISABLE();
- switch (data.state) {
- case Idle:
- if (work.c1 < 0) {
- timer.start();
- work.c1 = timer.read_us();
- } else {
- work.c3 = timer.read_us();
- int a = work.c2 - work.c1;
- int b = work.c3 - work.c2;
- if (InRange(a, TUS_NEC * 16) && InRange(b, TUS_NEC * 8)) {
- /*
- * NEC.
- */
- data.format = NEC;
- data.state = Receiving;
- data.bitcount = 0;
- } else if (InRange(a, TUS_NEC * 16) && InRange(b, TUS_NEC * 4)) {
- /*
- * NEC Repeat.
- */
- data.format = NEC;
- data.state = Received;
- data.bitcount = 0;
- } else if (InRange(a, TUS_AEHA * 8) && InRange(b, TUS_AEHA * 4)) {
- /*
- * AEHA.
- */
- data.format = AEHA;
- data.state = Receiving;
- data.bitcount = 0;
- } else if (InRange(a, TUS_AEHA * 8) && InRange(b, TUS_AEHA * 8)) {
- /*
- * AEHA Repeat.
- */
- data.format = AEHA;
- data.state = Received;
- data.bitcount = 0;
- } else {
- init_state();
- }
- }
- break;
- case Receiving:
- if (NEC == data.format) {
- work.d2 = timer.read_us();
- int a = work.d2 - work.d1;
- if (InRange(a, TUS_NEC * 3)) {
- data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8));
- } else if (InRange(a, TUS_NEC * 1)) {
- data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
- }
- data.bitcount++;
- if (32 <= data.bitcount) {
- data.state = Received;
- work.c1 = -1;
- work.c2 = -1;
- work.c3 = -1;
- work.d1 = -1;
- work.d2 = -1;
- }
- } else if (AEHA == data.format) {
- work.d2 = timer.read_us();
- int a = work.d2 - work.d1;
- if (InRange(a, TUS_AEHA * 3)) {
- data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8));
- } else if (InRange(a, TUS_AEHA * 1)) {
- data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
- }
- data.bitcount++;
- /*
- * Typical length of AEHA is 48 bits.
- * Please check a specification of your remote controller if you find a problem.
- */
- if (48 <= data.bitcount) {
- data.state = Received;
- work.c1 = -1;
- work.c2 = -1;
- work.c3 = -1;
- work.d1 = -1;
- work.d2 = -1;
- }
- } else if (SONY == data.format) {
- work.d1 = timer.read_us();
- }
- break;
- case Received:
- break;
- default:
- break;
- }
- IRQ_ENABLE();
-}
-
-void ReceiverIR::isr_rise(void) {
- IRQ_DISABLE();
- switch (data.state) {
- case Idle:
- if (0 <= work.c1) {
- work.c2 = timer.read_us();
- int a = work.c2 - work.c1;
- if (InRange(a, TUS_SONY * 4)) {
- data.format = SONY;
- data.state = Receiving;
- data.bitcount = 0;
- } else {
- static const int MINIMUM_LEADER_WIDTH = 150;
- if (a < MINIMUM_LEADER_WIDTH) {
- init_state();
- }
- }
- } else {
- init_state();
- }
- break;
- case Receiving:
- if (NEC == data.format) {
- work.d1 = timer.read_us();
- } else if (AEHA == data.format) {
- work.d1 = timer.read_us();
- } else if (SONY == data.format) {
- work.d2 = timer.read_us();
- int a = work.d2 - work.d1;
- if (InRange(a, TUS_SONY * 2)) {
- data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8));
- } else if (InRange(a, TUS_SONY * 1)) {
- data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
- }
- data.bitcount++;
- /*
- * How do we get the correct length? (12bits, 15bits, 20bits...)
- * By a model only?
- * Please check a specification of your remote controller if you find a problem.
- */
- if (12 <= data.bitcount) {
- data.state = Received;
- work.c1 = -1;
- work.c2 = -1;
- work.c3 = -1;
- work.d1 = -1;
- work.d2 = -1;
- }
- }
- break;
- case Received:
- break;
- default:
- break;
- }
- IRQ_ENABLE();
-}
--- a/RemoteIR/ReceiverIR.h Sun Aug 15 10:41:12 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/**
- * IR receiver (Version 0.0.2)
- *
- * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
- * http://shinta.main.jp/
- */
-
-#ifndef _RECEIVER_IR_H_
-#define _RECEIVER_IR_H_
-
-#include <mbed.h>
-
-#include "Semaphore.h"
-
-class ReceiverIR {
-public:
- ReceiverIR(PinName rx);
- ~ReceiverIR();
-
- typedef enum {
- Idle,
- Receiving,
- Received
- } State;
-
- typedef enum {
- UNKNOWN,
- NEC,
- AEHA,
- SONY
- } Format;
-
- State getState();
- int getData(Format *format, uint8_t *buf, int bufsiz);
-private:
- typedef struct {
- State state;
- Format format;
- int bitcount;
- uint8_t buffer[64];
- } data_t;
- typedef struct {
- int c1;
- int c2;
- int c3;
- int d1;
- int d2;
- } work_t;
-
- static const int TUS_NEC = 562;
- static const int TUS_AEHA = 425;
- static const int TUS_SONY = 600;
-
- InterruptIn evt;
- Timer timer;
- Ticker ticker;
- Semaphore sem;
-
- data_t data;
- work_t work;
-
- void init_state(void);
-
- void isr_wdt(void);
- void isr_fall(void);
- void isr_rise(void);
-
-};
-
-#endif
--- a/extlib/Semaphore.h Sun Aug 15 10:41:12 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#ifndef _SEMAPHORE_H_
-#define _SEMAPHORE_H_
-
-/*
- * http://mbed.org/forum/mbed/topic/181/#comment-799
- */
-
-class Semaphore {
-public:
- Semaphore(): s(SemFree) {};
-
- bool take(bool block = true) {
- int oldval;
- do {
- oldval = __ldrex(&s);
- } while ((block && (oldval == SemTaken)) || (__strex(SemTaken, &s) != 0));
- if (!block) {
- __clrex();
- }
- return (oldval == SemFree);
- }
-
- void release() {
- s = SemFree;
- }
-
-private:
- enum { SemFree, SemTaken };
- int s;
-};
-
-#endif
\ No newline at end of file
--- a/extlib/TextLCD.cpp Sun Aug 15 10:41:12 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/* mbed TextLCD Library, for a 4-bit LCD based on HD44780
- * Copyright (c) 2007-2010, sford
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/*
- * Modified for star board orange by Shinichiro Nakamura. (CuBeatSystems)
- *
- * ID : shintamainjp
- * Added : RW-
- */
-
-#include "TextLCD.h"
-#include "mbed.h"
-
-TextLCD::TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1,
- PinName d2, PinName d3, LCDType type) : _rs(rs), _rw(rw),
- _e(e), _d(d0, d1, d2, d3),
- _type(type) {
-
- _e = 1;
- _rs = 0; // command mode
- _rw = 0;
-
- wait(0.015); // Wait 15ms to ensure powered up
-
- // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
- for (int i=0; i<3; i++) {
- writeByte(0x3);
- wait(0.00164); // this command takes 1.64ms, so wait for it
- }
- writeByte(0x2); // 4-bit mode
- wait(0.000040f); // most instructions take 40us
-
- writeCommand(0x28); // Function set 001 BW N F - -
- writeCommand(0x0C);
- writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes
- cls();
-}
-
-void TextLCD::character(int column, int row, int c) {
- int a = address(column, row);
- writeCommand(a);
- writeData(c);
-}
-
-void TextLCD::cls() {
- writeCommand(0x01); // cls, and set cursor to 0
- wait(0.00164f); // This command takes 1.64 ms
- locate(0, 0);
-}
-
-void TextLCD::locate(int column, int row) {
- _column = column;
- _row = row;
-}
-
-int TextLCD::_putc(int value) {
- if (value == '\n') {
- _column = 0;
- _row++;
- if (_row >= rows()) {
- _row = 0;
- }
- } else {
- character(_column, _row, value);
- _column++;
- if (_column >= columns()) {
- _column = 0;
- _row++;
- if (_row >= rows()) {
- _row = 0;
- }
- }
- }
- return value;
-}
-
-int TextLCD::_getc() {
- return -1;
-}
-
-void TextLCD::writeByte(int value) {
- _d = value >> 4;
- wait(0.000040f); // most instructions take 40us
- _e = 0;
- wait(0.000040f);
- _e = 1;
- _d = value >> 0;
- wait(0.000040f);
- _e = 0;
- wait(0.000040f); // most instructions take 40us
- _e = 1;
-}
-
-void TextLCD::writeCommand(int command) {
- _rs = 0;
- writeByte(command);
-}
-
-void TextLCD::writeData(int data) {
- _rs = 1;
- writeByte(data);
-}
-
-int TextLCD::address(int column, int row) {
- switch (_type) {
- case LCD20x4:
- switch (row) {
- case 0:
- return 0x80 + column;
- case 1:
- return 0xc0 + column;
- case 2:
- return 0x94 + column;
- case 3:
- return 0xd4 + column;
- }
- case LCD16x2B:
- return 0x80 + (row * 40) + column;
- case LCD16x2:
- case LCD20x2:
- default:
- return 0x80 + (row * 0x40) + column;
- }
-}
-
-int TextLCD::columns() {
- switch (_type) {
- case LCD20x4:
- case LCD20x2:
- return 20;
- case LCD16x2:
- case LCD16x2B:
- default:
- return 16;
- }
-}
-
-int TextLCD::rows() {
- switch (_type) {
- case LCD20x4:
- return 4;
- case LCD16x2:
- case LCD16x2B:
- case LCD20x2:
- default:
- return 2;
- }
-}
--- a/extlib/TextLCD.h Sun Aug 15 10:41:12 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/* mbed TextLCD Library, for a 4-bit LCD based on HD44780
- * Copyright (c) 2007-2010, sford
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/*
- * Modified for star board orange by Shinichiro Nakamura. (CuBeatSystems)
- *
- * ID : shintamainjp
- * Added : RW-
- */
-
-#ifndef MBED_TEXTLCD_H
-#define MBED_TEXTLCD_H
-
-#include "mbed.h"
-
-/** A TextLCD interface for driving 4-bit HD44780-based LCDs
- *
- * Currently supports 16x2, 20x2 and 20x4 panels
- *
- * @code
- * #include "mbed.h"
- * #include "TextLCD.h"
- *
- * TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d0-d3
- *
- * int main() {
- * lcd.printf("Hello World!\n");
- * }
- * @endcode
- */
-class TextLCD : public Stream {
-public:
-
- /** LCD panel format */
- enum LCDType {
- LCD16x2 /**< 16x2 LCD panel (default) */
- , LCD16x2B /**< 16x2 LCD panel alternate addressing */
- , LCD20x2 /**< 20x2 LCD panel */
- , LCD20x4 /**< 20x4 LCD panel */
- };
-
- /** Create a TextLCD interface
- *
- * @param rs Instruction/data control line.
- * @param rw Read/Write- control line.
- * @param e Enable line (clock)
- * @param d0-d3 Data lines
- * @param type Sets the panel size/addressing mode (default = LCD16x2)
- */
- TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, PinName d2, PinName d3, LCDType type = LCD16x2);
-
-#if DOXYGEN_ONLY
- /** Write a character to the LCD
- *
- * @param c The character to write to the display
- */
- int putc(int c);
-
- /** Write a formated string to the LCD
- *
- * @param format A printf-style format string, followed by the
- * variables to use in formating the string.
- */
- int printf(const char* format, ...);
-#endif
-
- /** Locate to a screen column and row
- *
- * @param column The horizontal position from the left, indexed from 0
- * @param row The vertical position from the top, indexed from 0
- */
- void locate(int column, int row);
-
- /** Clear the screen and locate to 0,0 */
- void cls();
-
- int rows();
- int columns();
-
-protected:
-
- // Stream implementation functions
- virtual int _putc(int value);
- virtual int _getc();
-
- int address(int column, int row);
- void character(int column, int row, int c);
- void writeByte(int value);
- void writeCommand(int command);
- void writeData(int data);
-
- DigitalOut _rs, _rw, _e;
- BusOut _d;
- LCDType _type;
-
- int _column;
- int _row;
-};
-
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extlib/TextLCD.lib Fri Sep 17 22:05:34 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- a/main.cpp Sun Aug 15 10:41:12 2010 +0000
+++ b/main.cpp Fri Sep 17 22:05:34 2010 +0000
@@ -1,5 +1,5 @@
/**
- * StarBoard Orange - Example application No.2 (Version 0.0.1)
+ * StarBoard Orange - Example application No.2 (Version 0.0.4)
* Remote IR receiver with StarBoard Orange
*
* See also ... http://mbed.org/users/shintamainjp/notebook/starboard_example2_ja/
@@ -12,11 +12,14 @@
#include <mbed.h>
#include "ReceiverIR.h"
+#include "TransmitterIR.h"
#include "TextLCD.h"
-ReceiverIR ir(p17);
+ReceiverIR ir_rx(p15);
+TransmitterIR ir_tx(p21);
+TextLCD lcd(p24, p26, p27, p28, p29, p30);
BusOut led(LED4, LED3, LED2, LED1);
-TextLCD lcd(p24, p25, p26, p27, p28, p29, p30);
+Ticker ledTicker;
/**
* Display a splash screen.
@@ -38,10 +41,104 @@
}
/**
+ * Receive.
+ *
+ * @param format Pointer to a format.
+ * @param buf Pointer to a buffer.
+ * @param bufsiz Size of the buffer.
+ *
+ * @return Bit length of the received data.
+ */
+int receive(RemoteIR::Format *format, uint8_t *buf, int bufsiz, int timeout = 1000) {
+ int cnt = 0;
+ while (ir_rx.getState() != ReceiverIR::Received) {
+ wait_ms(1);
+ cnt++;
+ if (timeout < cnt) {
+ return -1;
+ }
+ }
+ return ir_rx.getData(format, buf, bufsiz * 8);
+}
+
+/**
+ * Transmit.
+ *
+ * @param format Format.
+ * @param buf Pointer to a buffer.
+ * @param bitlength Bit length of the data.
+ *
+ * @return Bit length of the received data.
+ */
+int transmit(RemoteIR::Format format, uint8_t *buf, int bitlength, int timeout = 1000) {
+ int cnt = 0;
+ while (ir_tx.getState() != TransmitterIR::Idle) {
+ wait_ms(1);
+ cnt++;
+ if (timeout < cnt) {
+ return -1;
+ }
+ }
+ return ir_tx.setData(format, buf, bitlength);
+}
+
+/**
+ * Display a current status.
+ */
+void display_status(char *status) {
+ lcd.locate(0, 0);
+ lcd.printf("%-12.12s", status);
+}
+
+/**
+ * Display a format of a data.
+ */
+void display_format(RemoteIR::Format format) {
+ lcd.locate(12, 0);
+ switch (format) {
+ case RemoteIR::UNKNOWN:
+ lcd.printf("????");
+ break;
+ case RemoteIR::NEC:
+ lcd.printf(" NEC");
+ break;
+ case RemoteIR::AEHA:
+ lcd.printf("AEHA");
+ break;
+ case RemoteIR::SONY:
+ lcd.printf("SONY");
+ break;
+ }
+}
+
+/**
+ * Display a data.
+ *
+ * @param buf Pointer to a buffer.
+ * @param bitlength Bit length of a data.
+ */
+void display_data(uint8_t *buf, int bitlength) {
+ lcd.locate(0, 1);
+ const int n = bitlength / 8 + (((bitlength % 8) != 0) ? 1 : 0);
+ for (int i = 0; i < n; i++) {
+ lcd.printf("%02X", buf[i]);
+ }
+ for (int i = 0; i < 8 - n; i++) {
+ lcd.printf("--");
+ }
+}
+
+void ledfunc(void) {
+ led = led + 1;
+}
+
+/**
* Entry point.
*/
int main(void) {
+ ledTicker.attach(&ledfunc, 0.5);
+
/*
* Splash.
*/
@@ -56,64 +153,69 @@
lcd.printf("Press a button ");
lcd.locate(0, 1);
lcd.printf("on a controller.");
+ wait_ms(2000);
+ lcd.cls();
+
+ /*
+ * Execute.
+ */
while (1) {
- static int latest_bits = 0;
- static ReceiverIR::State prev = ReceiverIR::Idle;
-
- /*
- * Get a current state.
- */
- ReceiverIR::State curr = ir.getState();
- if (prev != curr) {
- lcd.locate(0, 0);
- switch (curr) {
- case ReceiverIR::Idle:
- lcd.printf("Idle (%2d) \n", latest_bits);
- break;
- case ReceiverIR::Receiving:
- lcd.printf("Receiving \n");
- break;
- case ReceiverIR::Received:
- lcd.printf("Received \n");
- break;
+ uint8_t buf1[32];
+ uint8_t buf2[32];
+ int bitlength1;
+ int bitlength2;
+ RemoteIR::Format format;
+
+ memset(buf1, 0x00, sizeof(buf1));
+ memset(buf2, 0x00, sizeof(buf2));
+
+ {
+ display_status("1:RX> > ");
+ bitlength1 = receive(&format, buf1, sizeof(buf1));
+ if (bitlength1 < 0) {
+ continue;
+ }
+ display_data(buf1, bitlength1);
+ display_format(format);
+ }
+
+#if 0
+ wait_ms(1000);
+
+ {
+ display_status("2:RX>TX> ");
+ bitlength1 = transmit(format, buf1, bitlength1);
+ if (bitlength1 < 0) {
+ continue;
+ }
+ display_data(buf1, bitlength1);
+ display_format(format);
+ }
+
+ wait_ms(100);
+
+ {
+ display_status("3:RX>TX>RX");
+ bitlength2 = receive(&format, buf2, sizeof(buf2));
+ if (bitlength2 < 0) {
+ continue;
+ }
+ display_data(buf2, bitlength2);
+ display_format(format);
+ }
+
+ wait_ms(100);
+
+ {
+ for (int i = 0; i < sizeof(buf1); i++) {
+ if (buf1[i] != buf2[i]) {
+ display_status("Compare err.");
+ wait(1);
+ continue;
+ }
}
}
- prev = curr;
-
- /*
- * Update statuses if it updated.
- */
- if (ReceiverIR::Received == curr) {
- led = led + 1;
- ReceiverIR::Format format;
- uint8_t buf[32];
- int bc = ir.getData(&format, buf, sizeof(buf));
- latest_bits = bc;
- lcd.locate(10, 0);
- switch (format) {
- case ReceiverIR::UNKNOWN:
- lcd.printf(": ????");
- break;
- case ReceiverIR::NEC:
- lcd.printf(": NEC ");
- break;
- case ReceiverIR::AEHA:
- lcd.printf(": AEHA");
- break;
- case ReceiverIR::SONY:
- lcd.printf(": SONY");
- break;
- default:
- break;
- }
- lcd.locate(0, 1);
- for (int i = 0; i < (bc / 8); i++) {
- lcd.printf("%02X", buf[i]);
- }
- for (int i = 0; i < 8 - (bc / 8); i++) {
- lcd.printf("--");
- }
- }
+#endif
}
}
\ No newline at end of file
--- a/mbed.bld Sun Aug 15 10:41:12 2010 +0000 +++ b/mbed.bld Fri Sep 17 22:05:34 2010 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mylib/RemoteIR.lib Fri Sep 17 22:05:34 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/shintamainjp/code/RemoteIR/#268cc2ab63bd