]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
more rounding and float to integer experiments
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Fri, 14 Jan 2022 09:10:51 +0000 (14:40 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Fri, 14 Jan 2022 09:10:51 +0000 (14:40 +0530)
rigctl.c

index 21a3fb54bdecca090dcf71416fec17a666c16d7d..a569dba2f671cf7e38914b1be242e5ebe0e6af9d 100644 (file)
--- a/rigctl.c
+++ b/rigctl.c
@@ -3461,15 +3461,15 @@ int parse_cmd(void *data) {
     case 'A': // RA
       // set/read Attenuator function
       if (command[2] == ';') {
-        int att = 0;
+        double att = 0.0;
         if (have_rx_gain) {
-          att = (int)round(adc[active_receiver->adc].attenuation + 12);
-          att = (int)round((att * 99.0) / 60.0);
+          att = adc[active_receiver->adc].attenuation + 12.0);
+          att = round((att * 99.0) / 60.0);
         } else {
-          att = (int)(adc[active_receiver->adc].attenuation);
-          att = (int)round((att * 99.0) / 31.0);
+          att = adc[active_receiver->adc].attenuation;
+          att = round((att * 99.0) / 31.0);
         }
-        sprintf(reply, "RA%02d00;", att);
+        sprintf(reply, "RA%02d00;", (int)att);
         send_resp(client->fd, reply);
       } else if (command[4] == ';') {
           command[4] = '\0';