提交 | 用户 | age
|
418cb3
|
1 |
|
Q |
2 |
// LCDDisplayDlg.cpp: 实现文件
|
|
3 |
//
|
|
4 |
|
|
5 |
#include "pch.h"
|
|
6 |
#include "framework.h"
|
|
7 |
#include "LCDDisplayTest.h"
|
|
8 |
#include "LCDDisplayTestDlg.h"
|
|
9 |
#include "afxdialogex.h"
|
|
10 |
#include "../MyLib/Functions.hpp"
|
|
11 |
#ifdef _DEBUG
|
|
12 |
#define new DEBUG_NEW
|
|
13 |
#endif
|
|
14 |
|
|
15 |
|
|
16 |
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
|
|
17 |
|
|
18 |
class CAboutDlg : public CDialogEx
|
|
19 |
{
|
|
20 |
public:
|
|
21 |
CAboutDlg();
|
|
22 |
|
|
23 |
// 对话框数据
|
|
24 |
#ifdef AFX_DESIGN_TIME
|
|
25 |
enum { IDD = IDD_ABOUTBOX };
|
|
26 |
#endif
|
|
27 |
|
|
28 |
protected:
|
|
29 |
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
|
30 |
|
|
31 |
// 实现
|
|
32 |
protected:
|
|
33 |
DECLARE_MESSAGE_MAP()
|
|
34 |
};
|
|
35 |
|
|
36 |
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
|
41 |
{
|
|
42 |
CDialogEx::DoDataExchange(pDX);
|
|
43 |
}
|
|
44 |
|
|
45 |
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
|
|
46 |
END_MESSAGE_MAP()
|
|
47 |
|
|
48 |
|
|
49 |
// CLCDDisplayTestDlg 对话框
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
CLCDDisplayTestDlg::CLCDDisplayTestDlg(CWnd* pParent /*=nullptr*/)
|
|
54 |
: CDialogEx(IDD_LCDDISPLAY_DIALOG, pParent)
|
|
55 |
{
|
|
56 |
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
57 |
}
|
|
58 |
|
|
59 |
void CLCDDisplayTestDlg::DoDataExchange(CDataExchange* pDX)
|
|
60 |
{
|
|
61 |
CDialogEx::DoDataExchange(pDX);
|
|
62 |
DDX_Control(pDX, IDC_STATIC_DISPLAY, m_lcd_display);
|
|
63 |
DDX_Control(pDX, IDC_MFCCOLORBUTTON1, m_color_button1);
|
|
64 |
DDX_Control(pDX, IDC_MFCCOLORBUTTON2, m_color_button2);
|
|
65 |
}
|
|
66 |
|
|
67 |
BEGIN_MESSAGE_MAP(CLCDDisplayTestDlg, CDialogEx)
|
|
68 |
ON_WM_SYSCOMMAND()
|
|
69 |
ON_WM_PAINT()
|
|
70 |
ON_WM_QUERYDRAGICON()
|
|
71 |
ON_BN_CLICKED(IDC_BUTTON1, &CLCDDisplayTestDlg::OnBnClickedButton1)
|
|
72 |
ON_BN_CLICKED(IDC_BUTTON2, &CLCDDisplayTestDlg::OnBnClickedButton2)
|
|
73 |
ON_BN_CLICKED(IDC_BUTTON3, &CLCDDisplayTestDlg::OnBnClickedButton3)
|
|
74 |
ON_BN_CLICKED(IDC_BUTTON4, &CLCDDisplayTestDlg::OnBnClickedButton4)
|
|
75 |
ON_BN_CLICKED(IDC_BUTTON5, &CLCDDisplayTestDlg::OnBnClickedButton5)
|
|
76 |
ON_BN_CLICKED(IDC_BUTTON6, &CLCDDisplayTestDlg::OnBnClickedButton6)
|
|
77 |
ON_BN_CLICKED(IDC_BUTTON_CONVERT, &CLCDDisplayTestDlg::OnBnClickedButtonConvert)
|
|
78 |
ON_BN_CLICKED(IDC_BUTTON_CLEAR, &CLCDDisplayTestDlg::OnBnClickedButtonClear)
|
|
79 |
ON_WM_TIMER()
|
|
80 |
ON_BN_CLICKED(IDC_BUTTON7, &CLCDDisplayTestDlg::OnBnClickedButton7)
|
|
81 |
ON_BN_CLICKED(IDC_BUTTON8, &CLCDDisplayTestDlg::OnBnClickedButton8)
|
|
82 |
END_MESSAGE_MAP()
|
|
83 |
|
|
84 |
|
|
85 |
// CLCDDisplayTestDlg 消息处理程序
|
|
86 |
|
|
87 |
BOOL CLCDDisplayTestDlg::OnInitDialog()
|
|
88 |
{
|
|
89 |
CDialogEx::OnInitDialog();
|
|
90 |
|
|
91 |
// 将“关于...”菜单项添加到系统菜单中。
|
|
92 |
|
|
93 |
// IDM_ABOUTBOX 必须在系统命令范围内。
|
|
94 |
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
|
95 |
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
96 |
|
|
97 |
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
|
98 |
if (pSysMenu != nullptr)
|
|
99 |
{
|
|
100 |
BOOL bNameValid;
|
|
101 |
CString strAboutMenu;
|
|
102 |
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
|
|
103 |
ASSERT(bNameValid);
|
|
104 |
if (!strAboutMenu.IsEmpty())
|
|
105 |
{
|
|
106 |
pSysMenu->AppendMenu(MF_SEPARATOR);
|
|
107 |
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
|
108 |
}
|
|
109 |
}
|
|
110 |
|
|
111 |
// 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
|
|
112 |
// 执行此操作
|
|
113 |
SetIcon(m_hIcon, TRUE); // 设置大图标
|
|
114 |
SetIcon(m_hIcon, FALSE); // 设置小图标
|
|
115 |
|
|
116 |
// TODO: 在此添加额外的初始化代码
|
|
117 |
SetTimer(0, 20, NULL);
|
|
118 |
SetTimer(1, 100, NULL);
|
|
119 |
|
|
120 |
m_lcd_display.displayarray[1][2] = 1;
|
|
121 |
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
|
122 |
}
|
|
123 |
|
|
124 |
void CLCDDisplayTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
125 |
{
|
|
126 |
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
|
127 |
{
|
|
128 |
CAboutDlg dlgAbout;
|
|
129 |
dlgAbout.DoModal();
|
|
130 |
}
|
|
131 |
else
|
|
132 |
{
|
|
133 |
CDialogEx::OnSysCommand(nID, lParam);
|
|
134 |
}
|
|
135 |
}
|
|
136 |
|
|
137 |
// 如果向对话框添加最小化按钮,则需要下面的代码
|
|
138 |
// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
|
|
139 |
// 这将由框架自动完成。
|
|
140 |
|
|
141 |
void CLCDDisplayTestDlg::OnPaint()
|
|
142 |
{
|
|
143 |
if (IsIconic())
|
|
144 |
{
|
|
145 |
CPaintDC dc(this); // 用于绘制的设备上下文
|
|
146 |
|
|
147 |
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
|
148 |
|
|
149 |
// 使图标在工作区矩形中居中
|
|
150 |
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
151 |
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
152 |
CRect rect;
|
|
153 |
GetClientRect(&rect);
|
|
154 |
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
155 |
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
156 |
|
|
157 |
// 绘制图标
|
|
158 |
dc.DrawIcon(x, y, m_hIcon);
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
CDialogEx::OnPaint();
|
|
163 |
}
|
|
164 |
}
|
|
165 |
|
|
166 |
//当用户拖动最小化窗口时系统调用此函数取得光标
|
|
167 |
//显示。
|
|
168 |
HCURSOR CLCDDisplayTestDlg::OnQueryDragIcon()
|
|
169 |
{
|
|
170 |
return static_cast<HCURSOR>(m_hIcon);
|
|
171 |
}
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
void CLCDDisplayTestDlg::OnBnClickedButton1()
|
|
176 |
{
|
|
177 |
|
|
178 |
// TODO: 在此添加控件通知处理程序代码
|
|
179 |
m_lcd_display.Clear();
|
|
180 |
}
|
|
181 |
char str1[] = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
|
|
182 |
|
|
183 |
unsigned int font3_5[128] =
|
|
184 |
{
|
|
185 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
186 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
187 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x007720,0x002770, // ▲▼
|
|
188 |
|
|
189 |
0x000000,0x020222,0x000055,0x017574,0x036736,0x051245,0x053730,0x000122, // ! " # $ % & '
|
|
190 |
0x021112,0x024442,0x052725,0x022722,0x012200,0x000700,0x020000,0x012244, // ( ) * + , - . /
|
|
191 |
0x075557,0x022222,0x071747,0x074747,0x044755,0x074717,0x075717,0x044557, // 0 1 2 3 4 5 6 7
|
|
192 |
0x075757,0x074757,0x002020,0x012020,0x042124,0x007070,0x012421,0x020452, // 8 9 : ; < = > ?
|
|
193 |
0x025752,0x055752,0x035353,0x071117,0x035553,0x071717,0x011717,0x075517, // @ A B C D E F G
|
|
194 |
0x055755,0x072227,0x032227,0x055355,0x071111,0x055575,0x055535,0x025552, // H I J K L M N O
|
|
195 |
0x011353,0x065552,0x055353,0x034216,0x022227,0x075555,0x025555,0x057555, // P Q R S T U V W
|
|
196 |
0x055255,0x022255,0x071247,0x071117,0x042211,0x074447,0x000052,0x070000, // X Y Z [ \ ] ^ _
|
|
197 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
198 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
199 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
200 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,
|
|
201 |
};
|
|
202 |
|
|
203 |
unsigned long long font5_7[128] =
|
|
204 |
{
|
|
205 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
206 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
207 |
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ▲▼
|
|
208 |
|
|
209 |
0x000000000000,0x00400410e384,0x00000000a6db,0x00015f29f500, // ! " #
|
|
210 |
0x0043d4385784,0x0186421084c3,0x016255085080,0x00000000430c, // $ % & '
|
|
211 |
0x004081041084,0x004210410204,0x0112847c4291,0x0001047c4100, // ( ) * +
|
|
212 |
0x00230c000000,0x0000007c0000,0x00c300000000,0x000042108400, // , - . /
|
|
213 |
|
|
214 |
// ,
|
|
215 |
0x00e45355944e,0x00e104104184,0x01f08421044e,0x00e45039044e, // 0 1 2 3
|
|
216 |
0x01e21f24a308,0x00e45040f05f,0x00e4513c108c,0x00410410841f, // 4 5 6 7
|
|
217 |
0x00e45139144e,0x00e41079144e,0x00030c00c300,0x00330c00c300, // 8 9 : ;
|
|
218 |
0x008102042108,0x00001f01f000,0x002108408102,0x00400421044e, // < = > ?
|
|
219 |
0x01e04d55544e,0x01145f451284,0x00f4513d144f,0x00e44104144e, // @ A B C
|
|
220 |
0x00f45145144f,0x01f0413c105f,0x0010413c105f,0x00e45174144e, // D E F G
|
|
221 |
0x0114517d1451,0x00e10410410e,0x00614410410e,0x0112450c5251, // H I J K
|
|
222 |
0x01f041041041,0x0114555556d1,0x011459553451,0x00e45145144e, // L M N O
|
|
223 |
0x0010413d144f,0x01625545144e,0x0112453d144f,0x00e45038144e, // P Q R S
|
|
224 |
0x00410410411f,0x00e451451451,0x004291451451,0x00a555551451, // T U V W
|
|
225 |
0x01144a10a451,0x00410410a451,0x01f04210841f,0x00e08208208e, // X Y Z [
|
|
226 |
0x000408102040,0x00e20820820e,0x000000011284,0x01f000000000, // \ ] ^ _
|
|
227 |
0x000000204082,0x00058924e000,0x0003d144f041,0x00038104e000, // ` a b c
|
|
228 |
0x00079145e410,0x0003817d1380,0x00208208f08c,0x00620e249380, // d e f g
|
|
229 |
0x000249247041,0x000384106004,0x00614410e004,0x0002450c5241, // h i j k
|
|
230 |
0x000382082082,0x000451555280,0x0002492491c0,0x000391451380, // l m n o
|
|
231 |
0x0010472491c0,0x00820e249380,0x000082092340,0x000390302700, // p q r s
|
|
232 |
0x00070411e100,0x000389249000,0x000085249000,0x000295551000, // t u v w
|
|
233 |
0x00024a1c9000,0x00620e28a000,0x0003c210f000,0x008104084108, // x y z {
|
|
234 |
0x004104004104,0x002104204102,0x000000000352,0x000000000000, // | } ~
|
|
235 |
};
|
|
236 |
|
|
237 |
char str2[] = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
|
238 |
|
|
239 |
void CLCDDisplayTestDlg::OnBnClickedButton2()
|
|
240 |
{
|
|
241 |
// TODO: 在此添加控件通知处理程序代码
|
|
242 |
//m_lcd_display.displayarray[3][4] = 1;
|
|
243 |
//5*3 (6*4)
|
|
244 |
m_lcd_display.Clear();
|
|
245 |
int l = strlen(str1);
|
|
246 |
for (int i = 0; i < 10; i++)
|
|
247 |
{
|
|
248 |
for (int j = 0; j < 32; j++)
|
|
249 |
{
|
|
250 |
int index = (i * 32 + j) % l;
|
|
251 |
|
|
252 |
char ch = str1[index];
|
|
253 |
int dots = font3_5[ch];
|
|
254 |
|
|
255 |
for (int m = 0; m < 5; m++)
|
|
256 |
{
|
|
257 |
int line = dots & 0xf;
|
|
258 |
int mask = 1;
|
|
259 |
for (int n = 0; n < 3; n++)
|
|
260 |
{
|
|
261 |
if (line&mask)
|
|
262 |
{
|
|
263 |
m_lcd_display.displayarray[i * 6 + m][j * 4 + n] = 1;
|
|
264 |
}
|
|
265 |
mask <<= 1;
|
|
266 |
|
|
267 |
}
|
|
268 |
dots >>= 4;
|
|
269 |
}
|
|
270 |
}
|
|
271 |
}
|
|
272 |
m_lcd_display.RedrawWindow();
|
|
273 |
|
|
274 |
}
|
|
275 |
|
|
276 |
|
|
277 |
void CLCDDisplayTestDlg::OnBnClickedButton3()
|
|
278 |
{
|
|
279 |
// TODO: 在此添加控件通知处理程序代码
|
|
280 |
//7*5 (8*6)
|
|
281 |
m_lcd_display.Clear();
|
|
282 |
int l = strlen(str2);
|
|
283 |
for (int i = 0; i < 8; i++)
|
|
284 |
{
|
|
285 |
for (int j = 0; j < 21; j++)
|
|
286 |
{
|
|
287 |
int index = (i * 21 + j) % l;
|
|
288 |
|
|
289 |
char ch = str2[index];
|
|
290 |
long long dots = font5_7[ch];
|
|
291 |
|
|
292 |
for (int m = 0; m < 7; m++)
|
|
293 |
{
|
|
294 |
int line = dots & 0x3f;
|
|
295 |
int mask = 1;
|
|
296 |
for (int n = 0; n < 5; n++)
|
|
297 |
{
|
|
298 |
if (line&mask)
|
|
299 |
{
|
|
300 |
m_lcd_display.displayarray[i * 8 + m][j * 6 + n] = 1;
|
|
301 |
}
|
|
302 |
mask <<= 1;
|
|
303 |
}
|
|
304 |
dots >>= 6;
|
|
305 |
}
|
|
306 |
}
|
|
307 |
}
|
|
308 |
m_lcd_display.RedrawWindow();
|
|
309 |
|
|
310 |
}
|
|
311 |
|
|
312 |
|
|
313 |
void CLCDDisplayTestDlg::OnBnClickedButton4()
|
|
314 |
{
|
|
315 |
// TODO: 在此添加控件通知处理程序代码
|
|
316 |
//12*7 (13*8)
|
|
317 |
m_lcd_display.Clear();
|
|
318 |
for (int i = 0; i < 5; i++)
|
|
319 |
{
|
|
320 |
for (int j = 0; j < 16; j++)
|
|
321 |
{
|
|
322 |
for (int m = 0; m < 12; m++)
|
|
323 |
{
|
|
324 |
for (int n = 0; n < 7; n++)
|
|
325 |
{
|
|
326 |
m_lcd_display.displayarray[i * 13 + m][j * 8 + n] = 1;
|
|
327 |
|
|
328 |
}
|
|
329 |
}
|
|
330 |
}
|
|
331 |
}
|
|
332 |
m_lcd_display.RedrawWindow();
|
|
333 |
}
|
|
334 |
|
|
335 |
|
|
336 |
void CLCDDisplayTestDlg::OnBnClickedButton5()
|
|
337 |
{
|
|
338 |
// TODO: 在此添加控件通知处理程序代码
|
|
339 |
//15*7 (16*8)
|
|
340 |
m_lcd_display.Clear();
|
|
341 |
for (int i = 0; i < 4; i++)
|
|
342 |
{
|
|
343 |
for (int j = 0; j < 16; j++)
|
|
344 |
{
|
|
345 |
for (int m = 0; m < 15; m++)
|
|
346 |
{
|
|
347 |
for (int n = 0; n < 7; n++)
|
|
348 |
{
|
|
349 |
m_lcd_display.displayarray[i * 16 + m][j * 8 + n] = 1;
|
|
350 |
|
|
351 |
}
|
|
352 |
}
|
|
353 |
}
|
|
354 |
}
|
|
355 |
m_lcd_display.RedrawWindow();
|
|
356 |
}
|
|
357 |
|
|
358 |
|
|
359 |
void CLCDDisplayTestDlg::OnBnClickedButton6()
|
|
360 |
{
|
|
361 |
char aa[] = "12";
|
|
362 |
m_lcd_display.SetTextMode(LCDDisplay1::TextMode5_7);
|
|
363 |
m_lcd_display.putText(aa);
|
|
364 |
m_lcd_display.putText(str2);
|
|
365 |
|
|
366 |
m_lcd_display.RedrawWindow();
|
|
367 |
// TODO: 在此添加控件通知处理程序代码
|
|
368 |
}
|
|
369 |
|
|
370 |
DWORD dlgitemIDs[48] = {
|
|
371 |
IDC_CHECK1,IDC_CHECK2,IDC_CHECK3,IDC_CHECK4,IDC_CHECK5,IDC_CHECK6,
|
|
372 |
IDC_CHECK7,IDC_CHECK8,IDC_CHECK9,IDC_CHECK10,IDC_CHECK11,IDC_CHECK12,
|
|
373 |
IDC_CHECK13,IDC_CHECK14,IDC_CHECK15,IDC_CHECK16,IDC_CHECK17,IDC_CHECK18,
|
|
374 |
IDC_CHECK19,IDC_CHECK20,IDC_CHECK21,IDC_CHECK22,IDC_CHECK23,IDC_CHECK24,
|
|
375 |
IDC_CHECK25,IDC_CHECK26,IDC_CHECK27,IDC_CHECK28,IDC_CHECK29,IDC_CHECK30,
|
|
376 |
IDC_CHECK31,IDC_CHECK32,IDC_CHECK33,IDC_CHECK34,IDC_CHECK35,IDC_CHECK36,
|
|
377 |
IDC_CHECK37,IDC_CHECK38,IDC_CHECK39,IDC_CHECK40,IDC_CHECK41,IDC_CHECK42,
|
|
378 |
IDC_CHECK43,IDC_CHECK44,IDC_CHECK45,IDC_CHECK46,IDC_CHECK47,IDC_CHECK48
|
|
379 |
};
|
|
380 |
|
|
381 |
static int xtoi(const char * hexstr, int len)
|
|
382 |
{
|
|
383 |
int len1 = len;
|
|
384 |
if (len <= 0) len1 = (int)strlen(hexstr);
|
|
385 |
int j = 0;
|
|
386 |
for (int i = 0; i < len1; i++)
|
|
387 |
{
|
|
388 |
unsigned char ch = hexstr[i];
|
|
389 |
if (ch >= '0'&&ch <= '9') { int k = ch - '0'; j = j * 16 + k; continue; }
|
|
390 |
if (ch >= 'A'&&ch <= 'F') { int k = ch - 'A' + 10; j = j * 16 + k; continue; }
|
|
391 |
if (ch >= 'a'&&ch <= 'f') { int k = ch - 'a' + 10; j = j * 16 + k; continue; }
|
|
392 |
if (ch == ' ' || ch == ' ') { continue; }
|
|
393 |
break;
|
|
394 |
}
|
|
395 |
return j;
|
|
396 |
}
|
|
397 |
|
|
398 |
static unsigned char reversebyte(unsigned char b) {
|
|
399 |
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
|
400 |
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
|
401 |
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
|
402 |
return b;
|
|
403 |
}
|
|
404 |
void CLCDDisplayTestDlg::OnBnClickedButtonConvert()
|
|
405 |
{
|
|
406 |
// TODO: 在此添加控件通知处理程序代码
|
|
407 |
long long fontdots = 0;
|
|
408 |
unsigned char dots[48];
|
|
409 |
for (int i = 0; i < 48; i++)
|
|
410 |
{
|
|
411 |
fontdots <<= 1;
|
|
412 |
dots[i]= ((CButton *)GetDlgItem(dlgitemIDs[47-i]))->GetCheck();
|
|
413 |
if (dots[i]) fontdots|= 1;
|
|
414 |
}
|
|
415 |
CString s1;
|
|
416 |
s1.Format(_T("0x%04x%08x"), fontdots>>32, fontdots);
|
|
417 |
GetDlgItem(IDC_EDIT_HEX)->SetWindowText(s1);
|
|
418 |
}
|
|
419 |
|
|
420 |
|
|
421 |
void CLCDDisplayTestDlg::OnBnClickedButtonClear()
|
|
422 |
{
|
|
423 |
// TODO: 在此添加控件通知处理程序代码
|
|
424 |
for (int i = 0; i < 48; i++)
|
|
425 |
{
|
|
426 |
((CButton *)GetDlgItem(dlgitemIDs[i]))->SetCheck(0);
|
|
427 |
}
|
|
428 |
|
|
429 |
}
|
|
430 |
|
|
431 |
|
|
432 |
void CLCDDisplayTestDlg::OnTimer(UINT_PTR nIDEvent)
|
|
433 |
{
|
|
434 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
435 |
if (nIDEvent == 0)
|
|
436 |
{
|
|
437 |
KillTimer(0);
|
|
438 |
DelayInit();
|
|
439 |
}
|
|
440 |
else if (nIDEvent == 1)
|
|
441 |
{
|
|
442 |
UpdateDisplay();
|
|
443 |
}
|
|
444 |
else
|
|
445 |
{
|
|
446 |
|
|
447 |
}
|
|
448 |
CDialogEx::OnTimer(nIDEvent);
|
|
449 |
}
|
|
450 |
|
|
451 |
|
|
452 |
int CLCDDisplayTestDlg::DelayInit()
|
|
453 |
{
|
|
454 |
// TODO: 在此处添加实现代码.
|
|
455 |
return 0;
|
|
456 |
}
|
|
457 |
char str3[] = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ";
|
|
458 |
char str4[] = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~_";
|
|
459 |
|
|
460 |
int CLCDDisplayTestDlg::UpdateDisplay()
|
|
461 |
{
|
|
462 |
// TODO: 在此处添加实现代码.
|
|
463 |
static int nCount = 0;
|
|
464 |
CStringA sa;
|
|
465 |
CStringA sb;
|
|
466 |
CTime time1;
|
|
467 |
time1 = time1.GetTickCount();
|
|
468 |
|
|
469 |
int hour=0, min=0, sec=0;
|
|
470 |
hour=time1.GetHour(), min=time1.GetMinute(), sec=time1.GetSecond();
|
|
471 |
char aa[] = "12";
|
|
472 |
char bb[] = " ";
|
|
473 |
|
|
474 |
// m_lcd_display.Clear(false);
|
|
475 |
// m_lcd_display.SetTextMode(LCDDisplay1::TextMode5_7);
|
|
476 |
|
|
477 |
nCount += 1;
|
|
478 |
static int lastsec = 0;
|
|
479 |
|
|
480 |
if (sec != lastsec) {
|
|
481 |
sa.Format("%02d:%02d:%02d", hour,min,sec);
|
|
482 |
m_lcd_display.putTextXY(13,4, sa);
|
|
483 |
// m_lcd_display.putText(str3);
|
|
484 |
m_lcd_display.RedrawWindow();
|
|
485 |
lastsec = sec;
|
|
486 |
}
|
|
487 |
|
|
488 |
return 0;
|
|
489 |
}
|
|
490 |
|
|
491 |
|
|
492 |
void CLCDDisplayTestDlg::OnBnClickedButton7()
|
|
493 |
{
|
|
494 |
// TODO: 在此添加控件通知处理程序代码
|
|
495 |
CString s1,s2;
|
|
496 |
GetDlgItemText(IDC_EDIT3, s1);
|
|
497 |
CStringA s1A;
|
|
498 |
s1A = s1;
|
|
499 |
CStringA resstrs[100];
|
|
500 |
int j = Split(s1A, " ", resstrs);
|
|
501 |
s1.Empty();
|
|
502 |
for (int i = 0; i < j; i++)
|
|
503 |
{
|
|
504 |
int k = xtoi(resstrs[i], 2);
|
|
505 |
k = reversebyte(k);
|
|
506 |
s1.AppendFormat(_T("%02x "), k);
|
|
507 |
}
|
|
508 |
s2 = s1;
|
|
509 |
SetDlgItemText(IDC_EDIT4, s2);
|
|
510 |
}
|
|
511 |
|
|
512 |
|
|
513 |
void CLCDDisplayTestDlg::OnBnClickedButton8()
|
|
514 |
{
|
|
515 |
// TODO: 在此添加控件通知处理程序代码
|
|
516 |
COLORREF bkcolor, fntcolor;
|
|
517 |
bkcolor=m_color_button1.GetColor();
|
|
518 |
fntcolor = m_color_button2.GetColor();
|
|
519 |
m_lcd_display.SetBkColor(bkcolor);
|
|
520 |
m_lcd_display.SetFontColor(fntcolor);
|
|
521 |
|
|
522 |
}
|