test
Dependencies: MINI8I8O5A000 mbed EEPROM_P4 IICLCD_LOWCOST
main.cpp@11:c3151cd10c88, 2017-09-27 (annotated)
- Committer:
- tsuparit
- Date:
- Wed Sep 27 09:01:30 2017 +0000
- Revision:
- 11:c3151cd10c88
- Parent:
- 10:c58ec47d206c
- Child:
- 12:d97af85a47f9
Update Scene Changing Signal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tsuparit | 6:96d89c2f4bf9 | 1 | float firmware_version = 1.20; |
tsuparit | 0:5e60f85d6c26 | 2 | |
tsuparit | 10:c58ec47d206c | 3 | #define TRIGGER_0 1 |
tsuparit | 10:c58ec47d206c | 4 | #define TRIGGER_1 0 |
tsuparit | 10:c58ec47d206c | 5 | |
tsuparit | 0:5e60f85d6c26 | 6 | #include "mbed.h" |
tsuparit | 2:82dbbbff7518 | 7 | |
tsuparit | 11:c3151cd10c88 | 8 | #define BUZZVSP7 // Enable P7 for Buzzer.. |
tsuparit | 11:c3151cd10c88 | 9 | |
tsuparit | 11:c3151cd10c88 | 10 | |
tsuparit | 2:82dbbbff7518 | 11 | //#include "USBSerial.h" |
tsuparit | 11:c3151cd10c88 | 12 | |
tsuparit | 2:82dbbbff7518 | 13 | |
tsuparit | 2:82dbbbff7518 | 14 | |
tsuparit | 2:82dbbbff7518 | 15 | |
tsuparit | 2:82dbbbff7518 | 16 | //#define USBSerialOption |
tsuparit | 2:82dbbbff7518 | 17 | |
tsuparit | 2:82dbbbff7518 | 18 | #ifdef USBSerialOption |
tsuparit | 2:82dbbbff7518 | 19 | #include "USBSerial.h" |
tsuparit | 2:82dbbbff7518 | 20 | USBSerial pc; |
tsuparit | 7:3cb877cb7393 | 21 | |
tsuparit | 2:82dbbbff7518 | 22 | #else |
tsuparit | 2:82dbbbff7518 | 23 | |
tsuparit | 4:c08d713f8cfc | 24 | //Serial pc(USBTX, USBRX); // SDA serail port |
tsuparit | 4:c08d713f8cfc | 25 | Serial pc(PTE0, PTE1); // tx, rx |
tsuparit | 2:82dbbbff7518 | 26 | #endif |
tsuparit | 2:82dbbbff7518 | 27 | |
tsuparit | 2:82dbbbff7518 | 28 | |
tsuparit | 2:82dbbbff7518 | 29 | |
tsuparit | 0:5e60f85d6c26 | 30 | #include "LiquidCrystal_I2C.h" |
tsuparit | 0:5e60f85d6c26 | 31 | #include "mini8i8o5a.h" |
tsuparit | 0:5e60f85d6c26 | 32 | #define EEPROMBUFFERSIZE 16 |
tsuparit | 0:5e60f85d6c26 | 33 | #include "eepromlib.h" |
tsuparit | 0:5e60f85d6c26 | 34 | |
tsuparit | 0:5e60f85d6c26 | 35 | |
tsuparit | 0:5e60f85d6c26 | 36 | DigitalOut myled(LED1); |
tsuparit | 0:5e60f85d6c26 | 37 | |
tsuparit | 5:a693866be4b3 | 38 | int loopinilcd=0; |
tsuparit | 0:5e60f85d6c26 | 39 | |
tsuparit | 0:5e60f85d6c26 | 40 | char str[50]; |
tsuparit | 0:5e60f85d6c26 | 41 | char strbuf[50]; |
tsuparit | 0:5e60f85d6c26 | 42 | |
tsuparit | 0:5e60f85d6c26 | 43 | |
tsuparit | 0:5e60f85d6c26 | 44 | int rxchar_count=0; |
tsuparit | 0:5e60f85d6c26 | 45 | #define RXBUFFERSIZE 100 |
tsuparit | 0:5e60f85d6c26 | 46 | char rx_buffer[RXBUFFERSIZE]; |
tsuparit | 0:5e60f85d6c26 | 47 | char rx_buffer_CMD[RXBUFFERSIZE]; |
tsuparit | 0:5e60f85d6c26 | 48 | char rx_buffer_ARG[RXBUFFERSIZE]; |
tsuparit | 0:5e60f85d6c26 | 49 | char rx_pointer=0; |
tsuparit | 0:5e60f85d6c26 | 50 | char inchar=0; |
tsuparit | 0:5e60f85d6c26 | 51 | |
tsuparit | 0:5e60f85d6c26 | 52 | char remote_control=0; |
tsuparit | 0:5e60f85d6c26 | 53 | |
tsuparit | 0:5e60f85d6c26 | 54 | float ser_para_reset=0; |
tsuparit | 0:5e60f85d6c26 | 55 | //float ser_para_stab=3.25; |
tsuparit | 0:5e60f85d6c26 | 56 | float ser_para_time=1.19; |
tsuparit | 0:5e60f85d6c26 | 57 | float ser_para_result=0.0; |
tsuparit | 0:5e60f85d6c26 | 58 | |
tsuparit | 0:5e60f85d6c26 | 59 | char ser_para_state=0; |
tsuparit | 0:5e60f85d6c26 | 60 | char ser_para_err=0; |
tsuparit | 0:5e60f85d6c26 | 61 | char ser_para_range=0; |
tsuparit | 0:5e60f85d6c26 | 62 | |
tsuparit | 0:5e60f85d6c26 | 63 | char ser_trigger=0; |
tsuparit | 0:5e60f85d6c26 | 64 | char ser_para_cont_mode=1; //serial continue print out |
tsuparit | 0:5e60f85d6c26 | 65 | |
tsuparit | 0:5e60f85d6c26 | 66 | Timer com_timer; |
tsuparit | 0:5e60f85d6c26 | 67 | |
tsuparit | 0:5e60f85d6c26 | 68 | |
tsuparit | 0:5e60f85d6c26 | 69 | char boardaddress =1; |
tsuparit | 0:5e60f85d6c26 | 70 | |
tsuparit | 7:3cb877cb7393 | 71 | |
tsuparit | 7:3cb877cb7393 | 72 | |
tsuparit | 7:3cb877cb7393 | 73 | |
tsuparit | 7:3cb877cb7393 | 74 | int CAMERROR =0; |
tsuparit | 7:3cb877cb7393 | 75 | int CAMTOTAL =0; |
tsuparit | 7:3cb877cb7393 | 76 | #define CAMTRIGGER OUT0 |
tsuparit | 11:c3151cd10c88 | 77 | |
tsuparit | 11:c3151cd10c88 | 78 | #define SCENE_PULSE OUT1 |
tsuparit | 11:c3151cd10c88 | 79 | |
tsuparit | 7:3cb877cb7393 | 80 | #define CAMBUSY IN1 |
tsuparit | 7:3cb877cb7393 | 81 | |
tsuparit | 7:3cb877cb7393 | 82 | |
tsuparit | 0:5e60f85d6c26 | 83 | void serial_pc_rx_services() |
tsuparit | 0:5e60f85d6c26 | 84 | { |
tsuparit | 7:3cb877cb7393 | 85 | int i,j; |
tsuparit | 2:82dbbbff7518 | 86 | #ifdef USBSerialOption |
tsuparit | 2:82dbbbff7518 | 87 | while (pc.available()) |
tsuparit | 2:82dbbbff7518 | 88 | #else |
tsuparit | 2:82dbbbff7518 | 89 | while(pc.readable()) |
tsuparit | 2:82dbbbff7518 | 90 | #endif |
tsuparit | 3:e658376f6e27 | 91 | { |
tsuparit | 3:e658376f6e27 | 92 | inchar =pc.getc(); |
tsuparit | 2:82dbbbff7518 | 93 | if ( rx_pointer==0) //first incoming character clear old buffer |
tsuparit | 0:5e60f85d6c26 | 94 | { |
tsuparit | 0:5e60f85d6c26 | 95 | for (i=0;i<RXBUFFERSIZE;i++) rx_buffer[i]=0; //clear old buffer |
tsuparit | 3:e658376f6e27 | 96 | com_timer.reset(); |
tsuparit | 3:e658376f6e27 | 97 | com_timer.start(); |
tsuparit | 0:5e60f85d6c26 | 98 | } |
tsuparit | 0:5e60f85d6c26 | 99 | |
tsuparit | 5:a693866be4b3 | 100 | loopinilcd=0; |
tsuparit | 2:82dbbbff7518 | 101 | |
tsuparit | 3:e658376f6e27 | 102 | rx_buffer[rx_pointer]=inchar; //keep char in buffer... |
tsuparit | 0:5e60f85d6c26 | 103 | rx_pointer++; |
tsuparit | 7:3cb877cb7393 | 104 | |
tsuparit | 0:5e60f85d6c26 | 105 | if (rx_pointer>=(RXBUFFERSIZE-10)) |
tsuparit | 0:5e60f85d6c26 | 106 | { |
tsuparit | 0:5e60f85d6c26 | 107 | rx_pointer=0;//Error buffer overflow |
tsuparit | 2:82dbbbff7518 | 108 | pc.printf("ERR:buffer overflow\n"); |
tsuparit | 0:5e60f85d6c26 | 109 | } |
tsuparit | 7:3cb877cb7393 | 110 | |
tsuparit | 0:5e60f85d6c26 | 111 | if ((inchar=='\r')|(inchar=='\n')) |
tsuparit | 0:5e60f85d6c26 | 112 | { |
tsuparit | 2:82dbbbff7518 | 113 | |
tsuparit | 0:5e60f85d6c26 | 114 | rx_buffer[rx_pointer-1]=0;//mark end of string, remove terminate char |
tsuparit | 0:5e60f85d6c26 | 115 | |
tsuparit | 0:5e60f85d6c26 | 116 | i=0; |
tsuparit | 0:5e60f85d6c26 | 117 | j=0; |
tsuparit | 0:5e60f85d6c26 | 118 | char cmd_done=0; |
tsuparit | 0:5e60f85d6c26 | 119 | while (rx_buffer[i]!=0) |
tsuparit | 0:5e60f85d6c26 | 120 | { |
tsuparit | 0:5e60f85d6c26 | 121 | if (cmd_done==0) |
tsuparit | 0:5e60f85d6c26 | 122 | { |
tsuparit | 0:5e60f85d6c26 | 123 | rx_buffer_CMD[i]=rx_buffer[i];//copy cmd part |
tsuparit | 0:5e60f85d6c26 | 124 | if (rx_buffer_CMD[i]==' ') |
tsuparit | 0:5e60f85d6c26 | 125 | { |
tsuparit | 0:5e60f85d6c26 | 126 | cmd_done=1; |
tsuparit | 0:5e60f85d6c26 | 127 | rx_buffer_CMD[i+1]=0; |
tsuparit | 0:5e60f85d6c26 | 128 | } |
tsuparit | 0:5e60f85d6c26 | 129 | } |
tsuparit | 0:5e60f85d6c26 | 130 | else |
tsuparit | 0:5e60f85d6c26 | 131 | { |
tsuparit | 0:5e60f85d6c26 | 132 | rx_buffer_ARG[j]=rx_buffer[i];//copy cmd part |
tsuparit | 0:5e60f85d6c26 | 133 | j++; |
tsuparit | 0:5e60f85d6c26 | 134 | } |
tsuparit | 0:5e60f85d6c26 | 135 | i++; |
tsuparit | 0:5e60f85d6c26 | 136 | |
tsuparit | 0:5e60f85d6c26 | 137 | } |
tsuparit | 7:3cb877cb7393 | 138 | |
tsuparit | 1:d9ab13cdf377 | 139 | rx_buffer_ARG[j]=0; //end of string ++++ |
tsuparit | 0:5e60f85d6c26 | 140 | |
tsuparit | 10:c58ec47d206c | 141 | |
tsuparit | 7:3cb877cb7393 | 142 | |
tsuparit | 7:3cb877cb7393 | 143 | #define IDELBUSYLOOP 10000 |
tsuparit | 7:3cb877cb7393 | 144 | BUZZER=1; |
tsuparit | 7:3cb877cb7393 | 145 | |
tsuparit | 7:3cb877cb7393 | 146 | |
tsuparit | 7:3cb877cb7393 | 147 | if (rx_buffer[0]=='t') |
tsuparit | 7:3cb877cb7393 | 148 | { |
tsuparit | 10:c58ec47d206c | 149 | //pulse trigger |
tsuparit | 10:c58ec47d206c | 150 | |
tsuparit | 10:c58ec47d206c | 151 | |
tsuparit | 11:c3151cd10c88 | 152 | SCENE_PULSE=0; |
tsuparit | 11:c3151cd10c88 | 153 | wait(0.050); |
tsuparit | 11:c3151cd10c88 | 154 | SCENE_PULSE=1; |
tsuparit | 11:c3151cd10c88 | 155 | wait(0.050); |
tsuparit | 11:c3151cd10c88 | 156 | |
tsuparit | 10:c58ec47d206c | 157 | |
tsuparit | 10:c58ec47d206c | 158 | CAMTRIGGER=TRIGGER_0; //edge trigger |
tsuparit | 10:c58ec47d206c | 159 | |
tsuparit | 7:3cb877cb7393 | 160 | i=0; |
tsuparit | 7:3cb877cb7393 | 161 | while(1) //wait camera run busy |
tsuparit | 7:3cb877cb7393 | 162 | { |
tsuparit | 7:3cb877cb7393 | 163 | Input_sampling(8); |
tsuparit | 7:3cb877cb7393 | 164 | if(CAMBUSY!=0) break; |
tsuparit | 7:3cb877cb7393 | 165 | if (i++>IDELBUSYLOOP) |
tsuparit | 7:3cb877cb7393 | 166 | { |
tsuparit | 7:3cb877cb7393 | 167 | CAMERROR=1; |
tsuparit | 7:3cb877cb7393 | 168 | break; |
tsuparit | 7:3cb877cb7393 | 169 | } |
tsuparit | 7:3cb877cb7393 | 170 | } |
tsuparit | 7:3cb877cb7393 | 171 | //cmaera process run |
tsuparit | 10:c58ec47d206c | 172 | CAMTRIGGER=TRIGGER_1; //edge trigger |
tsuparit | 7:3cb877cb7393 | 173 | i=0; |
tsuparit | 7:3cb877cb7393 | 174 | while(1) //wait camera complete run |
tsuparit | 7:3cb877cb7393 | 175 | { |
tsuparit | 7:3cb877cb7393 | 176 | Input_sampling(8); |
tsuparit | 7:3cb877cb7393 | 177 | if(CAMBUSY==0) break; |
tsuparit | 7:3cb877cb7393 | 178 | if (i++>IDELBUSYLOOP) |
tsuparit | 7:3cb877cb7393 | 179 | { |
tsuparit | 8:055a85e600dd | 180 | CAMERROR=1; |
tsuparit | 8:055a85e600dd | 181 | break; |
tsuparit | 7:3cb877cb7393 | 182 | } |
tsuparit | 7:3cb877cb7393 | 183 | } |
tsuparit | 7:3cb877cb7393 | 184 | |
tsuparit | 7:3cb877cb7393 | 185 | } |
tsuparit | 7:3cb877cb7393 | 186 | else if (rx_buffer[0]=='j') |
tsuparit | 7:3cb877cb7393 | 187 | { |
tsuparit | 8:055a85e600dd | 188 | // wait(0.1); |
tsuparit | 7:3cb877cb7393 | 189 | } |
tsuparit | 7:3cb877cb7393 | 190 | else if (rx_buffer[0]=='r') |
tsuparit | 7:3cb877cb7393 | 191 | { |
tsuparit | 8:055a85e600dd | 192 | //wait(0.1); |
tsuparit | 7:3cb877cb7393 | 193 | } |
tsuparit | 7:3cb877cb7393 | 194 | else if (rx_buffer[0]=='p') |
tsuparit | 7:3cb877cb7393 | 195 | { |
tsuparit | 8:055a85e600dd | 196 | //wait(0.1); |
tsuparit | 8:055a85e600dd | 197 | #define PRGLINE0 OUT4 |
tsuparit | 8:055a85e600dd | 198 | #define PRGLINE1 OUT5 |
tsuparit | 8:055a85e600dd | 199 | #define PRGLINE2 OUT6 |
tsuparit | 8:055a85e600dd | 200 | #define PRGLINE3 OUT7 |
tsuparit | 11:c3151cd10c88 | 201 | #define PRG_ON 0 |
tsuparit | 8:055a85e600dd | 202 | #define PRG_OFF 1 |
tsuparit | 8:055a85e600dd | 203 | |
tsuparit | 8:055a85e600dd | 204 | switch( rx_buffer[1]) |
tsuparit | 8:055a85e600dd | 205 | { |
tsuparit | 8:055a85e600dd | 206 | case '0': PRGLINE3=PRG_OFF;PRGLINE2=PRG_OFF; PRGLINE1=PRG_OFF; PRGLINE0=PRG_OFF; break; |
tsuparit | 8:055a85e600dd | 207 | case '1': PRGLINE3=PRG_OFF;PRGLINE2=PRG_OFF; PRGLINE1=PRG_OFF; PRGLINE0=PRG_ON ; break; |
tsuparit | 8:055a85e600dd | 208 | case '2': PRGLINE3=PRG_OFF;PRGLINE2=PRG_OFF; PRGLINE1=PRG_ON ; PRGLINE0=PRG_OFF; break; |
tsuparit | 8:055a85e600dd | 209 | case '3': PRGLINE3=PRG_OFF;PRGLINE2=PRG_OFF; PRGLINE1=PRG_ON ; PRGLINE0=PRG_ON ; break; |
tsuparit | 8:055a85e600dd | 210 | case '4': PRGLINE3=PRG_OFF;PRGLINE2=PRG_ON ; PRGLINE1=PRG_OFF; PRGLINE0=PRG_OFF; break; |
tsuparit | 8:055a85e600dd | 211 | case '5': PRGLINE3=PRG_OFF;PRGLINE2=PRG_ON ; PRGLINE1=PRG_OFF; PRGLINE0=PRG_ON; break; |
tsuparit | 8:055a85e600dd | 212 | case '6': PRGLINE3=PRG_OFF;PRGLINE2=PRG_ON ; PRGLINE1=PRG_OFF; PRGLINE0=PRG_ON ; break; |
tsuparit | 8:055a85e600dd | 213 | case '7': PRGLINE3=PRG_OFF;PRGLINE2=PRG_ON ; PRGLINE1=PRG_ON ; PRGLINE0=PRG_ON ; break; |
tsuparit | 8:055a85e600dd | 214 | case '8': PRGLINE3=PRG_ON ;PRGLINE2=PRG_OFF; PRGLINE1=PRG_OFF; PRGLINE0=PRG_OFF; break; |
tsuparit | 8:055a85e600dd | 215 | case '9': PRGLINE3=PRG_ON ;PRGLINE2=PRG_OFF; PRGLINE1=PRG_OFF; PRGLINE0=PRG_ON ; break; |
tsuparit | 7:3cb877cb7393 | 216 | |
tsuparit | 8:055a85e600dd | 217 | default: PRGLINE3=PRG_OFF;PRGLINE2=PRG_OFF; PRGLINE1=PRG_OFF; PRGLINE0=PRG_OFF; break; |
tsuparit | 8:055a85e600dd | 218 | } |
tsuparit | 7:3cb877cb7393 | 219 | } |
tsuparit | 7:3cb877cb7393 | 220 | |
tsuparit | 7:3cb877cb7393 | 221 | BUZZER=0; |
tsuparit | 7:3cb877cb7393 | 222 | Input_sampling(8); |
tsuparit | 7:3cb877cb7393 | 223 | if (IN0) // Total result |
tsuparit | 7:3cb877cb7393 | 224 | { |
tsuparit | 7:3cb877cb7393 | 225 | CAMTOTAL=1; |
tsuparit | 7:3cb877cb7393 | 226 | OUT1=0; |
tsuparit | 7:3cb877cb7393 | 227 | } |
tsuparit | 7:3cb877cb7393 | 228 | else |
tsuparit | 7:3cb877cb7393 | 229 | { |
tsuparit | 7:3cb877cb7393 | 230 | CAMTOTAL=0; |
tsuparit | 7:3cb877cb7393 | 231 | OUT1=1; |
tsuparit | 7:3cb877cb7393 | 232 | } |
tsuparit | 7:3cb877cb7393 | 233 | |
tsuparit | 7:3cb877cb7393 | 234 | |
tsuparit | 7:3cb877cb7393 | 235 | |
tsuparit | 7:3cb877cb7393 | 236 | |
tsuparit | 7:3cb877cb7393 | 237 | //+++++ |
tsuparit | 7:3cb877cb7393 | 238 | pc.printf("%dOK\n",CAMTOTAL+4*CAMERROR); |
tsuparit | 7:3cb877cb7393 | 239 | //pc.printf("123OK"); |
tsuparit | 7:3cb877cb7393 | 240 | //pc.printf("rxbuffer: %s",rx_buffer); //test direct echo |
tsuparit | 7:3cb877cb7393 | 241 | //++++ |
tsuparit | 7:3cb877cb7393 | 242 | |
tsuparit | 2:82dbbbff7518 | 243 | //pc.printf("rxbuffer: %s",rx_buffer); //test direct echo |
tsuparit | 7:3cb877cb7393 | 244 | /* |
tsuparit | 0:5e60f85d6c26 | 245 | if (strcmp(rx_buffer,"*IDN?")==0) |
tsuparit | 0:5e60f85d6c26 | 246 | { |
tsuparit | 0:5e60f85d6c26 | 247 | pc.printf("Schaffner SerIO, ver %.1f\n",firmware_version); |
tsuparit | 0:5e60f85d6c26 | 248 | } |
tsuparit | 0:5e60f85d6c26 | 249 | else if (strcmp(rx_buffer,"*RST")==0) |
tsuparit | 0:5e60f85d6c26 | 250 | { |
tsuparit | 0:5e60f85d6c26 | 251 | pc.printf("Instrumnet Reset\n"); |
tsuparit | 0:5e60f85d6c26 | 252 | ser_para_reset=1; //pass flag stop all operation |
tsuparit | 0:5e60f85d6c26 | 253 | //LCDI2C4Bit_init(); |
tsuparit | 0:5e60f85d6c26 | 254 | LiquidCrystal_I2Cinit(); |
tsuparit | 0:5e60f85d6c26 | 255 | LCDI2C4Bit_clear(); |
tsuparit | 0:5e60f85d6c26 | 256 | //LCDI2C4Bit_backLight(true); |
tsuparit | 0:5e60f85d6c26 | 257 | LiquidCrystal_I2Cbacklight(); |
tsuparit | 0:5e60f85d6c26 | 258 | |
tsuparit | 0:5e60f85d6c26 | 259 | LCDI2C4Bit_cursorTo(0,0); |
tsuparit | 0:5e60f85d6c26 | 260 | sprintf (str," --- RESET ----"); |
tsuparit | 0:5e60f85d6c26 | 261 | LCDI2C4Bit_printIn(str); |
tsuparit | 0:5e60f85d6c26 | 262 | wait(0.25); |
tsuparit | 3:e658376f6e27 | 263 | NVIC_SystemReset();//softreser |
tsuparit | 0:5e60f85d6c26 | 264 | } |
tsuparit | 0:5e60f85d6c26 | 265 | else if (strcmp(rx_buffer,":SYS:VER")==0) |
tsuparit | 0:5e60f85d6c26 | 266 | { |
tsuparit | 0:5e60f85d6c26 | 267 | pc.printf("%.1f\n",firmware_version); |
tsuparit | 0:5e60f85d6c26 | 268 | } |
tsuparit | 0:5e60f85d6c26 | 269 | else if (strcmp(rx_buffer,":SYST:ERR")==0) |
tsuparit | 0:5e60f85d6c26 | 270 | { |
tsuparit | 0:5e60f85d6c26 | 271 | pc.printf("0\n"); |
tsuparit | 0:5e60f85d6c26 | 272 | } |
tsuparit | 0:5e60f85d6c26 | 273 | //else if (strcmp(rx_buffer,"a11000")==0) //Read Input "aX1" |
tsuparit | 0:5e60f85d6c26 | 274 | else if ( (rx_buffer[0]=='a') & (rx_buffer[1]==('0'+boardaddress)) & (rx_buffer[2]=='1')) // Write Output "aX1" |
tsuparit | 0:5e60f85d6c26 | 275 | { |
tsuparit | 3:e658376f6e27 | 276 | pc.printf("%dOK\n",INPUT); |
tsuparit | 0:5e60f85d6c26 | 277 | } |
tsuparit | 0:5e60f85d6c26 | 278 | else if ( (rx_buffer[0]=='a') & (rx_buffer[1]==('0'+boardaddress)) & (rx_buffer[2]=='2')) // Write Output "aX2" |
tsuparit | 0:5e60f85d6c26 | 279 | { |
tsuparit | 2:82dbbbff7518 | 280 | //writer |
tsuparit | 2:82dbbbff7518 | 281 | unsigned char b3,b2,b1; |
tsuparit | 2:82dbbbff7518 | 282 | unsigned int outdata=0; |
tsuparit | 2:82dbbbff7518 | 283 | |
tsuparit | 2:82dbbbff7518 | 284 | if (rx_buffer[3]!=0) |
tsuparit | 2:82dbbbff7518 | 285 | { |
tsuparit | 2:82dbbbff7518 | 286 | outdata=rx_buffer[3]-'0'; |
tsuparit | 2:82dbbbff7518 | 287 | } |
tsuparit | 2:82dbbbff7518 | 288 | if (rx_buffer[4]!=0) |
tsuparit | 2:82dbbbff7518 | 289 | { |
tsuparit | 2:82dbbbff7518 | 290 | outdata=outdata*10+rx_buffer[4]-'0'; |
tsuparit | 2:82dbbbff7518 | 291 | } |
tsuparit | 2:82dbbbff7518 | 292 | if (rx_buffer[5]!=0) |
tsuparit | 2:82dbbbff7518 | 293 | { |
tsuparit | 2:82dbbbff7518 | 294 | outdata=outdata*10+rx_buffer[5]-'0'; |
tsuparit | 2:82dbbbff7518 | 295 | } |
tsuparit | 3:e658376f6e27 | 296 | int OUTBUF=0; |
tsuparit | 3:e658376f6e27 | 297 | if bitchk(outdata,0) {OUT0=ON;OUTBUF=OUTBUF+1;} else OUT0=OFF; |
tsuparit | 3:e658376f6e27 | 298 | if bitchk(outdata,1) {OUT1=ON;OUTBUF=OUTBUF+2;} else OUT1=OFF; |
tsuparit | 3:e658376f6e27 | 299 | if bitchk(outdata,2) {OUT2=ON;OUTBUF=OUTBUF+4;} else OUT2=OFF; |
tsuparit | 3:e658376f6e27 | 300 | if bitchk(outdata,3) {OUT3=ON;OUTBUF=OUTBUF+8;} else OUT3=OFF; |
tsuparit | 2:82dbbbff7518 | 301 | |
tsuparit | 3:e658376f6e27 | 302 | if bitchk(outdata,4) {OUT4=ON;OUTBUF=OUTBUF+16;} else OUT4=OFF; |
tsuparit | 3:e658376f6e27 | 303 | if bitchk(outdata,5) {OUT5=ON;OUTBUF=OUTBUF+32;} else OUT5=OFF; |
tsuparit | 3:e658376f6e27 | 304 | if bitchk(outdata,6) {OUT6=ON;OUTBUF=OUTBUF+64;} else OUT6=OFF; |
tsuparit | 6:96d89c2f4bf9 | 305 | if bitchk(outdata,7) |
tsuparit | 6:96d89c2f4bf9 | 306 | {OUT7=ON;OUTBUF=OUTBUF+128; |
tsuparit | 6:96d89c2f4bf9 | 307 | #ifdef BUZZVSP7 |
tsuparit | 6:96d89c2f4bf9 | 308 | BUZZER=1; |
tsuparit | 6:96d89c2f4bf9 | 309 | #endif |
tsuparit | 6:96d89c2f4bf9 | 310 | |
tsuparit | 6:96d89c2f4bf9 | 311 | } |
tsuparit | 6:96d89c2f4bf9 | 312 | else |
tsuparit | 6:96d89c2f4bf9 | 313 | { |
tsuparit | 6:96d89c2f4bf9 | 314 | #ifdef BUZZVSP7 |
tsuparit | 6:96d89c2f4bf9 | 315 | BUZZER=1; |
tsuparit | 6:96d89c2f4bf9 | 316 | #endif |
tsuparit | 6:96d89c2f4bf9 | 317 | |
tsuparit | 6:96d89c2f4bf9 | 318 | |
tsuparit | 6:96d89c2f4bf9 | 319 | OUT7=OFF; |
tsuparit | 6:96d89c2f4bf9 | 320 | } |
tsuparit | 3:e658376f6e27 | 321 | OUTPUT=OUTBUF; |
tsuparit | 3:e658376f6e27 | 322 | pc.printf("%dOK\n",outdata); |
tsuparit | 0:5e60f85d6c26 | 323 | } |
tsuparit | 0:5e60f85d6c26 | 324 | else if ( (rx_buffer[0]=='a') & (rx_buffer[1]==('0'+boardaddress)) & (rx_buffer[2]=='3')) // Write Output "aX2" |
tsuparit | 0:5e60f85d6c26 | 325 | { |
tsuparit | 3:e658376f6e27 | 326 | pc.printf("%dOK\n",OUTPUT); |
tsuparit | 0:5e60f85d6c26 | 327 | } |
tsuparit | 0:5e60f85d6c26 | 328 | else |
tsuparit | 0:5e60f85d6c26 | 329 | {//unknow / handle comand |
tsuparit | 2:82dbbbff7518 | 330 | //pc.printf( "UNKNOWN %s=>%s,%s\n",rx_buffer,rx_buffer_CMD,rx_buffer_ARG); |
tsuparit | 2:82dbbbff7518 | 331 | pc.printf( "UNKNOWN %s=>%s,%s\n",rx_buffer); |
tsuparit | 7:3cb877cb7393 | 332 | } |
tsuparit | 7:3cb877cb7393 | 333 | |
tsuparit | 7:3cb877cb7393 | 334 | |
tsuparit | 7:3cb877cb7393 | 335 | */ |
tsuparit | 7:3cb877cb7393 | 336 | |
tsuparit | 7:3cb877cb7393 | 337 | |
tsuparit | 7:3cb877cb7393 | 338 | |
tsuparit | 7:3cb877cb7393 | 339 | |
tsuparit | 0:5e60f85d6c26 | 340 | rx_pointer=0;//Reset at the end |
tsuparit | 0:5e60f85d6c26 | 341 | com_timer.stop(); |
tsuparit | 2:82dbbbff7518 | 342 | break;//exit while |
tsuparit | 2:82dbbbff7518 | 343 | } //end foud "terminal of command// |
tsuparit | 2:82dbbbff7518 | 344 | |
tsuparit | 0:5e60f85d6c26 | 345 | |
tsuparit | 2:82dbbbff7518 | 346 | |
tsuparit | 2:82dbbbff7518 | 347 | } //end while data read aviable |
tsuparit | 3:e658376f6e27 | 348 | |
tsuparit | 2:82dbbbff7518 | 349 | |
tsuparit | 0:5e60f85d6c26 | 350 | |
tsuparit | 0:5e60f85d6c26 | 351 | } |
tsuparit | 0:5e60f85d6c26 | 352 | |
tsuparit | 0:5e60f85d6c26 | 353 | |
tsuparit | 0:5e60f85d6c26 | 354 | int main() |
tsuparit | 0:5e60f85d6c26 | 355 | { |
tsuparit | 9:dfb7951e8532 | 356 | int i=0; |
tsuparit | 0:5e60f85d6c26 | 357 | |
tsuparit | 9:dfb7951e8532 | 358 | OUT1=0; |
tsuparit | 0:5e60f85d6c26 | 359 | |
tsuparit | 5:a693866be4b3 | 360 | LiquidCrystal_I2C_SETUP(0x27,20,4); |
tsuparit | 0:5e60f85d6c26 | 361 | LiquidCrystal_I2Cinit(); |
tsuparit | 0:5e60f85d6c26 | 362 | LiquidCrystal_I2Cbacklight(); |
tsuparit | 0:5e60f85d6c26 | 363 | |
tsuparit | 0:5e60f85d6c26 | 364 | LiquidCrystal_I2CsetCursor(0,1); |
tsuparit | 0:5e60f85d6c26 | 365 | sprintf (str, " SCHAFFNER "); |
tsuparit | 0:5e60f85d6c26 | 366 | LCDI2C4Bit_printIn(str); |
tsuparit | 0:5e60f85d6c26 | 367 | LiquidCrystal_I2CsetCursor(0,0); |
tsuparit | 9:dfb7951e8532 | 368 | sprintf (str, "SerailVIS v:%.2f ",1.01) ; |
tsuparit | 0:5e60f85d6c26 | 369 | LCDI2C4Bit_printIn(str); |
tsuparit | 0:5e60f85d6c26 | 370 | |
tsuparit | 2:82dbbbff7518 | 371 | #ifdef USBSerialOption |
tsuparit | 2:82dbbbff7518 | 372 | |
tsuparit | 2:82dbbbff7518 | 373 | #else |
tsuparit | 2:82dbbbff7518 | 374 | pc.baud(9600); // set what you want here depending on your terminal program speed |
tsuparit | 2:82dbbbff7518 | 375 | #endif |
tsuparit | 2:82dbbbff7518 | 376 | |
tsuparit | 0:5e60f85d6c26 | 377 | |
tsuparit | 0:5e60f85d6c26 | 378 | com_timer.start(); |
tsuparit | 0:5e60f85d6c26 | 379 | com_timer.stop(); |
tsuparit | 0:5e60f85d6c26 | 380 | com_timer.reset(); |
tsuparit | 0:5e60f85d6c26 | 381 | |
tsuparit | 3:e658376f6e27 | 382 | wait(0.1); |
tsuparit | 3:e658376f6e27 | 383 | |
tsuparit | 3:e658376f6e27 | 384 | pc.attach(&serial_pc_rx_services); // Use interrupt services !! |
tsuparit | 5:a693866be4b3 | 385 | |
tsuparit | 7:3cb877cb7393 | 386 | OUT1=0; |
tsuparit | 11:c3151cd10c88 | 387 | SCENE_PULSE=1; |
tsuparit | 7:3cb877cb7393 | 388 | |
tsuparit | 7:3cb877cb7393 | 389 | #define BUZZER_EN 0 |
tsuparit | 7:3cb877cb7393 | 390 | |
tsuparit | 9:dfb7951e8532 | 391 | // while(1); |
tsuparit | 9:dfb7951e8532 | 392 | |
tsuparit | 9:dfb7951e8532 | 393 | #define MANUAL_RUNEANABLE |
tsuparit | 9:dfb7951e8532 | 394 | |
tsuparit | 9:dfb7951e8532 | 395 | #ifdef MANUAL_RUNEANABLE |
tsuparit | 10:c58ec47d206c | 396 | CAMTRIGGER=TRIGGER_0; // set signal ready for cam trigger |
tsuparit | 9:dfb7951e8532 | 397 | float analog= 0; |
tsuparit | 9:dfb7951e8532 | 398 | float analogPG=0; |
tsuparit | 7:3cb877cb7393 | 399 | |
tsuparit | 7:3cb877cb7393 | 400 | |
tsuparit | 9:dfb7951e8532 | 401 | load_eeprom(); |
tsuparit | 10:c58ec47d206c | 402 | while(1); //++++++++++++++++++++++++++ |
tsuparit | 10:c58ec47d206c | 403 | |
tsuparit | 9:dfb7951e8532 | 404 | while(1) |
tsuparit | 9:dfb7951e8532 | 405 | { |
tsuparit | 9:dfb7951e8532 | 406 | analog=ain0; //read trigger switch ( analog key ) |
tsuparit | 9:dfb7951e8532 | 407 | analogPG=ain1; //read program number by analog switch |
tsuparit | 9:dfb7951e8532 | 408 | |
tsuparit | 9:dfb7951e8532 | 409 | if (eedata[0]==0) |
tsuparit | 9:dfb7951e8532 | 410 | { |
tsuparit | 9:dfb7951e8532 | 411 | PRGLINE3=PRG_OFF;PRGLINE2=PRG_OFF; PRGLINE1=PRG_OFF; PRGLINE0=PRG_OFF; |
tsuparit | 9:dfb7951e8532 | 412 | LiquidCrystal_I2CsetCursor(0,1); |
tsuparit | 9:dfb7951e8532 | 413 | //sprintf (str, "an:%f ",analog); |
tsuparit | 9:dfb7951e8532 | 414 | sprintf (str, "PG0 "); |
tsuparit | 9:dfb7951e8532 | 415 | LCDI2C4Bit_printIn(str); |
tsuparit | 9:dfb7951e8532 | 416 | |
tsuparit | 9:dfb7951e8532 | 417 | //save_eeprom(); |
tsuparit | 9:dfb7951e8532 | 418 | } |
tsuparit | 9:dfb7951e8532 | 419 | else |
tsuparit | 9:dfb7951e8532 | 420 | { |
tsuparit | 9:dfb7951e8532 | 421 | PRGLINE3=PRG_OFF;PRGLINE2=PRG_OFF; PRGLINE1=PRG_OFF; PRGLINE0=PRG_ON; |
tsuparit | 9:dfb7951e8532 | 422 | LiquidCrystal_I2CsetCursor(0,1); |
tsuparit | 9:dfb7951e8532 | 423 | // sprintf (str, "an:%f ",analog); |
tsuparit | 9:dfb7951e8532 | 424 | sprintf (str, "PG1 "); |
tsuparit | 9:dfb7951e8532 | 425 | LCDI2C4Bit_printIn(str); |
tsuparit | 9:dfb7951e8532 | 426 | } |
tsuparit | 9:dfb7951e8532 | 427 | |
tsuparit | 9:dfb7951e8532 | 428 | if (IN4==0) |
tsuparit | 9:dfb7951e8532 | 429 | { |
tsuparit | 9:dfb7951e8532 | 430 | if (eedata[0]==0) |
tsuparit | 9:dfb7951e8532 | 431 | { |
tsuparit | 9:dfb7951e8532 | 432 | eedata[0]=1; |
tsuparit | 9:dfb7951e8532 | 433 | } |
tsuparit | 9:dfb7951e8532 | 434 | else |
tsuparit | 9:dfb7951e8532 | 435 | { |
tsuparit | 9:dfb7951e8532 | 436 | eedata[0]=0; |
tsuparit | 9:dfb7951e8532 | 437 | } |
tsuparit | 9:dfb7951e8532 | 438 | save_eeprom(); |
tsuparit | 9:dfb7951e8532 | 439 | while(IN4==0); |
tsuparit | 9:dfb7951e8532 | 440 | wait(0.5); |
tsuparit | 9:dfb7951e8532 | 441 | |
tsuparit | 9:dfb7951e8532 | 442 | } |
tsuparit | 9:dfb7951e8532 | 443 | |
tsuparit | 9:dfb7951e8532 | 444 | if (analog<0.6) |
tsuparit | 9:dfb7951e8532 | 445 | { |
tsuparit | 9:dfb7951e8532 | 446 | //++++++++++++++++++++++++++++++++++++++++ |
tsuparit | 9:dfb7951e8532 | 447 | //pulse trigger |
tsuparit | 10:c58ec47d206c | 448 | CAMTRIGGER=TRIGGER_0; //edge trigger |
tsuparit | 9:dfb7951e8532 | 449 | i=0; |
tsuparit | 9:dfb7951e8532 | 450 | while(1) //wait camera run busy |
tsuparit | 9:dfb7951e8532 | 451 | { |
tsuparit | 9:dfb7951e8532 | 452 | Input_sampling(8); |
tsuparit | 9:dfb7951e8532 | 453 | if(CAMBUSY!=0) break; |
tsuparit | 9:dfb7951e8532 | 454 | if (i++>IDELBUSYLOOP) |
tsuparit | 9:dfb7951e8532 | 455 | { |
tsuparit | 9:dfb7951e8532 | 456 | CAMERROR=1; |
tsuparit | 9:dfb7951e8532 | 457 | break; |
tsuparit | 9:dfb7951e8532 | 458 | } |
tsuparit | 9:dfb7951e8532 | 459 | } |
tsuparit | 9:dfb7951e8532 | 460 | //cmaera process run |
tsuparit | 10:c58ec47d206c | 461 | CAMTRIGGER=TRIGGER_1; //edge trigger |
tsuparit | 9:dfb7951e8532 | 462 | i=0; |
tsuparit | 9:dfb7951e8532 | 463 | while(1) //wait camera complete run |
tsuparit | 9:dfb7951e8532 | 464 | { |
tsuparit | 9:dfb7951e8532 | 465 | Input_sampling(8); |
tsuparit | 9:dfb7951e8532 | 466 | if(CAMBUSY==0) break; |
tsuparit | 9:dfb7951e8532 | 467 | if (i++>IDELBUSYLOOP) |
tsuparit | 9:dfb7951e8532 | 468 | { |
tsuparit | 9:dfb7951e8532 | 469 | CAMERROR=1; |
tsuparit | 9:dfb7951e8532 | 470 | break; |
tsuparit | 9:dfb7951e8532 | 471 | } |
tsuparit | 9:dfb7951e8532 | 472 | } |
tsuparit | 9:dfb7951e8532 | 473 | LiquidCrystal_I2CsetCursor(0,0); |
tsuparit | 9:dfb7951e8532 | 474 | sprintf (str, "Trig.. ") ; |
tsuparit | 9:dfb7951e8532 | 475 | LCDI2C4Bit_printIn(str); |
tsuparit | 9:dfb7951e8532 | 476 | |
tsuparit | 9:dfb7951e8532 | 477 | wait(1.0); //wait cam finish process |
tsuparit | 9:dfb7951e8532 | 478 | Input_sampling(8); |
tsuparit | 9:dfb7951e8532 | 479 | if (IN0) // Total result |
tsuparit | 9:dfb7951e8532 | 480 | { |
tsuparit | 9:dfb7951e8532 | 481 | LiquidCrystal_I2CsetCursor(0,0); |
tsuparit | 9:dfb7951e8532 | 482 | sprintf (str, "FAIL.. ") ; |
tsuparit | 9:dfb7951e8532 | 483 | LCDI2C4Bit_printIn(str); |
tsuparit | 9:dfb7951e8532 | 484 | |
tsuparit | 9:dfb7951e8532 | 485 | CAMTOTAL=1; |
tsuparit | 9:dfb7951e8532 | 486 | OUT1=0; |
tsuparit | 9:dfb7951e8532 | 487 | } |
tsuparit | 9:dfb7951e8532 | 488 | else |
tsuparit | 9:dfb7951e8532 | 489 | { |
tsuparit | 9:dfb7951e8532 | 490 | LiquidCrystal_I2CsetCursor(0,0); |
tsuparit | 9:dfb7951e8532 | 491 | sprintf (str, "PASS.. ") ; |
tsuparit | 9:dfb7951e8532 | 492 | LCDI2C4Bit_printIn(str); |
tsuparit | 9:dfb7951e8532 | 493 | |
tsuparit | 9:dfb7951e8532 | 494 | CAMTOTAL=0; |
tsuparit | 9:dfb7951e8532 | 495 | OUT1=1; |
tsuparit | 9:dfb7951e8532 | 496 | wait(1.0); |
tsuparit | 9:dfb7951e8532 | 497 | OUT1=0; |
tsuparit | 9:dfb7951e8532 | 498 | } |
tsuparit | 9:dfb7951e8532 | 499 | |
tsuparit | 9:dfb7951e8532 | 500 | LiquidCrystal_I2Cinit(); |
tsuparit | 9:dfb7951e8532 | 501 | LiquidCrystal_I2Cbacklight(); |
tsuparit | 9:dfb7951e8532 | 502 | LiquidCrystal_I2CsetCursor(0,0); |
tsuparit | 9:dfb7951e8532 | 503 | sprintf (str, "Ready..") ; |
tsuparit | 9:dfb7951e8532 | 504 | LCDI2C4Bit_printIn(str); |
tsuparit | 9:dfb7951e8532 | 505 | |
tsuparit | 9:dfb7951e8532 | 506 | //++++++++++++++++++++++++++++++++ |
tsuparit | 9:dfb7951e8532 | 507 | } |
tsuparit | 9:dfb7951e8532 | 508 | } |
tsuparit | 9:dfb7951e8532 | 509 | #endif |
tsuparit | 9:dfb7951e8532 | 510 | |
tsuparit | 9:dfb7951e8532 | 511 | |
tsuparit | 7:3cb877cb7393 | 512 | |
tsuparit | 7:3cb877cb7393 | 513 | while(0) |
tsuparit | 7:3cb877cb7393 | 514 | { |
tsuparit | 7:3cb877cb7393 | 515 | if (BUZZER_EN!=0) BUZZER=1; |
tsuparit | 7:3cb877cb7393 | 516 | OUT0=0; |
tsuparit | 7:3cb877cb7393 | 517 | wait(0.1); |
tsuparit | 7:3cb877cb7393 | 518 | if (BUZZER_EN!=0) BUZZER=0; |
tsuparit | 7:3cb877cb7393 | 519 | wait(0.1); |
tsuparit | 7:3cb877cb7393 | 520 | OUT0=1; |
tsuparit | 7:3cb877cb7393 | 521 | |
tsuparit | 7:3cb877cb7393 | 522 | |
tsuparit | 7:3cb877cb7393 | 523 | wait(1.0); |
tsuparit | 7:3cb877cb7393 | 524 | |
tsuparit | 7:3cb877cb7393 | 525 | |
tsuparit | 7:3cb877cb7393 | 526 | } |
tsuparit | 7:3cb877cb7393 | 527 | |
tsuparit | 7:3cb877cb7393 | 528 | |
tsuparit | 0:5e60f85d6c26 | 529 | while(1) |
tsuparit | 0:5e60f85d6c26 | 530 | { |
tsuparit | 5:a693866be4b3 | 531 | |
tsuparit | 5:a693866be4b3 | 532 | if (loopinilcd++>100) |
tsuparit | 5:a693866be4b3 | 533 | { |
tsuparit | 5:a693866be4b3 | 534 | loopinilcd=0; |
tsuparit | 5:a693866be4b3 | 535 | LiquidCrystal_I2Cinit(); |
tsuparit | 5:a693866be4b3 | 536 | LiquidCrystal_I2Cbacklight(); |
tsuparit | 5:a693866be4b3 | 537 | } |
tsuparit | 5:a693866be4b3 | 538 | |
tsuparit | 3:e658376f6e27 | 539 | Input_sampling(512); |
tsuparit | 0:5e60f85d6c26 | 540 | LiquidCrystal_I2CsetCursor(0,0); |
tsuparit | 5:a693866be4b3 | 541 | sprintf (str, "IN:%d OUT:%d ",INPUT,OUTPUT); |
tsuparit | 3:e658376f6e27 | 542 | LCDI2C4Bit_printIn(str); |
tsuparit | 0:5e60f85d6c26 | 543 | LiquidCrystal_I2CsetCursor(0,1); |
tsuparit | 5:a693866be4b3 | 544 | |
tsuparit | 5:a693866be4b3 | 545 | |
tsuparit | 3:e658376f6e27 | 546 | float processtime=1000.0*com_timer.read(); |
tsuparit | 3:e658376f6e27 | 547 | if (processtime<10.0) |
tsuparit | 3:e658376f6e27 | 548 | { |
tsuparit | 3:e658376f6e27 | 549 | sprintf (str, "%.1f ms:%s ",processtime,rx_buffer); |
tsuparit | 3:e658376f6e27 | 550 | } |
tsuparit | 3:e658376f6e27 | 551 | else |
tsuparit | 3:e658376f6e27 | 552 | { |
tsuparit | 3:e658376f6e27 | 553 | sprintf (str, " %.1f ms:%s ",processtime,rx_buffer); |
tsuparit | 5:a693866be4b3 | 554 | } |
tsuparit | 5:a693866be4b3 | 555 | |
tsuparit | 0:5e60f85d6c26 | 556 | LCDI2C4Bit_printIn(str); |
tsuparit | 5:a693866be4b3 | 557 | |
tsuparit | 5:a693866be4b3 | 558 | |
tsuparit | 5:a693866be4b3 | 559 | |
tsuparit | 5:a693866be4b3 | 560 | char strbuf[50]; |
tsuparit | 5:a693866be4b3 | 561 | |
tsuparit | 5:a693866be4b3 | 562 | |
tsuparit | 5:a693866be4b3 | 563 | LiquidCrystal_I2CsetCursor(0,3); |
tsuparit | 5:a693866be4b3 | 564 | sprintf (str, "#"); |
tsuparit | 5:a693866be4b3 | 565 | sprintf (strbuf, " "); |
tsuparit | 5:a693866be4b3 | 566 | |
tsuparit | 5:a693866be4b3 | 567 | if (OUT0) |
tsuparit | 5:a693866be4b3 | 568 | { |
tsuparit | 5:a693866be4b3 | 569 | sprintf (strbuf, "K1 "); |
tsuparit | 5:a693866be4b3 | 570 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 571 | } |
tsuparit | 5:a693866be4b3 | 572 | |
tsuparit | 5:a693866be4b3 | 573 | if (OUT1) |
tsuparit | 5:a693866be4b3 | 574 | { |
tsuparit | 5:a693866be4b3 | 575 | sprintf (strbuf, "K2 "); |
tsuparit | 5:a693866be4b3 | 576 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 577 | } |
tsuparit | 5:a693866be4b3 | 578 | |
tsuparit | 5:a693866be4b3 | 579 | if (OUT2) |
tsuparit | 5:a693866be4b3 | 580 | { |
tsuparit | 5:a693866be4b3 | 581 | sprintf (strbuf, "K3 "); |
tsuparit | 5:a693866be4b3 | 582 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 583 | } |
tsuparit | 5:a693866be4b3 | 584 | |
tsuparit | 5:a693866be4b3 | 585 | if (OUT3) |
tsuparit | 5:a693866be4b3 | 586 | { |
tsuparit | 5:a693866be4b3 | 587 | sprintf (strbuf, "K4 "); |
tsuparit | 5:a693866be4b3 | 588 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 589 | } |
tsuparit | 5:a693866be4b3 | 590 | |
tsuparit | 5:a693866be4b3 | 591 | |
tsuparit | 5:a693866be4b3 | 592 | |
tsuparit | 5:a693866be4b3 | 593 | |
tsuparit | 5:a693866be4b3 | 594 | |
tsuparit | 5:a693866be4b3 | 595 | if (OUT4) |
tsuparit | 5:a693866be4b3 | 596 | { |
tsuparit | 5:a693866be4b3 | 597 | sprintf (strbuf, "RE "); |
tsuparit | 5:a693866be4b3 | 598 | } |
tsuparit | 5:a693866be4b3 | 599 | else |
tsuparit | 5:a693866be4b3 | 600 | { |
tsuparit | 5:a693866be4b3 | 601 | sprintf (strbuf, "V."); |
tsuparit | 5:a693866be4b3 | 602 | } |
tsuparit | 5:a693866be4b3 | 603 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 604 | |
tsuparit | 5:a693866be4b3 | 605 | if (OUT5) |
tsuparit | 5:a693866be4b3 | 606 | { |
tsuparit | 5:a693866be4b3 | 607 | sprintf (strbuf, "AC "); |
tsuparit | 5:a693866be4b3 | 608 | } |
tsuparit | 5:a693866be4b3 | 609 | else |
tsuparit | 5:a693866be4b3 | 610 | { |
tsuparit | 5:a693866be4b3 | 611 | sprintf (strbuf, "DC "); |
tsuparit | 5:a693866be4b3 | 612 | } |
tsuparit | 5:a693866be4b3 | 613 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 614 | |
tsuparit | 5:a693866be4b3 | 615 | if (OUT6) |
tsuparit | 5:a693866be4b3 | 616 | { |
tsuparit | 5:a693866be4b3 | 617 | sprintf (strbuf, "Di "); |
tsuparit | 5:a693866be4b3 | 618 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 619 | } |
tsuparit | 5:a693866be4b3 | 620 | |
tsuparit | 5:a693866be4b3 | 621 | if (OUT7) |
tsuparit | 5:a693866be4b3 | 622 | { |
tsuparit | 5:a693866be4b3 | 623 | sprintf (strbuf, "POW "); |
tsuparit | 5:a693866be4b3 | 624 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 625 | } |
tsuparit | 5:a693866be4b3 | 626 | sprintf (strbuf, " "); |
tsuparit | 5:a693866be4b3 | 627 | strcat(str,strbuf); |
tsuparit | 5:a693866be4b3 | 628 | |
tsuparit | 5:a693866be4b3 | 629 | |
tsuparit | 5:a693866be4b3 | 630 | LCDI2C4Bit_printIn(str); |
tsuparit | 5:a693866be4b3 | 631 | |
tsuparit | 5:a693866be4b3 | 632 | |
tsuparit | 5:a693866be4b3 | 633 | |
tsuparit | 5:a693866be4b3 | 634 | |
tsuparit | 0:5e60f85d6c26 | 635 | if (com_timer.read()>5.0) |
tsuparit | 0:5e60f85d6c26 | 636 | { |
tsuparit | 5:a693866be4b3 | 637 | rx_pointer=0;//Reset at the end |
tsuparit | 5:a693866be4b3 | 638 | com_timer.stop(); |
tsuparit | 0:5e60f85d6c26 | 639 | } |
tsuparit | 0:5e60f85d6c26 | 640 | |
tsuparit | 0:5e60f85d6c26 | 641 | } |
tsuparit | 0:5e60f85d6c26 | 642 | |
tsuparit | 0:5e60f85d6c26 | 643 | |
tsuparit | 0:5e60f85d6c26 | 644 | } |