Loading ...
Sorry, an error occurred while loading the content.

Display.printChar( )

Expand Messages
  • Don
    Can anyone get this method to display characters on the LCD display? Try the following code: static Display lcd = IntelliBrain.getLcdDisplay();
    Message 1 of 4 , Feb 9, 2007
    • 0 Attachment
      Can anyone get this method to display characters on the LCD
      display? Try the following code:

      static Display lcd = IntelliBrain.getLcdDisplay();
      lcd.print(0," ");
      lcd.print(1," ");

      for(int i = 0; i < 256; i++){
      Integer j = new Integer(i);
      lcd.print(0, j.toString());
      lcd.printChar(1, 2, (byte)i);
      long time = System.currentTimeMillis();
      while(System.currentTimeMillis() < (time + 1000));
      }

      This should display the value of the numeric value of the byte, from
      0 to 255, on line 0, and the character value of each byte on line 1,
      pausing one sec between each. It does display line 0 correctly, but
      nothing on line 1.

      Or just try this: lcd.printChar( 1, 2,(byte)'A');

      Nothing.

      I hardly ever see any characters being displayed by using this
      method. Interestingly, once in a while a character IS displayed and
      never the same character for multiple executions of the same
      program. Is this method broken or am I doing something wrong?

      The Display.print( ) method works fine BTW.

      -- Don
    • RidgeSoft
      Hi Don, The printChar routine enables the calling thread to attempt to print a character to the LCD screen without waiting if the LCD hardware is busy. If the
      Message 2 of 4 , Feb 11, 2007
      • 0 Attachment
        Hi Don,

        The printChar routine enables the calling thread to attempt to print a
        character to the LCD screen without waiting if the LCD hardware is busy.
        If the LCD is not busy it will print the character and return true,
        otherwise it will return false and the caller will need to try again
        later.

        Changing the line with the printChar method to the following should
        solve the problem:

        while (!lcd.printChar(1, 2, (byte)i));


        RidgeSoft Support


        --- In intellibrain@yahoogroups.com, "Don" <DCFrench@...> wrote:
        >
        > Can anyone get this method to display characters on the LCD
        > display? Try the following code:
        >
        > static Display lcd = IntelliBrain.getLcdDisplay();
        > lcd.print(0," ");
        > lcd.print(1," ");
        >
        > for(int i = 0; i < 256; i++){
        > Integer j = new Integer(i);
        > lcd.print(0, j.toString());
        > lcd.printChar(1, 2, (byte)i);
        > long time = System.currentTimeMillis();
        > while(System.currentTimeMillis() < (time + 1000));
        > }
        >
        > This should display the value of the numeric value of the byte, from
        > 0 to 255, on line 0, and the character value of each byte on line 1,
        > pausing one sec between each. It does display line 0 correctly, but
        > nothing on line 1.
        >
        > Or just try this: lcd.printChar( 1, 2,(byte)'A');
        >
        > Nothing.
        >
        > I hardly ever see any characters being displayed by using this
        > method. Interestingly, once in a while a character IS displayed and
        > never the same character for multiple executions of the same
        > program. Is this method broken or am I doing something wrong?
        >
        > The Display.print( ) method works fine BTW.
        >
        > -- Don
        >
      • Don French
        Ah! There it was, right in the Javadoc. I guess I missed it because all the other LCD display classes I am familiar with do that kind of readiness-checking
        Message 3 of 4 , Feb 11, 2007
        • 0 Attachment
          Ah!  There it was, right in the Javadoc.  I guess I missed it because all the other LCD display classes I am familiar with do that kind of readiness-checking for you.  This might be a good example of a place to use subclassing to create a more usable class. 
           
          On a related note, I am curious as to why, as the Javadoc says, that this method should not be called directly.  Is it just because of this readiness issue, something that really could have and should have been handled in the printChar method in the first place?  The only alternative, if you want to change the contents of a single character position, is to write a string or array of bytes, both of which overwrite whatever precedes the character you want to change.  Therefore, you have to always keep track of the characters currently being displayed, an big nuisance and memory waste.

          -- Don French
           
           
          ----- Original Message -----
          From: RidgeSoft
          Sent: Sunday, February 11, 2007 6:12 AM
          Subject: [intellibrain] Re: Display.printChar( )

          Hi Don,

          The printChar routine enables the calling thread to attempt to print a
          character to the LCD screen without waiting if the LCD hardware is busy.
          If the LCD is not busy it will print the character and return true,
          otherwise it will return false and the caller will need to try again
          later.

          Changing the line with the printChar method to the following should
          solve the problem:

          while (!lcd.printChar( 1, 2, (byte)i));

          RidgeSoft Support

          --- In intellibrain@ yahoogroups. com, "Don" <DCFrench@.. .> wrote:
          >
          > Can anyone get this method to display characters on the LCD
          > display? Try the following code:
          >
          > static Display lcd = IntelliBrain. getLcdDisplay( );
          > lcd.print(0, " ");
          > lcd.print(1, " ");
          >
          > for(int i = 0; i < 256; i++){
          > Integer j = new Integer(i);
          > lcd.print(0, j.toString() );
          > lcd.printChar( 1, 2, (byte)i);
          > long time = System.currentTimeM illis();
          > while(System. currentTimeMilli s() < (time + 1000));
          > }
          >
          > This should display the value of the numeric value of the byte, from
          > 0 to 255, on line 0, and the character value of each byte on line 1,
          > pausing one sec between each. It does display line 0 correctly, but
          > nothing on line 1.
          >
          > Or just try this: lcd.printChar( 1, 2,(byte)'A') ;
          >
          > Nothing.
          >
          > I hardly ever see any characters being displayed by using this
          > method. Interestingly, once in a while a character IS displayed and
          > never the same character for multiple executions of the same
          > program. Is this method broken or am I doing something wrong?
          >
          > The Display.print( ) method works fine BTW.
          >
          > -- Don
          >

        • Don
          Oops, it is not going to be that easy to subclass Display. The problem is that you can t subclass Display without implementing printChar( ) because for some
          Message 4 of 4 , Feb 11, 2007
          • 0 Attachment
            Oops, it is not going to be that easy to subclass Display. The
            problem is that you can't subclass Display without implementing
            printChar( ) because for some reason it was made an abstract method.
            And you can't implement printChar( ) because Intellibrain does not
            permit native methods. Grrr!

            Ok, so the alternative is to encapsulate the Display object in
            another class. This is the one I created:

            import com.ridgesoft.intellibrain.IntelliBrain;
            import com.ridgesoft.io.*;

            public class LCD {
            Display myLCD;
            public LCD(){
            myLCD =IntelliBrain.getLcdDisplay();
            }

            public void printChar(int line, int col, char ch){
            while(!myLCD.printChar(line, col , (byte)ch));
            }

            public void printByte(int line, int col, byte ch){
            while(!myLCD.printChar(line, col , ch));
            }

            public void printString(int line, String str){
            myLCD.print(line, str);
            }

            public void printByteArray(int line, byte[] array){
            myLCD.print(line, array);
            }

            public void print(int line, String str){
            myLCD.print(line, str);
            }

            public void print(int line, byte[] array){
            myLCD.print(line, array);
            }

            public boolean printChar(int line, int col, byte ch){
            return myLCD.printChar(line, col, ch);
            }

            public int getHeight(){
            return myLCD.getHeight();
            }

            public int getWidth(){
            return myLCD.getWidth();
            }
            }

            It is uglier than subclassing, but it works. This class has the
            advantage of having a real printChar method that takes a char instead
            of a misnamed method whose argument is actually byte. But not to
            shortchange those who need a printByte method, I added that too. I
            also preserved all the original Display method signatures.
            printString and printByteArray are not really needed, but some people
            prefer method names that clearly describe the methods, so they are
            just dups of two other print methods.

            I wonder what the rationale was for making printChar an abstract
            method and suggesting that we not use it.

            -- Don French


            --- In intellibrain@yahoogroups.com, Don French <DCFrench@...> wrote:
            >
            > Ah! There it was, right in the Javadoc. I guess I missed it
            because all the other LCD display classes I am familiar with do that
            kind of readiness-checking for you. This might be a good example of
            a place to use subclassing to create a more usable class.
            >
            > On a related note, I am curious as to why, as the Javadoc says,
            that this method should not be called directly. Is it just because
            of this readiness issue, something that really could have and should
            have been handled in the printChar method in the first place? The
            only alternative, if you want to change the contents of a single
            character position, is to write a string or array of bytes, both of
            which overwrite whatever precedes the character you want to change.
            Therefore, you have to always keep track of the characters currently
            being displayed, an big nuisance and memory waste.
            >
            > -- Don French
            >
            >
            > ----- Original Message -----
            > From: RidgeSoft
            > To: intellibrain@yahoogroups.com
            > Sent: Sunday, February 11, 2007 6:12 AM
            > Subject: [intellibrain] Re: Display.printChar( )
            >
            >
            > Hi Don,
            >
            > The printChar routine enables the calling thread to attempt to
            print a
            > character to the LCD screen without waiting if the LCD hardware
            is busy.
            > If the LCD is not busy it will print the character and return
            true,
            > otherwise it will return false and the caller will need to try
            again
            > later.
            >
            > Changing the line with the printChar method to the following
            should
            > solve the problem:
            >
            > while (!lcd.printChar(1, 2, (byte)i));
            >
            > RidgeSoft Support
            >
            > --- In intellibrain@yahoogroups.com, "Don" <DCFrench@> wrote:
            > >
            > > Can anyone get this method to display characters on the LCD
            > > display? Try the following code:
            > >
            > > static Display lcd = IntelliBrain.getLcdDisplay();
            > > lcd.print(0," ");
            > > lcd.print(1," ");
            > >
            > > for(int i = 0; i < 256; i++){
            > > Integer j = new Integer(i);
            > > lcd.print(0, j.toString());
            > > lcd.printChar(1, 2, (byte)i);
            > > long time = System.currentTimeMillis();
            > > while(System.currentTimeMillis() < (time + 1000));
            > > }
            > >
            > > This should display the value of the numeric value of the byte,
            from
            > > 0 to 255, on line 0, and the character value of each byte on
            line 1,
            > > pausing one sec between each. It does display line 0 correctly,
            but
            > > nothing on line 1.
            > >
            > > Or just try this: lcd.printChar( 1, 2,(byte)'A');
            > >
            > > Nothing.
            > >
            > > I hardly ever see any characters being displayed by using this
            > > method. Interestingly, once in a while a character IS displayed
            and
            > > never the same character for multiple executions of the same
            > > program. Is this method broken or am I doing something wrong?
            > >
            > > The Display.print( ) method works fine BTW.
            > >
            > > -- Don
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.