KSM edits to RA8875

Dependents:   Liz_Test_Code

TextDisplay.h

Committer:
WiredHome
Date:
2014-01-20
Revision:
31:c72e12cd5c67
Parent:
29:422616aa04bd
Child:
33:b6b710758ab3

File content as of revision 31:c72e12cd5c67:

/* mbed TextDisplay Library Base Class
 * Copyright (c) 2007-2009 sford
 * Released under the MIT License: http://mbed.org/license/mit
 *
 * A common base class for Text displays
 * To port a new display, derive from this class and implement
 * the constructor (setup the display), character (put a character
 * at a location), rows and columns (number of rows/cols) functions.
 * Everything else (locate, printf, putc, cls) will come for free
 *
 * The model is the display will wrap at the right and bottom, so you can
 * keep writing and will always get valid characters. The location is
 * maintained internally to the class to make this easy
 */

#ifndef MBED_TEXTDISPLAY_H
#define MBED_TEXTDISPLAY_H

#include "mbed.h"

#include "DisplayDefs.h"

class TextDisplay : public Stream
{
public:

    // functions needing implementation in derived implementation class
    /** Create a TextDisplay interface
    *
    * @param name The name used in the path to access the strean through the filesystem
    */
    TextDisplay(const char *name = NULL);

    /** output a character at the given position
     *
     * @param x position in pixels
     * @param y position in pixels
     * @param c the character to be written to the TextDisplay
     * @returns number of pixels to advance the cursor.
     */
    virtual int character(int x, int y, int c) = 0;

    /** return number if rows on TextDisplay
     * @result number of rows
     */
    virtual int rows() = 0;

    /** return number if columns on TextDisplay
    * @result number of rows
    */
    virtual int columns() = 0;

    // functions that come for free, but can be overwritten

    /** redirect output from a stream (stoud, sterr) to  display
    * @param stream stream that shall be redirected to the TextDisplay
    */
    virtual bool claim (FILE *stream);

    /** clear screen
    */
    virtual RetCode_t cls() = 0;
    virtual RetCode_t locate(unsigned int column, unsigned int row) = 0;
    virtual RetCode_t foreground(uint16_t colour) = 0;
    virtual RetCode_t background(uint16_t colour) = 0;
    // putc (from Stream)
    // printf (from Stream)

protected:    
    virtual int _putc(int value);
    virtual int _getc();

    // character location
    uint16_t _column;
    uint16_t _row;

    // colours
    uint16_t _foreground;
    uint16_t _background;
    char *_path;
};

#endif