1 // program extra.c for Linrad
2 // This demo program displays the following information in the two upper lines
3 // on the Linrad 'receive mode' screens:
4 // -the selected frequency
5 // -the selected mode
6 // -the selected bandwith
7 // -the selected input device
8 // -the selected network-modes
9 // -the UTC date and time
10 //
11 //  Pierre/ON5GN
12 //
13 // UPDATE HISTORY
14 //   7 sept  2004  first version for linrad 01.24
15 //  23 may   2010  BASEB16 and BASEB24 network-modes added
16 //                 layout changes
17 //                 documentation updates
18 //  27 june  2010  input device information added
19 //
20 // INSTALLATION
21 //
22 // To install under Linux for Linux:
23 //   download lirxx-xx.tbz and extract it to your linrad directory
24 //   rename extra.c to users_extra.c in your linrad directory
25 //   run ./configure and  make xlinrad (or make linrad) from your linrad directory
26 //
27 // To generate a windows version under Linux:
28 //   install mingw32 from Leif's website
29 //   download lirxx-xx.tbz and extract it to your linrad directory
30 //   rename extra.c to users_extra.c in your linrad directory
31 //   run ./configure and  make linrad.exe from your linrad directory
32 //
33 // To generate a windows version under Windows:
34 //   Install mingw and nasm from Leif's website in the C:\MinGW  directory
35 //   Download lirxx-xx.zip and unpack the linrad sources in your linrad
36 //   directory
37 //   rename extra.c to users_extra.c in your linrad directory
38 //   Start a MS-DOS Command Window on your computer: click the Windows Start
39 //   menu and enter the "cmd.exe" command into the run box
40 //   In the MS-DOS Command Window issue a "cd" command to your linrad
41 //   directory, followed by a "configure.exe" and "make.bat" command
42 //
43 
44 #include <time.h>
45 #include <string.h>
46 
47 extern float users_extra_update_interval;
48 
init_users_extra(void)49 void init_users_extra(void)
50 {
51 // This routine is called just before a receive mode is entered.
52 // Use it to set your own things from the keyboard.
53 // Remove the comment statements below for testing purposes
54 /*
55 int line,col;
56 char s[80];
57 col=1;
58 line=2;
59 sprintf(s,"THIS ROUTINE init_users_extra IS CALLED JUST BEFORE A RECEIVE MODE IS ENTERED");
60 lir_text(col,line,s);
61 sprintf(s,"USE IT TO SET YOUR OWN THINGS FROM THE KEYBOARD");
62 lir_text(col,line+2,s);
63 sprintf(s,"HIT ANY KEY TO CONTINUE");
64 lir_text(col,line+4,s);
65 await_processed_keyboard();
66 */
67 //
68 // Set users_extra_update_interval to the highest rate at which
69 // you want your routines called.
70 // The users_extra routines will be called only when the CPU is idle
71 // and if the time interval you have specified is exceeded.
72 users_extra_update_interval=0.25;
73 }
74 
users_extra(void)75 void users_extra(void)
76 {
77 // Demo code for users_extra by ON5GN, Pierre
78 //
79 // color codes:
80 //
81 //0      - black.
82 //1      - blue.
83 //2      - green.
84 //3      - cyan.
85 //4      - red.
86 //5      - magenta.
87 //6      - brown.
88 //7      - grey.
89 //8      - dark grey
90 //9      - light blue.
91 //10     - light green.
92 //11     - light cyan.
93 //12     - light red.
94 //13     - light magenta.
95 //14     - yellow
96 //15     - bright white
97 //
98 struct tm *tm_ptr;
99 time_t the_time;
100 char s[80];
101 char s1[80];
102 double freq_Mhz;
103 double freq_khz;
104 double freq_hz;
105 double absfreq;
106 double bw;
107 double bw_khz;
108 double bw_hz;
109 
110 // Hide the mouse while we update the screen so it will
111 // not be destroyed by what we write.
112 hide_mouse(0,screen_width,0,text_height);
113 
114 //display mode
115 sprintf (s,"MODE=%s",rxmodes[rx_mode]);
116 settextcolor(12); //red
117 lir_text (1,1,s);
118 
119 //display bandwith
120 bw =0.001*baseband_bw_hz;
121 bw_khz= floor (bw);
122 bw_hz= floor ((bw-(bw_khz))*1000);
123 if (bw_khz > 99)
124   {
125   sprintf (s,"B/W=%.0f kHz     ",bw);
126   }
127 else
128   {
129   if (bw_khz > 9)
130     {
131     sprintf (s,"B/W=%.1f kHz     ",bw);
132     }
133   else
134     {
135     if (bw_khz > 0)
136       {
137       sprintf (s,"B/W=%.2f kHz     ",bw);
138       }
139     else
140       {
141       if(bw_hz > 9)
142         {
143         sprintf (s,"B/W=%3.0f Hz    ",baseband_bw_hz);
144         }
145       else
146         {
147         sprintf (s,"B/W=%2.2f Hz    ",baseband_bw_hz);
148         }
149       }
150     }
151   }
152 settextcolor(14); //yellow
153 lir_text(26,0,s);
154 
155 //display frequency
156 if(mix1_selfreq[0] < 0)
157   {
158   sprintf (s,"FREQ=        off         ");
159   }
160 else
161   {
162   absfreq=fabs(hwfreq);
163   freq_Mhz= floor(absfreq/1000) ;
164   freq_khz= floor (absfreq-(freq_Mhz*1000)) ;
165   freq_hz=  floor (absfreq*1000-(freq_Mhz*1000000)-(freq_khz*1000)) ;
166   if (freq_Mhz != 0)
167     {
168     if(hwfreq < 0)freq_Mhz=-freq_Mhz;
169     sprintf (s,"FREQ=%3.0f %03.0f.%03.0f kHz  ",freq_Mhz,freq_khz,freq_hz);
170     }
171   else
172     {
173     if(hwfreq < 0)freq_khz=-freq_khz;
174     sprintf (s,"FREQ= %3.0f.%03.0f kHz        ",freq_khz,freq_hz);
175     }
176   }
177 settextcolor(10); //  green
178 lir_text(1,0,s);
179 
180 //display UTC date and time
181 (void) time(&the_time);
182 tm_ptr=gmtime(&the_time);
183 sprintf(s,"DATE=%2d/%02d/%04d   TIME=%02d:%02d:%02d ",
184                tm_ptr->tm_mday, tm_ptr->tm_mon+1,tm_ptr->tm_year+1900,
185                tm_ptr->tm_hour,tm_ptr->tm_min, tm_ptr->tm_sec );
186 settextcolor (15);  //15   white bright
187 lir_text(75,0,s);
188 
189 
190 
191   settextcolor(11);   //11  bright cyan
192   display_rx_input_source(&s[0]);
193   sprintf(s1,"INPUT=%s",s);
194   lir_text(45,0,s1);
195   settextcolor(7);
196 
197 
198 
199 // display NETWORK OUTPUT mode(s)
200 s1[0]='\0';
201 if((ui.network_flag & NET_RXOUT_RAW16) != 0)  strcpy ( s1,"RAW16");
202 if((ui.network_flag & NET_RXOUT_RAW18) != 0)  strcpy ( s1,"RAW18");
203 if((ui.network_flag & NET_RXOUT_RAW24) != 0)  strcpy ( s1,"RAW24");
204 if((ui.network_flag & NET_RXOUT_FFT1)  != 0)  strcpy ( s1,"FFT1");
205 if((ui.network_flag & NET_RXOUT_TIMF2) != 0)  strcpy ( s1,"TIMF2");
206 if((ui.network_flag & NET_RXOUT_FFT2)  != 0)  strcpy ( s1,"FFT2");
207 if((ui.network_flag & NET_RXOUT_BASEB)  != 0)  strcpy ( s1,"BASEB16");
208 if((ui.network_flag & NET_RXOUT_BASEBRAW) != 0)  strcpy ( s1,"BASEB24");
209 if (strlen(s1) != 0)
210 {
211 sprintf (s,"NETWORK OUTPUT = %s ",s1);
212 settextcolor(13); //13  bright magenta
213 lir_text(45,1,s);
214 settextcolor(7);
215 }
216 }
217 
218