atmega128 wm_timer기능과 계산기 합체
-
곰부리
- 3149
- 0
void CDDNN::OnOK()
{
// TODO: Add extra validation here
InitUSB();
WriteB(PCR,0x80);
WriteB(PB,fnd[0]);
WriteB(PA,fnd[0]);
}
int m_number1; //첫번째값
int m_number2;//두번째 값
int m_result; //결과 값
int m_cal_number;//1==덧셈 2==뺄셈 3==곱셈 4==나눗셈
int led[10]={0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,0xff};
int wa=0;
void CDDNN::OnButton1()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[1]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[1]);wa=0;}
m_str+="1";
m_wq+="1";
UpdateData(FALSE);
}
void CDDNN::OnButton2()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[2]);wa++;Sleep(200);}
else if(wa==1){ WriteB(PB,fnd[2]);wa=0;}
m_str+="2";
m_wq+="2";
UpdateData(FALSE);
}
void CDDNN::OnButton3()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[3]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[3]);wa=0;}
m_str+="3";
m_wq+="3";
UpdateData(FALSE);
}
void CDDNN::OnButton4()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[4]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[4]);wa=0;}
m_str+="4";
m_wq+="4";
UpdateData(FALSE);
}
void CDDNN::OnButton5()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[5]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[5]);wa=0;}
m_str+="5";
m_wq+="5";
UpdateData(FALSE);
}
void CDDNN::OnButton6()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[6]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[6]);wa=0;}
m_str+="6";
m_wq+="6";
UpdateData(FALSE);
}
void CDDNN::OnButton7()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[7]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[7]);wa=0;}
m_str+="7";
m_wq+="7";
UpdateData(FALSE);
}
void CDDNN::OnButton8()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[8]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[8]);wa=0;}
m_str+="8";
m_wq+="8";
UpdateData(FALSE);
}
void CDDNN::OnButton9()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[9]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[9]);wa=0;}
m_str+="9";
m_wq+="9";
UpdateData(FALSE);
}
void CDDNN::OnButton10()
{
// TODO: Add your control notification handler code here
if(wa==0){WriteB(PA,fnd[0]);wa++;Sleep(200);}
else if(wa==1){WriteB(PB,fnd[0]);wa=0;}
m_str+="0";
m_wq+="0";
UpdateData(FALSE);
}
void CDDNN::Onplus()
{
// TODO: Add your control notification handler code here
m_number1=atoi(m_str);
wa=0;
m_cal_number=1;
m_str="";
m_wq="";
UpdateData(FALSE);
}
void CDDNN::Onmin()
{
// TODO: Add your control notification handler code here
m_number1=atoi(m_str);
wa=0;
m_cal_number=2;
m_str="";
m_wq="";
UpdateData(FALSE);
}
void CDDNN::Onnanum()
{
// TODO: Add your control notification handler code here
m_number1=atoi(m_str);
wa=0;
m_cal_number=4;
m_str="";
m_wq="";
UpdateData(FALSE);
}
void CDDNN::Ongop()
{
// TODO: Add your control notification handler code here
m_number1=atoi(m_str);
wa=0;
m_cal_number=3;
m_str="";
m_wq="";
UpdateData(FALSE);
}
void CDDNN::Onicore()
{
// TODO: Add your control notification handler code here
char str[80];
m_number2=atoi(m_str);
switch(m_cal_number)
{
case 1:
m_result=m_number1+m_number2;
break;
case 2:
m_result=m_number1-m_number2;
break;
case 3:
m_result=m_number1*m_number2;
break;
case 4:
m_result=m_number1/m_number2;
break;
};
itoa(m_result,str,10);
m_wq="";
UpdateData(FALSE);
m_wq=str;
UpdateData(FALSE);
m_str=str;
m_qs=m_str;
UpdateData(FALSE);
int res;
res=m_result/100;
m_result=m_result%100;
wa=0;
int tq;
int oq;
tq=m_result/10;
oq=m_result%10;
WriteB(PA,fnd[tq]);
WriteB(PB,fnd[oq]);
CString zz;
zz.Format("%d",m_result);
MessageBox(zz);
}
#include "stdlib.h"
#include "time.h"
int uk;
int i;
int t;
int w;
void CDDNN::Onrandom()
{
// TODO: Add your control notification handler code here
if(runt1 == 0)AfxBeginThread(RUN1,NULL);
}
void CDDNN::Onstop()
{
// TODO: Add your control notification handler code here
CString aa;
flag1=0;
aa.Format("%d",i);
MessageBox(aa);
}
UINT RUN1(LPVOID lpParam)
{
flag1 = 1;
runt1 = 1;
while(flag1)
{
srand((unsigned)time(NULL));
i=rand()%100;
t=i/10;
w=i%10;
WriteB(PA,fnd[t]);
WriteB(PB,fnd[w]);
}
runt1 =0;
return 0;
}
int fyear;
void CDDNN::Onedd()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
fyear = GetDlgItemInt(IDC_EDIT1);
}
void CDDNN::OnButton14()
{
// TODO: Add your control notification handler code here
CString aa;
if(i==fyear){
aa.Format("%d",i);
MessageBox(aa);
}
else{ MessageBox("틀렸다");}
}
void CDDNN::OnCcas()
{
// TODO: Add your control notification handler code here
m_wq="";
m_str="";
UpdateData(FALSE);
WriteB(PB,fnd[0]);
WriteB(PA,fnd[0]);
}
int h;
int th;
void CDDNN::OnTtm()
{
// TODO: Add your control notification handler code here
h=0;
th=0;
SetTimer(0,1000,NULL);
}
void CDDNN::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
h++;
if(h>9){h=0;th++;}
if(th==9 && h>10){h=0; th=0;}
WriteB(PB,fnd[h]);
WriteB(PA,fnd[th]);
CDialog::OnTimer(nIDEvent);
}
void CDDNN::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
KillTimer(0);
}
![기술랩장](https://gisullab.com/files/member_extra_info/profile_image/004/4.png?20150928191038)
추천인 1
곰부리
문의 010-6744-8207