This program is an addition of NOKIA3300 to NokiaLCD.

Dependencies:   mbed

Committer:
nucho
Date:
Fri Jul 09 16:21:55 2010 +0000
Revision:
0:c80720cda480

        

Who changed what in which revision?

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