Just tweeked orientation and contrast values

Fork of NokiaLCD by Simon Ford

Committer:
Capper
Date:
Fri Oct 24 15:34:27 2014 +0000
Revision:
3:51cb48ebad3e
Parent:
2:2d1b23692cbb
Changed orientation and contrast for this project

Who changed what in which revision?

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