找回密码
 立即注册

使用微信账号登录

只需一步,快速开始

QCC512x QCC302x earbud工程 LED 配置

2020-5-14 19:23| 发布者: csdn| 查看: 1721| 评论: 0|来自: CSDN

摘要: earbud 工程配置 LED 1、修改“av_headset_config.h”,修改需要的LED数量 工程默认使用的是 HAVE_3_LEDS 这个宏

earbud 工程配置 LED

1、修改“av_headset_config.h”,修改需要的LED数量

工程默认使用的是 HAVE_3_LEDS 这个宏,可以 “av_headset_config.h” 搜索这个宏,定位到需要修改的地方。
下面将这个宏附近的上下文贴出来,此处主要是增加了 HAVE_NO_LEDHAVE_2_LEDS ,默认只有1和3,由于我只需要用到2个LED,就增加一个宏即可。

#if defined(HAVE_NO_LED)

#define appConfigNumberOfLeds()  (0)

/*! PIO to control LED0 */
#define appConfigLed0Pio()       (0)
/*! PIO to control LED1 (not used) */
#define appConfigLed1Pio()       (0)
/*! PIO to control LED2 (not used) */
#define appConfigLed2Pio()       (0)
#elif defined(HAVE_1_LED)

/*! The number of LEDs av_headset_led will control. If one LED is configured,
    it will use appConfigLed0Pio(), if two LEDs are configured it will use
    appConfigLed0Pio() and appConfigLed1Pio() etc. */
#define appConfigNumberOfLeds()  (1)

/*! PIO to control LED0 */
#define appConfigLed0Pio()       CHIP_LED_0_PIO
/*! PIO to control LED1 (not used) */
#define appConfigLed1Pio()       (0)
/*! PIO to control LED2 (not used) */
#define appConfigLed2Pio()       (0)

/* 注意:此处是增加的内容 */
#elif defined(HAVE_2_LEDS)

/* The number of LEDs av_headset_led will control. */
#define appConfigNumberOfLeds()  (2)
/*! PIO to control LED0 */
#define appConfigLed0Pio()       CHIP_LED_0_PIO
/*! PIO to control LED1 */
#define appConfigLed1Pio()       CHIP_LED_1_PIO
/*! PIO to control LED2 */
#define appConfigLed2Pio()       (0)


#elif defined(HAVE_3_LEDS)

/* The number of LEDs av_headset_led will control. */
#define appConfigNumberOfLeds()  (3)
/*! PIO to control LED0 */
#define appConfigLed0Pio()       CHIP_LED_0_PIO
/*! PIO to control LED1 */
#define appConfigLed1Pio()       CHIP_LED_1_PIO
/*! PIO to control LED2 */
#define appConfigLed2Pio()       CHIP_LED_2_PIO

#else
#error LED config not correctly defined.
#endif

之后要在工程属性中修改一下,使用新定义的值。

在这里插入图片描述

2、修改 “av_headset_ui.c” ,修改 LED 的状态

以修改2个 LED 为例,修改使用2个LED时的定义,并且增加颜色组合。

#if (appConfigNumberOfLeds() == 3)
#define LED_0_STATE  (1 << 0)
#define LED_1_STATE  (1 << 1)
#define LED_2_STATE  (1 << 2)
#elif (appConfigNumberOfLeds() == 2)
/* We only have 2 LED so map all control to the same LED */
#define LED_0_STATE  (1 << 0)
#define LED_1_STATE  (1 << 1)
#define LED_2_STATE  (1 << 1)
#else
/* We only have 1 LED so map all control to the same LED */
#define LED_0_STATE  (1 << 0)
#define LED_1_STATE  (1 << 0)
#define LED_2_STATE  (1 << 0)
#endif

#define LED_RED     (LED_0_STATE)
#define LED_BLUE    (LED_1_STATE)
#define LED_GREEN   (LED_2_STATE)
#define LED_WHITE   (LED_0_STATE | LED_1_STATE | LED_2_STATE)
#define LED_PURPLE  (LED_RED | LED_BLUE)

3、LED 事件状态

在“av_headset_ui.c”文件中,刚才的宏定义下方,就是定义 LED 事件的地方,可参考工程原有代码的写法来改写。


来源:https://blog.csdn.net/qq_29225913/article/details/102400348
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

路过

雷人

握手
1

鲜花

鸡蛋

刚表态过的朋友 (1 人)

相关阅读

最新评论

小黑屋|手机版|我爱蓝牙网 - 52Bluetooth

GMT+8, 2024-3-29 22:20 , Processed in 0.107522 second(s), 16 queries , Gzip On, MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

返回顶部