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

📄 dc550_display.c

📁 一款经典的数字电话设计资料
💻 C
📖 第 1 页 / 共 5 页
字号:
    if(display_current_lineone[display_current_updatex] != readcharacter ) {
      display_current_state = DISPLAY_STATE_RESET_STAGE01;
      display_statuschange_lineone = TRUE;
      display_statuschange_linetwo = TRUE;
      display_statuschange_cursor = TRUE;
      return;
    }
    display_current_updatex++;
    j++;
  }
}


/******************************************************************************
 *  FUNCTION: display_exec_verifyquadthree(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  This function is called by the display_exec(.) function whenever
 *  enough time has gone by to warrant a check of the LCD for a static
 *  discharge.
 *****************************************************************************/
void display_exec_verifyquadthree(void) {
  // Declare function variables
  int j = 1;
  char readcharacter;

  // Set coordinates at display_current_updatex on line one
  display_util_setcoordinates(0, display_current_updatex);

  while((display_current_updatex != 24 ) && 
        (j < DISPLAY_MAXINSTRUCTIONS)) {
    readcharacter = display_util_readdata();
    if(display_current_lineone[display_current_updatex] != readcharacter ) {
      display_current_state = DISPLAY_STATE_RESET_STAGE01;
      display_statuschange_lineone = TRUE;
      display_statuschange_linetwo = TRUE;
      display_statuschange_cursor = TRUE;
      return;
    }
    display_current_updatex++;
    j++;
  }
  
  if(display_current_updatex == 24) {
    display_current_updatex = 0;
    display_current_state = DISPLAY_STATE_VERIFY_L2;
  }
}


/******************************************************************************
 *  FUNCTION: display_exec_verifyquadtwo(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  This function is called by the display_exec(.) function whenever
 *  enough time has gone by to warrant a check of the LCD for a static
 *  discharge.
 *****************************************************************************/
void display_exec_verifyquadtwo(void) {
  // Declare function variables
  int j = 1;
  char readcharacter;

  // Set coordinates at display_current_updatex on line two
  display_util_setcoordinates(1, display_current_updatex);

  while((display_current_updatex != 12 ) && 
        (j < DISPLAY_MAXINSTRUCTIONS)) {
    readcharacter = display_util_readdata();
    if(display_current_linetwo[display_current_updatex] != readcharacter ) {
      display_current_state = DISPLAY_STATE_RESET_STAGE01;
      display_statuschange_lineone = TRUE;
      display_statuschange_linetwo = TRUE;
      display_statuschange_cursor = TRUE;
      return;
    }
    display_current_updatex++;
    j++;
  }
}


/******************************************************************************
 *  FUNCTION: display_exec_verifyquadfour(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  This function is called by the display_exec(.) function whenever
 *  enough time has gone by to warrant a check of the LCD for a static
 *  discharge.
 *****************************************************************************/
void display_exec_verifyquadfour(void) {
  // Declare function variables
  int j = 1;
  char readcharacter;

  // Set coordinates at display_current_updatex on line two
  display_util_setcoordinates(1, display_current_updatex);

  while((display_current_updatex != 24 ) && 
        (j < DISPLAY_MAXINSTRUCTIONS)) {
    readcharacter = display_util_readdata();
    if(display_current_linetwo[display_current_updatex] != readcharacter ) {
      display_current_state = DISPLAY_STATE_RESET_STAGE01;
      display_statuschange_lineone = TRUE;
      display_statuschange_linetwo = TRUE;
      display_statuschange_cursor = TRUE;
      return;
    }
    display_current_updatex++;
    j++;
  }
  
  if(display_current_updatex == 24)
    display_current_state = DISPLAY_STATE_IDLE;
}


/******************************************************************************
 *  FUNCTION: display_exec_cursor(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  This function is called by display_exec(.) whenever 
 *  display_statuschange_cursor is true.  It checks the
 *  display_new_cursorblink variable; if it's true, it enables the cursor,
 *  and if it's false, it disables the cursor.
 *****************************************************************************/
