void lcd_writebuffer() { lcd_setup(); for (int i=0; i<LCD_LINE_LENGTH; i++) _lcd_write(1,charTable[lcd_line_1[i]]); _lcd_write(0,0b11000000); for (int i=0; i<LCD_LINE_LENGTH; i++) _lcd_write(1,charTable[lcd_line_2[i]]); }
void lcd_setup() { //0 0 1 1 N F FT1 FT0 //_lcd_write(0,0b00111100);_delay_us(LCD_DELAY_INIT); _lcd_write(0,0b00111010);_delay_us(LCD_DELAY_INIT); //0 0 0 0 1 D C B _lcd_write(0,0b00001100);_delay_us(LCD_DELAY_INIT); _lcd_write(0,0b00000001);_delay_us(LCD_DELAY_INIT); _lcd_write(0,0b00000010);_delay_us(LCD_DELAY_INIT); _lcd_write(0,0b00000110);_delay_us(LCD_DELAY_INIT); }
/** Print a number on LCD */ void _lcd_printNumber(u16 n, u8 base) { u8 buf[8 * sizeof(long)]; // Assumes 8-bit chars. u16 i = 0; if (n == 0) { _lcd_write('0'); return; } while (n > 0) { buf[i++] = n % base; n /= base; } for (; i > 0; i--) _lcd_write((char) (buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10)); }
/** Print a float number to LCD */ void _lcd_printFloat(float number, u8 digits) { u8 i, toPrint; u16 int_part; float rounding, remainder; // Handle negative numbers if (number < 0.0) { _lcd_write('-'); number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" rounding = 0.5; for (i=0; i<digits; ++i) rounding /= 10.0; number += rounding; // Extract the integer part of the number and print it int_part = (u16)number; remainder = number - (float)int_part; _lcd_printNumber(int_part, 10); // Print the decimal point, but only if there are digits beyond if (digits > 0) _lcd_write('.'); // Extract digits from the remainder one at a time while (digits-- > 0) { remainder *= 10.0; toPrint = (unsigned int)remainder; //Integer part without use of math.h lib, I think better! (Fazzi) _lcd_printNumber(toPrint, 10); remainder -= toPrint; } }
/** Print a string on LCD */ void _lcd_print(char *string) { u8 i; for( i=0; string[i]; i++) _lcd_write(string[i]); }