继上次74HC595显示自己想要的图案后,如果把一个芯片控制的64个灯当作一层,那么把八个芯片叠加在一起就可以达到立体显示的效果。
由于一个芯片占据3个引脚,八个只需要24个引脚,剩下引脚可以加入中断添加蓝牙、遥控、按键等功能原理可行,那么,开干。。。。。。
由于某些原因,在某宝上买了散件制作了一个光立方(制作花了我小一个月)。
?
?
?单片机型号不同但原理相同,代码很长放在文末,下面是效果展示
?另外这次玩光立方的时候遇到了传输数据的问题,USB接口不能传输数据,查阅资料后发现需要一个USB转TTL的模块
?这个模块既可以用来给各种单片机下载代码,也可以用来给光立方上位机进行演示,模块虽小,功能俱全。当然使用方法也很简单,只需要查看芯片原理图找到对应VCC,GND,TXD,RXD连接就行
另外用到的串口驱动还是学习单片机时使用的老朋友CH340。
最后额外声明一下,下面的代码是商家给的,仅供学习参考(商家:上升沿)
/*---------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
* é?éy??μ?×ó????
* ê±??2017.9.1
Build target 'Target 1'
compiling main.c...
linking...
Program Size: data=111.7 xdata=1017 code=55161
creating hex file from "×?D?app1aᢷ??′3ìDò"...
"×?D?app1aᢷ??′3ìDò" - 0 Error(s), 0 Warning(s).
------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------*/
#include "STC12C5A.H" //°üo?μ¥???úμ?í·???tê1ó?KEIL±?D?ìí?ó??à′·??ò±àò?2?á?
#include "intrins.h" //°üo?NOP?óê±í·???t
#include "main.h" //?÷3ìDòí·???t
#include "shuju.h" //°üo?×??£êy?Yêy×é
#include "flash.h" //?ˉ?-2?·?3ìDò
#include "hongwai.h" //oìía2?·?3ìDò
#include "key.h" //°′?ü2?·?3ìDò
#include "pinpu.h" //ò?à??μ?×2?·?3ìDò
#include "jiance.h" //?a?ú?ì2a?£ê?3ìDò
#include "moshi.h" //?£ê?????3ìDò
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@?¨ò?±?á?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
uchar xdata display[8][8];
uchar data msd=0;
uint ld=700;
uchar data key2=0,key3=0;
uchar data xsdsq=0;
uchar data sj_read_flag=0;
uchar data read_flag=0; //μ???é????ú?á±ê??
uchar data cnt=0;
uchar data cot=0;
uchar data cd=0,layerr=0,saom=0;
uint liangdu = 400; //áá?è
uint donghua_shudu=500; //?ˉ?-?ù?èμ÷?ú
int date=0; //′??ú2êy?Y
bit busy = 0; //′??ú?D??±ê??
uchar data moshi=0; // ?£ê?
bit start3 = 0; //Dy×a×????£ê?±ê??
bit key1=0;
uchar data abc_falg=0; //Dy×a×???±ê??
bit start1=1;//?μ?×????±ê??
uchar data ping=2; //?μ?×????±ê??
uchar data dong=2; //?ˉ?-????±ê??
uchar data gai=2;// ????±ê??
uchar data gaizi=2;//????±ê??
bit start2=1;// ?ˉ?-????±ê??
uchar data pingpu=0; //?????????μ?×?ˉ?-
uchar data donghua1=0; //????????í??ú?ˉ?-
bit start_shuju=0; //wifi?óê?êy?Y?aê?±ê??
bit abcd=0;//Dy×a×???
bit moshi_falg=0;
uchar data dhms_falg=0;
uchar data ppms_falg=0;
uchar data sjms_falg=0;
uchar data dnms_falg=0;
uchar data gzms_falg=0;
uchar data ldjian_falg=0;
uchar data ldjia_falg=0;
uchar data sdjia_falg=0;
uchar data sdjian_falg=0;
uchar data gzdh3_falg=0;
uchar gzdh3=0;
bit gaizi1_flag=1; //?a?ú?ì2aóD??óD±£′?1y?úèY
bit gaizi2_flag=1;
bit gaizi3_flag=1;
bit gaizi4_flag=1;
uchar gaizi_geshu1=0; //??×?μ?×?êy
uchar gaizi_geshu2=0;
uchar gaizi_geshu3=0;
uchar jcount=0; //ê?μ?×???μ???êy
bit kaiji_flag=0;//
bit gaizhiflag=0;
uchar gzms_falg1=0;
uchar gzms_falg2=0;
uchar gzms_falg3=0;
uchar gzms_falg4=0;
uchar gzms_falg5=0;
/*##########################################################################################*/
//************************************é?éy??μ?×ó????************************************
//oˉêy??3?£ovoid init();
//1| ?ü£o?¨ò?IO?ú1|?ü
//3??ú2?êy£o?T
//±à D′ è?£oé?éy??μ?×ó????
//±àD′è??ú£o2015-08-1
//DT??àúê·£oV1.0
//************************************é?éy??μ?×ó????************************************
void init()
{
P4SW=0xff; //?¨ò?P4?ú?aI/O?ú
P0M1=0x00;
P0M0=0xff; //?¨ò?P0?a??é?à-ê?3?.
P1M1=0x01;
P1M0=0xfe; //?¨ò?P1?a??é?à-ê?3?. P1.0×÷?aAD′?ê±2??ü×÷?a??é?àˉ
P2M1=0x00;
P2M0=0xff; //?¨ò?P2?a??é?à-ê?3?.
P3M1=0x00;
P3M0=0xf8; //?¨ò?P3?a??é?à-ê?3?.
P4M1=0x00;
P4M0=0xff; //?¨ò?P4?a??é?à-ê?3?.
}
/********************* AD3?ê??ˉ************************/
void ADC0_Init (void)
{
uchar i;
P1ASF = 0x01; //Open 8 channels ADC function
ADC_RES = 0; //Clear previous result ??á?ADCμ?8??êy?Y
AUXR1 &=0xFB; //1111,1011, á? ADRJ=0 (10??A/D×a???á1?μ???8??·??úADC_RES??′??÷, μí2??·??úADC_RESL??′??÷)
ADC_CONTR = ADC_POWER | ADC_SPEEDLL;//????ADC??′??÷
for(i=0;i<24;i++)
{
_nop_();
}
}
/*##########################################################################################*/
//************************************é?éy??μ?×ó????************************************
//oˉêy??3?£ovoid sinter()
//1| ?ü£o?D??3?ê??ˉ
//3??ú2?êy£o?T
//±à D′ è?£oé?éy??μ?×ó????
//±àD′è??ú£o2015-08-1
//DT??àúê·£oV1.0
//************************************é?éy??μ?×ó????************************************
void sinter()
{
TCON=0x01;
TH0=0x10;
TL0=0x00;
IPH = 0xfc;
ET0 = 1;
TR0 = 1;
}
/********************* ′??ú3?ê??ˉ************************/
void init_uart(void)
{
PCON |= 0x80;
SCON = 0x50;
AUXR |= 0x40;
AUXR &= 0xFE;
TMOD &= 0x0F;
TMOD |= 0x20;
TL1 = 0xE8;
TH1 = 0xE8;
ET1 = 0;
TR1 = 1;
ES=1;
EA=1;
}
/*##########################################################################################*/
//************************************é?éy??μ?×ó????************************************
//oˉêy??3?£ovoid delayus(unsigned int yanshi);
//1| ?ü£o?ù?Yyanshi?μμ?′óD???DD?óê±μè′y2ù×÷£?1??è??a2uS
//è??ú2?êy£oyanshiμ??μ£?·??§0-65535
//3??ú2?êy£o?T
//±à D′ è?£oé?éy??μ?×ó????
//±àD′è??ú£o2015-08-1
//DT??àúê·£oV1.0
//************************************é?éy??μ?×ó????************************************
void delayus(unsigned int yanshi)
{
unsigned int wmys; //?¨ò??óê±?-?·????±?á?
for(wmys=0;wmys<=yanshi;wmys++); //?ù?Y?óê±2?êy??DD???-?·2ù×÷£?′?μ??óê±1|?ü
}
void delay10us(void) //?ó2? -0.026765046296us STC 1T 22.1184Mhz
{
unsigned char a,b;
for(b=1;b>0;b--)
for(a=2;a>0;a--); //??è?μ??ù?è?a5£?±??ù1-5-25-125
}
void delay5us(void) //?ó2? -0.026765046296us STC 1T 22.1184Mhz
{
unsigned char a,b;
for(b=1;b>0;b--)
for(a=5;a>0;a--); //??è?μ??ù?è?a5£?±??ù1-5-25-125
}
void delay(uint ihk)
{
if(key3==2){return;}
else
{
while(ihk--)
{
delay5us(); //12tμ?mcu ×¢êí?a???óê±?′?é
if(dong == 1){return;} if(gai == 1){return;}if(gaizhiflag==1){return;}
}
}
}
void delays(int t)
{
int i;
while(t--)
for(i=0;i<700;i++);
}
/*##########################################################################################*/
//************************************é?éy??μ?×ó????************************************
//oˉêy??3?£ovoid hansao(unsigned char hs);
//1| ?ü£o?ù?Yè??ú2?êyhsμ??μ£???DD?D????????ò?DD£???í¨1-8DDμ???í¨
//è??ú2?êy£ohsμ??μ£?·??§0-7
//3??ú2?êy£o?T
//±à D′ è?£oé?éy??μ?×ó????
//************************************é?éy??μ?×ó????************************************
void hansao(unsigned char hs)
{
if(hs<8) //?D??hsμ??μê?·??úDDé¨?èμ??μ·??§?ú£?2??ú·??§?ú2??′DDè?o?2ù×÷
{
if(M_EN == 0)
{
if(hs==7) //??í¨μú1DD
{
P2=0Xfe;
delayus(liangdu);
P2 = 0xff; //??ó°
return;
}
if(hs==6) //??í¨μú2DD
{
P2=0Xfd;
delayus(liangdu);
P2 = 0xff;
return;
}
if(hs==5) //??í¨μú3DD
{
P2=0Xfb;
delayus(liangdu);
P2 = 0xff;
return;
}
if(hs==4) //??í¨μú4DD
{
P2=0Xf7;
delayus(liangdu);
P2 = 0xff;
return;
}
if(hs==3) //??í¨μú5DD
{
P2=0Xef;
delayus(liangdu);
P2 = 0xff;
return;
}
if(hs==2) //??í¨μú6DD
{
P2=0Xdf;
delayus(liangdu);
P2 = 0xff;
return;
}
if(hs==1) //??í¨μú7DD
{
P2=0Xbf;
delayus(liangdu);
P2 = 0xff;
return;
}
if(hs==0) //??í¨μú8DD
{
P2=0X7f;
delayus(liangdu);
P2 = 0xff;
return;
}
}
}
}
//************************************595D????y?ˉ3ìDò1 ?μ?×?£ê?oíoó???ˉ?-?£ê?************************************
void sendbyte(unsigned int num1,unsigned int num2,unsigned int num3,unsigned int num4)
{
unsigned char c;
for(c=0;c<8;c++)
{
CLK=0;
M_LR_DS0=num1&0x80;
M_LG_DS0=num2&0x80;
M_HR_DS0=num3&0x80;
M_HG_DS0=num4&0x80;
CLK=1;
num1<<=1;
num2<<=1;
num3<<=1;
num4<<=1;
}
}
//************************************595D????y?ˉ3ìDò2 //?°???ˉ?-************************************
void sendbyte1(unsigned int num1,unsigned int num2,unsigned int num3,unsigned int num4)
{
unsigned char c;
for(c=0;c<8;c++)
{
CLK=0; //?£?aê±?ó???????ú
M_LR_DS0=num1&0x01; //?£?aêy?Y·¢?í???ú
M_LG_DS0=num2&0x01;
M_HR_DS0=num3&0x01;
M_HG_DS0=num4&0x01;
CLK=1;
num1>>=1;
num2>>=1;
num3>>=1;
num4>>=1;
}
}
//************************************595D????y?ˉ3ìDò3 é????ú????2?·?***********************************
void sendbyteck(unsigned int num1,unsigned int num2,unsigned int num3,unsigned int num4)
{
unsigned char c;
for(c=0;c<8;c++)
{
CLK=0;
M_LR_DS0=num1&0x01;
M_LG_DS0=num2&0x01;
M_HR_DS0=num3&0x01;
M_HG_DS0=num4&0x01;
CLK=1;
num1>>=1;
num2>>=1;
num3>>=1;
num4>>=1;
}
}
void fvb() //μ???é????úêy?Y′|àí
{
if(read_flag)
{
read_flag=0;
for(saom=0;saom<8;saom++)
{
displayck[saom+0]=((shuzu8X8[saom*8]>>7)&0x01)+(((shuzu8X8[saom*8+1]>>7)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>7)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>7)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>7)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>7)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>7)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>7)&0x01)<<7);
displayck[saom+8]=((shuzu8X8[saom*8]>>6)&0x01)+(((shuzu8X8[saom*8+1]>>6)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>6)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>6)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>6)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>6)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>6)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>6)&0x01)<<7);
displayck[saom+16]=((shuzu8X8[saom*8]>>5)&0x01)+(((shuzu8X8[saom*8+1]>>5)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>5)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>5)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>5)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>5)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>5)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>5)&0x01)<<7);
displayck[saom+24]=((shuzu8X8[saom*8]>>4)&0x01)+(((shuzu8X8[saom*8+1]>>4)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>4)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>4)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>4)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>4)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>4)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>4)&0x01)<<7);
displayck[saom+32]=((shuzu8X8[saom*8]>>3)&0x01)+(((shuzu8X8[saom*8+1]>>3)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>3)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>3)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>3)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>3)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>3)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>3)&0x01)<<7);
displayck[saom+40]=((shuzu8X8[saom*8]>>2)&0x01)+(((shuzu8X8[saom*8+1]>>2)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>2)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>2)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>2)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>2)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>2)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>2)&0x01)<<7);
displayck[saom+48]=((shuzu8X8[saom*8]>>1)&0x01)+(((shuzu8X8[saom*8+1]>>1)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>1)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>1)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>1)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>1)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>1)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>1)&0x01)<<7);
displayck[saom+56]=((shuzu8X8[saom*8]>>0)&0x01)+(((shuzu8X8[saom*8+1]>>0)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>0)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>0)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>0)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>0)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>0)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>0)&0x01)<<7);
}
}
for(layerr=0;layerr<8;layerr++)
{
key_baihei_scan();
hansao(layerr);
sendbyteck(~displayck[layerr*8+0],~displayck[layerr*8+2],~displayck[layerr*8+4],~displayck[layerr*8+5]);
sendbyteck(~displayck[layerr*8+3],~displayck[layerr*8+1],~displayck[layerr*8+6],~displayck[layerr*8+7]);
SUO=0; //?£?a??′?D?o????ú
_nop_();
SUO=1;
M_EN=0;
hansao(layerr);
delayus(ld);
M_EN=1;
if(key2==1||key2==2||key2==4||key2==5)
{
break;
}
}
}
void zhen(uchar *a,uchar v) //?°???ˉ?-êy?Y′|àí
{
char layer;
while(v--)
{
for(layer=0;layer<8;layer++)
{
if(xsdsq==1){;}
else
{
key_baihei_scan();
if(msd==2||msd==6)
{
if(key2==1||key2==3||key2==5||key2==4)
{
key3=1;
M_EN=1;
break;
}
}
if(msd==4)
{
if(key2==1||key2==3||key2==5||key2==2)
{
key3=1;
M_EN=1;
break;
}
}
}
sendbyte1(~a[layer*8+7],~a[layer*8+5],~a[layer*8+3],~a[layer*8+2]);
sendbyte1(~a[layer*8+4],~a[layer*8+6],~a[layer*8+1],~a[layer*8+0]);
SUO=0;
_nop_();
SUO=1;
M_EN=0;
hansao(7-layer);
delayus(donghua_shudu);
M_EN=1;
if(dong == 1){ break;}
if(abcd == 1){break;}
if(gai == 1){break;}
}
delays(2);
}
}
void W_side(uchar *tab,char num,char v)
{
uchar a[64]={0};
int i,j;
for(j=0;j<num;j++)
{
for(i=0;i<8;i++)
a[i*8+7]=tab[j*8+i];
if(key3==1){break;}
else{zhen(a,v);}
delay(50);
}
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ?÷oˉêy @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
void main()
{
unsigned char p=0,k=0,l=0; //?¨ò?
init();
start_shuju = 1;
IDelay(100);
IRInit();
ADC0_Init();
clear(0);
PWM_LED();//?a??PWMo??üμ?1|?ü
moshi = 0;
key2 = 0;
ping=2;
dong=2;
gai=2;
gaizi=0;
pingpu = 0;
donghua1 = 0;
start1 = 1;
start2 = 1;
turn_on(10);
H_scan(10); // ×ó?òóòé¨?è?ì2a
V_scan(10); //???òé?é¨?è?ì2a
W_scan(10); //?°?òoóé¨?è?ì2a
PWM_POW=0; //′ò?aμ??′??ê?μ?
sinter();
TR0=0; //1?±??¨ê±?÷??ê?é¨?è ?àμ±óú1?±??μ?×?£ê???ê?oíoó??2?·??ˉ?-??ê?
while(1) //?a?ú?ì2a?£ê?
{
H_scan(40); // ×ó?òóòé¨?è?ì2a
V_scan(40); //???òé?é¨?è?ì2a
W_scan(40); //?°?òoóé¨?è?ì2a
if(key1 == 1)
{
msd=2;
break;
}
if(key2==3||key2==1||key2==4||key2==5||key2==2)
{
if(key2==3)
{
msd=3;break;
}
else
{
if(key2==1)
{
msd=1;break;
}
if(key2==4)
{
msd=4;
break;
}
if(key2==5)
{
msd=5;
break;
}
if(key2==2)
{
msd=2;
break;
}
}
}
}
delay(10); //è?1?ê??°???ˉ?-oíé??ú?£ê?Dèòa?óê±??
while(1) /*play list*/
{
kaiji_flag = 1; //?a?úoó
yinyue_moshi();//ò?à??μ?×?£ê?
donghua_moshi();//?ˉ?-?£ê?
shangweiji_moshi(); //é????ú?£ê?
xiugaidonghua_moshi(); //??ê???×??ˉ?-
}
}
/************************************′??ú?D??1************************************/
void serial (void) interrupt 4 using 1
{
uchar tempbuff;ES=0;
if(RI)
{
RI=0;tempbuff=SBUF;
switch(cnt)
{
case 0:if(tempbuff==0xf2)cnt=1;else {cnt=0;}break;
case 1:shuzu8X8[cd++]=tempbuff;
if(cd==64)
{
cnt=0;
cd=0;
read_flag=1;
}
else
{
break;
}
default:break;
}
}
ES=1;
}
/************************************?¨ê±?D??1************************************/
void print1() interrupt 1
{
static uchar layert=0;
TR0 = 0;
ET0= 0;
if(msd==1) //?μ?×?£ê?
{
sendbyte(~display[layert][0],~display[layert][2],~display[layert][4],~display[layert][5]);
sendbyte(~display[layert][3],~display[layert][1],~display[layert][6],~display[layert][7]);
SUO=0;
_nop_();
SUO=1;
M_EN=0;
hansao(7-layert);
delayus(ld);
M_EN=1;
if (layert<7)
layert++;
else
layert=0;
key_baihei_scan();
if(msd==1)
{
if(key2==2||key2==3||key2==4||key2==5)
{
key3=2;
return;
}
}
TH0=0xef;
TL0=0x00;
}
if(msd==2) //oó2?·??ˉ?-
{
sendbyte(~display[layert][0],~display[layert][2],~display[layert][4],~display[layert][5]);
sendbyte(~display[layert][3],~display[layert][1],~display[layert][6],~display[layert][7]);
SUO=0;
_nop_();
SUO=1;
M_EN=0;
hansao(layert);
delayus(donghua_shudu);
M_EN=1;
if (layert<7)
layert++;
else
layert=0;
key_baihei_scan();
if(msd==2)
{
if(key2==1||key2==3||key2==4||key2==5)
{
key3=2;
return;
}
}
TH0=0xef;
TL0=0x00;
}
if(msd==4) //??×??ˉ?-2?·?
{
sendbyte(~display[layert][0],~display[layert][2],~display[layert][4],~display[layert][5]);
sendbyte(~display[layert][3],~display[layert][1],~display[layert][6],~display[layert][7]);
SUO=0;
_nop_();
SUO=1;
M_EN=0;
hansao(layert);
delayus(donghua_shudu);
M_EN=1;
if (layert<7)
layert++;
else
layert=0;
key_baihei_scan();
if(msd==4)
{
if(key2==1||key2==3||key2==2||key2==5)
{
key3=2;
return;
}
}
TH0=0xef;
TL0=0x00;
}
TR0 = 1;
ET0 = 1;
}
void shudu_jia() //?ù?è?ó
{
if(key2==2 || key2==4)
{
if(donghua_shudu>500 && donghua_shudu<=1500)
{
donghua_shudu = donghua_shudu-200;
}
else if(donghua_shudu>100 && donghua_shudu<=500)
{
donghua_shudu = donghua_shudu-100;
}
else if(donghua_shudu>30 && donghua_shudu<=100)
{
donghua_shudu = donghua_shudu-40;
}
else if(donghua_shudu>0 && donghua_shudu<=30)
{
donghua_shudu = donghua_shudu-10;
}
if(donghua_shudu<=0 || donghua_shudu> 2000)
{
donghua_shudu=1;
}
}
}
void shudu_jian() //?ù?è??
{
if(key2==2 || key2==4)
{
if(donghua_shudu>0 && donghua_shudu<=30)
{
donghua_shudu = donghua_shudu+10;
}
else if(donghua_shudu>30 && donghua_shudu<=100)
{
donghua_shudu = donghua_shudu+40;
}
else if(donghua_shudu>100 && donghua_shudu<=500)
{
donghua_shudu = donghua_shudu+100;
}
else if(donghua_shudu>500 && donghua_shudu<1500)
{
donghua_shudu = donghua_shudu+200;
}
if(donghua_shudu >= 1500)
{
donghua_shudu = 1500;
}
}
}
?不知道为什么代码里面文字是乱码,有知道的大佬帮解释一下。
?
|