From c3164f21a9edbb3f35073a0c6c0003f0293b5528 Mon Sep 17 00:00:00 2001 From: 4r3 <4r3gn4ult@gmail.com> Date: Tue, 4 Feb 2025 20:43:41 +0100 Subject: [PATCH 1/2] add Pin2DMD HD support --- mpf/config_spec.yaml | 2 +- mpf/platforms/pin2dmd.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mpf/config_spec.yaml b/mpf/config_spec.yaml index 88af5b26b..a48790efc 100644 --- a/mpf/config_spec.yaml +++ b/mpf/config_spec.yaml @@ -1249,7 +1249,7 @@ pin2dmd: debug: single|bool|false console_log: single|enum(none,basic,full)|none file_log: single|enum(none,basic,full)|basic - resolution: single|enum(128x32,192x64)|128x32 + resolution: single|enum(128x32,192x64,256x64)|128x32 panel: single|enum(rgb,rbg)|rgb pkone: __valid_in__: machine diff --git a/mpf/platforms/pin2dmd.py b/mpf/platforms/pin2dmd.py index 0bfeada10..a481b40d4 100644 --- a/mpf/platforms/pin2dmd.py +++ b/mpf/platforms/pin2dmd.py @@ -110,8 +110,10 @@ def _send_brightness(self, brightness): def _send_frame(self, buffer): if self.resolution == "128x32": elements = 2048 - else: + elif self.resolution == "192x64": elements = 6144 + else: + elements = 8192 output_buffer = [0] * (elements * 6 + 4) @@ -164,6 +166,21 @@ def _send_frame(self, buffer): pixel_bl >>= 1 target_idx += elements + if self.resolution == "256x64": + dest_idx = 4 + tmp_idx = 4 + temp_buffer = output_buffer.copy() + + for _ in range(0, elements * 3): + temp_buffer[dest_idx] = output_buffer[tmp_idx + 128] + temp_buffer[dest_idx + 1] = output_buffer[tmp_idx] << 1 + dest_idx += 2 + tmp_idx += 1 + if (dest_idx - 4) % 256 == 0: + tmp_idx += 128 + + output_buffer = temp_buffer + if self.debug: self.log.debug("Writing 0x01, %s, 1000", "".join(" 0x%02x" % b for b in output_buffer)) From 23d695ae1be01a232bf7647bb601e6bb251fda29 Mon Sep 17 00:00:00 2001 From: 4r3 <4r3gn4ult@gmail.com> Date: Thu, 6 Feb 2025 20:34:18 +0100 Subject: [PATCH 2/2] fix lint issues --- mpf/platforms/pin2dmd.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mpf/platforms/pin2dmd.py b/mpf/platforms/pin2dmd.py index a481b40d4..c4eb83d5f 100644 --- a/mpf/platforms/pin2dmd.py +++ b/mpf/platforms/pin2dmd.py @@ -167,17 +167,17 @@ def _send_frame(self, buffer): target_idx += elements if self.resolution == "256x64": - dest_idx = 4 - tmp_idx = 4 + target_idx = 4 + idx = 4 temp_buffer = output_buffer.copy() for _ in range(0, elements * 3): - temp_buffer[dest_idx] = output_buffer[tmp_idx + 128] - temp_buffer[dest_idx + 1] = output_buffer[tmp_idx] << 1 - dest_idx += 2 - tmp_idx += 1 - if (dest_idx - 4) % 256 == 0: - tmp_idx += 128 + temp_buffer[target_idx] = output_buffer[idx + 128] + temp_buffer[target_idx + 1] = output_buffer[idx] << 1 + target_idx += 2 + idx += 1 + if (target_idx - 4) % 256 == 0: + idx += 128 output_buffer = temp_buffer