Added circle and line support
Embed:
(wiki syntax)
Show/hide line numbers
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 , PCF8833 00048 }; 00049 00050 /** Create and Nokia LCD interface, using a SPI and two DigitalOut interfaces 00051 * 00052 * @param mosi SPI data out 00053 * @param sclk SPI clock 00054 * @param cs Chip Select (DigitalOut) 00055 * @param rst Reset (DigitalOut) 00056 * @param type The LCDType to select driver chip variants 00057 */ 00058 NokiaLCD(PinName mosi, PinName sclk, PinName cs, PinName rst, LCDType type = LCD6100); 00059 00060 #if DOXYGEN_ONLY 00061 /** Write a character to the LCD 00062 * 00063 * @param c The character to write to the display 00064 */ 00065 int putc(int c); 00066 00067 /** Write a formated string to the LCD 00068 * 00069 * @param format A printf-style format string, followed by the 00070 * variables to use in formating the string. 00071 */ 00072 int printf(const char* format, ...); 00073 #endif 00074 00075 /** Locate to a screen column and row 00076 * 00077 * @param column The horizontal position from the left, indexed from 0 00078 * @param row The vertical position from the top, indexed from 0 00079 */ 00080 void locate(int column, int row); 00081 00082 /** Clear the screen and locate to 0,0 */ 00083 void cls(); 00084 00085 void pixel(int x, int y, int colour); 00086 void fill(int x, int y, int width, int height, int colour); 00087 void circle(int x0, int y0, int r, int colour); // Added this to create circles easy. 00088 void line(int x0, int y0, int x1, int y1, int colour); // Added this to create lines easy. 00089 00090 void blit(int x, int y, int width, int height, const int* colour); 00091 void bitblit(int x, int y, int width, int height, const char* bitstream); 00092 00093 int width(); 00094 int height(); 00095 int columns(); 00096 int rows(); 00097 00098 void reset(); 00099 00100 void foreground(int c); 00101 void background(int c); 00102 00103 00104 protected: 00105 virtual void _window(int x, int y, int width, int height); 00106 virtual void _putp(int colour); 00107 00108 void command(int value); 00109 void data(int value); 00110 00111 void newline(); 00112 virtual int _putc(int c); 00113 virtual int _getc() { 00114 return 0; 00115 } 00116 void putp(int v); 00117 void window(int x, int y, int width, int height); 00118 00119 SPI _spi; 00120 DigitalOut _rst; 00121 DigitalOut _cs; 00122 00123 LCDType _type; 00124 int _row, _column, _rows, _columns, _foreground, _background, _width, _height; 00125 }; 00126 00127 #endif 00128 00129
Generated on Mon Jul 18 2022 21:36:28 by 1.7.2