Geolocation demo using Nokia LCD. See http://mbed.org/users/4180_1/notebook/geolocation-nokia-lcd-display/

Dependencies:   NetServices mbed HTTPClient_ToBeRemoved

Committer:
4180_1
Date:
Fri May 25 00:24:31 2012 +0000
Revision:
0:019b7bf35f8c

        

Who changed what in which revision?

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