Give me permissions so I don't have to fork.
Fork of capstone_display by
display.cpp@10:53ac4447ffd2, 2014-04-25 (annotated)
- Committer:
- ryanyuyu
- Date:
- Fri Apr 25 03:09:10 2014 +0000
- Revision:
- 10:53ac4447ffd2
- Parent:
- 9:057f9952189b
Final (for sure)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmoffat | 0:6846cd4549ba | 1 | #include "st7735.h" |
jmoffat | 0:6846cd4549ba | 2 | #include "display.h" |
jmoffat | 0:6846cd4549ba | 3 | #include "mbed.h" |
jmoffat | 2:c3231b95aff0 | 4 | /** |
jmoffat | 2:c3231b95aff0 | 5 | *See display.h for instructions for functions. |
jmoffat | 2:c3231b95aff0 | 6 | */ |
jmoffat | 0:6846cd4549ba | 7 | display::display(ST7735_LCD *disp) |
jmoffat | 0:6846cd4549ba | 8 | { |
jmoffat | 0:6846cd4549ba | 9 | lcd = disp; |
jmoffat | 0:6846cd4549ba | 10 | lcd->Initialize(); |
jmoffat | 0:6846cd4549ba | 11 | lcd->ClearScreen(); |
jmoffat | 1:a6f341df1ef1 | 12 | |
jmoffat | 0:6846cd4549ba | 13 | } |
jmoffat | 0:6846cd4549ba | 14 | void display::print(char *str) |
jmoffat | 0:6846cd4549ba | 15 | { |
ryanyuyu | 9:057f9952189b | 16 | //lcd->ClearScreen(); |
jmoffat | 0:6846cd4549ba | 17 | lcd->SetFont( &TerminusFont ); |
jmoffat | 0:6846cd4549ba | 18 | lcd->SetForeground(COLOR_BLACK); |
jmoffat | 1:a6f341df1ef1 | 19 | lcd->Print(debugstr, CENTER, 50); |
jmoffat | 1:a6f341df1ef1 | 20 | debugstr = str; |
jmoffat | 0:6846cd4549ba | 21 | lcd->SetForeground(COLOR_WHITE); |
jmoffat | 0:6846cd4549ba | 22 | lcd->Print(str, CENTER, 50); |
jmoffat | 0:6846cd4549ba | 23 | } |
jmoffat | 0:6846cd4549ba | 24 | void display::printrb(const char *str) |
jmoffat | 0:6846cd4549ba | 25 | { |
jmoffat | 0:6846cd4549ba | 26 | lcd->SetForeground(COLOR_RED); |
jmoffat | 0:6846cd4549ba | 27 | lcd->Print(str, CENTER, 0); |
jmoffat | 0:6846cd4549ba | 28 | lcd->SetForeground(COLOR_CYAN); |
jmoffat | 0:6846cd4549ba | 29 | lcd->Print(str, CENTER, 25); |
jmoffat | 0:6846cd4549ba | 30 | lcd->SetForeground(COLOR_YELLOW); |
jmoffat | 0:6846cd4549ba | 31 | lcd->Print(str, CENTER, 50); |
jmoffat | 0:6846cd4549ba | 32 | lcd->SetForeground(COLOR_GREEN); |
jmoffat | 0:6846cd4549ba | 33 | lcd->Print(str, CENTER, 75); |
jmoffat | 0:6846cd4549ba | 34 | |
jmoffat | 0:6846cd4549ba | 35 | |
jmoffat | 0:6846cd4549ba | 36 | |
jmoffat | 0:6846cd4549ba | 37 | } |
jmoffat | 0:6846cd4549ba | 38 | void display::blinktext(const char *str) |
jmoffat | 0:6846cd4549ba | 39 | { |
jmoffat | 0:6846cd4549ba | 40 | lcd->SetForeground(COLOR_GREEN); |
jmoffat | 0:6846cd4549ba | 41 | wait(1); |
jmoffat | 0:6846cd4549ba | 42 | lcd->Print(str, CENTER, 55); |
jmoffat | 0:6846cd4549ba | 43 | lcd->SetForeground(COLOR_BLACK); |
jmoffat | 0:6846cd4549ba | 44 | wait(1); |
jmoffat | 0:6846cd4549ba | 45 | lcd->Print(str, CENTER, 55); |
jmoffat | 0:6846cd4549ba | 46 | } |
jmoffat | 0:6846cd4549ba | 47 | |
jmoffat | 1:a6f341df1ef1 | 48 | void display::displayStr(char *newStrength) |
jmoffat | 0:6846cd4549ba | 49 | { |
ryanyuyu | 7:a2b4e76a5f01 | 50 | //lcd->ClearScreen(); |
jmoffat | 2:c3231b95aff0 | 51 | lcd->SetForeground(COLOR_BLACK);//Set to black to overwrite old text. |
jmoffat | 2:c3231b95aff0 | 52 | lcd->Print("Strength: ", LEFT, 25);//Overwrite old text. |
jmoffat | 1:a6f341df1ef1 | 53 | lcd->Print(strength, CENTER, 25); |
jmoffat | 2:c3231b95aff0 | 54 | strength = newStrength;//Store new text for overwriting later. |
jmoffat | 2:c3231b95aff0 | 55 | lcd->SetForeground(COLOR_WHITE);//Set to white for printing. |
jmoffat | 2:c3231b95aff0 | 56 | lcd->Print("Strength: ", LEFT, 25);//Print. |
jmoffat | 1:a6f341df1ef1 | 57 | lcd->Print(strength, CENTER, 25); |
jmoffat | 1:a6f341df1ef1 | 58 | |
jmoffat | 1:a6f341df1ef1 | 59 | } |
jmoffat | 1:a6f341df1ef1 | 60 | |
jmoffat | 2:c3231b95aff0 | 61 | void display::displayDist(char *newDist)//Works identically to above. |
jmoffat | 1:a6f341df1ef1 | 62 | { |
ryanyuyu | 7:a2b4e76a5f01 | 63 | //lcd->ClearScreen(); |
jmoffat | 1:a6f341df1ef1 | 64 | lcd->SetForeground(COLOR_BLACK); |
jmoffat | 1:a6f341df1ef1 | 65 | lcd->Print("Dist: ", LEFT, 75); |
jmoffat | 1:a6f341df1ef1 | 66 | lcd->Print(dist, CENTER, 75); |
jmoffat | 1:a6f341df1ef1 | 67 | dist = newDist; |
jmoffat | 1:a6f341df1ef1 | 68 | lcd->SetForeground(COLOR_WHITE); |
jmoffat | 1:a6f341df1ef1 | 69 | lcd->Print("Dist: ", LEFT, 75); |
jmoffat | 1:a6f341df1ef1 | 70 | lcd->Print(dist, CENTER, 75); |
jmoffat | 1:a6f341df1ef1 | 71 | |
jmoffat | 3:ee53c9811f62 | 72 | } |
jmoffat | 3:ee53c9811f62 | 73 | void display::calibrationdist(char *str) |
jmoffat | 3:ee53c9811f62 | 74 | { |
jmoffat | 3:ee53c9811f62 | 75 | lcd->ClearScreen(); |
jmoffat | 3:ee53c9811f62 | 76 | lcd->SetForeground(COLOR_RED); |
jmoffat | 3:ee53c9811f62 | 77 | lcd->Print("CALIBRATION", CENTER, 25); |
jmoffat | 3:ee53c9811f62 | 78 | lcd->SetForeground(COLOR_WHITE); |
jmoffat | 3:ee53c9811f62 | 79 | lcd->Print("Place beacon: ", LEFT, 50); |
jmoffat | 3:ee53c9811f62 | 80 | lcd->Print(str, RIGHT, 50); |
jmoffat | 3:ee53c9811f62 | 81 | lcd->Print("Then press button", LEFT, 75); |
jmoffat | 3:ee53c9811f62 | 82 | |
jmoffat | 3:ee53c9811f62 | 83 | |
jmoffat | 3:ee53c9811f62 | 84 | } |
jmoffat | 3:ee53c9811f62 | 85 | void display::calibrationunl(void) |
jmoffat | 3:ee53c9811f62 | 86 | { |
jmoffat | 3:ee53c9811f62 | 87 | lcd->ClearScreen(); |
jmoffat | 3:ee53c9811f62 | 88 | lcd->SetForeground(COLOR_RED); |
jmoffat | 3:ee53c9811f62 | 89 | lcd->Print("CALIBRATION", CENTER, 25); |
jmoffat | 3:ee53c9811f62 | 90 | lcd->SetForeground(COLOR_WHITE); |
jmoffat | 3:ee53c9811f62 | 91 | lcd->Print("Turn off Beacon", LEFT, 50); |
jmoffat | 3:ee53c9811f62 | 92 | lcd->Print("Then press button", LEFT, 75); |
ryanyuyu | 10:53ac4447ffd2 | 93 | lcd->Print("Hold button to skip.", LEFT, 90); |
jmoffat | 3:ee53c9811f62 | 94 | |
jmoffat | 0:6846cd4549ba | 95 | |
ryanyuyu | 8:51ab9f11c992 | 96 | } |
ryanyuyu | 8:51ab9f11c992 | 97 | void display::clearscreen(void) |
ryanyuyu | 8:51ab9f11c992 | 98 | { |
ryanyuyu | 8:51ab9f11c992 | 99 | lcd->ClearScreen(); |
ryanyuyu | 8:51ab9f11c992 | 100 | |
ryanyuyu | 8:51ab9f11c992 | 101 | } |