Subversion Repositories DashDisplay

Rev

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

Rev 23 Rev 24
Line 56... Line 56...
56
 
56
 
57
/* USER CODE BEGIN PV */
57
/* USER CODE BEGIN PV */
58
/* Private variables ---------------------------------------------------------*/
58
/* Private variables ---------------------------------------------------------*/
59
#define MAXRDG 32
59
#define MAXRDG 32
60
 
60
 
-
 
61
/* timeout when the ignition is switched off */
-
 
62
#define IGNITION_OFF_TIMEOUT 30000UL
-
 
63
 
61
int OldObservation[2] =
64
int OldObservation[2] =
62
{ -1, -1 }; // illegal initial value
65
{ -1, -1 }; // illegal initial value
63
int OldObservationIndex[2] =
66
int OldObservationIndex[2] =
64
{ -1, -1 }; // if more than one sensor this will be printed
67
{ -1, -1 }; // if more than one sensor this will be printed
65
int16_t dial0[2] =
68
int16_t dial0[2] =
Line 81... Line 84...
81
        char Bytes[MAXRDG * sizeof(PLX_SensorInfo)];
84
        char Bytes[MAXRDG * sizeof(PLX_SensorInfo)];
82
} Data;
85
} Data;
83
int Max[MAXRDG];
86
int Max[MAXRDG];
84
int Min[MAXRDG];
87
int Min[MAXRDG];
85
int PLXItems;
88
int PLXItems;
-
 
89
 
-
 
90
uint32_t  Latch_Timer = IGNITION_OFF_TIMEOUT;
-
 
91
 
-
 
92
 
86
/* USER CODE END PV */
93
/* USER CODE END PV */
87
 
94
 
88
/* Private function prototypes -----------------------------------------------*/
95
/* Private function prototypes -----------------------------------------------*/
89
void SystemClock_Config(void);
96
void SystemClock_Config(void);
90
void Error_Handler(void);
97
void Error_Handler(void);
Line 189... Line 196...
189
                                        buff[i++] = ObservationIndex + '1';
196
                                        buff[i++] = ObservationIndex + '1';
190
                                }
197
                                }
191
 
198
 
192
                                print_large_string(buff, 64-i*4, 48, i); // this prints spaces for \0 at end of string
199
                                print_large_string(buff, 64-i*4, 48, i); // this prints spaces for \0 at end of string
193
 
200
 
-
 
201
                                // print suffix if present.
-
 
202
                                font_gotoxy(15,4);
-
 
203
                                int i=0;
-
 
204
                                while(DisplayInfo[Observation].suffix[i])
-
 
205
                                {
-
 
206
                                        font_putchar(DisplayInfo[Observation].suffix[i++]);
-
 
207
                                }
-
 
208
 
194
                                OldObservation[dial] = Observation;
209
                                OldObservation[dial] = Observation;
195
                                OldObservationIndex[dial] = ObservationIndex;
210
                                OldObservationIndex[dial] = ObservationIndex;
196
                                //
211
                                //
197
                                display();
212
                                display();
198
 
213
 
Line 388... Line 403...
388
 
403
 
389
        ssd1306_begin(1, 0);
404
        ssd1306_begin(1, 0);
390
        dial_origin(64, 60);
405
        dial_origin(64, 60);
391
        dial_size(60);
406
        dial_size(60);
392
 
407
 
393
 
-
 
-
 
408
    /* reset the display timeout, latch on power from accessories */
394
        // sort out the switch positions
409
        Latch_Timer = IGNITION_OFF_TIMEOUT;
395
 
-
 
396
 
-
 
397
 
-
 
-
 
410
        HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port,POWER_LATCH_Pin,GPIO_PIN_RESET);
398
 
411
 
399
        for (disp = 0; disp < 2; disp++)
412
        for (disp = 0; disp < 2; disp++)
400
        {
413
        {
401
                select_display(disp);
414
                select_display(disp);
402
                clearDisplay();
415
                clearDisplay();
Line 419... Line 432...
419
 
432
 
420
  /* Infinite loop */
433
  /* Infinite loop */
421
  /* USER CODE BEGIN WHILE */
434
  /* USER CODE BEGIN WHILE */
422
        uint32_t Ticks = HAL_GetTick() + 100;
435
        uint32_t Ticks = HAL_GetTick() + 100;
423
 
436
 
-
 
437
    /* while ignition is on, keep resetting power latch timer */
-
 
438
        if(HAL_GPIO_ReadPin(IGNITION_GPIO_Port,IGNITION_Pin) == GPIO_PIN_RESET)
-
 
439
        {
-
 
440
                Latch_Timer = HAL_GetTick() + IGNITION_OFF_TIMEOUT;
-
 
441
        }
-
 
442
        else
-
 
443
        {
-
 
444
                /* if the ignition has been off for a while, then turn off power */
-
 
445
                if(HAL_GetTick() > Latch_Timer )
-
 
446
                {
-
 
447
                        HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port,POWER_LATCH_Pin,GPIO_PIN_RESET);
-
 
448
                }
-
 
449
        }
-
 
450
 
424
    uint32_t timeout = 0;  //
451
    uint32_t timeout = 0;  //
425
        // PLX decoder protocol
452
        // PLX decoder protocols
426
        char PLXPacket = 0;
453
        char PLXPacket = 0;
427
        for (i = 0; i < MAXRDG; i++)
454
        for (i = 0; i < MAXRDG; i++)
428
        {
455
        {
429
                Max[i] = 0;
456
                Max[i] = 0;
430
                Min[i] = 0xFFF; // 12 bit max value
457
                Min[i] = 0xFFF; // 12 bit max value
Line 432... Line 459...
432
 
459
 
433
        int PLXPtr = 0;
460
        int PLXPtr = 0;
434
 
461
 
435
        while (1)
462
        while (1)
436
        {
463
        {
437
// poll switches
464
// poll switche
438
                HandleSwitches();
465
                HandleSwitches();
439
// Handle the bluetooth pairing function by pressing both buttons.
466
// Handle the bluetooth pairing function by pressing both buttons.
440
                if((push_pos[0] == 1) && (push_pos[1] == 1))
467
                if((push_pos[0] == 1) && (push_pos[1] == 1))
441
                {
468
                {
442
                  HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_SET);
469
                  HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_SET);
Line 668... Line 695...
668
 
695
 
669
  /*Configure GPIO pin Output Level */
696
  /*Configure GPIO pin Output Level */
670
  HAL_GPIO_WritePin(GPIOA, SPI1CD_Pin|BT_BUTTON_Pin, GPIO_PIN_RESET);
697
  HAL_GPIO_WritePin(GPIOA, SPI1CD_Pin|BT_BUTTON_Pin, GPIO_PIN_RESET);
671
 
698
 
672
  /*Configure GPIO pin Output Level */
699
  /*Configure GPIO pin Output Level */
673
  HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin|USART3_INVERT_Pin|USB_PWR_Pin, GPIO_PIN_RESET);
700
  HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin|POWER_LATCH_Pin|USB_PWR_Pin, GPIO_PIN_RESET);
674
 
701
 
675
  /*Configure GPIO pin Output Level */
702
  /*Configure GPIO pin Output Level */
676
  HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET);
703
  HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET);
677
 
704
 
678
  /*Configure GPIO pins : SPI_NSS1_Pin SPI1CD_Pin BT_BUTTON_Pin */
705
  /*Configure GPIO pins : SPI_NSS1_Pin SPI1CD_Pin BT_BUTTON_Pin */
679
  GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI1CD_Pin|BT_BUTTON_Pin;
706
  GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI1CD_Pin|BT_BUTTON_Pin;
680
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
707
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
681
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
708
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
682
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
709
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
683
 
710
 
684
  /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin USART3_INVERT_Pin USB_PWR_Pin */
711
  /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */
685
  GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NSS2_Pin|USART3_INVERT_Pin|USB_PWR_Pin;
712
  GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NSS2_Pin|POWER_LATCH_Pin|USB_PWR_Pin;
686
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
713
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
687
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
714
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
688
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
715
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
689
 
716
 
690
  /*Configure GPIO pins : SW1_PUSH_Pin SW1_I_Pin SW1_Q_Pin SW2_PUSH_Pin */
717
  /*Configure GPIO pins : SW1_PUSH_Pin SW1_I_Pin SW1_Q_Pin SW2_PUSH_Pin */
Line 697... Line 724...
697
  GPIO_InitStruct.Pin = SW2_I_Pin|SW2_Q_Pin;
724
  GPIO_InitStruct.Pin = SW2_I_Pin|SW2_Q_Pin;
698
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
725
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
699
  GPIO_InitStruct.Pull = GPIO_PULLUP;
726
  GPIO_InitStruct.Pull = GPIO_PULLUP;
700
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
727
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
701
 
728
 
-
 
729
  /*Configure GPIO pin : IGNITION_Pin */
-
 
730
  GPIO_InitStruct.Pin = IGNITION_Pin;
-
 
731
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-
 
732
  GPIO_InitStruct.Pull = GPIO_NOPULL;
-
 
733
  HAL_GPIO_Init(IGNITION_GPIO_Port, &GPIO_InitStruct);
-
 
734
 
702
}
735
}
703
 
736
 
704
/* USER CODE BEGIN 4 */
737
/* USER CODE BEGIN 4 */
705
 
738
 
706
/* USER CODE END 4 */
739
/* USER CODE END 4 */