示例#1
0
    def read_dsp_data(self):
        if self.volume_register is None:
            self.dspdata = None
            self.dspvol = None
            return False

        dspdata = self.spi.read(self.volume_register,
                                self.volume_register_length)

        if dspdata != self.dspdata:

            # Convert to percent and round to full percent
            vol = round(amplification2percent(self.dsp.decimal_val(dspdata)))

            if vol < 0:
                vol = 0
            elif vol > 100:
                vol = 100

            logging.debug("DSP volume changed from {}% to {}%".format(
                self.dspvol, vol))
            self.dspvol = vol

            self.dspdata = dspdata
            return True
        else:
            return False
示例#2
0
 def cmd_get_limit(self):
     vol = self.dsptk.get_limit()
     if vol is not None:
         print("Limit: {:.4f} / {:.0f}% / {:.0f}db".format(
             vol, amplification2percent(vol), amplification2decibel(vol)))
     else:
         print("Profile doesn't support volume limit")
         sys.exit(1)