void display_exec_cursor(void) {

  // The display driver has been instructed to enable the cursor
  if(display_new_cursorblink) {
    display_current_cursorx = display_new_cursorx;
    display_current_cursory = display_new_cursory;
    display_util_setcoordinates(display_current_cursory, display_current_cursorx);
    display_util_setcursormode(FALSE, TRUE);
  }
  
  // The display driver has been instructed to disable the cursor
  else {
    display_util_setcursormode(FALSE, FALSE);
  }
  
  // Mark the job complete
  display_statuschange_cursor = FALSE;
}


/******************************************************************************
 *  FUNCTION: void display_writelineone(DC550LCDCoordinate position,
 *                                            DC550LCDString output)
 ******************************************************************************
 *  DESCRIPTION:
 *  display_writelineone(.) is an external interface function used to
 *  instruct the display driver to write "output" on line one starting at
 *  position "position".  Bounds checking is performed on "position", and the
 *  function stops once it hits a null character.
 *****************************************************************************/
void display_writelineone(DC550LCDCoordinate position,
                                DC550LCDString output) {
  // Declare local variable
  int i;

  // Do range checking on the position parameter
  if(position > 23) return;

  // Change statuschange_linetwo to TRUE
  display_statuschange_lineone = TRUE;
  
  // If the current_updatex is past the "position" parameter and the system is
  // already updating line one, it moves current_updatex back to "position" so
  // that the newly written text gets updated
  if((display_current_updatex > position) &&
     (display_current_state == DISPLAY_STATE_LINEONE))
    display_current_updatex = position;
  
  // Copy the output over to line two starting from position
  for(i=0; (i<(24-position)) && (output[i]!=0); i++)
    display_new_lineone[position + i] = 
      display_util_translatechar(output[i]);
}


/******************************************************************************
 *  FUNCTION: void display_writelinetwo(DC550LCDCoordinate position,
 *                                            DC550LCDString output)
 ******************************************************************************
 *  DESCRIPTION:
 *  display_writelinetwo(.) is an external interface function used to
 *  instruct the display driver to write "output" on line two starting at
 *  position "position".  Bounds checking is performed on "position", and the
 *  function stops once it hits a null character.
 *****************************************************************************/
void display_writelinetwo(DC550LCDCoordinate position,
                                DC550LCDString output) {
  // Declare local variable
  int i;

  // Do range checking on the position parameter
  if(position > 23) return;

  // Change statuschange_linetwo to TRUE
  display_statuschange_linetwo = TRUE;
  
  // If the current_updatex is past the "position" parameter and the system is
  // already updating line two, it moves current_updatex back to "position" so
  // that the newly written text gets updated
  if((display_current_updatex > position) &&
     (display_current_state == DISPLAY_STATE_LINETWO))
    display_current_updatex = position;
  
  // Copy the output over to line two starting from position
  for(i=0; (i<(24-position)) && (output[i]!=0); i++)
    display_new_linetwo[position + i] = 
      display_util_translatechar(output[i]);
}


/******************************************************************************
 *  FUNCTION: void display_enablecursor(DC550LCDCoordinate y,
 *                                      DC550LCDCoordinate x)
 ******************************************************************************
 *  DESCRIPTION:
 *  display_enablecursor(.) is an external interface function used to
 *  instruct the display driver to enable the cursor at location (x,y).  The
 *  function also performs bounds checking on x and y to ensure that x is
 *  between 0 and 23 inclusive and y is either 0 or 1.
 *****************************************************************************/
void display_enablecursor(DC550LCDCoordinate y, DC550LCDCoordinate x) {
  if((x <= 23) && (y <= 1)) {
    display_statuschange_cursor = TRUE;
    display_new_cursorblink = TRUE;
    display_new_cursorx = x;
    display_new_cursory = y;
  }
}


/******************************************************************************
 *  FUNCTION: void display_disablecursor(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  display_disablecursor(.) is an external interface function used to
 *  instruct the display driver to disable the cursor.
 *****************************************************************************/
