diff options
| author | yum <yum.food.vr@gmail.com> | 2023-09-10 18:29:59 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-09-10 18:33:08 -0700 |
| commit | 920d6dfeeac132488c85311512fe9e5da505c4a8 (patch) | |
| tree | 11b7931f4d43eba6e502636f03790b5d3c267093 | |
| parent | 4f3b9382068a29731de664eb0810f9eb3a267905 (diff) | |
Fix paging bugv0.15.1
OSC was paging using incorrect board resolution. Use cfg to provide this
data.
| -rw-r--r-- | Scripts/osc_ctrl.py | 17 | ||||
| -rw-r--r-- | Scripts/transcribe_v2.py | 4 |
2 files changed, 12 insertions, 9 deletions
diff --git a/Scripts/osc_ctrl.py b/Scripts/osc_ctrl.py index 5e6f2ff..8e5f1e4 100644 --- a/Scripts/osc_ctrl.py +++ b/Scripts/osc_ctrl.py @@ -94,7 +94,7 @@ def updateRegion(client, region_idx, letter_encoded): # Sends one slice of `msg` to the board then returns. Slices are sent # in FIFO order; e.g., the most recently spoken words are sent last. # Returns True if done paging, False otherwise. -def pageMessage(osc_state: OscState, msg: str, estate: EmotesState) -> bool: +def pageMessage(cfg, osc_state: OscState, msg: str, estate: EmotesState) -> bool: msg = estate.encode_emotes(msg) msg_slice, slice_idx = osc_state.pager.getNextSlice(msg) @@ -120,17 +120,20 @@ def pageMessage(osc_state: OscState, msg: str, estate: EmotesState) -> bool: # len(msg_slice))) # Really long messages just wrap back around. - which_region = (slice_idx % generate_utils.config.numRegions(0)) # if in last region: # how long is it - num_cells = generate_utils.config.BOARD_ROWS * generate_utils.config.BOARD_COLS - num_regions = ceil(num_cells / generate_utils.config.CHARS_PER_SYNC) + num_cells = cfg["rows"] * cfg["cols"] + num_regions = ceil(num_cells / cfg["chars_per_sync"]) + which_region = slice_idx % num_regions + #print(f"which_region: {which_region}") + #print(f"num_regions: {num_regions}") #print("num regions: {}".format(num_regions)) if which_region == num_regions - 1: - layers_in_last_region = num_cells % generate_utils.config.CHARS_PER_SYNC + layers_in_last_region = num_cells % cfg["chars_per_sync"] + #print(f"layers in last region: {layers_in_last_region}") if layers_in_last_region == 0: - layers_in_last_region = generate_utils.config.CHARS_PER_SYNC + layers_in_last_region = cfg["chars_per_sync"] #print("layers in last region: {}".format(layers_in_last_region)) old_len = len(msg_slice) msg_slice = msg_slice[0:layers_in_last_region] @@ -156,7 +159,7 @@ def pageMessage(osc_state: OscState, msg: str, estate: EmotesState) -> bool: # Like `pageMessage` but uses the built-in chatbox. The built-in chatbox # truncates data at about 150 chars, so just send the suffix of the message for # now. -def pageMessageBuiltin(osc_state: OscState, msg: str) -> bool: +def pageMessageBuiltin(cfg, osc_state: OscState, msg: str) -> bool: if len(msg) == 0 or msg.isspace(): return False # Not paging diff --git a/Scripts/transcribe_v2.py b/Scripts/transcribe_v2.py index 2639697..87b88af 100644 --- a/Scripts/transcribe_v2.py +++ b/Scripts/transcribe_v2.py @@ -709,10 +709,10 @@ class OscPager: def page(self, text): if self.cfg["use_builtin"]: - osc_ctrl.pageMessageBuiltin(self.osc_state, text) + osc_ctrl.pageMessageBuiltin(self.cfg, self.osc_state, text) self.bumpSyncWindow(amount_s=1.5) else: - osc_ctrl.pageMessage(self.osc_state, text, EmotesState()) + osc_ctrl.pageMessage(self.cfg, self.osc_state, text, EmotesState()) self.bumpSyncWindow() def bumpSyncWindow(self, amount_s=osc_ctrl.SYNC_DELAY_S): |
