Page 1 of 1

Simple switch edit

Posted: Wed Jan 13, 2021 11:39 pm
by darrynenig22
Hi
When using Flowcode V5 it was so very easy to place two custom images for OFF / MID / ON

Placed on the dashboard panel static picture ON when pressed is replaced with static picture OFF

I have been trying to edit the base switch in V8 and V9 to create a new component and modify to replicate this very simple button press.
Have found it very difficult to navigate through the GUI and the exposed component folders to get this.

Can you provide a working example so I can see how it was created.


Thanks

Re: Simple switch edit

Posted: Fri Jan 15, 2021 12:54 pm
by Benj
Hello,

I've made a simple example for you here which should do just about everything you need.
SwitchDemo.zip
(31.83 KiB) Downloaded 204 times
I've also started a bit of a write up here.
https://www.flowcode.co.uk/wiki/index.p ... mpleSwitch

Let me know how you get on.

Re: Simple switch edit

Posted: Fri Jan 15, 2021 1:10 pm
by Benj
Sorry spotted a bug in the Ev_Release macro.

Should be this.
bug.jpg
bug.jpg (44.75 KiB) Viewed 2404 times
Also another in GetSwitchState macro.
bug2.jpg
bug2.jpg (25.01 KiB) Viewed 2404 times

Re: Simple switch edit

Posted: Sun Jan 17, 2021 6:11 pm
by darrynenig22
Hi Benj,

Thanks for the demo file, Im beginning to understand the structure of component creation, structure and saving created components.

The switchdemo file was very helpful.

There is an issue when I add multiple instances of the newly created component from the component library to the panel and assign separate ports to each off the switches they work as expected,but all switches retain there previous states if pressed in when flowcode is run again.
I have tried to follow what the handle SW_Object is interacting with but need some help .


Cheers Darryn

Re: Simple switch edit

Posted: Sun Jan 17, 2021 10:00 pm
by Benj
Hello,

If you wish to reset the switch state then create an event macro for the Simulation start event using the Events tab of the project explorer.

Inside the macro use a calculation to set the following code and that should reset the state on run.

Sw_Pin = State