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@1:2967eac08981, 2018-02-21 (annotated)
- Committer:
- ksaito
- Date:
- Wed Feb 21 09:13:28 2018 +0000
- Revision:
- 1:2967eac08981
- Parent:
- 0:c3bc6981ad28
- Child:
- 5:614e3ac042df
?????????
Who changed what in which revision?
| User | Revision | Line number | New 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 | 1:2967eac08981 | 6 | extern COMMAND_DEFINE *commandList[]; |
| ksaito | 0:c3bc6981ad28 | 7 | |
| ksaito | 0:c3bc6981ad28 | 8 | BusIn joy(p15,p12,p13,p16); |
| ksaito | 0:c3bc6981ad28 | 9 | DigitalIn fire(p14); |
| ksaito | 0:c3bc6981ad28 | 10 | C12832 lcd(p5, p7, p6, p8, p11); |
| ksaito | 0:c3bc6981ad28 | 11 | |
| ksaito | 0:c3bc6981ad28 | 12 | int main() |
| ksaito | 0:c3bc6981ad28 | 13 | { |
| ksaito | 0:c3bc6981ad28 | 14 | lcd.cls(); |
| ksaito | 0:c3bc6981ad28 | 15 | lcd.locate(0,3); |
| ksaito | 0:c3bc6981ad28 | 16 | lcd.printf("mbed Switches application"); |
| ksaito | 0:c3bc6981ad28 | 17 | |
| ksaito | 1:2967eac08981 | 18 | for(int index = 0; commandList[index] != NULL; index++) { |
| ksaito | 1:2967eac08981 | 19 | commandList[index]->initialize(); |
| ksaito | 1:2967eac08981 | 20 | } |
| ksaito | 0:c3bc6981ad28 | 21 | |
| ksaito | 0:c3bc6981ad28 | 22 | while(true) { |
| ksaito | 1:2967eac08981 | 23 | COMMAND_DEFINE *command = NULL; |
| ksaito | 1:2967eac08981 | 24 | int trigger = fire ? 0xff : joy; |
| ksaito | 1:2967eac08981 | 25 | /* |
| ksaito | 1:2967eac08981 | 26 | switch (joy) { |
| ksaito | 1:2967eac08981 | 27 | case JOY_UP: {message = "Up!"; SoundProcess(); SoundFinalize(); break;} |
| ksaito | 1:2967eac08981 | 28 | case JOY_DOWN: {message = "Down!"; AccelProcess(); break;} |
| ksaito | 1:2967eac08981 | 29 | case JOY_LEFT: {message = "Left!"; ColorProcess(); ColorFinalize(); break;} |
| ksaito | 1:2967eac08981 | 30 | case JOY_RIGHT: {message = "Right!"; LinerProcess(); break;} |
| ksaito | 1:2967eac08981 | 31 | default: {message = NULL; break;} |
| ksaito | 1:2967eac08981 | 32 | } |
| ksaito | 1:2967eac08981 | 33 | */ |
| ksaito | 1:2967eac08981 | 34 | for(int index = 0; commandList[index] != NULL; index++) { |
| ksaito | 1:2967eac08981 | 35 | if (trigger == commandList[index]->trigger) { |
| ksaito | 1:2967eac08981 | 36 | command = commandList[index]; |
| ksaito | 0:c3bc6981ad28 | 37 | } |
| ksaito | 0:c3bc6981ad28 | 38 | } |
| ksaito | 1:2967eac08981 | 39 | if (command != NULL) { |
| ksaito | 0:c3bc6981ad28 | 40 | lcd.locate(0,15); |
| ksaito | 0:c3bc6981ad28 | 41 | lcd.printf(" "); |
| ksaito | 0:c3bc6981ad28 | 42 | lcd.locate(0,15); |
| ksaito | 1:2967eac08981 | 43 | lcd.printf(command->name); |
| ksaito | 1:2967eac08981 | 44 | command->process(); |
| ksaito | 0:c3bc6981ad28 | 45 | } |
| ksaito | 0:c3bc6981ad28 | 46 | } |
| ksaito | 0:c3bc6981ad28 | 47 | } |