Skip to content

Commit

Permalink
hardware scan for P-Roc and P3-Roc
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed Jan 28, 2018
1 parent 2a58e98 commit c546b5f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions mpf/platforms/p3_roc.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ def _configure_accelerometer(self):
# flush data to proc
self.proc.flush()

def get_info_string(self):
"""Dump infos about boards."""
infos = "Firmware Version: {} Firmware Revision: {} Hardware Board ID: {}".format(
self.version, self.revision, self.hardware_version)

input_boards = set()
for switch, state in enumerate(self.proc.switch_get_states()):
if state != 3:
input_boards.add(switch // 16)

infos += "SW-16 boards found:\n"
for input_board in input_boards:
infos += " - Board: {} Switches: 16".format(input_board)

return infos

def configure_driver(self, config: DriverConfig, number: str, platform_settings: dict):
"""Create a P3-ROC driver.
Expand Down
6 changes: 6 additions & 0 deletions mpf/platforms/p_roc.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def __repr__(self):
"""Return string representation."""
return '<Platform.P-ROC>'

def get_info_string(self):
"""Dump infos about boards."""
infos = "Firmware Version: {} Firmware Revision: {} Hardware Board ID: {}".format(
self.version, self.revision, self.hardware_version)
return infos

def configure_driver(self, config: DriverConfig, number: str, platform_settings: dict):
"""Create a P-ROC driver.
Expand Down
8 changes: 7 additions & 1 deletion mpf/platforms/p_roc_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(self, machine):
self.hw_switch_rules = {}
self.version = None
self.revision = None
self.hardware_version = None

self.machine_type = pinproc.normalize_machine_type(
self.machine.config['hardware']['driverboards'])
Expand Down Expand Up @@ -108,7 +109,12 @@ def connect(self):

self.revision = version_revision & 0xFFFF
self.version = (version_revision & 0xFFFF0000) >> 16
self.log.info("Successfully connected to P-ROC/P3-ROC. Revision: %s. Version: %s", self.revision, self.version)
dipswitches = self.proc.read_data(0x00, 0x03)
self.hardware_version = (dipswitches & 0xF00) >> 8

self.log.info("Successfully connected to P-ROC/P3-ROC. Firmware Version: %s. Firmware Revision: %s. "
"Hardware Board ID: %s",
self.version, self.revision, self.hardware_version)

@classmethod
def _get_event_type(cls, sw_activity, debounced):
Expand Down

0 comments on commit c546b5f

Please sign in to comment.