Rev 56 | Rev 58 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 56 | Rev 57 | ||
---|---|---|---|
Line 63... | Line 63... | ||
63 | /* timeout when the ignition is switched off */ |
63 | /* timeout when the ignition is switched off */ |
64 | #define IGNITION_OFF_TIMEOUT 30000UL |
64 | #define IGNITION_OFF_TIMEOUT 30000UL |
65 | 65 | ||
66 | #define LOGGER_INTERVAL 500UL |
66 | #define LOGGER_INTERVAL 500UL |
67 | 67 | ||
68 | const int DialTimeout = 50; // about 20 seconds after twiddle, save the dial position. |
68 | const int DialTimeout = 10000; // about 10 seconds after twiddle, save the dial position. |
69 | 69 | ||
70 | nvram_info_t dial_nvram[MAX_DISPLAYS] __attribute__((section(".NVRAM_Data"))); |
70 | nvram_info_t dial_nvram[MAX_DISPLAYS] __attribute__((section(".NVRAM_Data"))); |
71 | 71 | ||
72 | info_t Info[MAXRDG]; |
72 | info_t Info[MAXRDG]; |
73 | 73 | ||
Line 104... | Line 104... | ||
104 | // the dial is the switch number we are using. |
104 | // the dial is the switch number we are using. |
105 | // suppress is the ItemIndex we wish to suppress on this display |
105 | // suppress is the ItemIndex we wish to suppress on this display |
106 | int |
106 | int |
107 | DisplayCurrent (int dial, int suppress) |
107 | DisplayCurrent (int dial, int suppress) |
108 | { |
108 | { |
109 | int itemIndex = dial_pos[dial] % PLXItems; |
- | |
110 | if (itemIndex < 0) |
109 | if (contexts[dial].knobPos < 0) |
111 | return -1; |
110 | return -1; |
112 | return cc_display (dial, itemIndex, suppress); |
111 | return cc_display (dial, suppress); |
113 | } |
112 | } |
114 | 113 | ||
115 | void |
114 | void |
116 | setBaud (usart_ctl *ctl, uint32_t baud) |
115 | setBaud (usart_ctl *ctl, uint32_t baud) |
117 | { |
116 | { |
Line 137... | Line 136... | ||
137 | { |
136 | { |
138 | char initBuf[30]; |
137 | char initBuf[30]; |
139 | // switch to command mode |
138 | // switch to command mode |
140 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_RESET); |
139 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_RESET); |
141 | HAL_Delay (500); |
140 | HAL_Delay (500); |
142 | int initLen = small_sprintf (initBuf, "AT+UART=%d,1,2\n", baudRate); |
141 | int initLen = small_sprintf (initBuf, "AT+UART=%l,1,2\n", baudRate); |
143 | setBaud (ctl, 38400); |
142 | setBaud (ctl, 38400); |
144 | sendString (ctl, initBuf, initLen); |
143 | sendString (ctl, initBuf, initLen); |
145 | TxWaitEmpty (ctl); |
144 | TxWaitEmpty (ctl); |
146 | // switch back to normal comms at new baud rate |
145 | // switch back to normal comms at new baud rate |
147 | 146 | ||
Line 241... | Line 240... | ||
241 | cc_init (); |
240 | cc_init (); |
242 | 241 | ||
243 | int i; |
242 | int i; |
244 | for (i = 0; i < 2; i++) |
243 | for (i = 0; i < 2; i++) |
245 | { |
244 | { |
246 | dial_pos[i] = -1; // default to items 0 and 1 |
245 | dial_pos[i] = 0; // default to items 0 and 1 |
- | 246 | contexts[i].knobPos = -1; |
|
247 | } |
247 | } |
248 | 248 | ||
249 | /* reset the display timeout, latch on power from accessories */ |
249 | /* reset the display timeout, latch on power from accessories */ |
250 | Latch_Timer = IGNITION_OFF_TIMEOUT; |
250 | Latch_Timer = IGNITION_OFF_TIMEOUT; |
251 | HAL_GPIO_WritePin (POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET); |
251 | HAL_GPIO_WritePin (POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET); |
Line 367... | Line 367... | ||
367 | if (log) |
367 | if (log) |
368 | { |
368 | { |
369 | 369 | ||
370 | char outbuff[100]; |
370 | char outbuff[100]; |
371 | 371 | ||
372 | int cnt = small_sprintf (outbuff, "$LOG,%d,%d,%d", |
372 | int cnt = small_sprintf (outbuff, |
- | 373 | "$PLLOG,%d,%d,%d", |
|
373 | Info[i].observation, |
374 | Info[i].observation, |
374 | Info[i].instance, |
375 | Info[i].instance, |
375 | Info[i].data); |
376 | Info[i].data); |
376 | 377 | ||
377 | //checksum |
378 | //checksum |
Line 405... | Line 406... | ||
405 | 406 | ||
406 | } |
407 | } |
407 | 408 | ||
408 | HAL_Delay (1); |
409 | HAL_Delay (1); |
409 | 410 | ||
- | 411 | for (i = 0; i < MAX_DISPLAYS; i++) |
|
- | 412 | { |
|
- | 413 | if (dial_pos[i] > 1000) |
|
410 | dial_pos[0] = cc_check_nvram (0, dial_pos[0]); |
414 | dial_pos[i] = PLXItems - 1; |
- | 415 | if (dial_pos[i] >= PLXItems) |
|
- | 416 | dial_pos[i] = 0; |
|
- | 417 | ||
- | 418 | int prevPos = contexts[i].knobPos; |
|
- | 419 | if (contexts[i].knobPos >= 0) |
|
411 | dial_pos[1] = cc_check_nvram (1, dial_pos[1]); |
420 | contexts[i].knobPos = dial_pos[i]; |
- | 421 | // if the dial position was changed then reset timer |
|
- | 422 | if (prevPos != contexts[i].knobPos) |
|
- | 423 | contexts[i].dial_timer = DialTimeout; |
|
412 | 424 | ||
- | 425 | cc_check_nvram (i); |
|
- | 426 | if (contexts[i].knobPos >= 0) |
|
- | 427 | dial_pos[i] = contexts[i].knobPos; |
|
- | 428 | } |
|
413 | } |
429 | } |
414 | - | ||
415 | /* USER CODE END WHILE */ |
430 | /* USER CODE END WHILE */ |
416 | 431 | ||
417 | /* USER CODE BEGIN 3 */ |
432 | /* USER CODE BEGIN 3 */ |
418 | } |
433 | } |
419 | /* USER CODE END 3 */ |
434 | /* USER CODE END 3 */ |