Page 1 of 1
Basic On/Off visualisation
Posted: Sun Mar 21, 2021 11:07 am
by tmead
As part of a simple In / Out visualisation as the first step of testing an Arduino Mega based system, I'd like to show the status of the outputs. Simplest would probbaly just be a small coloured square on screen if the output is on,and a blank square if its off. I can't see a control that does this - but as a beginner maybe I'm missing it !
Right now I have a table, which shows 0 / 1 just fine - its a bit of a clunky answer though !
Re: Basic On/Off visualisation
Posted: Sun Mar 21, 2021 12:44 pm
by tmead
Check boxes are quite simple, but they allow input - unless there's a config option that means they are disply only and can't be clicked ?
Re: Basic On/Off visualisation
Posted: Sun Mar 21, 2021 5:39 pm
by tmead
OK, I found the enabled setting, so they work as indications of status.
Re: Basic On/Off visualisation
Posted: Sun Mar 21, 2021 5:59 pm
by tmead
And now I need to expose my poor coding skills ! This function works to toggle the relevant pin, and feeds back the checked/unchecked status just fine.
Code: Select all
void toggle(int pin, const char* msg) {
//char msg2[25];
//strncat(msg2, msg, "CB");
digitalWrite(pin, !digitalRead(pin));
InterfacePanel MyPanel;
if (digitalRead(pin) == 1) {
MyPanel.SetCheck(msg, true); // check control
//MyPanel.SetForeColor(msg, F("Red"));
//MyPanel.SetBackColor(msg, F("Blue"));
}
else {
MyPanel.SetCheck(msg, false); // un-check control
//MyPanel.SetForeColor(msg, F("Red"));
//MyPanel.SetBackColor(msg, F("Green"));
}
The color settings dont work though, giving error during compile - "no matching function for call to 'InterfacePanel::SetBackColor(const char*&, const __FlashStringHelper*)'"
I'd like to learn how to deal with this. I've always shied away from text and strings etc - and have limited understanding of pointers and the like....
Re: Basic On/Off visualisation
Posted: Wed Mar 24, 2021 8:24 am
by philr
Hi, I think it might work if you remove the F("...."). Just put the string in "....".
Cheers
Phil