From 0769b77e94b1069d07e6c2691e60348135ff5e97 Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 7 Nov 2022 17:39:19 -0800 Subject: Fix osc_ctrl diffing Now we actually maintain an ongoing buffer with what we think is on the display. When we send a new cell, we update only that cell instead of overwriting the entire prefix up to that cell. --- osc_ctrl.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'osc_ctrl.py') diff --git a/osc_ctrl.py b/osc_ctrl.py index 5ab65de..8cd5571 100644 --- a/osc_ctrl.py +++ b/osc_ctrl.py @@ -235,27 +235,26 @@ def sendMessageLazy(client, msg, tx_state): # Skip cells we've already sent. This makes the board much more # responsive. - if cell_end < len(tx_state.last_msg_encoded): + if cell_end <= len(tx_state.last_msg_encoded): last_cell_msg = tx_state.last_msg_encoded[cell_begin:cell_end] if cell_msg == last_cell_msg: continue if cell_msg == [state.encoding[' ']] * NUM_LAYERS: if empty_cells_sent >= tx_state.empty_cells_to_send_per_call: - #print("empty cell budget exceeded") - tx_state.last_msg_encoded = msg_encoded[0:cell_end] return False empty_cells_sent += 1 else: if nonempty_cells_sent >= tx_state.nonempty_cells_to_send_per_call: - #print("nonempty cell budget exceeded") - tx_state.last_msg_encoded = msg_encoded[0:cell_end] return False nonempty_cells_sent += 1 sendMessageCellDiscrete(client, cell_msg, cell) + # Pad last msg encoded to the end of the array + tx_state.last_msg_encoded += [state.encoding[" "]] * (cell_end - + len(tx_state.last_msg_encoded)) + tx_state.last_msg_encoded[cell_begin:cell_end] = cell_msg - tx_state.last_msg_encoded = msg_encoded #resizeBoard(len(lines), tx_state, shrink_only=True) return True -- cgit v1.2.3