-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.c
3202 lines (2576 loc) · 83.3 KB
/
main.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
/* ************************************************************************
*
* main part
*
* (c) 2012-2024 by Markus Reschke
* based on code from Markus Frejek and Karl-Heinz Kübbeler
*
* ************************************************************************ */
/*
* local constants
*/
/* source management */
#define MAIN_C
/*
* include header files
*/
/* local includes */
#include "config.h" /* global configuration */
#include "common.h" /* common header file */
#include "variables.h" /* global variables */
#include "functions.h" /* external functions */
#include "colors.h" /* color definitions */
/*
* local variables
*/
/* program control */
#if CYCLE_MAX < 255
uint8_t MissedParts; /* counter for failed/missed components */
#endif
/* ************************************************************************
* output components and errors
* ************************************************************************ */
/*
* get pin designator for specific probe ID
*
* requires:
* - probe ID [0-2]
*
* returns:
* - pin designator
*/
uint8_t Get_SemiPinDesignator(uint8_t Probe)
{
uint8_t Char; /* designator / return value */
/* looking for matching probe ID */
if (Probe == Semi.A) /* matches pin A */
{
Char = Semi.DesA; /* designator for pin A */
}
else if (Probe == Semi.B) /* matches pin B */
{
Char = Semi.DesB; /* designator for pin B */
}
else /* matches pin C */
{
Char = Semi.DesC; /* designator for pin C */
}
return Char;
}
#if ! defined (UI_NO_TEXTPINOUT) || defined (SW_ENCODER)
/*
* show pinout for semiconductors
* - displays: 123=abc
*/
void Show_SemiPinout(void)
{
uint8_t n; /* counter */
/* display: 123 */
for (n = 0; n <= 2; n++) /* loop through probe pins */
{
Display_ProbeNumber(n); /* display probe ID */
}
/* display: = */
Display_Char('=');
/* display pin designators */
for (n = 0; n <= 2; n++) /* loop through probe pins */
{
Display_SemiPinDesignator(n); /* display pin designator */
}
}
#endif
/*
* show simple pinout
* - displays: 1:a 2:b 3:c
*
* required:
* - DesX: designators for probes #1, #2 and #3
* 0 -> not displayed
*/
void Show_SimplePinout(uint8_t Des1, uint8_t Des2, uint8_t Des3)
{
uint8_t n; /* counter */
unsigned char Des[3]; /* component pin designators */
#ifdef UI_PROBE_COLORS
uint16_t Color; /* color value */
Color = UI.PenColor; /* save current color */
#endif
/* copy probe pin designators */
Des[0] = Des1;
Des[1] = Des2;
Des[2] = Des3;
for (n = 0; n <= 2; n++) /* loop through probe pins */
{
if (Des[n] != 0) /* display this one */
{
Display_ProbeNumber(n);
Display_Colon();
#ifdef UI_PROBE_COLORS
UI.PenColor = ProbeColors[n]; /* set probe color */
#endif
Display_Char(Des[n]);
#ifdef UI_PROBE_COLORS
UI.PenColor = Color; /* restore old color */
#endif
Display_Space();
}
}
}
#ifdef FUNC_EVALUE
/*
* show E series norm values
*
* requires:
* - Value: unsigned value
* - Scale: exponent/multiplier (* 10^n)
* - ESeries: E6-192
* - Tolerance: in 0.1%
* - Unit: unit character
*/
void Show_ENormValues(uint32_t Value, int8_t Scale, uint8_t ESeries, uint8_t Tolerance, unsigned char Unit)
{
uint8_t n; /* number of norm values (1 or 2) */
uint8_t Pos; /* char x position */
uint8_t Temp; /* temporary value */
/*
* get E series norm values
* - 1st: Semi.I_value, Semi.I_scale
* - 2nd: Semi.C_value, Semi.C_scale
*/
n = GetENormValue(Value, Scale, ESeries, Tolerance);
/*
* show E series and tolerance
*/
Display_NextLine(); /* move to next line */
/* display E series */
Display_Char('E'); /* display: E */
Display_FullValue(ESeries, 0 , 0); /* display E series */
Display_Space(); /* display: " " */
/* display tolerance */
Temp = Tolerance; /* copy tolerance */
Pos = 0; /* reset decimal places */
if (Temp < 10) /* < 1% */
{
Pos = 1; /* one decimal place */
}
Temp /= 10; /* scale to 1 */
Display_FullValue(Temp, Pos, '%'); /* display tolerance */
Display_Space(); /* display: " " */
/*
* show norm values
*/
if (n) /* got norm value(s) */
{
Pos = UI.CharPos_X; /* get current char position */
/* display first norm value */
Display_EValue(Semi.I_value, Semi.I_scale, Unit);
if (n == 2) /* got two norm values */
{
/* move to next line at same position (after E series) */
Display_NextLine();
LCD_CharPos(Pos, UI.CharPos_Y);
/* display second norm value */
Display_EValue(Semi.C_value, Semi.C_scale, Unit);
}
}
else /* no norm value */
{
Display_Minus(); /* display: - */
}
}
#endif
#ifdef FUNC_COLORCODE
/*
* show E series norm values as color-code
*
* requires:
* - Value: unsigned value
* - Scale: exponent/multiplier (* 10^n)
* - ESeries: E6-192
* - Tolerance: in 0.1%
* - TolBand: color of tolerance band
*/
void Show_ENormCodes(uint32_t Value, int8_t Scale, uint8_t ESeries, uint8_t Tolerance, uint16_t TolBand)
{
uint8_t n; /* number of norm values (1 or 2) */
uint8_t Pos; /* char x position */
/*
* tolerance band
* - resistor
* 20% 10% 5% 2% 1% 0.5% 0.25% 0.1% 0.05%
* none silver gold red brown green blue violet grey
* - inductor
* 20% 10% 5% 4% 3% 2% 1% 0.5% 0.25% 0.1% 0.05%
* black silver gold yellow orange red brown green blue violet grey
* - caps: many different schemas
*
* multiplier reference
* - R: 0 (10^0) -> 1 Ohms
* C: -12 (10^-12) -> 1 pF
* L: -6 (10^-6) -> 1 µH
* - ref_scale as function argument?
* scale = scale - ref_scale
*/
/*
* get E series norm values
* - 1st: Semi.I_value, Semi.I_scale
* - 2nd: Semi.C_value, Semi.C_scale
*/
n = GetENormValue(Value, Scale, ESeries, Tolerance);
/*
* show E series
*/
Display_NextLine(); /* move to next line */
/* display E series */
Display_Char('E'); /* display: E */
Display_FullValue(ESeries, 0 , 0); /* display E series */
Display_Space(); /* display: " " */
/*
* show color-codes of norm values
*/
if (n) /* got norm value(s) */
{
Pos = UI.CharPos_X; /* get current char position */
/* display color-code of first norm value */
Display_ColorCode(Semi.I_value, Semi.I_scale, TolBand);
if (n == 2) /* got two norm values */
{
/* move to next line at same position (after E series) */
Display_NextLine();
LCD_CharPos(Pos, UI.CharPos_Y);
/* display color-code of second norm value */
Display_ColorCode(Semi.C_value, Semi.C_scale, TolBand);
}
}
else /* no norm value */
{
Display_Minus(); /* display: - */
}
#if 0
/*
* color testing
*/
uint16_t Color;
Display_NextLine();
/* first 5 colors plus gold */
n = 0;
while (n < 5)
{
Color = DATA_read_word((uint16_t *)&ColorCode_table[n]);
LCD_Band(Color, ALIGN_LEFT);
n++;
}
LCD_Band(COLOR_CODE_GOLD, ALIGN_RIGHT);
Display_NextLine();
/* last 5 colors plus silver */
while (n < 10)
{
Color = DATA_read_word((uint16_t *)&ColorCode_table[n]);
LCD_Band(Color, ALIGN_LEFT);
n++;
}
LCD_Band(COLOR_CODE_SILVER, ALIGN_RIGHT);
TestKey(0, CURSOR_BLINK);
#endif
}
#endif
#ifdef FUNC_EIA96
/*
* show E series norm values as EIA-96 code
* - implies E96 1%
*
* requires:
* - Value: unsigned value
* - Scale: exponent/multiplier (* 10^n)
*/
void Show_ENormEIA96(uint32_t Value, int8_t Scale)
{
uint8_t n; /* number of norm values (1 or 2) */
/*
* get E series norm values
* - 1st: Semi.I_value, Semi.I_scale, Semi.A (index number)
* - 2nd: Semi.C_value, Semi.C_scale, Semi.B (index number)
*/
n = GetENormValue(Value, Scale, E96, 10);
/*
* show E series and tolerance
*/
Display_NextLine(); /* move to next line */
/* display E series (E96) */
Display_Char('E'); /* display: E */
Display_FullValue(96, 0, 0); /* display E series */
Display_Space(); /* display: " " */
/* display tolerance (1%) */
Display_FullValue(1, 0, '%'); /* display tolerance */
Display_Space(); /* display: " " */
/*
* show EIA-96 codes of norm values
*/
if (n) /* got norm value(s) */
{
/* display EIA-96 code of first norm value */
Display_EIA96(Semi.A, Semi.I_scale);
if (n == 2) /* got two norm values */
{
Display_Space(); /* display: " " */
/* display EIA-96 code of second norm value */
Display_EIA96(Semi.B, Semi.C_scale);
}
}
else /* no norm value */
{
Display_Minus(); /* display: - */
}
}
#endif
/*
* show failed test
* - no component found
*/
void Show_Fail(void)
{
/* display info */
#ifdef UI_CENTER_ALIGN
Display_CenterLine(2); /* center block: 2 lines */
Display_EEString_Center(Failed1_str); /* display: No component */
Display_NL_EEString_Center(Failed2_str); /* display: found! */
#else
Display_EEString(Failed1_str); /* display: No component */
Display_NL_EEString(Failed2_str); /* display: found! */
#endif
#ifdef UI_QUESTION_MARK
/* display question mark symbol */
Check.Symbol = SYMBOL_QUESTIONMARK; /* set symbol ID */
Display_FancySemiPinout(3); /* show symbol starting in line #3 */
#endif
#if CYCLE_MAX < 255
MissedParts++; /* increase counter */
#endif
}
/*
* show error
*/
void Show_Error()
{
if (Check.Type == TYPE_DISCHARGE) /* discharge failed */
{
/* possibly a voltage source */
Display_EEString(DischargeFailed_str); /* display: Battery? */
/* display probe number and remaining voltage */
Display_NextLine();
Display_ProbeNumber(Check.Probe);
Display_Colon();
Display_Space();
Display_Value(Check.U, -3, 'V');
}
else if (Check.Type == TYPE_DETECTION) /* detection error */
{
/* simply display: No component found! */
Show_Fail();
}
}
#ifdef UI_PROBE_COLORS
/*
* show single (first) resistor
*
* requires:
* - Probe1: probe ID #1 [0-2]
* - Probe2: probe ID #2 [0-2]
* - Mode: 0 for probe ID
* >0 for pin designator
*/
void Show_SingleResistor(uint8_t Probe1, uint8_t Probe2, int8_t Mode)
{
Resistor_Type *Resistor; /* pointer to resistor */
Resistor = &Resistors[0]; /* pointer to first resistor */
/*
* show pinout
*/
if (Mode)
{
Display_SemiPinDesignator(Probe1);
}
else
{
Display_ProbeNumber(Probe1);
}
Display_EEString(Resistor_str);
if (Mode)
{
Display_SemiPinDesignator(Probe2);
}
else
{
Display_ProbeNumber(Probe2);
}
/* show resistance value */
Display_Space();
Display_Value(Resistor->Value, Resistor->Scale, LCD_CHAR_OMEGA);
}
#else
/*
* show single (first) resistor
*
* requires:
* - ID1: pin ID #1 character
* - ID2: pin ID #2 character
*/
void Show_SingleResistor(uint8_t ID1, uint8_t ID2)
{
Resistor_Type *Resistor; /* pointer to resistor */
Resistor = &Resistors[0]; /* pointer to first resistor */
/* show pinout */
Display_Char(ID1);
Display_EEString(Resistor_str);
Display_Char(ID2);
/* show resistance value */
Display_Space();
Display_Value(Resistor->Value, Resistor->Scale, LCD_CHAR_OMEGA);
}
#endif
/*
* show resistor(s)
*/
void Show_Resistor(void)
{
Resistor_Type *R1; /* pointer to resistor #1 */
Resistor_Type *R2; /* pointer to resistor #2 */
uint8_t Pin; /* ID of common pin */
R1 = &Resistors[0]; /* pointer to first resistor */
if (Check.Resistors == 1) /* single resistor */
{
R2 = NULL; /* disable second resistor */
Pin = R1->A; /* make B the first pin */
}
else /* multiple resistors */
{
R2 = R1;
R2++; /* pointer to second resistor */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Quantity = 2; /* got two */
#endif
if (Check.Resistors == 3) /* three resistors */
{
Resistor_Type *Rmax; /* pointer to largest resistor */
/*
* 3 resistors mean 2 single resistors and both resistors in series.
* So we have to single out that series resistor by finding the
* largest resistor.
*/
Rmax = R1; /* starting point */
for (Pin = 1; Pin <= 2; Pin++)
{
if (CmpValue(R2->Value, R2->Scale, Rmax->Value, Rmax->Scale) == 1)
{
Rmax = R2; /* update largest one */
}
R2++; /* next one */
}
/* get the two smaller resistors */
if (R1 == Rmax) R1++;
R2 = R1;
R2++;
if (R2 == Rmax) R2++;
}
/* find common pin of both resistors */
if ((R1->A == R2->A) || (R1->A == R2->B))
{
Pin = R1->A; /* pin A */
}
else
{
Pin = R1->B; /* pin B */
}
}
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Comp1 = (void *)R1; /* link first resistor */
Info.Comp2 = (void *)R2; /* link second resistor */
#endif
/*
* display the resistor(s) and pins in line #1
*/
#ifdef UI_COLORED_TITLES
Display_UseTitleColor(); /* use title color */
#endif
/* first resistor */
if (R1->A != Pin) /* A is not common pin */
{
Display_ProbeNumber(R1->A); /* display pin A */
}
else /* single resistor or A is common pin */
{
Display_ProbeNumber(R1->B); /* display pin B */
}
Display_EEString(Resistor_str);
Display_ProbeNumber(Pin); /* display common pin */
if (R2) /* second resistor */
{
Display_EEString(Resistor_str);
if (R2->A != Pin) /* A is not common pin */
{
Display_ProbeNumber(R2->A); /* display pin A */
}
else /* A is common pin */
{
Display_ProbeNumber(R2->B); /* display pin B */
}
}
#ifdef UI_COLORED_TITLES
Display_UseOldColor(); /* use old color */
#endif
/*
* display the value(s) in line #2
* - optionally inductance
* - optionally E-series norm values
*/
/* first resistor */
Display_NextLine();
Display_Value(R1->Value, R1->Scale, LCD_CHAR_OMEGA);
if (R2) /* second resistor */
{
Display_Space();
Display_Value(R2->Value, R2->Scale, LCD_CHAR_OMEGA);
#ifdef SW_R_TRIMMER
/* potentiometer/trimpot */
uint32_t R_Value; /* value of R1 */
uint32_t Rt_Value; /* value of R_t */
int8_t Scale; /* scale of R1 and R_t */
/* normalize R1 and R2 */
Scale = NormalizeValue(R1->Value, R1->Scale, R2->Value, R2->Scale);
R_Value = RescaleValue(R1->Value, R1->Scale, Scale); /* normalized R1 */
Rt_Value = RescaleValue(R2->Value, R2->Scale, Scale); /* normalized R2 */
Rt_Value += R_Value; /* R2 + R1 */
if (Rt_Value > 0) /* sanity check */
{
/* show sum: R1 + R2 */
Display_NL_EEString_Space(R_t_str); /* display: R_t */
Display_Value(Rt_Value, Scale, LCD_CHAR_OMEGA); /* display sum */
/* show R1 ratio (in %): R1 / (R1 + R2) */
Display_NL_EEString_Space(R1_str); /* display: R1 */
R_Value *= 100; /* for % */
R_Value /= Rt_Value; /* R1 / (R1 + R2) */
Display_Value(R_Value, 0, '%'); /* display ratio in % */
/* show R2 ratio (in %): R2 / (R1 + R2) or 100% - ratio_R1 */
Display_Space(); /* display space */
Display_EEString_Space(R2_str); /* display: R2 */
R_Value = 100 - R_Value; /* 100% - ratio_R1 */
Display_Value(R_Value, 0, '%'); /* display ratio in % */
}
#endif
}
#ifdef SW_INDUCTOR
else /* single resistor */
{
/* get inductance and display if relevant */
if (MeasureInductor(R1) == 1) /* inductor */
{
Display_Space();
Display_Value(Inductor.Value, Inductor.Scale, 'H');
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_R_L; /* inductance measured */
#endif
#ifdef SW_L_E6_T
/* show E series norm values for E6 20% */
Show_ENormValues(Inductor.Value, Inductor.Scale, E6, 200, 'H');
#endif
#ifdef SW_L_E12_T
/* show E series norm values for E12 10% */
Show_ENormValues(Inductor.Value, Inductor.Scale, E12, 100, 'H');
#endif
}
#ifdef SW_R_EXX
else /* no inductance */
{
#ifdef SW_R_E24_5_T
/* show E series norm values for E24 5% */
Show_ENormValues(R1->Value, R1->Scale, E24, 50, LCD_CHAR_OMEGA);
#endif
#ifdef SW_R_E24_5_CC
/* show E series norm value color-codes for E24 5% */
Show_ENormCodes(R1->Value, R1->Scale, E24, 50, COLOR_CODE_GOLD);
#endif
#ifdef SW_R_E24_1_T
/* show E series norm values for E24 1% */
Show_ENormValues(R1->Value, R1->Scale, E24, 10, LCD_CHAR_OMEGA);
#endif
#ifdef SW_R_E24_1_CC
/* show E series norm value color-codes for E24 1% */
Show_ENormCodes(R1->Value, R1->Scale, E24, 10, COLOR_CODE_BROWN);
#endif
#ifdef SW_R_E96_T
/* show E series norm values for E96 1% */
Show_ENormValues(R1->Value, R1->Scale, E96, 10, LCD_CHAR_OMEGA);
#endif
#ifdef SW_R_E96_CC
/* show E series norm value color-codes for E96 1% */
Show_ENormCodes(R1->Value, R1->Scale, E96, 10, COLOR_CODE_BROWN);
#endif
#ifdef SW_R_E96_EIA96
/* show E series norm value EIA-96 codes for E96 1% */
Show_ENormEIA96(R1->Value, R1->Scale);
#endif
}
#endif
}
#elif defined (SW_R_EXX)
else /* single resistor */
{
#ifdef SW_R_E24_5_T
/* show E series norm values for E24 5% */
Show_ENormValues(R1->Value, R1->Scale, E24, 50, LCD_CHAR_OMEGA);
#endif
#ifdef SW_R_E24_5_CC
/* show E series norm value color-codes for E24 5% */
Show_ENormCodes(R1->Value, R1->Scale, E24, 50, COLOR_CODE_GOLD);
#endif
#ifdef SW_R_E24_1_T
/* show E series norm values for E24 1% */
Show_ENormValues(R1->Value, R1->Scale, E24, 10, LCD_CHAR_OMEGA);
#endif
#ifdef SW_R_E24_1_CC
/* show E series norm value color-codes for E24 1% */
Show_ENormCodes(R1->Value, R1->Scale, E24, 10, COLOR_CODE_BROWN);
#endif
#ifdef SW_R_E96_T
/* show E series norm values for E96 1% */
Show_ENormValues(R1->Value, R1->Scale, E96, 10, LCD_CHAR_OMEGA);
#endif
#ifdef SW_R_E96_CC
/* show E series norm value color-codes for E96 1% */
Show_ENormCodes(R1->Value, R1->Scale, E96, 10, COLOR_CODE_BROWN);
#endif
#ifdef SW_R_E96_EIA96
/* show E series norm value EIA-96 codes for E96 1% */
Show_ENormEIA96(R1->Value, R1->Scale);
#endif
}
#endif
}
/*
* show capacitor
*/
void Show_Capacitor(void)
{
Capacitor_Type *MaxCap; /* pointer to largest cap */
Capacitor_Type *Cap; /* pointer to cap */
#if defined (SW_ESR) || defined (SW_OLD_ESR)
uint16_t ESR; /* ESR (in 0.01 Ohms) */
#endif
uint8_t Counter; /* loop counter */
/*
* find largest cap
*/
MaxCap = &Caps[0]; /* pointer to first cap */
Cap = MaxCap;
for (Counter = 1; Counter <= 2; Counter++)
{
Cap++; /* next cap */
if (CmpValue(Cap->Value, Cap->Scale, MaxCap->Value, MaxCap->Scale) == 1)
{
MaxCap = Cap;
}
}
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Comp1 = (void *)MaxCap; /* link largest cap */
#endif
/*
* display cap and pinout in line #1
*/
#ifdef UI_COLORED_TITLES
Display_UseTitleColor(); /* use title color */
#endif
Display_ProbeNumber(MaxCap->A); /* display pin #1 */
Display_EEString(Cap_str); /* display capacitor symbol */
Display_ProbeNumber(MaxCap->B); /* display pin #2 */
#ifdef UI_COLORED_TITLES
Display_UseOldColor(); /* use old color */
#endif
/*
* display capacitance in line #2, optionally ESR
*/
/* display capacitance */
Display_NextLine(); /* move to next line */
Display_Value(MaxCap->Value, MaxCap->Scale, 'F');
#if defined (SW_ESR) || defined (SW_OLD_ESR)
/* measure and display ESR */
ESR = MeasureESR(MaxCap); /* measure ESR */
if (ESR < UINT16_MAX) /* if successful */
{
Display_Space();
Display_Value(ESR, -2, LCD_CHAR_OMEGA); /* display ESR */
}
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Val1 = ESR; /* copy ESR */
#endif
#endif
/*
* display additional stuff
*/
/* display self-discharge equivalent leakage current */
if (MaxCap->I_leak_Value > 0) /* got value */
{
Display_NL_EEString_Space(I_leak_str);
Display_Value(MaxCap->I_leak_Value, MaxCap->I_leak_Scale, 'A'); /* in A */
}
#ifdef SW_C_VLOSS
/* display self-discharge voltage loss in % */
if (MaxCap->U_loss > 0) /* got value */
{
Display_NL_EEString_Space(U_loss_str);
Display_Value(MaxCap->U_loss, -1, '%'); /* in 0.1% */
}
#endif
#ifdef SW_C_E6_T
/* show E series norm values for E6 20% */
Show_ENormValues(MaxCap->Value, MaxCap->Scale, E6, 200, 'F');
#endif
#ifdef SW_C_E12_T
/* show E series norm values for E12 10% */
Show_ENormValues(MaxCap->Value, MaxCap->Scale, E12, 100, 'F');
#endif
}
/*
* show current (leakage or whatever) of semiconductor
*
* Mapping for Semi structure:
* - I_value - current
* - I_scale - scale for current (10^x)
*/
void Show_SemiCurrent(const unsigned char *String)
{
if (CmpValue(Semi.I_value, Semi.I_scale, 50, -9) >= 0) /* show if >=50nA */
{
Display_NL_EEString_Space(String); /* display: <string> */
Display_Value(Semi.I_value, Semi.I_scale, 'A'); /* display current */
}
}
#ifndef UI_SERIAL_COMMANDS
/*
* display capacitance of a diode
*
* requires:
* - pointer to diode structure
*/
void Show_Diode_Cap(Diode_Type *Diode)
{
/* get capacitance (reversed direction) */
MeasureCap(Diode->C, Diode->A, 0);
/* and show capacitance */
Display_Value(Caps[0].Value, Caps[0].Scale, 'F');
}
#endif
/*
* show flyback diode of 3-pin semiconductor and pin designators
* - convenience function to reduce firmware size
*
* requires:
* - Anode: probe ID of anode [0-2]
* - Cathode: probe ID of cathode [0-2]
*/
void Show_SemiFlybackDiode(uint8_t Anode, uint8_t Cathode)
{
Display_SemiPinDesignator(Anode); /* designator for anode side */
Display_Char(LCD_CHAR_DIODE_AC); /* diode symbol |>| */
Display_SemiPinDesignator(Cathode); /* designator for cathode side */
}