From: Ramakrishnan Muthukrishnan Date: Mon, 27 Nov 2023 15:34:52 +0000 (+0530) Subject: fix drawing of correct NR status, revisit this code X-Git-Url: https://git.rkrishnan.org/pf/content/en/COPYING.TGPPL.html?a=commitdiff_plain;h=5474587ac9a59decfb73bba7b9cea9b59097fbdb;p=pihpsdr.git fix drawing of correct NR status, revisit this code --- diff --git a/vfo.c b/vfo.c index bf9aef8..3236ca9 100644 --- a/vfo.c +++ b/vfo.c @@ -1015,6 +1015,32 @@ void draw_item(cairo_t *cr, size_t item, uint status) { cairo_show_text(cr, entry->label[status]); } +// I am not proud of this code +int get_nr(RECEIVER *rx) +{ + if (rx->nr == 0 && rx->nr2 == 0 && rx->nr3 == 0 && rx->nr4 == 0) { + return 0; + } + + if (rx->nr == 1 && rx->nr2 == 0 && rx->nr3 == 0 && rx->nr4 == 0) { + return 1; + } + + if (rx->nr == 0 && rx->nr2 == 1 && rx->nr3 == 0 && rx->nr4 == 0) { + return 2; + } + + if (rx->nr == 0 && rx->nr2 == 0 && rx->nr3 == 1 && rx->nr4 == 0) { + return 3; + } + + if (rx->nr == 0 && rx->nr2 == 0 && rx->nr3 == 0 && rx->nr4 == 1) { + return 4; + } + + return -1; +} + void vfo_update(void) { int id = active_receiver->id; int txvfo = get_tx_vfo(); @@ -1214,7 +1240,12 @@ void vfo_update(void) { // NR // NR, NR2, NR3 and NR4 are mutually exclusive - draw_item(cr, SCR_NR, active_receiver->nr); + int which_nr = get_nr(active_receiver); + if (which_nr < 0) { + g_print("RIGCTL: ERROR in NR determination used for display\n"); + which_nr = 0; + } + draw_item(cr, SCR_NR, which_nr); // anf draw_item(cr, SCR_ANF, active_receiver->anf);