diff --git a/main.cpp b/main.cpp index 1cf4de3..530388e 100644 --- a/main.cpp +++ b/main.cpp @@ -763,10 +763,10 @@ Config parse_args(int argc, char** argv) { } if (cfg.do1_toggle_per_frame) { if (!cfg.recv_block_specified) { - cfg.recv_block_words = 1024U; + cfg.recv_block_words = 256U; } if (!cfg.input_step_specified) { - cfg.input_step_words = 1024U; + cfg.input_step_words = 256U; } if (!cfg.input_buffer_specified) { cfg.input_buffer_words = std::max(cfg.input_buffer_words, 256U * 1024U); @@ -1786,6 +1786,10 @@ int run(const Config& cfg) { } if (cfg.do1_toggle_per_frame) { do1_next_state_high = false; + append_dout_word(do1_next_state_high); + do1_last_queued_high = do1_next_state_high; + do1_next_state_high = !do1_next_state_high; + flush_dout_queue(0U, false); } packet_active = true; }; @@ -1909,6 +1913,12 @@ int run(const Config& cfg) { std::cout << "\n"; } + if (cfg.do1_toggle_per_frame && do1_last_queued_high) { + append_dout_word(false); + do1_last_queued_high = false; + do1_next_state_high = false; + flush_dout_queue(0U, false); + } packet_active = false; packet_avg_steps = 0; fast_packet_frames = 0; @@ -1943,7 +1953,7 @@ int run(const Config& cfg) { uint32_t recv_request_words = cfg.recv_block_words; uint32_t recv_timeout_ms = cfg.recv_timeout_ms; if (cfg.do1_toggle_per_frame) { - recv_timeout_ms = std::min(recv_timeout_ms, 1U); + recv_timeout_ms = 0U; } uint32_t ready_words = 0; const int32_t ready_err = api.GetRecvReadyCount(device.hnd, &ready_words); @@ -2176,9 +2186,11 @@ int run(const Config& cfg) { append_dout_word(do1_next_state_high); do1_last_queued_high = do1_next_state_high; do1_next_state_high = !do1_next_state_high; + flush_dout_queue(0U, false); } else if (do1_last_queued_high) { append_dout_word(false); do1_last_queued_high = false; + flush_dout_queue(0U, false); } } @@ -2252,9 +2264,7 @@ int run(const Config& cfg) { } } - const uint32_t dout_send_timeout_ms = - cfg.do1_toggle_per_frame ? std::min(cfg.recv_timeout_ms, 1U) : 0U; - flush_dout_queue(dout_send_timeout_ms, false); + flush_dout_queue(0U, false); flush_tty_frames(); if (console_stop_requested()) {