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.
Dependents: NEW_LineTraceHub NEW_LineTraceHub_2 ColorSensorTest
Revision 4:e17943b827d8, committed 2015-11-06
- 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 |
--- 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)
{
--- 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;