📄 dc550_display.c
字号:
******************************************************************************
* DESCRIPTION:
* This function is called to execute the display driver task. The display
* driver itself has five states:
* A. Idle State
* B. Update Line One
* C. Update Line Two
* D. Verify Line One
* E. Verify Line Two
* During the Update Line One and Update Line Two states, the display driver
* updates lines one and two on the display, respectively. During the
* Verify Line One and Verify Line Two states, the display driver reads from
* the LCD DDRAM and checks its contents against the contents of the local
* buffer. During the Idle State, the display driver checks to see if:
* 1. Line One needs to be updated
* 2. Line Two needs to be updated
* 3. The cursor needs to be turned on or off
* 4. Enough time has elapsed to warrant entry into the Verify Line One State
* 5. Enough time has elapsed to warrant entry into the Verify Line Two State
* These states are necessary because the display driver is not permitted to
* run for more than 250 microseconds at a stretch.
*
* Because of the layout of the LCD glass, the display driver uses four
* quadrants rather than two lines. The quadrants are:
*
* 1 | 3
* ----------------------------
* 2 | 4
*****************************************************************************/
void display_exec(void) {
// Declare function variables
int i;
switch(display_current_state) {
case DISPLAY_STATE_IDLE:
if(display_statuschange_lineone) {
display_current_updatex = 0;
display_current_state = DISPLAY_STATE_LINEONE;
display_exec_quadrantone();
}
else if(display_statuschange_linetwo) {
display_current_updatex = 0;
display_current_state = DISPLAY_STATE_LINETWO;
display_exec_quadranttwo();
}
else if(display_statuschange_cursor)
display_exec_cursor();
else if((interrupt_counter-display_verify_counter)>DISPLAY_VERIFYTIME) {
display_verify_counter = interrupt_counter;
display_current_updatex = 0;
display_current_state = DISPLAY_STATE_VERIFY_L1;
display_exec_verifyquadone();
}
break;
case DISPLAY_STATE_LINEONE:
if(display_current_updatex < 12)
display_exec_quadrantone();
else
display_exec_quadrantthree();
break;
case DISPLAY_STATE_LINETWO:
if(display_current_updatex < 12)
display_exec_quadranttwo();
else
display_exec_quadrantfour();
break;
case DISPLAY_STATE_VERIFY_L1:
if(display_current_updatex < 12)
display_exec_verifyquadone();
else
display_exec_verifyquadthree();
break;
case DISPLAY_STATE_VERIFY_L2:
if(display_current_updatex < 12)
display_exec_verifyquadtwo();
else
display_exec_verifyquadfour();
break;
case DISPLAY_STATE_RESET_STAGE01:
for(i=0; i<25; i++) {
display_current_lineone[i] = 0;
display_current_linetwo[i] = 0;
}
display_usingbus = TRUE; // Enable LCD over LEDs
display_instr_functionset(); // Function Set (LCD function)
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE02;
break;
case DISPLAY_STATE_RESET_STAGE02:
display_usingbus = TRUE; // Enable LCD over LEDs
display_instr_functionset(); // Function Set (LCD function)
for(i = 48; i > 0; i--); // Wait for 40 microseconds
display_instr_functionset(); // Function Set (LCD function)
for(i = 48; i > 0; i--); // Wait for 40 microseconds
display_instr_displaymode(); // Display On (LCD function)
for(i = 48; i > 0; i--); // Wait for 40 microseconds
display_instr_displayclear(); // Display Clear
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE03;
break;
case DISPLAY_STATE_RESET_STAGE03:
display_usingbus = TRUE; // Enable LCD over LEDs
display_instr_entrymode(); // Entry Mode Set
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE04;
break;
case DISPLAY_STATE_RESET_STAGE04:
display_usingbus = TRUE; // Enable LCD over LEDs
display_instr_cgramaddress(0x01); // CGRAM address 1
for(i = 48; i > 0; i--); // Wait for 40 microseconds
display_util_chartop_emptybox(); // Write top of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE05;
break;
case DISPLAY_STATE_RESET_STAGE05:
display_usingbus = TRUE; // Enable LCD over LEDs
display_util_charbottom_emptybox(); // Write bottom of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE06;
break;
case DISPLAY_STATE_RESET_STAGE06:
display_usingbus = TRUE; // Enable LCD over LEDs
display_instr_cgramaddress(0x02); // CGRAM address 2
for(i = 48; i > 0; i--); // Wait for 40 microseconds
display_util_chartop_fullbox(); // Write top of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE07;
break;
case DISPLAY_STATE_RESET_STAGE07:
display_usingbus = TRUE; // Enable LCD over LEDs
display_util_charbottom_fullbox(); // Write bottom of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE08;
break;
case DISPLAY_STATE_RESET_STAGE08:
display_usingbus = TRUE; // Enable LCD over LEDs
display_instr_cgramaddress(0x03); // CGRAM address 3
for(i = 48; i > 0; i--); // Wait for 40 microseconds
display_util_chartop_uparrow(); // Write top of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE09;
break;
case DISPLAY_STATE_RESET_STAGE09:
display_usingbus = TRUE; // Enable LCD over LEDs
display_util_charbottom_uparrow(); // Write bottom of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE10;
break;
case DISPLAY_STATE_RESET_STAGE10:
display_usingbus = TRUE; // Enable LCD over LEDs
display_instr_cgramaddress(0x04); // CGRAM address 4
for(i = 48; i > 0; i--); // Wait for 40 microseconds
display_util_chartop_downarrow(); // Write top of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_RESET_STAGE11;
break;
case DISPLAY_STATE_RESET_STAGE11:
display_usingbus = TRUE; // Enable LCD over LEDs
display_util_charbottom_downarrow(); // Write bottom of character
display_usingbus = FALSE; // Enable LCD over LEDs
display_current_state = DISPLAY_STATE_IDLE;
break;
}
}
/******************************************************************************
* FUNCTION: display_exec_quadrantone(void)
******************************************************************************
* DESCRIPTION:
* This function is called by the display_exec(.) function whenever
* display_statuschange_lineone is true and the display_current_updatex is
* still less than 12. It updates the first quadrant of the display
* five characters at a time (more or less).
*****************************************************************************/
void display_exec_quadrantone(void) {
// Declare local variables
int j = 0;
// Disable the cursor if it is currently enabled
if(display_cursorblink) {
display_util_tempdisablecursor();
j++;
}
// Find the first character we have to update and move the cursor there
while((display_current_updatex !=12 ) &&
(display_new_lineone[display_current_updatex] ==
display_current_lineone[display_current_updatex]))
display_current_updatex++;
display_util_setcoordinates(0, display_current_updatex);
j++;
// Update the display starting from that character
while((display_current_updatex !=12 ) && (j < DISPLAY_MAXINSTRUCTIONS)) {
display_current_lineone[display_current_updatex] =
display_new_lineone[display_current_updatex];
display_util_writedata(display_current_lineone[display_current_updatex]);
display_current_updatex++;
j++;
}
}
/******************************************************************************
* FUNCTION: display_exec_quadrantthree(void)
******************************************************************************
* DESCRIPTION:
* This function is called by the display_exec(.) function whenever
* display_statuschange_lineone is true and the display_current_updatex is
* greater than 12. It updates the third quadrant of the display
* five characters at a time (more or less).
*****************************************************************************/
void display_exec_quadrantthree(void) {
// Declare local variables
int j = 0;
// Find the first character we have to update and move the cursor there
while((display_current_updatex !=24 ) &&
(display_new_lineone[display_current_updatex] ==
display_current_lineone[display_current_updatex]))
display_current_updatex++;
display_util_setcoordinates(0, display_current_updatex);
j++;
// Update the display starting from that character
while((display_current_updatex !=24 ) && (j < DISPLAY_MAXINSTRUCTIONS)) {
display_current_lineone[display_current_updatex] =
display_new_lineone[display_current_updatex];
display_util_writedata(display_current_lineone[display_current_updatex]);
display_current_updatex++;
j++;
}
if(display_current_updatex == 24) {
display_statuschange_lineone = FALSE;
display_current_state = DISPLAY_STATE_IDLE;
}
}
/******************************************************************************
* FUNCTION: display_exec_quadranttwo(void)
******************************************************************************
* DESCRIPTION:
* This function is called by the display_exec(.) function whenever
* display_statuschange_linetwo is true and the display_current_updatex is
* still less than 12. It updates the second quadrant of the display
* five characters at a time (more or less).
*****************************************************************************/
void display_exec_quadranttwo(void) {
// Declare local variables
int j = 0;
// Disable the cursor if it is currently enabled
if(display_cursorblink) {
display_util_tempdisablecursor();
j++;
}
// Find the first character we have to update and move the cursor there
while((display_current_updatex !=12 ) &&
(display_new_linetwo[display_current_updatex] ==
display_current_linetwo[display_current_updatex]))
display_current_updatex++;
display_util_setcoordinates(1, display_current_updatex);
j++;
// Update the display starting from that character
while((display_current_updatex !=12 ) && (j < DISPLAY_MAXINSTRUCTIONS)) {
display_current_linetwo[display_current_updatex] =
display_new_linetwo[display_current_updatex];
display_util_writedata(display_current_linetwo[display_current_updatex]);
display_current_updatex++;
j++;
}
}
/******************************************************************************
* FUNCTION: display_exec_quadrantfour(void)
******************************************************************************
* DESCRIPTION:
* This function is called by the display_exec(.) function whenever
* display_statuschange_linetwo is true and the display_current_updatex is
* greater than 12. It updates the fourth quadrant of the display
* five characters at a time (more or less).
*****************************************************************************/
void display_exec_quadrantfour(void) {
// Declare local variables
int j = 0;
// Find the first character we have to update and move the cursor there
while((display_current_updatex !=24 ) &&
(display_new_linetwo[display_current_updatex] ==
display_current_linetwo[display_current_updatex]))
display_current_updatex++;
display_util_setcoordinates(1, display_current_updatex);
j++;
// Update the display starting from that character
while((display_current_updatex !=24 ) && (j < DISPLAY_MAXINSTRUCTIONS)) {
display_current_linetwo[display_current_updatex] =
display_new_linetwo[display_current_updatex];
display_util_writedata(display_current_linetwo[display_current_updatex]);
display_current_updatex++;
j++;
}
if(display_current_updatex == 24) {
display_statuschange_linetwo = FALSE;
display_current_state = DISPLAY_STATE_IDLE;
}
}
/******************************************************************************
* FUNCTION: display_exec_verifyquadone(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_verifyquadone(void) {
// Declare function variables
int j = 1;
char readcharacter;
// Disable the cursor if it is currently enabled
if(display_cursorblink) {
display_util_tempdisablecursor();
j++;
}
// Set coordinates at display_current_updatex on line one
display_util_setcoordinates(0, display_current_updatex);
while((display_current_updatex != 12 ) &&
(j < DISPLAY_MAXINSTRUCTIONS)) {
readcharacter = display_util_readdata();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -