Menu system broken
Dependencies: ANSITermMenuSystem
Fork of menuSystemMbed by
Constantdisplay.cpp@8:6ddb8c26387a, 2013-05-04 (annotated)
- Committer:
- Rybowonder
- Date:
- Sat May 04 17:37:57 2013 +0000
- Revision:
- 8:6ddb8c26387a
- Parent:
- 6:2f220f5d782d
For Mitchener
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 | 6:2f220f5d782d | 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 | 6:2f220f5d782d | 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 | 8:6ddb8c26387a | 64 | reverse(s); |
Rybowonder | 5:92389cf2106d | 65 | } |
Rybowonder | 5:92389cf2106d | 66 | |
Rybowonder | 8:6ddb8c26387a | 67 | void Constantdisplay::reverse(char *s) |
Rybowonder | 8:6ddb8c26387a | 68 | { |
Rybowonder | 8:6ddb8c26387a | 69 | char *j; |
Rybowonder | 8:6ddb8c26387a | 70 | int c; |
Rybowonder | 8:6ddb8c26387a | 71 | |
Rybowonder | 8:6ddb8c26387a | 72 | j = s + strlen(s) - 1; |
Rybowonder | 8:6ddb8c26387a | 73 | while(s < j) { |
Rybowonder | 8:6ddb8c26387a | 74 | c = *s; |
Rybowonder | 8:6ddb8c26387a | 75 | *s++ = *j; |
Rybowonder | 8:6ddb8c26387a | 76 | *j-- = c; |
Rybowonder | 8:6ddb8c26387a | 77 | } |
Rybowonder | 8:6ddb8c26387a | 78 | } |
Rybowonder | 5:92389cf2106d | 79 | |
Rybowonder | 8:6ddb8c26387a | 80 | |
Rybowonder | 8:6ddb8c26387a | 81 |