AVRly - AVR Development Resources
main.c
Go to the documentation of this file.
1/******************************************************************************
2 @copyright Copyright © 2022 by Jason Duffy
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21******************************************************************************/
22
23/**
24 * @file main.c
25 * @ingroup digital_clock
26 * @author Jason Duffy
27 * @date 2nd April 2022
28 * @brief
29 * @bug No known bugs.
30 * @see
31 */
32
33#include "digital_clock.h"
34#include "hd44780_lcd.h"
35
36#define START_HOURS 21
37#define START_MINS 59
38#define START_SECS 02
39
40void print_time(void)
41{
42 static char *time;
43 time = get_time();
44 lcd_set_cursor(0,0);
46 lcd_print_string(time);
48}
49
50lcd_config_t lcd_config =
51{
52 .eight_bit_mode = false,
53 .two_line_display = true,
54 .five_by_ten_font = false,
55 .increment_counter = true,
56 .display_shift = false,
57 .cursor_enable = false,
58 .blink_enable = false,
59};
60
61
62int main()
63{
64 // Initialisation routines
65 init_lcd(&lcd_config);
66 set_time(START_HOURS, START_MINS, START_SECS);
68
69 while (1) // Loop forever
70 {
71 print_time();
72 }
73 return 0; // This line is never reached.
74}
75
76
77/*** end of file ***/
void lcd_print_string(const char *str)
Prints a string of characters to the display.
Definition: hd44780_lcd.c:205
void init_lcd(lcd_config_t *p_config)
Initialisation routine (run once at startup).
Definition: hd44780_lcd.c:105
void lcd_set_cursor(uint8_t column, uint8_t row)
Sets cursor location using x and y coordinates.
Definition: hd44780_lcd.c:247
char * get_time(void)
Getter function for time variables.
void set_time(uint8_t hrs, uint8_t mins, uint8_t secs)
Setter function for time variables.
void init_timer_counter_0(void)
Initialisation routine for 8-bit timer 0.
Definition: digital_clock.c:99
Driver to provide setup and configuration of the timer/counter hardware on the ATmega328P.
Driver for the HD44780 based 16x2 liquid crystal display.
int main()
Main routine to be executed on the MCU.
Definition: main.c:45
Configuration struct, to be instantiated and values assigned before passing it's address into and cal...
Definition: hd44780_lcd.h:57
bool eight_bit_mode
true = 8 bit mode, false = 4 bit mode.
Definition: hd44780_lcd.h:58