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

📄 disp.c

📁 本人at89c51snd1c主控IC增加了128*32点阵驱动显示
💻 C
📖 第 1 页 / 共 3 页
字号:
/*C**************************************************************************
* NAME:         disp.c
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      snd1c-refd-nf-4_0_3      
* REVISION:     1.12     
*----------------------------------------------------------------------------
* PURPOSE:
* This file contains the high level display routines
*****************************************************************************/

/*_____ I N C L U D E S ____________________________________________________*/

#include "config.h"                 /* system configuration */
#include "lib_mcu\kbd\kbd_drv.h"    /* Keyboard driver definition */
#include "modules\song\song_drv.h"  /* song driver definition */
#include "modules\file\file.h"      /* file definition */
#include "disp_task.h"              /* display task definition */
#include "disp.h"                   /* display definition */
#include "modules\display\icon.h"
#if CONF_DISPLAY == LED
#include "modules\mem\mem_task.h"           /* memory task definition */
#include "modules\display\led.h"            /* led definition */
#endif
extern void PutCodeToLCD( Byte *pBuffer, Uchar Loop );
extern void Draw2Digit( Uchar Pos, Uchar HexCode );
extern void Draw8x6Icons( Uchar Page, Uchar Column, Uchar Index );
extern void LCDClearLine( Uchar page, Uchar column, Uint16 Length );
extern void PutToChina(Uchar Page ,Uchar Column,Uchar code *prt );
/*_____ M A C R O S ________________________________________________________*/


/*_____ D E F I N I T I O N ________________________________________________*/

#if CONF_DISPLAY == LCD
  extern  bdata   bit     gl_kbd_lock;   /* set to TRUE if keyboard locked */
  extern  bdata   bit     fs_memory;     /* selected file system */

/* mode patterns */
code    Byte cgram_mass[] =   { 0x04, 0x06, 0x0D, 0x15, 0x14, 0x04, 0x0E, 0x04 };
code    Byte cgram_song[] =   { 0x03, 0x0F, 0x0D, 0x09, 0x09, 0x0B, 0x1B, 0x18 };
code    Byte cgram_voice[] =  { 0x00, 0x0D, 0x13, 0x13, 0x13, 0x0D, 0x00, 0x00 };
code    Byte cgram_tools[] =  { 0x0E, 0x04, 0x15, 0x1F, 0x11, 0x1F, 0x04, 0x04 };

/* state patterns */
code    Byte cgram_stop[] =   { 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00 };
code    Byte cgram_play[] =   { 0x00, 0x08, 0x0C, 0x0E, 0x0F, 0x0E, 0x0C, 0x08 };
code    Byte cgram_pause[] =  { 0x00, 0x00, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x00 };
code    Byte cgram_rec[] =    { 0x00, 0x00, 0x1F, 0x0E, 0x04, 0x1F, 0x00, 0x00 };

/* sound patterns */
code    Byte cgram_volume[] = { 0x02, 0x06, 0x1A, 0x12, 0x1A, 0x06, 0x02, 0x00 };
code    Byte cgram_bass[] =   { 0x07, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10, 0x00 };
code    Byte cgram_medium[] = { 0x04, 0x0A, 0x0A, 0x0A, 0x11, 0x11, 0x11, 0x00 };
code    Byte cgram_treble[] = { 0x1C, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00 };

/* memory patterns */
#if (MEM_CHIP_TYPE != CHIP_HDD)
  code    Byte cgram_chip[] =   { 0x0E, 0x1B, 0x0A, 0x1B, 0x0A, 0x1B, 0x0E, 0x00 };
#else
  code    Byte cgram_chip[] =   { 0x04, 0xA, 0x15, 0x11, 0x11, 0x15, 0x0A, 0x04 };
#endif

#if (MEM_CARD_TYPE != CARD_CDR)
  code    Byte cgram_card[] =   { 0x1C, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F };
#else
  code    Byte cgram_card[] =   { 0x04, 0x0A, 0x15, 0x15, 0x0A, 0x04, 0x00, 0x00 };
#endif

code    Byte cgram_card1[] =  { 0x1C, 0x12, 0x11, 0x15, 0x11, 0x11, 0x11, 0x1F };
code    Byte cgram_card2[] =  { 0x1C, 0x12, 0x11, 0x15, 0x11, 0x15, 0x11, 0x1F };