void display_disablecursor(void) {
  display_statuschange_cursor = TRUE;
  display_new_cursorblink = FALSE;
}


/******************************************************************************
 *  FUNCTION: void display_cleardisplay(void)
 ******************************************************************************
 *  DESCRIPTION:
 *  display_cleardisplay(.) is an external interface function used to
 *  clear the display.  It actually instructs the driver to fill the display
 *  with spaces.
 *****************************************************************************/
void display_cleardisplay(void) {
  // Declare local variables
  int i;
  
  // Blank out the new_lineone and new_linetwo arrays
  for(i=0; i<24; i++) {
    display_new_lineone[i] = ' ';
    display_new_linetwo[i] = ' ';
  }
  
  // Set the statuschange_lineone and statuschange_linetwo variables to TRUE
  // so that the lines are updated during the next exec
  display_statuschange_lineone = TRUE;
  display_statuschange_linetwo = TRUE;
  
  // Set the updateposition back to 0
  display_current_updatex = 0;
}


/******************************************************************************
 *  FUNCTION: void display_util_setdisplaymode(BOOL mode)
 ******************************************************************************
 *  DESCRIPTION:
 *  display_util_setdisplaymode(.) is an internal utility function used to set
 *  the display mode of the LCD according to the variable passed in as a
 *  parameter.  It sends the command to the LCD controller regardless of how
 *  it was set before.
 *****************************************************************************/
void display_util_setdisplaymode(BOOL mode) {
  // Declare local variables
  int i;
  
  // Reset global variables
  display_displaymode = mode;
  
  // Enable LCD over LEDs
  display_usingbus = TRUE;

  // Check if LCD is ready
  LCDCTRL_OUT &= ~(LCD_RS);           // Clear RS bit
  LCDCTRL_OUT |= LCD_RNW;             // Set R/W bit
  LCDDATA_DIR = 0x00;                 // Temporarily set data port for input
  LCDCTRL_OUT |= LCD_E;               // Clock bit high
  _NOP();

  // If LCD is not ready, wait for 12 microseconds at a time
  while(LCDDATA_IN & 0x80) {
    LCDCTRL_OUT &= ~(LCD_E);          // Clock bit low
    for(i = 12; i > 0; i--);
    LCDCTRL_OUT |= LCD_E;
  }
  LCDCTRL_OUT &= ~(LCD_E);            // Clock bit low again
  LCDDATA_DIR = 0xFF;                 // Set data port for output again
  
  // Set Display Mode
  display_instr_displaymode();

  // Enable LEDs over LCD
  display_usingbus = FALSE;
}


/******************************************************************************
 *  FUNCTION: void display_util_setcursormode(BOOL cursor, BOOL blink)
 ******************************************************************************
 *  DESCRIPTION:
 *  display_util_setcursormode(.) is an internal utility function used to set
 *  the cursor mode of the LCD according to the cursor and blink variables
 *  passed in as parameters.  It sends the command to the LCD controller
 *  regardless of how it was set before.
 *****************************************************************************/
void display_util_setcursormode(BOOL cursor, BOOL blink) {
  // Declare local variables
  int i;
  
  // Reset global variables
  display_cursormode = cursor;
  display_cursorblink = blink;
  
  // Enable LCD over LEDs
  display_usingbus = TRUE;

  // Check if LCD is ready
  LCDCTRL_OUT &= ~(LCD_RS);           // Clear RS bit
  LCDCTRL_OUT |= LCD_RNW;             // Set R/W bit
  LCDDATA_DIR = 0x00;                 // Temporarily set data port for input
  LCDCTRL_OUT |= LCD_E;               // Clock bit high
  _NOP();

  // If LCD is not ready, wait for 12 microseconds at a time
  while(LCDDATA_IN & 0x80) {
    LCDCTRL_OUT &= ~(LCD_E);          // Clock bit low
    for(i = 12; i > 0; i--);
    LCDCTRL_OUT |= LCD_E;
  }
  LCDCTRL_OUT &= ~(LCD_E);            // Clock bit low again

⌨️ 快捷键说明

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