asdf
Dependencies: NokiaLCD XMIT_IR mbed
Fork of 4180_mP_WirelessPong_revC by
Diff: main.cpp
- Revision:
- 3:8e492eacd346
- Parent:
- 1:9ba884d85ac6
- Child:
- 4:8fdff78c13c8
--- a/main.cpp Thu Oct 04 14:00:31 2012 +0000 +++ b/main.cpp Thu Oct 04 14:54:59 2012 +0000 @@ -5,27 +5,56 @@ #define FPS 5 +/**************************************** +|=======================================| +|MBED Connections: | +| -p5 : DIO on Sparkfun Nokia LCD | +| -p7 : CLK on Sparkfun Nokia LCD | +| -p8 : CS on Sparkfun Nokia LCD | +| -p9 : RST on Sparkfun Nokia LCD | +| -p22: GND on Sparkfun IR Xmtr | +|=======================================| +****************************************/ +//Pin Setup DigitalOut led1(LED1); DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type -Serial device(p13, p14); // tx, rx -PwmOut IRLED(p21); +Serial device(p28, p27); // tx, rx +PwmOut IRLED_mod(p22); +DigitalOut IRLED_ctrl(p22); +DigitalIn IRLED_rx(p20); +//Global Vars char buffer[32]; +unsigned char irdata_out=0; +unsigned char irdata_in=0; - +//Function Prototypes void BlinkAlive(void const* arguments); void UpdateLCD(void const* arguments); +void IRStuff(void const* arguments); int main() { + //LCD init lcd.background(0x000000); + //PWM init + IRLED_mod.period(1.0/38000.0); //38kHz Modulation Freq + IRLED_mod = 0.5; //pulse width = 50% + + //Serial init + device.baud(2400); + + //Thread init Thread thread_blinkalive(BlinkAlive); Thread thread_updatelcd(UpdateLCD); + Thread thread_irstuff(IRStuff); @@ -48,16 +77,35 @@ strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds)); lcd.printf("%s", buffer); + lcd.locate(0,4); + lcd.printf("IR_OUT=0x%X", irdata_out); + lcd.locate(0,5); + lcd.printf("IR_IN= 0x%X", irdata_in); + + + //End - Sleep thread led2 = 0; Thread::signal_wait(0x1); } } +void IRStuff(void const* arguments) +{ + while(true) { + device.putc(irdata_out); + if(device.readable()) { + irdata_in = device.getc(); + } + } +} + void BlinkAlive(void const* arguments) { while(true) { led1 = !led1; - Thread::wait(500); + IRLED_ctrl = led1; + irdata_out++; + Thread::wait(1000); } } \ No newline at end of file