数据页面3是从ANT+自行车灯广播的主要数据页面之一。如果存在子灯,则ANT+自行车灯应以数据页循环方式发送此页。有关何时发送或忽略此数据页面的详细信息,请参见7.3节。该消息中的所有字段均应按照表7-14中的说明进行设置。
Table 7-14. 数据页3格式–子灯状态
Table 7-15. 数据公共格式第3页
7.6.1 子灯索引
字节2:4中的数据描述子光,子光索引在字节2的子光索引字段中指示。
字节5:7中的数据描述具有下一个子灯光索引的子灯光。
例如,如果子灯光3以字节2:4描述,则字节5:7描述子灯光4。
为每个子光提供的数据包括子光配置为的光类型、电池电量、当前状态和光束强度。
此字段不应设置为0、4、5、6或7。
注意,作为一个最佳实践,如果没有子光[a + 1]存在,那么每个字节都应该被设置为0。
7.6.2 更改切换位 ‘A’/’A+1’
更改切换位旨在使主指示灯或控制器能够简单地确定是否在数据页中描述的子指示灯上发生了任何更改。每次以字节2:4(或5:7)发送的数据与描述该子光的最后发送的子光状态数据页相比不同时,应切换该位。
7.6.3 电池提示标志
如果子灯的电池电量低或严重,则通过将标志位设置为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.**//*************[A_StateBitField]***[A+_StateBitField]************************
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 "ant_BikeLight_page_3.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 子灯光状态 第3页数据布局结构. */
typedef struct
{uint8_t Light_Index; //灯光索引 0-63/*******************A********************/uint8_t SubLight_Index_A : 3; //子灯`A`索引 [1-3]uint8_t Light_Type_A : 3; //灯光类型 0:前灯 2:尾灯uint8_t : 1;uint8_t ChangeToggleBit_A : 1; //更改“A”数据时,此变量需要反转。uint8_t StateBitField_A; //状态位:见上面注释uint8_t Intensity_A : 7; //灯光亮度: [0,100]% 启用自动亮度模式:0x7E 无效:0x7Fuint8_t Battery_Warning_A : 1; //电池提示 0:没有提示 1--电量低/*******************A**END******************//********************A+1*********************/uint8_t Light_Type_A1 : 3; //灯光类型 0:前灯 2:尾灯uint8_t : 4;uint8_t ChangeToggleBit_A1 : 1; //更改“A+1”数据时,此变量需要反转。uint8_t StateBitField_A1; //状态位:见上面注释uint8_t Intensity_A1 : 7; //灯光亮度: [0,100]% 启用自动亮度模式:0x7E 无效:0x7Fuint8_t Battery_Warning_A1 : 1; //电池提示 0:没有提示 1--电量低/*******************A+1**END******************/
} ant_BikeLight_page3_data_layout_t;static void page3_data_log(ant_BikeLight_page3_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_3_encode(uint8_t *p_page_buffer,ant_BikeLight_page3_data_t const *p_page_data)
{ant_BikeLight_page3_data_layout_t *p_outcoming_data = (ant_BikeLight_page3_data_layout_t *)p_page_buffer;p_outcoming_data->Light_Index = p_page_data->Light_Index;p_outcoming_data->SubLight_Index_A = p_page_data->SubLight_Index_A;p_outcoming_data->Light_Type_A = p_page_data->Light_Type_A;p_outcoming_data->ChangeToggleBit_A = p_page_data->ChangeToggleBit_A;p_outcoming_data->StateBitField_A = p_page_data->StateBitField_A;p_outcoming_data->Intensity_A = p_page_data->Intensity_A;p_outcoming_data->Battery_Warning_A = p_page_data->Battery_Warning_A;page3_data_log(p_page_data);
}void ant_BikeLight_page_3_decode(uint8_t const *p_page_buffer,ant_BikeLight_page3_data_t *p_page_data)
{ant_BikeLight_page3_data_layout_t const *p_incoming_data =(ant_BikeLight_page3_data_layout_t *)p_page_buffer;p_page_data->Light_Index = p_incoming_data->Light_Index;p_page_data->SubLight_Index_A = p_incoming_data->SubLight_Index_A;p_page_data->Light_Type_A = p_incoming_data->Light_Type_A;p_page_data->ChangeToggleBit_A = p_incoming_data->ChangeToggleBit_A;p_page_data->StateBitField_A = p_incoming_data->StateBitField_A;p_page_data->Intensity_A = p_incoming_data->Intensity_A;p_page_data->Battery_Warning_A = p_incoming_data->Battery_Warning_A;page3_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_3_H__
#define ANT_BIKELIGHT_PAGE_3_H__
/*************[A_StateBitField]***[A+_StateBitField]************************
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
{uint8_t Light_Index; //灯光索引 0-63/*******************A********************/uint8_t SubLight_Index_A : 3; //子灯`A`索引 [1-3]uint8_t Light_Type_A : 3; //灯光类型 0:前灯 2:尾灯uint8_t : 1;uint8_t ChangeToggleBit_A : 1; //更改“A”数据时,此变量需要反转。uint8_t StateBitField_A; //状态位:见上面注释uint8_t Intensity_A : 7; //灯光亮度: [0,100]% 启用自动亮度模式:0x7E 无效:0x7Fuint8_t Battery_Warning_A : 1; //电池提示 0:没有提示 1--电量低/*******************A**END******************//********************A+1*********************/uint8_t Light_Type_A1 : 3; //灯光类型 0:前灯 2:尾灯uint8_t : 4;uint8_t ChangeToggleBit_A1 : 1; //更改“A+1”数据时,此变量需要反转。uint8_t StateBitField_A1; //状态位:见上面注释uint8_t Intensity_A1 : 7; //灯光亮度: [0,100]% 启用自动亮度模式:0x7E 无效:0x7Fuint8_t Battery_Warning_A1 : 1; //电池提示 0:没有提示 1--电量低/*******************A+1**END******************/
} ant_BikeLight_page3_data_t;#define DEFAULT_ANT_BikeLight_PAGE3() \(ant_BikeLight_page3_data_t) \{ \.Light_Index = 0, \.SubLight_Index_A = 1, \.Light_Type_A = 0, \.ChangeToggleBit_A = 0, \.StateBitField_A = 0, \.Intensity_A = 100, \.StateBitField_A = 0, \.Battery_Warning_A = 0, \.Light_Type_A1 = 0, \.ChangeToggleBit_A1 = 0, \.StateBitField_A1 = 0, \.Intensity_A1 = 0, \.Battery_Warning_A1 = 0, \}void ant_BikeLight_page_3_encode(uint8_t *p_page_buffer,ant_BikeLight_page3_data_t const *p_page_data);void ant_BikeLight_page_3_decode(uint8_t const *p_page_buffer,ant_BikeLight_page3_data_t *p_page_data);#endif // ANT_BIKELIGHT_PAGE_3_H__
/** @} */