gsumner Posted February 7, 2014 Report Posted February 7, 2014 Hi Pete and all, Im having mixed results when programmimg LUA for use with the goflight WP-6 panel An example is below ---------- GEAR LIGHTSfunction NoseGearStatus(offset, value) --LIGHT 1if logic.And(value,0x0000) ~=0 then --if nose red gfd.SetColour(GFWP6, 0, 0, 2) --set red light gfd.SetLight(GFWP6, 0, 0) --turn it onelseif logic.And(value,0x0002) ~=0 then --if nose green gfd.SetColour(GFWP6, 0, 0, 3) --set green light gfd.SetLight(GFWP6, 0, 0) --turn it onelse gfd.ClearLight(GFWP6, 0, 0) -- extinguish if no lights end endevent.offset("941E", "UB", "NoseGearStatus") Basically im testing the value of the nose uc light green and red status to decide if my button should glow red or green or extinguish. Im getting the green light fine and off with aircraft power off. I dont get any red light though and wonder now if its possible to use a light to use 2 colours. The offsets im using are correct and they are for the ifly 737 Hope you can help Graham
Pete Dowson Posted February 7, 2014 Report Posted February 7, 2014 Im having mixed results when programmimg LUA for use with the goflight WP-6 panel This is NEVER true: logic.And(value,0x0000) ~=0 If you AND something with zero the answer is ALWAYS zero! Pete
gsumner Posted February 7, 2014 Author Report Posted February 7, 2014 logic.And(value,0x0000) ~=0 this is testing bit 0 ( in HEX) of offset 941E or so i thoughtoffset bit description941E 0 NOSE_GEAR_RedLight_Status taken from ifly2fsuipc documentation Graham
Pete Dowson Posted February 7, 2014 Report Posted February 7, 2014 logic.And(value,0x0000) ~=0 this is testing bit 0 ( in HEX) of offset 941E or so i thought No, it certainly is not. Bit 0 is actually a bit, a part of a byte, and you have no bits at all set in the value 0x0000. Zero is zero and contains no bits to "AND" with at all! Bit 0 has the value 0x0001. Please go to the FAQ subforum and look at the thread about bits and numbers. Pete
gsumner Posted February 7, 2014 Author Report Posted February 7, 2014 Thanks Pete, All the LUA I've written never included tes ing a 0 bit before. Of course a 0 bit must have a value. I just over looked it ! Small things make a big difference ! All ok now. Have a great weekend ! Graham
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now