/*******************五线数码管*********************/
/********************PMS150G***********************/
/****************QQ774145445***********************/
/****************快手:共同学习STM8*****************/
/****************20200926**************************/
/**************************************************/
//__________________________________________
//| __2a__ __3a__ 4a 4b |
//| 1a| | | | | IN OUT |
//| | 2f| 2b| 3f| 3b| 4c 4d |
//| __2g__ __3g__ 5V 2.1A |
//| 1b| | | | | |
//| | | | 3e| 3c| 4e 4f 4g |
//| __2d__ __3d__ % 5V 1.0A |
//| @1 @2 @3 @4 @5 |
//|_________________________________________|
/**************************************************/
//__________________________________________
//| | 1- | 2- | 3- | 4- | 5- |
//| 1+ | ** | 2f | 2b | 2d | 2g |
//| 2+ | 1a1b | ** | 3a | 3c | 3f |
//| 3+ | 2a | 3g | ** | 4e | 4b |
//| 4+ | 2c | 3b | 3d | ** | 4f4g |
//| 5+ | 2e | 3e | 4a | 4c4d | ** |
//|_________________________________________|
/**************************************************/
// ------@------
// --|VDD GND|--
// @3--|PA7 PA0|--@1
// @4--|PA6 PA4|--@2
// @5--|PA5 PA3|--PWM
// -------------
/**************************************************/
led1 bit pa.0;
led2 bit pa.4;
led3 bit pa.7;
led4 bit pa.6;
led5 bit pa.5;
/**************************************************/
void xianshi(); //显示
void xianshi_chushi(); //显示初始化
void xianshi_fenjie(); //显示分解
void xianshi_chabiao(); //显示查表
byte xianshi_a1; //0-100显示的数
byte xianshi_b1,xianshi_b2,xianshi_b3; //显示分解用百位十位个位
byte xianshi_d1,xianshi_d2; //返回的字模
byte shu_0 =0xc0;
byte shu_1 =0xf9;
byte shu_2 =0xa4;
byte shu_3 =0xb0;
byte shu_4 =0x99;
byte shu_5 =0x92;
byte shu_6 =0x82;
byte shu_7 =0xf8;
byte shu_8 =0x80;
byte shu_9 =0x90;
/**************************************************/
#include "extern.h"
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
$ led1 out;
$ led2 out;
$ led3 out;
$ led4 out;
$ led5 out,pull;
/**************************************************/
xianshi_a1=100;
while (1)
{
xianshi();
}
}
/**************************************************/
void xianshi() //显示
{
xianshi_fenjie(); //显示分解
xianshi_chabiao();
xianshi_chushi(); //第一次扫描
}
/**************************************************/
void xianshi_chushi() //显示初始化
{
led1 =1;
led2 =1;
led3 =1;
led4 =1;
led5 =1;
}
/**************************************************/
void xianshi_fenjie() //显示分解
{
byte xianshi_c1;
xianshi_c1 =xianshi_a1;
xianshi_b1 =0; //百位
xianshi_b2 =0; //十位
xianshi_b3 =0; //个位
if(xianshi_c1==100) //如果是100直接返回
{
xianshi_b1 =1; //百位
xianshi_b2 =0; //十位
xianshi_b3 =0; //个位
return;
}
else{xianshi_b1=0;}
while(xianshi_c1>9) //(xianshi_c1>=10) //减法代替除法算出十位
{
xianshi_c1 -=10; //自减10
xianshi_b2 ++;
}
xianshi_b3 =xianshi_c1; //个位
}
/**************************************************/
void xianshi_chabiao() //显示查表
{
if (xianshi_b2 ==0){xianshi_d1 =shu_0;}
if (xianshi_b2 ==1){xianshi_d1 =shu_1;}
if (xianshi_b2 ==2){xianshi_d1 =shu_2;}
if (xianshi_b2 ==3){xianshi_d1 =shu_3;}
if (xianshi_b2 ==4){xianshi_d1 =shu_4;}
if (xianshi_b2 ==5){xianshi_d1 =shu_5;}
if (xianshi_b2 ==6){xianshi_d1 =shu_6;}
if (xianshi_b2 ==7){xianshi_d1 =shu_7;}
if (xianshi_b2 ==8){xianshi_d1 =shu_8;}
if (xianshi_b2 ==9){xianshi_d1 =shu_9;}
if (xianshi_b3 ==0){xianshi_d2 =shu_0;}
if (xianshi_b3 ==1){xianshi_d2 =shu_1;}
if (xianshi_b3 ==2){xianshi_d2 =shu_2;}
if (xianshi_b3 ==3){xianshi_d2 =shu_3;}
if (xianshi_b3 ==4){xianshi_d2 =shu_4;}
if (xianshi_b3 ==5){xianshi_d2 =shu_5;}
if (xianshi_b3 ==6){xianshi_d2 =shu_6;}
if (xianshi_b3 ==7){xianshi_d2 =shu_7;}
if (xianshi_b3 ==8){xianshi_d2 =shu_8;}
if (xianshi_b3 ==9){xianshi_d2 =shu_9;}
}
/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/ |