AirsoftTimer software based on mbed
Dependencies: mbed TextLCD keypad
Diff: main.cpp
- Revision:
- 4:2c91c9eccf3a
- Parent:
- 3:ce34dfe2463b
- Child:
- 7:baf207d88603
--- a/main.cpp Fri Dec 12 20:07:28 2014 +0000 +++ b/main.cpp Sat Dec 13 10:11:24 2014 +0000 @@ -2,97 +2,32 @@ #include "cmsis_os.h" -//#include "Airsofttimer.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); +LedPins ledpins = {P2_4, P2_4}; // left, right -PwmOut buzzer(P2_3); - -DigitalOut leda(P2_4); -DigitalOut ledb(P2_5); +KeyboardPins keyboardpins = {{P0_8, P0_9, P0_10, P0_11}, {P0_16, P0_17, P0_18}}; -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); +LcdPins lcdpins = {P1_30, P1_31, P0_23, P0_24, P0_25, P0_26}; -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 heartbeatThread(void const *args) -{ - while(true) { - heartbeatLed = 1; - leda = ledb = 1; - osDelay(10); - heartbeatLed = 0; - leda = ledb = 0; - osDelay(300); - heartbeatLed = 1; - leda = ledb = 1; - osDelay(10); - heartbeatLed = 0; - leda = ledb = 0; - osDelay(680); - } -} - -osThreadDef(heartbeatThread, osPriorityNormal, DEFAULT_STACK_SIZE); +Pinouts pinouts = { + P0_5, // button + P0_4, // key + ledpins, // leds + P2_3, // buzzer + keyboardpins, + lcdpins// lcd +}; int main() { - int tone =2300; - osThreadCreate(osThread(heartbeatThread), NULL); - TextLCD lcd(P1_30, P1_31, P0_23, P0_24, P0_25, P0_26, TextLCD::LCD20x4); // rs, e, d4-d7 - buzzer.period_us(1/2400); - - while(1) { - - lcd.locate(0,1); - lcd.printf(" - AirsoftTimer - "); - lcd.locate(0,3); - lcd.printf("Prototype V0.3"); - - tone = tone +20; - if(tone > 2500) tone = 2300; - if(!button) { - buzzer.period_us(1000000/tone); - buzzer = 0.5; - } else { - buzzer = 0.0; - } - - osDelay(10); - } + Airsofttimer airsofttimer(pinouts); } - -/* -char degree[8] = {0x02,0x05,0x05,0x02,0x00,0x00,0x00,0x00}; +//DigitalOut heartbeatLed(LED1); +//DigitalOut led2(LED2); +//DigitalOut led3(LED3); +//DigitalOut led4(LED4); -lcd.putcustomChar(1,degree,0x01,12,0); - -lcd.printf("C"); -*/