Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blink1 MK2 only 1 LED is activated #327

Open
rsam70 opened this issue Mar 22, 2018 · 10 comments
Open

Blink1 MK2 only 1 LED is activated #327

rsam70 opened this issue Mar 22, 2018 · 10 comments

Comments

@rsam70
Copy link

rsam70 commented Mar 22, 2018

Platform Windows 10, using c# API.

For diagnose purposes we use solid(blinking) red,use solid(blinking) green,
use solid(blinking) blue, off.

It sometimes happens that only 1 LED is on whilest expected to be Both on.
folowing code snippet

if (ledColorMode.Mode == LedMode.Blinking)
{
     succes &= client.Blink.setPatternAtPosition(0, 0, 0, pwm, 0);
     succes &= client.Blink.setPatternAtPosition(ledColorMode.Color.R, ledColorMode.Color.G, ledColorMode.Color.B, pwm, 1);
     succes &= client.Blink.PlayPattern(true, 0, 1, 0); // on 
 }
else
{
     succes &= client.Blink.PlayPattern(false, 0, 1, 0); // off
     succes &= client.Blink.setRGB(ledColorMode.Color.R, ledColorMode.Color.G, ledColorMode.Color.B);
}
@todbot
Copy link
Owner

todbot commented Mar 22, 2018

Hi,
Which C# API are you using? I cannot tell from the methods you're using. It looks sort of like "Blink1Lib" and not "ManagedBlink1", but I don't see a PlayPattern() method in "Blink1Lib".

@rsam70
Copy link
Author

rsam70 commented Mar 22, 2018 via email

@laurencedobson
Copy link

laurencedobson commented Jun 4, 2019

I am currently experiencing this problem. My app is using the Blink1 C# API and hidlibrary v3.2.46 in a .NET 4.6.1 app.

The issue occurs from a fresh start-up or after resuming from sleep* with the device already connected. From this point on, calls to SetColor() still affect both LEDs but, calls to PlayPreset() affect only 1 LED. The issue is resolved when removing and re-attaching the Blink(1) device.

*I suspect that the "demo mode" (blue, red, green cycle), which appears to occur when the device is plugged in while not in communication with the OS/driver, might be the cause of the issue... perhaps it leaves the device in a state which the C# API doesn't reset/clear.

@todbot
Copy link
Owner

todbot commented Jun 4, 2019

Hi @laurencedobson,
A few questions:

  1. Which exact Blink1 C# API are you using? There are a few different ones. It may be the library can be fixed.
  2. Are you just sending SetColor() commands and no others?
  3. Does the problem persist if you change your SetColor() calls to FadeToColor(10,...)? (This should be visually the same)
  4. Are there any other apps running trying to talk to the blink(1) device?
  5. What firmware version is the blink(1) device running? You can find this with blink1-control.exe --fwversion

(As for which C# API, I normally suggest people use the Sleddog.Blink1 on NuGet just because it's 100% .NET (no C library dependency) and it's in a package manager. Second choice would be our ManagedBlink1 library since it's also 100% .NET.)

@laurencedobson
Copy link

laurencedobson commented Jun 5, 2019

Hi @todbot. Thanks for getting back to me.
Answers to your questions:

  1. I am using "@ThingM.Blink1 managed Library", according to the Assembly Information "Title"
  2. I call SetColor() to set the device to a solid white (idle) color. Then I use SavePreset() to fill up each of the 32 available presets and PlayPreset(0) to make the device flash alerts
  3. I'll give this a try let you know shortly
  4. No, no other blink(1) apps installed/running
  5. My app is running on a number of workstations, each with their own device - and each exhibiting the same symptoms. The particular device that I am testing on is reported as:
    id:0 - firmware:204 serialnum:XXXXXXXX (mk2)

I note that, when using Blink1Control.exe, everything works as expected. When I then exit and run my app instead, the symptoms still persist.

@laurencedobson
Copy link

laurencedobson commented Jun 5, 2019

Follow-up for 3: Substituting SetColor() with FadetoColor() appears to have made no difference - either solution lights both LEDs correctly and calling SavePreset() and PlayPreset() still exhibits lighting on a single LED.

@laurencedobson
Copy link

laurencedobson commented Jun 5, 2019

While poking around with the command-line tool, blink1-tool.exe, I have found that writing my pattern to the flash memory (overwriting the default alternating pattern) prevents the issue from occurring on future system start-ups. This seems to suggest that saving a pattern to the device which contains led switching might be the root cause, presumably because the .NET library doesn't specify which LED to light when writing patterns to it.

@laurencedobson
Copy link

laurencedobson commented Jun 5, 2019

On a device exhibiting this issue, the pattern being written to it is different. Here's what I did...

  1. After start-up, the app sets the pattern.
  2. I inspect the pattern stored on the device by use of: blink1-tool.exe --readpattern
    The output is:
    {0,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1,#000078,0.50,1,#00c832,0.50,1}

The pattern uses 1 (which denotes LED 1 only)

  1. I then unplug the device and the app sets the pattern again.
  2. This time, I get a different pattern when I repeat: blink1-tool.exe --readpattern

Output:
{0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0,#000078,0.50,0,#00c832,0.50,0}

This time, the pattern is set to uses 0 (denoting both LEDs).

@laurencedobson
Copy link

laurencedobson commented Jun 5, 2019

Additionally, while exhibiting the issue, using blink1-tool.exe to play the pattern on a specific LED results in the pattern playing on LED 1, regardless of which LED I specify. Therefore, each of the following commands produces the same result:

blink1-tool.exe --play 1,0 -l 0
blink1-tool.exe --play 1,0 -l 1
blink1-tool.exe --play 1,0 -l 2

@laurencedobson
Copy link

laurencedobson commented Jun 5, 2019

I realised that what I needed was a way to specify the LED number via the .NET library, so...

  1. I took a look in the /hardware folder in this repository, specifically hardware/firmware_mk2/main.c (https://github.com/todbot/blink1/blob/master/hardware/firmware_mk2/main.c)
  2. I found the "Available Commands" comments section @ line 476
  3. This informed me of the command that I would need, Set ledn @ line 486
  4. I wrote an additional function, SetLED() in blink1/windows/ManagedBlink1/Blink1/Blink1.cs which does the necessary hidlibrary communication with the blink(1) device
  5. Then I modified the SavePreset() function to take an additional ledn parameter and call the new SetLED() function prior to saving the preset to the device

Now, ensuring the device was still exhibiting the issue, I then ran the new code to set the pattern and play it... AND IT WORKED :)

I'll get the changes put into a PR for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants