Live RSS News feed is displayed on a Nokia LCD. See http://mbed.org/users/4180_1/notebook/news-nokia-lcd-display/

Dependencies:   NetServices mbed spxml HTTPClient_ToBeRemoved

Committer:
4180_1
Date:
Fri May 25 01:08:51 2012 +0000
Revision:
0:91658d171678

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:91658d171678 1 /* mbed NokiaLCD Library, for a 130x130 Nokia colour LCD
4180_1 0:91658d171678 2 * Copyright (c) 2007-2010, sford
4180_1 0:91658d171678 3 *
4180_1 0:91658d171678 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
4180_1 0:91658d171678 5 * of this software and associated documentation files (the "Software"), to deal
4180_1 0:91658d171678 6 * in the Software without restriction, including without limitation the rights
4180_1 0:91658d171678 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4180_1 0:91658d171678 8 * copies of the Software, and to permit persons to whom the Software is
4180_1 0:91658d171678 9 * furnished to do so, subject to the following conditions:
4180_1 0:91658d171678 10 *
4180_1 0:91658d171678 11 * The above copyright notice and this permission notice shall be included in
4180_1 0:91658d171678 12 * all copies or substantial portions of the Software.
4180_1 0:91658d171678 13 *
4180_1 0:91658d171678 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4180_1 0:91658d171678 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4180_1 0:91658d171678 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4180_1 0:91658d171678 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4180_1 0:91658d171678 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4180_1 0:91658d171678 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4180_1 0:91658d171678 20 * THE SOFTWARE.
4180_1 0:91658d171678 21 */
4180_1 0:91658d171678 22
4180_1 0:91658d171678 23 #ifndef MBED_NOKIALCD_H
4180_1 0:91658d171678 24 #define MBED_NOKIALCD_H
4180_1 0:91658d171678 25
4180_1 0:91658d171678 26 #include "mbed.h"
4180_1 0:91658d171678 27
4180_1 0:91658d171678 28 /** An interface for the 130x130 Nokia Mobile phone screens
4180_1 0:91658d171678 29 *
4180_1 0:91658d171678 30 * @code
4180_1 0:91658d171678 31 * #include "mbed.h"
4180_1 0:91658d171678 32 * #include "NokiaLCD.h"
4180_1 0:91658d171678 33 *
4180_1 0:91658d171678 34 * NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::6610); // mosi, sclk, cs, rst, type
4180_1 0:91658d171678 35 *
4180_1 0:91658d171678 36 * int main() {
4180_1 0:91658d171678 37 * lcd.printf("Hello World!");
4180_1 0:91658d171678 38 * }
4180_1 0:91658d171678 39 * @endcode
4180_1 0:91658d171678 40 */
4180_1 0:91658d171678 41 class NokiaLCD : public Stream {
4180_1 0:91658d171678 42
4180_1 0:91658d171678 43 public:
4180_1 0:91658d171678 44 /** LCD panel format */
4180_1 0:91658d171678 45 enum LCDType {
4180_1 0:91658d171678 46 LCD6100 /**< Nokia 6100, as found on sparkfun board (default) */
4180_1 0:91658d171678 47 , LCD6610 /**< Nokia 6610, as found on olimex board */
4180_1 0:91658d171678 48 , PCF8833
4180_1 0:91658d171678 49 };
4180_1 0:91658d171678 50
4180_1 0:91658d171678 51 /** Create and Nokia LCD interface, using a SPI and two DigitalOut interfaces
4180_1 0:91658d171678 52 *
4180_1 0:91658d171678 53 * @param mosi SPI data out
4180_1 0:91658d171678 54 * @param sclk SPI clock
4180_1 0:91658d171678 55 * @param cs Chip Select (DigitalOut)
4180_1 0:91658d171678 56 * @param rst Reset (DigitalOut)
4180_1 0:91658d171678 57 * @param type The LCDType to select driver chip variants
4180_1 0:91658d171678 58 */
4180_1 0:91658d171678 59 NokiaLCD(PinName mosi, PinName sclk, PinName cs, PinName rst, LCDType type = LCD6100);
4180_1 0:91658d171678 60
4180_1 0:91658d171678 61 #if DOXYGEN_ONLY
4180_1 0:91658d171678 62 /** Write a character to the LCD
4180_1 0:91658d171678 63 *
4180_1 0:91658d171678 64 * @param c The character to write to the display
4180_1 0:91658d171678 65 */
4180_1 0:91658d171678 66 int putc(int c);
4180_1 0:91658d171678 67
4180_1 0:91658d171678 68 /** Write a formated string to the LCD
4180_1 0:91658d171678 69 *
4180_1 0:91658d171678 70 * @param format A printf-style format string, followed by the
4180_1 0:91658d171678 71 * variables to use in formating the string.
4180_1 0:91658d171678 72 */
4180_1 0:91658d171678 73 int printf(const char* format, ...);
4180_1 0:91658d171678 74 #endif
4180_1 0:91658d171678 75
4180_1 0:91658d171678 76 /** Locate to a screen column and row
4180_1 0:91658d171678 77 *
4180_1 0:91658d171678 78 * @param column The horizontal position from the left, indexed from 0
4180_1 0:91658d171678 79 * @param row The vertical position from the top, indexed from 0
4180_1 0:91658d171678 80 */
4180_1 0:91658d171678 81 void locate(int column, int row);
4180_1 0:91658d171678 82
4180_1 0:91658d171678 83 /** Clear the screen and locate to 0,0 */
4180_1 0:91658d171678 84 void cls();
4180_1 0:91658d171678 85
4180_1 0:91658d171678 86 /** Set a pixel on te screen
4180_1 0:91658d171678 87 *
4180_1 0:91658d171678 88 * @param x horizontal position from left
4180_1 0:91658d171678 89 * @param y vertical position from top
4180_1 0:91658d171678 90 * @param colour 24-bit colour in format 0x00RRGGBB
4180_1 0:91658d171678 91 */
4180_1 0:91658d171678 92 void pixel(int x, int y, int colour);
4180_1 0:91658d171678 93
4180_1 0:91658d171678 94 /** Fill an area of the screen
4180_1 0:91658d171678 95 *
4180_1 0:91658d171678 96 * @param x horizontal position from left
4180_1 0:91658d171678 97 * @param y vertical position from top
4180_1 0:91658d171678 98 * @param width width in pixels
4180_1 0:91658d171678 99 * @param height height in pixels
4180_1 0:91658d171678 100 * @param colour 24-bit colour in format 0x00RRGGBB
4180_1 0:91658d171678 101 */
4180_1 0:91658d171678 102 void fill(int x, int y, int width, int height, int colour);
4180_1 0:91658d171678 103
4180_1 0:91658d171678 104 void blit(int x, int y, int width, int height, const int* colour);
4180_1 0:91658d171678 105 void bitblit(int x, int y, int width, int height, const char* bitstream);
4180_1 0:91658d171678 106
4180_1 0:91658d171678 107 int width();
4180_1 0:91658d171678 108 int height();
4180_1 0:91658d171678 109 int columns();
4180_1 0:91658d171678 110 int rows();
4180_1 0:91658d171678 111
4180_1 0:91658d171678 112 void reset();
4180_1 0:91658d171678 113
4180_1 0:91658d171678 114 /** Set the foreground colour
4180_1 0:91658d171678 115 *
4180_1 0:91658d171678 116 * @param c 24-bit colour
4180_1 0:91658d171678 117 */
4180_1 0:91658d171678 118 void foreground(int c);
4180_1 0:91658d171678 119
4180_1 0:91658d171678 120 /** Set the background colour
4180_1 0:91658d171678 121 *
4180_1 0:91658d171678 122 * @param c 24-bit colour
4180_1 0:91658d171678 123 */
4180_1 0:91658d171678 124 void background(int c);
4180_1 0:91658d171678 125
4180_1 0:91658d171678 126 protected:
4180_1 0:91658d171678 127 virtual void _window(int x, int y, int width, int height);
4180_1 0:91658d171678 128 virtual void _putp(int colour);
4180_1 0:91658d171678 129
4180_1 0:91658d171678 130 void command(int value);
4180_1 0:91658d171678 131 void data(int value);
4180_1 0:91658d171678 132
4180_1 0:91658d171678 133 void newline();
4180_1 0:91658d171678 134 virtual int _putc(int c);
4180_1 0:91658d171678 135 virtual int _getc() {
4180_1 0:91658d171678 136 return 0;
4180_1 0:91658d171678 137 }
4180_1 0:91658d171678 138 void putp(int v);
4180_1 0:91658d171678 139 void window(int x, int y, int width, int height);
4180_1 0:91658d171678 140
4180_1 0:91658d171678 141 SPI _spi;
4180_1 0:91658d171678 142 DigitalOut _rst;
4180_1 0:91658d171678 143 DigitalOut _cs;
4180_1 0:91658d171678 144
4180_1 0:91658d171678 145 LCDType _type;
4180_1 0:91658d171678 146 int _row, _column, _rows, _columns, _foreground, _background, _width, _height;
4180_1 0:91658d171678 147 };
4180_1 0:91658d171678 148
4180_1 0:91658d171678 149 #endif
4180_1 0:91658d171678 150
4180_1 0:91658d171678 151