1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#include "lcd.h" //Declaratons for LCD
#include "i2c.h"
#include "ds3231.h" //Declarations for RTC
#ifdef ADC
#include "adc.h" //Declarations for ADC
#endif
#include "beep.h" //Declarations for BEEP
#ifdef DEBUG
#include "uart.h" //Declarations for UART
#include "term.h" //Declarations for Escape codes
#endif
#ifdef ADC
// Declare variable for LDR
unsigned int ldr;
#endif
// Declare variables for VFD brightness level
#define brtlvl ldr/256
unsigned int brtlvl_chg;
// Update to 1 if RB0 interrupt occurs, otherwise 0
unsigned int update;
// Boolean if setting time manually with user input
unsigned int edit_datetime;
// Declare variables for date time and alarms
extern unsigned int sec;
extern unsigned int min;
extern unsigned int hour;
extern unsigned int day;
extern unsigned int date;
extern unsigned int month;
extern unsigned int year;
extern unsigned int century;
extern unsigned int alarm1_sec, alarm1_min, alarm1_hour;
extern unsigned int alarm2_min, alarm2_hour;
extern unsigned int status_reg, alarm1_status, alarm2_status;
extern unsigned int control_reg;
// Declare variables for temperature
extern unsigned int temperature_lsb;
extern int temperature_msb;
unsigned char temp_sign;
// Define MSB / LSB: Useful for separating into chars for tens and ones places
#define LSB(x) ((x % 10) + '0') // x >> 4
#define MSB(x) ((x / 10) + '0') // x & 0x0F
#ifdef DEBUG
#include <stdio.h> // included for sprintf
// Declare a variable to use as a buffer for sprintf
char buf[40];
#endif
// Various display functions. Pass y and x coordinates with data
void display_Alpha(char, char, char);
void display_Digit(char, char, unsigned int);
void display_Intro(void);
void display_Lcd_Layout(void);
void display_Text(char, char, char *);
// Manually update time with set buttons
void edit_Date_Time(void);
// Format msb and lsb for temperature display
void format_Temperature(void);
// Determine Alarm status from control registers
void Get_Alarm_Status(void);
// Increment/Decrement values with time digit constraints
void decrementValue(unsigned int*, unsigned int, unsigned int);
void incrementValue(unsigned int*, unsigned int, unsigned int);
// Time separator colons
void timeSeparatorOn(void);
void timeSeparatorOff(void);
// Update display with current values
void update_Display(void);
// Interrupt service routine
void __interrupt() isr(void);
|