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

📄 cursor.c

📁 广州致远电子的SmartArm2400出厂时的演示代码。
💻 C
字号:
/****************************************Copyright (c)****************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name:           cursor.c
** Last modified Date:  2008-05-07
** Last Version:        1.0
** Descriptions:        the hardware cursor's driver
**
**--------------------------------------------------------------------------------------------------------
** Created by:          Houxiaolong
** Created date:        2008-05-07
** Version:             1.0
** Descriptions:        the hardware cursor's driver
**
**--------------------------------------------------------------------------------------------------------
** Modified by:         
** Modified date:       
** Version:             
** Descriptions:        
**                      
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/

#include "cursor.h"
#include "config.h"
#include "LCD2478.h"

#define MIRROR_XY         1
/*********************************************************************************************************
** the cursor image's base address
*********************************************************************************************************/
#define CRSR_IMGBASE0    0xFFE10800
#define CRSR_IMGBASE1    0xFFE10900
#define CRSR_IMGBASE2    0xFFE10A00
#define CRSR_IMGBASE3    0xFFE10B00
/*********************************************************************************************************
** the cursor's image
*********************************************************************************************************/
unsigned int uicursor[] = {
    0xaaaaaaaa,0xaaaaaaaa, 
    0xaaaaaaaa,0xa9aaaaaa, 
    0xaaaaaaaa,0xa5aaaaaa, 
    0xaaaaaaaa,0x95aaaaaa, 
    0xaaaaaaaa,0x55aaaaaa, 
    0xaaaaaaaa,0x55a9aaaa,   
    0xaaaaaaaa,0x55a5aaaa, 
    0xaaaaaaaa,0x5595aaaa, 
    0xaaaaaaaa,0x55a9aaaa, 
    0xaaaaaaaa,0x55a9aaaa, 
    0xaaaaaaaa,0x69a5aaaa,
    0xaaaaaaaa,0xaaa5aaaa, 
    0xaaaaaaaa,0xaa95aaaa,
    0xaaaaaaaa,0xaa96aaaa,
    0xaaaaaaaa,0xaa56aaaa,
    0xaaaaaaaa,0xaa9aaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa,
    0xaaaaaaaa,0xaaaaaaaa
};


/*********************************************************************************************************
** Function name :        cursor_Init
** Function Description : Initialize the hardware cursor
** Input:                 none
** Output:                none
*********************************************************************************************************/
void cursor_Init(void)
{
    unsigned char i;
    unsigned int *puicursor = (unsigned int *)CRSR_IMGBASE0;
    
       
    cursor_SetPosition(0, 0);                                           /*  setcursor position at [0,0] */
        
    CRSR_CTRL = 0x00;	                                                /*  the cursor is not display   */
    
    for(i = 0; i < 64; i++) {                                           
        *puicursor++ = uicursor[i];                                     /*  read the cursor image       */
    }
    
    CRSR_CFG  = (0x01 << 1) |                                           /*  Cursor are synchronized to 
                                                                            the frame synchronization 
                                                                            pulse                       */
                (0x00 << 0);                                            /*  select 32x32 pixel cursor   */
                
    CRSR_PAL0 = 0x00000000;                                             /*  Palette 0 is black color    */
    CRSR_PAL1 = 0x00ffffff;                                             /*  Palette 1 is white color    */
 
}


/*********************************************************************************************************
** Function name :        cursor_On
** Function Description : display the cursor enable
** Input:                 none                      
** Output:                none
*********************************************************************************************************/
void cursor_On(void)
{
    CRSR_CTRL |= 0x01;                                                  /* enable the cursor's display  */
}


/*********************************************************************************************************
** Function name :        cursor_Off
** Function Description : display the cursor disable
** Input:                 none                      
** Output:                none
*********************************************************************************************************/
void cursor_Off(void)
{
    CRSR_CTRL &= ~(1 << 0);                                             /* disable the cursor's display */
}


/*********************************************************************************************************
** Function name :        cursor_SetPosition
** Function Description : set the cursor's position
** Input:                 ix   the position of x coordinate                      
** Output:                iy   the position of y coordinate
*********************************************************************************************************/
void cursor_SetPosition(unsigned int ix, unsigned int iy)
{
    
    /* 
     *  if x coordinate is mirror, use underside way to set cursor's position
     */
    #if (MIRROR_XY == 1)
        unsigned int idx = 0;
        
        if(ix > 207) {
        
            idx = ix - 207;
            CRSR_CLIP = (unsigned long)((0 << 8) | (idx << 0));
            ix  = 0;
            
        } else {
        
            ix = U_LCD_XSIZE - ix - 1 - 32;
            
        }

    #endif
    
    /* 
     *  if x coordinate is normal, use underside way to set cursor's position
     */
    CRSR_XY = (unsigned long)((iy << 16) | (ix << 0));                                   
}

⌨️ 快捷键说明

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