AirsoftTimer software based on mbed
Dependencies: mbed TextLCD keypad
main.cpp
- Committer:
- sillevl
- Date:
- 2013-02-26
- Revision:
- 2:f8e46daca111
- Parent:
- 1:c80248c83025
- Child:
- 3:ce34dfe2463b
File content as of revision 2:f8e46daca111:
#include "mbed.h" #include "cmsis_os.h" //#include "Airsofttimer.h" #include "TextLCD.h" struct product { int weight; float price; } ; DigitalOut heartbeatLed(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); /*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 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() { 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.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; beep(); /* 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; osDelay(200); } } /* char degree[8] = {0x02,0x05,0x05,0x02,0x00,0x00,0x00,0x00}; lcd.putcustomChar(1,degree,0x01,12,0); lcd.printf("C"); */