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.
tampil.cpp@0:c8162f0b59f2, 2015-10-11 (annotated)
- Committer:
- irsanjul
- Date:
- Sun Oct 11 10:44:41 2015 +0000
- Revision:
- 0:c8162f0b59f2
for my others
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
irsanjul | 0:c8162f0b59f2 | 1 | #include "mbed.h" |
irsanjul | 0:c8162f0b59f2 | 2 | #include "tampil.h" |
irsanjul | 0:c8162f0b59f2 | 3 | #include "query.h" |
irsanjul | 0:c8162f0b59f2 | 4 | #include <sstream> |
irsanjul | 0:c8162f0b59f2 | 5 | |
irsanjul | 0:c8162f0b59f2 | 6 | extern Serial dsp; |
irsanjul | 0:c8162f0b59f2 | 7 | extern Serial dbg; |
irsanjul | 0:c8162f0b59f2 | 8 | |
irsanjul | 0:c8162f0b59f2 | 9 | Noritake_VFD_GU7000 vfd; |
irsanjul | 0:c8162f0b59f2 | 10 | |
irsanjul | 0:c8162f0b59f2 | 11 | uint8_t bar[] = {0x03, 0x03, 0x00, 0x0f, 0x0f, 0x00, 0x3f, 0x3f, 0x00, 0xff, 0xff, 0x00}; |
irsanjul | 0:c8162f0b59f2 | 12 | uint8_t bar0[] = {0x00, 0x00, 0x00, 0x00, 0x00}; |
irsanjul | 0:c8162f0b59f2 | 13 | uint8_t bar1[] = {0x01, 0x01, 0x01, 0x01, 0x01}; |
irsanjul | 0:c8162f0b59f2 | 14 | uint8_t bar2[] = {0x05, 0x05, 0x05, 0x05, 0x05}; |
irsanjul | 0:c8162f0b59f2 | 15 | uint8_t bar3[] = {0x15, 0x15, 0x15, 0x15, 0x15}; |
irsanjul | 0:c8162f0b59f2 | 16 | // saat signal > 3 maka bar3 akan dikombinasikan dengan bar4 atau bar5 |
irsanjul | 0:c8162f0b59f2 | 17 | uint8_t bar4[] = {0x55, 0x55, 0x55, 0x55, 0x55}; |
irsanjul | 0:c8162f0b59f2 | 18 | uint8_t bar5[] = {0x55, 0x55, 0x55, 0x55, 0x55}; |
irsanjul | 0:c8162f0b59f2 | 19 | |
irsanjul | 0:c8162f0b59f2 | 20 | |
irsanjul | 0:c8162f0b59f2 | 21 | std::string Convertint(int data) |
irsanjul | 0:c8162f0b59f2 | 22 | { |
irsanjul | 0:c8162f0b59f2 | 23 | std::stringstream c; |
irsanjul | 0:c8162f0b59f2 | 24 | c << data; |
irsanjul | 0:c8162f0b59f2 | 25 | return c.str(); |
irsanjul | 0:c8162f0b59f2 | 26 | } |
irsanjul | 0:c8162f0b59f2 | 27 | |
irsanjul | 0:c8162f0b59f2 | 28 | void display_init() |
irsanjul | 0:c8162f0b59f2 | 29 | { |
irsanjul | 0:c8162f0b59f2 | 30 | vfd.GU7000_cursorOff(); |
irsanjul | 0:c8162f0b59f2 | 31 | vfd.GU7000_clearScreen(); |
irsanjul | 0:c8162f0b59f2 | 32 | } |
irsanjul | 0:c8162f0b59f2 | 33 | |
irsanjul | 0:c8162f0b59f2 | 34 | void displayActive() |
irsanjul | 0:c8162f0b59f2 | 35 | { |
irsanjul | 0:c8162f0b59f2 | 36 | vfd.GU7000_setFontSize(1,1,false); |
irsanjul | 0:c8162f0b59f2 | 37 | vfd.GU7000_setCursor(60,8); |
irsanjul | 0:c8162f0b59f2 | 38 | vfd.print(" "); |
irsanjul | 0:c8162f0b59f2 | 39 | wait_us(100000); |
irsanjul | 0:c8162f0b59f2 | 40 | } |
irsanjul | 0:c8162f0b59f2 | 41 | |
irsanjul | 0:c8162f0b59f2 | 42 | void display_idle() |
irsanjul | 0:c8162f0b59f2 | 43 | { |
irsanjul | 0:c8162f0b59f2 | 44 | vfd.GU7000_setCursor(0,0); |
irsanjul | 0:c8162f0b59f2 | 45 | vfd.GU7000_setFontSize(2,2,false); |
irsanjul | 0:c8162f0b59f2 | 46 | vfd.print("-- -- --"); |
irsanjul | 0:c8162f0b59f2 | 47 | } |
irsanjul | 0:c8162f0b59f2 | 48 | |
irsanjul | 0:c8162f0b59f2 | 49 | void displayChn(int chInd) |
irsanjul | 0:c8162f0b59f2 | 50 | { |
irsanjul | 0:c8162f0b59f2 | 51 | std::string ch; |
irsanjul | 0:c8162f0b59f2 | 52 | ch += "CH"; |
irsanjul | 0:c8162f0b59f2 | 53 | |
irsanjul | 0:c8162f0b59f2 | 54 | if(chInd <= 9) |
irsanjul | 0:c8162f0b59f2 | 55 | { |
irsanjul | 0:c8162f0b59f2 | 56 | ch += " "; |
irsanjul | 0:c8162f0b59f2 | 57 | ch += Convertint(chInd); |
irsanjul | 0:c8162f0b59f2 | 58 | } |
irsanjul | 0:c8162f0b59f2 | 59 | else ch += Convertint(chInd); |
irsanjul | 0:c8162f0b59f2 | 60 | |
irsanjul | 0:c8162f0b59f2 | 61 | vfd.GU7000_setCursor(0,0); |
irsanjul | 0:c8162f0b59f2 | 62 | vfd.GU7000_setFontSize(2,2,false); |
irsanjul | 0:c8162f0b59f2 | 63 | vfd.print(ch.c_str()); |
irsanjul | 0:c8162f0b59f2 | 64 | } |
irsanjul | 0:c8162f0b59f2 | 65 | |
irsanjul | 0:c8162f0b59f2 | 66 | void displaySig(int sig) |
irsanjul | 0:c8162f0b59f2 | 67 | { |
irsanjul | 0:c8162f0b59f2 | 68 | /* |
irsanjul | 0:c8162f0b59f2 | 69 | vfd.GU7000_setCursor(100,0); |
irsanjul | 0:c8162f0b59f2 | 70 | vfd.GU7000_drawImage(3*sig, 0x08, bar); |
irsanjul | 0:c8162f0b59f2 | 71 | |
irsanjul | 0:c8162f0b59f2 | 72 | if(sig <= -105) |
irsanjul | 0:c8162f0b59f2 | 73 | { |
irsanjul | 0:c8162f0b59f2 | 74 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 75 | vfd.GU7000_drawImage(5, 0x08, bar0); |
irsanjul | 0:c8162f0b59f2 | 76 | } |
irsanjul | 0:c8162f0b59f2 | 77 | else if((sig > -105) && (sig < -93)) |
irsanjul | 0:c8162f0b59f2 | 78 | { |
irsanjul | 0:c8162f0b59f2 | 79 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 80 | vfd.GU7000_drawImage(5, 0x08, bar1); |
irsanjul | 0:c8162f0b59f2 | 81 | } |
irsanjul | 0:c8162f0b59f2 | 82 | else if((sig >= -93) && (sig < -81)) |
irsanjul | 0:c8162f0b59f2 | 83 | { |
irsanjul | 0:c8162f0b59f2 | 84 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 85 | vfd.GU7000_drawImage(5, 0x08, bar2); |
irsanjul | 0:c8162f0b59f2 | 86 | } |
irsanjul | 0:c8162f0b59f2 | 87 | else if((sig >= -81) && (sig < -69)) |
irsanjul | 0:c8162f0b59f2 | 88 | { |
irsanjul | 0:c8162f0b59f2 | 89 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 90 | vfd.GU7000_drawImage(5, 0x08, bar3); |
irsanjul | 0:c8162f0b59f2 | 91 | } |
irsanjul | 0:c8162f0b59f2 | 92 | else if((sig >= -69) && (sig < -57)) |
irsanjul | 0:c8162f0b59f2 | 93 | { |
irsanjul | 0:c8162f0b59f2 | 94 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 95 | vfd.GU7000_drawImage(5, 0x08, bar4); |
irsanjul | 0:c8162f0b59f2 | 96 | |
irsanjul | 0:c8162f0b59f2 | 97 | } |
irsanjul | 0:c8162f0b59f2 | 98 | else if(sig >= -57) |
irsanjul | 0:c8162f0b59f2 | 99 | { |
irsanjul | 0:c8162f0b59f2 | 100 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 101 | vfd.GU7000_drawImage(5, 0x08, bar5); |
irsanjul | 0:c8162f0b59f2 | 102 | }*/ |
irsanjul | 0:c8162f0b59f2 | 103 | switch(sig) |
irsanjul | 0:c8162f0b59f2 | 104 | { |
irsanjul | 0:c8162f0b59f2 | 105 | case 0:{ |
irsanjul | 0:c8162f0b59f2 | 106 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 107 | vfd.GU7000_drawImage(5, 0x08, bar0); |
irsanjul | 0:c8162f0b59f2 | 108 | break; |
irsanjul | 0:c8162f0b59f2 | 109 | } |
irsanjul | 0:c8162f0b59f2 | 110 | case 1:{ |
irsanjul | 0:c8162f0b59f2 | 111 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 112 | vfd.GU7000_drawImage(5, 0x08, bar1); |
irsanjul | 0:c8162f0b59f2 | 113 | break; |
irsanjul | 0:c8162f0b59f2 | 114 | } |
irsanjul | 0:c8162f0b59f2 | 115 | case 2:{ |
irsanjul | 0:c8162f0b59f2 | 116 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 117 | vfd.GU7000_drawImage(5, 0x08, bar2); |
irsanjul | 0:c8162f0b59f2 | 118 | break; |
irsanjul | 0:c8162f0b59f2 | 119 | } |
irsanjul | 0:c8162f0b59f2 | 120 | case 3:{ |
irsanjul | 0:c8162f0b59f2 | 121 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 122 | vfd.GU7000_drawImage(5, 0x08, bar3); |
irsanjul | 0:c8162f0b59f2 | 123 | break; |
irsanjul | 0:c8162f0b59f2 | 124 | } |
irsanjul | 0:c8162f0b59f2 | 125 | case 4:{ |
irsanjul | 0:c8162f0b59f2 | 126 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 127 | vfd.GU7000_drawImage(5, 0x08, bar4); |
irsanjul | 0:c8162f0b59f2 | 128 | break; |
irsanjul | 0:c8162f0b59f2 | 129 | } |
irsanjul | 0:c8162f0b59f2 | 130 | case 5:{ |
irsanjul | 0:c8162f0b59f2 | 131 | vfd.GU7000_setCursor(106,0); |
irsanjul | 0:c8162f0b59f2 | 132 | vfd.GU7000_drawImage(5, 0x08, bar5); |
irsanjul | 0:c8162f0b59f2 | 133 | break; |
irsanjul | 0:c8162f0b59f2 | 134 | } |
irsanjul | 0:c8162f0b59f2 | 135 | } |
irsanjul | 0:c8162f0b59f2 | 136 | } |
irsanjul | 0:c8162f0b59f2 | 137 | |
irsanjul | 0:c8162f0b59f2 | 138 | void displaySts(const char *sts) |
irsanjul | 0:c8162f0b59f2 | 139 | { |
irsanjul | 0:c8162f0b59f2 | 140 | vfd.GU7000_setFontSize(1,1,false); |
irsanjul | 0:c8162f0b59f2 | 141 | vfd.GU7000_setCursor(60,8); |
irsanjul | 0:c8162f0b59f2 | 142 | vfd.print(sts); |
irsanjul | 0:c8162f0b59f2 | 143 | // ada tanda untuk menandakan display aktif |
irsanjul | 0:c8162f0b59f2 | 144 | } |
irsanjul | 0:c8162f0b59f2 | 145 | |
irsanjul | 0:c8162f0b59f2 | 146 | void displaySts(int status) |
irsanjul | 0:c8162f0b59f2 | 147 | { |
irsanjul | 0:c8162f0b59f2 | 148 | const char *sts; |
irsanjul | 0:c8162f0b59f2 | 149 | |
irsanjul | 0:c8162f0b59f2 | 150 | switch(status) |
irsanjul | 0:c8162f0b59f2 | 151 | { |
irsanjul | 0:c8162f0b59f2 | 152 | case 0:{ |
irsanjul | 0:c8162f0b59f2 | 153 | sts = "CONNECT"; |
irsanjul | 0:c8162f0b59f2 | 154 | break; |
irsanjul | 0:c8162f0b59f2 | 155 | } |
irsanjul | 0:c8162f0b59f2 | 156 | case 2:{ |
irsanjul | 0:c8162f0b59f2 | 157 | sts = "WAITING"; |
irsanjul | 0:c8162f0b59f2 | 158 | break; |
irsanjul | 0:c8162f0b59f2 | 159 | } |
irsanjul | 0:c8162f0b59f2 | 160 | case 3:{ |
irsanjul | 0:c8162f0b59f2 | 161 | sts = "CONNECT"; |
irsanjul | 0:c8162f0b59f2 | 162 | break; |
irsanjul | 0:c8162f0b59f2 | 163 | } |
irsanjul | 0:c8162f0b59f2 | 164 | case 4:{ |
irsanjul | 0:c8162f0b59f2 | 165 | // mdm.mute(0); mute untuk menghilangkan suara dering dll. 0 = normal, 1 = mute. |
irsanjul | 0:c8162f0b59f2 | 166 | // using => AT+CALM=<value>, AT+CLVL=80, AT+CMUT=0, |
irsanjul | 0:c8162f0b59f2 | 167 | sts = "CALL IN"; |
irsanjul | 0:c8162f0b59f2 | 168 | break; |
irsanjul | 0:c8162f0b59f2 | 169 | } |
irsanjul | 0:c8162f0b59f2 | 170 | case 6:{ |
irsanjul | 0:c8162f0b59f2 | 171 | //mdm.mute(1); |
irsanjul | 0:c8162f0b59f2 | 172 | // AT+CALM=1, AT+CLVL=0, AT+CMUT=1, |
irsanjul | 0:c8162f0b59f2 | 173 | sts = "READY"; |
irsanjul | 0:c8162f0b59f2 | 174 | break; |
irsanjul | 0:c8162f0b59f2 | 175 | } |
irsanjul | 0:c8162f0b59f2 | 176 | } |
irsanjul | 0:c8162f0b59f2 | 177 | |
irsanjul | 0:c8162f0b59f2 | 178 | vfd.GU7000_setFontSize(1,1,false); |
irsanjul | 0:c8162f0b59f2 | 179 | /*vfd.GU7000_setCursor(60,8); |
irsanjul | 0:c8162f0b59f2 | 180 | vfd.print(" "); |
irsanjul | 0:c8162f0b59f2 | 181 | wait_us(10000);*/ |
irsanjul | 0:c8162f0b59f2 | 182 | vfd.GU7000_setCursor(60,8); |
irsanjul | 0:c8162f0b59f2 | 183 | vfd.print(sts); |
irsanjul | 0:c8162f0b59f2 | 184 | } |
irsanjul | 0:c8162f0b59f2 | 185 | |
irsanjul | 0:c8162f0b59f2 | 186 | void displayImg(uint8_t * img, unsigned x, unsigned y, int width) |
irsanjul | 0:c8162f0b59f2 | 187 | { |
irsanjul | 0:c8162f0b59f2 | 188 | vfd.GU7000_setCursor(x,y); |
irsanjul | 0:c8162f0b59f2 | 189 | vfd.GU7000_drawImage(width, 0x08, img); |
irsanjul | 0:c8162f0b59f2 | 190 | wait_us(200); |
irsanjul | 0:c8162f0b59f2 | 191 | } |
irsanjul | 0:c8162f0b59f2 | 192 | |
irsanjul | 0:c8162f0b59f2 | 193 | void displayClr() |
irsanjul | 0:c8162f0b59f2 | 194 | { |
irsanjul | 0:c8162f0b59f2 | 195 | vfd.GU7000_setFontSize(2,2,false); |
irsanjul | 0:c8162f0b59f2 | 196 | vfd.print(" "); |
irsanjul | 0:c8162f0b59f2 | 197 | vfd.GU7000_setFontSize(1,1,false); |
irsanjul | 0:c8162f0b59f2 | 198 | vfd.GU7000_clearScreen(); |
irsanjul | 0:c8162f0b59f2 | 199 | } |
irsanjul | 0:c8162f0b59f2 | 200 | |
irsanjul | 0:c8162f0b59f2 | 201 | void displayStd(time_t &dt) |
irsanjul | 0:c8162f0b59f2 | 202 | { |
irsanjul | 0:c8162f0b59f2 | 203 | tm *ptm = localtime(&dt); |
irsanjul | 0:c8162f0b59f2 | 204 | char buf1[20]; |
irsanjul | 0:c8162f0b59f2 | 205 | char buf2[20]; |
irsanjul | 0:c8162f0b59f2 | 206 | strftime(buf1,20,"%H:%M", ptm); |
irsanjul | 0:c8162f0b59f2 | 207 | strftime(buf2,20,"%H %M", ptm); |
irsanjul | 0:c8162f0b59f2 | 208 | vfd.GU7000_setFontSize(3,2,false); |
irsanjul | 0:c8162f0b59f2 | 209 | vfd.print(buf1); |
irsanjul | 0:c8162f0b59f2 | 210 | wait_us(100000); |
irsanjul | 0:c8162f0b59f2 | 211 | vfd.print(buf2); |
irsanjul | 0:c8162f0b59f2 | 212 | } |