AirsoftTimer software based on mbed
Dependencies: mbed TextLCD keypad
Revision 2:f8e46daca111, committed 2013-02-26
- Comitter:
- sillevl
- Date:
- Tue Feb 26 19:04:20 2013 +0000
- Parent:
- 1:c80248c83025
- Child:
- 3:ce34dfe2463b
- Commit message:
- Threaded alive led;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Menu.lib Tue Feb 26 19:04:20 2013 +0000 @@ -0,0 +1,1 @@ +Menu#bb5bfa42f861
--- a/TextLCD.lib Sun Feb 10 09:58:24 2013 +0000 +++ b/TextLCD.lib Tue Feb 26 19:04:20 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37 +http://mbed.org/users/simon/code/TextLCD/#dde7f427feda
--- a/main.cpp Sun Feb 10 09:58:24 2013 +0000 +++ b/main.cpp Tue Feb 26 19:04:20 2013 +0000 @@ -1,48 +1,136 @@ #include "mbed.h" +#include "cmsis_os.h" + + //#include "Airsofttimer.h" #include "TextLCD.h" +struct product { + int weight; + float price; +} ; + -DigitalOut myled1(LED1); -DigitalOut myled2(LED2); -DigitalOut myled3(LED3); -DigitalOut myled4(LED4); +DigitalOut heartbeatLed(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); -DigitalOut rs(P1_30); +/*DigitalOut rs(P1_30); DigitalOut e(P1_31); DigitalOut d4(P0_23); DigitalOut d5(P0_24); DigitalOut d6(P0_25); -DigitalOut d7(P0_26); +DigitalOut d7(P0_26);*/ + +DigitalOut buzzer(P2_3); DigitalOut leda(P2_4); DigitalOut ledb(P2_5); +DigitalOut col1(P0_16); +DigitalOut col2(P0_17); +DigitalOut col3(P0_18); + +DigitalIn row1(P0_8); +DigitalIn row2(P0_9); +DigitalIn row3(P0_10); +DigitalIn row4(P0_11); + +DigitalIn button(P0_5); +DigitalIn key(P0_4); + +int colCounter = 1; + +//keyboardRowPins = {P0_8 , P0_9 , P0_10, P0_11}; // ROWS=P0.8 -> P0.11 +//keyboardColPins = {P0_16, P0_17, P0_18}; // COLS=P0.16 -> P0.18 + +void beep(){ + buzzer = 1; + wait(0.02); + buzzer = 0; +} + +void heartbeatThread(void const *args){ + while(true){ + heartbeatLed = 1; + osDelay(10); + heartbeatLed = 0; + osDelay(300); + heartbeatLed = 1; + osDelay(10); + heartbeatLed = 0; + osDelay(680); + } +} + +osThreadDef(heartbeatThread, osPriorityNormal, DEFAULT_STACK_SIZE); + int main() { - //TextLCD lcd(P1_30, P1_31, P0_23, P0_24, P0_23, P0_26); // rs, e, d4-d7 - + osThreadCreate(osThread(heartbeatThread), NULL); + TextLCD lcd(P1_30, P1_31, P0_23, P0_24, P0_25, P0_26, TextLCD::LCD20x4); // rs, e, d4-d7 + while(1) { - //lcd.cls(); - //lcd.printf("AirsoftTimer\n"); - myled1 = 1; - myled2 = 1; - myled3 = 1; - myled4 = 1; - rs = e = d4 = d5 = d6 = d7 = 1; + //lcd.cls(); + lcd.locate(0,0); + lcd.printf("AirsoftTimer\n"); + col1 = 1; + col2 = 0; + col3 = 0; + lcd.printf("r1:%d r2:%d r3:%d r4:%d\n", row1.read(), row2.read(), row3.read(), row4.read()); + lcd.printf("Buzzer:%d Key:%d\n",buzzer.read(), key.read()); + +/* led2 = 1; + led3 = 1; + led4 = 1;*/ + //rs = e = d4 = d5 = d6 = d7 = 1; leda = ledb = 1; - wait(0.2); - - /////////////////////// + beep(); - myled1 = 0; - myled2 = 0; - myled3 = 0; - myled4 = 0; - rs = e = d4 = d5 = d6 = d7 = 0; +/* switch(colCounter){ + case 1: + col1=1; + col2=0; + col3=0; + break; + case 2: + col1=0; + col2=1; + col3=0; + break; + case 3: + col1=0; + col2=0; + col3=1; + break; + } + + colCounter++; + if(colCounter > 3) colCounter = 1;*/ + + wait(0.2); + + /////////////////////// + + + led2 = 0; + led3 = 0; + led4 = 0; + //rs = e = d4 = d5 = d6 = d7 = 0; leda = ledb = 0; - wait(0.2); + osDelay(200); } } + + + +/* +char degree[8] = {0x02,0x05,0x05,0x02,0x00,0x00,0x00,0x00}; + +lcd.putcustomChar(1,degree,0x01,12,0); + +lcd.printf("C"); +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Tue Feb 26 19:04:20 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#53e6cccd8782