This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HOW to add leds in desktop

Hi

I am using NCS desktop application

I ported it to my custom board(52833),It works well

but now,my custom board has three leds,while nrf52 kbd board only has 1 led,so I want add 2 leds

but after modify the code as blew,led has not change to 3 leds but 1 led(without any change)

~~~~~~~~~~~~what I modify~~~~~~~~~~~~~~~~~~~~~~

/*DTS  pin number is confirm ok*/

&pwm0 {
status = "okay";
ch0-pin = <2>;
ch0-inverted;
};
&pwm1 {
status = "okay";
ch0-pin = <28>;
ch0-inverted;
};
&pwm2 {
status = "okay";
ch0-pin = <29>;
ch0-inverted;
};

/*leds_def.h*/

static const size_t led_pins[CONFIG_DESKTOP_LED_COUNT]
[CONFIG_DESKTOP_LED_COLOR_COUNT] = {
{
DT_PROP(DT_ALIAS(pwm_0), ch0_pin)
},
{
DT_PROP(DT_ALIAS(pwm_1), ch0_pin)
},
{
DT_PROP(DT_ALIAS(pwm_2), ch0_pin)
},
};

/*config*/

CONFIG_DESKTOP_LED_COUNT  3

~~~~~~~~~~~~~~~~nordic sourcecode~~~~~~~~~~~~~~~~~~

/*DTS */

&pwm0 {
status = "okay";
ch0-pin = <30>;
ch0-inverted;
ch1-pin = <29>;
ch1-inverted;
ch2-pin = <28>;
ch2-inverted;
};

/*leds_def.h*/

static const size_t led_pins[CONFIG_DESKTOP_LED_COUNT]
[CONFIG_DESKTOP_LED_COLOR_COUNT] = {
{
DT_PROP(DT_ALIAS(pwm_0), ch0_pin)
},
};

/*config*/

CONFIG_DESKTOP_LED_COUNT  1     

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

BR

victor

  • I provided an answer to this earlier, check it out here. The answer was given 4 months ago, with an older version of NCS, and stuff might have changed since then, but the answer should give you a good overview.

    Best regards,

    Simon

  • Hi Simon,when I saw blew code,I think desktop suport three leds default

    I just need to know how to config ,or do I miss understand?  I know if I want to add a specific LED I should do like the link you say,but If desktop application support 3 peer leds default ,What I do is just config,am I right?

    static const struct led_effect led_peer_state_effect[LED_PEER_COUNT][LED_PEER_STATE_COUNT] = {
    	{
    		[LED_PEER_STATE_DISCONNECTED]   = LED_EFFECT_LED_OFF(),
    		[LED_PEER_STATE_CONNECTED]      = LED_EFFECT_LED_ON_GO_OFF(LED_COLOR(255), 5000, 3000),
    		[LED_PEER_STATE_PEER_SEARCH]    = LED_EFFECT_LED_BREATH(500, LED_COLOR(255)),
    		[LED_PEER_STATE_CONFIRM_SELECT] = LED_EFFECT_LED_CLOCK(1, LED_COLOR(255)),
    		[LED_PEER_STATE_CONFIRM_ERASE]  = LED_EFFECT_LED_BLINK(25, LED_COLOR(255)),
    		[LED_PEER_STATE_ERASE_ADV]	= LED_EFFECT_LED_BREATH(100, LED_COLOR(255)),
    	},
    	{
    		[LED_PEER_STATE_DISCONNECTED]   = LED_EFFECT_LED_OFF(),
    		[LED_PEER_STATE_CONNECTED]      = LED_EFFECT_LED_ON_GO_OFF(LED_COLOR(255), 5000, 3000),
    		[LED_PEER_STATE_PEER_SEARCH]    = LED_EFFECT_LED_BREATH(500, LED_COLOR(255)),
    		[LED_PEER_STATE_CONFIRM_SELECT] = LED_EFFECT_LED_CLOCK(2, LED_COLOR(255)),
    		[LED_PEER_STATE_CONFIRM_ERASE]  = LED_EFFECT_LED_BLINK(25, LED_COLOR(255)),
    		[LED_PEER_STATE_ERASE_ADV]	= LED_EFFECT_LED_BREATH(100, LED_COLOR(255)),
    	},
    	{
    		[LED_PEER_STATE_DISCONNECTED]   = LED_EFFECT_LED_OFF(),
    		[LED_PEER_STATE_CONNECTED]      = LED_EFFECT_LED_ON_GO_OFF(LED_COLOR(255), 5000, 3000),
    		[LED_PEER_STATE_PEER_SEARCH]    = LED_EFFECT_LED_BREATH(500, LED_COLOR(255)),
    		[LED_PEER_STATE_CONFIRM_SELECT] = LED_EFFECT_LED_CLOCK(3, LED_COLOR(255)),
    		[LED_PEER_STATE_CONFIRM_ERASE]  = LED_EFFECT_LED_BLINK(25, LED_COLOR(255)),
    		[LED_PEER_STATE_ERASE_ADV]	= LED_EFFECT_LED_BREATH(100, LED_COLOR(255)),
    	},
    
    };
    

  • Sorry, I was a little fast to respond. 

    Have you set CONFIG_DESKTOP_LED_COUNT=3 in the correct .conf file? Set it in the conf file corresponding to the one you are buildiing with. E.g. if you are building with west build ... DCMAKE_BUILD_TYPE=ZRelease, then you should set it in the file nrf\applications\nrf_desktop\configuration\<boad>\app_ZRelease.conf.

    In addition I think you should modify nrf\applications\nrf_desktop\configuration\<board>\leds_def.h and nrf\applications\nrf_desktop\configuration\<board>\led_state_def.h to take into account the increased amount of leds.

    Hope this helps!

    Best regards,

    Simon

  • Hi simon 

    I find out it

    the code does not mean the desktop has 3 leds but 1 led with 3 status 

    thank you

Related