flashLED is not blinking sometimes.

Hello

Currently we are using the https://github.com/mbientlab/MetaWear-SDK-iOS-macOS-tvOS Swift SDK and facing issues with Blinking LED sometimes not blinking is there any way to flashLED command delivery status?

used below function.

` public func flashLED(color: MBLColor, intensity: CGFloat, _repeat: UInt8 = 0xFF, onTime: UInt16 = 200, period: UInt16 = 800) {
assert(intensity >= 0.0 && intensity <= 1.0, "intensity valid range is [0, 1.0]")
guard mbl_mw_metawearboard_lookup_module(board, MBL_MW_MODULE_LED) != MODULE_TYPE_NA else {
return
}
let scaledIntensity = intensity * 31.0
let rtime = onTime / 2
let ftime = onTime / 2
let offset: UInt16 = 0

    var red: CGFloat = 0
    var blue: CGFloat = 0
    var green: CGFloat = 0
    color.getRed(&red, green: &green, blue: &blue, alpha: nil)
    let scaledRed = UInt8(round(red * scaledIntensity))
    let scaledBlue = UInt8(round(blue * scaledIntensity))
    let scaledGreen = UInt8(round(green * scaledIntensity))

    var pattern = MblMwLedPattern(high_intensity: 31,
                                  low_intensity: 0,
                                  rise_time_ms: rtime,
                                  high_time_ms: onTime,
                                  fall_time_ms: ftime,
                                  pulse_duration_ms: period,
                                  delay_time_ms: offset,
                                  repeat_count: _repeat)
    mbl_mw_led_stop_and_clear(board)
    if (scaledRed > 0) {
        pattern.high_intensity = scaledRed
        mbl_mw_led_write_pattern(board, &pattern, MBL_MW_LED_COLOR_RED)
    }
    if (scaledGreen > 0) {
        pattern.high_intensity = scaledGreen
        mbl_mw_led_write_pattern(board, &pattern, MBL_MW_LED_COLOR_GREEN)
    }
    if (scaledBlue > 0) {
        pattern.high_intensity = scaledBlue
        mbl_mw_led_write_pattern(board, &pattern, MBL_MW_LED_COLOR_BLUE)
    }
    mbl_mw_led_play(board)
}`

Comments

  • I've noticed sometimes I need to wait/pause a second before issuing the mbl_mw_led_play() command.
    Can you add that to your code and see if it makes a difference?

Sign In or Register to comment.