uru 賣井坂 / solenoid
Revision:
0:31ce4ad8c8f6
Child:
1:a04fadd675dc
diff -r 000000000000 -r 31ce4ad8c8f6 solenoid.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/solenoid.cpp	Fri Sep 08 06:58:17 2017 +0000
@@ -0,0 +1,29 @@
+#include "solenoid.h"
+void solenoid::output()
+{
+    i2c.write(adr<<1,&PORT,1);
+}
+solenoid::solenoid(PinName sda,PinName scl,char adr_):i2c(sda,scl)
+{
+    adr=adr_;
+}
+solenoid::solenoid(I2C& I2c,char adr_):i2c(I2c)
+{
+    adr=adr_;
+}
+solenoid& solenoid::operator=(char po)
+{
+    PORT=po;
+    output();
+    return *this;
+}
+void solenoid::Port(char port,char po)
+{
+    port= 0b100000000 >> port;
+    if(po==0) {
+        port ^= 0xFF;
+        PORT = PORT & port;
+    } else
+        PORT = PORT | port;
+    output();
+}
\ No newline at end of file