code: def _get_adc_value(self, channel, average=None):
          '''Read ADC
          '''
          conf = self.SCAN_OFF | self.SINGLE_ENDED | ((0x1e) & (channel << 1))
          self._intf.write(self._base_addr + self.MAX_1239_ADD, array('B', pack('B', conf)))
  
          def read_data():
              ret = self._intf.read(self._base_addr + self.MAX_1239_ADD | 1, size=2)
              ret.reverse()
              ret[1] = ret[1] & 0x0f  # 12-bit ADC
              return unpack_from('H', ret)[0]
  
          if average:
              raw = 0
              for _ in range(average):
                  raw += read_data()
              raw /= average
          else:
              raw = read_data()
  
          return raf _get_adc_value(self, channel, average=None):
          '''Read ADC
          '''
          conf = self.SCAN_OFF | self.SINGLE_ENDED | ((0x1e) & (channel << 1))
          self._intf.write(self._base_addr + self.MAX_1239_ADD, array('B', pack('B', conf)))
  
          def read_data():
              ret = self._intf.read(self._base_addr + self.MAX_1239_ADD | 1, size=2)
              ret.reverse()
              ret[1] = ret[1] & 0x0f  # 12-bit ADC
              return unpack_from('H', ret)[0]
  
          if average:
              raw = 0
              for _ in range(average):
                  raw += read_data()
              raw /= average
          else:
              raw = read_data()
  
          return raw
docs: Read ADC