output: simplify trigger marker position calculation (readability)
This amends commit 67b345b981
which fixed the calculation of the
trigger marker's position. Improve readability of the formulae and
adjust comments.
This commit is contained in:
parent
67b345b981
commit
3387a5d8ee
|
@ -200,10 +200,9 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
|
||||||
g_string_append_c(*out, '\n');
|
g_string_append_c(*out, '\n');
|
||||||
if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
|
if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
|
||||||
/*
|
/*
|
||||||
* Each group of 8 bits occupies 8 bit positions
|
* Sample data lines have one character per bit and
|
||||||
* and no separator. With this dense presentation
|
* no separator between bytes. Align trigger marker
|
||||||
* the "calculation" of the trigger position is
|
* to this layout.
|
||||||
* rather straight forward.
|
|
||||||
*/
|
*/
|
||||||
offset = ctx->trigger;
|
offset = ctx->trigger;
|
||||||
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
|
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
|
||||||
|
|
|
@ -169,13 +169,11 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
|
||||||
g_string_append_c(*out, '\n');
|
g_string_append_c(*out, '\n');
|
||||||
if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
|
if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
|
||||||
/*
|
/*
|
||||||
* Each group of 8 bits occupies 8 bit positions
|
* Sample data lines have one character per bit,
|
||||||
* plus 1 separator. Calculate the position of the
|
* plus one separator per byte. Align trigger marker
|
||||||
* byte which contains the trigger, then adjust for
|
* to this layout.
|
||||||
* the trigger's bit position within that byte.
|
|
||||||
*/
|
*/
|
||||||
offset = ctx->trigger / 8 * (8 + 1);
|
offset = ctx->trigger + ctx->trigger / 8;
|
||||||
offset += ctx->trigger % 8;
|
|
||||||
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
|
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
|
||||||
ctx->trigger = -1;
|
ctx->trigger = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,13 +182,11 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
|
||||||
g_string_append_c(*out, '\n');
|
g_string_append_c(*out, '\n');
|
||||||
if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
|
if (j == ctx->num_enabled_channels - 1 && ctx->trigger > -1) {
|
||||||
/*
|
/*
|
||||||
* Each group of 8 bits occupies 2 hex digits plus
|
* Sample data lines have one character per nibble,
|
||||||
* 1 separator. Calculate the position of the byte
|
* plus one separator per byte. Align trigger marker
|
||||||
* which contains the trigger, then adjust for the
|
* to this layout.
|
||||||
* trigger's bit position within that byte.
|
|
||||||
*/
|
*/
|
||||||
offset = ctx->trigger / 8 * (2 + 1);
|
offset = ctx->trigger / 4 + ctx->trigger / 8;
|
||||||
offset += (ctx->trigger % 8) / 4;
|
|
||||||
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
|
g_string_append_printf(*out, "T:%*s^ %d\n", offset, "", ctx->trigger);
|
||||||
ctx->trigger = -1;
|
ctx->trigger = -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue