Instrument fade in and test

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
leversole
Posts: 20
Joined: Wed Jul 22, 2020 11:47 pm

Instrument fade in and test

#1 Post by leversole »

Good Morning! I searched the forums for startup and fade in but could not find what I was looking for...Is it possible and are there any example of scripting to fade in an instrument? ON my King Air EIFS 84, I have a solid black mask that covers the instrument (may not be the best method) intil the EFIS power is switched on, I think it would be awesome to fade the mask away over some time period to simulate the screen starting up...

Also, phase 2 of this would be a "run once on startup" type of function to display some self test routines when the instrument is started...

Are there any community instruments that have this feature? Can someone give some example code to achieve this?

Thanks
Leslie

User avatar
Ralph
Posts: 7916
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Instrument fade in and test

#2 Post by Ralph »

Both are quite easy, you might need timers. For the fading you need either the opacity function: http://siminnovations.com/wiki/index.php?title=Opacity
Or do it with canvas and change the opacity in the fill: http://siminnovations.com/wiki/index.php?title=Fill

The pre start up check can be done by setting a global variable, that's initialized as false, to true when the startup is done.
I don't think that there's a good example in the community library.

leversole
Posts: 20
Joined: Wed Jul 22, 2020 11:47 pm

Re: Instrument fade in and test

#3 Post by leversole »

Thank You!

leversole
Posts: 20
Joined: Wed Jul 22, 2020 11:47 pm

Re: Instrument fade in and test

#4 Post by leversole »

I think I am close, may be something simple, but this does nothing...every second, lighten the image by 0.2

function timer_callback(count, max)
opac = 1.0
opacity(img_hide, opac)
opac = opac -.2
end

timer_start(0, 1000, 5, timer_callback)

Leslie

User avatar
Keith Baxter
Posts: 4684
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Instrument fade in and test

#5 Post by Keith Baxter »

Hi,

I did this some time back and is posted in the forum abyss. Take some time out to understand what the code is doing and it will help you.
Color Picker.siff
(3.39 KiB) Downloaded 97 times
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: Instrument fade in and test

#6 Post by Corjan »

Something like this might work:

Code: Select all

opac = 1.0

function timer_callback(count, max)	
	opacity(img_hide, opac)
	opac = opac -.2
end

timer_start(0, 1000, 5, timer_callback)

You where resetting the opac variable at every timer tick,

Corjan

leversole
Posts: 20
Joined: Wed Jul 22, 2020 11:47 pm

Re: Instrument fade in and test

#7 Post by leversole »

Interesting you said that, I just tried that! Even created a new var so as not to infinitely repeat...

-- This function will be called 5 times, once every second
opac = 1.0
function timer_callback(count, max)
parse=opac
opacity(img_hide, parse)
parse = parse - 0.2

end

timer_start(0, 1000, 5, timer_callback)

Still not working...I even tried a simple for loop...start at 1 subtract .2 each time, run 5 times....I thought it might turn the opacity .8, .6, .4. .2, 0...It did not! Once I get it to run I will tweak it...Also, looked at Keiths code...still struggling...

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: Instrument fade in and test

#8 Post by Corjan »

Hi,

You are doing the same thing, only different :).
Opac will stay at 1.0 during the complete execution of the code and will also be used in the opacity function.

Have you tried my snipplet?

Corjan

User avatar
Keith Baxter
Posts: 4684
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Instrument fade in and test

#9 Post by Keith Baxter »

Hi,

What @Corjan is saying is what you should try.

The code in my color picker was intended to illustrate the power AM has. How one can manipulate a timer and use it as a mask or apply any other animation. This mask can be used for images and any node that has opacity.

From this fun instrument we learn that opacity has a characteristic not expected. Also it shows the power of tables.
Note how the opacity of the mask affects the colors. The opacity value is indicated top right of the instrument.

We observe that the lower opacity values do little to mask the main object. As the opacity value increases above .7 then we see a noticeable change. That might not be what we want or a useful tool.

It is sometimes wanted that a "ramp" table is created so that the animation from the lower opacity to the higher opacity. So use your timer to step the "ramp" table instead of a simple math progression.
If you want to include things like flicker, this can also be done. :o

Use your imagination.

Your current stepping of (0.0, 0.2, 0.4...)
Could be (0.0. .......0.6, 0.7, 0.75. 0.8, 0.82, 0.84, 0.86, 0.87, 0.875....)



Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

leversole
Posts: 20
Joined: Wed Jul 22, 2020 11:47 pm

Re: Instrument fade in and test

#10 Post by leversole »

Corjan I tried your code...the screen flashes, I assume it is going dark to light very fast...

Post Reply