/****************WS281215*7************************/
/****************QQ:774145445**********************/
/****************快手:共同学习STM8*****************/
/*****************20210316*************************/
// PMS154C
// ______@______
// |1 PB4 PB3 16|
// |2 PB5 PB2 15|
// |3 PB6 PB1 14|
// |4 PB7 PB0 13|
// |5 VDD GND 12|
// |6 PA7 PA0 11|----WS281215*7
// |7 PA6 PA4 10|
// |8_PA5__PA3__9|
/**************************************************/
/**************************************************/
#include "extern.h"
byte x_0_1,x_0_2; //显示ram
byte x_1_1,x_1_2;
byte x_2_1,x_2_2;
byte x_3_1,x_3_2;
byte x_4_1,x_4_2;
byte x_5_1,x_5_2;
byte x_6_1,x_6_2;
byte shi,fen,miao; //时,分,秒
byte lv,hong,lan;
byte shi_shi,shi_ge; //小时十位,小时个位
byte fen_shi,fen_ge; //分钟十位,分钟个位
byte qumo_a1;
byte zimo_a1,zimo_a2,zimo_a3; //字模
/**************************************************/
void zimo_0(); //字模0
void zimo_1(); //字模1
void zimo_2(); //字模2
void zimo_3(); //字模3
void zimo_4(); //字模4
void zimo_5(); //字模5
void zimo_6(); //字模6
void zimo_7(); //字模7
void zimo_8(); //字模8
void zimo_9(); //字模9
void yi(); //发1
void ling(); //发0
void shijian_fenjie();//时间分解
void qing_ram(); //清ram
void qumo(); //取模
void fuzhi(); //赋值
void xianshi(); //显示
void xianshi_1(); //显示第一行
void xianshi_2(); //显示第二行//反取
void xianshi_3(); //显示第三行
void xianshi_4(); //显示第四行//反取
void xianshi_5(); //显示第五行
void xianshi_6(); //显示第六行//反取
void xianshi_7(); //显示第七行
void xian_1(); //显1
void xian_0(); //显0
/**************************************************/
chuan bit pa.0;
/**************************************************/
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
word a1;
$ chuan out,low;
shi =12;
fen =00;
miao =0;
lv =20;
hong =65;
lan =5;
while (1)
{
/*a1=2520;
while(a1--)
{
ling();
}
.delay 100;*/
xianshi();
.delay 2000000;
miao ++;
if(miao==2)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
{
shi=0;
}
}
}
}
}
/**************************************************
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
/**************************************************/
//0 fe 82 fe
//1 42 fe 02
//2 9e 92 f2
//3 92 92 fe
//4 70 10 fe
//5 f2 92 9e
//6 fe 92 9e
//7 c0 80 fe
//8 fe 92 fe
//9 f2 92 fe
void zimo_0() //字模0
{
zimo_a1 =0xfe;
zimo_a2 =0x82;
zimo_a3 =0xfe;
}
void zimo_1() //字模1
{
zimo_a1 =0x00;
zimo_a2 =0xfe;
zimo_a3 =0x00;
}
void zimo_2() //字模2
{
zimo_a1 =0x9e;
zimo_a2 =0x92;
zimo_a3 =0xf2;
}
void zimo_3() //字模3
{
zimo_a1 =0x92;
zimo_a2 =0x92;
zimo_a3 =0xfe;
}
void zimo_4() //字模4
{
zimo_a1 =0x70;
zimo_a2 =0x10;
zimo_a3 =0xfe;
}
void zimo_5() //字模5
{
zimo_a1 =0xf2;
zimo_a2 =0x92;
zimo_a3 =0x9e;
}
void zimo_6() //字模6
{
zimo_a1 =0xfe;
zimo_a2 =0x92;
zimo_a3 =0x9e;
}
void zimo_7() //字模7
{
zimo_a1 =0xc0;
zimo_a2 =0x80;
zimo_a3 =0xfe;
}
void zimo_8() //字模8
{
zimo_a1 =0xfe;
zimo_a2 =0x92;
zimo_a3 =0xfe;
}
void zimo_9() //字模9
{
zimo_a1 =0xf2;
zimo_a2 =0x92;
zimo_a3 =0xfe;
}
/**************************************************/
void yi() //发1
{
chuan =1;
nop;
nop;
nop;
nop;
chuan =0;
nop;
}
/**************************************************/
void ling() //发0
{
chuan =1;
//nop;
chuan =0;
nop;
nop;
nop;
nop;
}
/**************************************************/
void shijian_fenjie() //时间分解
{
byte shi_b1,fen_b1;
shi_shi =0;
shi_ge =0;
fen_shi =0;
fen_ge =0;
shi_b1 =shi;
fen_b1 =fen;
while(shi_b1>9) //小时分解
{
shi_shi ++; //小时十位
shi_b1 -=10;
}
shi_ge =shi_b1; //小时个位
while(fen_b1>9) //分钟分解
{
fen_shi ++; //分钟十位
fen_b1 -=10;
}
fen_ge =fen_b1; //分钟个位
}
/**************************************************/
void qing_ram() //清ram
{
x_0_1 =0;
x_0_2 =0;
x_1_1 =0;
x_1_2 =0;
x_2_1 =0;
x_2_2 =0;
x_3_1 =0;
x_3_2 =0;
x_4_1 =0;
x_4_2 =0;
x_5_1 =0;
x_5_2 =0;
x_6_1 =0;
x_6_2 =0;
}
/**************************************************/
void qumo() //取模
{
if(qumo_a1==0) {zimo_0(); return;}
if(qumo_a1==1) {zimo_1(); return;}
if(qumo_a1==2) {zimo_2(); return;}
if(qumo_a1==3) {zimo_3(); return;}
if(qumo_a1==4) {zimo_4(); return;}
if(qumo_a1==5) {zimo_5(); return;}
if(qumo_a1==6) {zimo_6(); return;}
if(qumo_a1==7) {zimo_7(); return;}
if(qumo_a1==8) {zimo_8(); return;}
if(qumo_a1==9) {zimo_9(); return;}
}
/**************************************************/
void fuzhi() //赋值
{
qumo_a1 =shi_shi; //取模赋值
qumo(); //取模
//zimo_a1,zimo_a2,zimo_a3; //取回的字模值
if(zimo_a1.7) {x_0_1.7 =1;} //小时十位//竖转横
if(zimo_a1.6) {x_1_1.7 =1;}
if(zimo_a1.5) {x_2_1.7 =1;}
if(zimo_a1.4) {x_3_1.7 =1;}
if(zimo_a1.3) {x_4_1.7 =1;}
if(zimo_a1.2) {x_5_1.7 =1;}
if(zimo_a1.1) {x_6_1.7 =1;}
if(zimo_a2.7) {x_0_1.6 =1;}
if(zimo_a2.6) {x_1_1.6 =1;}
if(zimo_a2.5) {x_2_1.6 =1;}
if(zimo_a2.4) {x_3_1.6 =1;}
if(zimo_a2.3) {x_4_1.6 =1;}
if(zimo_a2.2) {x_5_1.6 =1;}
if(zimo_a2.1) {x_6_1.6 =1;}
if(zimo_a3.7) {x_0_1.5 =1;}
if(zimo_a3.6) {x_1_1.5 =1;}
if(zimo_a3.5) {x_2_1.5 =1;}
if(zimo_a3.4) {x_3_1.5 =1;}
if(zimo_a3.3) {x_4_1.5 =1;}
if(zimo_a3.2) {x_5_1.5 =1;}
if(zimo_a3.1) {x_6_1.5 =1;}
qumo_a1 =shi_ge; //取模赋值
qumo(); //取模
//zimo_a1,zimo_a2,zimo_a3; //取回的字模值
if(zimo_a1.7) {x_0_1.3 =1;} //小时个位//竖转横
if(zimo_a1.6) {x_1_1.3 =1;}
if(zimo_a1.5) {x_2_1.3 =1;}
if(zimo_a1.4) {x_3_1.3 =1;}
if(zimo_a1.3) {x_4_1.3 =1;}
if(zimo_a1.2) {x_5_1.3 =1;}
if(zimo_a1.1) {x_6_1.3 =1;}
if(zimo_a2.7) {x_0_1.2 =1;}
if(zimo_a2.6) {x_1_1.2 =1;}
if(zimo_a2.5) {x_2_1.2 =1;}
if(zimo_a2.4) {x_3_1.2 =1;}
if(zimo_a2.3) {x_4_1.2 =1;}
if(zimo_a2.2) {x_5_1.2 =1;}
if(zimo_a2.1) {x_6_1.2 =1;}
if(zimo_a3.7) {x_0_1.1 =1;}
if(zimo_a3.6) {x_1_1.1 =1;}
if(zimo_a3.5) {x_2_1.1 =1;}
if(zimo_a3.4) {x_3_1.1 =1;}
if(zimo_a3.3) {x_4_1.1 =1;}
if(zimo_a3.2) {x_5_1.1 =1;}
if(zimo_a3.1) {x_6_1.1 =1;}
qumo_a1 =fen_shi; //取模赋值
qumo(); //取模
//zimo_a1,zimo_a2,zimo_a3; //取回的字模值
if(zimo_a1.7) {x_0_2.7 =1;} //分钟十位//竖转横
if(zimo_a1.6) {x_1_2.7 =1;}
if(zimo_a1.5) {x_2_2.7 =1;}
if(zimo_a1.4) {x_3_2.7 =1;}
if(zimo_a1.3) {x_4_2.7 =1;}
if(zimo_a1.2) {x_5_2.7 =1;}
if(zimo_a1.1) {x_6_2.7 =1;}
if(zimo_a2.7) {x_0_2.6 =1;}
if(zimo_a2.6) {x_1_2.6 =1;}
if(zimo_a2.5) {x_2_2.6 =1;}
if(zimo_a2.4) {x_3_2.6 =1;}
if(zimo_a2.3) {x_4_2.6 =1;}
if(zimo_a2.2) {x_5_2.6 =1;}
if(zimo_a2.1) {x_6_2.6 =1;}
if(zimo_a3.7) {x_0_2.5 =1;}
if(zimo_a3.6) {x_1_2.5 =1;}
if(zimo_a3.5) {x_2_2.5 =1;}
if(zimo_a3.4) {x_3_2.5 =1;}
if(zimo_a3.3) {x_4_2.5 =1;}
if(zimo_a3.2) {x_5_2.5 =1;}
if(zimo_a3.1) {x_6_2.5 =1;}
qumo_a1 =fen_ge; //取模赋值
qumo(); //取模
//zimo_a1,zimo_a2,zimo_a3; //取回的字模值
if(zimo_a1.7) {x_0_2.3 =1;} //小时个位//竖转横
if(zimo_a1.6) {x_1_2.3 =1;}
if(zimo_a1.5) {x_2_2.3 =1;}
if(zimo_a1.4) {x_3_2.3 =1;}
if(zimo_a1.3) {x_4_2.3 =1;}
if(zimo_a1.2) {x_5_2.3 =1;}
if(zimo_a1.1) {x_6_2.3 =1;}
if(zimo_a2.7) {x_0_2.2 =1;}
if(zimo_a2.6) {x_1_2.2 =1;}
if(zimo_a2.5) {x_2_2.2 =1;}
if(zimo_a2.4) {x_3_2.2 =1;}
if(zimo_a2.3) {x_4_2.2 =1;}
if(zimo_a2.2) {x_5_2.2 =1;}
if(zimo_a2.1) {x_6_2.2 =1;}
if(zimo_a3.7) {x_0_2.1 =1;}
if(zimo_a3.6) {x_1_2.1 =1;}
if(zimo_a3.5) {x_2_2.1 =1;}
if(zimo_a3.4) {x_3_2.1 =1;}
if(zimo_a3.3) {x_4_2.1 =1;}
if(zimo_a3.2) {x_5_2.1 =1;}
if(zimo_a3.1) {x_6_2.1 =1;}
}
/**************************************************/
void xianshi() //显示
{
shijian_fenjie(); //时间分解
qing_ram(); //清ram
fuzhi(); //赋值
xianshi_1(); //显示第一行
xianshi_2(); //显示第二行
xianshi_3(); //显示第三行
xianshi_4(); //显示第四行
xianshi_5(); //显示第五行
xianshi_6(); //显示第六行
xianshi_7(); //显示第七行
}
/**************************************************/
void xian_1() //显1发送顺序绿红蓝grb
{
if(lv.7) {yi();} else{ling();}
if(lv.6) {yi();} else{ling();}
if(lv.5) {yi();} else{ling();}
if(lv.4) {yi();} else{ling();}
if(lv.3) {yi();} else{ling();}
if(lv.2) {yi();} else{ling();}
if(lv.1) {yi();} else{ling();}
if(lv.0) {yi();} else{ling();}
if(hong.7) {yi();} else{ling();}
if(hong.6) {yi();} else{ling();}
if(hong.5) {yi();} else{ling();}
if(hong.4) {yi();} else{ling();}
if(hong.3) {yi();} else{ling();}
if(hong.2) {yi();} else{ling();}
if(hong.1) {yi();} else{ling();}
if(hong.0) {yi();} else{ling();}
if(lan.7) {yi();} else{ling();}
if(lan.6) {yi();} else{ling();}
if(lan.5) {yi();} else{ling();}
if(lan.4) {yi();} else{ling();}
if(lan.3) {yi();} else{ling();}
if(lan.2) {yi();} else{ling();}
if(lan.1) {yi();} else{ling();}
if(lan.0) {yi();} else{ling();}
}
/**************************************************/
void xian_0() //显0
{
byte xian_0_a1;
xian_0_a1 =24;
while(xian_0_a1--) //重复24次
{
ling();
}
}
/**************************************************/
void xianshi_1() //显示第一行
{
if (x_0_1.7) {xian_1();} else{xian_0();}
if (x_0_1.6) {xian_1();} else{xian_0();}
if (x_0_1.5) {xian_1();} else{xian_0();}
if (x_0_1.4) {xian_1();} else{xian_0();}
if (x_0_1.3) {xian_1();} else{xian_0();}
if (x_0_1.2) {xian_1();} else{xian_0();}
if (x_0_1.1) {xian_1();} else{xian_0();}
if (x_0_1.0) {xian_1();} else{xian_0();}
if (x_0_2.7) {xian_1();} else{xian_0();}
if (x_0_2.6) {xian_1();} else{xian_0();}
if (x_0_2.5) {xian_1();} else{xian_0();}
if (x_0_2.4) {xian_1();} else{xian_0();}
if (x_0_2.3) {xian_1();} else{xian_0();}
if (x_0_2.2) {xian_1();} else{xian_0();}
if (x_0_2.1) {xian_1();} else{xian_0();}
//if (x_0_2.0) {xian_1();} else{xian_0();}
}
/**************************************************/
void xianshi_2() //显示第二行//反取
{
//if (x_1_2.0) {xian_1();} else{xian_0();}
if (x_1_2.1) {xian_1();} else{xian_0();}
if (x_1_2.2) {xian_1();} else{xian_0();}
if (x_1_2.3) {xian_1();} else{xian_0();}
if (x_1_2.4) {xian_1();} else{xian_0();}
if (x_1_2.5) {xian_1();} else{xian_0();}
if (x_1_2.6) {xian_1();} else{xian_0();}
if (x_1_2.7) {xian_1();} else{xian_0();}
if (x_1_1.0) {xian_1();} else{xian_0();}
if (x_1_1.1) {xian_1();} else{xian_0();}
if (x_1_1.2) {xian_1();} else{xian_0();}
if (x_1_1.3) {xian_1();} else{xian_0();}
if (x_1_1.4) {xian_1();} else{xian_0();}
if (x_1_1.5) {xian_1();} else{xian_0();}
if (x_1_1.6) {xian_1();} else{xian_0();}
if (x_1_1.7) {xian_1();} else{xian_0();}
}
/**************************************************/
void xianshi_3() //显示第三行
{
if (x_2_1.7) {xian_1();} else{xian_0();}
if (x_2_1.6) {xian_1();} else{xian_0();}
if (x_2_1.5) {xian_1();} else{xian_0();}
if (x_2_1.4) {xian_1();} else{xian_0();}
if (x_2_1.3) {xian_1();} else{xian_0();}
if (x_2_1.2) {xian_1();} else{xian_0();}
if (x_2_1.1) {xian_1();} else{xian_0();}
if (x_2_1.0) {xian_1();} else{xian_0();}
if (x_2_2.7) {xian_1();} else{xian_0();}
if (x_2_2.6) {xian_1();} else{xian_0();}
if (x_2_2.5) {xian_1();} else{xian_0();}
if (x_2_2.4) {xian_1();} else{xian_0();}
if (x_2_2.3) {xian_1();} else{xian_0();}
if (x_2_2.2) {xian_1();} else{xian_0();}
if (x_2_2.1) {xian_1();} else{xian_0();}
//if (x_2_2.0) {xian_1();} else{xian_0();}
}
/**************************************************/
void xianshi_4() //显示第四行//反取
{
//if (x_3_2.0) {xian_1();} else{xian_0();}
if (x_3_2.1) {xian_1();} else{xian_0();}
if (x_3_2.2) {xian_1();} else{xian_0();}
if (x_3_2.3) {xian_1();} else{xian_0();}
if (x_3_2.4) {xian_1();} else{xian_0();}
if (x_3_2.5) {xian_1();} else{xian_0();}
if (x_3_2.6) {xian_1();} else{xian_0();}
if (x_3_2.7) {xian_1();} else{xian_0();}
if (x_3_1.0) {xian_1();} else{xian_0();}
if (x_3_1.1) {xian_1();} else{xian_0();}
if (x_3_1.2) {xian_1();} else{xian_0();}
if (x_3_1.3) {xian_1();} else{xian_0();}
if (x_3_1.4) {xian_1();} else{xian_0();}
if (x_3_1.5) {xian_1();} else{xian_0();}
if (x_3_1.6) {xian_1();} else{xian_0();}
if (x_3_1.7) {xian_1();} else{xian_0();}
}
/**************************************************/
void xianshi_5() //显示第五行
{
if (x_4_1.7) {xian_1();} else{xian_0();}
if (x_4_1.6) {xian_1();} else{xian_0();}
if (x_4_1.5) {xian_1();} else{xian_0();}
if (x_4_1.4) {xian_1();} else{xian_0();}
if (x_4_1.3) {xian_1();} else{xian_0();}
if (x_4_1.2) {xian_1();} else{xian_0();}
if (x_4_1.1) {xian_1();} else{xian_0();}
if (x_4_1.0) {xian_1();} else{xian_0();}
if (x_4_2.7) {xian_1();} else{xian_0();}
if (x_4_2.6) {xian_1();} else{xian_0();}
if (x_4_2.5) {xian_1();} else{xian_0();}
if (x_4_2.4) {xian_1();} else{xian_0();}
if (x_4_2.3) {xian_1();} else{xian_0();}
if (x_4_2.2) {xian_1();} else{xian_0();}
if (x_4_2.1) {xian_1();} else{xian_0();}
//if (x_4_2.0) {xian_1();} else{xian_0();}
}
/**************************************************/
void xianshi_6() //显示第六行//反取
{
//if (x_5_1.0) {xian_1();} else{xian_0();}
if (x_5_2.1) {xian_1();} else{xian_0();}
if (x_5_2.2) {xian_1();} else{xian_0();}
if (x_5_2.3) {xian_1();} else{xian_0();}
if (x_5_2.4) {xian_1();} else{xian_0();}
if (x_5_2.5) {xian_1();} else{xian_0();}
if (x_5_2.6) {xian_1();} else{xian_0();}
if (x_5_2.7) {xian_1();} else{xian_0();}
if (x_5_1.0) {xian_1();} else{xian_0();}
if (x_5_1.1) {xian_1();} else{xian_0();}
if (x_5_1.2) {xian_1();} else{xian_0();}
if (x_5_1.3) {xian_1();} else{xian_0();}
if (x_5_1.4) {xian_1();} else{xian_0();}
if (x_5_1.5) {xian_1();} else{xian_0();}
if (x_5_1.6) {xian_1();} else{xian_0();}
if (x_5_1.7) {xian_1();} else{xian_0();}
}
/**************************************************/
void xianshi_7() //显示第七行
{
if (x_6_1.7) {xian_1();} else{xian_0();}
if (x_6_1.6) {xian_1();} else{xian_0();}
if (x_6_1.5) {xian_1();} else{xian_0();}
if (x_6_1.4) {xian_1();} else{xian_0();}
if (x_6_1.3) {xian_1();} else{xian_0();}
if (x_6_1.2) {xian_1();} else{xian_0();}
if (x_6_1.1) {xian_1();} else{xian_0();}
if (x_6_1.0) {xian_1();} else{xian_0();}
if (x_6_2.7) {xian_1();} else{xian_0();}
if (x_6_2.6) {xian_1();} else{xian_0();}
if (x_6_2.5) {xian_1();} else{xian_0();}
if (x_6_2.4) {xian_1();} else{xian_0();}
if (x_6_2.3) {xian_1();} else{xian_0();}
if (x_6_2.2) {xian_1();} else{xian_0();}
if (x_6_2.1) {xian_1();} else{xian_0();}
//if (x_6_2.0) {xian_1();} else{xian_0();}
}
/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/
|