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: N5110 ShiftReg Tone mbed
Fork of 1620_Project_Template by
ModeA/ModeA.cpp@4:4269457cf8d8, 2017-07-12 (annotated)
- Committer:
 - eendmo
 - Date:
 - Wed Jul 12 16:15:04 2017 +0000
 - Revision:
 - 4:4269457cf8d8
 - Parent:
 - 2:0f91b789d90a
 
Updated Mode B
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| eencae | 0:d5312060f649 | 1 | #include "ModeA.h" | 
| eencae | 0:d5312060f649 | 2 | |
| eencae | 0:d5312060f649 | 3 | void mode_A() { | 
| eencae | 0:d5312060f649 | 4 | |
| eencae | 0:d5312060f649 | 5 | lcd.clear(); | 
| eencae | 0:d5312060f649 | 6 | lcd.printString("Mode A",0,0); | 
| eencae | 0:d5312060f649 | 7 | lcd.refresh(); | 
| eendmo | 2:0f91b789d90a | 8 | wait_ms(250); | 
| eendmo | 2:0f91b789d90a | 9 | |
| eendmo | 2:0f91b789d90a | 10 | int segments[10] = {}; // Enter your hex values here! | 
| eendmo | 2:0f91b789d90a | 11 | int count = 0; | 
| eendmo | 2:0f91b789d90a | 12 | |
| eendmo | 2:0f91b789d90a | 13 | update_display(count, segments[count]); | 
| eencae | 0:d5312060f649 | 14 | |
| eencae | 0:d5312060f649 | 15 | while (button_a.read() == 0) { | 
| eencae | 0:d5312060f649 | 16 | |
| eendmo | 2:0f91b789d90a | 17 | if(button_b.read() == 1){ | 
| eendmo | 2:0f91b789d90a | 18 | count++; | 
| eendmo | 2:0f91b789d90a | 19 | update_display(count, segments[count]); | 
| eendmo | 2:0f91b789d90a | 20 | wait_ms(250); | 
| eendmo | 2:0f91b789d90a | 21 | } | 
| eendmo | 2:0f91b789d90a | 22 | if(button_d.read() == 1){ | 
| eendmo | 2:0f91b789d90a | 23 | count--; | 
| eendmo | 2:0f91b789d90a | 24 | update_display(count, segments[count]); | 
| eendmo | 2:0f91b789d90a | 25 | wait_ms(250); | 
| eendmo | 2:0f91b789d90a | 26 | } | 
| eencae | 0:d5312060f649 | 27 | |
| eendmo | 2:0f91b789d90a | 28 | |
| eencae | 0:d5312060f649 | 29 | |
| eencae | 0:d5312060f649 | 30 | } | 
| eencae | 0:d5312060f649 | 31 | |
| eendmo | 2:0f91b789d90a | 32 | } | 
| eendmo | 2:0f91b789d90a | 33 | |
| eendmo | 2:0f91b789d90a | 34 | void update_display(int count, int hex){ | 
| eendmo | 2:0f91b789d90a | 35 | char count_string[14]; | 
| eendmo | 2:0f91b789d90a | 36 | sprintf(count_string, "Count = %d ", count); | 
| eendmo | 2:0f91b789d90a | 37 | lcd.printString(count_string,0,2); | 
| eendmo | 2:0f91b789d90a | 38 | char hex_string[14]; | 
| eendmo | 2:0f91b789d90a | 39 | sprintf(hex_string, "Hex: %#04x ", hex); | 
| eendmo | 2:0f91b789d90a | 40 | lcd.printString(hex_string,0,3); | 
| eendmo | 2:0f91b789d90a | 41 | lcd.refresh(); | 
| eendmo | 2:0f91b789d90a | 42 | |
| eencae | 0:d5312060f649 | 43 | } | 
