最新日志

发表于:2008-6-29 19:55:12
标签:无标签

0

080629写了个按键的程序(扫描方式)

        刚刚写了个5个按键,扫描方式检测的。烧写进实验板后发现按起来不够灵敏,常常是按N多次才响应一次,高手帮忙看看什么问题。程序包在下面附件里,打算再用中断方式写一个看看。

         按键用的是GPF0~GPF4,设置输入 ,然后检测。有按键放开后响应,UART0输出相应按键信息,同时LED7闪烁相应次数相应。

     程序包:   点击下载

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(38)
发表于:2008-6-28 14:37:02
标签:无标签

0

080628我的开发板,有PP

          得空拍了张图,大家可以看看!

        点击看大图

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(1) | 阅读(63)
发表于:2008-6-28 11:38:58
标签:无标签

0

080628我的第一个ARM2410程序(2)

             昨天说了一下工程建立、编译链接及得到BIN文件,现在只要烧写到SDRAM里面就可以跑起来看看现象了。烧写前准备工作要做好。

                1.先将板的串口线、USB线将PC同实验板连好,一般串口选串口0,具体可能有不同。USB线A字头的连到实验板上,另一端连USBPC机口。当然,板的电源也要。

                2.打开调试工具DNW,这个到处都能下到。打开之后,先配置串口点Configuration>Options,出现下面框:

                

          波特率选择115200,com根据你实际用的选。OK之后,点Serial Port>Connect,连接好的话出现下面的框的样子

                

       我这个USB的驱动也装好了 ,所以后面USB那里有0K字样,如果没装驱动,显示的是+(一个叉)。

               假设我的驱动没有装,要用USB下载,就要装上驱动,基本步骤如下:

在线都连好之后,上电实验板。串口出现提示信息,如下图

               

          这时会提示新硬件,弹出安装驱动的框,如果没有,就按ESC,再选择0.

出现安装驱动提示框后,就像平时装驱动一样安装驱动secbulk.inf,安装完就可以用USB下载了,安装成功会提示如下:

             

        然后就可以用USB Port>Transmit下载程序了

             下载会出现进度条,下载完之后会出现提示信息,是否运行程序,如下图:

            

          选者Y运行程序,就看见GFIO6出来的LED在闪烁了。

       

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(54)
发表于:2008-6-28 1:34:33
标签:无标签

0

080627成功的烧写到板上,跑了我的第一个程序(1)

              今天晚上花了点时间将昨天写好的程序,成功的下到了板上,跑了起来,迈出了实验的第一步。其中用USB下载花了我点时间来装驱动。现在将我跑的第一个程序过程给大家分享下。

               首先是用ADS1.2写一个程序,并编译链接。

                1.打开ADS1.2

         

      2.File>New

         

  3.建立工程,工程名2410LED,地址存在H:\实验程序\2410LED。前面选择第一项ARM Executable Image。至于下面各项的意义,各位可以到网上下ADS1.2的教程来看看。

       

  4.确定之后

      

      5.点击下图红框,进行调试设置。

    

     点击后,出现下面方框,Targets Setting里,图示Post-Linker选择ARM fromELF。

   

   接着设置Language Setting,将前面两项ARM Assembler和ARM C Compiler在Targets项选者ARM920T,我想大家都明白为什么。

     点击看大图

设置ARM Linker,将RO Base设为0x30000000,RW Base设为0x33000000.如下图

点击看大图

转到ARM Linker里面的Layout项,设置如下图:

点击看大图

最后设置ARM fromELF,我们选者输出2进制文件,输出文件名设为2410LED.bin

点击看大图

6.下面向工程中添加文件,大家可以先把我工程包里面的所有C文件和汇编文件拷到上面建的工程文件文件夹里。在工程管理框里邮寄,出现Add Files...,点击出现加文件的框

 

将工程文件夹里所有的C文件和汇编(S文件)添加到工程,有错误点确定。

 

加入后,工程管理框如下:

 

点击上图DebugRel右边的Make图标,编译链接程序。出现一个Error&Warning框,最上面行有显示错误数,警告数等,当错误数为0是通过编译链接,在工程文件家的2410LED_data里的DebugRel中出现2410LED.bin

点击看大图

工程包:

点击下载

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(133)
发表于:2008-6-27 0:10:59
标签:无标签

0

关于IO口模拟SPI

               最近有朋友问到IO口模拟SPI的问题,其实光模拟来说,就时序问题,读取和写入一个字节的时序。

                   首先选4个IO口,作模拟用,分别模拟CS、SCLK、SI、SO.即是片选、时钟、数据输入、数据输出。

                   IO口初始化,分别把对应的IO口设置输入输出。CS、SCLK、SO、设置为输出,SI设置为输入。

                     然后就是时序问题了,一般如下:

//设要写的数据是abyte表示。 

CS_1;              //片选高,
SCLK_1;        //时钟高
CS_0;              //片选低,开始工作。
for(i=0;i<8;i++)//循环产生时钟,写入数据。

{
SCLK_0;          //时钟低,下降沿
if(0x80&abyte)
SO_1;        
else
SO_0;
SCLK_1;
abyte<<=1;
}
SCLK_0;
CS_1;

 

//设要读的数据是abyte表示。 

CS_0;

SCLK_1;

for(i=0;i<8;i++)//读取数据值。
{
SCLK_0;
;;
SCLK_1;
abyte<<=1;
if(in_SI)
abyte++;
}
SCLK_0;
CS_1;

点击此处查看原文 >>

系统分类: 单片机   |    用户分类:    |    来源: 无分类

评论(0) | 阅读(54)
发表于:2008-6-26 22:51:14
标签:无标签

0

