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

📄 disp_task.c

📁 开发工具:keil7 主要IC:at89c51sdnd1(atmel) 说明:mp3播放器详细设计方案
💻 C
字号:
/*C**************************************************************************
* $RCSfile: disp_task.c,v $
*----------------------------------------------------------------------------
* Copyright (c) 2002 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      $Name: DEMO_FAT_1_9_9 $      
* REVISION:     $Revision: 1.6 $     
* FILE_CVSID:   $Id: disp_task.c,v 1.6 2002/08/13 11:48:30 ffosse Exp $       
*----------------------------------------------------------------------------
* PURPOSE:
* This file contains the display task and attached routines
*
* NOTES:
* Global Variables:
*   - gl_cpt_tick:  global tick counter in data space
*****************************************************************************/

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

#include "config.h"                         /* system configuration */
#include "..\file\file.h"                   /* file definition */
#include "..\display\disp.h"                /* display definition */
#include "..\mass\sbc.h"                    /* SBC commands definition */
#include "disp_task.h"                      /* display task definition */


/*_____ M A C R O S ________________________________________________________*/


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

extern  data    Byte    gl_cpt_tick;        /* general tick counter */

static  bdata   bit     disp_scroll_on;     /* set to TRUE to scroll name */
static  bdata   bit     disp_clock_on;      /* set to TRUE to start clock */
static  data    Byte    disp_sec_cpt;       /* second counter */
static  data    Byte    disp_min_cpt;       /* minute counter */
static  data    char pdata *  disp_buffer;

static  data    Byte    disp_state;         /* task state */


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


/*F**************************************************************************
* NAME: disp_task_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Display task initialization
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void disp_task_init (void)
{
  disp_scroll_on = FALSE;
  disp_clock_on = FALSE;
  disp_state = DISP_IDLE;
  print_init();
}


/*F**************************************************************************
* NAME: disp_task
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Display task handling display of clock and scrolling of file name
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void disp_task (void)
{
  switch (disp_state)
  {
    case DISP_IDLE:
    {
      if (sbc_wr_busy)
      {
        Lcd_cur_on();                       /* blinking cursor for .5 sec */
        sbc_wr_busy = FALSE;
        gl_cpt_tick = 0;
        disp_state = DISP_MS_BUSY;
      }
      break;
    }

    case DISP_INIT:
    {
      disp_state = DISP_TICK0;
      gl_cpt_tick = 0;
      disp_buffer = File_get_name();
      if (print_name(disp_buffer) != TRUE)  /* test if not short name */
      {
        disp_scroll_on = TRUE;              /* activate name scrolling */
      }
      else
      {
        disp_scroll_on = FALSE;             /* no scrolling */
      }
      break;
    }

    case DISP_TICK0:
    {
      if (gl_cpt_tick > DISP_TICK_500)      /* 1/2 sec expiration */
      {
        gl_cpt_tick -= DISP_TICK_500;
        if (disp_scroll_on)
        {
          if (print_name(disp_buffer))
          {
            disp_buffer = File_get_name();
          }
          else
          {
            disp_buffer++;
          }
        }
        disp_state = DISP_TICK1;
      }
      break;
    }

    case DISP_TICK1:
    {
      if (gl_cpt_tick > DISP_TICK_500)      /* 1/2 sec expiration */
      {
        gl_cpt_tick -= DISP_TICK_500;
        if (disp_scroll_on)
        {
          if (print_name(disp_buffer))
          {
            disp_buffer = File_get_name();
          }
          else
          {
            disp_buffer++;
          }
        }
        if (disp_clock_on)
        {
          disp_state = DISP_SEC;
        }
        else
        {
          disp_state = DISP_TICK0;
        }
      }
      break;
    }

    case DISP_SEC:
    {
      if (disp_sec_cpt == DISP_SEC_MIN)     /* 1 min expiration */
      {
        disp_sec_cpt = 0;
        print_sec(disp_sec_cpt);
        disp_state = DISP_MIN;
      }
      else
      {
        disp_sec_cpt++;
        print_sec(disp_sec_cpt);
        disp_state = DISP_TICK0;
      }
      break;
    }

    case DISP_MIN:
    {
      disp_min_cpt++;
      print_min(disp_min_cpt);
      disp_state = DISP_TICK0;
      break;
    }

    case DISP_MS_BUSY:
    {
      if (sbc_wr_busy)                      /* still busy */
      {
        sbc_wr_busy = FALSE;
        gl_cpt_tick = 0;
      }
      else
      {
        if (gl_cpt_tick > DISP_TICK_500)    /* 1/2 sec expiration */
        {
          Lcd_cur_off();
          disp_state = DISP_IDLE;
        }
      }
    }
  }
}


/*F**************************************************************************
* NAME: disp_name_start 
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Start name display
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void disp_name_start (void)
{
  disp_state = DISP_INIT;
}


/*F**************************************************************************
* NAME: disp_name_stop 
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Suspend name display
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void disp_name_stop (void)
{
  disp_state = DISP_IDLE;
}


/*F**************************************************************************
* NAME: disp_clock_reset
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Reset chrono to 0:00
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void disp_clock_reset (void)
{
  disp_clock_on = FALSE;
  disp_sec_cpt = 0;
  disp_min_cpt = 0;
  print_time(0, 0);                         /* display 0:00 */
}


/*F**************************************************************************
* NAME: disp_clock_start 
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Start or re-start clock display
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void disp_clock_start (void)
{
  disp_clock_on = TRUE;
}


/*F**************************************************************************
* NAME: disp_clock_stop 
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Suspend clock display
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void disp_clock_stop (void)
{
  disp_clock_on = FALSE;
}


/*F**************************************************************************
* NAME: disp_get_min 
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   minutes
*----------------------------------------------------------------------------
* PURPOSE: 
*   Return minutes of current time
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
Byte disp_get_min (void)
{
  return disp_min_cpt;
}


/*F**************************************************************************
* NAME: disp_get_sec 
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   seconds
*----------------------------------------------------------------------------
* PURPOSE: 
*   Return seconds of current time
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
Byte disp_get_sec (void)
{
  return disp_sec_cpt;
}

⌨️ 快捷键说明

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