Pedro Serra / NokiaLCD_X3
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MobileLCD.h Source File

MobileLCD.h

00001 /* mbed Library - Nokia LCD Labelled "X3"
00002 * This is using the Philips PCF8833 controller
00003  * Copyright (c) 2009 P.R.Green
00004  */
00005 
00006 #ifndef MBED_MOBILELCD_H
00007 #define MBED_MOBILELCD_H
00008 
00009 //Colours in RGB 5:6:5 16bit mode
00010 #define BLACK 0x0000
00011 #define RED 0xF800
00012 #define GREEN 0x07E0 
00013 #define BLUE 0x001F
00014 #define WHITE 0xFFFF
00015 #include "mbed.h"
00016 
00017 
00018 namespace mbed {
00019 
00020 /* Class: MobileLCD
00021  *  An abstraction of the 130x130 Nokia Mobile labelled "X3" phone screen
00022  *
00023  * Example:
00024  * >
00025  * > #include "mbed.h"
00026  * > #include "MobileLCD.h"
00027  * >
00028  * > MobileLCD lcd(p5,p6,p7,p8,p9);
00029  * > 
00030  * > int main() {
00031  * >     lcd.printf("Hello World!");
00032  * > }
00033  */
00034 
00035 class MobileLCD : public Stream {
00036 
00037 public:
00038     /* Constructor: MobileLCD
00039      *  Create and object for the Mobile LCD, using SPI and two DigitalOuts
00040      *
00041      * Variables:
00042      *  mosi - SPI data out
00043      *  miso - SPI data in, not used
00044      *  clk  - SPI clock
00045      *  cs   - Chip Select
00046      *  rst  - reset
00047      */
00048 
00049     MobileLCD(PinName mosi, PinName miso, PinName clk, PinName cs, PinName rst);
00050 
00051     virtual void reset();
00052     virtual void _select();
00053     virtual void _deselect();
00054     virtual void _window(int x, int y, int width, int height);
00055     virtual void _putp(int colour);
00056     //virtual void orientation();
00057 
00058      void command(int value);
00059      void data(int value);
00060      void foreground(int v);
00061      void background(int v);
00062      /* Function: locate
00063       *  Set the text cursor to location x,y
00064       *
00065       * Variables:
00066       *  x - An integer setting the column position
00067       *  y - An integer setting the row position
00068       */
00069      void locate(int column, int row);
00070      /* Function: newline
00071       *  Set the text cursor to the start of the next line
00072       */
00073      void newline();
00074      virtual int _putc(int c);
00075      virtual int _getc() { return 0; }
00076     SPI _spi;
00077     DigitalOut _rst;
00078     DigitalOut _cs;    
00079     void bitblit(int x, int y, int width, int height, const char* bitstream);
00080     void fill(int x, int y, int width, int height, int colour);
00081     void blit(int x, int y, int width, int height, const int* colour);
00082     /* Function: cls
00083      *  Clear the screen
00084      */
00085     void cls();
00086     int width();
00087     int height();
00088     int columns();
00089     int rows();
00090     void putp(int v);
00091     void window(int x, int y, int width, int height);
00092     void pixel(int x, int y, int colour);
00093     int _row, _column, _rows, _columns, _foreground, _background, _width, _height;
00094 };
00095 
00096 }
00097 
00098 #endif
00099     
00100