TTDC / Mbed 2 deprecated switches

Dependencies:   C12832 MMA7660 mbed

Committer:
ksaito
Date:
Wed Mar 14 11:15:31 2018 +0000
Revision:
5:614e3ac042df
Parent:
1:2967eac08981
Child:
9:35c816293400
????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ksaito 0:c3bc6981ad28 1 #include "mbed.h"
ksaito 0:c3bc6981ad28 2 #include "C12832.h"
ksaito 0:c3bc6981ad28 3
ksaito 1:2967eac08981 4 #include "commands.h"
ksaito 0:c3bc6981ad28 5
ksaito 5:614e3ac042df 6 extern COMMAND_DEFINE *commandList[];
ksaito 5:614e3ac042df 7 extern COMMAND_DEFINE Command_null;
ksaito 0:c3bc6981ad28 8
ksaito 0:c3bc6981ad28 9 BusIn joy(p15,p12,p13,p16);
ksaito 0:c3bc6981ad28 10 DigitalIn fire(p14);
ksaito 0:c3bc6981ad28 11 C12832 lcd(p5, p7, p6, p8, p11);
ksaito 0:c3bc6981ad28 12
ksaito 0:c3bc6981ad28 13 int main()
ksaito 0:c3bc6981ad28 14 {
ksaito 0:c3bc6981ad28 15 lcd.cls();
ksaito 0:c3bc6981ad28 16 lcd.locate(0,3);
ksaito 0:c3bc6981ad28 17 lcd.printf("mbed Switches application");
ksaito 0:c3bc6981ad28 18
ksaito 5:614e3ac042df 19 for(int index = 0; commandList[index]->trigger != 0x00; index++) {
ksaito 1:2967eac08981 20 commandList[index]->initialize();
ksaito 1:2967eac08981 21 }
ksaito 5:614e3ac042df 22
ksaito 5:614e3ac042df 23 COMMAND_DEFINE *current = &Command_null;
ksaito 0:c3bc6981ad28 24 while(true) {
ksaito 5:614e3ac042df 25 COMMAND_DEFINE *request = NULL;
ksaito 1:2967eac08981 26 int trigger = fire ? 0xff : joy;
ksaito 5:614e3ac042df 27 for(int index = 0; commandList[index]->trigger != 0x00; index++) {
ksaito 1:2967eac08981 28 if (trigger == commandList[index]->trigger) {
ksaito 5:614e3ac042df 29 request = commandList[index];
ksaito 0:c3bc6981ad28 30 }
ksaito 0:c3bc6981ad28 31 }
ksaito 5:614e3ac042df 32 if (request != NULL && request != current) {
ksaito 5:614e3ac042df 33 current->finalize();
ksaito 5:614e3ac042df 34 current = &Command_null;
ksaito 5:614e3ac042df 35 }
ksaito 5:614e3ac042df 36 if (current->trigger == 0x00) {
ksaito 5:614e3ac042df 37 if (request != NULL){
ksaito 5:614e3ac042df 38 current = request;
ksaito 5:614e3ac042df 39 lcd.locate(0,15);
ksaito 5:614e3ac042df 40 lcd.printf(" ");
ksaito 5:614e3ac042df 41 lcd.locate(0,15);
ksaito 5:614e3ac042df 42 lcd.printf(current->name);
ksaito 5:614e3ac042df 43 current->processInitialize();
ksaito 5:614e3ac042df 44 }
ksaito 5:614e3ac042df 45 } else {
ksaito 5:614e3ac042df 46 current->processRunning();
ksaito 5:614e3ac042df 47 if (! current->processIsContinue()){
ksaito 5:614e3ac042df 48 current->finalize();
ksaito 5:614e3ac042df 49 current = &Command_null;
ksaito 5:614e3ac042df 50 }
ksaito 0:c3bc6981ad28 51 }
ksaito 0:c3bc6981ad28 52 }
ksaito 0:c3bc6981ad28 53 }