-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMobo_LCD_Display.c
2410 lines (2037 loc) · 79.4 KB
/
Mobo_LCD_Display.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//*********************************************************************************
//**
//** Project.........: USB controller firmware for the Softrock 6.3 SDR,
//** enhanced with the 9V1AL Motherboard, F6ITU LPF bank
//** and other essentials to create an all singing and
//** all dancing HF SDR amateur radio transceiver
//**
//** Initial Core project team: 9V1AL, F6ITU, KF4BQ, KY1K
//** TF3LJ & many more
//**
//** Platform........: AT90USB162 @ 16MHz
//**
//** Licence.........: This software is freely available for non-commercial
//** use - i.e. for research and experimentation only!
//**
//** Several alternate functions included in this file:
//**
//** Quiet Mode (LCD_PAR_DISPLAY2):
//** 20x4 and 40x2
//**
//** Old style, constant LCD write (LCD_PAR_DISPLAY):
//** 16x2, 20x2 non bargraph versions
//** 16x2, 20x2, 20x4 and 40x2 bargraph versions
//**
//** Experimental (not tested) I2C alternatives of "Old style"
//**
//** Initial version.: 2009-09-09, Loftur Jonasson, TF3LJ
//**
//** Last update to this file: 2010-05-24, Loftur Jonasson, TF3LJ
//**
//** Check the Mobo.c file
//**
//**
//*********************************************************************************
#include "Mobo.h"
//#include <rprintf.h> // AVRLIB (not AVRLibc) functions
// Identical routines for I2C and parallel connected displays
#if (LCD_PAR_DISPLAY2 || LCD_PAR_DISPLAY || LCD_I2C_DISPLAY)
//
//-----------------------------------------------------------------------------
// This little routine is used to handle LCD print from program memory,
// rather than using SRAM.
// A small trick necessary for not to overrun what little SRAM we have left
// (similar function in lcd.c, but it compiles 6 bytes leaner if placed here)
//-----------------------------------------------------------------------------
//
void lcd_putchar_P(const char *addr)
{
uint8_t c;
while ((c = pgm_read_byte(addr++)))
lcd_data(c);
}
#endif
//*******************************************************************************************************************
#if LCD_PAR_DISPLAY2 // New and improved, low traffic (low noise) Mobo_LCD_Display.c routines
//*******************************************************************************************************************
#if LCD_DISPLAY_20x4_b // 20x4 LCD display variant.
//
//-----------------------------------------------------------------------------
// Display stuff on a 20x4 LCD
//-----------------------------------------------------------------------------
//
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
static uint16_t pow_avg[PEP_MAX_PERIOD]; // Power measurement ringbuffer
#endif
//
//-------------------------------------------------------
// Display TX/RX Status on change
//-------------------------------------------------------
//
void lcd_display_TRX_status_on_change(void)
{
static uint8_t tx_status = 1; // Force run first time. Keep track of TRX status
if (tx_status != (Status1 & TX_FLAG)) // Has there been a TX/RX change?
{
tx_status = Status1 & TX_FLAG;
lcd_display_TRX_stuff();
}
}
//
//-------------------------------------------------------
// Display TX/RX Stuff
//-------------------------------------------------------
//
void lcd_display_TRX_stuff(void)
{
lcd_clrscr(); // Clear Screen is a cheaper operation than
// writing blanks, though it causes flicker
lcd_display_freq_and_filters(); // Update frequency display
lcd_display_P_SWR_V_C_T(); // Update 2nd line, Temp, V, I...
lcd_command(LCD_DISP_ON); // Blinking block cursor OFF
lcd_gotoxy(0,0); // First char, first line
if(Status1 & TX_FLAG) // TX or RX ?
{
lcd_data('T');
}
else
{
lcd_data('R');
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
for (uint8_t j = 0; j < PEP_MAX_PERIOD; j++)// Clear PEP storage during receive
{
pow_avg[j]=0;
}
#endif
//
//-------------------------------------------
// Display static stuff when in Receive ("RX") mode
//-------------------------------------------
//
#if DISP_TERSE // Option for 20x4 and 40x2 displays
lcd_gotoxy(12,3); // Line 4 position 13
lcd_putchar_P(PSTR("Mobo 4.3")); // Print string from flash rom
#endif
#if DISP_VERBOSE // Option for 20x4 and 40x2 displays
lcd_gotoxy(0,2); // Line 3 position 0
lcd_putchar_P(PSTR("Softrock 6.3 &")); // Print string from flash rom
lcd_gotoxy(12,3); // Line 4 position 13
lcd_putchar_P(PSTR("Mobo 4.3")); // Print string from flash rom
#endif
#if DISP_VER_SIMPLE // Option for 20x4 and 40x2 displays
lcd_gotoxy(0,3); // Line 4 position 0
lcd_putchar_P(PSTR("Mobo 4.3")); // Print string from flash rom
lcd_gotoxy(16,3);
rprintf("%s",VERSION); // Print version info
#endif
#if DISP_VER_SHORT // Option for 20x4 and 40x2 displays
lcd_gotoxy(0,3); // Line 4 position 0
lcd_putchar_P(PSTR("Mobo 4.3 ")); // Print string from flash rom
rprintf("%s-%u.%u",VERSION,VERSION_MAJOR,VERSION_MINOR);// Print version info
#endif
#if DISP_VERSION // Option for 20x4 and 40x2 displays
lcd_gotoxy(0,2); // Line 3 position 0
lcd_putchar_P(PSTR("SR 6.3 <--> Mobo 4.3"));// Print string from flash rom
lcd_gotoxy(5,3); // Line 4 position 5
rprintf("Ver: %s-%u.%u",VERSION,VERSION_MAJOR,VERSION_MINOR);// Print version info
#endif
}
}
//
//-------------------------------------------------------
// Display Frequency and Filters
//-------------------------------------------------------
//
void lcd_display_freq_and_filters(void)
{
uint32_t dispFrq;
uint16_t fMHz;
uint32_t fHz;
lcd_gotoxy(1,0); // Second char, first line
//
//-------------------------------------------------------
// Display the Si570 frequency (divided by 4) on the LCD:
//-------------------------------------------------------
//
#if PSDR_IQ_OFFSET36 // Display a fixed frequency offset during RX only.
if(!(Status1 & TX_FLAG))
{
//frq = frq + R.LCD_RX_Offset;
R.Freq[0] = R.Freq[0] + R.LCD_RX_Offset;
}
#endif
dispFrq = (double) R.Freq[0] * 1000000.0 / _2(23); // R.Freq / 2^21 / 4 = Lo frequency
#if PSDR_IQ_OFFSET68 // Display a fixed frequency offset during RX only.
if(!(Status1 & TX_FLAG))
{
dispFrq = dispFrq + R.LCD_RX_Offset * 1000; // 1000.0 * _2(23);
}
#endif
fMHz = dispFrq / 1000000;
fHz = dispFrq % 1000000;
rprintf("X%3u.%06luMHz F%x-%x", fMHz,fHz,selectedFilters[0],selectedFilters[1]);
}
//
//-------------------------------------------------------
// Display Power, SWR, Voltage, Current and Temperature
//-------------------------------------------------------
//
void lcd_display_P_SWR_V_C_T(void)
{
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
if (R.PEP_samples > PEP_MAX_PERIOD) R.PEP_samples = PEP_MAX_PERIOD;// Safety measure
#endif
lcd_gotoxy(0,1); // First char, second line
#if DISP_FAHRENHEIT // Display temperature in Fahrenheit
uint16_t tmp_F; // (threshold still set in deg C)
tmp_F = ((tmp100_data.w>>7) * 9)/10 + 32;
#else
int8_t tmp_C = tmp100_data.i1;
#endif
// Display " Voltage and temperature" in second line
#if DISP_FAHRENHEIT // Display temperature in Fahrenheit
// (threshold still set in deg C)
rprintf("%3uF", tmp_F);
#else
rprintf("%3d", tmp_C);
lcd_data(0xdf); lcd_data('C');
#endif
// Prep Voltage readout. Max voltage = 15.6V (5V * 14.7k/4.7k)
uint16_t vdd_tenths = ((uint32_t) ad7991_adc[AD7991_PSU_VOLTAGE].w * 156) / 0xfff0;
uint16_t vdd = vdd_tenths / 10;
vdd_tenths = vdd_tenths % 10;
lcd_gotoxy(7,1);
rprintf("%2u.%1uV", vdd, vdd_tenths);
//
//-------------------------------------------------------
// During TX, Display PA current in second line of LCD
//-------------------------------------------------------
//
if (Status1 & (PA_CAL | TX_FLAG))
{
// Fetch and normalize PA current
uint16_t idd_ca = ad7991_adc[AD7991_PA_CURRENT].w / 262;
uint16_t idd = idd_ca/100; idd_ca = idd_ca%100;
lcd_gotoxy(13,1); // Second line, 13th position
rprintf("%u.%02uA", idd, idd_ca); // Display current while in transmit
}
//
//-------------------------------------------------------
// Display alternate text during RX in second line of LCD
//-------------------------------------------------------
//
else
{
lcd_putchar_P(PSTR(" Bias:")); // Print string from flash rom
}
//
//-------------------------------------------------------
// Display Bias setting in second line of LCD
//-------------------------------------------------------
//
const char bias[]= {'R','L','H'};
lcd_gotoxy(19,1); // Second line, 19th position
lcd_data(bias[biasInit]); // Print Bias status 'R'educed
// 'Low' or 'H'igh
//-------------------------------------------------------
// Display Stuff in third and fourth line of the LCD
//-------------------------------------------------------
lcd_gotoxy(0,3); // Fourth line, first position
//--------------------------------------------
// Display a PA thermal runaway situation
//--------------------------------------------
if(Status1 & TMP_ALARM) // Thermal runaway, TX shutdown
{
lcd_putchar_P(PSTR("Temperature Shutdown"));// A trick to print string from flash rom
// rather than from SRAM
}
//
//-------------------------------------------------------
// Display PA Bias tune indication
//-------------------------------------------------------
//
else if(Status1 & PA_CAL) // PA bias cal in progress flags
{
lcd_putchar_P(PSTR("PA Bias Calibrate")); // Print string from flash rom rather than from SRAM
}
//
//-------------------------------------------------------
// Display stuff while in Transmit "TX" mode
//-------------------------------------------------------
//
else if(Status1 & TX_FLAG)
{
//
//-------------------------------------------------------
// Power Output Bargraph in third line
//-------------------------------------------------------
//
lcd_gotoxy(0,2); // Third line
uint16_t pow_tot, pow, pow_mw;
// Prepare Power readout
pow_tot = measured_Power(ad7991_adc[AD7991_POWER_OUT].w);// Power in mW (max 65535mW)
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
static uint8_t i = 0;
#if PWR_PEP_ADJUST // Option to adjust the number of samples in PEP measurement
pow_avg[i] = pow_tot; // Store value in ringbuffer
i++;
if (i >= R.PEP_samples) i = 0;
pow_tot = 0;
for (uint8_t j = 0; j < R.PEP_samples; j++) // Retrieve the largest value out of the measured window
{
if (pow_avg[j] > pow_tot) pow_tot = pow_avg[j];
}
#else
pow_avg[i] = pow_tot; // Store value in ringbuffer
i++;
if (i >= PEP_PERIOD) i = 0;
pow_tot = 0;
for (uint8_t j = 0; j < PEP_PERIOD; j++) // Retrieve the largest value out of the measured window
{
if (pow_avg[j] > pow_tot) pow_tot = pow_avg[j];
}
#endif
#endif
// progress, maxprogress, len
lcdProgressBar(pow_tot/100, R.PWR_fullscale*10, 12);
pow = pow_tot / 1000; // Watts
pow_mw = pow_tot % 1000; // milliWatts
rprintf("P%2u.%03uW", pow, pow_mw);
//
//--------------------------------------------
// Display SWR Bargraph in fourth line
//--------------------------------------------
//
lcd_gotoxy(0,3); // Fourth line
// Prepare SWR readout
uint16_t swr, swr_hundredths, swr_tenths;
swr = measured_SWR / 100; // SWR
swr_hundredths = measured_SWR % 100; // sub decimal point, 1/100 accuracy
swr_tenths = swr_hundredths / 10; // sub decimal point, 1/10 accuracy
// progress, maxprogress, len
#if BARGRAPH_SWR_SCALE // Add option to adjust the Fullscale value for the SWR bargraph
// possible bug fix for SWR lcdProgressBar exceeding range
uint16_t display_SWR = ((measured_SWR-100) > R.SWR_fullscale*100) ? R.SWR_fullscale*100 : (measured_SWR-100);
lcdProgressBar(display_SWR, R.SWR_fullscale*100, 12);
#else
display_SWR = ((measured_SWR-100) > R.SWR_fullscale*100) ? SWR_FULL_SCALE : (measured_SWR-100);
lcdProgressBar(display_SWR - 100, SWR_FULL_SCALE, 12);
#endif
lcd_putchar_P(PSTR("SWR")); // Print string from flash rom
rprintf("%2u.", swr); // Print the super decimal portion of the SWR
#if SWR_ALARM_FUNC // SWR alarm function, activates a secondary PTT
//
//--------------------------------------------
// Display a SWR Alarm situation
//--------------------------------------------
//
if(Status1 & SWR_ALARM) // SWR Alarm flag set
{
if(swr >= 100) // SWR more than 99
lcd_putchar_P(PSTR(" --"));
else
lcd_data(swr_tenths+0x30); // Print the sub-decimal value of the SWR, single digit precision
// (a lean byte saving way to print a single decimal)
lcd_data('A'); // A in SWRA indication
lcd_command(LCD_DISP_ON_BLINK); // Blinking block cursor ON
}
else
#endif//SWR_ALARM_FUNC
rprintf("%02u", swr_hundredths); // Print the sub-decimal value of the SWR, double digit precision
// In case of a blinking "SWR Alarm" cursor, put it on "A" in "SWR Alarm"
lcd_gotoxy(19,3);
}
}
//
//-------------------------------------------------------
// Display if new Frequency is stored by Shaft Encoder func
//-------------------------------------------------------
//
#if ENCODER_INT_STYLE || ENCODER_SCAN_STYLE // Shaft Encoder VFO function
void lcd_display_Memory_Stored(void) // Display Memory Stored for a certain amount of time
{
static int count = 0; // Display for ENC_STORE_DISP * 100ms
lcd_gotoxy(0,3); // Fourth line
lcd_putchar_P(PSTR("VFO Memory Stored ")); // Print string from flash rom rather than from SRAM
count++;
if(count>=ENC_STORE_DISP)
{
Status2 &= ~ENC_STORED;
count = 0;
lcd_display_TRX_stuff();
}
}
#endif
#endif//LCD_DISPLAY_20x4_b// 20x4 LCD display.
//*******************************************************************************************************************
#if LCD_DISPLAY_40x2_b // Alternate 40x2 LCD display variant.
//
//-----------------------------------------------------------------------------
// Display stuff on a 40x2 LCD
//-----------------------------------------------------------------------------
//
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
static uint16_t pow_avg[PEP_MAX_PERIOD]; // Power measurement ringbuffer
#endif
//
//-------------------------------------------------------
// Display TX/RX Status on change
//-------------------------------------------------------
//
void lcd_display_TRX_status_on_change(void)
{
static uint8_t tx_status = 1; // Force run first time. Keep track of TRX status
if (tx_status != (Status1 & TX_FLAG)) // Has there been a TX/RX change?
{
tx_status = Status1 & TX_FLAG;
lcd_display_TRX_stuff();
}
}
//
//-------------------------------------------------------
// Display TX/RX Stuff
//-------------------------------------------------------
//
void lcd_display_TRX_stuff(void)
{
lcd_clrscr(); // Clear Screen is a cheaper operation than
// writing blanks, though it causes flicker
lcd_display_freq_and_filters(); // Update frequency display
lcd_display_P_SWR_V_C_T(); // Update 2nd line, Temp, V, I...
lcd_command(LCD_DISP_ON); // Blinking block cursor OFF
lcd_gotoxy(0,0); // First char, first line
if(Status1 & TX_FLAG) // TX or RX ?
{
lcd_data('T');
}
else
{
lcd_data('R');
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
for (uint8_t j = 0; j < PEP_MAX_PERIOD; j++)// Clear PEP storage during receive
{
pow_avg[j]=0;
}
#endif
//
//-------------------------------------------
// Display static stuff when in Receive ("RX") mode
//-------------------------------------------
//
#if DISP_TERSE // Option for 20x4 and 40x2 displays
lcd_gotoxy(32,1); // Line 2 position 32
lcd_putchar_P(PSTR("Mobo 4.3")); // Print string from flash rom
#endif
#if DISP_VERBOSE // Option for 20x4 and 40x2 displays
lcd_gotoxy(21,0); // Line 1 position 21
lcd_putchar_P(PSTR("Softrock 6.3 &")); // Print string from flash rom
lcd_gotoxy(32,1); // Line 2 position 32
lcd_putchar_P(PSTR("Mobo 4.3")); // Print string from flash rom
#endif
#if DISP_VER_SIMPLE // Option for 20x4 and 40x2 displays
lcd_gotoxy(21,1); // Line 2 position 21
lcd_putchar_P(PSTR("Mobo 4.3")); // Print string from flash rom
lcd_gotoxy(36,1);
rprintf("%s",VERSION); // Print version info
#endif
#if DISP_VER_SHORT // Option for 20x4 and 40x2 displays
lcd_gotoxy(21,1); // Line 4 position 0
lcd_putchar_P(PSTR("Mobo 4.3 ")); // Print string from flash rom
rprintf("%s-%u.%u",VERSION,VERSION_MAJOR,VERSION_MINOR);// Print version info
#endif
#if DISP_VERSION // Option for 20x4 and 40x2 displays
lcd_gotoxy(21,0); // Line 1 position 20
lcd_putchar_P(PSTR("SR 6.3 <--> Mobo 4.3"));// Print string from flash rom
lcd_gotoxy(25,1); // Line 2 position 25
rprintf("Ver: %s-%u.%u",VERSION,VERSION_MAJOR,VERSION_MINOR);// Print version info
#endif
}
}
//
//-------------------------------------------------------
// Display Frequency and Filters
//-------------------------------------------------------
//
void lcd_display_freq_and_filters(void)
{
uint32_t dispFrq;
uint16_t fMHz;
uint32_t fHz;
lcd_gotoxy(1,0); // Second char, first line
//
//-------------------------------------------------------
// Display the Si570 frequency (divided by 4) on the LCD:
//-------------------------------------------------------
//
#if PSDR_IQ_OFFSET36 // Display a fixed frequency offset during RX only.
if(!(Status1 & TX_FLAG))
{
//frq = frq + R.LCD_RX_Offset;
R.Freq[0] = R.Freq[0] + R.LCD_RX_Offset;
}
#endif
dispFrq = (double) R.Freq[0] * 1000000.0 / _2(23); // R.Freq / 2^21 / 4 = Lo frequency
#if PSDR_IQ_OFFSET68 // Display a fixed frequency offset during RX only.
if(!(Status1 & TX_FLAG))
{
dispFrq = dispFrq + R.LCD_RX_Offset * 1000; // 1000.0 * _2(23);
}
#endif
fMHz = dispFrq / 1000000;
fHz = dispFrq % 1000000;
rprintf("X%3u.%06luMHz F%x-%x", fMHz,fHz,selectedFilters[0],selectedFilters[1]);
}
//
//-------------------------------------------------------
// Display Power, SWR, Voltage, Current and Temperature
//-------------------------------------------------------
//
void lcd_display_P_SWR_V_C_T(void)
{
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
if (R.PEP_samples > PEP_MAX_PERIOD) R.PEP_samples = PEP_MAX_PERIOD;// Safety measure
#endif
lcd_gotoxy(0,1); // First char, second line
#if DISP_FAHRENHEIT // Display temperature in Fahrenheit
uint16_t tmp_F; // (threshold still set in deg C)
tmp_F = ((tmp100_data.w>>7) * 9)/10 + 32;
#else
int8_t tmp_C = tmp100_data.i1;
#endif
// Display " Voltage and temperature" in second line
#if DISP_FAHRENHEIT // Display temperature in Fahrenheit
// (threshold still set in deg C)
rprintf("%3uF", tmp_F);
#else
rprintf("%3d", tmp_C);
lcd_data(0xdf); lcd_data('C');
#endif
// Prep Voltage readout. Max voltage = 15.6V (5V * 14.7k/4.7k)
uint16_t vdd_tenths = ((uint32_t) ad7991_adc[AD7991_PSU_VOLTAGE].w * 156) / 0xfff0;
uint16_t vdd = vdd_tenths / 10;
vdd_tenths = vdd_tenths % 10;
lcd_gotoxy(7,1);
rprintf("%2u.%1uV", vdd, vdd_tenths);
//
//-------------------------------------------------------
// During TX, Display PA current in second line of LCD
//-------------------------------------------------------
//
if (Status1 & (PA_CAL | TX_FLAG))
{
// Fetch and normalize PA current
uint16_t idd_ca = ad7991_adc[AD7991_PA_CURRENT].w / 262;
uint16_t idd = idd_ca/100; idd_ca = idd_ca%100;
lcd_gotoxy(13,1); // Second line, 13th position
rprintf("%u.%02uA", idd, idd_ca); // Display current while in transmit
}
//
//-------------------------------------------------------
// Display alternate text during RX in second line of LCD
//-------------------------------------------------------
//
else
{
lcd_putchar_P(PSTR(" Bias:")); // Print string from flash rom
}
//
//-------------------------------------------------------
// Display Bias setting in second line of LCD
//-------------------------------------------------------
//
const char bias[]= {'R','L','H'};
lcd_gotoxy(19,1); // Second line, 19th position
lcd_data(bias[biasInit]); // Print Bias status 'R'educed
// 'Low' or 'H'igh
//-------------------------------------------------------
// Display Stuff in third and fourth line of the LCD
//-------------------------------------------------------
lcd_gotoxy(20,1); // Second half, second line
//--------------------------------------------
// Display a PA thermal runaway situation
//--------------------------------------------
if(Status1 & TMP_ALARM) // Thermal runaway, TX shutdown
{
lcd_putchar_P(PSTR("Temperature Shutdown"));// A trick to print string from flash rom
// rather than from SRAM
}
//
//-------------------------------------------------------
// Display PA Bias tune indication
//-------------------------------------------------------
//
else if(Status1 & PA_CAL) // PA bias cal in progress flags
{
lcd_putchar_P(PSTR("PA Bias Calibrate")); // Print string from flash rom rather than from SRAM
}
//
//-------------------------------------------------------
// Display stuff while in Transmit "TX" mode
//-------------------------------------------------------
//
else if(Status1 & TX_FLAG)
{
//
//-------------------------------------------------------
// Power Output Bargraph in third line
//-------------------------------------------------------
//
lcd_gotoxy(20,0); // Second half, first line
uint16_t pow_tot, pow, pow_mw;
// Prepare Power readout
pow_tot = measured_Power(ad7991_adc[AD7991_POWER_OUT].w);// Power in mW (max 65535mW)
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
static uint8_t i = 0;
#if PWR_PEP_ADJUST // Option to adjust the number of samples in PEP measurement
pow_avg[i] = pow_tot; // Store value in ringbuffer
i++;
if (i >= R.PEP_samples) i = 0;
pow_tot = 0;
for (uint8_t j = 0; j < R.PEP_samples; j++) // Retrieve the largest value out of the measured window
{
if (pow_avg[j] > pow_tot) pow_tot = pow_avg[j];
}
#else
pow_avg[i] = pow_tot; // Store value in ringbuffer
i++;
if (i >= PEP_PERIOD) i = 0;
pow_tot = 0;
for (uint8_t j = 0; j < PEP_PERIOD; j++) // Retrieve the largest value out of the measured window
{
if (pow_avg[j] > pow_tot) pow_tot = pow_avg[j];
}
#endif
#endif
// progress, maxprogress, len
lcdProgressBar(pow_tot/100, R.PWR_fullscale*10, 12);
pow = pow_tot / 1000; // Watts
pow_mw = pow_tot % 1000; // milliWatts
rprintf("P%2u.%03uW", pow, pow_mw);
//
//--------------------------------------------
// Display SWR Bargraph in fourth line
//--------------------------------------------
//
lcd_gotoxy(20,1); // Second half, second line
// Prepare SWR readout
uint16_t swr, swr_hundredths, swr_tenths;
swr = measured_SWR / 100; // SWR
swr_hundredths = measured_SWR % 100; // sub decimal point, 1/100 accuracy
swr_tenths = swr_hundredths / 10; // sub decimal point, 1/10 accuracy
// progress, maxprogress, len
#if BARGRAPH_SWR_SCALE // Add option to adjust the Fullscale value for the SWR bargraph
// possible bug fix for SWR exceeding lcdProgressBar range
uint16_t display_SWR = ((measured_SWR-100) > R.SWR_fullscale*100) ? R.SWR_fullscale*100 : (measured_SWR-100);
lcdProgressBar(display_SWR, R.SWR_fullscale*100, 12);
#else
display_SWR = ((measured_SWR-100) > R.SWR_fullscale*100) ? SWR_FULL_SCALE : (measured_SWR-100);
lcdProgressBar(display_SWR - 100, SWR_FULL_SCALE, 12);
#endif
lcd_putchar_P(PSTR("SWR")); // Print string from flash rom
rprintf("%2u.", swr); // Print the super decimal portion of the SWR
#if SWR_ALARM_FUNC // SWR alarm function, activates a secondary PTT
//
//--------------------------------------------
// Display a SWR Alarm situation
//--------------------------------------------
//
if(Status1 & SWR_ALARM) // SWR Alarm flag set
{
if(swr >= 100) // SWR more than 99
lcd_putchar_P(PSTR(" --"));
else
lcd_data(swr_tenths+0x30); // Print the sub-decimal value of the SWR, single digit precision
// (a lean byte saving way to print a single decimal)
lcd_data('A'); // A in SWRA indication
lcd_command(LCD_DISP_ON_BLINK); // Blinking block cursor ON
}
else
#endif//SWR_ALARM_FUNC
rprintf("%02u", swr_hundredths); // Print the sub-decimal value of the SWR, double digit precision
// In case of a blinking "SWR Alarm" cursor, put it on "A" in "SWR Alarm"
lcd_gotoxy(39,1);
}
}
//
//-------------------------------------------------------
// Display if new Frequency is stored by Shaft Encoder func
//-------------------------------------------------------
//
#if ENCODER_INT_STYLE || ENCODER_SCAN_STYLE // Shaft Encoder VFO function
void lcd_display_Memory_Stored(void) // Display Memory Stored for a certain amount of time
{
static int count = 0; // Display for ENC_STORE_DISP * 100ms
lcd_gotoxy(20,1); // Second half, second line
lcd_putchar_P(PSTR(" VFO Memory Stored ")); // Print string from flash rom rather than from SRAM
count++;
if(count>=ENC_STORE_DISP)
{
Status2 &= ~ENC_STORED;
count = 0;
lcd_display_TRX_stuff();
}
}
#endif
#endif//LCD_DISPLAY_40x2_b// Alternate 40x2 LCD display.
#endif //LCD_PAR_DISPLAY2 // Alternate low traffic (low noise) Mobo_LCD_Display.c routines
//*******************************************************************************************************************
#if (LCD_PAR_DISPLAY || LCD_I2C_DISPLAY)// Identical routines for I2C and parallel connected displays
//*******************************************************************************************************************
#if LCD_DISPLAY_16x2// Original Default Display Routines for 16x2 LCD
//
//-----------------------------------------------------------------------------
// Display stuff on a 16x2 LCD
//-----------------------------------------------------------------------------
//
void lcd_display(void)
{
//rprintfInit(lcd_data);
#if !DEBUG_1LN // First line of LCD not used for Debug
//
//-------------------------------------------------------
// Display stuff in first line of LCD
//-------------------------------------------------------
//
lcd_gotoxy(0,0); // First char, first line
//-------------------------------------------------------
// Display PA Bias tune indication
//-------------------------------------------------------
if(Status1 & PA_CAL) // PA bias cal in progress flags
{
lcd_putchar_P(PSTR("PA BiasCalibrate")); // Lean and pgm space efficient print
}
#if ENCODER_INT_STYLE || ENCODER_SCAN_STYLE // Shaft Encoder VFO function
//-------------------------------------------------------
// Display if new Frequency is stored by Shaft Encoder func
//-------------------------------------------------------
else if (Status2 & ENC_STORED)
{
lcd_putchar_P(PSTR("Memory Stored "));
static int count = 0; // Display for ENC_STORE_DISP * 100ms
count++;
if(count>=ENC_STORE_DISP)
{
Status2 &= ~ENC_STORED;
count = 0;
}
}
#endif
//-------------------------------------------------------
// Display the Si570 frequency (divided by 4) on the LCD:
// (Two separate compile time options below)
//-------------------------------------------------------
else
{
// Display the current Si570 frequency on the LCD
int32_t freq;
freq = R.Freq[0];
#if PSDR_IQ_OFFSET36 // Display a fixed frequency offset during RX only.
if(!(Status1 & TX_FLAG))
{
freq = freq + R.LCD_RX_Offset;
}
#endif
uint32_t dispFreq;
dispFreq = (double) freq * 1000000.0 / _2(23); // R.Freq / 2^21 / 4 = Lo frequency
#if PSDR_IQ_OFFSET68 // Display a fixed frequency offset during RX only.
if(!(Status1 & TX_FLAG))
{
dispFreq = dispFreq + R.LCD_RX_Offset * 1000; // 1000.0 * _2(23);
}
#endif
uint16_t fMHz = dispFreq / 1000000;
uint32_t fHz = dispFreq % 1000000;
rprintf("%3u.%06luMHz RX", fMHz,fHz);
}
//--------------------------------------------
// Display the Transmit/Receive Status
//--------------------------------------------
lcd_gotoxy(14,0); // 15th char, first line
if(Status1 & TX_FLAG)
{
lcd_putchar_P(PSTR("TX")); // Display a blinking "TX"
lcd_command(LCD_DISP_ON_BLINK); // Blinking block cursor ON
}
else
{
lcd_putchar_P(PSTR("RX")); // Display a steady "RX"
lcd_command(LCD_DISP_ON); // Blinking block cursor OFF
}
#endif//DEBUG_1LN
#if !DEBUG_2LN // Second line of LCD not used for Debug
//
//-------------------------------------------------------
// Display stuff in second line of LCD
//-------------------------------------------------------
//
lcd_gotoxy(0,1); // First char, second line
// Variables used for print formatting, to emulate a floating point printf
// AVRLIB floating point printf formatting would be very costly in size
uint16_t vdd_tot, vdd, vdd_tenths;
#if POWER_SWR // Power and SWR measurement
uint16_t swr, swr_hundredths, swr_tenths, pow_tot, pow, pow_dw, pow_cw, pow_mw;
#endif
#if DISP_FAHRENHEIT // Display temperature in Fahrenheit
int16_t tmp_F; // (threshold still set in deg C)
tmp_F = ((tmp100_data.i/128) * 9)/10 + 32;
#else
int8_t tmp_C = tmp100_data.i1;
#endif
// Prep Voltage readout. Max voltage = 15.6V (5V * 14.7k/4.7k)
vdd_tot = ((uint32_t) ad7991_adc[AD7991_PSU_VOLTAGE].w * 156) / 0xfff0;
vdd = vdd_tot / 10;
vdd_tenths = vdd_tot % 10;
// Fetch and normalize PA current
uint16_t idd_ca = ad7991_adc[AD7991_PA_CURRENT].w / 262;
uint16_t idd = idd_ca / 100;
idd_ca = idd_ca % 100;
#if POWER_SWR // Power and SWR measurement
// Prepare Power readout
pow_tot = measured_Power(ad7991_adc[AD7991_POWER_OUT].w);// Power in mW (max 65535mW)
#if PWR_PEAK_ENVELOPE //PEP measurement. Highest value in buffer shown
static uint16_t pow_avg[PEP_MAX_PERIOD]; // Power measurement ringbuffer
if (R.PEP_samples > PEP_MAX_PERIOD) R.PEP_samples = PEP_MAX_PERIOD;// Safety measure
static uint8_t i = 0;
#if PWR_PEP_ADJUST // Option to adjust the number of samples in PEP measurement
pow_avg[i] = pow_tot; // Store value in ringbuffer
i++;
if (i >= R.PEP_samples) i = 0;
pow_tot = 0;
for (uint8_t j = 0; j < R.PEP_samples; j++) // Retrieve the largest value out of the measured window
{
if (pow_avg[j] > pow_tot) pow_tot = pow_avg[j];
}
#else
pow_avg[i] = pow_tot; // Store value in ringbuffer
i++;
if (i >= PEP_PERIOD) i = 0;
pow_tot = 0;
for (uint8_t j = 0; j < PEP_PERIOD; j++) // Retrieve the largest value out of the measured window
{
if (pow_avg[j] > pow_tot) pow_tot = pow_avg[j];
}
#endif
#endif
pow = pow_tot / 1000; // Watts
pow_mw = pow_tot % 1000; // milliWatts for certain LCD prints
pow_cw = pow_mw/10; // centiWatts for other LCD prints
pow_dw = pow_mw/100; // deciWatts for yet other LCD prints
// Prepare SWR readout
swr = measured_SWR / 100; // SWR
swr_hundredths = measured_SWR % 100; // sub decimal point, 1/100 accuracy
swr_tenths = swr_hundredths/10; // sub decimal point, 1/10 accuracy
#endif//POWER_SWR // Power and SWR measurement
//-------------------------------------------
// Display stuff while in Transmit "TX" mode
//-------------------------------------------
if(Status1 & TX_FLAG)
{
//--------------------------------------------
// Display a PA thermal runaway situation
//--------------------------------------------
if(Status1 & TMP_ALARM) // Thermal runaway, TX shutdown
{
#if DISP_FAHRENHEIT // Display temperature in Fahrenheit
// (threshold still set in deg C)
rprintf("TempShutdwn:%3uF", tmp_F);
#else
rprintf("TempShutdwn%3d", tmp_C);
lcd_data(0xdf); lcd_data('C');