# HG changeset patch # User Michael Pavone # Date 1672688176 28800 # Node ID e27ab5f4bfe32c5095dc59c4b85152602339aedd # Parent bf1bb893f1047c64ae2a569ea4faa96c529b2df3 Fix off by one in oscilloscope rendering diff -r bf1bb893f104 -r e27ab5f4bfe3 oscilloscope.c --- a/oscilloscope.c Thu Dec 29 22:44:35 2022 -0800 +++ b/oscilloscope.c Mon Jan 02 11:36:16 2023 -0800 @@ -84,8 +84,8 @@ //TODO: at least linear filtering int16_t sample = scope->channels[i].samples[(int)(cur_sample + 0.5f)]; int y = (float)sample * value_scale + 0.5f; - if (y > row_height / 2) { - y = row_height / 2; + if (y > row_height / 2 - 1) { + y = row_height / 2 - 1; } else if (y < -(row_height / 2)) { y = -(row_height / 2); } @@ -106,15 +106,15 @@ cur_sample -= scope->channels[i].period; } } - + offset += column_width; if (offset >= width) { offset = 0; cur_line += pitch * row_height; } } - - + + render_framebuffer_updated(scope->window, WIDTH); }