080626Make成第一个实验程序

        经过近两天对ADS和2410用户手册的学习,终于搞定了一个可以烧到板上的实验程序。由于板现在不在宿舍,所以还无法搞定。明天看能不能烧到板上跑起来。程序是从网上淘的一个,做了小小修改,以便可以和我的开发板配好。成功与否以及问题,明天同大家讨论。

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(51)
发表于:2008-6-18 23:33:46
标签:无标签

0

080618买的ARM9-2410板到了,慢慢学一下。

           最近好长时间都没上博了,这段时间好好的理了下工作,最后决定在闲空之余学习一下嵌入式系统,上周在淘宝上买了一块开发板,今天终于一睹了真容。上电试了一下,还不错。上面已经有了个wince的系统,可以跑了,就是触摸屏有点划痕,看起来不爽。由于这两天都有紧要事做,肯能一段时间不能上来了,对于开发板的PP,有空在发。希望在学习过程中,各位高手能指点一二。

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(2) | 阅读(78)
发表于:2008-3-15 11:19:17
标签:无标签

0

AVR(Mega8)的study:14、LCD3510液晶字符

液晶显示字符是不可少的,对于3510,自身没有字库,需要自己建,我用了LCDzimo取模,采用点阵显示。

点击看大图

//LCD3510.C

#include
#include "mytype.h"
#include "math.h"
#include "lcd3510.h"
#include "ascii.h"
#include "uart.h"

uint8 table[16]={"0123456789abcdef"};
void DelayXms(uint16 x)
{
 uint8 i;
 while(x--)
  {
   i="1275";
   while(i--);
  }
}

/**************************************************************   ************
 液晶硬件复位
******************************************************************************/
void LcdReset(void)
{
 ClrLcdRst();
 DelayXms(5);
 SetLcdRst();
 DelayXms(5);
}
/**************************************************************************************************
 发送命令
 ******************************************************************************************************/
void LcdSendCommand(uint8 cmd)
{
 uint8 i;
 SetSdataOut();
 ClrLcdCs();
 ClrLcdSclk();
 ClrLcdSdata();
 SetLcdSclk();
 
 for(i=0;i<8;i++)
  {
   ClrLcdSclk();
   if(cmd & 0x80)
    {
     SetLcdSdata();
    }
   else
    {
     ClrLcdSdata();
    }
   SetLcdSclk();
   cmd<<=1;
  }
}

