TextStar Serial LCD Library

30 Dec 2009

Simon,

I recently purchased a TextStar serial LCD module from Cool Components. Very nice too - it has the same "cool factor" as mbed!

I have started to write a class library for it and am using your experimental TextDisplay class as the base. Unfortunately, TextStar's capabilities do not seem to mesh well with the TextDisplay model. For example:

TextStar handles cursor wrapping and has a "lazy scrolling" feature that ensures the most recent output is visible even if the cursor position is not.

TextStar supports a 16 line virtual display and has commands to move the visible window over that space.

TextStar has numerous cursor manipulation commands including several single character ones. These could easily be embedded in a string. This means the column/row tracking logic in character() needs to be much more sophisticated.

TextStar has commands for custom character definition and key programming. The TextDisplay model does not support these operations.

Is TextDisplay likely to become the "official" way of interfacing text displays or is it just another experiment? Should I persevere with TextDisplay or would I be better off deriving a TextStar class directly from Serial?

BTW, I also tried using TextDisplay on the USB virtual serial port talking to TerraTerm. At 9600 baud it was dreadfully slow. Not surprising given that you are doing an x,y addressing before outputting each character. I can't help feeling that this is the wrong approach. Perhaps you should add a mode command to support either raw output (ie fast) or windowed output?

I would appreciate your guidance.

Paul

30 Dec 2009

Hi Paul,

I'd just have a play with writing whatever feels right; definitely recommend inheriting from stream so you get the printf/file functionality, but that is probably enough and a good start.

In time I'm sure we'll find the right balance of flexibility and commonality (e.g. i'd expect some basic functions like cls() and locate(x,y) to be common), but for now just code up something that lets you use the display easily and others could use. As you say, not sure if the experiments I was doing would be the right approach - it was more to push the idea of commonality as far as I could to see where it cost more than the benefits.

So I think just get something working then share the results!

Simon

31 Dec 2009

Hi Paul,

I had a go at the terminal emulator again based on your comments around simplifying it, and I think you are right; it feels much nicer.

Take a look at the results and library here:

Terminal

This might be a good comparison for your display (which i'm suspecting is also serial plus escape sequences from your description). I've basically wrapped up cls, locate and foreground/background colour sequences, so nice and simple yet really usable.

Here is an example of it in use:

Right, I'm off to make tea.

Simon

03 Jan 2010

Hi Simon,

I agree, this feels much nicer!

Do you think it is worthwhile adding some more functions to the library for cursor movement and control, eg

  • up()
  • down()
  • left()
  • right()
  • home()
  • cursor(int style)     hide/show cursor and set cursor style

TextStar cursor styles are: 0 = off, 1 = solid block, 2 = flashing block, 3 = solid underline, 4 = flashing underline

Finally, I would appreciate some asistance.

The TextStar module uses CR to effectively do a CR-LF. LF just moves the cursor down. This means that normal C strings ending in "\n" do not display correctly. What I want to do is intercept the low level output from printf() and puts() and translate LF characters into CR characters. All other characters are to pass through unchanged. However, I still need the ability to send LF to the display for the cursor down command.

I am thinking along the lines of

int TextStar::_putc(int value) {
    if (value == '\n') {
        _serial._putc('\r');
    } else {
        _serial._putc(value);
     }
    return value;
}

This is my first foray into C++ class programming, so I am not too sure about the details, especially which low level routine to use for output and how to declare it correctly. Everything I have tried either does not compile or does not work!

Paul.