aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rwxr-xr-xmain.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/main.c b/main.c
index 8bb8554..c5235d1 100755
--- a/main.c
+++ b/main.c
@@ -1,5 +1,3 @@
-#include <stdio.h> // included for sprintf
-
#include "conf.h" //Configuration settings
#include "main.h" //Declarations for main
#include "lcd.h" //Declaratons for LCD
@@ -19,6 +17,10 @@
void main(void) {
TRISA0 = 0x01; // RA is input (ADC)
+
+ TRISBbits.TRISB0 = 0; // Set RB0 as output
+ PORTBbits.RB0 = 0; // Set RB0 low
+
TRISC = 0x00; // Set PORTC as outputs
PORTC = 0x00; // Set all PORTC pins LOW
@@ -54,7 +56,7 @@ void main(void) {
Lcd_Init();
#ifdef DEBUG
- UART_send_string(CURSOR(15, 23)); // Set cursor at line 15, column 23
+ UART_send_string(CURSOR(15, 24)); // Set cursor at line 15, column 24
UART_send_string(GREEN); // Set Green
UART_send_string("LCD Module Initialized and active\r\n");
UART_send_string(CLRATTR); // No color
@@ -132,11 +134,11 @@ void main(void) {
#ifdef ADC
// Get current LDR reading and calculate for brightness levels 0 - 3
- ldr = Adc_Read(0) / 256;
+ ldr = Adc_Read(0);
- if (ldr_chg != ldr) {
- Vfd_Set_Brightness(ldr);
- ldr_chg = ldr;
+ if (brtlvl_chg != brtlvl) {
+ Vfd_Set_Brightness(brtlvl);
+ brtlvl_chg = brtlvl;
}
#endif
@@ -158,7 +160,7 @@ void main(void) {
UART_send_string(buf);
sprintf(buf, "%sTEMP:\t%s%c%c%c.%c%cC%s\t\t%sLDR:%s\t\%04d %d\r\n",
YELLOW, CLRATTR, temp_sign, temp_2, temp_1, temp_0, 0xB0,
- CLRATTR, YELLOW, CLRATTR, ldr, ldr / 256);
+ CLRATTR, YELLOW, CLRATTR, ldr, brtlvl);
UART_send_string(buf);
#endif
}