-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathCommand.h
More file actions
205 lines (182 loc) · 4.25 KB
/
Copy pathCommand.h
File metadata and controls
205 lines (182 loc) · 4.25 KB
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
//////////////////////////////////////////////////////////////////////////////
//
// Filename: Command.h
// Version:
// Data:
//
// Author: Liu, Zemin
// Company: JYE Tech
//
//-----------------------------------------------------------------------------
//
// Target: STM32F103C8
// Tool chain: CodeSourcery G++
//
//-----------------------------------------------------------------------------
// Required files:
//
//-----------------------------------------------------------------------------
// Notes:
//
//
//-----------------------------------------------------------------------------
// Revision History:
//
///////////////////////////////////////////////////////////////////////////////
//
//
#ifndef Command_h
#define Command_h
#include "Common.h"
// ============== Key Analysis Definitions =====================
typedef struct {
// Keypad processing variables
U16 Flags;
U16 KScanBuf;
U16 KScanCode;
U16 KeyCode;
U16 KeyParam;
U16 KeyCodeBuf;
U16 KCount; // Key debounce counter
U16 KDebounceVal; // Debounce timing length (number of scans)
U16 KHCount; // Key hold counter
U16 KTimeChk; // Key time check
U16 EncState;
} KEYPAD;
enum KeypadFlags {
KF_DoKeyScan = 0,
KF_PressDetected = 1,
KF_HoldDetected = 2,
KF_KeyHit = 3,
};
// -- Key-Event mapping
typedef struct {
U8 Keycode;
U8 Event;
}KeyEvent ;
// -- Key code conversion
typedef struct {
U16 ScanCode;
U8 Keycode;
}KeyMap ;
// --------------------------------------
// Keypad
typedef struct {
U16 ScanCode;
U8 KeyCode;
U8 KeyParam;
}KeyScanCode;
// -- Key Code Definitions
enum KeyCodes {
KC_void = 0,
KC_SW1,
KC_SW2,
KC_SW3,
KC_SW4,
KC_SW1H,
KC_SW2H,
KC_SW3H,
KC_SW4H,
KC_SW1_SW4,
KC_SW2_SW4,
KC_SW3_SW4,
KC_SW2_SW3,
KC_SW2_SW3H,
KC_ENC_CW,
KC_ENC_CCW,
KC_ENC_PB,
KC_ENC_PBH,
KC_PB_SW1,
KC_PB_SW2,
KC_PB_SW3,
KC_PB_SW4,
};
// Pushbutton processing parameters
#define NoKey 0xFFFF
#define KD_val 6 //
#define KD_val1 15 //
#define KH_val 90 //
#define KR_Time 3
// Add-ons
enum AddOn {
AO_MeasurementOn = 0,
AO_TestSigAmp = 1, // 0 - normal (3.3V), 1 - 0.1V
AO_TestSigAmpDisp = 2,
};
// Setting status
#define SettingStatus_Initialized 0xF3A5
#define VoltageReadingx0 205
#define VoltageReadingy0 20
#define FreqReadingx0 15
#define FreqReadingy0 20
#define TestSigAmpx0 15
#define TestSigAmpy0 (WWindowy0 + WWindowSizey - 20)
#define Flag_MeasurementOn 0
#define Flag_FreqValid 1
#define Flag_VoltValid 2
#define Flag_FreqAreaCleared 3
#define Waveform_START_ADDRESS ((uint32_t)0x0800E000)
#define Parameter_START_ADDRESS ((uint32_t)0x0800E800)
// ===========================================================
// Export variables
// ===========================================================
//
extern U16 AddOns;
extern KEYPAD Keypad;
extern S16 Vmax;
extern S16 Vmin;
extern S16 Vavr;
extern S16 Vpp;
extern S16 Vrms;
extern U8 ReadingStr[];
extern U8 MeasurementOn;
extern float Freq;
extern float Cycle;
extern float PW;
extern float Duty;
extern U16 Flags;
extern U16 FreqUnit;
extern U16 CycleUnit;
extern U16 FreqStrLen;
extern U16 CycleStrLen;
extern U16 PwStrLen;
extern U8 *UnitsStr[8];
// ===========================================================
// Function Declarations
// ===========================================================
//
void AppInit();
void LoadDefault(void);
void KeyScan(void);
void KeyConvert(KeyScanCode *KSCTab, U16 KSCode);
U8 KeyEventMap(U8 keycode, KeyEvent *kvmap);
void KeyProc(void);
void DoKeyOk(void);
void DoKeyInc(void);
void DoKeyDec(void);
void DoKeySel(void);
void DoKeyOkH(void);
void DoKeyIncH(void);
void DoKeyDecH(void);
void DoKeySelH(void);
void SelVertical(void);
void SelHorzontal(void);
void SelTrigger(void);
void VPosAlign(void);
void CenterHPos(void);
void CenterTrigLevel(void);
void LedBlink(void);
void LedBlink_Fast(void);
void TestMode(void);
void SaveWaveform(void);
void LoadWaveform(void);
void Measurements(void);
void OnScreenDisplay(void);
void TestSigAmpDisplay(void);
U8 *VoltToStr(S16 volt, U8 *strbuf);
U8 *BinToDecStr16(U16 binary, U8 *Str);
U8 *BinToDec32(U32 binary, U8 *Str);
U32 FindDec(U32 bin, U8 ind, U8 *str);
void DeZero(U8 *str, U8 num, U8 ch);
U8 *FloatToStr(float f, U8 width, U8 precision, U8 *str);
#endif