Setting up a toggle switch

Forum to ask for any help
Post Reply
coolmacdude
Posts: 12
Joined: Tue Jan 15, 2013 2:58 am

Setting up a toggle switch

Post by coolmacdude » Sat Feb 02, 2013 10:15 pm

Hello please can someone help me or point me in the right direction.

I have read the article about implementing a toggle button but it doesn't seem to work or i am missing something?

Basically I am looking at a solution to create just 1 button (lets say for my lighting system).
I have 2 graphic files an orange bulb for the light on and a grey bulb to represent the light being off.

Please can someone give me details in layman terms on exactly what I have to do so when I click the button the graphic changes to the orange bulb and turns the lights on then when i hit it again it sends a command to turn my lights off and changes the graphic to the grey bulb.

I know I need to create flags and dependant flags but just cant seem to get it in the right order? does the action need to be created in the released, pressed or gesture actions.

Just love playing around with demopad software and the GC hardware which works great. I have spent weeks creating a pretty good and extensive hardware project which I will happily upload and share once completed.

any help would be greatly appreciated.

Kindest Regards

Darren

Idealhomes
Posts: 144
Joined: Mon Jul 16, 2012 3:35 pm
Location: New Zealand
Contact:

Re: Setting up a toggle switch

Post by Idealhomes » Sat Feb 02, 2013 10:51 pm

You could start by setting up a couple of flags inside a folder called "Lighting" for your lighting toggle control, one being "lights on" and one being "lights off".

You would then assign the orange lighting icon to "lights on" and the grey icon to "lights off".

You would then set the commands like the following for a toggle of icon........

Say you would like to turn the lights on to show the orange icon and turn the grey off

Action when button released

Lights Off Off
Lights On On

The reverse action to turn the lights off.....

Action when button released

Lights On Off
Lights Off On

The key is getting ONE icon to show in the first place. This is where you add a command in the "edit page load action" screen. You would set the folder of Lighting to OFF and then you could set the "Lights Off" to ON or "Lights On" to On depending on what icon you would like to have show first for the "Toggle".

The problem with this sort of toggle, is if you do not have a lighting system that can give two-way feedback , you are unable to have the correct icon showing the correct state of your lighting. You could have the orange icon showing "lights on" when they are actually off and visa-versa.

I hope this helps for the toggle anyway.
"Setting the Standard in Quality and Commitment"

coolmacdude
Posts: 12
Joined: Tue Jan 15, 2013 2:58 am

Re: Setting up a toggle switch

Post by coolmacdude » Sun Feb 03, 2013 12:06 am

Thanks for your prompt reply.

Im sorry if I sound stupid but how do I set the flags for the icons?
when I create a button lets say orange on icon I select edit and set the flag to lights on, but then how do I set the grey icon to the flag lights off if the button does not exist?
I tried clicking edit and set the highlighted image to the grey icon but unless I am being daft the button it still set to flag on.

the other question is where about in the actions do I insert the command to turn on and then the off

the last thing is you mentioned the page load actions screen, do you mean when I select a page, click edit and edit startup actions?

I was thinking about the false state of the lights and I have been looking to replace my lighting system and will get a 2-way system.

many thanks in advance.

Darren

Idealhomes
Posts: 144
Joined: Mon Jul 16, 2012 3:35 pm
Location: New Zealand
Contact:

Re: Setting up a toggle switch

Post by Idealhomes » Sun Feb 03, 2013 1:47 am

coolmacdude wrote:Im sorry if I sound stupid but how do I set the flags for the icons?
when I create a button lets say orange on icon I select edit and set the flag to lights on, but then how do I set the grey icon to the flag lights off if the button does not exist?
I tried clicking edit and set the highlighted image to the grey icon but unless I am being daft the button it still set to flag on.
You need to start with two icons on your canvas (page or subpage), one orange and one grey. If you click on either button it will bring up the "object properties" tab. Third in from the left is a "Reveal"/"Show" area, if you extend this open you can change the "flag" or essentially giving your button/icon a flag. If it is the orange icon, you will change the "flag" to "lights on" and if it is the grey icon "lights off".
coolmacdude wrote: the other question is where about in the actions do I insert the command to turn on and then the off
You can set the command for the lights on and off command within the button action editor (just double click icon for "action when button released" editor). If you are setting up the light on orange button, you will set the flags and also the command for action.....

