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