After a semester of graduate school life, has been for several months did not see the program, hands are itching very much. Finally finished the test, you can do a little thing. The next semester, may be to use PIC single-chip Computer simulation System control program. Voltage, current acquisition and measurement is very annoying, today to do this electronic 8-section tube simulation program is to be prepared in advance.
Use
I think the electronic 8 section tube is not very strange to everybody. A lot of electronic equipment (such as watches, timers, etc.) have their figure. This program is on the computer to achieve the Electronic 8 section of the simulation, mainly for external input to show the output. For example, in the use of RC circuit lap simulation system simulation design, need to measure a variety of voltage, current value, we can through the ad converter to collect a variety of analog data into the computer. Then the 8-segment tube is displayed, and a very simple digital voltmeter is done.
The sample program interface in this article, as shown in figure one, shows the following list items as shown in Figure two:
Figure I
Figure II
Program Description
The main purpose of the program is to realize the encapsulation of the analog 8-segment Cnumpane function: The main function functions are as follows.
class CNumPane : public CStatic
{
public:
CNumPane(BOOL bIsShow = FALSE);
public:
void Restore(); //将CEPane内各个参数恢复初始设定值
BOOL bIsShowBackGround; //属性,是否要绘制8段管的背景数字
void SetBackNumColor(COLORREF ref); // 设置背景数字的颜色
void SetNumColor(COLORREF ref); // 设置前景数字的颜色
void SetBorderColor(COLORREF ref); // 设置控件边框的颜色
void SetBackGroundColor(COLORREF ref); // 设置控件的背景颜色
void SetShowNumber(CString str); // 设置控件要显示的数字,
//可以提供float型或者CString型
void SetShowNumber(float f);
};
By invoking these functions, we can control the 8-segment tube.
The interior also assists in defining a structure that is part of a 8-segment tube unit: (This structure is primarily used to store specific coordinates for each 8-segment tube and to provide corresponding rendering functions).
struct Pane8
{
CPoint m_leftup;
CPoint m_rightup;
CPoint m_leftmid;
CPoint m_rightmid;
CPoint m_leftbottom;
CPoint m_rightbottom; // 对应8段管6个定点坐标
CDC * pDC;
void DrawA() //以下是对A-G段的绘制,用很简单的LineTo做的
.....
// 以下绘制0-9 10个数字,''-''和''.''符号
void Draw9()
.....
};
The focus of program implementation is the Cnumpane::makecoordinate () function, which, after the control size and the data to be displayed, calculates the key coordinates of each 8 segment tube, constructs a Pane8 array pitem to store the coordinate values. (The specific implementation process, the program source code has detailed introduction)
The inadequacy of the place
For 8 sections of the Tube drawing processing is relatively simple, is moveto,lineto painting, did not make stereo effect. And since it was a whim to do something like this, it took 3 hours to finish it hastily, and there may be some hidden bugs that have not been found. I hope members can identify and correct them.
Operating conditions
The specific effect of the operation, please compile the source code after the implementation. This example compiles and runs through in Visual C + + 6.0 and Window xp/98.