Advanced NXT Buttons NXT-G Block

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
bungeshea
Posts: 207
Joined: 14 Aug 2011, 08:45
Location: Australia
Contact:

Advanced NXT Buttons NXT-G Block

Post 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?
Last edited by bungeshea on 08 Apr 2011, 06:28, edited 1 time in total.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post by mattallen37 »

I am quite sure you can't with NXT-G. However, I know you can with NXC.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
sidneys1
Posts: 141
Joined: 01 Oct 2010, 14:38
Location: Pennsylvania - The United States of America
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post 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
My Mindstorms website: http://sidneys1.com
bungeshea
Posts: 207
Joined: 14 Aug 2011, 08:45
Location: Australia
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post 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.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post 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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
bungeshea
Posts: 207
Joined: 14 Aug 2011, 08:45
Location: Australia
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post 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?!
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post by mattallen37 »

studbrickmaster wrote:What is EFW?!
Enhanced firmware.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post 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
---> Link to lots of MINDSTORMS stuff under my picture --->
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
sidneys1
Posts: 141
Joined: 01 Oct 2010, 14:38
Location: Pennsylvania - The United States of America
Contact:

Re: Advanced NXT Buttons NXT-G Block

Post 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
My Mindstorms website: http://sidneys1.com
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests