for rex

Dependencies:   FatFileSystem mbed

Fork of SnakeGame by Pujun Bhatnagar

Committer:
superlova
Date:
Sat Aug 08 09:32:56 2015 +0000
Revision:
1:4222a8f9ca88
Parent:
0:8b08136c5edd
for rexry

Who changed what in which revision?

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