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

📄 main.c

📁 内外差值法
💻 C
字号:
/********************************************************************************************\
*  *  *Copyright:the Freescale MCU&DSP laboratory of thecnology of HENAN university *   *   *

*  *  *File name: AW60_photodata_LCD12864showing.c                                  *   *   * 

*  *  *CPU: MC9S08AW60                                                              *   *   * 

*  *  *Compiler:CodWarrior V6.0 08s Compiler                                        *   *   *

*  *  *Author:qingsong Liu (a MCU_beginner)                                         *   *   *

*  *  *Dscription:This main file succeed in drawing the histogram for cmosdata.     *   *   *
                  And the cmosdata cellection  for every 20s!
*  *  *History:2008-8-1                                                             *   *   *

*  *  *Remaining:This program is far from perfict,so you'd better to improve it!    *   *   *

\********************************************************************************************/
#include "12864.h"       /* for EnableInterrupts macro */
#include "init.h"       /* include peripheral declarations */
#include "cmos.h"

/**************功能:图形数组***********************/
unsigned char TU_TAB1[16]={0};

/***************************************************\
******函数名称:商数写入函数
******函数功能:按商值判断写入图形数组数据个数
******函数参数:quotient- 确定写入的数据数 
******         station-- 确定写入的截止位置
******quotient和station一起决定了写入数据的位置
\***************************************************/

void quotient_draw (unsigned char quotient,unsigned char station)  
 {                              
  signed char i=quotient;       //将数据8等分后,写入商数个0xff
  for(;i>=station;i--)
   {
     TU_TAB1[i]=0xff;           //数据满足该组全部点亮
   }
 }
/***************************************************\
******函数名称:余数写入函数
******函数功能:按余数值判断写入图形数组数据点的个数
******函数参数:quotient- 确定写入的数据位置 
******         station-- 确定写入的数据点数
\***************************************************/ 
 void residue_draw (unsigned char quotient,unsigned char residue) 
 {
  switch(residue)               //得到余数后进行分支判断
  {
   case(0): TU_TAB1[quotient]=0x00;  break;
   case(1): TU_TAB1[quotient]=0x80;  break;
   case(2): TU_TAB1[quotient]=0xc0;  break;
   case(3): TU_TAB1[quotient]=0xe0;  break;
   case(4): TU_TAB1[quotient]=0xf0;  break;
   case(5): TU_TAB1[quotient]=0xf8;  break;
   case(6): TU_TAB1[quotient]=0xfc;  break;
   case(7): TU_TAB1[quotient]=0xfe;  break;
  }               
 }
/***************************************************\
******函数名称:图像数据转换函数
******函数功能:按比较值判断图形数组数据值
******函数参数:mnud- 图像数据比较值
******每个数组共包含两行数据的比较结果         
\***************************************************/ 
void data_switch(unsigned char mnud)
{
 unsigned char quotient,residue;
 quotient=cmos_data[row][mnud]/8;      //商值
 residue=cmos_data[row][mnud]%8;       //余数
 quotient_draw(quotient,0);          //调用商数写入函数,写前半屏数据
 residue_draw(quotient,residue);     //调用余数写入函数,写前半屏数据
 quotient=cmos_data[row+1][mnud]/8;      //商值
 residue=cmos_data[row+1][mnud]%8;       //余数
 quotient_draw(quotient+8,8);        //调用余数写入函数,写后半屏数据
 residue_draw(quotient+8,residue);   //调用余数写入函数,写后半屏数据
}

/*****************************************************\
*********函数名称:清零数组函数
*********函数功能:数组元素全部清零
*********函数参数:无
\******************************************************/

void clear1(void)
 {
  unsigned char j;
  for(j=0;j<=15;j++)          //将图形数组逐一清空
     {
      TU_TAB1[j]=0x00;
     }
 }   
 
/*****************************************************\
*********函数名称:写绘图函数
*********函数功能:将
*********函数参数:无
\******************************************************/ 
void phto_write(void)
 { 
   unsigned char minuend=0; //选择图像数据数组列
   unsigned char i;
   LCD_X=0X80;              //上半屏横轴起始坐标
   LCD_Y=0X80;              //纵轴起始坐标
   for(i=0;i<=15;i++) 
    { 
       clear1();            //清空数组
       data_switch(minuend);//调用图形数组转换函数
       PHO_DISP(TU_TAB1);   //调用写图形函数
       LCD_Y++;             //写完一行后,纵坐标加一
       clear1();
       PHO_DISP(TU_TAB1);   //调用写图形函数
       LCD_Y++;             //写完一行后,纵坐标加一
       minuend++;           //图像数据数组列加一
    }
   LCD_X=0X88;              //下半屏横轴起始坐标
   LCD_Y=0X80;              //纵轴起始坐标
   for(i=0;i<=15;i++)
      {
       clear1();            //清空数组
       data_switch(minuend);   //调用图形数组转换函数
       PHO_DISP(TU_TAB1);   //调用写图形函数
       LCD_Y++;             //写完一行后,纵坐标加一
       clear1();            //清空数组
       PHO_DISP(TU_TAB1);   //调用写图形函数
       LCD_Y++;             //写完一行后,纵坐标加一
       minuend++;           //图像数据数组列加一
      }      
   Lcd12864_Write_Command(0x36);    //打开绘图显示
   Lcd12864_Write_Command(0x30);    //打开基本动作集指令
   
 }
 
/*****************主函数***************************/
    
void main(void)
 {
  
   Init_all(); 
   EnableInterrupts;
   CMOS_getpic();
   phto_write();
   for(;;)
    {
     if(time>=1)
      {
       //Lcd12864_Write_Command(Clear_screen);
       phto_write();
       row+=2;    
       time=0;
      }
     //if(row>30)
     if(row>3)
      {
       CMOS_getpic();
       row=0;
       time=0;
      }
     __RESET_WATCHDOG();
    }
 }
 
 
 
 
 
 
 
 
 
 
 
  







  


   
   
   
   

⌨️ 快捷键说明

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