Lights ON - Off
Lights OFF - On
Command sent for lights Off

If you are setting the grey button......

Lights Off - Off
Lights On - On
Command send for light ON
coolmacdude wrote:the last thing is you mentioned the page load actions screen, do you mean when I select a page, click edit and edit startup actions?

I was thinking about the false state of the lights and I have been looking to replace my lighting system and will get a 2-way system.
Yes, whatever page you are using for the lighting control. What this will do, is everytime the page is loaded it will default to one of your choice of buttons to start for toggle control. Two-way feedback will help determine the state of the lighting and you can set dependent flags for this. You end up with full control instead of toggling between icons not knowing which state your lights are in.

I hope this helps some, let us know if you need more :mrgreen:
"Setting the Standard in Quality and Commitment"

coolmacdude
Posts: 12
Joined: Tue Jan 15, 2013 2:58 am

Re: Setting up a toggle switch

Post by coolmacdude » Sun Feb 03, 2013 2:10 am

Thanks again Pal,

I don't think this is what I was asking?, please forgive me if I am wrong.
Basically I thought I could have one button that changed from the on graphic to the off graphic every time I pressed it I didn't want 2 icons/buttons on the canvas.

bob3695
Posts: 27
Joined: Sat Dec 29, 2012 3:30 am

Re: Setting up a toggle switch

Post by bob3695 » Sun Feb 03, 2013 3:52 am

coolmacdude wrote:Thanks again Pal,

I don't think this is what I was asking?, please forgive me if I am wrong.
Basically I thought I could have one button that changed from the on graphic to the off graphic every time I pressed it I didn't want 2 icons/buttons on the canvas.
You can. I have this setup and I got it working with the help of this: http://demopad.com/forum/viewtopic.php?f=7&t=33

Admittedly it is not an ideal setup as you have to have 2 flags just for the button and 4-5 (maybe more?) actions on the button just a boiler plate to make it work.

Idealhomes
Posts: 144
Joined: Mon Jul 16, 2012 3:35 pm
Location: New Zealand
Contact:

Re: Setting up a toggle switch

Post by Idealhomes » Sun Feb 03, 2013 4:38 am

bob3695 wrote:
coolmacdude wrote:Thanks again Pal,

I don't think this is what I was asking?, please forgive me if I am wrong.
Basically I thought I could have one button that changed from the on graphic to the off graphic every time I pressed it I didn't want 2 icons/buttons on the canvas.
You can. I have this setup and I got it working with the help of this: http://demopad.com/forum/viewtopic.php?f=7&t=33

Admittedly it is not an ideal setup as you have to have 2 flags just for the button and 4-5 (maybe more?) actions on the button just a boiler plate to make it work.
I started with this as a toggle option but found it far less confusing using two icons as buttons, both work the same but I need less flags with two buttons. Everyone has their own way, do what ever you find easiest, as with this software there are plenty of ways to skin a cat to get the same result :mrgreen:
"Setting the Standard in Quality and Commitment"

User avatar
DemoPad
Site Admin
Posts: 769
Joined: Thu Jun 14, 2012 10:46 am
Contact:

Re: Setting up a toggle switch

Post by DemoPad » Sun Feb 03, 2013 10:54 am

Absolutely - there are many ways to do the same thing. You really have 2 choices, either:

1. Use a single button, and use the 'Highlight' flag menu to decide when the alternate image is shown - this approach needs 2 flags & at least 4 actions on the button using the toggle approach in the manual,

or

2. Use 2 buttons, in the same place on screen, but only have one of them visible at any one time - using the 'Reveal' menu & a 2 flags for Lights On & Lights Off, where each button flips the value of each when pressed, to make the other button appear.

Post Reply