Page 1 of 1
Advanced NXT Buttons NXT-G Block
Posted: 07 Apr 2011, 09:19
by bungeshea
Does anyone know of an NXT-G block that allows you to use the Clear (dark grey) button in your program? I know it is not possible with the standed NXT firmware, but is it possible with the enhanced NXC/NBC firmware?
Re: Advanced NXT Buttons NXT-G Block
Posted: 07 Apr 2011, 09:28
by mattallen37
I am quite sure you can't with NXT-G. However, I know you can with NXC.
Re: Advanced NXT Buttons NXT-G Block
Posted: 07 Apr 2011, 14:04
by sidneys1
No, it is not possible to use that button with the standard NXT firmware. It will always make the program 'exit'. However, I wonder if an NXT-G block could be made that makes use of the SetLongAbort(true) functionality of the enhanced NXC/NBC firmware...
Have a nice day,
~Sidneys1
Re: Advanced NXT Buttons NXT-G Block
Posted: 08 Apr 2011, 06:19
by bungeshea
sidneys1 wrote:No, it is not possible to use that button with the standard NXT firmware. It will always make the program 'exit'. However, I wonder if an NXT-G block could be made that makes use of the SetLongAbort(true) functionality of the enhanced NXC/NBC firmware...
Have a nice day,
~Sidneys1
Yeah, I thought it might be possible with the enhanced firmware, the only problem is I don't know how.
Re: Advanced NXT Buttons NXT-G Block
Posted: 08 Apr 2011, 08:53
by mattallen37
studbrickmaster wrote:Yeah, I thought it might be possible with the enhanced firmware, the only problem is I don't know how.
The EFW supports it, but not NXT-G. There is a lot of stuff the EFW supports that NXT-G doesn't.
Re: Advanced NXT Buttons NXT-G Block
Posted: 08 Apr 2011, 10:22
by bungeshea
mattallen37 wrote:studbrickmaster wrote:Yeah, I thought it might be possible with the enhanced firmware, the only problem is I don't know how.
The EFW supports it, but not NXT-G. There is a lot of stuff the EFW supports that NXT-G doesn't.
What is EFW?!
Re: Advanced NXT Buttons NXT-G Block
Posted: 08 Apr 2011, 10:29
by mattallen37
studbrickmaster wrote:What is EFW?!
Enhanced firmware.
Re: Advanced NXT Buttons NXT-G Block
Posted: 08 Apr 2011, 12:07
by hassenplug
sidneys1 wrote:No, it is not possible to use that button with the standard NXT firmware. It will always make the program 'exit'. However, I wonder if an NXT-G block could be made that makes use of the SetLongAbort(true) functionality of the enhanced NXC/NBC firmware...
It wouldn't work to try to make an NXT-G block, because the NXT-G compiler would not know how to create a command for the enhanced firmware.
Steve
Re: Advanced NXT Buttons NXT-G Block
Posted: 09 Apr 2011, 15:10
by afanofosc
So long as the enhanced firmware functionality is entirely usable or controllable via the standard IOMapRead or IOMapWrite calls then it should be possible to access that functionality via an NXT-G block. The ability to set the enhanced firmware into a state where the Exit button can be used within a user-program only requires that you set a field that I added to the UI module IOMap. The offset is shown below. It is one byte.
Code: Select all
#define UIOffsetAbortFlag 40 /*!< RW - Long Abort (true == use long press to abort) (1 byte) */
The pressed state flags are here:
Code: Select all
PRESSED_EV = 0x01,
SHORT_RELEASED_EV = 0x02,
LONG_PRESSED_EV = 0x04,
LONG_RELEASED_EV = 0x08,
By default the AbortFlag field at offset 40 in the UI module IOMap is set to PRESSED_EV. The code in the Command module checks the state of BTN1 (or BTNEXIT) for this state and exits the program if it contains whatever state AbortFlag is set to. These state flags can be ORed together since the button may be in both the LONG_PRESSED_EV state and the PRESSED_EV state at the same time, of course.
The NXC API function SetLongAbort simply sets AbortFlag to LONG_PRESSED_EV (or, technically, BTNSTATE_LONG_PRESSED_EV, since that is the way I named the above firmware constants in the NBCCommon.h header file). If you want to completely disable the firmware handling of an abort key in your program then you could set AbortFlag to a value that cannot be achieved via the Button module code. That would be any value that does not include the above state values, such as 0x10.
I am pretty sure that the NXT-G compiler does not check the offset value against some compiler hard-coded maximum offset for an IOMapWrite. It would be very odd if it did since the module name is passed in as a string and each module has a different maximum offset. So it should be possible to create an NXT-G block that uses IOMapWrite to set the enhanced NBC/NXC firmware's UI module's AbortFlag field to something other than BTNSTATE_PRESSED_EV.
John Hansen
Re: Advanced NXT Buttons NXT-G Block
Posted: 10 Apr 2011, 15:21
by sidneys1
Interesting.. Time to drag out my old copy of NXT-G v1 (can't find my 1.1 cd) and Labview and see what I can do.
Have a nice day,
~Sidneys1