Example #1
0
 def _sub_regs(self, bits_count, bits_size=1, fmt=None):
     if fmt is None:
         fmt = 'e{:02}'
     return {
         fmt.format(i): registers_tree.SubReg(i * bits_size, bits_count)
         for i in range(self.elec_count)
     }
Example #2
0
 def _sub_regs(self, bits_count, bits_size=1, fmt=None):
     if fmt is None:
         fmt = 'e{}'
     return {
         fmt.format(i): registers_tree.SubReg(i * bits_size, bits_count)
         for i in self._ELECTRODES_RANGE
     }
Example #3
0
 def __init__(self, dev, elec_count=12):
     self._configured = False
     self._dev = dev
     self.elec_count = elec_count
     self.regs = registers_tree.Registers(
         'mpr121_registers',
         self._dev,
         touch_status=registers_tree.Register(
             0x00,
             16,
             0,
             eleprox=registers_tree.SubReg(12, 1),
             ovcf=registers_tree.SubReg(15, 1),
             **self._sub_regs(1)),
         oor_status=registers_tree.Register(
             0x02,
             16,
             0,
             eleprox=registers_tree.SubReg(12, 1),
             acff=registers_tree.SubReg(14, 1),
             arff=registers_tree.SubReg(15, 1),
             **self._sub_regs(1)),
         electrode_value=registers_tree.Register(
             0x04,
             208,
             0,
             eleprox=registers_tree.SubReg(192, 10),
             **self._sub_regs(10, 16)),
         baseline_value=registers_tree.Register(
             0x1E,
             104,
             0,
             eleprox=registers_tree.SubReg(96, 8),
             **self._sub_regs(8, 8)),
         baseline_filters=registers_tree.Register(
             0x2B,
             88,
             0,
             write_hook=self._reg_write_hook,
             rising_mhd=registers_tree.SubReg(0, 6),
             rising_nhd=registers_tree.SubReg(8, 6),
             rising_ncl=registers_tree.SubReg(16, 8),
             rising_fdl=registers_tree.SubReg(24, 8),
             falling_mhd=registers_tree.SubReg(32, 6),
             falling_nhd=registers_tree.SubReg(40, 6),
             falling_ncl=registers_tree.SubReg(48, 8),
             falling_fdl=registers_tree.SubReg(56, 8),
             touched_nhd=registers_tree.SubReg(64, 6),
             touched_ncl=registers_tree.SubReg(72, 8),
             touched_fdl=registers_tree.SubReg(80, 8)),
         eleprox_baseline_filters=registers_tree.Register(
             0x36,
             88,
             0,
             rising_mhd=registers_tree.SubReg(0, 6),
             rising_nhd=registers_tree.SubReg(8, 6),
             rising_ncl=registers_tree.SubReg(16, 8),
             rising_fdl=registers_tree.SubReg(24, 8),
             falling_mhd=registers_tree.SubReg(32, 6),
             falling_nhd=registers_tree.SubReg(40, 6),
             falling_ncl=registers_tree.SubReg(48, 8),
             falling_fdl=registers_tree.SubReg(56, 8),
             touched_nhd=registers_tree.SubReg(64, 6),
             touched_ncl=registers_tree.SubReg(72, 8),
             touched_fdl=registers_tree.SubReg(80, 8)),
         electrode_threshold=registers_tree.Register(
             0x41,
             208,
             0,
             write_hook=self._reg_write_hook,
             eleprox_touch=registers_tree.SubReg(192, 8),
             eleprox_release=registers_tree.SubReg(200, 8),
             **self._sub_regs(8, 16, 'e{:02}_touch'),
             **self._sub_regs(8, 16, 'e{:02}_release')),
         debounce=registers_tree.Register(0x5B,
                                          8,
                                          0,
                                          write_hook=self._reg_write_hook,
                                          touch=registers_tree.SubReg(0, 3),
                                          release=registers_tree.SubReg(
                                              4, 3)),
         afe_configuration=registers_tree.Register(
             0x5C,
             16,
             0x2410,
             write_hook=self._reg_write_hook,
             cdc=registers_tree.SubReg(0, 6),
             ffi=registers_tree.SubReg(6, 2),
             esi=registers_tree.SubReg(8, 3),
             sfi=registers_tree.SubReg(11, 2),
             cdt=registers_tree.SubReg(13, 3)),
         electrode_configuration=registers_tree.Register(
             0x5E,
             8,
             0,
             ele=registers_tree.SubReg(0, 4),
             eleprox=registers_tree.SubReg(4, 2),
             cl=registers_tree.SubReg(6, 2)),
         electrode_current=registers_tree.Register(
             0x5F,
             104,
             0,
             write_hook=self._reg_write_hook,
             eleprox=registers_tree.SubReg(96, 6),
             **self._sub_regs(6, 8)),
         gpio=registers_tree.Register(
             0x73,
             64,
             0,
             control=registers_tree.SubReg(0, 16),
             data=registers_tree.SubReg(16, 8),
             direction=registers_tree.SubReg(24, 8),
             enable=registers_tree.SubReg(32, 8),
             data_set=registers_tree.SubReg(40, 8),
             data_clear=registers_tree.SubReg(48, 8),
             data_toggle=registers_tree.SubReg(56, 8)),
         auto_configuration=registers_tree.Register(
             0x7B,
             40,
             0,
             write_hook=self._reg_write_hook,
             ace=registers_tree.SubReg(0, 1),
             are=registers_tree.SubReg(1, 1),
             bva=registers_tree.SubReg(2, 2),
             retry=registers_tree.SubReg(4, 2),
             afes=registers_tree.SubReg(6, 2),
             acfie=registers_tree.SubReg(8, 1),
             arfie=registers_tree.SubReg(9, 1),
             oorie=registers_tree.SubReg(10, 1),
             scts=registers_tree.SubReg(15, 1),
             usl=registers_tree.SubReg(16, 8),
             lsl=registers_tree.SubReg(24, 8),
             tl=registers_tree.SubReg(32, 8)))