0

AdafruitClassLibrary - DotStar
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

AdafruitClassLibrary - DotStar

by seitz on Tue Sep 19, 2017 4:43 am

Hi, I'm trying to control a DotStar Strip with the AdafruitClassLibrary in Visual Studio 2017.
I've wrote a very simple program to learn how the class library works:
Two buttons, one button to turn led 2 on and one button to turn led 2 off.

It works but i have to click twice on the buttons to se a change. why?

Here the code:

Code: Select all | TOGGLE FULL SIZE
namespace Seitz.Assembly.IoT.Controller
{
    public sealed partial class MainPage : Page
    {
        public DotStar Strip { get; set; }
        private const int PixelNumber = 30;

        public MainPage()
        {
            this.InitializeComponent();
            Strip = new DotStar(PixelNumber, DotStar.DOTSTAR_GBR);
        }

        private async void MainPage_OnLoaded(object sender, RoutedEventArgs e)
        {
            await Strip.BeginAsync();
            Strip.Clear();
            Strip.Show();
        }

        private void On_Click(object sender, RoutedEventArgs e)
        {
            Strip.SetPixelColor(2, 255, 0, 0);
            Strip.Show();
        }

        private void Off_Click(object sender, RoutedEventArgs e)
        {
            Strip.SetPixelColor(2, 0, 0, 0);
            Strip.Show();
        }
       
    }
}


seitz
 
Posts: 3
Joined: Tue Sep 19, 2017 4:28 am

Re: AdafruitClassLibrary - DotStar

by adafruit_support_rick on Tue Sep 19, 2017 8:53 am

Wow - I don't know. Maybe it's a problem with the on-click functions?

Have you tried stepping into the click calls? Are they getting called twice?

Alternately, you can add a couple of debug statements to the click calls to see if they're getting called twice:
[code] private void On_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine(string.Format("On_Click called"));
Strip.SetPixelColor(2, 255, 0, 0);
Strip.Show();
}/code]

The Dotstar strip on my Pi is offline for a couple of days - I lent my level shifter chip to friend. I'll have another in a day or two.

Meanwhile, can you zip up your solution and post it here? I'll give it a try and see what I can figure out.

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: AdafruitClassLibrary - DotStar

by seitz on Tue Sep 19, 2017 9:34 am

Thank you for the quick reply.
Here it is the zipped solution.

The click calls are not getting called twice... I have to click twice on the buttons...
I figured out that in order to work, I need to call the _pixelStrip.Show(); twice on the On_Click Event.
This behavior shows up when i put _pixelStrip.Clear(); in the MainPage_Loaded Event. If I comment out _pixelStrip.Clear(); from the MainPage_Loaded Event (and comment out the second _pixelStrip.Show();) then i have to click just once one the button... but i can only address the first pixel.
Very strange...

I hope I could express myself clearly ;-)
Do you have a simple example with UWP and DotStar which you can upload? This would me help a lot.
Attachments
Seitz.Assembly.zip
(536.2 KiB) Downloaded 2 times

seitz
 
Posts: 3
Joined: Tue Sep 19, 2017 4:28 am

Re: AdafruitClassLibrary - DotStar

by adafruit_support_rick on Tue Sep 19, 2017 10:54 am

Just published a Dot Star demo solution:
https://github.com/adafruit/DotStarDemo

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: AdafruitClassLibrary - DotStar

by adafruit_support_rick on Wed Sep 20, 2017 12:31 pm

Okay - I just ran your app, and it works for me. No need to double-click, no need to call _pixelStrip.Show twice.

I don't know why it's not working for you, but it does not seem to be a problem with the DotStar class

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: AdafruitClassLibrary - DotStar

by seitz on Wed Sep 20, 2017 12:38 pm

Did you notice that in my app i call the _pixelStrip.Show() twice in row?
What happens on your System if you comment out one _pixelStrip.Show()?

seitz
 
Posts: 3
Joined: Tue Sep 19, 2017 4:28 am

Re: AdafruitClassLibrary - DotStar

by adafruit_support_rick on Wed Sep 20, 2017 3:12 pm

Yes, I know. As I said, I don't have to call show twice.

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Please be positive and constructive with your questions and comments.