refactor Functions to group everything connected to the vehicle to a central location

This commit is contained in:
2024-05-28 03:52:03 +02:00
parent 9c489c1a25
commit 766d5e9ca8
14 changed files with 274 additions and 186 deletions

View File

@@ -11,6 +11,7 @@
#include "BSP_GPIO.h"
#include "CanDataTask.h"
#include "Vehicle.h"
#include "BSP_ADC.h"
#define DIMM_DEADZONE_VOLTAGE 0.7
@@ -82,14 +83,14 @@ void LightTask_func(void *argument) {
float dimmfactor = 1.0;
uint8_t dimm = 255;
// currenlty not working
// only dimm if the headlight is on
if (BSP_GPIO_HeadLightIsSet()) {
//if (Vehicle_isHeadlightOn()) {
// new version over CAN
uint8_t precent = CanDataTask_CarCanBrightness();
dimmfactor = (float)precent / 100.0;
//dimm = Vehicle_Brightness();
// old version over ADC
// calculate the dimmfactor based on the battery voltage and the dimmer voltage
@@ -104,9 +105,10 @@ void LightTask_func(void *argument) {
//} else {
// dimmfactor = (v_dimm - 4.0) / (v_bus - 4.0);
//}
}
uint8_t adjustedBrightness = (uint8_t)(brightness * dimmfactor);
//}
uint8_t adjustedBrightness = (brightness * dimm)/ 255;
lightSettings_dimmed.brightness = adjustedBrightness;
lightSettings_dimmed.theme = lightSettings.theme;