Wim De Roeve / LS020
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LS020LCD.h Source File

LS020LCD.h

00001 /* mbed LS020 Library, for driving the LCD display LS020 from SHARP used in
00002  * GSM S65 Siemens
00003  *
00004  * Copyright (c) 2010, Wim De Roeve, thanks to Christian Kranz research
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a copy
00007  * of this software and associated documentation files (the "Software"), to deal
00008  * in the Software without restriction, including without limitation the rights
00009  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010  * copies of the Software, and to permit persons to whom the Software is
00011  * furnished to do so, subject to the following conditions:
00012  *
00013  * The above copyright notice and this permission notice shall be included in
00014  * all copies or substantial portions of the Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022  * THE SOFTWARE.
00023  */
00024 
00025 
00026 #ifndef MBED_LS020LCD_H
00027 #define MBED_LS020LCD_H
00028 
00029 #include "mbed.h"
00030 
00031 namespace mbed {
00032 /* Class: LS020LCD
00033      *  An abstraction of the LS020 Mobile phone screen, used in GSm Siemens S65
00034      *
00035      * Example:
00036      * >
00037      * > #include "mbed.h"
00038      * > #include "LS020LCD.h"
00039      * >
00040      * >LSO20LCD S65lcd(p5,p6,p7,p8,p9);
00041      * >
00042      * > int main() {
00043      * >     S65lcd.fillcircle(10,10,10,0xE0);
00044      * > }
00045 */
00046 
00047 class LS020LCD {
00048 public:
00049     /* Constructor: LSO20LCD
00050            *  Create and object for the LS020 LCD, using SPI and three DigitalOuts
00051            *
00052            * Variables:
00053            *  mosi - SPI data out
00054            *  miso - SPI data in, not used
00055            *  clk  - SPI clock
00056            *  cs   - Chip Select
00057            *  rst  - reset
00058            *  rs   - register select
00059     */
00060     LS020LCD(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName rs);
00061 
00062     virtual void orientation(bool rotate, bool mirror);
00063     virtual void reset();
00064     virtual void set_8bit_mode(char BGR);
00065     virtual void set_16bit_mode(void);
00066     virtual void set_8_color_mode(void);
00067     virtual void set_65k_color_mode(void);
00068 
00069     void fillrectangle(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int color);
00070     void drawpixel(unsigned int x, unsigned int y, unsigned int color);
00071     void drawline(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int color);
00072     void drawrectangle(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int color);
00073     void fillcircle(unsigned int x0, unsigned int y0, unsigned int radius, unsigned int color);
00074     void drawcircle(unsigned int x0, unsigned int y0, unsigned int radius, unsigned int color);
00075     unsigned int putc(unsigned int x, unsigned int y, unsigned int c, unsigned int size, unsigned int font, unsigned int color, unsigned int bgcolor);
00076     void drawtext(unsigned int x, unsigned int y, char* text, unsigned int size,unsigned int font, unsigned int color, unsigned int bgcolor);
00077     void scroll(char offset);
00078     void cls();
00079     void rectangle8(char x1, char y1, char x2, char y2, char color);
00080     void putpixel(unsigned char r,unsigned char g,unsigned char b, unsigned char x, unsigned char y);
00081     void put_char8(char x, char y, char symbol, char color, char bkcolor);
00082     void put_string8(char x, char y, char* text, char color, char bkcolor);
00083     void draw_table(void);
00084     
00085 private:
00086     SPI _spi;
00087     DigitalOut _rst;
00088     DigitalOut _cs;
00089     DigitalOut _rs;
00090 
00091     int _row,_column,_rows,_columns,_width, _height;
00092     bool _rotate,_mirror ;
00093     int _font,_foreground, _background;
00094 
00095     void write_cmdRG(uint8_t reg, uint8_t param);
00096     void write_cmd8(uint8_t cmd8);
00097     void write_cmd16(uint16_t cmd16);
00098     void write_data8(char data);
00099     void write_data16(uint16_t cmd16);
00100     void draw(uint16_t cmd16) ;
00101     void drawstop(void);
00102     void drawstart(void);
00103 
00104     void foreground(unsigned int color);
00105     void background(unsigned int color);
00106 
00107     void locate(int column, int row);
00108     void newline();
00109     int columns();
00110     int rows();
00111     void set_cursor(unsigned int x, unsigned int y);
00112     void set_window(char x0, char y0, char x1,char y1);
00113 
00114 };
00115 }
00116 
00117 #endif