Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SO1602A by
SO1602A.h
00001 /** SO1602A is Organic-LED, and has 16 chars/line and 2 lines. 00002 * 00003 * This librarry supports "printf()" C format. 00004 * 00005 * 00006 * @code 00007 * #include "mbed.h" 00008 * #include "SO1602A.h" 00009 * I2C i2c(p28, p27); 00010 * SO1602A oled(i2c); 00011 * DigitalOut led[]= {LED1, LED2, LED3, LED4}; 00012 * int main() 00013 * { 00014 * oled.init(); 00015 * int iter= 0; 00016 * while(true) { 00017 * led[0] = !led[0]; 00018 * oled.printf("iter: %5.5d.", iter); 00019 * wait(1.0f); 00020 * if(iter%10 == 0) // 10s 00021 * oled.clear(); 00022 * iter++; 00023 * } 00024 * } 00025 * @endcode 00026 */ 00027 00028 #pragma once 00029 00030 #include "mbed.h" 00031 00032 // SA0(Pin4); Low: i2c_addr= 0x78, High: 0x7a; 00033 // DDRAM addr. Line1: 0x00 ~ 0x0f. Line2: 0x20 ~ 0x2f. 00034 00035 class SO1602A : public Stream{ 00036 public: 00037 SO1602A (PinName sda, PinName scl, char address= 0x78); 00038 SO1602A (I2C &_i2c, char address= 0x78); 00039 ~SO1602A(); 00040 // ******************** printf() future of C-language. *************************** 00041 00042 /** Initialize 00043 */ 00044 void init(); 00045 00046 /** Clear Display. 00047 */ 00048 void clear(); 00049 00050 /** Set Position of char. 00051 * @param col: column, row: rows. 00052 */ 00053 void locate(int col, int row); 00054 00055 /** Set Contrast. 00056 * @param val; 256steps, 0x00 ~ 0xff. Contrast increas as the value. 00057 */ 00058 void setContrast(char val); 00059 00060 /** Set Display flag. 00061 * @parm Enable Display, Cursor turned on, Cursor Blink. 00062 */ 00063 void setDispFlag(bool disp= true, bool cursor= true, bool blink= true); 00064 00065 private: 00066 I2C *p_i2c; 00067 I2C &i2c; 00068 char addr; 00069 char buf[3]; 00070 int col, row; 00071 00072 bool cmd(char chr); 00073 00074 // virtual func for printf() in Stream-class. 00075 virtual int _putc(int val); 00076 virtual int _getc(); 00077 00078 // Function SET 00079 void setRE(); 00080 void clearRE(); 00081 void setSD(); 00082 void clearSD(); 00083 00084 }; 00085 00086 // EOF
Generated on Wed Jul 20 2022 05:57:42 by
1.7.2
