WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

Displays

Adds support for various standalone display hardware.
Most of the displays available today come in two different forms:
Character display have a fixed number of text columns across and a fixed number of text lines down. Think of them as being like the display in a hand held calculator. By default these devices can display standard ASCII characters like letters, numbers and punctuation. Some devices have some 'unused' characters and allow you to create your own bitmap. These are called 'custom characters'. These are useful if you want to add stuff like progress bars, or a set of icons like: play, pause, rewind, fast forward, play etc. But there are normally only a handful of available slots.
Graphic displays are more akin to your computer display - ie they are 'x' number of pixels (dots) across and 'y' pixels down. Each dot can be controlled individually - by which I mean it can be set to a particular colour. A black and white screen will either allow you turn a given pixel on or off. More advanced screens allow you to set it to one of 8, 16, 256, 65536, or even millions of colours. Displaying text is not easy as the characters are actually 'drawn'. So the size of each character is potentially variable. Hence its impossible to say how many characters across/down are allowed. You can either have lots of small characters, or less larger characters. This all sounds great - but it does come with downsides. A character display just requires you to give it a single byte representing the character you want displayed. Whereas a graphic display, assuming a character size of 5 dots by 8 dots, requires you to set all 40 dots and so may need you to send 40 bytes rather than just one depending on the firmware provided by the display. So these devices are more powerful - but, for the reasons above, are normally slower if you are just working with text. On the plus side: if you want your display to show maps, dials, graphs etc then you can only choose a graphic display.
The other consideration for displays is how they are connected to your robot board and the choices are either:
A serial connection just uses a UART. So only a transmit pin, ground, and a power supply are normally required.
A parallel connection tends to require either 4 or 8 I/O pins plus an overhead of around 3 extra I/O pins for control purposes. So quite I/O hungry.
An I2C connection is fast and only requires a few pins.
Which is the best? Well serial needs less pins but can be slow (since you are sending 1 bit at a time over the UART), whereas parallel displays require lots of your valuable IO pins but can be faster (as you are sending up to 8 bits at the same time). My personal favourite is I2C. Parallel devices also tend to be cheaper to buy as they are simpler designs and hence require less hardware. The serial devices often have a parallel display 'under the hood' with an extra board that accepts the serial input and then talks to the parallel display.
For example: some shop fronts, such as Sparkfun, sell a 'serial board' that plugs into a parallel display so that a parallel display can be converted into a serial display.
The actual choice of display manufacturer and model is up to you - but WebbotLib tries to make all of them appear to work in the same way as far as your code is concerned. This allows you to change from one display to another whilst minimising the effects on your code.
The available commands for all displays are listed in _display_common.h and graphical displays add the extra functions listed in _gdisplay_common.h.
Here is a code snippet example of how to use a display in text mode, in this case just a plain old HD44780 compatible display, to show a bar graph of each of the analogue to digital ports:
// Forward reference
MAKE_WRITER(display_put_char);
// Define the display for the Axon
HD44780 display = MAKE_HD44780_4PIN(8,2,L0,L1,L2,L3,L4,L5,L6,&display_put_char);
// Create a Writer to write to display
MAKE_WRITER(display_put_char){
    return displaySendByte(&display,byte);
}
 
// Initialise the display and send
// rprintf output to it
void appInitHardware(void) {
    displayInit(&display);
    setErrorLog(displayGetWriter(&display));
    rprintfInit(displayGetWriter(&display));
}
 
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    displayAutoScroll(&display,FALSE);
    displayLineWrap(&display,FALSE);
 
    int cols = MIN(NUM_ADC_CHANNELS, displayColumns(&display));
    for(int n=0; n<cols;n++){
        rprintf("%d",n % 10);
    }
    return 0;
}
 
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
    int depth = displayLines(&display)-1;
    int cols = MIN(NUM_ADC_CHANNELS, displayColumns(&display));
    for(int ch = 0; ch<cols; ch++){
        uint8_t val = a2dConvert8bit(ADC_NUMBER_TO_CHANNEL(ch));
        displayVertGraph(&display,ch,1, val, 255, depth);
    }
    return 0;
}

 

File

 

Valid XHTML 1.0 Transitional