SO1602A Lib. SO1602A is Organic LED, has 16 chars and 2 lines. This lib supports printf() of C-Language. http://akizukidenshi.com/catalog/g/gP-08276/

Dependents:   NEW_LineTraceHub NEW_LineTraceHub_2 ColorSensorTest

Files at this revision

API Documentation at this revision

Comitter:
AkinoriHashimoto
Date:
Fri Nov 06 06:23:52 2015 +0000
Parent:
3:eaaedd09fa6b
Commit message:
Adj. Constructer, Refer

Changed in this revision

SO1602A.cpp Show annotated file Show diff for this revision Revisions of this file
SO1602A.h Show annotated file Show diff for this revision Revisions of this file
diff -r eaaedd09fa6b -r e17943b827d8 SO1602A.cpp
--- a/SO1602A.cpp	Mon Oct 19 05:44:49 2015 +0000
+++ b/SO1602A.cpp	Fri Nov 06 06:23:52 2015 +0000
@@ -1,15 +1,20 @@
 #include "SO1602A.h"
 
 SO1602A::SO1602A (PinName sda, PinName scl, char address)
-    : i2c(sda, scl), addr(address)
+    : p_i2c(new I2C(sda, scl)), i2c(*p_i2c), addr(address)
 {
     init();
 }
 SO1602A::SO1602A (I2C &_i2c, char address)
-    : i2c(_i2c), addr(address)
+    : p_i2c(NULL), i2c(_i2c), addr(address)
 {
     init();
 }
+SO1602A::~SO1602A()
+{
+    if(p_i2c != NULL)
+    delete p_i2c;
+}
 
 bool SO1602A::cmd(char chr)
 {
diff -r eaaedd09fa6b -r e17943b827d8 SO1602A.h
--- a/SO1602A.h	Mon Oct 19 05:44:49 2015 +0000
+++ b/SO1602A.h	Fri Nov 06 06:23:52 2015 +0000
@@ -36,7 +36,7 @@
 public:
     SO1602A (PinName sda, PinName scl, char address= 0x78);
     SO1602A (I2C &_i2c, char address= 0x78);
-    
+    ~SO1602A();
 //  ******************** printf() future of C-language. ***************************
 
     /** Initialize
@@ -63,7 +63,8 @@
     void setDispFlag(bool disp= true, bool cursor= true, bool blink= true);
 
 private:    
-    I2C i2c;
+    I2C *p_i2c;
+    I2C &i2c;
     char addr;
     char buf[3];
     int col, row;