エレキジャックweb mbed入門 Nokia LCD3300@aitendo テストプログラム

Dependencies:   mbed

Committer:
takeuchi
Date:
Sun Oct 03 10:21:07 2010 +0000
Revision:
0:327cf35353c3

        

Who changed what in which revision?

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