GraphicsLCD.drawString not drawing text in 0.8.1

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

mcrosbie
Novice
Posts: 33
Joined: Wed Mar 24, 2010 12:27 pm
Location: Dublin, Ireland
Contact:

GraphicsLCD.drawString not drawing text in 0.8.1

Postby mcrosbie » Thu May 22, 2014 2:14 pm

I'm trying to display some text using the GraphicsLCD.drawString() method (as distinct from the LCD one). In this code I expect it to display an incrementing value on the screen but instead all I see is a blank screen. If I remove the call to g.setColor(COLOR.WHITE) then I get over-printing and the text smudges itself. This is on 0.8.1-beta.

Any ideas?

Code: Select all

import lejos.hardware.Button;
import lejos.hardware.Sound;
import lejos.hardware.ev3.LocalEV3;
import lejos.hardware.lcd.GraphicsLCD;
import lejos.hardware.lcd.LCD;
import lejos.robotics.Color;
import lejos.utility.Delay;


public class TestGraphics {

   static GraphicsLCD g = LocalEV3.get().getGraphicsLCD();
    final static int SW = g.getWidth();
    final static int SH = g.getHeight();

   public static void main(String[] args) {
      // TODO Auto-generated method stub

      int i = 0;
      while(Button.ENTER.isUp()) {
         
         g.setColor(Color.BLACK);
         g.drawString("i = " + i, 20, 20, GraphicsLCD.HCENTER | GraphicsLCD.BASELINE);
         Delay.msDelay(1000);
         g.setColor(Color.WHITE);
         g.drawString("i = " + i, 20, 20, GraphicsLCD.HCENTER | GraphicsLCD.BASELINE);
         i++;
      }
      
      Delay.msDelay(1000);
   }

}

User avatar
gloomyandy
leJOS Team Member
Posts: 4766
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: GraphicsLCD.drawString not drawing text in 0.8.1

Postby gloomyandy » Thu May 22, 2014 4:31 pm

Hi Marc,
The Color class is used for the values returned by the various color sensors it does not define a set of RGB constants for things like BLACK/WHITE etc. The setColor method expects an RGB value, not a Lego color code (the current GraphicsLCD is based on the old Java LCDUI code, it is not Lego specific). Try using GraphicsLCD.BLACK and GraphicsLCD.WHITE instead...

Andy

mcrosbie
Novice
Posts: 33
Joined: Wed Mar 24, 2010 12:27 pm
Location: Dublin, Ireland
Contact:

Re: GraphicsLCD.drawString not drawing text in 0.8.1

Postby mcrosbie » Thu May 22, 2014 5:09 pm

Cheers Andy - I figured it was something silly alright.


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 2 guests