add exponent character
This commit is contained in:
parent
d45c9702b0
commit
bb102add67
37
src/lcd.c
37
src/lcd.c
@ -45,7 +45,6 @@ static int row, col;
|
||||
#define LCD_BUSY P2_7 //LCD D7
|
||||
|
||||
static void outCsrBlindNibble(unsigned char command);
|
||||
static void outCsrBlind(unsigned char command);
|
||||
static void outCsr(unsigned char command);
|
||||
static char readBusy(void);
|
||||
static void wait_busy(void);
|
||||
@ -66,13 +65,6 @@ static void outCsrBlindNibble(unsigned char command) {
|
||||
LCD_E = 0;
|
||||
}
|
||||
|
||||
static void outCsrBlind(unsigned char command) {
|
||||
outCsrBlindNibble(command >> 4); // ms nibble, E=0, RS=0
|
||||
_delay_us(100);
|
||||
outCsrBlindNibble(command); // ls nibble, E=0, RS=0
|
||||
_delay_us(100); // blind cycle 90 us wait
|
||||
}
|
||||
|
||||
static void outCsr(unsigned char command) {
|
||||
DISABLE_INTERRUPTS();
|
||||
outCsrBlindNibble(command >> 4); // ms nibble, E=0, RS=0
|
||||
@ -143,6 +135,7 @@ static void LCD_OutChar(unsigned char c) {
|
||||
}
|
||||
|
||||
void LCD_Open(void) {
|
||||
uint8_t i;
|
||||
//set ports to push-pull output M[1:0] = b01
|
||||
//P2 entire port
|
||||
P2M1 = 0;
|
||||
@ -161,21 +154,35 @@ void LCD_Open(void) {
|
||||
outCsrBlindNibble(0x02); // DL=1 switch to 4 bit mode (only high 4 bits are sent)
|
||||
_delay_us(100); // blind cycle 100 us wait
|
||||
//set increment, no shift
|
||||
outCsrBlind(0x4 + LCDINC + LCDNOSHIFT);
|
||||
outCsr(0x4 + LCDINC + LCDNOSHIFT);
|
||||
#ifdef DEBUG
|
||||
//set display on, cursor on, blink on:
|
||||
outCsrBlind(0x0c + LCDCURSOR + LCDBLINK);
|
||||
outCsr(0x0c + LCDCURSOR + LCDBLINK);
|
||||
#else
|
||||
//set display on, cursor and blink off:
|
||||
outCsrBlind(0x0c + LCDNOCURSOR + LCDNOBLINK);
|
||||
outCsr(0x0c + LCDNOCURSOR + LCDNOBLINK);
|
||||
#endif
|
||||
//set display shift on and to the right
|
||||
outCsrBlind(0x10 + LCDNOSCROLL + LCDRIGHT);
|
||||
outCsr(0x10 + LCDNOSCROLL + LCDRIGHT);
|
||||
//set 4-bit mode, 2 line, 5x7 display:
|
||||
outCsrBlind(0x20 + LCD2LINE + LCD7DOT);
|
||||
outCsr(0x20 + LCD2LINE + LCD7DOT);
|
||||
|
||||
outCsr(0x40); //set cgram address to 0
|
||||
//program CGRAM
|
||||
for (i = 0; i < 2; i++){
|
||||
//define exponent and negative exponent sign
|
||||
LCD_OutChar(0x0);
|
||||
LCD_OutChar(i ? 0x0f : 0);
|
||||
LCD_OutChar(0x0);
|
||||
LCD_OutChar(0x1c);
|
||||
LCD_OutChar(0x10);
|
||||
LCD_OutChar(0x18);
|
||||
LCD_OutChar(0x10);
|
||||
LCD_OutChar(0x1c);
|
||||
}
|
||||
|
||||
//clear display
|
||||
// LCD_Clear();
|
||||
// _delay_ms(50);
|
||||
LCD_Clear();
|
||||
}
|
||||
|
||||
//row and columns indexed from 0
|
||||
|
@ -17,6 +17,9 @@ void LCD_ClearToEnd(uint8_t curr_row);
|
||||
|
||||
unsigned char LCD_Timeout_Error(void);
|
||||
|
||||
//CGRAM character address
|
||||
#define CGRAM_EXP 0
|
||||
#define CGRAM_EXP_NEG 1
|
||||
|
||||
#endif
|
||||
|
||||
|
12
src/main.c
12
src/main.c
@ -168,10 +168,10 @@ int main()
|
||||
} else { //have exponent to display
|
||||
LCD_OutString(Buf, MAX_CHARS_PER_LINE - 3);
|
||||
if (disp_exponent < 0){
|
||||
TERMIO_PutChar('-');
|
||||
TERMIO_PutChar(CGRAM_EXP_NEG);
|
||||
disp_exponent = -disp_exponent;
|
||||
} else {
|
||||
TERMIO_PutChar(' ');
|
||||
TERMIO_PutChar(CGRAM_EXP);
|
||||
}
|
||||
TERMIO_PutChar((disp_exponent / 10) + '0');
|
||||
TERMIO_PutChar((disp_exponent % 10) + '0');
|
||||
@ -376,10 +376,10 @@ int main()
|
||||
} else { //have exponent to display
|
||||
LCD_OutString(Buf, MAX_CHARS_PER_LINE - 3);
|
||||
if (disp_exponent < 0){
|
||||
TERMIO_PutChar('-');
|
||||
TERMIO_PutChar(CGRAM_EXP_NEG);
|
||||
disp_exponent = -disp_exponent;
|
||||
} else {
|
||||
TERMIO_PutChar(' ');
|
||||
TERMIO_PutChar(CGRAM_EXP);
|
||||
}
|
||||
TERMIO_PutChar((disp_exponent / 10) + '0');
|
||||
TERMIO_PutChar((disp_exponent % 10) + '0');
|
||||
@ -408,9 +408,9 @@ int main()
|
||||
}
|
||||
//print exponent sign
|
||||
if (entering_exp == ENTERING_EXP_NEG){
|
||||
TERMIO_PutChar('-');
|
||||
TERMIO_PutChar(CGRAM_EXP_NEG);
|
||||
} else {
|
||||
TERMIO_PutChar(' ');
|
||||
TERMIO_PutChar(CGRAM_EXP);
|
||||
}
|
||||
//print exp
|
||||
TERMIO_PutChar(ExpBuf[1] + '0');
|
||||
|
Loading…
Reference in New Issue
Block a user