wishlist for NXC
Re: wishlist for NXC
indeed I was thinking of arrays of any type to be sorted, single dimensional arrays of integer as well as floats, maybe even 2-dim arrays of floats  (= [x,y] coordinates, sorted to the x or the y value)
for this task having a function overloading surely would be helpful
I was asking because a qsort normally is already implemented in most of C libraries coming with the compilers, so I wouldn't have to try to write something like it on my own.
			
			
									
						
										
						for this task having a function overloading surely would be helpful
I was asking because a qsort normally is already implemented in most of C libraries coming with the compilers, so I wouldn't have to try to write something like it on my own.
Re: wishlist for NXC
You would need a mechanism to create a pointer to a function that provides a comparison for the type in question.  Otherwise there is no generic way of doing this.
- Xander
			
			
									
						
							- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
			
						| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Re: wishlist for NXC
The enhanced NBC/NXC firmware does provide a way to sort a 1d array of any scalar type.  It is exposed as the ArraySort NXC API function.
http://bricxcc.sourceforge.net/nbc/nxcd ... index.html
Search for ArraySort.
http://bricxcc.sourceforge.net/nbc/nxcd ... ample.html
John Hansen
			
			
									
						
							http://bricxcc.sourceforge.net/nbc/nxcd ... index.html
Search for ArraySort.
http://bricxcc.sourceforge.net/nbc/nxcd ... ample.html
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
			
						http://bricxcc.sourceforge.net/
Re: wishlist for NXC
That's really great, thanks!
Even the ArrayOp is excellent ! :)
maybe you also wish to implement an ArrayMed and an OPARR_MED for the median? ;)
(edit: although it's simple, as it's just variant[(1+array_len)/2] of the sorted array (start counting at 1) or
variant[array_len/2] (start counting at 0))
			
			
													Even the ArrayOp is excellent ! :)
maybe you also wish to implement an ArrayMed and an OPARR_MED for the median? ;)
(edit: although it's simple, as it's just variant[(1+array_len)/2] of the sorted array (start counting at 1) or
variant[array_len/2] (start counting at 0))
					Last edited by HaWe on 28 Jan 2011, 17:33, edited 1 time in total.
									
			
						
										
						Re: wishlist for NXC
hi,
could we have a well working function for synched motor control which works less faulty than the current RotateMotorEx together with the current FW (OFW/EFW)?
e.g.
			
			
									
						
										
						could we have a well working function for synched motor control which works less faulty than the current RotateMotorEx together with the current FW (OFW/EFW)?
e.g.
Code: Select all
void RotateMotorSync  ( // sync is always true!
  byte  output_0, // Master: targets absolute value
  byte  output_1, // Slave: targets relative value
  char  pwr,  
  long  angle,  
  char  turnpct,  
  bool  stop   
 ) Code: Select all
----------------- settings ----------------|------------- results ------------------ 
output_0, output_1, pwr angle turnpct stop | target_0 target_1 // comment 
OUT_A     OUT_B     75   400     100  true |   400       400    // 2nd: 100% = 400     
OUT_A     OUT_B     75   400    -100  true |   400      -400    // 2nd: -100% = -400
OUT_A     OUT_B     75   400       0  true |   400         0    // 2nd: 0% 0f 400 = 0
OUT_A     OUT_B     75   400      50  true |   400       200    // 2nd: 50% of 400 = 200
OUT_A     OUT_B     75   400     -30  true |   400      -120    // 2nd: -30% of 400 = -120 
OUT_A     OUT_B     75   400      -3  true |   400       -12    // 2nd: -3% of 400 = -12 Re: wishlist for NXC
Can we have a "ptr" alias for "unsigned long"?
vs
			
			
									
						
							Code: Select all
unsigned long addr = addressOf(??);Code: Select all
ptr addr = addressOf(??);Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Re: wishlist for NXC
What would be different compared to starting both motor with a different speed and angle?doc-helmut wrote:hi,
could we have a well working function for synched motor control which works less faulty than the current RotateMotorEx together with the current FW (OFW/EFW)?
Code: Select all
----------------- settings ----------------|------------- results ------------------ output_0, output_1, pwr angle turnpct stop | target_0 target_1 // comment OUT_A OUT_B 75 400 100 true | 400 400 // 2nd: 100% = 400 OUT_A OUT_B 75 400 -100 true | 400 -400 // 2nd: -100% = -400 OUT_A OUT_B 75 400 0 true | 400 0 // 2nd: 0% 0f 400 = 0 OUT_A OUT_B 75 400 50 true | 400 200 // 2nd: 50% of 400 = 200 OUT_A OUT_B 75 400 -30 true | 400 -120 // 2nd: -30% of 400 = -120 OUT_A OUT_B 75 400 -3 true | 400 -12 // 2nd: -3% of 400 = -12
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
			
						Re: wishlist for NXC
the sync mode.
both motors run during the same time until they finally have reached their individual target concurrently,
i.e. with turnpct=100% the difference between both counters must not exceed more than e.g. 1 degree ever
and with small turnpcts it's simultaneously the proportional value +/-1:
			
			
									
						
										
						both motors run during the same time until they finally have reached their individual target concurrently,
i.e. with turnpct=100% the difference between both counters must not exceed more than e.g. 1 degree ever
and with small turnpcts it's simultaneously the proportional value +/-1:
Code: Select all
angle=400, turnpct=50
motor_0   0   50   100   150   200   250   300   350   400 // absolute
motor_1   0   25    50    75   100   125   150   175   200  // simultaneously proportionally +-1Re: wishlist for NXC?
are there (hopefully) already any news about this subject?afanofosc wrote:One thing I know Xander has wished for is support for overloaded functions so that you could write:Code: Select all
int foobar(int x, int y) { return x+y; } string foobar(string x, string y) { return x + y; }
Re: wishlist for NXC
hi,doc-helmut wrote:can we have more kinds of formatting parameters for FormatString or printf except %d or %f
...
I just observed that FomatNum already works in the 20101103 release with fmt="%x", "%04x" as well as with "%s" .
No idea why I couldn't make it work so far.
Unfortunately I still couldn't find a hint about fmt string parameters in the help (FormatNum topic).
Just e.g. "%9s" for flush right tabulator string formatting does not work, but I'm not sure if this is standard anyway.
Code: Select all
  
#define printf1( _x, _y, _format1, _value1) { \
  string sval1 = FormatNum(_format1, _value1); \
  TextOut(_x, _y, sval1); \
}
  printf1( 0,LCDline[0], "seed=%8d dc",RAND_SEED);
  printf1( 0,LCDline[1], "seed=%08x hx",RAND_SEED); // nums flush right
  printf1( 0,LCDline[2], "%9s", "press");  // strings flush left
  printf1( 0,LCDline[3], "%9s", "any");
  printf1( 0,LCDline[4], "%9s", "btn");
  printf1( 0,LCDline[5], "%9s", "to");
  printf1( 0,LCDline[6], "%9s", "continue");
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest