From 0798ec40c1a8f69a91933eee0b45c9cbc91371bf Mon Sep 17 00:00:00 2001 From: Oliver Walter Date: Wed, 29 May 2024 04:01:55 +0200 Subject: [PATCH] added ambient light to can bus --- Application/CLS | 2 +- Application/Tasks/Headlight_can.c | 17 ++++++++++++++++- Core/Src/freertos.c | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Application/CLS b/Application/CLS index 4744762..58b50b2 160000 --- a/Application/CLS +++ b/Application/CLS @@ -1 +1 @@ -Subproject commit 4744762b4c3736d4ea2ec4dba3a70e996763841e +Subproject commit 58b50b2fb3b5efd60c0b546db3831cd4c7e7a011 diff --git a/Application/Tasks/Headlight_can.c b/Application/Tasks/Headlight_can.c index 8bb8055..f303ef6 100644 --- a/Application/Tasks/Headlight_can.c +++ b/Application/Tasks/Headlight_can.c @@ -7,7 +7,7 @@ #include "CLS.h" #include "CLS_BSP.h" #include "CLSAddress.h" - +#include "ulog.h" cls_headlight_RequestSettings msg_cls_headlight_RequestSettings; cls_headlight_Settings msg_cls_headlight_Settings; @@ -20,6 +20,21 @@ typedef struct Headlight_Control_Setting { uint16_t off_threshold; } Headlight_Control_Setting_t; + +uint16_t headlight_amblight = 0; + +void CanData_ambilight(CanDataId canid, uint8_t* data, uint8_t len) { + if(len == 2) { + headlight_amblight = (data[1] << 8) | data[0]; + } + + ULOG_INFO("Ambilight: %d", headlight_amblight); +} + +void AddHeadlightMessages() { + CanData_regEventMsg(GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, 0, CLS_CH_STA_AMBIENTLIGHT), CanData_ambilight); +} + // whan a message is received, this function is called void DataClbk_cls_headlight_Settings(void* msg, uint32_t length) { DATA_CLBK_SETUP(cls_headlight_Settings); diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 3ae0f44..d944e5d 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -41,6 +41,7 @@ #include "BSP_ADC.h" #include "BSP_SDLogger.h" #include "Vehicle.h" + /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -151,6 +152,8 @@ void MX_FREERTOS_Init(void) { } /* USER CODE BEGIN Header_StartDefaultTask */ +void AddHeadlightMessages(); + /** * @brief Function implementing the defaultTask thread. * @param argument: Not used @@ -189,6 +192,7 @@ void StartDefaultTask(void *argument) } BSP_SDLogger_Init(counter); + AddHeadlightMessages(); char INA_LOG[72];