/* file pattern */
code    Byte cgram_mp3[] =    { 0x04, 0x06, 0x07, 0x04, 0x04, 0x0C, 0x1C, 0x08 };
code    Byte cgram_wav[] =    { 0x00, 0x00, 0x02, 0x15, 0x15, 0x08, 0x00, 0x00 };
code    Byte cgram_dir[] =    { 0x00, 0x00, 0x00, 0x0C, 0x13, 0x11, 0x1F, 0x00 };

/* repeat pattern */
code    Byte cgram_repeat[] = { 0x00, 0x00, 0x0E, 0x01, 0x09, 0x1E, 0x08, 0x00 };
code    Byte cgram_rep_A[] =  { 0x02, 0x1F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 };
code    Byte cgram_rep_B[] =  { 0x02, 0x1F, 0x02, 0x00, 0x00, 0x08, 0x1F, 0x08 };

/* misc pattern */
code    Byte cgram_lock[] =   { 0x04, 0x1C, 0x0C, 0x04, 0x04, 0x0C, 0x12, 0x0C };
code    Byte cgram_blank[] =  { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
code    Byte cgram_error[] =  { 0x00, 0x00, 0x00, 0x0A, 0x04, 0x0A, 0x00, 0x00 };


#else
  extern  xdata Byte    func_timeout;
  extern  xdata Byte    func_state;
  extern  xdata Byte    ref_state;
  extern        bit     playing;
  extern        bit     recording;
  extern        bit     pause;
  extern        bit     bargraph;
  extern        Byte    song_sound;
  extern  xdata Byte    LED_ON;
  extern  xdata Byte    LED_FAST;
  extern  Byte    mem_state;                  /* task state */
#endif
Uchar code  abcd[]={0x10,0x61,0x06,0xe0,0x18,0x84,0xe4,0x1c,0x84,0x65,0xbe,0x24,0xa4,0x64,0x04,0x00,
                    0x04,0x04,0xff,0x00,0x01,0x00,0xff,0x41,0x21,0x12,0x0c,0x1b,0x61,0xc0,0x40,0x00};
code    Byte cgram_mp3[] =    { 0x04, 0x06, 0x07, 0x04, 0x04, 0x0C, 0x1C, 0x08 };
code    Byte cgram_wav[] =    { 0x00, 0x00, 0x02, 0x15, 0x15, 0x08, 0x00, 0x00 };
code    Byte cgram_dir[] =    { 0x00, 0x00, 0x00, 0x0C, 0x13, 0x11, 0x1F, 0x00 };
code    Byte cgram_blank[] =  { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

extern void PutCodeToLCD( Byte *pBuffer, Uchar Loop );
extern void SetLCDAddress( Uchar Page, Uchar Column );

/*_____ D E C L A R A T I O N ______________________________________________*/


/*F**************************************************************************
* NAME: print_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Print initialization
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void print_init (void)
{    
	Uchar loop1;
#if CONF_DISPLAY == LCD
  //LCDDisplayInit ();                              /* lcd initialization */
 // lcd_cgram(CGRAM_SOUND, cgram_volume);     /* init volume icon */
 // lcd_cgram(CGRAM_REPEAT, cgram_repeat);    /* init repeat icon */
 // lcd_cgram(CGRAM_MODE, cgram_song);        /* init mode icon to song */
  //lcd_cgram(CGRAM_STATE, cgram_stop);       /* init state icon to stop */
  print_kbd_lock();                         /* set lock icon or not */
#else

     SetLCDAddress( PLAY_VOL_ICON_X_POS, PLAY_VOL_ICON_Y_POS); /* init volume icon */
      for( loop1 = 0; loop1 < 32; loop1++ )
     PutCodeToLCD( &VolumeStep[loop1], 32 );
     led_task_init();
#endif
}


/*F**************************************************************************
* NAME: print_state_blank
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Print the blank icon
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void print_state_blank (void)
{
#if CONF_DISPLAY == LCD
  //lcd_cgram(CGRAM_STATE, cgram_blank);      /* select blank icon */
#endif
}


/*F**************************************************************************
* NAME: print_state_stop
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Print the stop icon
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void print_state_stop (void)
{
#if CONF_DISPLAY == LCD
  lcd_cgram(CGRAM_STATE, cgram_stop);       /* select stop icon */
#else
    SetLCDAddress( PLAY_STATE_ICON_X_POS, PLAY_STATE_ICON_Y_POS);
    PutCodeToLCD( &PlaymodeIcon[2][0], 10 );
        
    // second page
    SetLCDAddress(PLAY_STATE_ICON_X_POS+ 1 ,PLAY_STATE_ICON_Y_POS );
    PutCodeToLCD( &PlaymodeIcon[2][10], 10 );
  LED_FAST = 3;
