added display messages
This commit is contained in:
@@ -13,6 +13,7 @@ target_sources(${PROJECT_NAME}
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/LightTask.c
|
${CMAKE_CURRENT_LIST_DIR}/LightTask.c
|
||||||
${CMAKE_CURRENT_LIST_DIR}/LightState.c
|
${CMAKE_CURRENT_LIST_DIR}/LightState.c
|
||||||
${CMAKE_CURRENT_LIST_DIR}/Headlight_can.c
|
${CMAKE_CURRENT_LIST_DIR}/Headlight_can.c
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/DisplayComm.c
|
||||||
|
|
||||||
INTERFACE
|
INTERFACE
|
||||||
${CMAKE_CURRENT_LIST_DIR}/UsbDataHandler.h
|
${CMAKE_CURRENT_LIST_DIR}/UsbDataHandler.h
|
||||||
@@ -24,4 +25,4 @@ target_sources(${PROJECT_NAME}
|
|||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC PROTOS CLS)
|
target_link_libraries(${PROJECT_NAME} PUBLIC PROTOS CLS)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE Revision CLS_BSP BSP ulog Vehicle ram_loader)
|
target_link_libraries(${PROJECT_NAME} PRIVATE Revision CLS_BSP BSP ulog Vehicle ram_loader mlzr_comm TinyFrame)
|
||||||
@@ -318,10 +318,9 @@ extern uint8_t gCLS_DEVICE_ADDRESS;
|
|||||||
void DataClbk_cls_device_RequestList(void* msg, uint32_t length) {
|
void DataClbk_cls_device_RequestList(void* msg, uint32_t length) {
|
||||||
memset(&list,0,sizeof(list));
|
memset(&list,0,sizeof(list));
|
||||||
// add yourself
|
// add yourself
|
||||||
|
|
||||||
CLS_Position_t position = CLS_BSP_GetPosition();
|
CLS_Position_t position = CLS_BSP_GetPosition();
|
||||||
CLS_Type_t type = CLS_BSP_GetDeviceType();
|
CLS_Type_t type = CLS_BSP_GetDeviceType();
|
||||||
|
|
||||||
list.devices[list.devices_count].available = true;
|
list.devices[list.devices_count].available = true;
|
||||||
list.devices[list.devices_count].canid = GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, gCLS_DEVICE_ADDRESS, CLS_CH_STA_HEATBEAT);
|
list.devices[list.devices_count].canid = GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, gCLS_DEVICE_ADDRESS, CLS_CH_STA_HEATBEAT);
|
||||||
list.devices[list.devices_count].device = gCLS_DEVICE_ADDRESS;
|
list.devices[list.devices_count].device = gCLS_DEVICE_ADDRESS;
|
||||||
@@ -333,7 +332,21 @@ void DataClbk_cls_device_RequestList(void* msg, uint32_t length) {
|
|||||||
list.devices[list.devices_count].fw_version[1] = VERSION_INFO.patch;
|
list.devices[list.devices_count].fw_version[1] = VERSION_INFO.patch;
|
||||||
list.devices[list.devices_count].fw_version[2] = VERSION_INFO.minor;
|
list.devices[list.devices_count].fw_version[2] = VERSION_INFO.minor;
|
||||||
list.devices[list.devices_count].fw_version[3] = VERSION_INFO.major;
|
list.devices[list.devices_count].fw_version[3] = VERSION_INFO.major;
|
||||||
|
list.devices_count++;
|
||||||
|
|
||||||
|
//add display
|
||||||
|
list.devices[list.devices_count].available = true;
|
||||||
|
list.devices[list.devices_count].canid = GENERATE_CLS_ADDRESS(CLS_CODE_STATUS, gCLS_DEVICE_ADDRESS+1, CLS_CH_STA_HEATBEAT);
|
||||||
|
list.devices[list.devices_count].device = gCLS_DEVICE_ADDRESS+1;
|
||||||
|
list.devices[list.devices_count].type = cls_device_Type_DISPLAY; // enum to uint
|
||||||
|
list.devices[list.devices_count].position[0] = position.p0;
|
||||||
|
list.devices[list.devices_count].position[1] = position.p1;
|
||||||
|
list.devices[list.devices_count].position_count = 2;
|
||||||
|
list.devices[list.devices_count].fw_version[0] = 0;
|
||||||
|
list.devices[list.devices_count].fw_version[1] = 0;
|
||||||
|
list.devices[list.devices_count].fw_version[2] = 0;
|
||||||
|
list.devices[list.devices_count].fw_version[3] = 0;
|
||||||
|
|
||||||
list.devices_count++;
|
list.devices_count++;
|
||||||
|
|
||||||
for (size_t i = 0; i < 16; i++)
|
for (size_t i = 0; i < 16; i++)
|
||||||
|
|||||||
16
Application/Tasks/DisplayComm.c
Normal file
16
Application/Tasks/DisplayComm.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "UsbDataHandler.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "mlzr_comm.h"
|
||||||
|
#include "pb_decode.h"
|
||||||
|
#include "display.pb.h"
|
||||||
|
|
||||||
|
static cls_display_SetLayout msg_cls_display_SetLayout;
|
||||||
|
|
||||||
|
|
||||||
|
void DataClbk_cls_display_SetLayout(void* msg, uint32_t length) {
|
||||||
|
DATA_CLBK_SETUP(cls_display_SetLayout);
|
||||||
|
uint8_t num = (uint8_t)msg_cls_display_SetLayout.layout;
|
||||||
|
TF_SendSimple(tf_fallback,0x0F, &num, sizeof(num));
|
||||||
|
}
|
||||||
@@ -156,8 +156,13 @@ void DataClbk_cls_firmware_Done(void *msg, uint32_t length) {
|
|||||||
|
|
||||||
if(msg_cls_firmware_Done.device_id == gCLS_DEVICE_ADDRESS) {
|
if(msg_cls_firmware_Done.device_id == gCLS_DEVICE_ADDRESS) {
|
||||||
RamLoader_LoadApplication();
|
RamLoader_LoadApplication();
|
||||||
} else {
|
} else if (msg_cls_firmware_Done.device_id == gCLS_DEVICE_ADDRESS +1) {
|
||||||
|
// send fw to display
|
||||||
|
// todo !
|
||||||
|
|
||||||
|
} {
|
||||||
|
|
||||||
|
// send fw to slave
|
||||||
FirmwareUpdateArgs args;
|
FirmwareUpdateArgs args;
|
||||||
args.device = msg_cls_firmware_Done.device_id;
|
args.device = msg_cls_firmware_Done.device_id;
|
||||||
memcpy(args.name, msg_cls_firmware_Start.name, sizeof(args.name));
|
memcpy(args.name, msg_cls_firmware_Start.name, sizeof(args.name));
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include "cls_device.pb.h"
|
#include "cls_device.pb.h"
|
||||||
#include "usb.pb.h"
|
#include "usb.pb.h"
|
||||||
|
#include "display.pb.h"
|
||||||
#include "stdbool.h"
|
#include "stdbool.h"
|
||||||
|
|
||||||
/* Declare the thread function */
|
/* Declare the thread function */
|
||||||
@@ -67,6 +68,7 @@ union {
|
|||||||
cls_headlight_SaveSettings msg_cls_headlight_SaveSettings;
|
cls_headlight_SaveSettings msg_cls_headlight_SaveSettings;
|
||||||
cls_headlight_RequestSettings msg_cls_headlight_RequestSettings;
|
cls_headlight_RequestSettings msg_cls_headlight_RequestSettings;
|
||||||
cls_headlight_RequestBrightness msg_cls_headlight_RequestBrightness;
|
cls_headlight_RequestBrightness msg_cls_headlight_RequestBrightness;
|
||||||
|
cls_display_SetLayout msg_cls_display_SetLayout;
|
||||||
} mem_msg_decode;
|
} mem_msg_decode;
|
||||||
|
|
||||||
|
|
||||||
@@ -129,6 +131,7 @@ message_handler_t message_handlers[] = {
|
|||||||
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_SAVE_SETTINGS, cls_headlight_SaveSettings),
|
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_SAVE_SETTINGS, cls_headlight_SaveSettings),
|
||||||
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_REQUEST_SETTINGS, cls_headlight_RequestSettings),
|
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_REQUEST_SETTINGS, cls_headlight_RequestSettings),
|
||||||
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_REQUEST_BRIGHTNESS, cls_headlight_RequestBrightness),
|
MESSAGE_HANDLER(cls_usb_PackageType_HEADLIGHT_REQUEST_BRIGHTNESS, cls_headlight_RequestBrightness),
|
||||||
|
MESSAGE_HANDLER(cls_usb_PackageType_DISPLAY_SET_LAYOUT, cls_display_SetLayout),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ void DataClbk_cls_headlight_Settings(void* msg, uint32_t length);
|
|||||||
void DataClbk_cls_headlight_SaveSettings(void* msg, uint32_t length);
|
void DataClbk_cls_headlight_SaveSettings(void* msg, uint32_t length);
|
||||||
void DataClbk_cls_headlight_RequestSettings(void* msg, uint32_t length);
|
void DataClbk_cls_headlight_RequestSettings(void* msg, uint32_t length);
|
||||||
void DataClbk_cls_headlight_RequestBrightness(void* msg, uint32_t length);
|
void DataClbk_cls_headlight_RequestBrightness(void* msg, uint32_t length);
|
||||||
|
void DataClbk_cls_display_SetLayout(void* msg, uint32_t length);
|
||||||
|
|
||||||
#include "usb.pb.h"
|
#include "usb.pb.h"
|
||||||
void USBDataResonse(void * msg, const pb_msgdesc_t *fields, cls_usb_PackageType typeid);
|
void USBDataResonse(void * msg, const pb_msgdesc_t *fields, cls_usb_PackageType typeid);
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH proto
|
|||||||
proto/light.proto
|
proto/light.proto
|
||||||
proto/usb.proto
|
proto/usb.proto
|
||||||
proto/headlight.proto
|
proto/headlight.proto
|
||||||
|
proto/display.proto
|
||||||
)
|
)
|
||||||
add_library(PROTOS ${PROTO_SRCS} ${PROTO_HDRS})
|
add_library(PROTOS ${PROTO_SRCS} ${PROTO_HDRS})
|
||||||
target_include_directories(PROTOS PUBLIC ${NANOPB_INCLUDE_DIRS} ${PROJECT_BINARY_DIR})
|
target_include_directories(PROTOS PUBLIC ${NANOPB_INCLUDE_DIRS} ${PROJECT_BINARY_DIR})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ ${PROTO_SRC_DIR}/light.proto
|
|||||||
${PROTO_SRC_DIR}/usb.proto
|
${PROTO_SRC_DIR}/usb.proto
|
||||||
${PROTO_SRC_DIR}/cls_device.proto
|
${PROTO_SRC_DIR}/cls_device.proto
|
||||||
${PROTO_SRC_DIR}/headlight.proto
|
${PROTO_SRC_DIR}/headlight.proto
|
||||||
|
${PROTO_SRC_DIR}/display.proto
|
||||||
)
|
)
|
||||||
|
|
||||||
# Specify where you want to generate the python code
|
# Specify where you want to generate the python code
|
||||||
|
|||||||
41
tools/display_test.py
Normal file
41
tools/display_test.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import serial
|
||||||
|
import struct
|
||||||
|
from google.protobuf.message import DecodeError
|
||||||
|
from serial.tools import list_ports
|
||||||
|
|
||||||
|
from display_pb2 import SetLayout
|
||||||
|
from usb_pb2 import PackageType
|
||||||
|
from vcp_driver import *
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
ser = setup_connection()
|
||||||
|
# Create a message
|
||||||
|
#request = GlobalBrightness()
|
||||||
|
#request.brightness = 100
|
||||||
|
# Serialize the request to a bytearray
|
||||||
|
#request_data = request.SerializeToString()
|
||||||
|
|
||||||
|
# Send the request
|
||||||
|
#send_package(PackageType.LIGHT_GLOBAL_BRIGHT, request_data, ser)
|
||||||
|
|
||||||
|
|
||||||
|
#request = GlobalTheme()
|
||||||
|
#request.theme = 1
|
||||||
|
#request_data = request.SerializeToString()
|
||||||
|
#send_package(PackageType.LIGHT_GLOBAL_THEME, request_data, ser)
|
||||||
|
|
||||||
|
|
||||||
|
# request = ThemeSettings()
|
||||||
|
# request.deviceId = 1
|
||||||
|
# request.theme = 1
|
||||||
|
# request.rgb = 0x00f000f0
|
||||||
|
# request.brightness = 255
|
||||||
|
# request.animation = 2
|
||||||
|
# request_data = request.SerializeToString()
|
||||||
|
# send_package(PackageType.LIGHT_SETTING_THEME, request_data, ser)
|
||||||
|
|
||||||
|
|
||||||
|
request = SetLayout()
|
||||||
|
request.layout = 2
|
||||||
|
request_data = request.SerializeToString()
|
||||||
|
send_package(PackageType.DISPLAY_SET_LAYOUT, request_data, ser)
|
||||||
Reference in New Issue
Block a user