//改PMS150-C SOP23-6 WS2812
/****************WS281215*7************************/
/****************QQ:774145445**********************/
/****************快手:共同学习STM8*****************/
/*****************20210217*************************/
// 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"
chuan bit pa.3; //串行线
key bit pa.4; //按键
//byte led_liangdu; //亮度
//byte led_lv; //绿色
//byte led_hong; //红色
//byte led_lan; //蓝色
byte x_1_1,x_1_2; //显示ram
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 x_7_1,x_7_2;
/**************************************************/
void yi(); //发1
void ling(); //发0
void xianshi(); //显示
void xian_1(); //显示1
void xian_2(); //显示2
void xian_xin(); //显示心
void xian_zuo(); //显示左箭头
void xian_you(); //显示右箭头
void anjian(); //按键
/**************************************************/
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
$ chuan out,low; //设置为输出,低
$ key in,pull; //输入,上拉电阻
//xian_xin(); //显示心
//xian_zuo(); //显示左
//xian_you(); //显示右
byte a1,a2;
while (1)
{
a1=0;
while(a1<106)
{
a1++;
a2 =a1;
while(a2--)
{
ling();ling();ling();ling();ling();ling();ling();ling();
ling();ling();ling();ling();ling();ling();ling();ling();
ling();ling();ling();ling();ling();ling();ling();ling();
}
ling();ling();ling();ling();ling();ling();ling();ling();
ling();ling();ling();ling();ling();ling();ling();ling();
yi();ling();ling();ling();ling();ling();ling();ling();
.delay 500000;
}
//continue;
}
}
/**************************************************/
/*
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
*/
/**************************************************
void tu_xin() //图心
{
pcadd a; //a不能为0
ret 0x28;
ret 0x28;
ret 0x54;
ret 0x54;
ret 0x82;
ret 0x82;
ret 0x82;
ret 0x82;
ret 0x44;
ret 0x44;
ret 0x28;
ret 0x28;
ret 0x10;
ret 0x10;
}
/**************************************************/
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 xianshi() //显示
{
if(x_1_1.7){xian_1();} else{xian_2();} //第一行
if(x_1_1.6){xian_1();} else{xian_2();}
if(x_1_1.5){xian_1();} else{xian_2();}
if(x_1_1.4){xian_1();} else{xian_2();}
if(x_1_1.3){xian_1();} else{xian_2();}
if(x_1_1.2){xian_1();} else{xian_2();}
if(x_1_1.1){xian_1();} else{xian_2();}
if(x_1_1.0){xian_1();} else{xian_2();}
if(x_1_2.7){xian_1();} else{xian_2();}
if(x_1_2.6){xian_1();} else{xian_2();}
if(x_1_2.5){xian_1();} else{xian_2();}
if(x_1_2.4){xian_1();} else{xian_2();}
if(x_1_2.3){xian_1();} else{xian_2();}
if(x_1_2.2){xian_1();} else{xian_2();}
if(x_1_2.1){xian_1();} else{xian_2();}
//if(x_1_2.0){xian_1();} else{xian_2();}
//if(x_2_2.0){xian_1();} else{xian_2();} //第二行
if(x_2_2.1){xian_1();} else{xian_2();}
if(x_2_2.2){xian_1();} else{xian_2();}
if(x_2_2.3){xian_1();} else{xian_2();}
if(x_2_2.4){xian_1();} else{xian_2();}
if(x_2_2.5){xian_1();} else{xian_2();}
if(x_2_2.6){xian_1();} else{xian_2();}
if(x_2_2.7){xian_1();} else{xian_2();}
if(x_2_1.0){xian_1();} else{xian_2();}
if(x_2_1.1){xian_1();} else{xian_2();}
if(x_2_1.2){xian_1();} else{xian_2();}
if(x_2_1.3){xian_1();} else{xian_2();}
if(x_2_1.4){xian_1();} else{xian_2();}
if(x_2_1.5){xian_1();} else{xian_2();}
if(x_2_1.6){xian_1();} else{xian_2();}
if(x_2_1.7){xian_1();} else{xian_2();}
if(x_3_1.7){xian_1();} else{xian_2();} //第三行
if(x_3_1.6){xian_1();} else{xian_2();}
if(x_3_1.5){xian_1();} else{xian_2();}
if(x_3_1.4){xian_1();} else{xian_2();}
if(x_3_1.3){xian_1();} else{xian_2();}
if(x_3_1.2){xian_1();} else{xian_2();}
if(x_3_1.1){xian_1();} else{xian_2();}
if(x_3_1.0){xian_1();} else{xian_2();}
if(x_3_2.7){xian_1();} else{xian_2();}
if(x_3_2.6){xian_1();} else{xian_2();}
if(x_3_2.5){xian_1();} else{xian_2();}
if(x_3_2.4){xian_1();} else{xian_2();}
if(x_3_2.3){xian_1();} else{xian_2();}
if(x_3_2.2){xian_1();} else{xian_2();}
if(x_3_2.1){xian_1();} else{xian_2();}
//if(x_3_2.0){xian_1();} else{xian_2();}
//if(x_4_2.0){xian_1();} else{xian_2();} //第四行
if(x_4_2.1){xian_1();} else{xian_2();}
if(x_4_2.2){xian_1();} else{xian_2();}
if(x_4_2.3){xian_1();} else{xian_2();}
if(x_4_2.4){xian_1();} else{xian_2();}
if(x_4_2.5){xian_1();} else{xian_2();}
if(x_4_2.6){xian_1();} else{xian_2();}
if(x_4_2.7){xian_1();} else{xian_2();}
if(x_4_1.0){xian_1();} else{xian_2();}
if(x_4_1.1){xian_1();} else{xian_2();}
if(x_4_1.2){xian_1();} else{xian_2();}
if(x_4_1.3){xian_1();} else{xian_2();}
if(x_4_1.4){xian_1();} else{xian_2();}
if(x_4_1.5){xian_1();} else{xian_2();}
if(x_4_1.6){xian_1();} else{xian_2();}
if(x_4_1.7){xian_1();} else{xian_2();}
if(x_5_1.7){xian_1();} else{xian_2();} //第五行
if(x_5_1.6){xian_1();} else{xian_2();}
if(x_5_1.5){xian_1();} else{xian_2();}
if(x_5_1.4){xian_1();} else{xian_2();}
if(x_5_1.3){xian_1();} else{xian_2();}
if(x_5_1.2){xian_1();} else{xian_2();}
if(x_5_1.1){xian_1();} else{xian_2();}
if(x_5_1.0){xian_1();} else{xian_2();}
if(x_5_2.7){xian_1();} else{xian_2();}
if(x_5_2.6){xian_1();} else{xian_2();}
if(x_5_2.5){xian_1();} else{xian_2();}
if(x_5_2.4){xian_1();} else{xian_2();}
if(x_5_2.3){xian_1();} else{xian_2();}
if(x_5_2.2){xian_1();} else{xian_2();}
if(x_5_2.1){xian_1();} else{xian_2();}
//if(x_5_2.0){xian_1();} else{xian_2();}
//if(x_6_2.0){xian_1();} else{xian_2();} //第六行
if(x_6_2.1){xian_1();} else{xian_2();}
if(x_6_2.2){xian_1();} else{xian_2();}
if(x_6_2.3){xian_1();} else{xian_2();}
if(x_6_2.4){xian_1();} else{xian_2();}
if(x_6_2.5){xian_1();} else{xian_2();}
if(x_6_2.6){xian_1();} else{xian_2();}
if(x_6_2.7){xian_1();} else{xian_2();}
if(x_6_1.0){xian_1();} else{xian_2();}
if(x_6_1.1){xian_1();} else{xian_2();}
if(x_6_1.2){xian_1();} else{xian_2();}
if(x_6_1.3){xian_1();} else{xian_2();}
if(x_6_1.4){xian_1();} else{xian_2();}
if(x_6_1.5){xian_1();} else{xian_2();}
if(x_6_1.6){xian_1();} else{xian_2();}
if(x_6_1.7){xian_1();} else{xian_2();}
if(x_7_1.7){xian_1();} else{xian_2();} //第七行
if(x_7_1.6){xian_1();} else{xian_2();}
if(x_7_1.5){xian_1();} else{xian_2();}
if(x_7_1.4){xian_1();} else{xian_2();}
if(x_7_1.3){xian_1();} else{xian_2();}
if(x_7_1.2){xian_1();} else{xian_2();}
if(x_7_1.1){xian_1();} else{xian_2();}
if(x_7_1.0){xian_1();} else{xian_2();}
if(x_7_2.7){xian_1();} else{xian_2();}
if(x_7_2.6){xian_1();} else{xian_2();}
if(x_7_2.5){xian_1();} else{xian_2();}
if(x_7_2.4){xian_1();} else{xian_2();}
if(x_7_2.3){xian_1();} else{xian_2();}
if(x_7_2.2){xian_1();} else{xian_2();}
if(x_7_2.1){xian_1();} else{xian_2();}
//if(x_7_2.0){xian_1();} else{xian_2();}
}
/**************************************************/ //高位先发,按照 GRB 的顺序发送数据
void xian_1() //显示1
{
byte xian_1_a1;
xian_1_a1 =24;
while(xian_1_a1--)
{
yi();
}
/*
if(led_lv.7){yi();} else{ling();} //绿
if(led_lv.6){yi();} else{ling();}
if(led_lv.5){yi();} else{ling();}
if(led_lv.4){yi();} else{ling();}
if(led_lv.3){yi();} else{ling();}
if(led_lv.2){yi();} else{ling();}
if(led_lv.1){yi();} else{ling();}
if(led_lv.0){yi();} else{ling();}
if(led_hong.7){yi();} else{ling();} //红
if(led_hong.6){yi();} else{ling();}
if(led_hong.5){yi();} else{ling();}
if(led_hong.4){yi();} else{ling();}
if(led_hong.3){yi();} else{ling();}
if(led_hong.2){yi();} else{ling();}
if(led_hong.1){yi();} else{ling();}
if(led_hong.0){yi();} else{ling();}
if(led_lan.7){yi();} else{ling();} //蓝
if(led_lan.6){yi();} else{ling();}
if(led_lan.5){yi();} else{ling();}
if(led_lan.4){yi();} else{ling();}
if(led_lan.3){yi();} else{ling();}
if(led_lan.2){yi();} else{ling();}
if(led_lan.1){yi();} else{ling();}
if(led_lan.0){yi();} else{ling();}
*/
}
/**************************************************/
void xian_2() //显示2
{
byte xian_2_a1;
xian_2_a1 =24;
while(xian_2_a1--)
{
ling();
}
}
/**************************************************/
void xian_xin() //显示心
{
//双心 0x28,0x28,0x54,0x54,0x82,0x82,0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10
x_1_1 =0x28;
x_1_2 =0x28;
x_2_1 =0x54;
x_2_2 =0x54;
x_3_1 =0x82;
x_3_2 =0x82;
x_4_1 =0x82;
x_4_2 =0x82;
x_5_1 =0x44;
x_5_2 =0x44;
x_6_1 =0x28;
x_6_2 =0x28;
x_7_1 =0x10;
x_7_2 =0x10;
//led_lv =4;
//led_hong =50;
//led_lan =4;
xianshi();
}
/**************************************************/
void xian_zuo() //显示左箭头
{
//左箭头0x00,0x00,0x10,0x00,0x20,0x00,0x7F,0xFC,0x20,0x00,0x10,0x00,0x00,0x00
x_1_1 =0x00;
x_1_2 =0x00;
x_2_1 =0x10;
x_2_2 =0x00;
x_3_1 =0x20;
x_3_2 =0x00;
x_4_1 =0x7f;
x_4_2 =0xfc;
x_5_1 =0x20;
x_5_2 =0x00;
x_6_1 =0x10;
x_6_2 =0x00;
x_7_1 =0x00;
x_7_2 =0x00;
//led_lv =60;
//led_hong =70;
//led_lan =0;
xianshi();
}
/**************************************************/
void xian_you() //显示右箭头
{
//右箭头0x00,0x00,0x00,0x10,0x00,0x08,0x7F,0xFC,0x00,0x08,0x00,0x10,0x00,0x00
x_1_1 =0x00;
x_1_2 =0x00;
x_2_1 =0x00;
x_2_2 =0x10;
x_3_1 =0x00;
x_3_2 =0x08;
x_4_1 =0x7f;
x_4_2 =0xfc;
x_5_1 =0x00;
x_5_2 =0x08;
x_6_1 =0x00;
x_6_2 =0x10;
x_7_1 =0x00;
x_7_2 =0x00;
//led_lv =60;
//led_hong =70;
//led_lan =0;
xianshi();
}
/**************************************************/
void anjian() //按键
{
while(key) //死循环等待按下
{
nop;
}
while(!key) //等待松手
{
nop;
}
}
/**************************************************/
|
|