avr/display/display.h

72 lines
1.9 KiB
C

/*
Copyright 2022, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of Savanni's AVR library.
This AVR library is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
Lumeto is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
Lumeto. If not, see <https://www.gnu.org/licenses/>.
*/
/* This library covers a three-wire diagnostic display board.
*
* Hardware:
* 74HC595 shift register
* Adafruit HD44780 LCD
*
* Input pins:
* SDI -- Serial data in. This leads to the 74HC595, pin 14 (A).
* CLK -- Clock pulse. One bit will be shifted into the device on each rising
* edge. This leads to the 74HC595, pin 11 (Shift Clock).
* LS -- Latch pulse. All data in the shift register will be sent to the
* output on a rising edge. This leads to the 74HC595, pin 12 (Latch Clock);
*
* 74HC595 -> HD44780
* Qc -> D4
* Qd -> D5
* Qe -> D6
* Qf -> D7
* Qg -> RS
* Qh -> E
*
* I use the 4-wire protocol of the HD44780. This means that two of the shift
* register pins are used for the RS and E control pins of the LCD.
*/
#ifndef __DISPLAY_H__
#define __DISPLAY_H__
#include <shift_register.h>
#include <stddef.h>
typedef struct DISPLAY {
shift_register_t reg;
/*
gpio_t register_select;
gpio_t enable;
*/
} display_t;
void display_init(display_t *);
void display_clear(display_t *);
void display_enable(display_t *);
void display_set_location(display_t *, size_t, size_t);
void display_write_message(display_t *, const char *);
void display_write_bit_pattern(display_t *, const uint8_t);
#endif