def retrieveSettings(): settings = {} for key in mapping: settings[key] = retrieveSetting(key) GPIOq.pinMode(key,Mode.IN) # Default to IN mode, to avoid short-circuit. return settings
def _setValue(self,wId,value): set(wId,Setting.VALUE,value) mode = self._getMode(wId) if ( mode == Mode.IN ): sys.exit("Can not set value for a pin in IN mode !") elif (mode == Mode.OUT): GPIOq.digitalWrite( wId, 1 if value > 0 else 0 ) elif (mode == Mode.PWM): GPIOq.softPWMWrite(wId,value) else: sys.exit("Unknown mode !")
def _setMode(self,wId,mode): set(wId,Setting.MODE,mode) GPIOq.pinMode(wId,1 if mode > 1 else mode) if ( mode == Mode.PWM ): GPIOq.softPWMCreate(wId) set(wId,Setting.VALUE,GPIOq.digitalRead(wId))