asdf
Dependencies: NokiaLCD XMIT_IR mbed
Fork of 4180_mP_WirelessPong_revC by
main.cpp@1:9ba884d85ac6, 2012-10-04 (annotated)
- Committer:
- cmulady
- Date:
- Thu Oct 04 13:58:09 2012 +0000
- Revision:
- 1:9ba884d85ac6
- Parent:
- 0:c8ddcaa575ba
- Child:
- 3:8e492eacd346
Last revision didn't have rtos stuff in it. That's what happens when you have two compiler windows open.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cmulady | 0:c8ddcaa575ba | 1 | #include "mbed.h" |
cmulady | 0:c8ddcaa575ba | 2 | #include "rtos.h" |
cmulady | 0:c8ddcaa575ba | 3 | #include "NokiaLCD.h" |
cmulady | 1:9ba884d85ac6 | 4 | #include "XMIT_IR.h" |
cmulady | 0:c8ddcaa575ba | 5 | |
cmulady | 1:9ba884d85ac6 | 6 | #define FPS 5 |
cmulady | 1:9ba884d85ac6 | 7 | |
cmulady | 1:9ba884d85ac6 | 8 | |
cmulady | 1:9ba884d85ac6 | 9 | DigitalOut led1(LED1); |
cmulady | 1:9ba884d85ac6 | 10 | DigitalOut led2(LED2); |
cmulady | 0:c8ddcaa575ba | 11 | NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type |
cmulady | 1:9ba884d85ac6 | 12 | Serial device(p13, p14); // tx, rx |
cmulady | 1:9ba884d85ac6 | 13 | PwmOut IRLED(p21); |
cmulady | 1:9ba884d85ac6 | 14 | |
cmulady | 1:9ba884d85ac6 | 15 | char buffer[32]; |
cmulady | 1:9ba884d85ac6 | 16 | |
cmulady | 1:9ba884d85ac6 | 17 | |
cmulady | 1:9ba884d85ac6 | 18 | void BlinkAlive(void const* arguments); |
cmulady | 1:9ba884d85ac6 | 19 | void UpdateLCD(void const* arguments); |
cmulady | 1:9ba884d85ac6 | 20 | |
cmulady | 1:9ba884d85ac6 | 21 | |
cmulady | 1:9ba884d85ac6 | 22 | int main() |
cmulady | 1:9ba884d85ac6 | 23 | { |
cmulady | 0:c8ddcaa575ba | 24 | |
cmulady | 0:c8ddcaa575ba | 25 | lcd.background(0x000000); |
cmulady | 1:9ba884d85ac6 | 26 | |
cmulady | 1:9ba884d85ac6 | 27 | Thread thread_blinkalive(BlinkAlive); |
cmulady | 1:9ba884d85ac6 | 28 | Thread thread_updatelcd(UpdateLCD); |
cmulady | 1:9ba884d85ac6 | 29 | |
cmulady | 1:9ba884d85ac6 | 30 | |
cmulady | 1:9ba884d85ac6 | 31 | |
cmulady | 0:c8ddcaa575ba | 32 | while(1) { |
cmulady | 1:9ba884d85ac6 | 33 | thread_updatelcd.signal_set(0x1); |
cmulady | 1:9ba884d85ac6 | 34 | Thread::wait(1000/FPS); |
cmulady | 1:9ba884d85ac6 | 35 | |
cmulady | 0:c8ddcaa575ba | 36 | } |
cmulady | 0:c8ddcaa575ba | 37 | } |
cmulady | 1:9ba884d85ac6 | 38 | |
cmulady | 1:9ba884d85ac6 | 39 | void UpdateLCD(void const* arguments) |
cmulady | 1:9ba884d85ac6 | 40 | { |
cmulady | 1:9ba884d85ac6 | 41 | while(true) { |
cmulady | 1:9ba884d85ac6 | 42 | led2 = 1; |
cmulady | 1:9ba884d85ac6 | 43 | lcd.locate(0,1); |
cmulady | 1:9ba884d85ac6 | 44 | lcd.printf("Debug:"); |
cmulady | 1:9ba884d85ac6 | 45 | |
cmulady | 1:9ba884d85ac6 | 46 | lcd.locate(0,3); |
cmulady | 1:9ba884d85ac6 | 47 | time_t seconds = time(NULL); |
cmulady | 1:9ba884d85ac6 | 48 | strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds)); |
cmulady | 1:9ba884d85ac6 | 49 | lcd.printf("%s", buffer); |
cmulady | 1:9ba884d85ac6 | 50 | |
cmulady | 1:9ba884d85ac6 | 51 | //End - Sleep thread |
cmulady | 1:9ba884d85ac6 | 52 | led2 = 0; |
cmulady | 1:9ba884d85ac6 | 53 | Thread::signal_wait(0x1); |
cmulady | 1:9ba884d85ac6 | 54 | } |
cmulady | 1:9ba884d85ac6 | 55 | } |
cmulady | 1:9ba884d85ac6 | 56 | |
cmulady | 1:9ba884d85ac6 | 57 | void BlinkAlive(void const* arguments) |
cmulady | 1:9ba884d85ac6 | 58 | { |
cmulady | 1:9ba884d85ac6 | 59 | while(true) { |
cmulady | 1:9ba884d85ac6 | 60 | led1 = !led1; |
cmulady | 1:9ba884d85ac6 | 61 | Thread::wait(500); |
cmulady | 1:9ba884d85ac6 | 62 | } |
cmulady | 1:9ba884d85ac6 | 63 | } |