diff options
| author | yum <yum.food.vr@gmail.com> | 2022-11-07 17:39:19 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2022-11-07 17:39:19 -0800 |
| commit | 0769b77e94b1069d07e6c2691e60348135ff5e97 (patch) | |
| tree | 4c75b4882df35d3e012fc1eb45c276c516c8f666 /osc_ctrl.py | |
| parent | 629c0f611de1622131bb0fa364c170219f6252ed (diff) | |
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.
Diffstat (limited to 'osc_ctrl.py')
| -rw-r--r-- | osc_ctrl.py | 11 |
1 files changed, 5 insertions, 6 deletions
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 |
