Subversion Repositories DashDisplay

Rev

Rev 66 | Rev 68 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 66 Rev 67
Line 69... Line 69...
69
#define IGNITION_OFF_TIMEOUT 30000UL
69
#define IGNITION_OFF_TIMEOUT 30000UL
70
 
70
 
71
// 500mS per logger period.
71
// 500mS per logger period.
72
#define LOGGER_INTERVAL 500UL
72
#define LOGGER_INTERVAL 500UL
73
 
73
 
74
const int DialTimeout = 10000; // about 10 seconds after twiddle, save the dial position.
74
const int DialTimeout = 100; // about 10 seconds after twiddle, save the dial position.
75
 
75
 
76
nvram_info_t dial_nvram[MAX_DISPLAYS] __attribute__((section(".NVRAM_Data")));
76
nvram_info_t dial_nvram[MAX_DISPLAYS];
77
 
77
 
78
info_t Info[MAXRDG];
78
info_t Info[MAXRDG];
79
 
79
 
80
/// \brief storage for incoming data
80
/// \brief storage for incoming data
81
data_t Data;
81
data_t Data;
Line 249... Line 249...
249
  int i;
249
  int i;
250
  for (i = 0; i < 2; i++)
250
  for (i = 0; i < 2; i++)
251
  {
251
  {
252
    dial_pos[i] = 0;            // default to items 0 and 1
252
    dial_pos[i] = 0;            // default to items 0 and 1
253
    contexts[i].knobPos = -1;   // set the knob position
253
    contexts[i].knobPos = -1;   // set the knob position
254
    contexts[i].dial_timer = 1; // timeout immediately
254
    contexts[i].dial_timer = 1; // timeout immediately when decremented
-
 
255
 
-
 
256
    cc_check_nvram(i);
255
  }
257
  }
256
 
258
 
257
  /* reset the display timeout, latch on power from accessories */
259
  /* reset the display timeout, latch on power from accessories */
258
  Latch_Timer = IGNITION_OFF_TIMEOUT;
260
  Latch_Timer = IGNITION_OFF_TIMEOUT;
259
  HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET);
261
  HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET);
Line 267... Line 269...
267
  uint8_t log = 0;
269
  uint8_t log = 0;
268
  // PLX decoder protocols
270
  // PLX decoder protocols
269
  char PLXPacket = 0;
271
  char PLXPacket = 0;
270
  for (i = 0; i < MAXRDG; i++)
272
  for (i = 0; i < MAXRDG; i++)
271
  {
273
  {
272
    Info[i].Max = 0;
274
    Info[i].Max = 0;
273
    Info[i].Min = 0xFFF;
275
    Info[i].Min = 0xFFF;
274
    Info[i].sum = 0;  
276
    Info[i].sum = 0;
275
    Info[i].count = 0;
277
    Info[i].count = 0;
276
    Info[i].updated = 0;
278
    Info[i].updated = 0;
277
    Info[i].lastUpdated = 0;
279
    Info[i].lastUpdated = 0;
278
  }
280
  }
279
 
281
 
280
  int PLXPtr = 0;
282
  int PLXPtr = 0;
Line 391... Line 393...
391
    }
393
    }
392
 
394
 
393
    /// process the observation list
395
    /// process the observation list
394
    for (chr = 0; chr < cc; chr++)
396
    for (chr = 0; chr < cc; chr++)
