NokiaLCDに美咲フォントを組み込んで日本語出力ができるようにしたものです。 NOKIA330用の設定と\"\\n\"による改行も追加されています。

Committer:
nucho
Date:
Tue Oct 19 23:49:09 2010 +0000
Revision:
0:839ab88da656

        

Who changed what in which revision?

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