AirsoftTimer software based on mbed

Dependencies:   mbed TextLCD keypad

Committer:
sillevl
Date:
Fri Dec 12 20:07:28 2014 +0000
Revision:
3:ce34dfe2463b
Parent:
2:f8e46daca111
Child:
4:2c91c9eccf3a
old v0.3 inital demo app

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sillevl 1:c80248c83025 1 #include "mbed.h"
sillevl 2:f8e46daca111 2 #include "cmsis_os.h"
sillevl 2:f8e46daca111 3
sillevl 2:f8e46daca111 4
sillevl 1:c80248c83025 5 //#include "Airsofttimer.h"
sillevl 1:c80248c83025 6 #include "TextLCD.h"
sillevl 1:c80248c83025 7
sillevl 1:c80248c83025 8
sillevl 2:f8e46daca111 9 struct product {
sillevl 3:ce34dfe2463b 10 int weight;
sillevl 3:ce34dfe2463b 11 float price;
sillevl 2:f8e46daca111 12 } ;
sillevl 2:f8e46daca111 13
sillevl 1:c80248c83025 14
sillevl 1:c80248c83025 15
sillevl 2:f8e46daca111 16 DigitalOut heartbeatLed(LED1);
sillevl 2:f8e46daca111 17 DigitalOut led2(LED2);
sillevl 2:f8e46daca111 18 DigitalOut led3(LED3);
sillevl 2:f8e46daca111 19 DigitalOut led4(LED4);
sillevl 1:c80248c83025 20
sillevl 3:ce34dfe2463b 21 PwmOut buzzer(P2_3);
sillevl 1:c80248c83025 22
sillevl 1:c80248c83025 23 DigitalOut leda(P2_4);
sillevl 1:c80248c83025 24 DigitalOut ledb(P2_5);
sillevl 1:c80248c83025 25
sillevl 2:f8e46daca111 26 DigitalOut col1(P0_16);
sillevl 2:f8e46daca111 27 DigitalOut col2(P0_17);
sillevl 2:f8e46daca111 28 DigitalOut col3(P0_18);
sillevl 2:f8e46daca111 29
sillevl 2:f8e46daca111 30 DigitalIn row1(P0_8);
sillevl 2:f8e46daca111 31 DigitalIn row2(P0_9);
sillevl 2:f8e46daca111 32 DigitalIn row3(P0_10);
sillevl 2:f8e46daca111 33 DigitalIn row4(P0_11);
sillevl 2:f8e46daca111 34
sillevl 2:f8e46daca111 35 DigitalIn button(P0_5);
sillevl 2:f8e46daca111 36 DigitalIn key(P0_4);
sillevl 2:f8e46daca111 37
sillevl 2:f8e46daca111 38 int colCounter = 1;
sillevl 2:f8e46daca111 39
sillevl 2:f8e46daca111 40 //keyboardRowPins = {P0_8 , P0_9 , P0_10, P0_11}; // ROWS=P0.8 -> P0.11
sillevl 2:f8e46daca111 41 //keyboardColPins = {P0_16, P0_17, P0_18}; // COLS=P0.16 -> P0.18
sillevl 2:f8e46daca111 42
sillevl 3:ce34dfe2463b 43 void heartbeatThread(void const *args)
sillevl 3:ce34dfe2463b 44 {
sillevl 3:ce34dfe2463b 45 while(true) {
sillevl 2:f8e46daca111 46 heartbeatLed = 1;
sillevl 3:ce34dfe2463b 47 leda = ledb = 1;
sillevl 2:f8e46daca111 48 osDelay(10);
sillevl 2:f8e46daca111 49 heartbeatLed = 0;
sillevl 3:ce34dfe2463b 50 leda = ledb = 0;
sillevl 2:f8e46daca111 51 osDelay(300);
sillevl 2:f8e46daca111 52 heartbeatLed = 1;
sillevl 3:ce34dfe2463b 53 leda = ledb = 1;
sillevl 2:f8e46daca111 54 osDelay(10);
sillevl 2:f8e46daca111 55 heartbeatLed = 0;
sillevl 3:ce34dfe2463b 56 leda = ledb = 0;
sillevl 2:f8e46daca111 57 osDelay(680);
sillevl 2:f8e46daca111 58 }
sillevl 2:f8e46daca111 59 }
sillevl 2:f8e46daca111 60
sillevl 2:f8e46daca111 61 osThreadDef(heartbeatThread, osPriorityNormal, DEFAULT_STACK_SIZE);
sillevl 2:f8e46daca111 62
sillevl 1:c80248c83025 63 int main()
sillevl 1:c80248c83025 64 {
sillevl 3:ce34dfe2463b 65 int tone =2300;
sillevl 2:f8e46daca111 66 osThreadCreate(osThread(heartbeatThread), NULL);
sillevl 2:f8e46daca111 67 TextLCD lcd(P1_30, P1_31, P0_23, P0_24, P0_25, P0_26, TextLCD::LCD20x4); // rs, e, d4-d7
sillevl 3:ce34dfe2463b 68 buzzer.period_us(1/2400);
sillevl 2:f8e46daca111 69
sillevl 1:c80248c83025 70 while(1) {
sillevl 3:ce34dfe2463b 71
sillevl 3:ce34dfe2463b 72 lcd.locate(0,1);
sillevl 3:ce34dfe2463b 73 lcd.printf(" - AirsoftTimer - ");
sillevl 3:ce34dfe2463b 74 lcd.locate(0,3);
sillevl 3:ce34dfe2463b 75 lcd.printf("Prototype V0.3");
sillevl 3:ce34dfe2463b 76
sillevl 3:ce34dfe2463b 77 tone = tone +20;
sillevl 3:ce34dfe2463b 78 if(tone > 2500) tone = 2300;
sillevl 3:ce34dfe2463b 79 if(!button) {
sillevl 3:ce34dfe2463b 80 buzzer.period_us(1000000/tone);
sillevl 3:ce34dfe2463b 81 buzzer = 0.5;
sillevl 3:ce34dfe2463b 82 } else {
sillevl 3:ce34dfe2463b 83 buzzer = 0.0;
sillevl 2:f8e46daca111 84 }
sillevl 2:f8e46daca111 85
sillevl 3:ce34dfe2463b 86 osDelay(10);
sillevl 1:c80248c83025 87 }
sillevl 1:c80248c83025 88 }
sillevl 2:f8e46daca111 89
sillevl 2:f8e46daca111 90
sillevl 2:f8e46daca111 91
sillevl 2:f8e46daca111 92 /*
sillevl 2:f8e46daca111 93 char degree[8] = {0x02,0x05,0x05,0x02,0x00,0x00,0x00,0x00};
sillevl 2:f8e46daca111 94
sillevl 2:f8e46daca111 95 lcd.putcustomChar(1,degree,0x01,12,0);
sillevl 2:f8e46daca111 96
sillevl 2:f8e46daca111 97 lcd.printf("C");
sillevl 2:f8e46daca111 98 */