Dependencies:   mbed

Committer:
simonb
Date:
Tue Jan 12 11:12:13 2010 +0000
Revision:
0:a136481b0662

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simonb 0:a136481b0662 1 /* mbed Library - OLEDSeps525f
simonb 0:a136481b0662 2 * Copyright (c) 2010, sblandford
simonb 0:a136481b0662 3 * Based on MobileLCD library
simonb 0:a136481b0662 4 * Copyright (c) 2007/8, sford
simonb 0:a136481b0662 5 * released under MIT license http://mbed.org/licence/mit
simonb 0:a136481b0662 6 */
simonb 0:a136481b0662 7
simonb 0:a136481b0662 8 #ifndef MBED_OLEDSEPS525F_H
simonb 0:a136481b0662 9 #define MBED_OLEDSEPS525F_H
simonb 0:a136481b0662 10
simonb 0:a136481b0662 11 #include "mbed.h"
simonb 0:a136481b0662 12
simonb 0:a136481b0662 13 namespace mbed {
simonb 0:a136481b0662 14
simonb 0:a136481b0662 15 /* Class: OLEDSeps525f
simonb 0:a136481b0662 16 * An abstraction of an 160x128 OLED driven by the SEPS525F
simonb 0:a136481b0662 17 * such as the Densitron DD-160128FC-1A
simonb 0:a136481b0662 18 *
simonb 0:a136481b0662 19 * Example:
simonb 0:a136481b0662 20 * > // Print messages when the AnalogIn is greater than 50%
simonb 0:a136481b0662 21 * >
simonb 0:a136481b0662 22 * > #include "mbed.h"
simonb 0:a136481b0662 23 * > #include "OLEDSeps525f.h"
simonb 0:a136481b0662 24 * >
simonb 0:a136481b0662 25 * > OLEDSeps525f lcd(p5,p6,p7,p8,p9,p10);
simonb 0:a136481b0662 26 * >
simonb 0:a136481b0662 27 * > int main() {
simonb 0:a136481b0662 28 * > lcd.printf("Hello World!");
simonb 0:a136481b0662 29 * > }
simonb 0:a136481b0662 30 */
simonb 0:a136481b0662 31
simonb 0:a136481b0662 32 class OLEDSeps525f : public Stream {
simonb 0:a136481b0662 33
simonb 0:a136481b0662 34 public:
simonb 0:a136481b0662 35 /* Constructor: OLEDSeps525f
simonb 0:a136481b0662 36 * Create and object for the Seps525f OLED, using SPI and three DigitalOuts
simonb 0:a136481b0662 37 *
simonb 0:a136481b0662 38 * Variables:
simonb 0:a136481b0662 39 * mosi - SPI data out
simonb 0:a136481b0662 40 * miso - SPI data in, not used
simonb 0:a136481b0662 41 * clk - SPI clock
simonb 0:a136481b0662 42 * cs - Chip Select
simonb 0:a136481b0662 43 * rst - reset
simonb 0:a136481b0662 44 * rs - command/data select
simonb 0:a136481b0662 45 */
simonb 0:a136481b0662 46
simonb 0:a136481b0662 47 OLEDSeps525f(PinName mosi, PinName miso, PinName clk, PinName cs, PinName rst, PinName rs);
simonb 0:a136481b0662 48
simonb 0:a136481b0662 49 virtual void reset();
simonb 0:a136481b0662 50 virtual void _window(int x, int y, int width, int height);
simonb 0:a136481b0662 51 virtual void _putp(int colour);
simonb 0:a136481b0662 52
simonb 0:a136481b0662 53 void command(int value);
simonb 0:a136481b0662 54 void data(int value);
simonb 0:a136481b0662 55 void rgbdot(int r, int g, int b);
simonb 0:a136481b0662 56 void pixel(int value);
simonb 0:a136481b0662 57 /* Functions foreground and background
simonb 0:a136481b0662 58 * v - A three-byte RGB code to set the foreground
simonb 0:a136481b0662 59 * or background colour
simonb 0:a136481b0662 60 */
simonb 0:a136481b0662 61 void foreground(int v);
simonb 0:a136481b0662 62 void background(int v);
simonb 0:a136481b0662 63 /* Funtion: orientation
simonb 0:a136481b0662 64 * set the display orientation in
simonb 0:a136481b0662 65 * 90 degree steps.
simonb 0:a136481b0662 66 * o - An integer from 0-3 setting the orientation
simonb 0:a136481b0662 67 */
simonb 0:a136481b0662 68 void orientation(int o);
simonb 0:a136481b0662 69 /* Function: tablength
simonb 0:a136481b0662 70 * Set the tab length
simonb 0:a136481b0662 71 * l - An integer representing the number of columns
simonb 0:a136481b0662 72 */
simonb 0:a136481b0662 73 void tablength(int l);
simonb 0:a136481b0662 74 /* Function: locate
simonb 0:a136481b0662 75 * Set the text cursor to location x,y
simonb 0:a136481b0662 76 *
simonb 0:a136481b0662 77 * Variables:
simonb 0:a136481b0662 78 * x - An integer setting the column position
simonb 0:a136481b0662 79 * y - An integer setting the row position
simonb 0:a136481b0662 80 */
simonb 0:a136481b0662 81 void locate(int column, int row);
simonb 0:a136481b0662 82 /* Function: newline
simonb 0:a136481b0662 83 * Set the text cursor to the start of the next line
simonb 0:a136481b0662 84 */
simonb 0:a136481b0662 85 void newline();
simonb 0:a136481b0662 86 virtual int _putc(int c);
simonb 0:a136481b0662 87 virtual int _getc() { return 0; }
simonb 0:a136481b0662 88 SPI _spi;
simonb 0:a136481b0662 89 DigitalOut _rst;
simonb 0:a136481b0662 90 DigitalOut _cs;
simonb 0:a136481b0662 91 DigitalOut _rs;
simonb 0:a136481b0662 92 void bitblit(int x, int y, int width, int height, const char* bitstream);
simonb 0:a136481b0662 93 void fill(int x, int y, int width, int height, int colour);
simonb 0:a136481b0662 94 void blit(int x, int y, int width, int height, const int* colour);
simonb 0:a136481b0662 95 /* Function: cls
simonb 0:a136481b0662 96 * Clear the screen
simonb 0:a136481b0662 97 */
simonb 0:a136481b0662 98 void cls();
simonb 0:a136481b0662 99 /* Functions returning the current max width, max height, max columns, max rows, orientation
simonb 0:a136481b0662 100 * and tablength as an integer
simonb 0:a136481b0662 101 */
simonb 0:a136481b0662 102 int width();
simonb 0:a136481b0662 103 int height();
simonb 0:a136481b0662 104 int columns();
simonb 0:a136481b0662 105 int rows();
simonb 0:a136481b0662 106 int orientation();
simonb 0:a136481b0662 107 int tablength();
simonb 0:a136481b0662 108 /* Functions returning the current foreground or background colour as a three-byte RGB code */
simonb 0:a136481b0662 109 int foreground();
simonb 0:a136481b0662 110 int background();
simonb 0:a136481b0662 111 void putp(int v);
simonb 0:a136481b0662 112 void window(int x, int y, int width, int height);
simonb 0:a136481b0662 113 void pixel(int x, int y, int colour);
simonb 0:a136481b0662 114 enum {_physical_width=160};
simonb 0:a136481b0662 115 enum {_physical_height=128};
simonb 0:a136481b0662 116 int _row, _column, _rows, _columns, _tablength, _foreground, _background, _width, _height, _rotation, _writing_pixels;
simonb 0:a136481b0662 117 };
simonb 0:a136481b0662 118
simonb 0:a136481b0662 119 }
simonb 0:a136481b0662 120
simonb 0:a136481b0662 121 #endif