So I've been working on getting software put together for HVAC controls using the FB. With much help from Tk1Toaster along the way, I've gotten pretty close to what I'm after. You can have a look at my G35 Carputer HVAC control thread to see where the project is headed.
Anyhows, what I have done is the following:
The original HVAC controls require you to push a button once for it to turn a setting on (ie. defrost), and then push it again to turn it off. So to emulate this in software, Ive done the following:
1) Push "Defrost" button and change a variable (defroststate) that I've set up to be a counter (opinion=d+1)
2) This counter allows me to set 2 states for the button - 0=off, 1=on
3) I have two multi-images that monitor defroststate, such that when it equals 1 an image is displayed of the button being pressed down, and a second defrost indicator is displayed.
4) In the logic section, I've defined defroststate=1 to trigger the defrost output on
5) when defroststate=2 the defrost output is triggered again, and I reset the defroststate counter back to 0.
6) I have a timed pulse programmed with the button that to my knowledge should pulse the output on and off over 1 second when triggered.
So far, the cycling of the multi-images works perfectly as I've intended alternating with each click of the button. The issue I'm having now is having the button act as a momentary button each time it is pressed. Using the code I have now, pressing the button once puts the output into a pulsing state where it keeps pulsing every second, rather than just once as I would like. Then, pressing it again turns the pulsing state off.
I have a feeling this has something to do with my logic section only triggering the output "on", but I'm not sure if there's a way I could just incorporate a timer into the logic such that first step is triggering output on and then 1 second later triggering output off. I think that would solve my problem.
Any further advice would be appreciated as always. I've attahed my fusionconfig file for reference.
For anyone that may be interested, I've managed to figure this out on my own with a lot of trial and error and integrating different pices of code from the forums. I'm sure there is a more elegant solution to what I've done, but this does work, and allows for all of the functions I've described in my previous post. Here's what I've done step by step:
I'll use my defrost function as an example:
1) Defrost button changes variabe "defroststate" to "d+1" priority absolute
2) Have two separate multi-images:
a) Button down
b) Defrost logo
3) When defroststate=0, both multi-images display a transparent image on screen
4) My background has the buttons drawn on in the "up state"
5) Thus, all of the actual button images are transparent
6) In the logic section:
when defroststate between 1 and 1:
trigger the output on
change variable defroststate to 2*
7) set the multiimages to display the button down and defrost logo when defroststate=2
8) The output section has a sequence timer that turns the output on for 1000ms, then switches it off
9) I found that I had to change defroststate to 2 as in step 6, because if I didn't, defroststate would stay equal to 1 with each cycle until the button was pressed again. This meant that the output was always triggered on, and I couldn't pulse the input.
10) Now when the button is pressed again, defroststate is increased to 3
11) In the logic section:
when defroststate between 3 and 3
trigger the output on
change defroststate back to 0.
12) This sets the multi-images back to the transparent images, and essentially creates an "off" state.