![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
This ih my prototipe program for displaying to vfd Noritake via SC16IS752 (i2c to Serial). for program which i use, i say sorry and you can message me for i publish. thank
Dependencies: Noritake SC16IS752 mbed
Fork of 08_SCT_menu by
main.cpp@1:da53a4d93c33, 2016-08-12 (annotated)
- Committer:
- irsanjul
- Date:
- Fri Aug 12 04:37:13 2016 +0000
- Revision:
- 1:da53a4d93c33
- Parent:
- 0:51be68b5e97c
My Prototipe
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
irsanjul | 0:51be68b5e97c | 1 | /** |
irsanjul | 0:51be68b5e97c | 2 | LPC1768 adalah program display noritake yang digabungkan dengan |
irsanjul | 0:51be68b5e97c | 3 | pogram i2c to serial SC16IS752. |
irsanjul | 0:51be68b5e97c | 4 | **/ |
irsanjul | 0:51be68b5e97c | 5 | |
irsanjul | 0:51be68b5e97c | 6 | #include "mbed.h" |
irsanjul | 0:51be68b5e97c | 7 | #include "query.h" |
irsanjul | 1:da53a4d93c33 | 8 | #include "Katakata.h" |
irsanjul | 1:da53a4d93c33 | 9 | #include <sstream> |
irsanjul | 1:da53a4d93c33 | 10 | #include <vector> |
irsanjul | 0:51be68b5e97c | 11 | |
irsanjul | 0:51be68b5e97c | 12 | DigitalOut myled(LED1); |
irsanjul | 0:51be68b5e97c | 13 | Serial dbg(USBTX, USBRX); |
irsanjul | 0:51be68b5e97c | 14 | Noritake_VFD_GU7000 vfd(p28, p27); |
irsanjul | 0:51be68b5e97c | 15 | |
irsanjul | 1:da53a4d93c33 | 16 | void Display_init() |
irsanjul | 0:51be68b5e97c | 17 | { |
irsanjul | 0:51be68b5e97c | 18 | vfd.GU7000_cursorOff(); |
irsanjul | 0:51be68b5e97c | 19 | vfd.GU7000_clearScreen(); |
irsanjul | 1:da53a4d93c33 | 20 | } |
irsanjul | 1:da53a4d93c33 | 21 | |
irsanjul | 1:da53a4d93c33 | 22 | void Main_Menu() |
irsanjul | 1:da53a4d93c33 | 23 | { |
irsanjul | 1:da53a4d93c33 | 24 | vector<uint8_t> Vdat; |
irsanjul | 0:51be68b5e97c | 25 | |
irsanjul | 1:da53a4d93c33 | 26 | Vdat.insert(Vdat.begin(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 27 | for(int i=0; i<strlen(MMe); i++) |
irsanjul | 1:da53a4d93c33 | 28 | Vdat.push_back((uint8_t) MMe[i]); |
irsanjul | 1:da53a4d93c33 | 29 | Vdat.insert(Vdat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 30 | |
irsanjul | 1:da53a4d93c33 | 31 | Vdat.insert(Vdat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 32 | for(int i=0; i<strlen(Sat); i++) |
irsanjul | 1:da53a4d93c33 | 33 | Vdat.push_back((uint8_t) Sat[i]); |
irsanjul | 1:da53a4d93c33 | 34 | Vdat.insert(Vdat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 35 | for(int i=0; i<strlen(Ent); i++) |
irsanjul | 1:da53a4d93c33 | 36 | Vdat.push_back((uint8_t) Ent[i]); |
irsanjul | 1:da53a4d93c33 | 37 | |
irsanjul | 1:da53a4d93c33 | 38 | Vdat.insert(Vdat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 39 | for(int i=0; i<strlen(Dua); i++) |
irsanjul | 1:da53a4d93c33 | 40 | Vdat.push_back((uint8_t) Dua[i]); |
irsanjul | 1:da53a4d93c33 | 41 | Vdat.insert(Vdat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 42 | for(int i=0; i<strlen(Exi); i++) |
irsanjul | 1:da53a4d93c33 | 43 | Vdat.push_back((uint8_t) Exi[i]); |
irsanjul | 1:da53a4d93c33 | 44 | |
irsanjul | 1:da53a4d93c33 | 45 | Vdat.insert(Vdat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 46 | for(int i=0; i<strlen(Tig); i++) |
irsanjul | 1:da53a4d93c33 | 47 | Vdat.push_back((uint8_t) Tig[i]); |
irsanjul | 1:da53a4d93c33 | 48 | Vdat.insert(Vdat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 49 | for(int i=0; i<strlen(SCo); i++) |
irsanjul | 1:da53a4d93c33 | 50 | Vdat.push_back((uint8_t) SCo[i]); |
irsanjul | 1:da53a4d93c33 | 51 | |
irsanjul | 1:da53a4d93c33 | 52 | Vdat.insert(Vdat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 53 | for(int i=0; i<strlen(Emp); i++) |
irsanjul | 1:da53a4d93c33 | 54 | Vdat.push_back((uint8_t) Emp[i]); |
irsanjul | 1:da53a4d93c33 | 55 | Vdat.insert(Vdat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 56 | for(int i=0; i<strlen(SKe); i++) |
irsanjul | 1:da53a4d93c33 | 57 | Vdat.push_back((uint8_t) SKe[i]); |
irsanjul | 1:da53a4d93c33 | 58 | |
irsanjul | 1:da53a4d93c33 | 59 | Vdat.insert(Vdat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 60 | for(int i=0; i<strlen(Lim); i++) |
irsanjul | 1:da53a4d93c33 | 61 | Vdat.push_back((uint8_t) Lim[i]); |
irsanjul | 1:da53a4d93c33 | 62 | Vdat.insert(Vdat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 63 | for(int i=0; i<strlen(MDa); i++) |
irsanjul | 1:da53a4d93c33 | 64 | Vdat.push_back((uint8_t) MDa[i]); |
irsanjul | 1:da53a4d93c33 | 65 | |
irsanjul | 1:da53a4d93c33 | 66 | uint8_t tmp[128]; |
irsanjul | 1:da53a4d93c33 | 67 | copy(Vdat.begin(), Vdat.end(), tmp); |
irsanjul | 1:da53a4d93c33 | 68 | const uint8_t* data = tmp; |
irsanjul | 1:da53a4d93c33 | 69 | vfd.print(data, Vdat.size()); |
irsanjul | 1:da53a4d93c33 | 70 | Vdat.clear(); |
irsanjul | 1:da53a4d93c33 | 71 | } |
irsanjul | 1:da53a4d93c33 | 72 | |
irsanjul | 1:da53a4d93c33 | 73 | int PreMenu = 0; // 0=Main Menu; 1=Entrance; 2=Exit; 3=Set Config; 4=Set Key; 5=Mode Data |
irsanjul | 1:da53a4d93c33 | 74 | void Sub_Menu(int Menu) |
irsanjul | 1:da53a4d93c33 | 75 | { |
irsanjul | 1:da53a4d93c33 | 76 | if(Menu != PreMenu) |
irsanjul | 1:da53a4d93c33 | 77 | { |
irsanjul | 1:da53a4d93c33 | 78 | vfd.GU7000_clearScreen(); |
irsanjul | 1:da53a4d93c33 | 79 | PreMenu = Menu; |
irsanjul | 1:da53a4d93c33 | 80 | } |
irsanjul | 1:da53a4d93c33 | 81 | |
irsanjul | 1:da53a4d93c33 | 82 | if(Menu == 0) |
irsanjul | 1:da53a4d93c33 | 83 | { |
irsanjul | 1:da53a4d93c33 | 84 | Main_Menu(); |
irsanjul | 1:da53a4d93c33 | 85 | } |
irsanjul | 1:da53a4d93c33 | 86 | |
irsanjul | 1:da53a4d93c33 | 87 | vector<uint8_t> dat; |
irsanjul | 1:da53a4d93c33 | 88 | |
irsanjul | 1:da53a4d93c33 | 89 | // Set Header |
irsanjul | 1:da53a4d93c33 | 90 | switch(Menu) |
irsanjul | 0:51be68b5e97c | 91 | { |
irsanjul | 1:da53a4d93c33 | 92 | case 0: break; |
irsanjul | 1:da53a4d93c33 | 93 | case 1: dat.insert(dat.begin(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 94 | for(int i=0; i<strlen(MEn); i++) |
irsanjul | 1:da53a4d93c33 | 95 | dat.push_back((uint8_t) MEn[i]); |
irsanjul | 1:da53a4d93c33 | 96 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 97 | break; |
irsanjul | 1:da53a4d93c33 | 98 | |
irsanjul | 1:da53a4d93c33 | 99 | case 2: dat.insert(dat.begin(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 100 | for(int i=0; i<strlen(MEx); i++) |
irsanjul | 1:da53a4d93c33 | 101 | dat.push_back((uint8_t) MEx[i]); |
irsanjul | 1:da53a4d93c33 | 102 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 103 | break; |
irsanjul | 1:da53a4d93c33 | 104 | |
irsanjul | 1:da53a4d93c33 | 105 | case 3: dat.insert(dat.begin(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 106 | for(int i=0; i<strlen(MKo); i++) |
irsanjul | 1:da53a4d93c33 | 107 | dat.push_back((uint8_t) MKo[i]); |
irsanjul | 1:da53a4d93c33 | 108 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 109 | break; |
irsanjul | 1:da53a4d93c33 | 110 | |
irsanjul | 1:da53a4d93c33 | 111 | case 4: dat.insert(dat.begin(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 112 | for(int i=0; i<strlen(Set); i++) |
irsanjul | 1:da53a4d93c33 | 113 | dat.push_back((uint8_t) Set[i]); |
irsanjul | 1:da53a4d93c33 | 114 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 115 | break; |
irsanjul | 1:da53a4d93c33 | 116 | |
irsanjul | 1:da53a4d93c33 | 117 | case 5: dat.insert(dat.begin(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 118 | for(int i=0; i<strlen(Mod); i++) |
irsanjul | 1:da53a4d93c33 | 119 | dat.push_back((uint8_t) Mod[i]); |
irsanjul | 1:da53a4d93c33 | 120 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 121 | dat.push_back('\n'); |
irsanjul | 1:da53a4d93c33 | 122 | break; |
irsanjul | 1:da53a4d93c33 | 123 | |
irsanjul | 1:da53a4d93c33 | 124 | case 6: dat.insert(dat.begin(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 125 | for(int i=0; i<strlen(Mod); i++) |
irsanjul | 1:da53a4d93c33 | 126 | dat.push_back((uint8_t) Mod[i]); |
irsanjul | 1:da53a4d93c33 | 127 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 128 | for(int i=0; i<strlen(His); i++) |
irsanjul | 1:da53a4d93c33 | 129 | dat.push_back((uint8_t) His[i]); |
irsanjul | 1:da53a4d93c33 | 130 | break; |
irsanjul | 1:da53a4d93c33 | 131 | } |
irsanjul | 1:da53a4d93c33 | 132 | |
irsanjul | 1:da53a4d93c33 | 133 | if(Menu != 0) |
irsanjul | 1:da53a4d93c33 | 134 | { |
irsanjul | 1:da53a4d93c33 | 135 | for(int i=0; i<strlen(Mas); i++) |
irsanjul | 1:da53a4d93c33 | 136 | dat.push_back((uint8_t) Mas[i]); |
irsanjul | 0:51be68b5e97c | 137 | } |
irsanjul | 1:da53a4d93c33 | 138 | |
irsanjul | 1:da53a4d93c33 | 139 | // Set Body |
irsanjul | 1:da53a4d93c33 | 140 | switch(Menu) |
irsanjul | 1:da53a4d93c33 | 141 | { |
irsanjul | 1:da53a4d93c33 | 142 | case 0: break; |
irsanjul | 1:da53a4d93c33 | 143 | case 1: |
irsanjul | 1:da53a4d93c33 | 144 | case 2: for(int i=0; i<strlen(PAS); i++) |
irsanjul | 1:da53a4d93c33 | 145 | dat.push_back((uint8_t) PAS[i]); |
irsanjul | 1:da53a4d93c33 | 146 | break; |
irsanjul | 1:da53a4d93c33 | 147 | |
irsanjul | 1:da53a4d93c33 | 148 | case 3: |
irsanjul | 1:da53a4d93c33 | 149 | case 4: for(int i=0; i<strlen(MTN); i++) |
irsanjul | 1:da53a4d93c33 | 150 | dat.push_back((uint8_t) MTN[i]); |
irsanjul | 1:da53a4d93c33 | 151 | break; |
irsanjul | 1:da53a4d93c33 | 152 | |
irsanjul | 1:da53a4d93c33 | 153 | case 5: for(int i=0; i<strlen(PUL); i++) |
irsanjul | 1:da53a4d93c33 | 154 | dat.push_back((uint8_t) PUL[i]); |
irsanjul | 1:da53a4d93c33 | 155 | break; |
irsanjul | 1:da53a4d93c33 | 156 | |
irsanjul | 1:da53a4d93c33 | 157 | case 6: for(int i=0; i<strlen(ENT); i++) |
irsanjul | 1:da53a4d93c33 | 158 | dat.push_back((uint8_t) ENT[i]); |
irsanjul | 1:da53a4d93c33 | 159 | break; |
irsanjul | 1:da53a4d93c33 | 160 | } |
irsanjul | 1:da53a4d93c33 | 161 | |
irsanjul | 1:da53a4d93c33 | 162 | // Set Footer |
irsanjul | 1:da53a4d93c33 | 163 | switch(Menu) |
irsanjul | 1:da53a4d93c33 | 164 | { |
irsanjul | 1:da53a4d93c33 | 165 | case 0: break; |
irsanjul | 1:da53a4d93c33 | 166 | case 6: |
irsanjul | 1:da53a4d93c33 | 167 | case 1: |
irsanjul | 1:da53a4d93c33 | 168 | case 2: |
irsanjul | 1:da53a4d93c33 | 169 | case 3: |
irsanjul | 1:da53a4d93c33 | 170 | case 4: dat.insert(dat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 171 | for(int i=0; i<strlen(Noo); i++) |
irsanjul | 1:da53a4d93c33 | 172 | dat.push_back((uint8_t) Noo[i]); |
irsanjul | 1:da53a4d93c33 | 173 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 174 | for(int i=0; i<strlen(Bat); i++) |
irsanjul | 1:da53a4d93c33 | 175 | dat.push_back((uint8_t) Bat[i]); |
irsanjul | 1:da53a4d93c33 | 176 | break; |
irsanjul | 1:da53a4d93c33 | 177 | |
irsanjul | 1:da53a4d93c33 | 178 | case 5: dat.insert(dat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 179 | for(int i=0; i<strlen(Yes); i++) |
irsanjul | 1:da53a4d93c33 | 180 | dat.push_back((uint8_t) Yes[i]); |
irsanjul | 1:da53a4d93c33 | 181 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 182 | for(int i=0; i<strlen(Lan); i++) |
irsanjul | 1:da53a4d93c33 | 183 | dat.push_back((uint8_t) Lan[i]); |
irsanjul | 1:da53a4d93c33 | 184 | dat.insert(dat.end(), invertOn, invertOn+sizeof(invertOn)); |
irsanjul | 1:da53a4d93c33 | 185 | for(int i=0; i<strlen(Noo); i++) |
irsanjul | 1:da53a4d93c33 | 186 | dat.push_back((uint8_t) Noo[i]); |
irsanjul | 1:da53a4d93c33 | 187 | dat.insert(dat.end(), invertOff, invertOff+sizeof(invertOff)); |
irsanjul | 1:da53a4d93c33 | 188 | for(int i=0; i<strlen(Bat); i++) |
irsanjul | 1:da53a4d93c33 | 189 | dat.push_back((uint8_t) Bat[i]); |
irsanjul | 1:da53a4d93c33 | 190 | break; |
irsanjul | 1:da53a4d93c33 | 191 | } |
irsanjul | 1:da53a4d93c33 | 192 | |
irsanjul | 1:da53a4d93c33 | 193 | uint8_t tmp[128]; |
irsanjul | 1:da53a4d93c33 | 194 | copy(dat.begin(), dat.end(), tmp); |
irsanjul | 1:da53a4d93c33 | 195 | const uint8_t* data = tmp; |
irsanjul | 1:da53a4d93c33 | 196 | vfd.print(data, dat.size()); |
irsanjul | 1:da53a4d93c33 | 197 | dat.clear(); |
irsanjul | 1:da53a4d93c33 | 198 | |
irsanjul | 1:da53a4d93c33 | 199 | dbg.printf("Switch Menu is done\r\n"); |
irsanjul | 0:51be68b5e97c | 200 | } |
irsanjul | 1:da53a4d93c33 | 201 | |
irsanjul | 1:da53a4d93c33 | 202 | DigitalOut led(LED1); |
irsanjul | 1:da53a4d93c33 | 203 | Ticker run; |
irsanjul | 1:da53a4d93c33 | 204 | void runled() |
irsanjul | 1:da53a4d93c33 | 205 | { |
irsanjul | 1:da53a4d93c33 | 206 | led =! led; |
irsanjul | 1:da53a4d93c33 | 207 | } |
irsanjul | 1:da53a4d93c33 | 208 | |
irsanjul | 1:da53a4d93c33 | 209 | int main() |
irsanjul | 1:da53a4d93c33 | 210 | { |
irsanjul | 1:da53a4d93c33 | 211 | run.attach(&runled, 0.5); |
irsanjul | 1:da53a4d93c33 | 212 | Display_init(); |
irsanjul | 1:da53a4d93c33 | 213 | Main_Menu(); |
irsanjul | 1:da53a4d93c33 | 214 | set_time(1256729737); |
irsanjul | 1:da53a4d93c33 | 215 | while(1) |
irsanjul | 1:da53a4d93c33 | 216 | { |
irsanjul | 1:da53a4d93c33 | 217 | time_t t = time(NULL); |
irsanjul | 1:da53a4d93c33 | 218 | char buf[32]; |
irsanjul | 1:da53a4d93c33 | 219 | strftime(buf, 32, "%d/%m/%y %H:%M:%S", localtime(&t)); |
irsanjul | 1:da53a4d93c33 | 220 | vfd.printAt(1, 8, buf); |
irsanjul | 1:da53a4d93c33 | 221 | |
irsanjul | 1:da53a4d93c33 | 222 | vfd.GU7000_drawImageAt(122, 56, 6, 8, sym); |
irsanjul | 1:da53a4d93c33 | 223 | } |
irsanjul | 1:da53a4d93c33 | 224 | |
irsanjul | 1:da53a4d93c33 | 225 | } |