-
Notifications
You must be signed in to change notification settings - Fork 13
/
menuSystem.cpp
139 lines (117 loc) · 3.14 KB
/
menuSystem.cpp
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
/*
*/
#include "../../SPI/src/SPI.h"
#include "fancyLock.h"
#include "testPins.h"
#include "allComponents.h"
#include "dso_adc.h"
#include "testerGfx.h"
#include "testerControl.h"
#include "componentSignature.h"
#include "cpuID.h"
#include "pinConfiguration.h"
#include "dso_menuEngine.h"
#include "testerVersion.h"
/**
*/
extern TestPin pin1,pin2,pin3;
void wipeCal()
{
NVM::reset();
}
/**
*
*/
void swInfo()
{
TesterGfx::clear();
TesterGfx::topLine("Info");
char st[20];
sprintf(st,"v%2.2f",TESTER_VERSION);
TesterGfx::printSmall(10,40,st);
TesterGfx::printSmall(10,80,cpuID::getIdAsString());
const char *build="??";
#ifdef MCU_GD32F103C8
build="GD32F1";
#elif MCU_GD32F303C8
build="GD32F3";
#elif MCU_STM32F103C8
build="STM32F1";
#elif
#error
#endif
TesterGfx::printSmall(10,60,build);
TesterGfx::bottomLine("Press Ok");
TesterControl::waitForAnyEvent();
}
/**
*
*/
static void fmtLine(const char *patt,int up, int down, int line)
{
char st[60];
sprintf(st,patt,up, down);
TesterGfx::print(1,line,st);
}
#define ZINTER(x) (32+18*x)
void calibrationInfo()
{
TesterGfx::clear();
TesterGfx::topLine("Calibration-R");
//#define ALLRES(x) {sprintf(st,"RU:%d:RD:%d",pin##x._calibration.resUp,pin##x._calibration.resUp);TesterGfx::print(1,ZINTER(x-1),st);}
#define ALLRES(x) {fmtLine("RU:%d:RD:%d",pin##x._calibration.resUp,pin##x._calibration.resUp,ZINTER(x-1));;}
ALLRES(1);
ALLRES(2);
ALLRES(3);
TesterGfx::bottomLine("Press Ok");
TesterControl::waitForAnyEvent();
TesterGfx::clear();
TesterGfx::topLine("Calibration-C");
#undef ALLRES
//#define ALLRES(x) {sprintf(st,"Ch:%d:Cl:%d",pin##x._calibration.capOffsetInPf,pin##x._calibration.capOffsetHighInPfMu16[0]/16);TesterGfx::print(1,ZINTER(x-1),st);}
#define ALLRES(x) {fmtLine("Ch:%d:Cl:%d",pin##x._calibration.capOffsetInPf,pin##x._calibration.capOffsetHighInPfMu16[0]/16,ZINTER(x-1));}
ALLRES(1);
ALLRES(2);
ALLRES(3);
TesterGfx::bottomLine("Press Ok");
TesterControl::waitForAnyEvent();
}
/**
*
*/
#define SHOW(x) {TesterGfx::x;TesterControl::waitForAnyEvent();}
void showIcons()
{
SHOW(drawDiode(0, "x",1,3));
SHOW(drawCoil(0, "x",1,2));
SHOW(drawCapacitor(0, "x",1,2));
SHOW(drawResistor(0, "x",1,2));
SHOW(drawPMosFet( 1,2,3));
SHOW(drawNMosFet(1,2,3));
SHOW(drawMosInfo(0, 1.0, 1.0,1.0, 1.0));
SHOW(drawNPN(100,1,1,2,3));
SHOW(drawPNP(100,1,1,2,3));
}
/**
*/
const MenuItem topMenu[]={
{MenuItem::MENU_TITLE, "Main Menu",NULL},
{MenuItem::MENU_CALL, "Info",(const void *)swInfo},
{MenuItem::MENU_CALL, "Icons",(const void *)showIcons},
{MenuItem::MENU_CALL, "Show cal.",(const void *)calibrationInfo},
{MenuItem::MENU_CALL, "Wipe cal",(const void *)&wipeCal},
{MenuItem::MENU_END, NULL,NULL}
};
/**
*
*/
void menuSystem(void)
{
const MenuItem *tem=topMenu;
// clear events if any
TesterControl::clearEvent();
TesterControl::clearEvent();
MenuManager man(tem);
man.run();
return;
}