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

Committer:
Wimpie
Date:
Mon Dec 06 20:37:10 2010 +0000
Revision:
1:2269e07af50b
Parent:
0:d550841cd6eb
Child:
2:d048f09dcfb0

        

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 0:d550841cd6eb 79
Wimpie 0:d550841cd6eb 80 private:
Wimpie 0:d550841cd6eb 81 SPI _spi;
Wimpie 0:d550841cd6eb 82 DigitalOut _rst;
Wimpie 0:d550841cd6eb 83 DigitalOut _cs;
Wimpie 0:d550841cd6eb 84 DigitalOut _rs;
Wimpie 0:d550841cd6eb 85
Wimpie 0:d550841cd6eb 86 int _row,_column,_rows,_columns,_width, _height;
Wimpie 0:d550841cd6eb 87 bool _rotate,_mirror ;
Wimpie 0:d550841cd6eb 88 int _font,_foreground, _background;
Wimpie 0:d550841cd6eb 89
Wimpie 0:d550841cd6eb 90 void write_cmdRG(uint8_t reg, uint8_t param);
Wimpie 0:d550841cd6eb 91 void write_cmd8(uint8_t cmd8);
Wimpie 0:d550841cd6eb 92 void write_cmd16(uint16_t cmd16);
Wimpie 0:d550841cd6eb 93 void write_data8(char data);
Wimpie 0:d550841cd6eb 94 void write_data16(uint16_t cmd16);
Wimpie 0:d550841cd6eb 95 void draw(uint16_t cmd16) ;
Wimpie 0:d550841cd6eb 96 void drawstop(void);
Wimpie 0:d550841cd6eb 97 void drawstart(void);
Wimpie 0:d550841cd6eb 98
Wimpie 0:d550841cd6eb 99 void foreground(unsigned int color);
Wimpie 0:d550841cd6eb 100 void background(unsigned int color);
Wimpie 0:d550841cd6eb 101
Wimpie 0:d550841cd6eb 102 void locate(int column, int row);
Wimpie 0:d550841cd6eb 103 void newline();
Wimpie 0:d550841cd6eb 104 int columns();
Wimpie 0:d550841cd6eb 105 int rows();
Wimpie 0:d550841cd6eb 106 void set_cursor(unsigned int x, unsigned int y);
Wimpie 0:d550841cd6eb 107 void set_window(char x0, char y0, char x1,char y1);
Wimpie 0:d550841cd6eb 108
Wimpie 0:d550841cd6eb 109 };
Wimpie 0:d550841cd6eb 110 }
Wimpie 0:d550841cd6eb 111
Wimpie 0:d550841cd6eb 112 #endif