How do I extend the CAF LED module?

I am currently using the CAF LED modules. This works fine with a mono-color LED or a tri-color RGB LED.

question 1:
My problem is that unfortunatly my hardware board has only Bi-color LED e.g. red+green.
Is there any (hidden) configuration settings in CAF to disable the "blue" color in the LED module.

without hitting the assert in function leds_init at line 186

   __ASSERT_NO_MSG((led->color_count == 1) || (led->color_count == 3));

Question2:
An small architectural question:
How can I overload or inherit the CAF LED module correctly, without copy-paste the code to my custom sdk (as extended library to zephyr)

Any idea / hint / tip how to fix this correctly.

Thx.

  • Hi,

    It is unfortunately not possible to "disable" one of the colors. I have asked one of the developers whether this is something we can add support for. I have not tested this myself, but have you tried implementing it as 2 monochromatic LEDs?

    For your second question, what are you trying to do exactly? What is the issue you are trying to solve? What do you mean by "custom SDK"?

  • Hello Oivind

    When I run the sample, after I adapt the board configuration with a Red + green pwm led output)

    The debugger hits the assert in the code at line 186  (it looks as intended by design to support 1 or 3 colors only :-)

       __ASSERT_NO_MSG((led->color_count == 1) || (led->color_count == 3));

    Hence my question to proper adapt the Nordic module without  migrate each time Nordic release a new ncs version.

    kind regards,
       nRF5xFanBoy
  • I did made a "custom SDK" this is a typical so called zephyr extended library contains re-usable modulair flexible components.

    The components are my (custom) building blocks for several applications I made in different (client) projects.
    Each component has a kconfig and cmakelist.txt next to source code file and header file.

    Depending on the board configuration and the build configuration in the project
    the components will be enable or disabled based upon the multiple boards definition in the project.

    I do like run / test my application on multiple vendor boards (stm32F411 nucleo / nordic 52840DK and a nxp board. ;-)

    So what i try to solve is the limitations of the CAF LED module in a correct manor without adapting the source code of the CAF LED module (and button module) each time Nordic release a new ncs version.

  • Ok, the developer is currently on holiday, and will look into a possible solution when he returns next week.

  • Hi Oivind

    In the file <ncs root>nrf\subsys\caf\led_effect.h
    there is a multi-channel color count
    #define
    _CAF_LED_COLOR_CHANNEL_COUNT 3
    So I can undef and redefine this into the value 2 (for a bi-color led)

    But unfortunaltly in the file <ncs root>nrf\subsys\caf\modules\leds.c
    the above define is not used  (but  replaced by a hardcoded value)
    __ASSERT_NO_MSG((led->color_count == 1) || (led->color_count == 3));

    It seems this is technical debt to be solved to support improved flexibility for multi-channel colored LEDs.


Related