首页 > 其他分享 >ANT+ 自行车车灯 数据页面4 –子灯功能(0x04)

ANT+ 自行车车灯 数据页面4 –子灯功能(0x04)

时间:2022-10-31 21:01:06浏览次数:51  
标签:0x04 Light uint8 支持 page ANT -- data 子灯


数据页面4是从ANT+自行车灯广播的主要数据页面之一。ANT+自行车灯应作为数据页面循环的一部分发送此页面,并且在存在子灯的情况下应控制器的要求发送。有关何时发送或忽略此数据页面的详细信息,请参见7.3节。该消息中的所有字段均应按照表7-16中的说明进行设置。

ANT+ 自行车车灯 数据页面4 –子灯功能(0x04)_ico


ANT+ 自行车车灯 数据页面4 –子灯功能(0x04)_ico_02

7.7.1 子灯索引
此页面中的数据描述了带有指示的子灯索引的子灯的功能。该字段不得设置为值0、5、6或7。

7.7.2 主光的一部分
显示屏可以使用此字段来确定如何向用户呈现子灯:作为两个独立的灯(0)或作为单个灯(1)。
如果单个自行车灯支持同时作为两种灯类型工作,而每种灯类型都表示为子灯,则应设置此位。如果副灯在物理上与主光源不同,则该位应为零。

/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/

#include "ant_BikeLight_page_4.h"
#include "ant_BikeLight_utils.h"
#include "ant_BikeLight_page_logger.h"
#include "SEGGER_RTT.h"
#include "SEGGER_RTT_Conf.h"
#include "main.h"
/**@brief BikeLight 子灯功能 第4页数据布局结构. */
typedef struct
{
uint8_t Light_Index; //灯光索引 0-63

uint8_t Light_Properties_AutoIntensityMode: 1; //灯光属性--自动亮度模式--0:不支持 1:支持
uint8_t Light_Properties_Beam : 1; //灯光属性--灯光类型 --0:不支持远/近关灯 1:支持远/近关灯
uint8_t Light_Properties_SupportedModes : 6; //灯光属性--支持的模式 --0:不支持灯光模式(仅限常亮灯光) 1:63---支持的模式总数

uint8_t Sublight_Index : 2; //子灯索引 1-4
uint8_t Partofprincipal_light : 1; //如果客户认为子灯光与主灯光相同,则设置此位。
uint8_t Reserved : 4; //保留

uint8_t Battery_Capacity; //充满电的电池容量 单位:200mAh 范围: [0-50800mAh]

uint8_t LSB; //支持的标准模式位字段LSB(上面有注释)

uint8_t MSB: 7; //支持的标准模式位字段MSB(上面有注释)
uint8_t BrakeLightLight: 1; //刹车灯光:0--不支持 1支持

uint8_t Supported_Light_Types; //支持的灯光类型 0:前灯 2:尾灯
} ant_BikeLight_page4_data_layout_t;


static void page4_data_log(ant_BikeLight_page4_data_t const *p_page_data)
{
// SEGGER_RTT_printf(0, "Light_Index: %d\r\n", (uint8_t)p_page_data->Light_Index);

}


void ant_BikeLight_page_4_encode(uint8_t *p_page_buffer,
ant_BikeLight_page4_data_t const *p_page_data)
{
ant_BikeLight_page4_data_layout_t *p_outcoming_data = (ant_BikeLight_page4_data_layout_t *)p_page_buffer;

p_outcoming_data->Light_Index = p_page_data->Light_Index;
p_outcoming_data->Light_Properties_AutoIntensityMode = p_page_data->Light_Properties_AutoIntensityMode;
p_outcoming_data->Light_Properties_Beam = p_page_data->Light_Properties_Beam;
p_outcoming_data->Light_Properties_SupportedModes = p_page_data->Light_Properties_SupportedModes;

p_outcoming_data->Sublight_Index = p_page_data->Sublight_Index;
p_outcoming_data->Partofprincipal_light = p_page_data->Partofprincipal_light;

p_outcoming_data->Battery_Capacity = p_page_data->Battery_Capacity;

p_outcoming_data->LSB = p_page_data->LSB;
p_outcoming_data->MSB = p_page_data->MSB;
p_outcoming_data->BrakeLightLight = p_page_data->BrakeLightLight;
p_outcoming_data->Supported_Light_Types = p_page_data->Supported_Light_Types;
page4_data_log(p_page_data);
}


