def read(self): """Get the output brightness of the LED. Returns: int """ return int(utils.readstr_all(_LED_FILE(self._name, 'brightness')))
def max_brightness(self): """Maximum brightness value supportd by the LED. Returns: int """ return int(utils.readstr_all(_LED_FILE(self._name, 'max_brightness')))
def name(self): """Linux name of the ADC device. :type: str """ return utils.readstr_all( os.path.join(_DEVICE_PATH(self._device), 'name'))
def enabled(self): """Enabled property of the PWM. :type: bool """ return bool(int(utils.readstr_all(os.path.join(_CHANNEL_PATH(self._chip, self._channel), 'enable'))))
def period(self): """Microsecond period of the PWM. :type: int """ period_ns = int(utils.readstr_all(os.path.join(_CHANNEL_PATH(self._chip, self._channel), 'period'))) return int(period_ns / 1000)
def sampling_frequency(self): """Get the sampling frequency of the ADC. :type: int """ return int( utils.readstr_all( os.path.join(_DEVICE_PATH(self._device), 'sampling_frequency')))
def num_channels(chip): """Get the number of available PWM channels on the specified chip. Args: chip (int): The PWM chip id. Returns: int """ return int(utils.readstr_all(os.path.join(_CHIP_PATH(chip), "npwm")))
def duty_cycle(self): """Duty cycle of the PWM. :type: float """ duty_cycle_ns = int(utils.readstr_all(os.path.join(_CHANNEL_PATH(self._chip, self._channel), 'duty_cycle'))) if self.period > 0: return float(duty_cycle_ns / 1000.0 / float(self.period)) else: return 0.0
def polarity(self): """Polarity setting of the PWM. Basically, this sets the "active high" or "active low" setting of the PWM. :type: PWM.NORMAL, PWM.INVERSED Note: This a readonly property because we set polarity in creation and there seems to be little value in changing it later. """ return utils.readstr_all( os.path.join(_CHANNEL_PATH(self._chip, self._channel), "polarity"))
def scale(self): """Get the ADC value scale. The value you have to multiply the ADC value by to get microvolts. :type: float, None """ if not os.path.isfile( os.path.join(_DEVICE_PATH(self._device), 'in_voltage_scale')): return None return float( utils.readstr_all( os.path.join(_DEVICE_PATH(self._device), 'in_voltage_scale')))
def available_triggers(self): """List of available trigger names for the device. One of the names returned here can then be used when calling ``start_capture()`` to specify the trigger. :type: list: A list of trigger names available. """ names = [] triggers = [f for f in os.listdir(_ADC_ROOT) if \ os.path.isdir(os.path.join(_ADC_ROOT, f)) and 'trigger' in f] for trigger in triggers: names.append( utils.readstr_all(os.path.join(_ADC_ROOT, trigger, 'name'))) return sorted(names)
def value(self, channel): """ Perform a software trigger and get the raw ADC value. Calling this function causes a software trigger of the ADC. The ADC will do a conversion and then return the value. Args: channel (int): The ADC channel. Returns: int """ if not isinstance(channel, (int)): raise TypeError("channel must be an int.") return int( utils.readstr_all( os.path.join(_VOLTAGE_RAW_PATH(self._device, channel))))