def orient_threshold(self, threshold): err = berry_api.set_device_multi_values(self.addr, self.REG_ORIENT_THRESHOLD_L, pack("<h", threshold), 2) if err != 0: berry_api.eprint("Error %d in set_orient_threshold for %s" % (err, self.to_string()))
def turn_off(self): err = berry_api.set_device_multi_values(self.addr, self.REG_NOTE, [0], 1) if err != 0: berry_api.eprint("Error %d in turn_off. %s" % (err, self.to_string())) self._note = "OFF"
def set_threshold(self, threshold): err = berry_api.set_device_multi_values(self.addr, self.REG_INTR_THRESHOLD, [threshold], 1) if err != 0: berry_api.eprint("Error %d in set_threshold for %s" % (err, self.to_string()))
def set_color(self, vals): err = berry_api.set_device_multi_values(self.addr, self.REG_RED, vals, 3) if err != 0: berry_api.eprint("Error ", err, "in write_rgb_colors, rgb = ") self.print_info() self._color = [None, None, None] else: self._color = deepcopy(vals)
def set_value(self, value): if value < 0xC0: err = berry_api.set_device_multi_values(self.addr, self.REG_NOTE, [value], 1) if err != 0: berry_api.eprint("Error %d in turn_off. %s" % (err, self.to_string())) else: berry_api.eprint("Error in set_value: invalid value of 0x%x. %s" % (value, self.to_string()))
def set_intensity(self, intensity): if intensity < 0 or intensity > 100: berry_api.eprint("Error, intensity out of range for berr %s" % self.to_string()) else: intensity = round(intensity * 2.55) err = berry_api.set_device_multi_values(self.addr, self.REG_INTENSITY, [intensity], 1) if err != 0: berry_api.eprint("Error %d in set_intensity. %s" % (err, self.to_string()))
def set_position(self, position): if position < 0 or position > 255: berry_api.eprint( "Error in set_position; invalid position of %d. %s" % (position, self.to_string())) return err = berry_api.set_device_multi_values(self.addr, self.REG_POSITION, [position], 1) if err != 0: berry_api.eprint("Error %d in set_position. %s" % (err, self.to_string())) return self._position = position
def play_note(self, note): if not note in self.notes: berry_api.eprint("Error in set_note: note", note, "is not a valid note. %s" % self.to_string()) else: value = self.notes[note] err = berry_api.set_device_multi_values(self.addr, self.REG_NOTE, [value], 1) if err != 0: berry_api.eprint("Error %d in set_note for %s" % (err, self.to_string())) self._note = None else: self._note = note
def set_interrupt_delay(self, delay): err = berry_api.set_device_multi_values(self.addr, self.REG_INTR_DELAY, [delay], 1) if err != 0: berry_api.eprint("Error %d in set_interrupt_delay for %s" % (err, self.to_string()))
def stop(self): err = berry_api.set_device_multi_values(self.addr, self.REG_ON_OFF, [0], 1) if err != 0: berry_api.eprint("Error %d in stop. %s" % (err, self.to_string()))
def int_cooldown(self, div): err = berry_api.set_device_multi_values(self.addr, self.INT_COOLDOWN, [div], 1) if err != 0: berry_api.eprint("Error %d in set_int_cooldown for %s" % (err, self.to_string()))
def orient_div(self, div): err = berry_api.set_device_multi_values(self.addr, self.REG_ORIENT_DIV, [div], 1) if err != 0: berry_api.eprint("Error %d in set_orient_div for %s" % (err, self.to_string()))