Hi all,
I just got a Pixelblaze, I’m completely new to addressable leds and I must say I’m very impressed with the possibilities.
I’m building a modular light for my girlfriend’s birthday, one where she will be able to connect wooden blocks that will contain a set number of leds(around 15 per block), and make any shape/length she wants-she loves puzzles and light, so I know she will love it:). I have solved all hardware issues, connections etc, but the code is way beyond my abilities.
I’m trying to have a few preset patterns for her to play, without having to touch the edit page as she is equally bad-or possibly worse- at it as I am. Given the modular nature of the light, I want her to have the ability to change colours or patterns along the strip and divide it as she pleases, all done with sliders.
I’ve played around with the multisegment pattern by @zranger1, it is pretty much what I’m looking for, but with one major problem: It won’t keep changes, on every restart it switches to defaults.
I understand that the way to go is to have local-per segment- variables stored, but given that they all share the same sliders, how is that possible?
I have many other questions, but I’d like to start with this one and keep the rest for later, some I might even succeed in answering myself:)
I’m not looking for someone to write the code for me, I’d like to understand how to do it myself, so please try to guide me through it.
By reading example patterns today, I managed to create the following, given my first foray in it I’m quite happy, no matter how simple-and possibly wrong it my look:
// Colour Picker 1
var hue1 = 0, saturation1 = 0, value1 = 1
export function hsvPickerHue1(_h, _s, _v) {
hue1 = _h
saturation1 = _s
value1 = _v
}
//Colour Picker 2
/*var hue2 = 0, saturation2 = 0, value2 = 1
export function hsvPickerHue2(_h, _s, _v) {
hue2 = _h
saturation2 = _s
value2 = _v
}
*/
export function sliderDepth(v) {
depth = (v * 30);
}
export function render(index) {
if (index < pixelCount / depth) {
hue = hue1
saturation = saturation1
value = value1
hsv(hue1, saturation1, value1)
} else {
hsv(time(.1) + index/-pixelCount, 1, 1)
}
}
/*export function render(index) {
if (index < pixelCount / depth) {
hue = hue1
saturation = saturation1
value = value1
} else {
hue = hue2
saturation = saturation2
value = value2
}
hsv(hue, saturation, value)
} */
The first test was a simple divide of colours with the ability to move the divide across the strip, after that I added a rainbow in the second part, that’s why part of the code is commented. This is of course nowhere near what I’m looking for and know that zranger1’s example is the way to go, but thought I’d post it to show I can at least understand this much:)
btw, how do I add code to a post? Clearly not the way I did it.