395
    {
397
    {
396
      char c = GetCharSerial(&uc1);
398
      uint8_t c = GetCharSerial(&uc1);
397
 
399
 
398
      if (c == PLX_Start) // at any time if the start byte appears, reset the pointers
400
      if (c == PLX_Start) // at any time if the start byte appears, reset the pointers
399
      {
401
      {
400
        PLXPtr = 0; // reset the pointer
402
        PLXPtr = 0; // reset the pointer
401
        PLXPacket = 1;
403
        PLXPacket = 1;
402
        timeout = 0; // Reset the timer
404
        timeout = 0; // Reset the timer
-
 
405
        continue;
403
      }
406
      }
404
      else if (c == PLX_Stop)
407
      if (c == PLX_Stop)
405
      {
408
      {
406
        if (PLXPacket)
409
        if (PLXPacket)
407
        {
410
        {
408
          // we can now decode the selected parameter
411
          // we can now decode the selected parameter
409
          PLXItems = PLXPtr / sizeof(PLX_SensorInfo); // total
412
          PLXItems = PLXPtr / sizeof(PLX_SensorInfo); // total
Line 429... Line 432...
429
            // take an average
432
            // take an average
430
            Info[i].sum += Info[i].data;
433
            Info[i].sum += Info[i].data;
431
            Info[i].count++;
434
            Info[i].count++;
432
            // note the last update time
435
            // note the last update time
433
            Info[i].lastUpdated = HAL_GetTick();
436
            Info[i].lastUpdated = HAL_GetTick();
434
            Info[i].updated = 1; // it has been updated 
437
            Info[i].updated = 1; // it has been updated
435
          }
438
          }
436
          PLXPtr = 0;
439
          PLXPtr = 0;
437
          PLXPacket = 0;
440
          PLXPacket = 0;
438
        }
-
 
439
        else if (c > PLX_Stop) // illegal char, restart reading
-
 
440
        {
-
 
441
          PLXPacket = 0;
-
 
442
          PLXPtr = 0;
-
 
443
        }
-
 
444
        else if (PLXPacket && PLXPtr < sizeof(Data.Bytes))
-
 
445
        {
-
 
446
          Data.Bytes[PLXPtr++] = c;
441
          break; // something to process 
447
        }
442
        }
448
      }
443
      }
449
 
-
 
450
      int suppress = -1;
-
 
451
      for (i = 0; i < MAX_DISPLAYS; i++)
-
 
452
      { // now to display the information
444
      if (c > PLX_Stop) // illegal char, restart reading
453
        DisplayCurrent(i, suppress);
-
 
454
 
445
      {
455
        if (dial_pos[i] < 0)
446
        PLXPacket = 0;
456
          dial_pos[i] = PLXItems - 1;
447
        PLXPtr = 0;
457
        if (dial_pos[i] >= PLXItems)
-
 
458
          dial_pos[i] = 0;
448
        continue;
459
 
449
      }
460
        int prevPos = contexts[i].knobPos;
-
 
461
        if (contexts[i].knobPos >= 0)
-
 
462
          contexts[i].knobPos = dial_pos[i];
-
 
463
        // if the dial position was changed then reset timer
-
 
464
        if (prevPos != contexts[i].knobPos)
450
      if (PLXPacket && PLXPtr < sizeof(Data.Bytes))
465
          contexts[i].dial_timer = DialTimeout;
-
 
466
 
-
 
467
        cc_check_nvram(i);
451
      {
468
        if (contexts[i].knobPos >= 0)
452
        Data.Bytes[PLXPtr++] = c;
469
          dial_pos[i] = contexts[i].knobPos;
-
 
470
      }
453
      }
471
    }
454
    }
-
 
455
    int suppress = -1;
-
 
456
    for (i = 0; i < MAX_DISPLAYS; i++)
-
 
457
    { // now to display the information
-
 
458
      suppress = DisplayCurrent(i, suppress);
-
 
459
     
-
 
460
 
-
 
461
      if (dial_pos[i] < 0)
-
 
462
        dial_pos[i] = PLXItems - 1;
-
 
463
      if (dial_pos[i] >= PLXItems)
-
 
464
        dial_pos[i] = 0;
-
 
465
 
-
 
466
      int prevPos = contexts[i].knobPos;
-
 
467
      if (contexts[i].knobPos >= 0)
-
 
468
        contexts[i].knobPos = dial_pos[i];
-
 
469
      // if the dial position was changed then reset timer
-
 
470
      if (prevPos != contexts[i].knobPos)
-
 
471
        contexts[i].dial_timer = DialTimeout;
-
 
472
 
-
 
473
      cc_check_nvram(i);
-
 
474
      if (contexts[i].knobPos >= 0)
-
 
475
        dial_pos[i] = contexts[i].knobPos;
-
 
476
    }
472
  }
477
  }
473
  /* USER CODE END WHILE */
478
  /* USER CODE END WHILE */
474
 
479
 
475
  /* USER CODE BEGIN 3 */
480
  /* USER CODE BEGIN 3 */
476
 
481
 
477
  /* USER CODE END 3 */
482
  /* USER CODE END 3 */
478
}
483
}
-
 
484
 
479
/**
485
/**
480
 * @brief System Clock Configuration
486
 * @brief System Clock Configuration
481
 * @retval None
487
 * @retval None
482
 */
488
 */
483
void SystemClock_Config(void)
489
void SystemClock_Config(void)