def setDigitalMap(index=0, direction="out"): helper.ShellCommand("echo '{}' > {}/unexport".format(index, GPIO_SYSFS), exit=False) helper.ShellCommand("echo '{}' > {}/export".format(index, GPIO_SYSFS), exit=False) helper.ShellCommand(command="echo '{}' > {}/gpio{}/direction".format( direction, GPIO_SYSFS, index), exit=False)
def set_configure(self, index=0, direction="out", drive="strong"): ## Direction self.index = index helper.ShellCommand("echo '{}' > {}/export".format( self.index, GPIO_SYSFS), exit=False) helper.ShellCommand(command="echo '{}' > {}/gpio{}/direction".format( direction, GPIO_SYSFS, index), exit=False)
def set_value(self, value): logging.info("Set Value (Index : {}, Value {}".format( self.index, value)) logging.info("echo '{}' > {}{}/value".format(value, GPIO_SYSFS, self.index)) helper.ShellCommand(command="echo '{}' > {}{}/value".format( value, GPIO_SYSFS, self.index), exit=True) result = self.cursor.execute( "UPDATE pinmap SET V={} WHERE phy={}".format(value, self.index), "") self.mydb.commit()
def get_value(self): result = helper.ShellCommand(command="cat {}{}/value".format( GPIO_SYSFS, self.index), exit=True) logging.info("cat {}{}/value".format(GPIO_SYSFS, self.index)) return result
def read(index=0): result = helper.ShellCommand(command="cat {}gpio{}/value".format( GPIO_SYSFS, index), exit=True) return result["out"].decode("utf-8")
def write(index=0, value=True): logging.info("Set Value (Index : {}, Value {}".format(index, value)) logging.info("echo '{}' > {}gpio{}/value".format(value, GPIO_SYSFS, index)) helper.ShellCommand(command="echo '{}' > {}gpio{}/value".format( value, GPIO_SYSFS, index), exit=True)