From 2bb687d09947310d3e8c9a89d6932865912bc8b6 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Sun, 28 Jul 2019 01:09:20 -0500 Subject: Add VFD brightness level. --- conf.h | 3 +++ lcd.c | 11 ++++++++++- main.c | 10 +++++++++- main.h | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/conf.h b/conf.h index c63df84..6f5c652 100755 --- a/conf.h +++ b/conf.h @@ -17,6 +17,9 @@ // Define baud rate of 9600 #define Baud_rate 9600 +// Define if VFD if used +#define VFD 1 + // HD44780 #define RS RD2 // Register Select on RD2 #define EN RD3 // Enable on RD3 diff --git a/lcd.c b/lcd.c index b6d0ece..0ec8e38 100755 --- a/lcd.c +++ b/lcd.c @@ -65,6 +65,9 @@ void Lcd_Init() { Lcd_Cmd(0x03); ///////////////////////////////////////////////////// Lcd_Cmd(0x02); +#ifdef VFD + Vfd_Set_Brightness(0); //Set brightness to max +#endif Lcd_Cmd(0x02); Lcd_Cmd(0x08); Lcd_Cmd(0x00); @@ -105,6 +108,12 @@ void Lcd_Shift_Left() { } // For some VFD's like Noritake + void Vfd_Set_Brightness(int level) { - + Lcd_Cmd(0x03); + __delay_ms(11); + Lcd_Cmd(0x03); + ///////////////////////////////////////////////////// + Lcd_Cmd(0x02); + Lcd_Write_Char(level); } \ No newline at end of file diff --git a/main.c b/main.c index 86caf6a..9c1020b 100755 --- a/main.c +++ b/main.c @@ -46,6 +46,10 @@ int main() { UART_send_string(CLRATTR); // No color #endif +#ifdef VFD + Vfd_Set_Brightness(0); //Max brightness 3 - minimum +#endif + display_Intro(); display_Lcd_Layout(); @@ -53,7 +57,7 @@ int main() { //Set_Time_Date(); //Set_Time(); //Set_Date(); - //Set_DayOfWeek(); + Set_DayOfWeek(); // Write default alarm values @@ -65,6 +69,10 @@ int main() { UART_send_string("Writing Alarms\r\n"); Write_Alarms();*/ +#ifdef VFD + Vfd_Set_Brightness(3); //Max brightness 3 - minimum +#endif + while (1) { // Set time and date variables from DS3231 diff --git a/main.h b/main.h index d51ebe3..35fead3 100755 --- a/main.h +++ b/main.h @@ -2,7 +2,7 @@ unsigned int sec = 30; unsigned int min = 42; unsigned int hour = 21; -unsigned int dayOfWeek = 7; +unsigned int dayOfWeek = 1; unsigned int date = 27; unsigned int month = 7; unsigned int year = 19; -- cgit v1.2.3-54-g00ecf