uru 賣井坂 / solenoid
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers solenoid.cpp Source File

solenoid.cpp

00001 #include "solenoid.h"
00002 void solenoid::output()
00003 {
00004     i2c->write(adr<<1,&PORT,1);
00005 }
00006 solenoid::solenoid(I2C *I2c,char adr_):i2c(I2c)
00007 {
00008     adr=adr_;
00009 }
00010 solenoid& solenoid::operator=(char po)
00011 {
00012     PORT=po;
00013     output();
00014     return *this;
00015 }
00016 void solenoid::Port(char port,char po)
00017 {
00018     port= 0b100000000 >> port;
00019     if(po==0) {
00020         port ^= 0xFF;
00021         PORT = PORT & port;
00022     } else
00023         PORT = PORT | port;
00024     output();
00025 }