test

Dependencies:   FatFileSystem TextLCD mbed

Committer:
y_notsu
Date:
Tue Sep 18 07:24:22 2012 +0000
Revision:
0:2c37ad282618
test

Who changed what in which revision?

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