Packed 12bit Raw image file load to display to Nokia LCD. Add function "blit12" to Nokia LCD for native 12bit color buffer.

Dependencies:   mbed

Committer:
sakai
Date:
Thu Feb 10 14:44:49 2011 +0000
Revision:
4:f746ea56e891
Parent:
2:7cf441bf092d

        

Who changed what in which revision?

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