[ANT+][nrf51422][s210] Bicycle Light Data Page 2 – Light Function (0x02)

Publisher:梦中徐来Latest update time:2022-09-07 Source: csdnKeywords:nrf51422 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Data Page 2 is one of the main data pages broadcast from an ANT+ bike light. All ANT+ bike lights should send this page as part of the data page cycle and upon request from the controller. See Section 7.3 for details on when this data page is sent. All fields in this message should be set as described in Table 7-8.

Table 7-8. Data Page 2 Format – Light Functions

insert image description here

7.5.1 Lighting properties

The light capabilities represented by the light attribute bit fields are set as shown in the following table.


Table 7-10. Light Attribute Bit Fields

insert image description here

Note that the #SupportedModes field includes both the number of standard modes and the number of custom modes supported in the light.


7.5.2 # Supported auxiliary lights

This field indicates the number of auxiliary lights in the network that the primary light is able to connect to. This field should contain a valid value. Please note that all ANT+ bike lights should support at least 4 auxiliary lights.

The number of auxiliary lamps supported is generally limited by the available memory on that lamp and should be specified assuming that each auxiliary lamp has 4 sub-lamps. The values ​​in Table 7-11 show the number of bytes required to store data pages 1 and 3 for each lamp and sub-lamp. An 8-byte buffer is included to allow requests for additional data pages from auxiliary lamps to be serviced. Each auxiliary lamp also includes an additional 1-byte buffer for comparison of the change trigger bit in data page 3.


Table 7-11. Memory Required to Support Auxiliary Lights

insert image description here

7.5.3 Lighting Control


7.5.4 Supported Standard Modes Bit Field

This bit field is used to indicate which standard modes are supported by the ANT+ bike light, as described in the table below.


Table 7-12. Supported Standard Mode Bit Fields

insert image description here

7.5.5 Battery capacity

The Battery Capacity field indicates the battery capacity of the light when fully charged. If using multiple batteries, the Battery Capacity field will reflect the total capacity available to the light.


7.5.6 Supported Light Types

The Supported Light Types bit field indicates the light types that the ANT+ bike light can be configured as. If the controller attempts to configure an ANT+ bike light as an unsupported light type, the light should ignore the command. The controller should only attempt to configure the light in a supported manner.


Table 7-13. Supported Light Type Bit Fields

insert image description here

/* 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.

 *

 */


/*************Light_State_ModeNum***Supported standard mode bit fields************************

LSB:

0 Reserved for future use. Set to 0

1 Always on: 81 - 100% brightness 0--Not supported 1--Supported

2 Always on: 61 - 80% brightness 0--Not supported 1--Supported

3 Always on: 41 - 60% brightness 0--Not supported 1--Supported

4 Always on: 21 - 40% brightness 0--Not supported 1--Supported

5 Constantly on: 0 - 20% brightness 0--Not supported 1--Supported

6 Slow flash 0--Not supported 1--Supported

7 Fast flashing 0--Not supported 1--Supported


MSB:

0 Random flashing 0--Not supported 1--Supported

1 Automatic 0--Not supported 1--Supported

2 Left turn signal light (automatically canceled) 0--Not supported 1--Supported

3 Left turn signal light (continuous) 0--Not supported 1--Supported

4 Right turn signal light (automatically canceled) 0--Not supported 1--Supported

5 Right turn signal light (continuous) 0--Not supported 1--Supported

6 Hazard indicator lights (left and right indicator lights flash continuously) 0--Not supported 1--Supported

**********************************/


/*************Light_Properties_SupportedModes***Lighting mode number************************

0 Lights off

1 Constant on: 81 - 100% brightness

2 Constantly on: 61 - 80% brightness

3 Constantly on: 41 - 60% brightness

4 Constantly on: 21 - 40% brightness

5 Constant light: 0 - 20% brightness

6 Slow flashing

7 Fast flashing

8 Random flashes

9 Automatic

10 Left turn signal (automatically canceled)

11 Left turn signal (continuous)

12 Right turn signal (automatically canceled)

13 Right turn signal (continuous)

14 Hazard indicators (left and right indicators flash continuously)

15:47 Reserved for future use. Do not use.

48 Custom Mode48

X Custom Mode "X"

63 Custom Mode 63

**********************************/

/*************Supported_Light_Types***Supported light types************************

Bit Light Type Value Description

0 Front light 0/1 0: Not supported 1: Supported

1 Reserved 0 Set to zero

2 Tail light 0/1 0: Not supported 1: Supported

3 Traffic lights - configurable 0/1 0: not supported 1: supported

4 Traffic light - left 0/1 0: not supported 1: supported

5 Traffic light - right 0/1 0: Not supported 1: Supported

6 Reserved 0 Set to zero

7 Others 0/1 0: Not supported 1: Supported

**********************************/

