4Dsystems Oled library
Embed:
(wiki syntax)
Show/hide line numbers
OLED32028P1T.h
00001 // mbed library for 4DSystems uOLED-32028-P1T 00002 00003 // *****OLED_BAUDRATE must start at 9600******* 00004 00005 #define BAUDRATE 9600 // MUST use 9600 here to initialise display, can be redefined upto 256K in OLED3208P1T.cpp 00006 00007 // Screen states 00008 #define OFF 0x00 00009 #define ON 0x01 00010 00011 // Text properties 00012 #define TEXT 0x73 00013 #define FONT5X7 0x00 00014 #define FONT8X8 0x01 00015 #define FONT8X12 0x02 00016 #define FONT12X16 0x03 00017 #define TEXTFORMATED 0x54 00018 #define SET_TEXT_BACKGROUND_TYPE 0x4F 00019 #define SET_BACKGROUND_COLOR 0x42 00020 #define TEXT_TRANSPARENT 0x00 00021 #define TEXT_OPAQUE 0x01 00022 #define OLED_TEXT_BUTTON 0x62 00023 00024 // Colours 00025 #define BLACK 0x0000 00026 #define WHITE 0xFFFF 00027 #define RED 0xF800 00028 #define GREEN 0x07E0 00029 #define BLUE 0x001F 00030 #define YELLOW 0xFFE0 00031 #define CYAN 0x07FF 00032 #define MAGENTA 0xF81F 00033 #define BLUE2 0xA6BF 00034 #define GREEN2 0x2500 00035 00036 #define red_min 0//150 00037 #define red_max 255 00038 #define blue_min 0//185 00039 #define blue_max 255 00040 #define green_min 0//195 00041 #define green_max 255 00042 00043 class OLED32028P1T : public Stream { 00044 public: 00045 00046 OLED32028P1T(PinName serialTx, PinName serialRx, PinName resetPin); // Default constructor 00047 00048 // TEXT FUNCTIONS 00049 void setFontSize(int fontSize); // fontSize can be: OLED_FONT5X7, OLED_FONT8X8, or OLED_FONT8X12 00050 void setFontColor(int fontColor); // Set font color, for use with printf(); all other functions override this setting. 00051 void drawText(int column, int row, int font_size, char *mytext, int color); // Draw string text at character location column & row) 00052 void drawSingleChar(int column, int row, int theChar, int color); // Draw a single ASCII character at the specified location. 00053 void drawTextGraphic(int x, int y, int font_size, char *mytext, int color, int width, int height); // Draw string text at pixel location x & y) 00054 // GRAPHIC FUNCTIONS 00055 void drawCircle(int x, int y, int radius, int color); 00056 void drawRectangle(int x, int y, int width, int height, int color); 00057 void drawLine(int x1, int y1, int x2, int y2, int color); 00058 void drawPixel(int x, int y, int color); 00059 void drawTextButton(int up_down, int x, int y, int button_colour, int font, int string_colour, int width, int height, char *mytext); 00060 00061 // TOUCH FUNCTIONS 00062 void enableTouch(); // Enables the Touch Screen 00063 void disableTouch(); // Disables the Touch Screen 00064 void setTouchArea(int, int, int, int); // define Touch Area 0,0,219,239 for whole screen 00065 void resetTouchArea(); // Resets Touch Area to whole screen 00066 void waitTouch(int); // wait for Touch, wait time in milliseconds. Maximum value of 65,535 msec or 65.5 seconds used for delay in sd card image display. 00067 unsigned char getTouch(int *xbuffer, int *ybuffer); // get Touch co-ordiantes 00068 unsigned char getTouchRelease(int *xbuffer, int *ybuffer); // get Touch Release co-ordiantes 00069 unsigned char getTouchPress(int *xbuffer, int *ybuffer); // get Touch Press co-ordiantes 00070 00071 00072 // SD FUNCTIONS 00073 unsigned char stringSD(int, int, int, int, int, unsigned char, unsigned char, int, int, char[]); 00074 unsigned char imageSD(int , int , char[]); 00075 00076 // DISPLAY CONTROL FUNCTION 00077 void resetDisplay(); // Reset the display using the reset pin (the reset pin is active-low). 00078 void init(); // Initialise OLED display. 00079 void baudReset(); 00080 void getResponse(); // Processes responses (ACK or NAK) from the OLED. A new command cannot be sent to the OLED until a NAK is received, so 00081 // this function waits for the minimum time needed. 00082 void clear(); // Clear the OLED screen. 00083 void setPenSize(int penSize); // Set the "pen size". 00084 void setTextBackgroundType(int textBackgroundType); //textBackgroundType can be OLED_SET_TEXT_TRANSPARENT or OLED_SET_TEXT_OPAQUE 00085 void setBackgroundColor(int color); 00086 int toRGB(int red, int green, int blue);// Calculate 16-bit value from RGB (0 to 63, 565 format) 00087 void displayControl(int mode, int value); // Display control functions, such as display ON/OFF, power-up/power-down. 00088 void displayOff(); 00089 void displayOn(); 00090 void displaySleep(); 00091 char getPenSize(); // Get Pen Size 00092 int rows(); //Get number of text rows TODO: must depend on font size 00093 int columns();// Get number of text columns 00094 virtual void locate(int column, int row);// Set text cursor location 00095 int lastCount; 00096 int NAKCount; 00097 00098 protected: 00099 virtual int _putc(int value); 00100 virtual int _getc(); 00101 short _column; //Text cursor column number 00102 short _row; //Text cursor row number 00103 int _fontSize; 00104 int _penSize; 00105 int _fontColor; 00106 00107 private: 00108 Serial s; 00109 DigitalOut reset; 00110 };
Generated on Thu Jul 21 2022 17:24:33 by 1.7.2