Jump to content
The simFlight Network Forums

Annunciators


Recommended Posts

All you have said above just bears out what I said that I do not have any idea about how to write the coding I need to get a window to display the OAT for me.

There are lots of examples, those supplied in the package installed for you in the FSUIPC Documents folder, and those supplied by others in the User Contributions subforum. There is also a lot of information about Lua programming on the Lua website, which is why I provide a link to it in the documentation. There are tutorials there and a reference manual.

There's probably more chance of that than me getting the code I need correct, but I was hoping that, with some helpful advise I might learn how to get there. I've spent about 8 hours this weekend trying to understand what to do and how to do it- from the Lua handbook, which I found hardgoing, to Google, and got nowhere.

That's why I need help.

So why not simply ask me to do it for you? That's what you want, isn't it? You don't really want to do anything for yourself?

Any sort of script or program follows a sequence, like English or any other language. If I jumble up all the wodrs I write here in a random fashion, like your attempt at a script, would you be able to understand? Why do you think a computer can understand random stuff put together with no thought?

Think about it logically. First, you obviously need to READ the value you wasnt to display BEFORE you display it. You actually formatted the message for display using a variable called "oat" which you'd not set.beforehand. So, reverse those two lines:

temp = ipc.readSW(0x0e8c)
str = string.format("OAT %2.0fC", oat + 0.5)[/CODE]

That's step 1. But now notice that you read the OAT into "temp" but formatted something called "oat". Make the names the same:

[CODE]oat = ipc.readSW(0x0e8c)
str = string.format("OAT %2.0fC", oat + 0.5)[/CODE]

Better? Can you at least see a bit of sense in this yet? (If not I give up).

Now you want to actually display it on your window -- you know how to do that already!

[CODE]wnd.text(w5, str)[/CODE]

You might want to clear the window first, though, or each display will be on a new line, with the old obnes scrolling up.

That's it. Almost. Two more things.

First, if you'd looked up 0E8C in the offsets list, as you should have, you'd see it isn't in degrees C but 256 times degrees C. So you need to divide it by 256 first. So:

[CODE]oat = ipc.readSW(0x0e8c) / 256[/CODE]

Second, I assume you really want to keep this updated, not just display it once and terminate? So you need either to loop displaying it at, say, half-second intervals:

[CODE]while true do -- says do the following forever (because "true" is always true)
oat = ipc.readSW(0x0e8c) / 256
str = string.format("OAT %2.0fC", oat + 0.5)
wnd.clear(w5)
wnd.text(w5, str)
ipc.sleep(500) --delay half a second
end -- end of the loop started by the 'while'[/CODE]

Alternatively, a more advanced and tidier way is to re-display it when it changes. This is done by using an "event", so:

[CODE]function displayoat(off, val) -- says the following is going to be called by something, using the name "displayoat"
oat = val / 256 -- val supplies the oat when it changes, don't need to read it again
str = string.format("OAT %2.0fC", oat + 0.5)
wnd.clear(w5)
wnd.text(w5, str)
end -- end of the function

event.offset(0x0e8c, "SW", "displayoat") -- says execute function "displayoat" when offset 0e8c, which is "SW"-signed word-changes.[/CODE]

Now, don't you think you can do others yourself? If not, why? What have I not explained?

Oh, yes. One last thing. Look in the log to see if there are errors in the program. I'm not perfect either. I've not tested this here.

Pete

Link to comment
Share on other sites

There are lots of examples, those supplied in the package installed for you in the FSUIPC Documents folder, and those supplied by others in the User Contributions subforum

Yes I know, I read through these during my attempts over the weekend.

So why not simply ask me to do it for you? That's what you want, isn't it?

I thought I already did in an earlier post. See

I would very much appreciate it if you would show me how to do it, with as short explanation so I can learn for the future- if you can spare the time
You don't really want to do anything for yourself?

Yes I do- that is why I asked you to explain things to me. See above.

Now, don't you think you can do others yourself?

I hope so, I'll certainly try.

Regards and thanks

Den

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.