Fork of LCD-Window which works with Enhanced TextLCD from Wim

Fork of LcdWindow by Hendrik Lipka

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers window.h Source File

window.h

00001 /*
00002  * mbed LCDWindow library
00003 * Copyright (c) 2010 Hendrik Lipka
00004 *
00005 * Permission is hereby granted, free of charge, to any person obtaining a copy
00006 * of this software and associated documentation files (the "Software"), to deal
00007 * in the Software without restriction, including without limitation the rights
00008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 * copies of the Software, and to permit persons to whom the Software is
00010 * furnished to do so, subject to the following conditions:
00011 *
00012 * The above copyright notice and this permission notice shall be included in
00013 * all copies or substantial portions of the Software.
00014 *
00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00021 * THE SOFTWARE.
00022 */
00023 
00024 #ifndef WINDOW_H_
00025 #define WINDOW_H_
00026 
00027 #include "Stream.h"
00028 #include "semaphore.h"
00029 
00030 using namespace mbed;
00031 
00032 /**
00033  * the base window class, which proves the interface for all common methods.
00034 */
00035 class Window : public Stream {
00036 public:
00037     /**
00038      * write text into the window, at the given position.
00039      * this doesn't change the internal cursor position
00040      * Implementations should check for the length of the text and shorten it accordingly.
00041      * @params columns the column where to write
00042      * @params row the line where to write
00043      * @params text the text to write
00044     */
00045     virtual void writeText(const unsigned int column, const unsigned int row, const char text[])=0;
00046     /**
00047      * @param returns the height of the window
00048     */
00049     virtual int getRows()=0;
00050     /**
00051      * @param returns the width of the window
00052     */
00053     virtual int getColumns()=0;
00054     /**
00055      * clears the window
00056     */
00057     virtual void clear()=0;
00058 
00059     /**
00060     * set (internal) cursor to a screen column and row
00061     *
00062     * @param column  The horizontal position from the left, indexed from 0
00063     * @param row     The vertical position from the top, indexed from 0
00064     */
00065     virtual void locate(int column, int row);
00066 
00067     /**
00068      * writes a character to the specified position
00069      * must be public because it is used during delegation
00070      *
00071      * @param column  The horizontal position from the left, indexed from 0
00072      * @param row     The vertical position from the top, indexed from 0
00073      * @param c the character
00074     */
00075     virtual void character(int column, int row, int c)=0;
00076 
00077 #if DOXYGEN_ONLY
00078     /**
00079      * Write a character to the LCD, on the position specified by the cursor
00080      * sets the cursor to the next position, and wraps (from right to left, next line, and from bottom back to top)
00081      *
00082      * @param c The character to write to the display
00083      */
00084     int putc(int c);
00085 
00086     /**
00087      * Write a formated string to the LCD, on the position specified by the cursor
00088      * does wrap around (as specified by putc)
00089      *
00090      * @param format A printf-style format string, followed by the
00091      *               variables to use in formating the string.
00092      */
00093     int printf(const char* format, ...);
00094 #endif
00095 protected:
00096     /**
00097      * base constructor
00098      * initializes the _guard semaphore needed for syncing parallel writes
00099     */
00100     Window();
00101 
00102     // Stream implementation functions
00103     virtual int _putc(int value);
00104     virtual int _getc() {
00105         return -1;
00106     };
00107 
00108     int _column;
00109     int _row;
00110 
00111     Semaphore *_guard;
00112 };
00113 
00114 #endif /*WINDOW_H_*/