|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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);
}
|
|
#2
|
||||
|
||||
|
In the past I've had similar problems.
Even though my team is using java I'm interested to see what the fix is. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
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....
|
|
#6
|
|||
|
|||
|
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(); |
|
#7
|
||||
|
||||
|
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? |
|
#8
|
|||
|
|||
|
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 |
|
#9
|
|||
|
|||
|
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! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|