aREST
aREST copied to clipboard
How can I swap the ON and OFF buttons in the UI?
I have two relays that switch on when driven high. However, the UI swaps these, so when powered up, the relay is supposed to be off, the UI shows it's off - but it's activated, the LED indicating it's active is lit, and the Normally Open connection is closed.
Clicking ON in the UI turns them off.
There are relays that work the other way, they need to be driven low to be activated. In code I've written, I have set up the option to handle both types (depending on how the relay module is configured, you never know what you're going to get from ebay).
Is there a way to do this in aREST? e.g., ON = 1 and OFF = 0, or ON = 0 and OFF =1.
Hi, looking at the source code, there is currently no way to do this. But for me, your issue is more on the application side than on the code side. It's to the Calling application to know what "on" or "off" means. Not to the board itself. And this is specific for one entry, what if you have some IO for which "on" mean 1 and some others it mens 0? Would be too complicate to set per IO what on and an off means. Better do that at the applicaiton level calling.
Hi Jeff,
Just to be sure, you mean the UI in the dashboard (http://dashboard.arest.io/) or the aREST UI library which is a separate project?
It's been awhile since I worked on this, but as I recall, this was in the UI, which had the states of the On and Off indicators reversed. I was using an ESP8266 board and toggling the relays remotely via the UI.
My question at the end was asking if there is a way to swap the indicators in the UI, similar to the way I can in the Arduino IDE.
What I do to handle both types of relays in Arduino (or other IDEs) is define ON and OFF like this: const byte Is_Off = 0; const byte Is_On = 1;
Then later do this:
digitalWrite(Relay1, Is_On); delay (5000); digitalWrite(Relay1, Is_Off);
If I get one of the relay modules where you have to drive it low to activate it, then I just swap the 1 and 0 in the definitions. I was wondering if there was a way to swap how the indicators in the UI displayed, in a similar manner.