1.1 --- a/lib/display.c Wed Nov 07 00:12:44 2018 +0100
1.2 +++ b/lib/display.c Thu Nov 08 18:32:07 2018 +0100
1.3 @@ -121,8 +121,24 @@
1.4
1.5 int get_position(display_config_t *cfg, int x)
1.6 {
1.7 - int cell = x / cfg->cell_size, offset = x % cfg->cell_size;
1.8 - int pos = (cell / 2) * cfg->cell_size + offset;
1.9 + int cell, offset, pos;
1.10 +
1.11 + if (cfg->line_channels < 2)
1.12 + return x;
1.13 +
1.14 + /* Determine which cell is providing the position and the offset of the
1.15 + pixel within the cell. */
1.16 +
1.17 + cell = x / cfg->cell_size;
1.18 + offset = x % cfg->cell_size;
1.19 +
1.20 + /* Determine the resulting position within the divided-up data. */
1.21 +
1.22 + pos = (cell / 2) * cfg->cell_size + offset;
1.23 +
1.24 + /* Return the final position within the entire data. All cells in
1.25 + odd-numbered positions occur in the first half, all even-numbered cells
1.26 + in the second half. */
1.27
1.28 return cell % 2 ? pos + cfg->line_length / 2 : pos;
1.29 }