#include "ant_BikeLight_page_2.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 lighting function (0x02) Page 2 data layout structure. */

typedef struct

{

    uint8_t Light_Index; //Light index 0-63


    uint8_t Light_Properties_AutoIntensityMode: 1; //Light properties--Automatic brightness mode--0: Not supported 1: Supported

    uint8_t Light_Properties_Beam: 1; //Light properties--Light type --0: Do not support turning off the light at far/near 1: Support turning off the light at far/near

    uint8_t Light_Properties_SupportedModes: 6; //Light properties--supported modes --0: light mode is not supported (only constant light) 1:63---total number of supported modes


    uint8_t Battery_Capacity; //Fully charged battery capacity Unit: 200mAh Range: [0-50800mAh]


    uint8_t Supported_Secondary_Lights : 4; //Auxiliary lighting [4-63]

    uint8_t : 2;

    uint8_t Beam_Focus_Control: 1; //Light focus control 0--support 1--not support

    uint8_t Beam_Intensity_Control: 1; //Light brightness control 0--Not supported 1--Supported


    uint8_t LSB; //Supported standard mode bit field LSB (with comments above)


    uint8_t MSB: 7; //Supported standard mode bit field MSB (with comments above)

    uint8_t BrakeLightLight: 1; //Brake light: 0--Not supported 1 Supported


    uint8_t Supported_Light_Types; //Supported light types 0: Headlight 2: Taillight 3: Signal light 4: Signal light - left 5: Signal light - right


} ant_BikeLight_page2_data_layout_t;



static void page2_data_log(ant_BikeLight_page2_data_t const *p_page_data)

{

// SEGGER_RTT_printf(0, "Light_Index: %drn", (uint8_t)p_page_data->Light_Index);

// SEGGER_RTT_printf(0, "AutoIntensityMode: %drn", (uint8_t)p_page_data->Light_Properties_AutoIntensityMode);

// SEGGER_RTT_printf(0, "Beam: %drn", (uint8_t)p_page_data->Light_Properties_Beam);

// SEGGER_RTT_printf(0, "SupportedModes: %drn", (uint8_t)p_page_data->Light_Properties_SupportedModes);

// SEGGER_RTT_printf(0, "Battery_Capacity: %drn", (uint8_t)p_page_data->Battery_Capacity);

}



void ant_BikeLight_page_2_encode(uint8_t *p_page_buffer,

                                 ant_BikeLight_page2_data_t const *p_page_data)

{

    ant_BikeLight_page2_data_layout_t *p_outcoming_data = (ant_BikeLight_page2_data_layout_t *)p_page_buffer;


    memset(p_page_buffer, 0, sizeof(ant_BikeLight_page2_data_layout_t));

    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->Battery_Capacity = p_page_data->Battery_Capacity;


    p_outcoming_data->Supported_Secondary_Lights = p_page_data->Supported_Secondary_Lights;

    p_outcoming_data->Beam_Focus_Control = p_page_data->Beam_Focus_Control;

    p_outcoming_data->Beam_Intensity_Control = p_page_data->Beam_Intensity_Control;

    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;

    page2_data_log(p_page_data);

}



void ant_BikeLight_page_2_decode(uint8_t const *p_page_buffer,

                                 ant_BikeLight_page2_data_t *p_page_data,

                                 uint8_t const Channel)

{

    ant_BikeLight_page2_data_layout_t const *p_incoming_data =

        (ant_BikeLight_page2_data_layout_t *)p_page_buffer;

    if (Channel == 0)

    {

// if (p_incoming_data->Light_Index == m_ant_BikeLight.page_1.Light_Index) //Judge the light index

// {

// 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->Battery_Capacity = p_incoming_data->Battery_Capacity;


// p_page_data->Supported_Secondary_Lights = p_incoming_data->Supported_Secondary_Lights;

// p_page_data->Beam_Focus_Control = p_incoming_data->Beam_Focus_Control;

// p_page_data->Beam_Intensity_Control = p_incoming_data->Beam_Intensity_Control;

// 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;

// page2_data_log(p_page_data);

// }

// else // Commands that are not your own are forwarded to the shared channel

// {

[1] [2] [3] [4]
Keywords:nrf51422 Reference address:[ANT+][nrf51422][s210] Bicycle Light Data Page 2 – Light Function (0x02)

Previous article:[vscode][nrf51][nrf52] uint8_t uint16_t uint32_t etc. variables are abnormal
Next article:[ANT+][nrf51422][s210] Bicycle Light Data Page 1 – Light Status 1 (0x01)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号