Display text on LCD displays (even on multiple ones). Allow to create windows (frames) on display, and to combine them (split, add, duplicate, scroll). See http://mbed.org/users/hlipka/notebook/lcdwindow/ for more information.

Dependents:   Mbell

Committer:
hlipka
Date:
Sat Nov 27 22:54:13 2010 +0000
Revision:
2:5ac5bab7daaf
Parent:
1:65f72ed914fa
Child:
3:e5d5e2fe4bf6
Moved to \"Stream\"-based API (like TextLCD) which allows the usage of printf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hlipka 0:ae5037e3d6e0 1 /*
hlipka 0:ae5037e3d6e0 2 * mbed LCDWindow library
hlipka 0:ae5037e3d6e0 3 * Copyright (c) 2010 Hendrik Lipka
hlipka 2:5ac5bab7daaf 4 *
hlipka 0:ae5037e3d6e0 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
hlipka 0:ae5037e3d6e0 6 * of this software and associated documentation files (the "Software"), to deal
hlipka 0:ae5037e3d6e0 7 * in the Software without restriction, including without limitation the rights
hlipka 0:ae5037e3d6e0 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
hlipka 0:ae5037e3d6e0 9 * copies of the Software, and to permit persons to whom the Software is
hlipka 0:ae5037e3d6e0 10 * furnished to do so, subject to the following conditions:
hlipka 2:5ac5bab7daaf 11 *
hlipka 0:ae5037e3d6e0 12 * The above copyright notice and this permission notice shall be included in
hlipka 0:ae5037e3d6e0 13 * all copies or substantial portions of the Software.
hlipka 2:5ac5bab7daaf 14 *
hlipka 0:ae5037e3d6e0 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
hlipka 0:ae5037e3d6e0 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
hlipka 0:ae5037e3d6e0 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
hlipka 0:ae5037e3d6e0 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
hlipka 0:ae5037e3d6e0 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
hlipka 0:ae5037e3d6e0 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
hlipka 0:ae5037e3d6e0 21 * THE SOFTWARE.
hlipka 0:ae5037e3d6e0 22 */
hlipka 0:ae5037e3d6e0 23
hlipka 0:ae5037e3d6e0 24 #ifndef WINDOW_H_
hlipka 0:ae5037e3d6e0 25 #define WINDOW_H_
hlipka 0:ae5037e3d6e0 26
hlipka 2:5ac5bab7daaf 27 #include "Stream.h"
hlipka 2:5ac5bab7daaf 28
hlipka 2:5ac5bab7daaf 29 using namespace mbed;
hlipka 2:5ac5bab7daaf 30
hlipka 0:ae5037e3d6e0 31 /**
hlipka 0:ae5037e3d6e0 32 * the base window class, which proves the interface for all common methods.
hlipka 0:ae5037e3d6e0 33 */
hlipka 2:5ac5bab7daaf 34 class Window : public Stream {
hlipka 2:5ac5bab7daaf 35 public:
hlipka 2:5ac5bab7daaf 36 /**
hlipka 2:5ac5bab7daaf 37 * write text into the window, at the given position.
hlipka 2:5ac5bab7daaf 38 * this doesn't change the internal cursor position
hlipka 2:5ac5bab7daaf 39 * Implementations should check for the length of the text and shorten it accordingly.
hlipka 2:5ac5bab7daaf 40 * @params columns the column where to write
hlipka 2:5ac5bab7daaf 41 * @params row the line where to write
hlipka 2:5ac5bab7daaf 42 * @params text the text to write
hlipka 2:5ac5bab7daaf 43 */
hlipka 2:5ac5bab7daaf 44 virtual void writeText(const unsigned int column, const unsigned int row, const char text[])=0;
hlipka 2:5ac5bab7daaf 45 /**
hlipka 2:5ac5bab7daaf 46 * @param returns the height of the window
hlipka 2:5ac5bab7daaf 47 */
hlipka 2:5ac5bab7daaf 48 virtual int getRows()=0;
hlipka 2:5ac5bab7daaf 49 /**
hlipka 2:5ac5bab7daaf 50 * @param returns the width of the window
hlipka 2:5ac5bab7daaf 51 */
hlipka 2:5ac5bab7daaf 52 virtual int getColumns()=0;
hlipka 2:5ac5bab7daaf 53 /**
hlipka 2:5ac5bab7daaf 54 * clears the window
hlipka 2:5ac5bab7daaf 55 */
hlipka 2:5ac5bab7daaf 56 virtual void clear()=0;
hlipka 2:5ac5bab7daaf 57
hlipka 2:5ac5bab7daaf 58 /**
hlipka 2:5ac5bab7daaf 59 * set (internal) cursor to a screen column and row
hlipka 2:5ac5bab7daaf 60 *
hlipka 2:5ac5bab7daaf 61 * @param column The horizontal position from the left, indexed from 0
hlipka 2:5ac5bab7daaf 62 * @param row The vertical position from the top, indexed from 0
hlipka 2:5ac5bab7daaf 63 */
hlipka 2:5ac5bab7daaf 64 virtual void locate(int column, int row);
hlipka 2:5ac5bab7daaf 65
hlipka 2:5ac5bab7daaf 66 /**
hlipka 2:5ac5bab7daaf 67 * writes a character to the specified position
hlipka 2:5ac5bab7daaf 68 * must be public because it is used during delegation
hlipka 2:5ac5bab7daaf 69 *
hlipka 2:5ac5bab7daaf 70 * @param column The horizontal position from the left, indexed from 0
hlipka 2:5ac5bab7daaf 71 * @param row The vertical position from the top, indexed from 0
hlipka 2:5ac5bab7daaf 72 * @param c the character
hlipka 2:5ac5bab7daaf 73 */
hlipka 2:5ac5bab7daaf 74 virtual void character(int column, int row, int c)=0;
hlipka 2:5ac5bab7daaf 75
hlipka 2:5ac5bab7daaf 76 #if DOXYGEN_ONLY
hlipka 2:5ac5bab7daaf 77 /**
hlipka 2:5ac5bab7daaf 78 * Write a character to the LCD, on the position specified by the cursor
hlipka 2:5ac5bab7daaf 79 * sets the cursor to the next position, and wraps (from right to left, next line, and from bottom back to top)
hlipka 2:5ac5bab7daaf 80 *
hlipka 2:5ac5bab7daaf 81 * @param c The character to write to the display
hlipka 2:5ac5bab7daaf 82 */
hlipka 2:5ac5bab7daaf 83 int putc(int c);
hlipka 2:5ac5bab7daaf 84
hlipka 2:5ac5bab7daaf 85 /**
hlipka 2:5ac5bab7daaf 86 * Write a formated string to the LCD, on the position specified by the cursor
hlipka 2:5ac5bab7daaf 87 * does wrap around (as specified by putc)
hlipka 2:5ac5bab7daaf 88 *
hlipka 2:5ac5bab7daaf 89 * @param format A printf-style format string, followed by the
hlipka 2:5ac5bab7daaf 90 * variables to use in formating the string.
hlipka 2:5ac5bab7daaf 91 */
hlipka 2:5ac5bab7daaf 92 int printf(const char* format, ...);
hlipka 2:5ac5bab7daaf 93 #endif
hlipka 2:5ac5bab7daaf 94 protected:
hlipka 2:5ac5bab7daaf 95 // Stream implementation functions
hlipka 2:5ac5bab7daaf 96 virtual int _putc(int value);
hlipka 2:5ac5bab7daaf 97 virtual int _getc() {
hlipka 2:5ac5bab7daaf 98 return -1;
hlipka 2:5ac5bab7daaf 99 };
hlipka 2:5ac5bab7daaf 100
hlipka 2:5ac5bab7daaf 101 int _column;
hlipka 2:5ac5bab7daaf 102 int _row;
hlipka 0:ae5037e3d6e0 103 };
hlipka 0:ae5037e3d6e0 104
hlipka 0:ae5037e3d6e0 105 #endif /*WINDOW_H_*/