hi I just have really quick question for mirroring LED from the board to my LED. What should I do to make it happen after I update the firmware to 0.4.5? I remember one of user mentioned about it last time. Does the function already available now on version 0.4.5?
thank you so much.
when I compile it it says class RGBClass has no member named âonChangeâ. is there anyway to see my photon version. I just run particle update and I donât know what else I need to do to deal with it?
This is the Error message I have got.
error: âclass RGBClassâ has no member named 'onChangeâ
RGB.onChange(ledChangeHandler);
Are you sure you have 0.4.5 selected against your device, assuming youâre building your app in Build?
void ledChangeHandler(uint8_t r, uint8_t g, uint8_t b)
{
analogWrite(redLED, r);
analogWrite(greenLED, g);
analogWrite(blueLED, b);
}
void setup(void)
{
pinMode(redLED,OUTPUT);
pinMode(greenLED,OUTPUT);
pinMode(blueLED,OUTPUT);
RGB.onChange(ledChangeHandler);
}
This is what I have from the code. I use CoolTerm to check the system itâs 0.4.5 already, when I compile it the error message from local compiler is as follow:
âclass RGBClassâ has no member named 'onChangeâ
RGB.onChange(ledChangeHandler);
The way I update the system firmware is update CLI first and then doing âparticle updateâ in terminal line on my Mac.
There is an interesting thing. When I open spark_wiring_rgb.h, there is no functions of âonChange(ledChangeHandler);â
You talk about opening source files, so I guess youâre building locally. Have you pulled the latest changes from github?
git pull
i see
btw, If I run it on MANUAL mode, will function still work?
btw, which repo to pull?
I have update firmware and also pull the files from git, but my external LED display the all of color(RGB), and there is no action that associate with the RGB LED on the Board. What happen?
void ledChangeHandler(uint8_t r, uint8_t g, uint8_t b)
{
analogWrite(redLED, r);
analogWrite(greenLED, g);
analogWrite(blueLED, b);
}
void setup(void)
{
pinMode(redLED,OUTPUT);
pinMode(greenLED,OUTPUT);
pinMode(blueLED,OUTPUT);
RGB.onChange(ledChangeHandler);
//Server to Client(Photon) command
Spark.function("setLive", startLivePublish);
#if TESTING
#endif
}
Hi @mikelo
I tried this and I canât make it work either using analogWrite. It does work with digitalWrite to D7 so I know that the handler is getting called.
I wonder if @mdma knows of any reason why this shouldnât work with analogWrite? Timer problem?
I even tried doing an analogWrite(D7,0); in setup so that the timer was started.
So I just realized that I was using D7 and analogWrite() which do not play nice together.
So @mikelo
Are you using analogWrite capable pins? On Photon these are listed here:
On the Photon, this function works on pins D0, D1, D2, D3, A4, A5, WKP, RX and TX with a caveat: PWM timer peripheral is duplicated on two pins (A5/D2) and (A4/D3) for 7 total independent PWM outputs. For example: PWM may be used on A5 while D2 is used as a GPIO, or D2 as a PWM while A5 is used as an analog input. However A5 and D2 cannot be used as independently controlled PWM outputs at the same time.
which pins are you trying to analogWrite to? Not all pins support analog write - please check yours in the docs https://docs.particle.io/reference/firmware/photon/#analogwrite-
@mikelo, in addition to @bkoâs question regarding the correct pin selection, have you tested your external LEDsâ wiring to make sure the LEDs are working as expected?
@Moors7 asked me to chime in here with a quick code snippet from something I just wrote for another project. Instead of blinking a traditional RGB LED, Iâm blinking an LED on an LED matrix panel.
SYSTEM_MODE(SEMI_AUTOMATIC);
void ledChangeHandler(uint8_t r, uint8_t g, uint8_t b) {
if(!Particle.connected()) {
matrix.drawPixel(0, 0, matrix.Color444(r, g, b));
matrix.swapBuffers(true);
}
}
void setup() {
matrix.begin();
matrix.setTextWrap(false); // Allow text to run off right edge
matrix.setTextSize(1);
matrix.setTextColor(matrix.Color333(210, 210, 210));
RGB.onChange(ledChangeHandler);
// Connect to the cloud
Particle.connect();
while(!Particle.connected()) {
Particle.process();
delay(1);
}
}
I hope this helps!
yes, I am pretty sure the pins connect to external RGB LED correctly by using D0,D1 and D2. When I set their pin mode to output. All three LEDs are light up. There is nothing that external LED works like itâs mirroring the on-board LED.
@mikelo, do you have current limiting resistors for each LED?
yes, I do, and itâs way before I ask this question. The concerns that you ask about are not real concern, but thank you for double check with me. The thing I want the external LED to do is pretty simple, just display the color and act exactly the same as the on-board LED.