Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832 MMA7660 mbed
main.cpp
- Committer:
- ksaito
- Date:
- 2018-03-14
- Revision:
- 5:614e3ac042df
- Parent:
- 1:2967eac08981
- Child:
- 9:35c816293400
File content as of revision 5:614e3ac042df:
#include "mbed.h"
#include "C12832.h"
#include "commands.h"
extern COMMAND_DEFINE *commandList[];
extern COMMAND_DEFINE Command_null;
BusIn joy(p15,p12,p13,p16);
DigitalIn fire(p14);
C12832 lcd(p5, p7, p6, p8, p11);
int main()
{
lcd.cls();
lcd.locate(0,3);
lcd.printf("mbed Switches application");
for(int index = 0; commandList[index]->trigger != 0x00; index++) {
commandList[index]->initialize();
}
COMMAND_DEFINE *current = &Command_null;
while(true) {
COMMAND_DEFINE *request = NULL;
int trigger = fire ? 0xff : joy;
for(int index = 0; commandList[index]->trigger != 0x00; index++) {
if (trigger == commandList[index]->trigger) {
request = commandList[index];
}
}
if (request != NULL && request != current) {
current->finalize();
current = &Command_null;
}
if (current->trigger == 0x00) {
if (request != NULL){
current = request;
lcd.locate(0,15);
lcd.printf(" ");
lcd.locate(0,15);
lcd.printf(current->name);
current->processInitialize();
}
} else {
current->processRunning();
if (! current->processIsContinue()){
current->finalize();
current = &Command_null;
}
}
}
}