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