Generating code from Static Patterns

wow, that’s amazing! The sample file here is a PNG, but I could easily live with GIF if the system doesn’t read PNGs. The included file is actually oversized at 200px tall, but my strip is only 123 LEDs. However, I’d just assume that when a pattern image is created, that the maker will crop it to match the number of vertical pixels to the number of LEDs in their strip (since it’s going to vary for different hardware setups) Feel free to crop it however you need in order to test.

Thank you for your input.static pattern 200tallx1wide

Hi Troy. I’ve actually started but will need to come back later to finish it off - other things getting in the way at the moment! Will drop some code here when I’ve sorted it out! I’m not sure why I mentioned GIF - PNG is much more preferable and it’s already reading a PNG file I knocked up!

Totally understand, I’m just appreciative for the help, regardless of when it happens!

Thanks

You could try this (I’ve not fully checked it but hopefully it works):

export var pattern = array(200);
pattern[0] = 0;
pattern[1] = 0;
pattern[2] = 0;
pattern[3] = 0;
pattern[4] = 424628;
pattern[5] = 424628;
pattern[6] = 424628;
pattern[7] = 424628;
pattern[8] = 424628;
pattern[9] = 424628;
pattern[10] = 424628;
pattern[11] = 424628;
pattern[12] = 424628;
pattern[13] = 424628;
pattern[14] = 424628;
pattern[15] = 424628;
pattern[16] = 424628;
pattern[17] = 424628;
pattern[18] = 424628;
pattern[19] = 424628;
pattern[20] = 424628;
pattern[21] = 424628;
pattern[22] = 424628;
pattern[23] = 0;
pattern[24] = 0;
pattern[25] = 0;
pattern[26] = 0;
pattern[27] = 0;
pattern[28] = 0;
pattern[29] = 0;
pattern[30] = 0;
pattern[31] = 424628;
pattern[32] = 424628;
pattern[33] = 424628;
pattern[34] = 424628;
pattern[35] = 424628;
pattern[36] = 424628;
pattern[37] = 424628;
pattern[38] = 424628;
pattern[39] = 424628;
pattern[40] = 424628;
pattern[41] = 424628;
pattern[42] = 424628;
pattern[43] = 424628;
pattern[44] = 424628;
pattern[45] = 424628;
pattern[46] = 424628;
pattern[47] = 424628;
pattern[48] = 424628;
pattern[49] = 424628;
pattern[50] = 0;
pattern[51] = 0;
pattern[52] = 0;
pattern[53] = 0;
pattern[54] = 0;
pattern[55] = 0;
pattern[56] = 0;
pattern[57] = 0;
pattern[58] = 424628;
pattern[59] = 424628;
pattern[60] = 424628;
pattern[61] = 424628;
pattern[62] = 424628;
pattern[63] = 424628;
pattern[64] = 424628;
pattern[65] = 424628;
pattern[66] = 424628;
pattern[67] = 424628;
pattern[68] = 424628;
pattern[69] = 424628;
pattern[70] = 424628;
pattern[71] = 424628;
pattern[72] = 424628;
pattern[73] = 424628;
pattern[74] = 424628;
pattern[75] = 424628;
pattern[76] = 424628;
pattern[77] = 0;
pattern[78] = 0;
pattern[79] = 0;
pattern[80] = 0;
pattern[81] = 0;
pattern[82] = 0;
pattern[83] = 0;
pattern[84] = 0;
pattern[85] = 424628;
pattern[86] = 424628;
pattern[87] = 424628;
pattern[88] = 424628;
pattern[89] = 424628;
pattern[90] = 424628;
pattern[91] = 424628;
pattern[92] = 424628;
pattern[93] = 424628;
pattern[94] = 424628;
pattern[95] = 424628;
pattern[96] = 424628;
pattern[97] = 424628;
pattern[98] = 424628;
pattern[99] = 424628;
pattern[100] = 424628;
pattern[101] = 424628;
pattern[102] = 424628;
pattern[103] = 424628;
pattern[104] = 424628;
pattern[105] = 0;
pattern[106] = 0;
pattern[107] = 0;
pattern[108] = 0;
pattern[109] = 0;
pattern[110] = 0;
pattern[111] = 0;
pattern[112] = 16777215;
pattern[113] = 16777215;
pattern[114] = 16777215;
pattern[115] = 16777215;
pattern[116] = 16777215;
pattern[117] = 16777215;
pattern[118] = 16777215;
pattern[119] = 16777215;
pattern[120] = 16777215;
pattern[121] = 16777215;
pattern[122] = 16777215;
pattern[123] = 16777215;
pattern[124] = 16777215;
pattern[125] = 16777215;
pattern[126] = 16777215;
pattern[127] = 16777215;
pattern[128] = 16777215;
pattern[129] = 16777215;
pattern[130] = 16777215;
pattern[131] = 16777215;
pattern[132] = 16777215;
pattern[133] = 16777215;
pattern[134] = 16777215;
pattern[135] = 16777215;
pattern[136] = 16777215;
pattern[137] = 16777215;
pattern[138] = 16777215;
pattern[139] = 16777215;
pattern[140] = 16777215;
pattern[141] = 16777215;
pattern[142] = 16777215;
pattern[143] = 16777215;
pattern[144] = 16777215;
pattern[145] = 16777215;
pattern[146] = 16777215;
pattern[147] = 16777215;
pattern[148] = 16777215;
pattern[149] = 16777215;
pattern[150] = 16777215;
pattern[151] = 16777215;
pattern[152] = 16777215;
pattern[153] = 16777215;
pattern[154] = 16777215;
pattern[155] = 16777215;
pattern[156] = 16777215;
pattern[157] = 16777215;
pattern[158] = 16777215;
pattern[159] = 16777215;
pattern[160] = 16777215;
pattern[161] = 16777215;
pattern[162] = 16777215;
pattern[163] = 16777215;
pattern[164] = 16777215;
pattern[165] = 16777215;
pattern[166] = 16777215;
pattern[167] = 16777215;
pattern[168] = 16777215;
pattern[169] = 0;
pattern[170] = 0;
pattern[171] = 0;
pattern[172] = 0;
pattern[173] = 0;
pattern[174] = 0;
pattern[175] = 0;
pattern[176] = 0;
pattern[177] = 424628;
pattern[178] = 424628;
pattern[179] = 424628;
pattern[180] = 424628;
pattern[181] = 424628;
pattern[182] = 424628;
pattern[183] = 424628;
pattern[184] = 424628;
pattern[185] = 424628;
pattern[186] = 424628;
pattern[187] = 424628;
pattern[188] = 424628;
pattern[189] = 424628;
pattern[190] = 424628;
pattern[191] = 424628;
pattern[192] = 424628;
pattern[193] = 424628;
pattern[194] = 424628;
pattern[195] = 424628;
pattern[196] = 0;
pattern[197] = 0;
pattern[198] = 0;
pattern[199] = 0;

