TextLCD compatible wrapper for NOKIA_5110 library

Dependencies:   NOKIA_5110

Fork of TextLCD by Simon Ford

Committer:
davervw
Date:
Sat Jan 18 20:19:20 2014 +0000
Revision:
9:8a3f38cbadd5
Parent:
TextLCD.h@8:308d188a2d3a
TextLCD compatible wrapper for NOKIA_5110 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davervw 9:8a3f38cbadd5 1 /* mbed TextLCD5110 Library, for Nokia 5110 LCDs
davervw 9:8a3f38cbadd5 2 * Original Copyright (c) 2007-2010, sford, http://mbed.org
davervw 9:8a3f38cbadd5 3 * Revisions Copyright (c) 2014, David R. Van Wagner, https://mbed.org/users/davervw/
simon 1:ac48b187213c 4 *
simon 1:ac48b187213c 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 1:ac48b187213c 6 * of this software and associated documentation files (the "Software"), to deal
simon 1:ac48b187213c 7 * in the Software without restriction, including without limitation the rights
simon 1:ac48b187213c 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 1:ac48b187213c 9 * copies of the Software, and to permit persons to whom the Software is
simon 1:ac48b187213c 10 * furnished to do so, subject to the following conditions:
simon 2:227356c7d12c 11 *
simon 1:ac48b187213c 12 * The above copyright notice and this permission notice shall be included in
simon 1:ac48b187213c 13 * all copies or substantial portions of the Software.
simon 2:227356c7d12c 14 *
simon 1:ac48b187213c 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 1:ac48b187213c 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 1:ac48b187213c 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 1:ac48b187213c 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 1:ac48b187213c 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 1:ac48b187213c 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 1:ac48b187213c 21 * THE SOFTWARE.
simon 1:ac48b187213c 22 */
simon 1:ac48b187213c 23
simon 1:ac48b187213c 24 #ifndef MBED_TEXTLCD_H
simon 1:ac48b187213c 25 #define MBED_TEXTLCD_H
simon 1:ac48b187213c 26
simon 1:ac48b187213c 27 #include "mbed.h"
davervw 9:8a3f38cbadd5 28 #include "NOKIA_5110.h"
simon 2:227356c7d12c 29
davervw 9:8a3f38cbadd5 30 /** A TextLCD compatible interface for driving Nokia 5110 LCDs
simon 2:227356c7d12c 31 *
simon 2:227356c7d12c 32 * @code
simon 2:227356c7d12c 33 * #include "mbed.h"
davervw 9:8a3f38cbadd5 34 * #include "TextLCD5110.h"
simon 5:a53b3e2d6f1e 35 *
davervw 9:8a3f38cbadd5 36 * TextLCD5110 lcd(p5, p7, p24, p25, p26);
simon 5:a53b3e2d6f1e 37 *
simon 2:227356c7d12c 38 * int main() {
simon 2:227356c7d12c 39 * lcd.printf("Hello World!\n");
simon 2:227356c7d12c 40 * }
simon 2:227356c7d12c 41 * @endcode
simon 2:227356c7d12c 42 */
davervw 9:8a3f38cbadd5 43 class TextLCD5110 : public Stream {
simon 1:ac48b187213c 44 public:
simon 1:ac48b187213c 45
davervw 9:8a3f38cbadd5 46 /** Create a TextLCD5110 interface
simon 2:227356c7d12c 47 *
davervw 9:8a3f38cbadd5 48 * @param mosi serial in line (din)
davervw 9:8a3f38cbadd5 49 * @param sclk serial clock line (sclk)
davervw 9:8a3f38cbadd5 50 * @param dc data/command select line
davervw 9:8a3f38cbadd5 51 * @param cse Enable line (chip select)
davervw 9:8a3f38cbadd5 52 * @param reset Reset line
simon 2:227356c7d12c 53 */
davervw 9:8a3f38cbadd5 54 TextLCD5110(PinName mosi, PinName sclk, PinName dc, PinName cse, PinName reset);
simon 2:227356c7d12c 55
simon 2:227356c7d12c 56 #if DOXYGEN_ONLY
simon 2:227356c7d12c 57 /** Write a character to the LCD
simon 2:227356c7d12c 58 *
simon 2:227356c7d12c 59 * @param c The character to write to the display
simon 2:227356c7d12c 60 */
simon 2:227356c7d12c 61 int putc(int c);
simon 2:227356c7d12c 62
simon 2:227356c7d12c 63 /** Write a formated string to the LCD
simon 2:227356c7d12c 64 *
simon 2:227356c7d12c 65 * @param format A printf-style format string, followed by the
simon 2:227356c7d12c 66 * variables to use in formating the string.
simon 2:227356c7d12c 67 */
simon 2:227356c7d12c 68 int printf(const char* format, ...);
simon 2:227356c7d12c 69 #endif
simon 2:227356c7d12c 70
simon 2:227356c7d12c 71 /** Locate to a screen column and row
simon 2:227356c7d12c 72 *
simon 2:227356c7d12c 73 * @param column The horizontal position from the left, indexed from 0
simon 2:227356c7d12c 74 * @param row The vertical position from the top, indexed from 0
simon 2:227356c7d12c 75 */
simon 1:ac48b187213c 76 void locate(int column, int row);
simon 2:227356c7d12c 77
simon 2:227356c7d12c 78 /** Clear the screen and locate to 0,0 */
simon 1:ac48b187213c 79 void cls();
simon 2:227356c7d12c 80
simon 1:ac48b187213c 81 int rows();
simon 2:227356c7d12c 82 int columns();
simon 2:227356c7d12c 83
davervw 9:8a3f38cbadd5 84 int get_row();
davervw 9:8a3f38cbadd5 85 int get_column();
davervw 9:8a3f38cbadd5 86
simon 1:ac48b187213c 87 protected:
simon 1:ac48b187213c 88
simon 1:ac48b187213c 89 // Stream implementation functions
simon 1:ac48b187213c 90 virtual int _putc(int value);
simon 1:ac48b187213c 91 virtual int _getc();
simon 1:ac48b187213c 92
simon 1:ac48b187213c 93 int _column;
simon 1:ac48b187213c 94 int _row;
davervw 9:8a3f38cbadd5 95
davervw 9:8a3f38cbadd5 96 NokiaLcd *pLcd;
davervw 9:8a3f38cbadd5 97
davervw 9:8a3f38cbadd5 98 void character(int column, int row, int c);
davervw 9:8a3f38cbadd5 99
simon 1:ac48b187213c 100 };
simon 1:ac48b187213c 101
simon 1:ac48b187213c 102 #endif