This library can be used to control a low-cost Adafruit 358 TFT display. It has basic functionality but is a starting point for others trying to control this type of display using the FRDM-K64F.

Committer:
bmazzeo
Date:
Thu Aug 07 03:17:21 2014 +0000
Revision:
1:cd3c7c2e2746
Parent:
0:7cb96171f886
A few updates to clean up the code before publishing.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bmazzeo 0:7cb96171f886 1 /* mbed TextDisplay Library Base Class
bmazzeo 0:7cb96171f886 2 * Copyright (c) 2007-2009 sford
bmazzeo 0:7cb96171f886 3 * Released under the MIT License: http://mbed.org/license/mit
bmazzeo 0:7cb96171f886 4 *
bmazzeo 0:7cb96171f886 5 * A common base class for Text displays
bmazzeo 0:7cb96171f886 6 * To port a new display, derive from this class and implement
bmazzeo 0:7cb96171f886 7 * the constructor (setup the display), character (put a character
bmazzeo 0:7cb96171f886 8 * at a location), rows and columns (number of rows/cols) functions.
bmazzeo 0:7cb96171f886 9 * Everything else (locate, printf, putc, cls) will come for free
bmazzeo 0:7cb96171f886 10 *
bmazzeo 0:7cb96171f886 11 * The model is the display will wrap at the right and bottom, so you can
bmazzeo 0:7cb96171f886 12 * keep writing and will always get valid characters. The location is
bmazzeo 0:7cb96171f886 13 * maintained internally to the class to make this easy
bmazzeo 0:7cb96171f886 14 */
bmazzeo 0:7cb96171f886 15
bmazzeo 0:7cb96171f886 16 #ifndef MBED_TEXTDISPLAY_H
bmazzeo 0:7cb96171f886 17 #define MBED_TEXTDISPLAY_H
bmazzeo 0:7cb96171f886 18
bmazzeo 0:7cb96171f886 19 #include "mbed.h"
bmazzeo 0:7cb96171f886 20
bmazzeo 0:7cb96171f886 21 /**
bmazzeo 0:7cb96171f886 22 * TextDisplay interface
bmazzeo 0:7cb96171f886 23 */
bmazzeo 0:7cb96171f886 24 class TextDisplay : public Stream {
bmazzeo 0:7cb96171f886 25 public:
bmazzeo 0:7cb96171f886 26
bmazzeo 0:7cb96171f886 27 /** Create a TextDisplay interface
bmazzeo 0:7cb96171f886 28 *
bmazzeo 0:7cb96171f886 29 * @param name The name used in the path to access the strean through the filesystem
bmazzeo 0:7cb96171f886 30 */
bmazzeo 0:7cb96171f886 31 TextDisplay(const char *name = NULL);
bmazzeo 0:7cb96171f886 32
bmazzeo 0:7cb96171f886 33 /** Output a character at the given position
bmazzeo 0:7cb96171f886 34 *
bmazzeo 0:7cb96171f886 35 * @param column column where charater must be written
bmazzeo 0:7cb96171f886 36 * @param row where character must be written
bmazzeo 0:7cb96171f886 37 * @param c the character to be written to the TextDisplay
bmazzeo 0:7cb96171f886 38 */
bmazzeo 0:7cb96171f886 39 virtual void character(int column, int row, int c) = 0;
bmazzeo 0:7cb96171f886 40
bmazzeo 0:7cb96171f886 41 /** Return number if rows on TextDisplay
bmazzeo 0:7cb96171f886 42 *
bmazzeo 0:7cb96171f886 43 * @result number of rows
bmazzeo 0:7cb96171f886 44 */
bmazzeo 0:7cb96171f886 45 virtual int rows() = 0;
bmazzeo 0:7cb96171f886 46
bmazzeo 0:7cb96171f886 47 /** Return number if columns on TextDisplay
bmazzeo 0:7cb96171f886 48 * @result number of rows
bmazzeo 0:7cb96171f886 49 */
bmazzeo 0:7cb96171f886 50 virtual int columns() = 0;
bmazzeo 0:7cb96171f886 51
bmazzeo 0:7cb96171f886 52 // functions that come for free, but can be overwritten
bmazzeo 0:7cb96171f886 53
bmazzeo 0:7cb96171f886 54 /** Redirect output from a stream (stoud, sterr) to display
bmazzeo 0:7cb96171f886 55 * @param stream stream that shall be redirected to the TextDisplay
bmazzeo 0:7cb96171f886 56 */
bmazzeo 0:7cb96171f886 57 virtual bool claim (FILE *stream);
bmazzeo 0:7cb96171f886 58
bmazzeo 0:7cb96171f886 59 /** Clear screen
bmazzeo 0:7cb96171f886 60 */
bmazzeo 0:7cb96171f886 61 virtual void cls();
bmazzeo 0:7cb96171f886 62 virtual void locate(int column, int row);
bmazzeo 0:7cb96171f886 63 virtual void foreground(uint16_t colour);
bmazzeo 0:7cb96171f886 64 virtual void background(uint16_t colour);
bmazzeo 0:7cb96171f886 65 // putc (from Stream)
bmazzeo 0:7cb96171f886 66 // printf (from Stream)
bmazzeo 0:7cb96171f886 67
bmazzeo 0:7cb96171f886 68 protected:
bmazzeo 0:7cb96171f886 69
bmazzeo 0:7cb96171f886 70 virtual int _putc(int value);
bmazzeo 0:7cb96171f886 71 virtual int _getc();
bmazzeo 0:7cb96171f886 72
bmazzeo 0:7cb96171f886 73 // character location
bmazzeo 0:7cb96171f886 74 uint16_t _column;
bmazzeo 0:7cb96171f886 75 uint16_t _row;
bmazzeo 0:7cb96171f886 76
bmazzeo 0:7cb96171f886 77 // colours
bmazzeo 0:7cb96171f886 78 uint16_t _foreground;
bmazzeo 0:7cb96171f886 79 uint16_t _background;
bmazzeo 0:7cb96171f886 80 char *_path;
bmazzeo 0:7cb96171f886 81 };
bmazzeo 0:7cb96171f886 82
bmazzeo 0:7cb96171f886 83 #endif