export function render(index) {
  r = pattern[index] & 0xff0000 >> 16;
  g = pattern[index] & 0xff00 >> 8;
  b = pattern[index] & 0xff;
  
  rgb(r, g, b);
}

If it works OK then I’ll explain what I did!

1 Like

@zeb,
Cool, stoked that you are helping out with a converter! BTW PB’s variables and constants are limited to ±32,767, as they are 16.16 fixed point numbers. If you want to stuff 3 bytes into a value, you need to divide by 256 to get your constants. e.g. 1658.703125 instead of 424628. Now your red and green are 8 less shifts, and your blue is 8 shifts left.

1 Like

Aha, that makes sense now. I remember seeing that in Jeff’s code for the scrolling text and wasn’t entirely sure why it was like that! Here’s another attempt at the code (if it doesn’t work then my excuse is that I don’t have a PixelBlaze with me at the moment to test it on!):

export var pattern = array(200);
pattern[0] = 0;
pattern[1] = 0;
pattern[2] = 0;
pattern[3] = 0;
pattern[4] = 1658.703125;
pattern[5] = 1658.703125;
pattern[6] = 1658.703125;
pattern[7] = 1658.703125;
pattern[8] = 1658.703125;
pattern[9] = 1658.703125;
pattern[10] = 1658.703125;
pattern[11] = 1658.703125;
pattern[12] = 1658.703125;
pattern[13] = 1658.703125;
pattern[14] = 1658.703125;
pattern[15] = 1658.703125;
pattern[16] = 1658.703125;
pattern[17] = 1658.703125;
pattern[18] = 1658.703125;
pattern[19] = 1658.703125;
pattern[20] = 1658.703125;
pattern[21] = 1658.703125;
pattern[22] = 1658.703125;
pattern[23] = 0;
pattern[24] = 0;
pattern[25] = 0;
pattern[26] = 0;
pattern[27] = 0;
pattern[28] = 0;
pattern[29] = 0;
pattern[30] = 0;
pattern[31] = 1658.703125;
pattern[32] = 1658.703125;
pattern[33] = 1658.703125;
pattern[34] = 1658.703125;
pattern[35] = 1658.703125;
pattern[36] = 1658.703125;
pattern[37] = 1658.703125;
pattern[38] = 1658.703125;
pattern[39] = 1658.703125;
pattern[40] = 1658.703125;
pattern[41] = 1658.703125;
pattern[42] = 1658.703125;
pattern[43] = 1658.703125;
pattern[44] = 1658.703125;
pattern[45] = 1658.703125;
pattern[46] = 1658.703125;
pattern[47] = 1658.703125;
pattern[48] = 1658.703125;
pattern[49] = 1658.703125;
pattern[50] = 0;
pattern[51] = 0;
pattern[52] = 0;
pattern[53] = 0;
pattern[54] = 0;
pattern[55] = 0;
pattern[56] = 0;
pattern[57] = 0;
pattern[58] = 1658.703125;
pattern[59] = 1658.703125;
pattern[60] = 1658.703125;
pattern[61] = 1658.703125;
pattern[62] = 1658.703125;
pattern[63] = 1658.703125;
pattern[64] = 1658.703125;
pattern[65] = 1658.703125;
pattern[66] = 1658.703125;
pattern[67] = 1658.703125;
pattern[68] = 1658.703125;
pattern[69] = 1658.703125;
pattern[70] = 1658.703125;
pattern[71] = 1658.703125;
pattern[72] = 1658.703125;
pattern[73] = 1658.703125;
pattern[74] = 1658.703125;
pattern[75] = 1658.703125;
pattern[76] = 1658.703125;
pattern[77] = 0;
pattern[78] = 0;
pattern[79] = 0;
pattern[80] = 0;
pattern[81] = 0;
pattern[82] = 0;
pattern[83] = 0;
pattern[84] = 0;
pattern[85] = 1658.703125;
pattern[86] = 1658.703125;
pattern[87] = 1658.703125;
pattern[88] = 1658.703125;
pattern[89] = 1658.703125;
pattern[90] = 1658.703125;
pattern[91] = 1658.703125;
pattern[92] = 1658.703125;
pattern[93] = 1658.703125;
pattern[94] = 1658.703125;
pattern[95] = 1658.703125;
pattern[96] = 1658.703125;
pattern[97] = 1658.703125;
pattern[98] = 1658.703125;
pattern[99] = 1658.703125;
pattern[100] = 1658.703125;
pattern[101] = 1658.703125;
pattern[102] = 1658.703125;
pattern[103] = 1658.703125;
pattern[104] = 1658.703125;
pattern[105] = 0;
pattern[106] = 0;
pattern[107] = 0;
pattern[108] = 0;
pattern[109] = 0;
pattern[110] = 0;
pattern[111] = 0;
pattern[112] = 65535.99609375;
pattern[113] = 65535.99609375;
pattern[114] = 65535.99609375;
pattern[115] = 65535.99609375;
pattern[116] = 65535.99609375;
pattern[117] = 65535.99609375;
pattern[118] = 65535.99609375;
pattern[119] = 65535.99609375;
pattern[120] = 65535.99609375;
pattern[121] = 65535.99609375;
pattern[122] = 65535.99609375;
pattern[123] = 65535.99609375;
pattern[124] = 65535.99609375;
pattern[125] = 65535.99609375;
pattern[126] = 65535.99609375;
pattern[127] = 65535.99609375;
pattern[128] = 65535.99609375;
pattern[129] = 65535.99609375;
pattern[130] = 65535.99609375;
pattern[131] = 65535.99609375;
pattern[132] = 65535.99609375;
pattern[133] = 65535.99609375;
pattern[134] = 65535.99609375;
pattern[135] = 65535.99609375;
pattern[136] = 65535.99609375;
pattern[137] = 65535.99609375;
pattern[138] = 65535.99609375;
pattern[139] = 65535.99609375;
pattern[140] = 65535.99609375;
pattern[141] = 65535.99609375;
pattern[142] = 65535.99609375;
pattern[143] = 65535.99609375;
pattern[144] = 65535.99609375;
pattern[145] = 65535.99609375;
pattern[146] = 65535.99609375;
pattern[147] = 65535.99609375;
pattern[148] = 65535.99609375;
pattern[149] = 65535.99609375;
pattern[150] = 65535.99609375;
pattern[151] = 65535.99609375;
pattern[152] = 65535.99609375;
pattern[153] = 65535.99609375;
pattern[154] = 65535.99609375;
pattern[155] = 65535.99609375;
pattern[156] = 65535.99609375;
pattern[157] = 65535.99609375;
pattern[158] = 65535.99609375;
pattern[159] = 65535.99609375;
pattern[160] = 65535.99609375;
pattern[161] = 65535.99609375;
pattern[162] = 65535.99609375;
pattern[163] = 65535.99609375;
pattern[164] = 65535.99609375;
pattern[165] = 65535.99609375;
pattern[166] = 65535.99609375;
pattern[167] = 65535.99609375;
pattern[168] = 65535.99609375;
pattern[169] = 0;
pattern[170] = 0;
pattern[171] = 0;
pattern[172] = 0;
pattern[173] = 0;
pattern[174] = 0;
pattern[175] = 0;
pattern[176] = 0;
pattern[177] = 1658.703125;
pattern[178] = 1658.703125;
pattern[179] = 1658.703125;
pattern[180] = 1658.703125;
pattern[181] = 1658.703125;
pattern[182] = 1658.703125;
pattern[183] = 1658.703125;
pattern[184] = 1658.703125;
pattern[185] = 1658.703125;
pattern[186] = 1658.703125;
pattern[187] = 1658.703125;
pattern[188] = 1658.703125;
pattern[189] = 1658.703125;
pattern[190] = 1658.703125;
pattern[191] = 1658.703125;
pattern[192] = 1658.703125;
pattern[193] = 1658.703125;
pattern[194] = 1658.703125;
pattern[195] = 1658.703125;
pattern[196] = 0;
pattern[197] = 0;
pattern[198] = 0;
pattern[199] = 0;

