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.
Fork of BinaryCount by
main.cpp@8:8a2d07e4a8c3, 2017-10-23 (annotated)
- Committer:
- CSTritt
- Date:
- Mon Oct 23 19:10:39 2017 +0000
- Revision:
- 8:8a2d07e4a8c3
- Parent:
- 7:031078522195
Improved opening comments. Changed out-of-range error indication from -1 to 1.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| CSTritt | 0:8ed2f4a2a2fe | 1 | /* |
| CSTritt | 7:031078522195 | 2 | Project: FlexiBarDemo |
| CSTritt | 0:8ed2f4a2a2fe | 3 | File: main.cpp |
| CSTritt | 7:031078522195 | 4 | |
| CSTritt | 7:031078522195 | 5 | Test harness for flexiBar bar graph display function. |
| CSTritt | 7:031078522195 | 6 | |
| CSTritt | 0:8ed2f4a2a2fe | 7 | Written by: Dr. C. S. Tritt |
| CSTritt | 6:0c1ab2c11252 | 8 | Created: 9/13/17 (v. 1.0) |
| CSTritt | 0:8ed2f4a2a2fe | 9 | */ |
| CSTritt | 0:8ed2f4a2a2fe | 10 | #include "mbed.h" |
| CSTritt | 8:8a2d07e4a8c3 | 11 | #include <flexiBar.h> |
| CSTritt | 0:8ed2f4a2a2fe | 12 | |
| CSTritt | 7:031078522195 | 13 | // Create 10-bit BusOut object called barGraph. |
| CSTritt | 7:031078522195 | 14 | BusOut barGraph(D11, D10, D9, D8, D7, D6, D5, D4, D3, D2); |
| CSTritt | 7:031078522195 | 15 | |
| CSTritt | 0:8ed2f4a2a2fe | 16 | int main() { |
| CSTritt | 6:0c1ab2c11252 | 17 | |
| CSTritt | 7:031078522195 | 18 | printf("flexiBar Test Harness\n"); // ID software. |
| CSTritt | 0:8ed2f4a2a2fe | 19 | |
| CSTritt | 7:031078522195 | 20 | // Start by directly testing the display. |
| CSTritt | 7:031078522195 | 21 | barGraph = 0b1111111111; // Light all bars. |
| CSTritt | 7:031078522195 | 22 | wait(2.0); |
| CSTritt | 7:031078522195 | 23 | barGraph = 0; // All bars off. |
| CSTritt | 7:031078522195 | 24 | wait(2.0); |
| CSTritt | 0:8ed2f4a2a2fe | 25 | |
| CSTritt | 7:031078522195 | 26 | // Loop through all values in both modes. |
| CSTritt | 0:8ed2f4a2a2fe | 27 | while(true) { |
| CSTritt | 7:031078522195 | 28 | bool single = true; |
| CSTritt | 7:031078522195 | 29 | for (int n = 0; n <= 9; n++) { |
| CSTritt | 7:031078522195 | 30 | flexiBar(n, barGraph, single, true); |
| CSTritt | 7:031078522195 | 31 | wait(1.0); |
| CSTritt | 7:031078522195 | 32 | } |
| CSTritt | 7:031078522195 | 33 | single = false; |
| CSTritt | 7:031078522195 | 34 | for (int n = 0; n <= 9; n++) { |
| CSTritt | 7:031078522195 | 35 | flexiBar(n, barGraph, single, true); |
| CSTritt | 7:031078522195 | 36 | wait(1.0); |
| CSTritt | 7:031078522195 | 37 | } |
| CSTritt | 7:031078522195 | 38 | // Test the special case of all bars off. Third argument is ignored. |
| CSTritt | 7:031078522195 | 39 | flexiBar(-1, barGraph, false, true); |
| CSTritt | 7:031078522195 | 40 | wait(2.0); |
| CSTritt | 7:031078522195 | 41 | } |
| CSTritt | 8:8a2d07e4a8c3 | 42 | } |