/*****************************************************************************
发送数据
****************************************************************************************/
void LcdSendData(uint32 Data)
{
 uint32 i;
 SetSdataOut();
 ClrLcdCs();
 ClrLcdSclk();
 SetLcdSdata();
 SetLcdSclk();

 for(i=0;i<8;i++)
  {
   ClrLcdSclk();
   if(Data & 0x80)
    {
     SetLcdSdata();
    }
   else
    {
     ClrLcdSdata();
    }
   SetLcdSclk();
   Data<<=1;
  }
}
/***************************************************************************
液晶端口初始化
************************************************************************/
void LcdPortInit(void)
{
DDR4|=((1<DDR2|=((1<SetLcdRst();
SetLcdCs();
SetLcdSclk();
}

/**********************************************************************
液晶初始化 
*************************************************************************/
void LcdInit(void)
{
 uint8 i;
 LcdPortInit();

 LcdReset();
 LcdSendCommand(0x01);  //soft reset
 SetLcdCs();
 
 DelayXms(5);
 LcdSendCommand(0xc6);     //initial escape
 SetLcdCs();

 LcdSendCommand(0xb9);  //refresh set
 LcdSendData(0x00);
 SetLcdCs();

 LcdSendCommand(0xb6);  //display control
 LcdSendData(0x80);
 LcdSendData(0x80);
 LcdSendData(0x81);
 LcdSendData(84);
 LcdSendData(69);
 LcdSendData(82);
 LcdSendData(67);
 SetLcdCs();

 LcdSendCommand(0xb3);  //gray scale position set
 LcdSendData(1);
 LcdSendData(2);
 LcdSendData(4);
 LcdSendData(8);
 LcdSendData(16);
 LcdSendData(30);
 LcdSendData(40);
 LcdSendData(50);
 LcdSendData(60);
 LcdSendData(70);
 LcdSendData(80);
 LcdSendData(90);
 LcdSendData(100);
 LcdSendData(110);
 LcdSendData(127);
 SetLcdCs();

 LcdSendCommand(0xb5);  //gamma curve set
 LcdSendData(0x01);
 SetLcdCs();

 LcdSendCommand(0xbd);  //common driver output select
 LcdSendData(0x00);
 SetLcdCs();

 LcdSendCommand(0xbe);  //power control
 LcdSendData(0x04);
 SetLcdCs();

 LcdSendCommand(0x11);  //sleep out
 SetLcdCs();
 
 LcdSendCommand(0xba);  //voltage control
 LcdSendData(127);
 LcdSendData(3);
 SetLcdCs();

 LcdSendCommand(0xb7);  //temperature gradient set
 for(i=0; i<14; i++)
  {
   LcdSendData(0x00);
  }
 SetLcdCs();

 LcdSendCommand(0x29);  //display ON
 SetLcdCs();

 LcdSendCommand(0x03);  //booster voltage ON
 SetLcdCs();
 DelayXms(5);

 LcdSendCommand(0x20);  //display inversion OFF
 SetLcdCs();
 
 LcdSendCommand(0x25);  //write contrast
 LcdSendData(63);
 SetLcdCs();
}
/* ************************************************************************
液晶清屏 
*****************************************************************************/
void LcdClr(void)
{
 uint8 x, y;
 LcdSendCommand(0x2a);  //column address set
 LcdSendData(0);
 LcdSendData(97);
 SetLcdCs();

 LcdSendCommand(0x2b);  //page address set
 LcdSendData(0);
 LcdSendData(66);
 SetLcdCs();
 
 LcdSendCommand(0x2c);  //memory write
 for(y=0;y<67;y++)
  {
   for(x=0;x<98;x+=2)
    {
     LcdSendData(0);
     LcdSendData(0);
     LcdSendData(0);
    }
  }
 SetLcdCs();
}


 /*******************************************************************************************
 画点
 *******************************************************************************************/
 void LcdPointWrite(uint8 x, uint8 y,uint8 rr,uint8 gg,uint8 bb)
 {
 uint8 b1,b2;
 b1=~(((rr<<4)&0xf0)|(gg&0x0f));
 b2=~(((bb<<4)&0xf0)|(rr&0x0f));
 LcdSendCommand(0x2a);  //column address set
 LcdSendData(x);
 LcdSendData(x);
 SetLcdCs();

 LcdSendCommand(0x2b);  //page address set
 LcdSendData(y);
 LcdSendData(y);
 SetLcdCs();

 LcdSendCommand(0x2c);  //memory write
 
     LcdSendData(b1);
     LcdSendData(b2);
 SetLcdCs(); 
}

/**************************************************************************
16*8字符   
***************************************************************************/

void LCD_Drawletter(uint8 x,uint8 y,uint8  p,uint8 rr,uint8 gg,uint8 bb)
{
uint8 x1,y1,p1;
for(y1=y;y1<=(y+15);y1++)
    {p1=ASCII[(uint16)((uint16)(y1-y)+(uint16)((p-32)*16))];
 
    for(x1=x;x1<=(x+7);x1++)
       {if((p1&0x80)==0x80)
              LcdPointWrite(x1, y1,rr,gg,bb);
          else ;
    p1=p1<<1;
    }
 }
}

//ascii.h

// ------------------  ASCII字模的数据表 ------------------------ //
// 码表从0x20~0x7e                                                //
// 字库: E:\LcmZimo\Asc8X16E.dat 横向取模左高位                   //
// -------------------------------------------------------------- //
unsigned char ASCII[] =              // ASCII
{
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // - -
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18,  // -!-
 0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,

 0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,  // -"-
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x6C,0x6C,0xFE,0x6C,0x6C,  // -#-
 0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,

 0x18,0x18,0x7C,0xC6,0xC2,0xC0,0x7C,0x06,  // -$-
 0x86,0xC6,0x7C,0x18,0x18,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0xC2,0xC6,0x0C,0x18,  // -%-
 0x30,0x60,0xC6,0x86,0x00,0x00,0x00,0x00,

 0x00,0x00,0x38,0x6C,0x6C,0x38,0x76,0xDC,  // -&-
 0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,

 0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,  // -'-
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x0C,0x18,0x30,0x30,0x30,0x30,  // -(-
 0x30,0x30,0x18,0x0C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x30,0x18,0x0C,0x0C,0x0C,0x0C,  // -)-
 0x0C,0x0C,0x18,0x30,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x66,0x3C,0xFF,  // -*-
 0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,  // -+-
 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -,-
 0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,  // ---
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -.-
 0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x02,0x06,0x0C,0x18,  // -/-
 0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0xC6,0xCE,0xD6,0xD6,  // -0-
 0xE6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,  // -1-
 0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30,  // -2-
 0x60,0xC0,0xC6,0xFE,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0x06,0x06,0x3C,0x06,  // -3-
 0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE,  // -4-
 0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,

 0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xFC,0x0E,  // -5-
 0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x38,0x60,0xC0,0xC0,0xFC,0xC6,  // -6-
 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0xFE,0xC6,0x06,0x06,0x0C,0x18,  // -7-
 0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7C,0xC6,  // -8-
 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06,  // -9-
 0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,  // -:-
 0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,  // -;-
 0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,  // -<-
 0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,  // -=-
 0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06,  // ->-
 0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0xC6,0x0C,0x18,0x18,  // -?-
 0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x7C,0xC6,0xC6,0xDE,0xDE,  // -@-
 0xDE,0xDC,0xC0,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,  // -A-
 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,

 0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x66,  // -B-
 0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00,

 0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,  // -C-
 0xC0,0xC2,0x66,0x3C,0x00,0x00,0x00,0x00,

 0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66,  // -D-
 0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00,

 0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,  // -E-
 0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00,

 0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,  // -F-
 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,

 0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xDE,  // -G-
 0xC6,0xC6,0x66,0x3A,0x00,0x00,0x00,0x00,

 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xFE,0xC6,  // -H-
 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,  // -I-
 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,  // -J-
 0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00,

 0x00,0x00,0xE6,0x66,0x6C,0x6C,0x78,0x78,  // -K-
 0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,

 0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60,  // -L-
 0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00,

 0x00,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,  // -M-
 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,

 0x00,0x00,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE,  // -N-
 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xC6,  // -O-
 0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00,

 0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x60,  // -P-
 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,  // -Q-
 0xC6,0xD6,0xDE,0x7C,0x0C,0x0E,0x00,0x00,

 0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C,  // -R-
 0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7C,0xC6,0xC6,0x60,0x38,0x0C,  // -S-
 0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x7E,0x7E,0x5A,0x18,0x18,0x18,  // -T-
 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,

 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,  // -U-
 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,  // -V-
 0xC6,0x6C,0x38,0x10,0x00,0x00,0x00,0x00,

 0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,  // -W-
 0xD6,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,

 0x00,0x00,0xC6,0xC6,0x6C,0x6C,0x38,0x38,  // -X-
 0x6C,0x6C,0xC6,0xC6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x18,  // -Y-
 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,

 0x00,0x00,0xFE,0xC6,0x86,0x0C,0x18,0x30,  // -Z-
 0x60,0xC2,0xC6,0xFE,0x00,0x00,0x00,0x00,

 /*0x00,0x00,0x3C,0x30,0x30,0x30,0x30,0x30,  // -[-
 0x30,0x30,0x30,0x3C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,  // -\-
 0x1C,0x0E,0x06,0x02,0x00,0x00,0x00,0x00,

 0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,  // -]-
 0x0C,0x0C,0x0C,0x3C,0x00,0x00,0x00,0x00,

 0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,  // -^-
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -_-
 0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,

 0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,  // -`-
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,  // -a-
 0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,

 0x00,0x00,0xE0,0x60,0x60,0x78,0x6C,0x66,  // -b-
 0x66,0x66,0x66,0xDC,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0,  // -c-
 0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x1C,0x0C,0x0C,0x3C,0x6C,0xCC,  // -d-
 0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xFE,  // -e-
 0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x38,0x6C,0x64,0x60,0xF0,0x60,  // -f-
 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,  // -g-
 0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78,0x00,

 0x00,0x00,0xE0,0x60,0x60,0x6C,0x76,0x66,  // -h-
 0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,  // -i-
 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x06,0x06,0x00,0x0E,0x06,0x06,  // -j-
 0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00,

 0x00,0x00,0xE0,0x60,0x60,0x66,0x6C,0x78,  // -k-
 0x78,0x6C,0x66,0xE6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,  // -l-
 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0xEC,0xFE,0xD6,  // -m-
 0xD6,0xD6,0xD6,0xD6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,  // -n-
 0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,  // -o-
 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,  // -p-
 0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,

 0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,  // -q-
 0xCC,0xCC,0xCC,0x7C,0x0C,0x0C,0x1E,0x00,

 0x00,0x00,0x00,0x00,0x00,0xDC,0x76,0x62,  // -r-
 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0x60,  // -s-
 0x38,0x0C,0xC6,0x7C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x10,0x30,0x30,0xFC,0x30,0x30,  // -t-
 0x30,0x30,0x36,0x1C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,  // -u-
 0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,  // -v-
 0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,  // -w-
 0xD6,0xD6,0xFE,0x6C,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,  // -x-
 0x38,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,  // -y-
 0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0xF8,0x00,

 0x00,0x00,0x00,0x00,0x00,0xFE,0xCC,0x18,  // -z-
 0x30,0x60,0xC6,0xFE,0x00,0x00,0x00,0x00,

 /*0x00,0x00,0x0E,0x18,0x18,0x18,0x70,0x18,  // -{-
 0x18,0x18,0x18,0x0E,0x00,0x00,0x00,0x00,

 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18,  // -|-
 0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,

 0x00,0x00,0x70,0x18,0x18,0x18,0x0E,0x18,  // -}-
 0x18,0x18,0x18,0x70,0x00,0x00,0x00,0x00,

 0x00,0x00,0x76,0xDC,0x00,0x00,0x00,0x00,  // -~-
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x10,0x38,0x6C,0xC6,  // --
 0xC6,0xC6,0xFE,0x00,0x00,0x00,0x00,0x00,*/
};

 

点击此处查看原文 >>

系统分类: 单片机   |    用户分类:    |    来源: 原创

评论(0) | 阅读(296)
发表于:2008-3-15 11:13:44
标签:无标签

0

AVR(Mega8)的study:13、点亮LCD3510液晶画圆

上一篇讲了画矩形及多边形,以及实块,由于资源问题没能将画圆及圆形实块等加上,这次分开说一下。

效果图:(由于液晶像素点不是正方形,所以看起来圆有点椭,呵呵!)

点击看大图

点击看大图

//lcd3510.c

#include <iom8v.h>
#include "mytype.h"
#include "math.h"
#include "lcd3510.h"


void DelayXms(uint16 x)
{
 uint8 i;
 while(x--)
  {
   i="1275";
   while(i--);
  }
}

/**************************************************************  

************
 液晶硬件复位
*****************************************************************************

*/
void LcdReset(void)
{
 ClrLcdRst();
 DelayXms(5);
 SetLcdRst();
 DelayXms(5);
}
/****************************************************************************

**********************
 发送命令
 

*****************************************************************************

*************************/
void LcdSendCommand(uint8 cmd)
{
 uint8 i;
 SetSdataOut();
 ClrLcdCs();
 ClrLcdSclk();
 ClrLcdSdata();
 SetLcdSclk();
 
 for(i=0;i<8;i++)
  {
   ClrLcdSclk();
   if(cmd & 0x80)
    {
     SetLcdSdata();
    }
   else
    {
     ClrLcdSdata();
    }
   SetLcdSclk();
   cmd<<=1;
  }
}

/****************************************************************************

*
发送数据
*****************************************************************************

***********/
void LcdSendData(uint32 Data)
{
 uint32 i;
 SetSdataOut();
 ClrLcdCs();
 ClrLcdSclk();
 SetLcdSdata();
 SetLcdSclk();

 for(i=0;i<8;i++)
  {
   ClrLcdSclk();
   if(Data & 0x80)
    {
     SetLcdSdata();
    }
   else
    {
     ClrLcdSdata();
    }
   SetLcdSclk();
   Data<<=1;
  }
}
/***************************************************************************
液晶端口初始化
************************************************************************/
void LcdPortInit(void)
{
DDR4|=((1<<LCD_RST)|(1<<LCD_CS));
DDR2|=((1<<LCD_SDATA)|(1<<LCD_SCLK));
SetLcdRst();
SetLcdCs();
SetLcdSclk();
}

/**********************************************************************
液晶初始化 
*************************************************************************/
void LcdInit(void)
{
 uint8 i;
 LcdPortInit();

 LcdReset();
 LcdSendCommand(0x01);  //soft reset
 SetLcdCs();
 
 DelayXms(5);
 LcdSendCommand(0xc6);     //initial escape
 SetLcdCs();

 LcdSendCommand(0xb9);  //refresh set
 LcdSendData(0x00);
 SetLcdCs();

 LcdSendCommand(0xb6);  //display control
 LcdSendData(0x80);
 LcdSendData(0x80);
 LcdSendData(0x81);
 LcdSendData(84);
 LcdSendData(69);
 LcdSendData(82);
 LcdSendData(67);
 SetLcdCs();

 LcdSendCommand(0xb3);  //gray scale position set
 LcdSendData(1);
 LcdSendData(2);
 LcdSendData(4);
 LcdSendData(8);
 LcdSendData(16);
 LcdSendData(30);
 LcdSendData(40);
 LcdSendData(50);
 LcdSendData(60);
 LcdSendData(70);
 LcdSendData(80);
 LcdSendData(90);
 LcdSendData(100);
 LcdSendData(110);
 LcdSendData(127);
 SetLcdCs();

 LcdSendCommand(0xb5);  //gamma curve set
 LcdSendData(0x01);
 SetLcdCs();

 LcdSendCommand(0xbd);  //common driver output select
 LcdSendData(0x00);
 SetLcdCs();

 LcdSendCommand(0xbe);  //power control
 LcdSendData(0x04);
 SetLcdCs();

 LcdSendCommand(0x11);  //sleep out
 SetLcdCs();
 
 LcdSendCommand(0xba);  //voltage control
 LcdSendData(127);
 LcdSendData(3);
 SetLcdCs();

 LcdSendCommand(0xb7);  //temperature gradient set
 for(i=0; i<14; i++)
  {
   LcdSendData(0x00);
  }
 SetLcdCs();

 LcdSendCommand(0x29);  //display ON
 SetLcdCs();

 LcdSendCommand(0x03);  //booster voltage ON
 SetLcdCs();
 DelayXms(5);

 LcdSendCommand(0x20);  //display inversion OFF
 SetLcdCs();
 
 LcdSendCommand(0x25);  //write contrast
 LcdSendData(63);
 SetLcdCs();
}
/* ************************************************************************
液晶清屏 
*****************************************************************************

/
void LcdClr(void)
{
 uint8 x, y;
 LcdSendCommand(0x2a);  //column address set
 LcdSendData(0);
 LcdSendData(97);
 SetLcdCs();

 LcdSendCommand(0x2b);  //page address set
 LcdSendData(0);
 LcdSendData(66);
 SetLcdCs();
 
 LcdSendCommand(0x2c);  //memory write
 for(y=0;y<67;y++)
  {
   for(x=0;x<98;x+=2)
    {
     LcdSendData(0);
     LcdSendData(0);
     LcdSendData(0);
    }
  }
 SetLcdCs();
}


 

/****************************************************************************

***************
 画点
 

*****************************************************************************

**************/
 void LcdPointWrite(uint8 x, uint8 y,uint8 rr,uint8 gg,uint8 bb)
 {
 uint8 b1,b2;
 b1=~(((rr<<4)&0xf0)|(gg&0x0f));
 b2=~(((bb<<4)&0xf0)|(rr&0x0f));
 LcdSendCommand(0x2a);  //column address set
 LcdSendData(x);
 LcdSendData(x);
 SetLcdCs();

 LcdSendCommand(0x2b);  //page address set
 LcdSendData(y);
 LcdSendData(y);
 SetLcdCs();

 LcdSendCommand(0x2c);  //memory write
 
     LcdSendData(b1);
     LcdSendData(b2);
 SetLcdCs(); 
}
/***************************************************************************
画线  
*****************************************************************************

/
void LCD_DrawLine(uint8 x1, uint8 y1, uint8 x2, uint8 y2,uint8 rr,uint8

gg,uint8 bb)
{
uint8 x,y;
if(x1<x2)
  for(x=x1;x<=x2;x++)
    {
 if(y1<=y2)
      { y="y1"+(uint16)((x-x1)*(y2-y1))/(x2-x1);
       LcdPointWrite(x,y,rr,gg,bb);}
 else
   {y=y1-(uint16)((x-x1)*(y1-y2))/(x2-x1);
     LcdPointWrite(x, y,rr,gg,bb);}
    }
else if(x1==x2)
     { x="x1";
      if(y1<=y2)
        {for(y=y1;y<=y2;y++)
        LcdPointWrite(x, y,rr,gg,bb);}
      else {
      for(y=y2;y<=y1;y++)
         LcdPointWrite(x, y,rr,gg,bb);}
      }
 else  for(x=x2;x<=x1;x++)
     {
   if(y1>=y2)
        { y="y1-"(uint16)((x1-x)*(y1-y2))/(x1-x2);
         LcdPointWrite(x, y,rr,gg,bb);}
   else
      {y=y1+(uint16)((x1-x)*(y2-y1))/(x1-x2);
   LcdPointWrite(x, y,rr,gg,bb);}
       }

if(y1<y2)
  for (y=y1;y<=y2;y++)
  {
  if(x1<=x2)
    {x=x1+(uint16)((y-y1)*(x2-x1))/(y2-y1);
  LcdPointWrite(x, y,rr,gg,bb);}
   else
     {x=x1-(uint16)((y-y1)*(x1-x2))/(y2-y1);
  LcdPointWrite(x, y,rr,gg,bb);}
   }
else if(y1==y2)
   {y=y1;
    if(x1<=x2)
    {for(x=x1;x<=x2;x++)
    LcdPointWrite(x, y,rr,gg,bb);}
 else
    {for(x=x2;x<=x1;x++)
    LcdPointWrite(x, y,rr,gg,bb);}
 }
else 
   for(y=y2;y<=y1;y++)
   {
   if(x1<=x2)
     {x=x1+(uint16)((y1-y)*(x2-x1))/(y1-y2);
      LcdPointWrite(x, y,rr,gg,bb);}
   else 
     {x=x1-(uint16)((y1-y)*(x1-x2))/(y1-y2);
      LcdPointWrite(x, y,rr,gg,bb);}
   }  

/****************************************************************************

******
画圆  
*****************************************************************************

******/

void LCD_Drawcir(uint8 x1,uint8 y1,uint8 r,uint8 rr,uint8 gg,uint8 bb)
{
uint8 x,y;
if(x1>=r)
   x=(x1-r);
else
   x="0";
for(x;x<=(x1+r);x++)
   {y=sqrt((uint16)(r*r)-(uint16)((x-x1)*(x-x1)))+y1;
   if((y-2*sqrt((uint16)(r*r)-(uint16)((x-x1)*(x-x1))))<0)
       LcdPointWrite(x, y,rr,gg,bb);
  else
      {LcdPointWrite(x, y,rr,gg,bb);
       LcdPointWrite(x,(y-2*sqrt((uint16)(r*r)-(uint16)((x-x1)*(x-x1))))

,rr,gg,bb); }
    }
if(y1>=r)
     y=(y1-r);
else
     y="0";
for(y;y<=(y1+r);y++)
   {x=sqrt((uint16)(r*r)-(uint16)((y-y1)*(y-y1)))+x1;
   if((x-2*sqrt((uint16)(r*r)-(uint16)((y-y1)*(y-y1))))<0)
       LcdPointWrite(x, y,rr,gg,bb);
  else
      { LcdPointWrite(x, y,rr,gg,bb);
        LcdPointWrite((x-2*sqrt((uint16)(r*r)-(uint16)((y-y1)*(y-y1)))),y

,rr,gg,bb);}
    } 
}
/**************************************************************************
圆形实块   
*****************************************************************************

*****/

void LCD_Drawfilledcir(uint8 x1,uint8 y1,uint8 r,uint8 rr,uint8 gg,uint8 bb)
{

uint8 x,y;
if(x1>=r)
 x=(x1-r);
else
 x=0;
for(x;x<=(x1+r);x++)
   {y=sqrt((uint16)(r*r)-(uint16)((x-x1)*(x-x1)))+y1;
   if((y-2*sqrt((uint16)(r*r)-(uint16)((x-x1)*(x-x1))))<0)
       LCD_DrawLine(x,0,x,y,rr,gg,bb);
   else
       LCD_DrawLine(x,(y-2*sqrt((uint16)(r*r)-(uint16)((x-x1)*(x-

x1)))),x,y,rr,gg,bb);
    }
if(y1>=r)
   y=(y1-r);
else
   y="0";
for(y;y<=(y1+r);y++)
   {x=sqrt((uint16)(r*r)-(uint16)((y-y1)*(y-y1)))+x1;
   if((x-2*sqrt((uint16)(r*r)-(uint16)((y-y1)*(y-y1))))<0)
       LCD_DrawLine(x,0,x,y,rr,gg,bb);
   else
       LCD_DrawLine((x-2*sqrt((uint16)(r*r)-(uint16)((y-y1)*(y-

y1)))),y,x,y,rr,gg,bb);
    } 
}

 

 

 

 

点击此处查看原文 >>

系统分类: 单片机   |    用户分类:    |    来源: 原创

评论(0) | 阅读(163)
发表于:2008-3-15 11:03:22
标签:无标签

0

AVR(Mega8)的study:12、点亮LCD3510液晶

现在手里的液晶基本都没了,12864、12232什么的都不见影了,还有一块诺基亚手机3510上拆下来的液晶,以前点过,现在用Mega8再点点。由于Mega8的资源有限,不能一次做多个测试,只能一个个的做了。要3510资料的可以上BAIDU搜搜,有很多。

测试效果:

点击看大图

点击看大图

点击看大图

点击看大图

点击看大图

//3510.c

#include <iom8v.h>
#include "mytype.h"
#include "math.h"
#include "lcd3510.h"
//#include "ascii.h"

void DelayXms(uint16 x)
{
 uint8 i;
 while(x--)
  {
   i="1275";
   while(i--);
  }
}

/**************************************************************  

************
 液晶硬件复位
*****************************************************************************

*/
void LcdReset(void)
{
 ClrLcdRst();
 DelayXms(5);
 SetLcdRst();
 DelayXms(5);
}
/****************************************************************************

**********************
 发送命令
 

*****************************************************************************

*************************/
void LcdSendCommand(uint8 cmd)
{
 uint8 i;
 SetSdataOut();
 ClrLcdCs();
 ClrLcdSclk();
 ClrLcdSdata();
 SetLcdSclk();
 
 for(i=0;i<8;i++)
  {
   ClrLcdSclk();
   if(cmd & 0x80)
    {
     SetLcdSdata();
    }
   else
    {
     ClrLcdSdata();
    }
   SetLcdSclk();
   cmd<<=1;
  }
}

/****************************************************************************

*
发送数据
*****************************************************************************

***********/
void LcdSendData(uint32 Data)
{
 uint32 i;
 SetSdataOut();
 ClrLcdCs();
 ClrLcdSclk();
 SetLcdSdata();
 SetLcdSclk();

 for(i=0;i<8;i++)
  {
   ClrLcdSclk();
   if(Data & 0x80)
    {
     SetLcdSdata();
    }
   else
    {
     ClrLcdSdata();
    }
   SetLcdSclk();
   Data<<=1;
  }
}
/***************************************************************************
液晶端口初始化
************************************************************************/
void LcdPortInit(void)
{
DDR4|=((1<<LCD_RST)|(1<<LCD_CS));
DDR2|=((1<<LCD_SDATA)|(1<<LCD_SCLK));
SetLcdRst();
SetLcdCs();
SetLcdSclk();
}

/**********************************************************************
液晶初始化 
*************************************************************************/
void LcdInit(void)
{
 uint8 i;
 LcdPortInit();

 LcdReset();
 LcdSendCommand(0x01);  //soft reset
 SetLcdCs();
 
 DelayXms(5);
 LcdSendCommand(0xc6);     //initial escape
 SetLcdCs();

 LcdSendCommand(0xb9);  //refresh set
 LcdSendData(0x00);
 SetLcdCs();

 LcdSendCommand(0xb6);  //display control
 LcdSendData(0x80);
 LcdSendData(0x80);
 LcdSendData(0x81);
 LcdSendData(84);
 LcdSendData(69);
 LcdSendData(82);
 LcdSendData(67);
 SetLcdCs();

 LcdSendCommand(0xb3);  //gray scale position set
 LcdSendData(1);
 LcdSendData(2);
 LcdSendData(4);
 LcdSendData(8);
 LcdSendData(16);
 LcdSendData(30);
 LcdSendData(40);
 LcdSendData(50);
 LcdSendData(60);
 LcdSendData(70);
 LcdSendData(80);
 LcdSendData(90);
 LcdSendData(100);
 LcdSendData(110);
 LcdSendData(127);
 SetLcdCs();

 LcdSendCommand(0xb5);  //gamma curve set
 LcdSendData(0x01);
 SetLcdCs();

 LcdSendCommand(0xbd);  //common driver output select
 LcdSendData(0x00);
 SetLcdCs();

 LcdSendCommand(0xbe);  //power control
 LcdSendData(0x04);
 SetLcdCs();

 LcdSendCommand(0x11);  //sleep out
 SetLcdCs();
 
 LcdSendCommand(0xba);  //voltage control
 LcdSendData(127);
 LcdSendData(3);
 SetLcdCs();

 LcdSendCommand(0xb7);  //temperature gradient set
 for(i=0; i<14; i++)
  {
   LcdSendData(0x00);
  }
 SetLcdCs();

 LcdSendCommand(0x29);  //display ON
 SetLcdCs();

 LcdSendCommand(0x03);  //booster voltage ON
 SetLcdCs();
 DelayXms(5);

 LcdSendCommand(0x20);  //display inversion OFF
 SetLcdCs();
 
 LcdSendCommand(0x25);  //write contrast
 LcdSendData(63);
 SetLcdCs();
}
/* ************************************************************************
液晶清屏 
*****************************************************************************

/
void LcdClr(void)
{
 uint8 x, y;
 LcdSendCommand(0x2a);  //column address set
 LcdSendData(0);
 LcdSendData(97);
 SetLcdCs();

 LcdSendCommand(0x2b);  //page address set
 LcdSendData(0);
 LcdSendData(66);
 SetLcdCs();
 
 LcdSendCommand(0x2c);  //memory write
 for(y=0;y<67;y++)
  {
   for(x=0;x<98;x+=2)
    {
     LcdSendData(0);
     LcdSendData(0);
     LcdSendData(0);
    }
  }
 SetLcdCs();
}


 

/****************************************************************************

***************
 画点
 

*****************************************************************************

**************/
 void LcdPointWrite(uint8 x, uint8 y,uint8 rr,uint8 gg,uint8 bb)
 {
 uint8 b1,b2;
 b1=~(((rr<<4)&0xf0)|(gg&0x0f));
 b2=~(((bb<<4)&0xf0)|(rr&0x0f));
 LcdSendCommand(0x2a);  //column address set
 LcdSendData(x);
 LcdSendData(x);
 SetLcdCs();

 LcdSendCommand(0x2b);  //page address set
 LcdSendData(y);
 LcdSendData(y);
 SetLcdCs();

 LcdSendCommand(0x2c);  //memory write
 
     LcdSendData(b1);
     LcdSendData(b2);
 SetLcdCs(); 
}

/***************************************************************************
画线  
*****************************************************************************

/
void LCD_DrawLine(uint8 x1, uint8 y1, uint8 x2, uint8 y2,uint8 rr,uint8

gg,uint8 bb)
{
uint8 x,y;
if(x1<x2)
  for(x=x1;x<=x2;x++)
    {
 if(y1<=y2)
      { y="y1"+(uint16)((x-x1)*(y2-y1))/(x2-x1);
       LcdPointWrite(x,y,rr,gg,bb);}
 else
   {y=y1-(uint16)((x-x1)*(y1-y2))/(x2-x1);
     LcdPointWrite(x, y,rr,gg,bb);}
    }
else if(x1==x2)
     { x="x1";
      if(y1<=y2)
        {for(y=y1;y<=y2;y++)
        LcdPointWrite(x, y,rr,gg,bb);}
      else {
      for(y=y2;y<=y1;y++)
         LcdPointWrite(x, y,rr,gg,bb);}
      }
 else  for(x=x2;x<=x1;x++)
     {
   if(y1>=y2)
        { y="y1-"(uint16)((x1-x)*(y1-y2))/(x1-x2);
         LcdPointWrite(x, y,rr,gg,bb);}
   else
      {y=y1+(uint16)((x1-x)*(y2-y1))/(x1-x2);
   LcdPointWrite(x, y,rr,gg,bb);}
       }

if(y1<y2)
  for (y=y1;y<=y2;y++)
  {
  if(x1<=x2)
    {x=x1+(uint16)((y-y1)*(x2-x1))/(y2-y1);
  LcdPointWrite(x, y,rr,gg,bb);}
   else
     {x=x1-(uint16)((y-y1)*(x1-x2))/(y2-y1);
  LcdPointWrite(x, y,rr,gg,bb);}
   }
else if(y1==y2)
   {y=y1;
    if(x1<=x2)
    {for(x=x1;x<=x2;x++)
    LcdPointWrite(x, y,rr,gg,bb);}
 else
    {for(x=x2;x<=x1;x++)
    LcdPointWrite(x, y,rr,gg,bb);}
 }
else 
   for(y=y2;y<=y1;y++)
   {
   if(x1<=x2)
     {x=x1+(uint16)((y1-y)*(x2-x1))/(y1-y2);
      LcdPointWrite(x, y,rr,gg,bb);}
   else 
     {x=x1-(uint16)((y1-y)*(x1-x2))/(y1-y2);
      LcdPointWrite(x, y,rr,gg,bb);}
   }  

/****************************************************************************

*********
画线形实块,
*****************************************************************************

**********/
void LCD_Drawfilled(uint8 m1,uint8 n1,uint8 m2, uint8 n2,uint8 m3, uint8

n3,uint8 rr, uint8 gg,uint8 bb)
{
uint8 left,left0,mid,mid0,mid1,right,right0;
uint8 a,a0,b,b0,c,c0,k,k0,l,l0;
uint8 x,y1,y2;
uint8 z;
z=2;
if(m1==m2)
   {{mid=m1;mid0=n1;mid1=n2;}
    if(m1<m3)
     {right=m3;right0=n3;z=0;}
 else
   {left=m3;left0=n3;z=1;}
 }
if(m1==m3)
    {{mid=m1;mid0=n1;mid1=n3;}
 if(m1<m2)
     {right=m2;right0=n2;z=0;}
 else
     {left=m2;left0=n2;z=1;}
 }
if(m2==m3)
    {{mid=m2;mid0=n2;mid1=n3;}
 if(m2<m1)
    {right=m1;right0=n1;z=0;}
 else
    {left=m1;left0=n1;z=1;}
 }
if(z==1)
    for(x=left;x<=mid;x++)
       {if(mid0<=left0)
      y1=mid0+(uint16)((left0-mid0)*(mid-x))/(mid-left);
    else
         y1=mid0-(uint16)((mid0-left0)*(mid-x))/(mid-left);
    if(mid1<=left0)
      y2=mid1+(uint16)((left0-mid1)*(mid-x))/(mid-left);
       else
      y2=mid1-(uint16)((mid1-left0)*(mid-x))/(mid-left);
   LCD_DrawLine(x,y1,x,y2,rr,gg,bb);}
else if(z==0)
       for(x=mid;x<=right;x++)
    {if(mid0<=right0)
       y1=mid0+(uint16)((right0-mid0)*(x-mid))/(right-mid);
  else
    y1=mid0-(uint16)((mid0-right0)*(x-mid))/(right-mid);
  if(mid1<=right0)
    y2=mid1+(uint16)((right0-mid1)*(x-mid))/(right-mid);
  else
    y2=mid1-(uint16)((mid1-right0)*(x-mid))/(right-mid);
  LCD_DrawLine(x,y1,x,y2,rr,gg,bb);}
else
  { 
  if(m1>m2)
       {k=m1;k0=n1;l=m2;l0=n2;}
   else
       {k=m2;k0=n2;l=m1,l0=n1;}
   if(m3>k)
       {a=m3;a0=n3;b=k;b0=k0;c=l;c0=l0;}
   else 
       {if( m3>l)
       {a=k;a0=k0;b=m3;b0=n3;c=l;c0=l0;}
     else   
    {a=k;a0=k0;b=l;b0=l0;c=m3;c0=n3;}
        }
  for(x=c;x<=b;x++)
    {if(c0>=a0)
       y1=c0-(uint16)((x-c)*(c0-a0))/(a-c);
    else
       y1=c0+(uint16)((x-c)*(a0-c0))/(a-c);
    if(c0>=b0)
       y2=c0-(uint16)((x-c)*(c0-b0))/(b-c);
    else
       y2=c0+(uint16)((x-c)*(b0-c0))/(b-c);
       LCD_DrawLine(x,y1,x,y2,rr,gg,bb);}   
  for(x=b;x<=a;x++)
    {if(b0>=a0)
       y1=b0-(uint16)((x-b)*(b0-a0))/(a-b);
 else
    y1=b0+(uint16)((x-b)*(a0-b0))/(a-b);
 if(c0>=a0)
       y2=c0-(uint16)((x-c)*(c0-a0))/(a-c);
    else
       y2=c0+(uint16)((x-c)*(a0-c0))/(a-c);
  LCD_DrawLine(x,y1,x,y2,rr,gg,bb);}  
}
}

/****************************************************************************

**************
 方块块写
*****************************************************************************

*******************/
void LcdBlockWrite(uint8 x1, uint8 y1, uint8 x2, uint8 y2, uint8 rr,uint8 

gg,uint8 bb)
{
 uint8 x, y;
 uint8 b1,b2,b3;
 b1=~(((rr<<4)&0xf0)|(gg&0x0f));
 b2=~(((bb<<4)&0xf0)|(rr&0x0f));
 b3=~(((gg<<4)&0xf0)|(bb&0x0f));

 LcdSendCommand(0x2a);  //column address set
 LcdSendData(x1);
 LcdSendData(x2);
 SetLcdCs();

 LcdSendCommand(0x2b);  //page address set
 LcdSendData(y1);
 LcdSendData(y2);
 SetLcdCs();

 LcdSendCommand(0x2c);  //memory write
 for(y=y1;y<=y2;y++)
  {
   for(x=x1;x<=x2;x+=2)
    {
     LcdSendData(b1);
     LcdSendData(b2);
  LcdSendData(b3);
    }
  }
 SetLcdCs(); 
}

 

点击此处查看原文 >>

系统分类: 单片机   |    用户分类:    |    来源: 原创

评论(0) | 阅读(147)
总共 , 当前 /,23下一页