⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managment.bak

📁 LED渐明变灭,遥控控制,总体变化,方便使用
💻 BAK
字号:
#include <reg51.h>
#include <string.h>
//#include <stdio.h>
//#include <intrins.h>

#include "types.h"
#include "key.h"
#include "managment.h"

sbit loadout_b=P1^7;
sbit loadout_g=P1^6;
sbit loadout_r=P1^5;
//#define out_p2 P2

void Timer0Init();
bit ts;
uchar en=0;
uchar tep,temp,ntep;
uchar  inc_rgb0, inc_rgb;
uchar led_buf[2];
uint plus;
uchar data  datap[8]={0xdf,0x9f,0xbf,0X3f,0X7f,0X5f,0x0,0xff};
statmode();

//---------------------------------

//uint md[12];
/***************************************************************************/
    ////////////////////////////////////////////////////
// 初始化,定时器T0工作在方式1,1ms中断一次
////////////////////////////////////////////////////
void Timer0Init()
{
	TMOD|=0x01;			//timer 0 work in 16 bit timer mode
	TL0=0x30;
	TH0=0xfb;			//timer 0 interrupt period is 1ms
	TR0=1;				//timer 0 runing
	ET0=1;
//    STATELED=1;			//timer 0 interrupt enable
}
//----------------------------
  loadout_rgb(uchar ch)
  {
   if(ch&0x20) loadout_r=1;
     else loadout_r=0;
   if(ch&0x40) loadout_g=1;
     else loadout_g=0;
   if(ch&0x80) loadout_b=1;
     else loadout_b=0;
  }
//-------------------------------
void rgb0_rgb(void)
 {
   if(plus>0x2648)
   {
   // if(!bzRxBufEmpty)
  //  {
    plus=0XC8;
    inc_rgb0=inc_rgb;
    inc_rgb++;
    if(inc_rgb>6) inc_rgb=1;
   // }
    //else plus=0x4c90;
    //ts=~ts;
   }
   re0: if(!TF0)  goto re0;
   TH0=(0xd8f0+plus)>>8;   //变窄
   TL0=0xd8f0+plus;//%256;
   //IntervalTime=0;
   loadout_rgb(datap[inc_rgb0]);
   //------------------------------------------
   re1:if(!TF0) goto re1;
   TH0=(0xffff-plus)>>8;   //变宽
   TL0=0xffff-plus;//%256;
   //IntervalTime=0;
   loadout_rgb(datap[inc_rgb]);
 }
//-----------------------
//statmode()
//{
 //led_buf[0]=led_buf[0]&0x0f;

//}
//------------------------------------------
void managment()
{
 switch(led_buf[0]&0x0f)
 {
 case 0: //BACK
        ts=0;
         loadout_rgb(0xdf);
        if(counter>(0x7d0-led_buf[1]*20))  counter=0;
        //onoff=1;
        break;
 case 1: //STATIC RED
        ts=0;
        loadout_rgb(0xbf);
        if(counter>(3500-led_buf[1]*35))  counter=0;
       // onoff=1;
        break;
 case 2: //STATIC GREEN
        ts=0;
        loadout_rgb(0x9f);
        if(counter>(5000-led_buf[1]*50))  counter=0;
       // onoff=1;
        break;
 case 3: //STATIC YELLOW
        ts=0;
        loadout_rgb(0x7f);
        if(counter>(5000-led_buf[1]*50))  counter=0;
       //onoff=1;
        break;
  case 4: //STATIC YELLOW
        ts=0;
        loadout_rgb(0x5f);
        if(counter>(5000-led_buf[1]*50)) counter=0;
       // onoff=1;
        break;
  case 5: //STATIC YELLOW
        ts=0;
        loadout_rgb(0x3f);
        if(counter>(5000-led_buf[1]*50))  counter=0;
       // onoff=1;
        break;
  case 6: //STATIC YELLOW
        ts=0;
        loadout_rgb(0x1f);
        if(counter>(5000-led_buf[1]*50))  counter=0;
       // onoff=1;
        break;
 case 7: //STATIC BLUE
       if(counter>(4000-led_buf[1]*40))
       {
        counter=0;
       temp++;
       if(temp>6) temp=0;
        loadout_rgb(temp<<5);
       // onoff=1;
        }
        break;
 case 8: //STATIC  PURPLE
       ts=1;
       rgb0_rgb();
       //onoff=1;
       break;
 default:
        break;
   }
 // onoff=0;
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -