Uses Google Weather API to display current conditions for a city on a Nokia LCD. See http://mbed.org/users/4180_1/notebook/weather-nokia-lcd-display/

Dependencies:   NetServices mbed spxml HTTPClient_ToBeRemoved

Committer:
4180_1
Date:
Fri May 25 00:57:24 2012 +0000
Revision:
0:4a917644acc4

        

Who changed what in which revision?

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