Microsoft MakeCode

Makecode Set strip command error

I am new to this. Have dabbled in some sketch but I am a newb.
I use win10
I have a Gemma m0
But the problem I am having is when I use the code provided for a project when I open it in makecode it throws error on the set strip line. I have tried rebuilding by hand. I had this working a week ago. I don’t think it has anything to do with the Gemma because I cannot get it to work in the visualizer/virtual model.
All I wanted to do was change the pixel count from 30 to 60 on the strip setup under start. Any ideas? Here is the file I am using to get this tested out. It worked with 30 on the Gemma I had it loaded on from where I was playing with the device bfore I wired it up. I also tried to upload with a spare Gemma I have and although the Gemma works the code will not upload because of the error.
https://maker.makecode.com/29855-53175-12460-49135

Will include photos.

Here is what the error looks like in Java

I have been plugging away at this for hours today. Probably more than 6.

I also have an Adafruit Circuit Playground Express. I was able to use that Microsoft MakeCode For Circuit Playground Express to make a very similar code for it. It went very easy.

For some reason the Microsoft MakeCode.com just will not allow me to set up a neopixel strip. I feel somewhat puzzled. As I was able to test the code but now I am unable to edit it without getting the error.

Anyway thanks if anyone can point me in the right direction.

I’ll take a peek later tonight.

1 Like

It has something to do with this here.
I was able to use this with java and make it work. I just need to understand why exactly.
Its an error in the 3rd statement somehow. I have learned a little with this. Just want to understand more.


This is what I came up with in Java from the github link that someone from Adafruit found for me. Just posting for others to see. I can only post one image in a post at this time so I will reply again with what it looks like in blocks.

Here is my example in blocks for others to see. I am at a little bit of a loss on how one would come up with this but I am learning. Now on to building a second set of what I am working on.

Looks like a compiler bug - thanks for reporting. As a temporary fix, specify the neopixel mode argument.

2 Likes

Great work reporting this bug! I wish the bug reports I got at work were this detailed and well described. I would say your username is not an accurate description of your ability to code (most of which is solving problems like this one).

@Peli thanks for the workaround

1 Like

The fix is live.

2 Likes

Thanks, I think I understand it was lacking the mode RGB designator but not sure why. does this have more to do with the website and how it incorporates libraries for functions?
is there a guide to building blocks

I took from Peli’s response that there was a compiler error, so there’s not much that users would be able to do. I tried to get this to work by specifying the RBG designator and didn’t have any luck.

I am not aware of a guide for building blocks. Is there a particular thing you’re trying to do?

1 Like

I would like to modify an animation or make a new one. I like the rainbow effect that is a animation. But I am interested in changing the order at which the pixels travel. The way I had to wrap my strip around the ears (mickey ear project from adafruit) to make it look like I think it should made the animation play the wrong way on one strip. IMO
I would like to also possible make one of the other animations like the blue or green chase in maybe some other colors. I feel like if I could edit the animations I could tailor them a little to something I am wanting.
I could then use this to possibly make some new animations to add to the library? is that what you all call the pre made blocks repository? I know there is a huge neopixel library for strand animations but I don’t know how to bring anything I am looking for into this makecode environment. Which for now is what I am using for this project. In the future I may look into writing this in circuitpython or something.

But for now if I could just edit the animations themselves it would be super cool.
Sorry I ramble.

An animation is an instance of a NeopixelAnimation class ( https://github.com/microsoft/pxt-common-packages/blob/master/libs/light/neopixel.ts#L1235 ). This class can be subclassed to define any custom animation you wish (see Rainbow animation https://github.com/microsoft/pxt-common-packages/blob/master/libs/light/neopixel.ts#L1247).
Once you have a subclass, declare a global variable that instantiates the animation object.
https://github.com/microsoft/pxt-common-packages/blob/master/libs/light/neopixel.ts#L1273 . Notice the special comments there specifically “fixedInstance” is needed.
The last piece of the puzzle is to generate the icon image (.jres file) in your extension for your animation. It currently requires to run a CLI but maybe we can make it simpler.

2 Likes

Ignore the enum; it’s there for legacy.

1 Like

@KMSkelton I don’t know why you deleted your posts I found them informing and I will try what you mentioned. I was able to read them through email notification.

Thanks for the link peli. I appreciate both of you giving me some input

I removed the posts because they weren’t accurate in light of Peli’s post. I was going to write an edit but the sysyem said I’d already made too many posts on this topic. At any rate… with the correct links (provided by Peli) the creation of the animations looks very straight forward. I’m pleased you found the explanations helpful

1 Like

After digging into the links you gave me Peli, I realize most of the pixels are set with math. Which would mean I would somehow have to declare some constant for pixels 30-60 to be reversed so that when 30 is pulled it would actually activate 60. ect ect. Which I would also have to do for my own code also.

We also support “ranges”, see the range(0, 30) function. It returns a sub-strip instance and you can run animation/set color on those as needed. So you can use ranges to partition a long strip into various sections.

2 Likes