LS020.h is a MobileLCD library for the LS020 display (used in GSM Siemens S65 family). Resolution 176x132

Committer:
Wimpie
Date:
Wed Dec 08 19:29:42 2010 +0000
Revision:
2:d048f09dcfb0
Parent:
1:2269e07af50b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wimpie 1:2269e07af50b 1 /* mbed LS020 Library, for driving the LCD display LS020 from SHARP used in
Wimpie 1:2269e07af50b 2 * GSM S65 Siemens
Wimpie 1:2269e07af50b 3 *
Wimpie 1:2269e07af50b 4 * Copyright (c) 2010, Wim De Roeve, thanks to Christian Kranz research
Wimpie 1:2269e07af50b 5 *
Wimpie 0:d550841cd6eb 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
Wimpie 0:d550841cd6eb 7 * of this software and associated documentation files (the "Software"), to deal
Wimpie 0:d550841cd6eb 8 * in the Software without restriction, including without limitation the rights
Wimpie 0:d550841cd6eb 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Wimpie 0:d550841cd6eb 10 * copies of the Software, and to permit persons to whom the Software is
Wimpie 0:d550841cd6eb 11 * furnished to do so, subject to the following conditions:
Wimpie 0:d550841cd6eb 12 *
Wimpie 0:d550841cd6eb 13 * The above copyright notice and this permission notice shall be included in
Wimpie 0:d550841cd6eb 14 * all copies or substantial portions of the Software.
Wimpie 0:d550841cd6eb 15 *
Wimpie 0:d550841cd6eb 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Wimpie 0:d550841cd6eb 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Wimpie 0:d550841cd6eb 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Wimpie 0:d550841cd6eb 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Wimpie 0:d550841cd6eb 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Wimpie 0:d550841cd6eb 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Wimpie 0:d550841cd6eb 22 * THE SOFTWARE.
Wimpie 0:d550841cd6eb 23 */
Wimpie 0:d550841cd6eb 24
Wimpie 0:d550841cd6eb 25
Wimpie 0:d550841cd6eb 26 #ifndef MBED_LS020LCD_H
Wimpie 0:d550841cd6eb 27 #define MBED_LS020LCD_H
Wimpie 0:d550841cd6eb 28
Wimpie 0:d550841cd6eb 29 #include "mbed.h"
Wimpie 0:d550841cd6eb 30
Wimpie 0:d550841cd6eb 31 namespace mbed {
Wimpie 0:d550841cd6eb 32 /* Class: LS020LCD
Wimpie 1:2269e07af50b 33 * An abstraction of the LS020 Mobile phone screen, used in GSm Siemens S65
Wimpie 0:d550841cd6eb 34 *
Wimpie 0:d550841cd6eb 35 * Example:
Wimpie 0:d550841cd6eb 36 * >
Wimpie 0:d550841cd6eb 37 * > #include "mbed.h"
Wimpie 0:d550841cd6eb 38 * > #include "LS020LCD.h"
Wimpie 0:d550841cd6eb 39 * >
Wimpie 0:d550841cd6eb 40 * >LSO20LCD S65lcd(p5,p6,p7,p8,p9);
Wimpie 0:d550841cd6eb 41 * >
Wimpie 0:d550841cd6eb 42 * > int main() {
Wimpie 1:2269e07af50b 43 * > S65lcd.fillcircle(10,10,10,0xE0);
Wimpie 0:d550841cd6eb 44 * > }
Wimpie 0:d550841cd6eb 45 */
Wimpie 0:d550841cd6eb 46
Wimpie 0:d550841cd6eb 47 class LS020LCD {
Wimpie 0:d550841cd6eb 48 public:
Wimpie 0:d550841cd6eb 49 /* Constructor: LSO20LCD
Wimpie 0:d550841cd6eb 50 * Create and object for the LS020 LCD, using SPI and three DigitalOuts
Wimpie 0:d550841cd6eb 51 *
Wimpie 0:d550841cd6eb 52 * Variables:
Wimpie 0:d550841cd6eb 53 * mosi - SPI data out
Wimpie 0:d550841cd6eb 54 * miso - SPI data in, not used
Wimpie 0:d550841cd6eb 55 * clk - SPI clock
Wimpie 0:d550841cd6eb 56 * cs - Chip Select
Wimpie 0:d550841cd6eb 57 * rst - reset
Wimpie 0:d550841cd6eb 58 * rs - register select
Wimpie 0:d550841cd6eb 59 */
Wimpie 0:d550841cd6eb 60 LS020LCD(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName rs);
Wimpie 0:d550841cd6eb 61
Wimpie 0:d550841cd6eb 62 virtual void orientation(bool rotate, bool mirror);
Wimpie 0:d550841cd6eb 63 virtual void reset();
Wimpie 0:d550841cd6eb 64 virtual void set_8bit_mode(char BGR);
Wimpie 0:d550841cd6eb 65 virtual void set_16bit_mode(void);
Wimpie 0:d550841cd6eb 66 virtual void set_8_color_mode(void);
Wimpie 0:d550841cd6eb 67 virtual void set_65k_color_mode(void);
Wimpie 0:d550841cd6eb 68
Wimpie 0:d550841cd6eb 69 void fillrectangle(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int color);
Wimpie 0:d550841cd6eb 70 void drawpixel(unsigned int x, unsigned int y, unsigned int color);
Wimpie 0:d550841cd6eb 71 void drawline(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int color);
Wimpie 0:d550841cd6eb 72 void drawrectangle(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int color);
Wimpie 0:d550841cd6eb 73 void fillcircle(unsigned int x0, unsigned int y0, unsigned int radius, unsigned int color);
Wimpie 0:d550841cd6eb 74 void drawcircle(unsigned int x0, unsigned int y0, unsigned int radius, unsigned int color);
Wimpie 0:d550841cd6eb 75 unsigned int putc(unsigned int x, unsigned int y, unsigned int c, unsigned int size, unsigned int font, unsigned int color, unsigned int bgcolor);
Wimpie 0:d550841cd6eb 76 void drawtext(unsigned int x, unsigned int y, char* text, unsigned int size,unsigned int font, unsigned int color, unsigned int bgcolor);
Wimpie 0:d550841cd6eb 77 void scroll(char offset);
Wimpie 0:d550841cd6eb 78 void cls();
Wimpie 2:d048f09dcfb0 79 void rectangle8(char x1, char y1, char x2, char y2, char color);
Wimpie 2:d048f09dcfb0 80 void putpixel(unsigned char r,unsigned char g,unsigned char b, unsigned char x, unsigned char y);
Wimpie 2:d048f09dcfb0 81 void put_char8(char x, char y, char symbol, char color, char bkcolor);
Wimpie 2:d048f09dcfb0 82 void put_string8(char x, char y, char* text, char color, char bkcolor);
Wimpie 2:d048f09dcfb0 83 void draw_table(void);
Wimpie 2:d048f09dcfb0 84
Wimpie 0:d550841cd6eb 85 private:
Wimpie 0:d550841cd6eb 86 SPI _spi;
Wimpie 0:d550841cd6eb 87 DigitalOut _rst;
Wimpie 0:d550841cd6eb 88 DigitalOut _cs;
Wimpie 0:d550841cd6eb 89 DigitalOut _rs;
Wimpie 0:d550841cd6eb 90
Wimpie 0:d550841cd6eb 91 int _row,_column,_rows,_columns,_width, _height;
Wimpie 0:d550841cd6eb 92 bool _rotate,_mirror ;
Wimpie 0:d550841cd6eb 93 int _font,_foreground, _background;
Wimpie 0:d550841cd6eb 94
Wimpie 0:d550841cd6eb 95 void write_cmdRG(uint8_t reg, uint8_t param);
Wimpie 0:d550841cd6eb 96 void write_cmd8(uint8_t cmd8);
Wimpie 0:d550841cd6eb 97 void write_cmd16(uint16_t cmd16);
Wimpie 0:d550841cd6eb 98 void write_data8(char data);
Wimpie 0:d550841cd6eb 99 void write_data16(uint16_t cmd16);
Wimpie 0:d550841cd6eb 100 void draw(uint16_t cmd16) ;
Wimpie 0:d550841cd6eb 101 void drawstop(void);
Wimpie 0:d550841cd6eb 102 void drawstart(void);
Wimpie 0:d550841cd6eb 103
Wimpie 0:d550841cd6eb 104 void foreground(unsigned int color);
Wimpie 0:d550841cd6eb 105 void background(unsigned int color);
Wimpie 0:d550841cd6eb 106
Wimpie 0:d550841cd6eb 107 void locate(int column, int row);
Wimpie 0:d550841cd6eb 108 void newline();
Wimpie 0:d550841cd6eb 109 int columns();
Wimpie 0:d550841cd6eb 110 int rows();
Wimpie 0:d550841cd6eb 111 void set_cursor(unsigned int x, unsigned int y);
Wimpie 0:d550841cd6eb 112 void set_window(char x0, char y0, char x1,char y1);
Wimpie 0:d550841cd6eb 113
Wimpie 0:d550841cd6eb 114 };
Wimpie 0:d550841cd6eb 115 }
Wimpie 0:d550841cd6eb 116
Wimpie 0:d550841cd6eb 117 #endif