This Program is for MAPLE board with OLED and GPS/RTC module. OLED module(OB) : 128 x 128 pixels, 4K color GPS/RTC module(GB) : UP501 These module can buy Marutyu (http://www.marutsu.co.jp)

Dependencies:   mbed

Committer:
y_notsu
Date:
Sun Jun 05 15:10:48 2011 +0000
Revision:
0:58e40a872950

        

Who changed what in which revision?

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