Go to Post IRI: Where the Egos Go to Tie. :ahh: - Ian Curtis [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-09-2008, 15:18
rwood359 rwood359 is offline
Registered User
AKA: Randy
FRC #0359 (Hawaiian Kids)
Team Role: Mentor
 
Join Date: Aug 2008
Rookie Year: 2008
Location: Waialua, HI
Posts: 212
rwood359 is a name known to allrwood359 is a name known to allrwood359 is a name known to allrwood359 is a name known to allrwood359 is a name known to allrwood359 is a name known to all
PrintToScreen vs printf escape sequences

I am just getting started with WPILib under MPLAB 8.1 and C18 2.4.
I followed the WPI instructions for building the "Hello World" project and everything worked.
I added a called to the color control routine and everything worked. (Code follows)
The output is:

Hello World
In color

The three warning messages irritated me, so I changed printf to PrintToScreen. That got rid of the warnings, but the output is no longer correct

The output is:
[0;7680;12032mHello World
[0;7936;12032mIn color

It looks like PrintToScreen is stripping off the ESC control character needed by Tera Term for terminal control operations.

Any suggestions?

The code is:
#include "API.h"

#define RESET 0
#define BRIGHT 1
#define DIM 2
#define UNDERLINE 3
#define BLINK 4
#define REVERSE 7
#define HIDDEN 8

#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7

void textcolor(int attr, int fg, int bg);
void main (void)
{
while (1)
{
textcolor(RESET, BLACK,WHITE);
PrintToScreen("Hello World\r");
Wait(1000);
textcolor(RESET, RED, WHITE);
PrintToScreen("In color\r");
Wait(1000);
}
}
void textcolor(int attr, int fg, int bg)
{
/* Send color command to the terminal */
PrintToScreen("%c[%d;%d;%dm",0x1B, attr, fg + 30, bg + 40);
}
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
printf or PrintToScreen? sfs Programming 6 04-02-2008 20:39
RC Secret Key Sequences tdlrali Programming 9 05-02-2007 07:16
Odd Escape ZZII 527 Math and Science 25 09-04-2004 22:14
printf isn't printf-ing. Help! Meandmyself Programming 14 15-02-2004 16:27


All times are GMT -5. The time now is 09:30.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi