opened
kgracey
username_0
Created the following code in project 8337 http://blockly.parallax.com/blockly/editor/blocklyc.jsp?project=8337#:

![image](https://user-images.githubusercontent.com/9534148/27670471-00c4b3fa-5c42-11e7-9e7f-95dac6f36b10.png)

To make it work I brought it into SImpleIDE and made the following changes noted in the comments to enumerate the instances of more than one ColorPal:

`// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "ws2812.h"
 
#define LED_PIN 0
#define LED_COUNT 3
 
#include "colorpal.h"
 
// ------ Global Variables and Objects ------
ws2812 * __ws2812b;
int RGBleds[3];
 
colorPal *cpalL; // we need unique identifiers for multiple colorPals - perhaps the I/O pin number
colorPal *cpalM;
colorPal *cpalR;
 
int cpRR = 0;
int cpGG = 0;
int cpBB = 0;
 
int colorL;
int colorM;
int colorR;
 
 
// ------ Main Program ------
int main()
{
__ws2812b = ws2812b_open();
pause(1000);
print("hello\n");
//while(1);
cpalL = colorPal_open(17); // also generated with unique identifiers
pause(100);
cpalM = colorPal_open(16); // also generated with unique identifiers
pause(100);
cpalR = colorPal_open(11); // also generated with unique identifiers
pause(100);
while (1)
{
colorPal_getRGB(cpalL, &cpRR, &cpGG, &cpBB);
colorL = colorPalRRGGBB(cpRR, cpGG, cpBB);
colorPal_getRGB(cpalM, &cpRR, &cpGG, &cpBB);
colorM = colorPalRRGGBB(cpRR, cpGG, cpBB);
colorPal_getRGB(cpalR, &cpRR, &cpGG, &cpBB);
colorR = colorPalRRGGBB(cpRR, cpGG, cpBB);
print("colorL = %d, colorM = %d, colorR = %d\r",
colorL, colorM, colorR);
//
if (1 > 0 && 1 <= LED_COUNT)
{
RGBleds[1 - 1] = colorL;
}
if (2 > 0 && 2 <= LED_COUNT)
{
RGBleds[2 - 1] = colorM;
}
if (3 > 0 && 3 <= LED_COUNT)
{
RGBleds[3 - 1] = colorR;
}
//
pause(100);
ws2812_set(__ws2812b, LED_PIN, RGBleds, LED_COUNT);
pause(1000);
}
}
`
@username_1 can you do this?
Multiple ColorPals: change request for color line follower
issue
created
MatzElectronics
username_1
@username_0 I am now able to this in my dev for the colorPal sensor - so now it's a big copy-paste operation for other sensors.  Any preferences on which ones should be done first?
comment
created
MatzElectronics
username_1
This should now be available in demo for:
- PROTOCOLS > Serial
- RGB-LEDs
- ColorPal
comment