export function render(index) {
  r = (pattern[index] >> 8) & 0xff;
  g = pattern[index] & 0xff;
  b = (pattern[index] << 8) & 0xff;

  rgb(r, g, b);
}

OK, here’s one that’s tested now that I have access to my PixelBlaze… And it even works (on my string of 128 WS2812Bs I have handy! HSV variant to follow…

export var pattern = array(200);
pattern[0] = 0;
pattern[1] = 0;
pattern[2] = 0;
pattern[3] = 0;
pattern[4] = 1658.703125;
pattern[5] = 1658.703125;
pattern[6] = 1658.703125;
pattern[7] = 1658.703125;
pattern[8] = 1658.703125;
pattern[9] = 1658.703125;
pattern[10] = 1658.703125;
pattern[11] = 1658.703125;
pattern[12] = 1658.703125;
pattern[13] = 1658.703125;
pattern[14] = 1658.703125;
pattern[15] = 1658.703125;
pattern[16] = 1658.703125;
pattern[17] = 1658.703125;
pattern[18] = 1658.703125;
pattern[19] = 1658.703125;
pattern[20] = 1658.703125;
pattern[21] = 1658.703125;
pattern[22] = 1658.703125;
pattern[23] = 0;
pattern[24] = 0;
pattern[25] = 0;
pattern[26] = 0;
pattern[27] = 0;
pattern[28] = 0;
pattern[29] = 0;
pattern[30] = 0;
pattern[31] = 1658.703125;
pattern[32] = 1658.703125;
pattern[33] = 1658.703125;
pattern[34] = 1658.703125;
pattern[35] = 1658.703125;
pattern[36] = 1658.703125;
pattern[37] = 1658.703125;
pattern[38] = 1658.703125;
pattern[39] = 1658.703125;
pattern[40] = 1658.703125;
pattern[41] = 1658.703125;
pattern[42] = 1658.703125;
pattern[43] = 1658.703125;
pattern[44] = 1658.703125;
pattern[45] = 1658.703125;
pattern[46] = 1658.703125;
pattern[47] = 1658.703125;
pattern[48] = 1658.703125;
pattern[49] = 1658.703125;
pattern[50] = 0;
pattern[51] = 0;
pattern[52] = 0;
pattern[53] = 0;
pattern[54] = 0;
pattern[55] = 0;
pattern[56] = 0;
pattern[57] = 0;
pattern[58] = 1658.703125;
pattern[59] = 1658.703125;
pattern[60] = 1658.703125;
pattern[61] = 1658.703125;
pattern[62] = 1658.703125;
pattern[63] = 1658.703125;
pattern[64] = 1658.703125;
pattern[65] = 1658.703125;
pattern[66] = 1658.703125;
pattern[67] = 1658.703125;
pattern[68] = 1658.703125;
pattern[69] = 1658.703125;
pattern[70] = 1658.703125;
pattern[71] = 1658.703125;
pattern[72] = 1658.703125;
pattern[73] = 1658.703125;
pattern[74] = 1658.703125;
pattern[75] = 1658.703125;
pattern[76] = 1658.703125;
pattern[77] = 0;
pattern[78] = 0;
pattern[79] = 0;
pattern[80] = 0;
pattern[81] = 0;
pattern[82] = 0;
pattern[83] = 0;
pattern[84] = 0;
pattern[85] = 1658.703125;
pattern[86] = 1658.703125;
pattern[87] = 1658.703125;
pattern[88] = 1658.703125;
pattern[89] = 1658.703125;
pattern[90] = 1658.703125;
pattern[91] = 1658.703125;
pattern[92] = 1658.703125;
pattern[93] = 1658.703125;
pattern[94] = 1658.703125;
pattern[95] = 1658.703125;
pattern[96] = 1658.703125;
pattern[97] = 1658.703125;
pattern[98] = 1658.703125;
pattern[99] = 1658.703125;
pattern[100] = 1658.703125;
pattern[101] = 1658.703125;
pattern[102] = 1658.703125;
pattern[103] = 1658.703125;
pattern[104] = 1658.703125;
pattern[105] = 0;
pattern[106] = 0;
pattern[107] = 0;
pattern[108] = 0;
pattern[109] = 0;
pattern[110] = 0;
pattern[111] = 0;
pattern[112] = -0.00390625;
pattern[113] = -0.00390625;
pattern[114] = -0.00390625;
pattern[115] = -0.00390625;
pattern[116] = -0.00390625;
pattern[117] = -0.00390625;
pattern[118] = -0.00390625;
pattern[119] = -0.00390625;
pattern[120] = -0.00390625;
pattern[121] = -0.00390625;
pattern[122] = -0.00390625;
pattern[123] = -0.00390625;
pattern[124] = -0.00390625;
pattern[125] = -0.00390625;
pattern[126] = -0.00390625;
pattern[127] = -0.00390625;
pattern[128] = -0.00390625;
pattern[129] = -0.00390625;
pattern[130] = -0.00390625;
pattern[131] = -0.00390625;
pattern[132] = -0.00390625;
pattern[133] = -0.00390625;
pattern[134] = -0.00390625;
pattern[135] = -0.00390625;
pattern[136] = -0.00390625;
pattern[137] = -0.00390625;
pattern[138] = -0.00390625;
pattern[139] = -0.00390625;
pattern[140] = -0.00390625;
pattern[141] = -0.00390625;
pattern[142] = -0.00390625;
pattern[143] = -0.00390625;
pattern[144] = -0.00390625;
pattern[145] = -0.00390625;
pattern[146] = -0.00390625;
pattern[147] = -0.00390625;
pattern[148] = -0.00390625;
pattern[149] = -0.00390625;
pattern[150] = -0.00390625;
pattern[151] = -0.00390625;
pattern[152] = -0.00390625;
pattern[153] = -0.00390625;
pattern[154] = -0.00390625;
pattern[155] = -0.00390625;
pattern[156] = -0.00390625;
pattern[157] = -0.00390625;
pattern[158] = -0.00390625;
pattern[159] = -0.00390625;
pattern[160] = -0.00390625;
pattern[161] = -0.00390625;
pattern[162] = -0.00390625;
pattern[163] = -0.00390625;
pattern[164] = -0.00390625;
pattern[165] = -0.00390625;
pattern[166] = -0.00390625;
pattern[167] = -0.00390625;
pattern[168] = -0.00390625;
pattern[169] = 0;
pattern[170] = 0;
pattern[171] = 0;
pattern[172] = 0;
pattern[173] = 0;
pattern[174] = 0;
pattern[175] = 0;
pattern[176] = 0;
pattern[177] = 1658.703125;
pattern[178] = 1658.703125;
pattern[179] = 1658.703125;
pattern[180] = 1658.703125;
pattern[181] = 1658.703125;
pattern[182] = 1658.703125;
pattern[183] = 1658.703125;
pattern[184] = 1658.703125;
pattern[185] = 1658.703125;
pattern[186] = 1658.703125;
pattern[187] = 1658.703125;
pattern[188] = 1658.703125;
pattern[189] = 1658.703125;
pattern[190] = 1658.703125;
pattern[191] = 1658.703125;
pattern[192] = 1658.703125;
pattern[193] = 1658.703125;
pattern[194] = 1658.703125;
pattern[195] = 1658.703125;
pattern[196] = 0;
pattern[197] = 0;
pattern[198] = 0;
pattern[199] = 0;

export function render(index) {
  r = ((pattern[index] >> 8) & 0xff) >> 8;
  g = (pattern[index] & 0xff) >> 8;
  b = ((pattern[index] << 8) & 0xff) >> 8;

  rgb(r, g, b);
}

And for good measure, here’s the HSV version:

export var pattern = array(200);
pattern[0] = 0;
pattern[1] = 0;
pattern[2] = 0;
pattern[3] = 0;
pattern[4] = 200.37606811523;
pattern[5] = 200.37606811523;
pattern[6] = 200.37606811523;
pattern[7] = 200.37606811523;
pattern[8] = 200.37606811523;
pattern[9] = 200.37606811523;
pattern[10] = 200.37606811523;
pattern[11] = 200.37606811523;
pattern[12] = 200.37606811523;
pattern[13] = 200.37606811523;
pattern[14] = 200.37606811523;
pattern[15] = 200.37606811523;
pattern[16] = 200.37606811523;
pattern[17] = 200.37606811523;
pattern[18] = 200.37606811523;
pattern[19] = 200.37606811523;
pattern[20] = 200.37606811523;
pattern[21] = 200.37606811523;
pattern[22] = 200.37606811523;
pattern[23] = 0;
pattern[24] = 0;
pattern[25] = 0;
pattern[26] = 0;
pattern[27] = 0;
pattern[28] = 0;
pattern[29] = 0;
pattern[30] = 0;
pattern[31] = 200.37606811523;
pattern[32] = 200.37606811523;
pattern[33] = 200.37606811523;
pattern[34] = 200.37606811523;
pattern[35] = 200.37606811523;
pattern[36] = 200.37606811523;
pattern[37] = 200.37606811523;
pattern[38] = 200.37606811523;
pattern[39] = 200.37606811523;
pattern[40] = 200.37606811523;
pattern[41] = 200.37606811523;
pattern[42] = 200.37606811523;
pattern[43] = 200.37606811523;
pattern[44] = 200.37606811523;
pattern[45] = 200.37606811523;
pattern[46] = 200.37606811523;
pattern[47] = 200.37606811523;
pattern[48] = 200.37606811523;
pattern[49] = 200.37606811523;
pattern[50] = 0;
pattern[51] = 0;
pattern[52] = 0;
pattern[53] = 0;
pattern[54] = 0;
pattern[55] = 0;
pattern[56] = 0;
pattern[57] = 0;
pattern[58] = 200.37606811523;
pattern[59] = 200.37606811523;
pattern[60] = 200.37606811523;
pattern[61] = 200.37606811523;
pattern[62] = 200.37606811523;
pattern[63] = 200.37606811523;
pattern[64] = 200.37606811523;
pattern[65] = 200.37606811523;
pattern[66] = 200.37606811523;
pattern[67] = 200.37606811523;
pattern[68] = 200.37606811523;
pattern[69] = 200.37606811523;
pattern[70] = 200.37606811523;
pattern[71] = 200.37606811523;
pattern[72] = 200.37606811523;
pattern[73] = 200.37606811523;
pattern[74] = 200.37606811523;
pattern[75] = 200.37606811523;
pattern[76] = 200.37606811523;
pattern[77] = 0;
pattern[78] = 0;
pattern[79] = 0;
pattern[80] = 0;
pattern[81] = 0;
pattern[82] = 0;
pattern[83] = 0;
pattern[84] = 0;
pattern[85] = 200.37606811523;
pattern[86] = 200.37606811523;
pattern[87] = 200.37606811523;
pattern[88] = 200.37606811523;
pattern[89] = 200.37606811523;
pattern[90] = 200.37606811523;
pattern[91] = 200.37606811523;
pattern[92] = 200.37606811523;
pattern[93] = 200.37606811523;
pattern[94] = 200.37606811523;
pattern[95] = 200.37606811523;
pattern[96] = 200.37606811523;
pattern[97] = 200.37606811523;
pattern[98] = 200.37606811523;
pattern[99] = 200.37606811523;
pattern[100] = 200.37606811523;
pattern[101] = 200.37606811523;
pattern[102] = 200.37606811523;
pattern[103] = 200.37606811523;
pattern[104] = 200.37606811523;
pattern[105] = 0;
pattern[106] = 0;
pattern[107] = 0;
pattern[108] = 0;
pattern[109] = 0;
pattern[110] = 0;
pattern[111] = 0;
pattern[112] = 0.00152587890625;
pattern[113] = 0.00152587890625;
pattern[114] = 0.00152587890625;
pattern[115] = 0.00152587890625;
pattern[116] = 0.00152587890625;
pattern[117] = 0.00152587890625;
pattern[118] = 0.00152587890625;
pattern[119] = 0.00152587890625;
pattern[120] = 0.00152587890625;
pattern[121] = 0.00152587890625;
pattern[122] = 0.00152587890625;
pattern[123] = 0.00152587890625;
pattern[124] = 0.00152587890625;
pattern[125] = 0.00152587890625;
pattern[126] = 0.00152587890625;
pattern[127] = 0.00152587890625;
pattern[128] = 0.00152587890625;
pattern[129] = 0.00152587890625;
pattern[130] = 0.00152587890625;
pattern[131] = 0.00152587890625;
pattern[132] = 0.00152587890625;
pattern[133] = 0.00152587890625;
pattern[134] = 0.00152587890625;
pattern[135] = 0.00152587890625;
pattern[136] = 0.00152587890625;
pattern[137] = 0.00152587890625;
pattern[138] = 0.00152587890625;
pattern[139] = 0.00152587890625;
pattern[140] = 0.00152587890625;
pattern[141] = 0.00152587890625;
pattern[142] = 0.00152587890625;
pattern[143] = 0.00152587890625;
pattern[144] = 0.00152587890625;
pattern[145] = 0.00152587890625;
pattern[146] = 0.00152587890625;
pattern[147] = 0.00152587890625;
pattern[148] = 0.00152587890625;
pattern[149] = 0.00152587890625;
pattern[150] = 0.00152587890625;
pattern[151] = 0.00152587890625;
pattern[152] = 0.00152587890625;
pattern[153] = 0.00152587890625;
pattern[154] = 0.00152587890625;
pattern[155] = 0.00152587890625;
pattern[156] = 0.00152587890625;
pattern[157] = 0.00152587890625;
pattern[158] = 0.00152587890625;
pattern[159] = 0.00152587890625;
pattern[160] = 0.00152587890625;
pattern[161] = 0.00152587890625;
pattern[162] = 0.00152587890625;
pattern[163] = 0.00152587890625;
pattern[164] = 0.00152587890625;
pattern[165] = 0.00152587890625;
pattern[166] = 0.00152587890625;
pattern[167] = 0.00152587890625;
pattern[168] = 0.00152587890625;
pattern[169] = 0;
pattern[170] = 0;
pattern[171] = 0;
pattern[172] = 0;
pattern[173] = 0;
pattern[174] = 0;
pattern[175] = 0;
pattern[176] = 0;
pattern[177] = 200.37606811523;
pattern[178] = 200.37606811523;
pattern[179] = 200.37606811523;
pattern[180] = 200.37606811523;
pattern[181] = 200.37606811523;
pattern[182] = 200.37606811523;
pattern[183] = 200.37606811523;
pattern[184] = 200.37606811523;
pattern[185] = 200.37606811523;
pattern[186] = 200.37606811523;
pattern[187] = 200.37606811523;
pattern[188] = 200.37606811523;
pattern[189] = 200.37606811523;
pattern[190] = 200.37606811523;
pattern[191] = 200.37606811523;
pattern[192] = 200.37606811523;
pattern[193] = 200.37606811523;
pattern[194] = 200.37606811523;
pattern[195] = 200.37606811523;
pattern[196] = 0;
pattern[197] = 0;
pattern[198] = 0;
pattern[199] = 0;

export function render(index) {
  h = (pattern[index] & 0xffff) / 360;
  s = ((pattern[index] << 8) & 0xff) / 100;
  v = ((pattern[index] << 16) & 0xff) / 100;

  hsv(h, s, v);
}

If these do the trick then I’ll see if I can get the code beaten into shape!

I’ve been out camping. Will try as soon as I have access. Thanks

No problem. Hope you had a great trip!

that worked great. Even got my momentary switch working. getting close to making this a nice light painting stick! What does the process look like to go from the image to outputting the code?

Excellent! :grinning: I’ll see what I can do to beat the code into shape. Would you be interested if I stood up a web server where you could just upload the image and get the code in return? Or maybe even a .epe file if I can work that out?

that would be great. Thanks

@zeb did you ever polish this code? Just came cross this thread and mentioned it as a solution for POV image uploading

Apologies. I didn’t get anywhere with this. Consider it moved further up the “pile”. I will make some time to get this sorted out. It shouldn’t take too long to get it in a fit state to be usable even if not particularly pretty!

2 Likes

Friendly bump! I know how life goes, but I just stumbled upon this thread and figured I’d see if there was a chance anything had moved forward here!

2 Likes

Hey, @wizard, is this helpful?

1 Like

Just a heads up… I’m about 3/4 of the way through a complete Pixelblaze control library for Processing/Java. Since Processing can read all these file formats and already has image processing libraries that can do selection and scaling, it ought to make this sort of thing relatively easy.

I’ll make a note to include a bitmap → pattern converter of some sort in the examples.

3 Likes

For basic image to code, something that could take an image and spit out some code to put the data in an array, perhaps with some getPixel() APIs would be a good start. This could be done entirely outside of PB, even just in the browser. Browsers can decode all kinds of images and draw them in canvases, and then give you pixel data from the canvas (though sometimes color correction changes things in unexpected ways).

See

and

Now if we had a canvas API and a way to load PNG files as sprites (or sprite sheets) then an embedded PNG decoder would be handy. Note that in any event all of the decompressed image data still has to sit in RAM for things to be performant.

1 Like

Yeah, the usefulness in firmware does depends on a canvas API.

I’m hopeful we can port at least a decent chunk of it into usercode first. Between webgl and that, so many existing bits of JS would become doable easily.