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: ANSITermMenuSystem
Fork of menuSystemMbed by
Constantdisplay.cpp@5:92389cf2106d, 2013-04-21 (annotated)
- Committer:
- Rybowonder
- Date:
- Sun Apr 21 20:15:31 2013 +0000
- Revision:
- 5:92389cf2106d
- Child:
- 6:2f220f5d782d
Error off the hop
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Rybowonder | 5:92389cf2106d | 1 | // | 
| Rybowonder | 5:92389cf2106d | 2 | // MainMenu.cpp | 
| Rybowonder | 5:92389cf2106d | 3 | // menuSystem | 
| Rybowonder | 5:92389cf2106d | 4 | // | 
| Rybowonder | 5:92389cf2106d | 5 | // Created by BradDSmith on 2013-02-26. | 
| Rybowonder | 5:92389cf2106d | 6 | // Copyright (c) 2013 BradDSmith. All rights reserved. | 
| Rybowonder | 5:92389cf2106d | 7 | // | 
| Rybowonder | 5:92389cf2106d | 8 | |
| Rybowonder | 5:92389cf2106d | 9 | #include "Constantdisplay.h" | 
| Rybowonder | 5:92389cf2106d | 10 | |
| Rybowonder | 5:92389cf2106d | 11 | #include "console.h" | 
| Rybowonder | 5:92389cf2106d | 12 | |
| Rybowonder | 5:92389cf2106d | 13 | Constantdisplay::Constantdisplay() | 
| Rybowonder | 5:92389cf2106d | 14 | { | 
| Rybowonder | 5:92389cf2106d | 15 | maxitems = MAXCDISPLAYITEMS; | 
| Rybowonder | 5:92389cf2106d | 16 | } | 
| Rybowonder | 5:92389cf2106d | 17 | |
| Rybowonder | 5:92389cf2106d | 18 | void Constantdisplay::setMaxCdisplayItems(int max) | 
| Rybowonder | 5:92389cf2106d | 19 | { | 
| Rybowonder | 5:92389cf2106d | 20 | maxitems = max; | 
| Rybowonder | 5:92389cf2106d | 21 | } | 
| Rybowonder | 5:92389cf2106d | 22 | |
| Rybowonder | 5:92389cf2106d | 23 | void Constantdisplay::setCdisplayItem(int locID, const char * CdisplayText, int x, int y, int x2, int y2) | 
| Rybowonder | 5:92389cf2106d | 24 | { | 
| Rybowonder | 5:92389cf2106d | 25 | CdisplayItem[locID].initialize( (char *)CdisplayText,x, y, x2 ,y2); | 
| Rybowonder | 5:92389cf2106d | 26 | } | 
| Rybowonder | 5:92389cf2106d | 27 | |
| Rybowonder | 5:92389cf2106d | 28 | void Constantdisplay::printCdisplay() | 
| Rybowonder | 5:92389cf2106d | 29 | { | 
| Rybowonder | 5:92389cf2106d | 30 | for (int i = 0; i < maxitems; i++) { | 
| Rybowonder | 5:92389cf2106d | 31 | CdisplayItem[i].print(); | 
| Rybowonder | 5:92389cf2106d | 32 | } | 
| Rybowonder | 5:92389cf2106d | 33 | } | 
| Rybowonder | 5:92389cf2106d | 34 | |
| Rybowonder | 5:92389cf2106d | 35 | void Constantdisplay::updatedisplayitem(int ID, char * updateText) | 
| Rybowonder | 5:92389cf2106d | 36 | { | 
| Rybowonder | 5:92389cf2106d | 37 | CdisplayItem[ID].setValue(updateText); | 
| Rybowonder | 5:92389cf2106d | 38 | } | 
| Rybowonder | 5:92389cf2106d | 39 | |
| Rybowonder | 5:92389cf2106d | 40 | void Constantdisplay::printrect(int ID, int x1, int y1, int x2, int y2) | 
| Rybowonder | 5:92389cf2106d | 41 | { | 
| Rybowonder | 5:92389cf2106d | 42 | CdisplayItem[ID].Crect(x1, y1, x2, y2); | 
| Rybowonder | 5:92389cf2106d | 43 | } | 
| Rybowonder | 5:92389cf2106d | 44 | |
| Rybowonder | 5:92389cf2106d | 45 | void Constantdisplay::deleterect(int ID, int x1, int y1, int x2, int y2) | 
| Rybowonder | 5:92389cf2106d | 46 | { | 
| Rybowonder | 5:92389cf2106d | 47 | CdisplayItem[ID].DeleteCrect(x1, y1, x2, y2); | 
| Rybowonder | 5:92389cf2106d | 48 | } | 
| Rybowonder | 5:92389cf2106d | 49 | |
| Rybowonder | 5:92389cf2106d | 50 | /* itoa: convert n to characters in s */ | 
| Rybowonder | 5:92389cf2106d | 51 | void Constantdisplay::itoa(int n, char s[]) | 
| Rybowonder | 5:92389cf2106d | 52 | { | 
| Rybowonder | 5:92389cf2106d | 53 | int i, sign; | 
| Rybowonder | 5:92389cf2106d | 54 | |
| Rybowonder | 5:92389cf2106d | 55 | if ((sign = n) < 0) /* record sign */ | 
| Rybowonder | 5:92389cf2106d | 56 | n = -n; /* make n positive */ | 
| Rybowonder | 5:92389cf2106d | 57 | i = 0; | 
| Rybowonder | 5:92389cf2106d | 58 | do { /* generate digits in reverse order */ | 
| Rybowonder | 5:92389cf2106d | 59 | s[i++] = n % 10 + '0'; /* get next digit */ | 
| Rybowonder | 5:92389cf2106d | 60 | } while ((n /= 10) > 0); /* delete it */ | 
| Rybowonder | 5:92389cf2106d | 61 | if (sign < 0) | 
| Rybowonder | 5:92389cf2106d | 62 | s[i++] = '-'; | 
| Rybowonder | 5:92389cf2106d | 63 | s[i] = '\0'; | 
| Rybowonder | 5:92389cf2106d | 64 | } | 
| Rybowonder | 5:92389cf2106d | 65 | |
| Rybowonder | 5:92389cf2106d | 66 | 
