- if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
- offset = ctx->trigger + ctx->trigger / 8;
+ if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
+ /*
+ * Each group of 8 bits occupies 2 hex digits plus
+ * 1 separator. Calculate the position of the byte
+ * which contains the trigger, then adjust for the
+ * trigger's bit position within that byte.
+ */
+ offset = ctx->trigger / 8 * (2 + 1);
+ offset += (ctx->trigger % 8) / 4;