void ant_BikeLight_page_4_decode(uint8_t const *p_page_buffer,
ant_BikeLight_page4_data_t *p_page_data)
{
ant_BikeLight_page4_data_layout_t const *p_incoming_data =
(ant_BikeLight_page4_data_layout_t *)p_page_buffer;

p_page_data->Light_Index = p_incoming_data->Light_Index;
p_page_data->Light_Properties_AutoIntensityMode = p_incoming_data->Light_Properties_AutoIntensityMode;
p_page_data->Light_Properties_Beam = p_incoming_data->Light_Properties_Beam;
p_page_data->Light_Properties_SupportedModes = p_incoming_data->Light_Properties_SupportedModes;

p_page_data->Sublight_Index = p_incoming_data->Sublight_Index;
p_page_data->Partofprincipal_light = p_incoming_data->Partofprincipal_light;

p_page_data->Battery_Capacity = p_incoming_data->Battery_Capacity;

p_page_data->LSB = p_incoming_data->LSB;
p_page_data->MSB = p_incoming_data->MSB;
p_page_data->BrakeLightLight = p_incoming_data->BrakeLightLight;
p_page_data->Supported_Light_Types = p_incoming_data->Supported_Light_Types;
page4_data_log(p_page_data);
}
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
#ifndef ANT_BIKELIGHT_PAGE_4_H__
#define ANT_BIKELIGHT_PAGE_4_H__
/*************Light_State_ModeNum***支持的标准模式位字段************************
LSB:
0 保留以备将来使用。设置为0
1 常亮:81 - 100%亮度 0--不支持 1--支持
2 常亮:61 - 80%亮度 0--不支持 1--支持
3 常亮:41 - 60%亮度 0--不支持 1--支持
4 常亮:21 - 40%亮度 0--不支持 1--支持
5 常亮: 0 - 20%亮度 0--不支持 1--支持
6 慢闪烁 0--不支持 1--支持
7 快速闪烁 0--不支持 1--支持

MSB:
0 随机闪烁 0--不支持 1--支持
1 自动 0--不支持 1--支持
2 左转信号灯(自动取消) 0--不支持 1--支持
3 左转信号灯(持续) 0--不支持 1--支持
4 右转信号灯(自动取消) 0--不支持 1--支持
5 右转信号灯(持续) 0--不支持 1--支持
6 危险指示灯(左右指示灯连续闪烁) 0--不支持 1--支持
**********************************/
/*************Light_Properties_SupportedModes***灯光模式号************************
0 灯光关闭
1 常亮:81 - 100%亮度
2 常亮:61 - 80%亮度
3 常亮:41 - 60%亮度
4 常亮:21 - 40%亮度
5 常亮: 0 - 20%亮度
6 慢闪烁
7 快速闪烁
8 随机闪烁
9 自动
10 左转信号灯(自动取消)
11 左转信号灯(持续)
12 右转信号灯(自动取消)
13 右转信号灯(持续)
14 危险指示灯(左右指示灯连续闪烁)
15:47 保留以备将来使用。不要使用。
48 自定义模式48
X 自定义模式“X”
63 自定义模式63
**********************************/
#include <stdint.h>

typedef struct
{
uint8_t Light_Index; //灯光索引 0-63

uint8_t Light_Properties_AutoIntensityMode: 1; //灯光属性--自动亮度模式--0:不支持 1:支持
uint8_t Light_Properties_Beam : 1; //灯光属性--灯光类型 --0:不支持远/近关灯 1:支持远/近关灯
uint8_t Light_Properties_SupportedModes : 6; //灯光属性--支持的模式 --0:不支持灯光模式(仅限常亮灯光) 1:63---支持的模式总数

uint8_t Sublight_Index : 2; //子灯索引 1-4
uint8_t Partofprincipal_light : 1; //如果客户认为子灯光与主灯光相同,则设置此位。0-1
uint8_t Reserved : 4; //保留

uint8_t Battery_Capacity; //充满电的电池容量 单位:200mAh 范围: [0-50800mAh]

uint8_t LSB; //支持的标准模式位字段LSB(上面有注释)

uint8_t MSB: 7; //支持的标准模式位字段MSB(上面有注释)
uint8_t BrakeLightLight: 1; //刹车灯光:0--不支持 1支持

uint8_t Supported_Light_Types; //支持的灯光类型 0:前灯 2:尾灯

} ant_BikeLight_page4_data_t;


#define DEFAULT_ANT_BikeLight_PAGE4() \
(ant_BikeLight_page4_data_t) \
{ \
.Light_Index = 0, \
.Light_Properties_AutoIntensityMode = 1, \
.Light_Properties_Beam = 0, \
.Light_Properties_SupportedModes = 0, \
.Sublight_Index = 1, \
.Partofprincipal_light = 1, \
.Battery_Capacity = 1, \
.LSB = 0xff, \
.MSB = 0, \
.BrakeLightLight = 1, \
.Supported_Light_Types = 0, \
}


void ant_BikeLight_page_4_encode(uint8_t *p_page_buffer,
ant_BikeLight_page4_data_t const *p_page_data);


void ant_BikeLight_page_4_decode(uint8_t const *p_page_buffer,
ant_BikeLight_page4_data_t *p_page_data);

#endif // ANT_BIKELIGHT_PAGE_4_H__
/** @} */


标签:0x04,Light,uint8,支持,page,ANT,--,data,子灯
From: https://blog.51cto.com/xuejianqiang/5811278

相关文章