wishlist for NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

if everything was like your statement connotes I wouldn't have started this wishlist thread (and no one else would need one).^^

BTW: Wishlist.
Not discussion thread.
;)

and my wish was:
NumOut and TextOut both use an optional "clear" parameter which makes the display clear or not before writing (clear screen).
It would be nice (and much more useful) to have it also for clearing the current line before drawing or to clear the end of the line after writing (clear end of line).

For down-compatibility we could make it
0 = no clear
1 = clrscr
-1 = clrln (before writing)
-2 = clreol (after writing)
this would be a very convenient enhancement IMO.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: wishlist for NXC

Post by mattallen37 »

The functionality already exists, you just don't seem to want to use it unless it is packaged into an official function. A wishlist should be for things that don't exist, not for suggesting official solutions for every desired function.

That's fine if you wish for it. John is very good about choosing what he thinks is a legitimately worthwhile enhancement.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

matt,
exactly, it is a wish to John as He is the developer.

It was not a wish to you, so there is no need to start arguing about it.

So please let Him the choice if He wants to implement my wish (meant as a proposal) into NXC for more convenience to all other users who like to use this extra functionality.
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: wishlist for NXC

Post by muntoo »

Although I stand with Matt, let's just wait for John to answer and not pollute this thread when neither sides are willing to give ground. ;)
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

1 extension to be integrated into NXTdefs.h (or any new header like stdlib.h):

Code: Select all

#define clock() ( CurrentTick()-FirstTick() )
C Reference wrote:function
clock

clock_t clock ( void );
Returns the number of clock ticks elapsed since the program was launched.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

BUG-REPORT:
assigning float values in scientific notation is bugged:
spillerec wrote:but it seems like it is the compiler which easily messes up with scientific notification.
yes, indeed, it seems to be a compiler bug, cause I also tried it by

Code: Select all

// #define FLT_MAX 1E37 
float FLT_MAX=1E37;

float max(float f1, float f2, float f3 = -FLT_MAX, float f4 = -FLT_MAX, float f5 = -FLT_MAX) {
  float flarr[5], f;
  flarr[0]=f1; flarr[1]=f2; flarr[2]=f3; flarr[3]=f4; flarr[4]=f5;
  f=ArrayMax( flarr, 0, 5 );
  return f;
}

task main() {
  NumOut(0,8, max(7.1, 12.4, 5.9, 18.6));   // NumOut does not display floats!
  //NumOut(0,0, max(7.1, 12.4, 5.9, 1E+9));   // compiler error
  for(;;);
}
with a similar error msg.
# Error: Invalid floating point operation
File "c:\Temp\temp.nxc" ; line 5
# FLT_MAX float 9.99999999999999954E36
#----------------------------------------------------------
# Error: Error parsing expression: FLT_MAX |
File "c:\Temp\temp.nxc" ; line 14
#
#----------------------------------------------------------
2 errors during compilation
ps
- edit -

Code: Select all

#define FLT_MAX 10000000000000000000000000000000000000
also doesn't work at all.
Last edited by HaWe on 15 Jul 2012, 09:08, edited 1 time in total.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

supplement:
also direct assignment of large floats in decimal notation does not work:

Code: Select all

float max(float f1, float f2, float f3 = -10000000000000000000000000000000000000,
                              float f4 = -10000000000000000000000000000000000000,
                              float f5 = -10000000000000000000000000000000000000) {
  float flarr[5];
  flarr[0]=f1; flarr[1]=f2; flarr[2]=f3; flarr[3]=f4; flarr[4]=f5;
 
  return ArrayMax( flarr, 0, 5 );
}
# Error: Invalid floating point operation
# mov __max_7qG2_f5_7qG2_000, -10000000000000000000000000000000000000

Code: Select all

float max(float f1, float f2, float f3 = -10000000000000000000000000000000000000.0,
                              float f4 = -10000000000000000000000000000000000000.0,
                              float f5 = -10000000000000000000000000000000000000.0) {
  float flarr[5];
  flarr[0]=f1; flarr[1]=f2; flarr[2]=f3; flarr[3]=f4; flarr[4]=f5;
 
  return ArrayMax( flarr, 0, 5 );
}
# Error: Invalid floating point operation
# mov __max_7qG2_f5_7qG2_000, -10000000000000000000000000000000000000.0
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: wishlist for NXC

Post by afanofosc »

I think I have fixed the worst part of the problems with the float max code Doc posted above. One issue not "fixed" since it isn't really supported is using -FLT_MAX as the default value in the function definition when FLT_MAX is a variable name rather than a #define constant.

Generally exponential notation should now work but there probably are still bugs here and there.

I have also made firmware changes that might (!) work for clear line and clear eol options when drawing text (but not with the RIC-based font text drawing). I need to test it a bit before I make it available.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: wishlist for NXC

Post by afanofosc »

I have uploaded a new test release zip and firmware image to the test_releases folder on the BricxCC website.

Code: Select all

#define DRAW_OPT_CLEAR_LINE                 (0x0800) /*!< When drawing text, clear the entire line before drawing the text */
#define DRAW_OPT_CLEAR_EOL                  (0x1000) /*!< When drawing text, clear to the end of the line after drawing the text */
Use these two constants with the new firmware image to clear the entire line or clear to the end of the line after drawing text. These work with NumOut and TextOut.

Exponential numbers and floating point constants outside the range if Int64:

Code: Select all

//#define FLT_MAX 1E37
const float NEG_FLT_MAX=-1E+37;
const float FLT_MAX=1E+37;

//float max(float f1, float f2, float f3 = -FLT_MAX, float f4 = -FLT_MAX, float f5 = -FLT_MAX) {
float max(float f1, float f2, float f3 = NEG_FLT_MAX, float f4 = NEG_FLT_MAX, float f5 = NEG_FLT_MAX) {
  float flarr[5], f;
  flarr[0]=f1; flarr[1]=f2; flarr[2]=f3; flarr[3]=f4; flarr[4]=f5;
  f=ArrayMax( flarr, 0, 5 );
  return f;
}

task main() {
  NumOut(0,8, max(7.1, 12.4, 5.9, 18.6));   // These both seem to work fine now
  NumOut(0,0, max(7.1, 12.4, 5.9, 1e+19));  
  for(;;);
}
Line clearing:

Code: Select all

task main()
{
  string msg = "testing";
  TextOut(0, 52, msg);
  Wait(SEC_2);
  NumOut(24, 52, 10, DRAW_OPT_CLEAR_LINE);
  Wait(SEC_2);
  TextOut(0, 26, msg);
  Wait(SEC_2);
  NumOut(24, 26, 10, DRAW_OPT_CLEAR_EOL);
  Wait(SEC_5);
}
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: wishlist for NXC

Post by HaWe »

just back from my summer holidays, there are really lots of interesting good news. I'll start and keep testing and will report ASAP.
Thank you, John, for anticipating and for your efforts!
Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests