Go to Post I wanted my team to be rewarded for something they do, not because they do it for the award. - MikePres [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-01-2013, 21:50
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Printing over other text

Hello! I'm having a small bit of trouble. Nothing critical, but I was wondering if someone could quickly clear something up for me. How do I print text (to the driver station) which completely replaces the previous line? Here is my code:
Code:
                        if (joyTrigger)
			{
				dsLCD->Printf(DriverStationLCD::kUser_Line1, 1, "Trigger");
				dsLCD->UpdateLCD();
				Wait(0.1);
			}
			else if (Button2)
			{
				dsLCD->Printf(DriverStationLCD::kUser_Line1, 11, "BottomThumbButton");
				dsLCD->UpdateLCD();
				Wait(0.1);
			}
What it outputs is the current button (on the joystick). When I press a different button, it overwrites only the space it needs, so if I had it print something like "1111111111" and then something like "22222", it would end up printing "2222211111". I'm pretty sure it's just taking over the spaces, and not pushing the old text to the end of the line where it disappears. I know I could fix it by adding a bunch of spaces after each print, but is there another way? Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 13-01-2013, 22:01
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
In the past I've had similar problems.

Even though my team is using java I'm interested to see what the fix is.
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________
Reply With Quote
  #3   Spotlight this post!  
Unread 13-01-2013, 22:05
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Printing over other text

The DriverStaion LCD duplicates the functionality of the old blue KwickByte DS. This means that the characters are written into a display buffer and you need to pad them with spaces if you wish to write the entire line.

The good part of its behavior is that you can pretty easily make columns on the same line, but it complicates simple debugging printfs.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 13-01-2013, 22:17
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Printing over other text

There's no mechanism to clear a single line other than using spaces, however if you're willing to erase the whole screen, you can use dsLCD->Clear(), which is just a shortcut for writing spaces to all of the lines.

EDIT: I spoke without looking. Use dsLCD->PrintfLine(), which pads spaces as necessary to clear the rest of the line
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote
  #5   Spotlight this post!  
Unread 13-01-2013, 22:36
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Printing over other text

I assume that there is some sort of syntax alteration? Adding "Line" to the end causes an error. I'll look into WPI....
Reply With Quote
  #6   Spotlight this post!  
Unread 13-01-2013, 22:37
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Printing over other text

Drop the "1" argument when you switch to that. PrintfLine assumes you're starting at the front of the line

Code:
dsLCD->PrintfLine(DriverStationLCD::kUser_Line1, "Trigger");
dsLCD->UpdateLCD();
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote
  #7   Spotlight this post!  
Unread 13-01-2013, 23:04
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Printing over other text

Thanks! I have one more question...
When I run a program that prints to the dashboard, then run one that doesn't (or doesn't immediately), the text from the previous program remains on the dashboard until it is either replaced by something else or the driver station is restarted. Is it good practice to use dsLCD->Clear() at the end of the program, or is this not supposed to happen?
Reply With Quote
  #8   Spotlight this post!  
Unread 13-01-2013, 23:38
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Printing over other text

The data on the driver station is only updated when you call dsLCD->UpdateLCD(). Clear() doesn't make that call, so by calling Clear() you're only clearing out the robot-side buffer, but not updating the screen with it.

I personally don't mind having the stale data on the DS, especially since it leaves a snapshot of the robot's state from right before the connection was lost. Whenever I'm using the DriverStationLCD class though (which isn't as common now that SmartDashboard is available) I put in a call to Clear() before any Printf()s, just so that I can be sure I'm not forgetting to blank out any lines. It's all up to you though
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote
  #9   Spotlight this post!  
Unread 14-01-2013, 11:40
cjlane1138 cjlane1138 is offline
Team 1138
FRC #1138 (Eagle Engineering)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Los Angeles
Posts: 88
cjlane1138 is an unknown quantity at this point
Re: Printing over other text

Last year, I developed a simple header and class file that has a few methods for simple printing to the LCD. Here it is:
http://www.filedropper.com/printtodslcd

Let me know how it works for you!
__________________
Eagle Engineering 1138
Reply With Quote
Reply


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


All times are GMT -5. The time now is 02:51.

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