February 29, 20242 yr Hi all I have to admit: i have a quite long experience in code development in general, but very small in any aspect related to FS2020 - so I am now in a dark tunnel and I can't see any light (literally) PLANE: HONDA JET GOAL: I would like to manage cockpit area ambient light with my combo Elgato Streamdeck + Axis and Ohs MY PROBLEM: Using AAO event/variable listeners I have understood that there are the command "K:Light_potentiometer_XX_set" and the variable "A:LIGHT·POTENTIOMETER:XX,·Percent" to work on this; actually the XX is 11 in this case the "percent" readable in the variable is a number between 0.000000 and 1.000000 There is NOT a command "INC" "DEC" as i have seen in other planes, so i have decided to use ONE stream deck button to cycle, sequentially, 0-25-50-75-100 of the light intensity. Unfortunately, i am not able to understand how to create a script to do this; i have found this video https://www.youtube.com/watch?v=GCXgaj3ah8U&list=PLVrv-Tg8MzVi3jX6Qux8wCmAB4288-iJP&index=6&t=591s which seems exactly to go in the direction i need but i have spent may ber one whole day in tentative without success So, I will appreciate any help and suggestion (using this method or any else, of course) to get my goal but, more important, TO LEARN Thank you so much to all the community!
February 29, 20242 yr Commercial Member The potentiometer events are usually indexed: idx val (>K:2:evtname) 11 50 (>K:2:LIGHT_POTENTIOMETER_SET) should set the pot at index 11 to 50% Edited February 29, 20242 yr by Lorby_SI LORBY-SI
February 29, 20242 yr Commercial Member The spec for flightsim RPN is (generally speaking) this one Reverse Polish Notation (flightsimulator.com) Plus the AAO manual. It is always a good strategy to look for AAO StreamDeck profiles on flightsim.to. Even if they are for a different/default aircraft, the script files that come with them are usually very helpful LORBY-SI
February 29, 20242 yr Author 1 minute ago, Lorby_SI said: The potentiometer events are usually indexed 11 50 (>K:2:LIGHT_POTENTIOMETER_SET) should set the pot at index 11 to 50% first of all thank you for your answer i have been able to use one button to set a SINGLE value What I am not able to do is how to create a system to cycle I have tested with a TextGauge button in thousand of ways but, for my inexperience, no success
February 29, 20242 yr Author 2 minutes ago, Lorby_SI said: The spec for flightsim RPN is (generally speaking) this one Reverse Polish Notation (flightsimulator.com) Plus the AAO manual. It is always a good strategy to look for AAO StreamDeck profiles on flightsim.to. Even if they are for a different/default aircraft, the script files that come with them are usually very helpful actually i have not used the first link, so thank you again but yes, i have checked vary other profiles, but i have always found commands with "INC" or "DEC" so no way
February 29, 20242 yr Commercial Member The full script would be something like this (A:LIGHT POTENTIOMETER:11, Percent) 100 * 25 / flr 25 * 25 + s0 100 > if{ 0 s0 } 11 l0 (>K:2:LIGHT_POTENTIOMETER_SET) In pseudo code with an example - read the value off the potentiometer (0.3) - multiply with 100 (30) - divide by 25 (1.2) - floor (1) - multiply with 25 (25) - add 25 (50) - store in register 0 (that is the "s0") - check if the sum is greater than 100, if it is, store 0 in the register 0 (this will restart the cycle from 0) - set the index of the pot (11) - read register 0 (that is the "l0", that is "ell-zero", not "ten") => 50 - write into pot event. Edited February 29, 20242 yr by Lorby_SI LORBY-SI
February 29, 20242 yr Author 10 minutes ago, Lorby_SI said: The full script would be something like this (A:LIGHT·POTENTIOMETER:11, Percent) 100 * 25 / flr 25 * 25 + s0 100 > if{ 0 s0 } 11 l0 (>K:2:LIGHT_POTENTIOMETER_SET) i will check and, most important, i will try to understand exactly HOW IT WORKS Edited February 29, 20242 yr by Lorby_SI
February 29, 20242 yr Commercial Member Just now, Roberto Alfieri said: i will check and, most important, i will try to understand exactly HOW IT WORKS I've added the explanation in pseudo code above. It is a bit longer than necessary, because I wanted to force the 25er sequence, regardless of the actual pot value (which could be something in between). There are at least two other options how to do this and probably many more. But I'm not at my devel system at the moment, this is just off the top of my head. LORBY-SI
February 29, 20242 yr Commercial Member 4 minutes ago, Roberto Alfieri said: i will check and, most important, i will try to understand exactly HOW IT WORKS I've corrected the script, there was a typo in it. LORBY-SI
February 29, 20242 yr Author 54 minutes ago, Lorby_SI said: I've corrected the script, there was a typo in it. you are my hero, not only for the suggestion, but for the EXPLAINATION If a man is hungry, don't give him a fish, but teach him HOW TO fish! (its the Bible not me :-DDDD) Thank you i will read more and more and will try to fully understand
February 29, 20242 yr Commercial Member You can also use JScript or VBscript. (WSH:jscript|AaoEntry) function AaoEntry(){ var pot = (A:LIGHT POTENTIOMETER:11, Percent); pot = Math.round(pot * 100 / 25) * 25; pot += 25; if (pot > 100) pot = 0; AaoCmd.exec("11 " + pot + " (>K:2:LIGHT_POTENTIOMETER_SET)"); } Again, off the top of my head, untested. Edited February 29, 20242 yr by Lorby_SI LORBY-SI
February 29, 20242 yr Author Right to thank you and show that i have followed all your suggestions: The RPN script unfortunately always returns 11 as the light intensity value, and nothing changes; even pressing the button repeatedly; unfortunately i am totally new to Reverse Notation so it is too much difficult to me to find the problem, even I have an idea (read below) So, i switched to the jscript approach, environment i know better, and i have modified the code: (WSH:jscript|AaoEntry) function AaoEntry(){ var pot = (A:LIGHT POTENTIOMETER:11, Percent); pot += 25; if (pot > 100) pot = 0; AaoCmd.exec(pot + " (>K:LIGHT_POTENTIOMETER_11_SET)"); } If the light value is randomly set (or manually, with the mouse in the plane touch display, at the first run there will be "strange" values; but the first time it will come to 100, then will start the right sequence The main problem even in the RPN script seems to be in the notation ">K:2:LIGHT_POTENTIOMETER_SET" This seems not correctly written, or something, but at the moment with my level of knowledge i can't find the mistake; but in my way it works, and you have showed me the way so thank you really very much, i have appreciated. I will study more and i will find the trick for sure, i can't stay with a technical issue to fix in my brain LAST BUT NOT LEAST: Considering i have had the chance to talk with mr. Lorby IN PERSON, could you be so kind to put an SSL certificate to your website so my provider will not consider it as the devil asking me 100 times if i REALLY want to access? :-)))) If needed, i will help you with pleasure Ciao and thank you very much one more time
March 1, 20242 yr Commercial Member 6 hours ago, Roberto Alfieri said: The RPN script unfortunately always returns 11 as the light intensity value, Flip the index and the value then in front of the K:2 event. I was just guessing. But even more likely the pot value is simply wrong, because I assumed that the variable will return a value between 0 and 1. It may also need an additional flr or something, to avoid floating point numbers (K: events only understand int) 6 hours ago, Roberto Alfieri said: Considering i have had the chance to talk with mr. Lorby IN PERSON, could you be so kind to put an SSL certificate to your website so my provider will not consider it as the devil asking me 100 times if i REALLY want to access? :-)))) It is not "my" website. All Lorby sites are hosted by Weebly as a paid service and as far as I can tell, SSL is on. I am just a customer and have to trust that they are doing things correctly. Even if they don't, talking to them is about as easy and effective as sending a letter to Santa. At some point the website(s) will be moved to a different provider, but that is still a ways off. Edited March 1, 20242 yr by Lorby_SI LORBY-SI
March 1, 20242 yr Commercial Member 6 hours ago, Roberto Alfieri said: If the light value is randomly set (or manually, with the mouse in the plane touch display, at the first run there will be "strange" values; but the first time it will come to 100, then will start the right sequence Add a bit of math to smooth it out then. When the ", Percent" unit is already returning a value between 0 and 100, then simply remove the multiplication by 100 (WSH:jscript|AaoEntry) function AaoEntry(){ var pot = (A:LIGHT POTENTIOMETER:11, Percent); pot = Math.round(pot / 25) * 25; pot += 25; if (pot > 100) pot = 0; AaoCmd.exec("11 " + pot + " (>K:2:LIGHT_POTENTIOMETER_SET)"); } LORBY-SI
Archived
This topic is now archived and is closed to further replies.