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

TURNING ON LED IN THINGY:52 ?

I want to turn on the LED in Thingy:52 in a particular color if a particular condition is satisfied. How can I address the LED and turn the LED on in the desired color in my program.

Parents
  • Have you taken a look at the Thingy source code yet? The m_ui.c & m_ui.h files should be helpful for getting started.

    You can set the LED color either via the m_ui_led_set() or via the m_ui_led_set_event() functions:

    /**@brief Function for setting the RGB value of an LED.
     *
     * @param[in]   r   Red intensity (0 to 255).
     * @param[in]   g   Green intensity (0 to 255).
     * @param[in]   b   Blue intensity (0 to 255).
     *
     * @note In Breathe or One-shot mode, the intensity will be set via a separate intensity variable.
     * The values entered in these two modes will be treated as binary (Boolean) for each color.
     *
     * @retval NRF_SUCCESS      Operation was successful.
     * @retval Other codes from the underlying drivers.
     */
    ret_code_t m_ui_led_set(uint8_t r, uint8_t g, uint8_t b);
    
    /**
     * @brief Function for setting LED color according to predefined events.
     *
     * @param[in]   event_code  Predefined event code.
     *
     * @retval NRF_SUCCESS      If initialization was successful.
     * @retval Other codes from the underlying drivers.
     */
    ret_code_t m_ui_led_set_event(ui_led_events event_code);

Reply
  • Have you taken a look at the Thingy source code yet? The m_ui.c & m_ui.h files should be helpful for getting started.

    You can set the LED color either via the m_ui_led_set() or via the m_ui_led_set_event() functions:

    /**@brief Function for setting the RGB value of an LED.
     *
     * @param[in]   r   Red intensity (0 to 255).
     * @param[in]   g   Green intensity (0 to 255).
     * @param[in]   b   Blue intensity (0 to 255).
     *
     * @note In Breathe or One-shot mode, the intensity will be set via a separate intensity variable.
     * The values entered in these two modes will be treated as binary (Boolean) for each color.
     *
     * @retval NRF_SUCCESS      Operation was successful.
     * @retval Other codes from the underlying drivers.
     */
    ret_code_t m_ui_led_set(uint8_t r, uint8_t g, uint8_t b);
    
    /**
     * @brief Function for setting LED color according to predefined events.
     *
     * @param[in]   event_code  Predefined event code.
     *
     * @retval NRF_SUCCESS      If initialization was successful.
     * @retval Other codes from the underlying drivers.
     */
    ret_code_t m_ui_led_set_event(ui_led_events event_code);

Children
No Data
Related