Basic On/Off visualisation

A place to just chat
Post Reply
tmead
Posts: 4
Joined: Sun Mar 21, 2021 10:52 am

Sun Mar 21, 2021 11:07 am

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 !
tmead
Posts: 4
Joined: Sun Mar 21, 2021 10:52 am

Sun Mar 21, 2021 12:44 pm

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 ?
tmead
Posts: 4
Joined: Sun Mar 21, 2021 10:52 am

Sun Mar 21, 2021 5:39 pm

OK, I found the enabled setting, so they work as indications of status.
tmead
Posts: 4
Joined: Sun Mar 21, 2021 10:52 am

Sun Mar 21, 2021 5:59 pm

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....
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Wed Mar 24, 2021 8:24 am

Hi, I think it might work if you remove the F("...."). Just put the string in "....".

Cheers
Phil
Post Reply