#endif
}


/*F**************************************************************************
* NAME: print_state_play
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Print the play icon
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void print_state_play (void)
{
	 Uchar *prt;
	 prt=abcd;
#if CONF_DISPLAY == LCD
  //lcd_cgram(CGRAM_STATE, cgram_play);       /* select play icon */
    SetLCDAddress( PLAY_STATE_ICON_X_POS, PLAY_STATE_ICON_Y_POS);
    PutCodeToLCD( &PlaymodeIcon[0][0], 10 );
        
    // second page
    SetLCDAddress(PLAY_STATE_ICON_X_POS+ 1 ,PLAY_STATE_ICON_Y_POS );
    PutCodeToLCD( &PlaymodeIcon[0][10], 10 );
#else
  
     SetLCDAddress( PLAY_STATE_ICON_X_POS, PLAY_STATE_ICON_Y_POS);
    PutCodeToLCD( &PlaymodeIcon[0][0], 10 );
        
    // second page
    SetLCDAddress(PLAY_STATE_ICON_X_POS+ 1 ,PLAY_STATE_ICON_Y_POS );
    PutCodeToLCD( &PlaymodeIcon[0][10], 10 );
    
  
   //SetLCDAddress( PLAY_STATE_ICON_X_POS, PLAY_STATE_ICON_Y_POS);
   //PutToChina(PLAY_STATE_ICON_X_POS ,PLAY_STATE_ICON_Y_POS,prt );
   //PutCodeToLCD( prt, 32 );
  LED_ON = (8 >> ref_state);
  LED_FAST = 1;
  func_state = 0;
  playing = TRUE;  
#endif
}


/*F**************************************************************************
* NAME: print_state_pause
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Print the pause icon
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void print_state_pause (void)
{
//	Uchar _loop3;
#if CONF_DISPLAY == LCD
  //lcd_cgram(CGRAM_STATE, cgram_pause);      /* select pause icon */
  SetLCDAddress( PLAY_STATE_ICON_X_POS, PLAY_STATE_ICON_Y_POS);
    PutCodeToLCD( &PlaymodeIcon[1][0], 10 );
        
    // second page
    SetLCDAddress(PLAY_STATE_ICON_X_POS+ 1 ,PLAY_STATE_ICON_Y_POS );
    PutCodeToLCD( &PlaymodeIcon[1][10], 10 );
#else
    SetLCDAddress( PLAY_STATE_ICON_X_POS, PLAY_STATE_ICON_Y_POS);
    PutCodeToLCD( &PlaymodeIcon[1][0], 10 );
        
    // second page
    SetLCDAddress(PLAY_STATE_ICON_X_POS+ 1 ,PLAY_STATE_ICON_Y_POS );
    PutCodeToLCD( &PlaymodeIcon[1][10], 10 );
 /* SetLCDAddress( 0, 10 );
    for( _loop3 = 0; _loop3 < 3; _loop3++ )
        PutCodeToLCD( &PlayingSettingIcon1[_loop3][0], 24 );

   SetLCDAddress( 0 + 1,10 );
    for( _loop3 = 0; _loop3 < 3; _loop3++ )
        PutCodeToLCD( &PlayingSettingIcon1[_loop3][24], 24 );
        */
 //lcd_cgram(0,50,5);  
  LED_ON = (8 >> ref_state);
  if (recording) LED_FAST = 2;
  else LED_FAST = 3;
  func_state = 0;
  playing = FALSE;
  pause = TRUE;
#endif
}


/*F**************************************************************************
* NAME: print_state_record
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Print the record icon
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void print_state_record (void)
{
#if CONF_DISPLAY == LCD
  //lcd_cgram(CGRAM_STATE, cgram_rec);        /* select record icon */
#else
  LED_ON = 15 - (8 >> ref_state);
  LED_FAST = 1;
  playing = TRUE;
  pause = FALSE;
#endif
}



/*F**************************************************************************
* NAME: print_state_error
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Print the error icon
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void print_state_error (void)
{
#if CONF_DISPLAY == LCD
  //lcd_cgram(CGRAM_STATE, cgram_error);      /* select error icon */
#else
  if (mem_state == MEM_CHIP_ERR_FMT)
  {
    LED_VOL = 1; LED_TREEB=0;
    Fformat();
    if (mem_select_format() == OK) return;
  }
  LED_ON=15;
  LED_FAST=3;
#endif
}



/*F**************************************************************************
* NAME: print_mode_song
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:

⌨️ 快捷键说明

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