TextOut y value
Re: TextOut y value
You can use #import without anything after the filename as described here:
http://bricxcc.sourceforge.net/nbc/nxcd ... mport.html
In that case the variable name for the Tiny_6 font would be Tiny_6 and the variable name for the Sans_10 font would be Sans_10. That might help avoid this problem. The optional value after the filename is a format specified which defaults to %s where the filename without an extension is what is passed into the format specifier. So you could use fnt_%s following the Filename and the variable would be named fnt_Tiny_6 and fnt_Sans_10 respectively.
John Hansen
			
			
									
						
							http://bricxcc.sourceforge.net/nbc/nxcd ... mport.html
In that case the variable name for the Tiny_6 font would be Tiny_6 and the variable name for the Sans_10 font would be Sans_10. That might help avoid this problem. The optional value after the filename is a format specified which defaults to %s where the filename without an extension is what is passed into the format specifier. So you could use fnt_%s following the Filename and the variable would be named fnt_Tiny_6 and fnt_Sans_10 respectively.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
			
						http://bricxcc.sourceforge.net/
Re: TextOut y value
thank you very much!
that would mean
#import "Tiny_6.ric"
would be further processed like
__gFont = "Tiny_6.ric";
LoadFont( Tiny_6, __gFont );
			
			
									
						
										
						that would mean
#import "Tiny_6.ric"
would be further processed like
__gFont = "Tiny_6.ric";
LoadFont( Tiny_6, __gFont );
Re: TextOut y value
yes, just killed another bug  ;)
now finally it works!
			
			
									
						
										
						now finally it works!
Code: Select all
// importFont.nxc
string __gFont;
unsigned int LoadFont( byte &arr[], string filename ){
   byte handle;
   unsigned int size = ArrayLen( arr );
   unsigned int result = CreateFileLinear( filename, size, handle );
   if( result == LDR_SUCCESS ){
      result = Write( handle, arr );
      CloseFile( handle );
   }
   ArrayInit( arr, 0, 0 );
   return result;
}
unsigned int UnloadFont( string filename ){
  return DeleteFile( filename );
}
#import "Tiny_6.ric"
#import "Sans_10.ric"
task main() {
  LoadFont( Tiny_6,  "Tiny_6.ric"  );
  LoadFont( Sans_10, "Sans_10.ric" );
  __gFont = "Sans_10.ric";
  FontTextOut(0,45,__gFont, "y=45 "+ __gFont);  //
  __gFont = "Tiny_6.ric";
  FontTextOut(0,30,__gFont, "y=30 "+ __gFont);  //
  
  __gFont = "Sans_10.ric";
  FontTextOut(0,15,__gFont, "y=15 "+ __gFont);  //
  
  __gFont = "Tiny_6.ric";
  FontTextOut(0, 0,__gFont, "y=0 "+ __gFont);  //
  
  
  while(1);
}- 
				spillerrec
 - Posts: 358
 - Joined: 01 Oct 2010, 06:37
 - Location: Denmark
 - Contact:
 
Re: TextOut y value
Yeah, I accidentally hardcoded the filename instead of using the "filename" parameter I originally intended to use. I was starting to wonder when you would notice it xD
			
			
									
						
							My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
			
						RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: TextOut y value
I've uploaded a new build of the enhanced NBC/NXC firmware to the test_releases folder.  It implements the faster text drawing code from Nicolas and support for FontTextOut with either a RIC font filename or a RIC font array.  The firmware assumes it is a filename if it has <= 20 bytes in the array and otherwise it assumes it is an array containing the font data.
John Hansen
			
			
									
						
							Code: Select all
  FontTextOut(0,LCD_LINE3,"tahoma8.ric", "Cicero scripsit:");
  FontTextOut(0,LCD_LINE5,"", "Cicero scripsit:"); // uses TextOut if empty string
  TextOut(0,LCD_LINE6,"Cicero scripsit:");
  FontTextOut(0,LCD_LINE8,Tiny_6, "Cicero scripsit:");
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
			
						http://bricxcc.sourceforge.net/
- 
				mattallen37
 - Posts: 1818
 - Joined: 02 Oct 2010, 02:19
 - Location: Michigan USA
 - Contact:
 
Re: TextOut y value
Got it, thanks!
BTW, it's upload dated for about 5 hours from now
			
			
									
						
							BTW, it's upload dated for about 5 hours from now
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
			
						http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: TextOut y value
I think sourceforge is showing a UTC time - equivalent to about 9:20pm CST.
John Hansen
			
			
									
						
							John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
			
						http://bricxcc.sourceforge.net/
Re: TextOut y value
Using the code from my previous post
http://sourceforge.net/apps/phpbb/mindb ... =10#p12142
I compared the latest firmware to the firmware from Jan 7 before the TextOut changes. This time I paid attention to compiler optimization level. I tested using optimization levels 1, 2, and 3. These are the average timings in ticks (n = 5):
lms_arm_nbcnxc_131_20111019_1659.rfw 5507 5103 4675
lms_arm_nbcnxc_132_20120214_2114.rfw 6843 6424 5933
The latest firmware with optimization levels 1, 2, and 3 has an increase of 24%, 26%, and 27% respectively over the earlier firmware. Thank you John and Nicolas.
			
			
									
						
										
						http://sourceforge.net/apps/phpbb/mindb ... =10#p12142
I compared the latest firmware to the firmware from Jan 7 before the TextOut changes. This time I paid attention to compiler optimization level. I tested using optimization levels 1, 2, and 3. These are the average timings in ticks (n = 5):
lms_arm_nbcnxc_131_20111019_1659.rfw 5507 5103 4675
lms_arm_nbcnxc_132_20120214_2114.rfw 6843 6424 5933
The latest firmware with optimization levels 1, 2, and 3 has an increase of 24%, 26%, and 27% respectively over the earlier firmware. Thank you John and Nicolas.
Who is online
Users browsing this forum: No registered users and 10 guests