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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NokiaLCD.h Source File

NokiaLCD.h

00001 /* mbed NokiaLCD Library, for a 130x130 Nokia colour LCD
00002  * Copyright (c) 2007-2010, sford
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to deal
00006  * in the Software without restriction, including without limitation the rights
00007  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008  * copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00017  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00019  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00020  * THE SOFTWARE.
00021  */
00022 
00023 #ifndef MBED_NOKIALCD_H
00024 #define MBED_NOKIALCD_H
00025 
00026 #include "mbed.h"
00027 
00028 /** An interface for the 130x130 Nokia Mobile phone screens
00029  *
00030  * @code
00031  * #include "mbed.h"
00032  * #include "NokiaLCD.h"
00033  *
00034  * NokiaLCD lcd(p5, p7, p8, p9); // mosi, sclk, cs, rst
00035  *
00036  * int main() {
00037  *     lcd.printf("Hello World!");
00038  * }
00039  */
00040 class NokiaLCD : public Stream {
00041 
00042 public:
00043     /** LCD panel format */
00044     enum LCDType {
00045         LCD6100     /**< Nokia 6100, as found on sparkfun board (default) */
00046         , LCD6610   /**< Nokia 6610, as found on olimex board */
00047         , LCD3300   /**< Nokia 3300, as found on aitendo */
00048         , PCF8833
00049     };
00050 
00051     /** Create and Nokia LCD interface, using a SPI and two DigitalOut interfaces
00052      *
00053      * @param mosi SPI data out
00054      * @param sclk SPI clock
00055      * @param cs Chip Select (DigitalOut)
00056      * @param rst Reset (DigitalOut)
00057      * @param type The LCDType to select driver chip variants
00058      */
00059     NokiaLCD(PinName mosi, PinName sclk, PinName cs, PinName rst, LCDType type = LCD3300);
00060 
00061 #if DOXYGEN_ONLY
00062     /** Write a character to the LCD
00063      *
00064      * @param c The character to write to the display
00065      */
00066     int putc(int c);
00067 
00068     /** Write a formated string to the LCD
00069      *
00070      * @param format A printf-style format string, followed by the
00071      *               variables to use in formating the string.
00072      */
00073     int printf(const char* format, ...);
00074 #endif
00075 
00076     /** Locate to a screen column and row
00077      *
00078      * @param column  The horizontal position from the left, indexed from 0
00079      * @param row     The vertical position from the top, indexed from 0
00080      */
00081     void locate(int column, int row);
00082 
00083     /** Clear the screen and locate to 0,0 */
00084     void cls();
00085 
00086     void pixel(int x, int y, int colour);
00087     void fill(int x, int y, int width, int height, int colour);
00088 
00089     void blit(int x, int y, int width, int height, const int* colour);
00090     void bitblit(int x, int y, int width, int height, const char* bitstream);
00091 
00092     int width();
00093     int height();
00094     int columns();
00095     int rows();
00096 
00097     void reset();
00098 
00099     void foreground(int c);
00100     void background(int c);
00101 
00102 protected:
00103     virtual void _window(int x, int y, int width, int height);
00104     virtual void _putp(int colour);
00105 
00106     void command(int value);
00107     void data(int value);
00108 
00109     void newline();
00110     virtual int _putc(int c);
00111     virtual int _getc() {
00112         return 0;
00113     }
00114     void putp(int v);
00115     void window(int x, int y, int width, int height);
00116 
00117     SPI _spi;
00118     DigitalOut _rst;
00119     DigitalOut _cs;
00120 
00121     LCDType _type;
00122     int _row, _column, _rows, _columns, _foreground, _background, _width, _height;
00123     
00124     unsigned int findface(unsigned short c);
00125 };
00126 
00127 #endif
00128 
00129