This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
AtTiny_alarm_clock/Libs/LCD4/lcd4.h
2018-07-16 17:04:58 +02:00

95 lines
3.5 KiB
C

/* avrmb2313_lcd.h
* V 1.0 by (Hr & RJH-Systems) @ (FLG)
* 30.03.07
* Zum Ansteuern eines zweizeiligen LCD-Displays
* Hitachi 44780 od. KS0070B
* auf dem AVR-evaluationsboard von Matze Brenner
* > www.flg-informatik.de
* 8-bit Mode
* 4-bit Mode
*/
#ifndef avrmb2313_lcd
#define avrmb2313_lcd
#include <inttypes.h>
/* Some ports must be definded first, dont touch these for avrmb2313-project
* but set for other Designs using other out-Ports
*/
#ifndef lcd_bus4
#ifndef lcd_bus8
#define lcd_bus4 //defaults to 4-Bit
#endif
#endif
#ifndef lcd_dataports_defined
#define lcd_dataports_defined
#include <avr/io.h>
#define lcd_dataport PORTB
#define lcd_dataport_DDR DDRB // DataDirectionRegister für lcd_datatport
//#ifdef lcd_bus8
#define lcd_dataport_mask 0xf0 // which bits in that port (8-bit = 0xff for 8-bit operation)
//#else
// #define lcd_dataport_mask 0xf0 // which bits in that port (4-bit = 0xf0 for 4-bit operation)
// #endif
#define set_lcd_RS_DDR DDRD=(DDRD | ((uint8_t) 0x08)) // Dir-Out für lcd _RS setzen)
#define set_lcd_E_DDR DDRD=(DDRD | ((uint8_t) 0x04)) // Dir-Out für lcd _E setzen)
#define set_lcd_RS PORTD=(PORTD | ((uint8_t) 0x08)) // Bit für lcd _RS setzen)
#define unset_lcd_RS PORTD=(PORTD & ~((uint8_t) 0x08)) // Bit für lcd _RS löschen)
#define set_lcd_E PORTD=(PORTD | ((uint8_t) 0x04)) // Bit für lcd _E setzen)
#define unset_lcd_E PORTD=(PORTD & ~((uint8_t) 0x04)) // Bit für lcd _E löschen)
#
#endif
extern void wait_100us(void); // This function must be implemented
// Bitte eine Funktion "void wait_100us()" implementieren, die 100us wartet
// Please implement function "void wait_100us()": just waiting 100*10^(-6) s
extern void lcd_init(void);
extern void lcd_write(uint8_t lcd_whichwrite, uint8_t zeichen, uint8_t position);
enum lcd_whichwrite{here, therepos, line1, line2, instruct, preinstruct};
extern void lcd_blank_line(uint8_t lcd_whichwrite); // line1, line2, instruct=all
extern void lcd_instruct(uint8_t zeichen);
/* possible "zeichen":
lcd_DISPLAY_CLEAR
lcd_RETURN_HOME
lcd_ENTRY_MODE_SET_INCREASE
lcd_ENTRY_MODE_SET_DECREASE
lcd_ENTRY_MODE_SET_DISPLAY_SHIFTED
lcd_ENTRY_MS_DISPLAY_NOT_S hifted
*/
extern void lcd_5ms(); //based on wait_100us
extern void lcd_1s(); //based on wait_100us
// Die Konstanten des lcd-Kontrollers local
#define lcd_DISPLAY_CLEAR 0b00000001
#define lcd_RETURN_HOME 0b00000010
#define lcd_ENTRY_MODE_SET 0b00000100
#define lcd_ENTRY_MODE_SET_INCREASE 0b00000110
#define lcd_ENTRY_MODE_SET_DECREASE 0b00000100
#define lcd_ENTRY_MODE_SET_DISPLAY_SHIFTED 0b00000101
#define lcd_ENTRY_MS_DISPLAY_NOT_S 0b00000100
#define lcd_DISPLAY_OO 0b00001000
#define lcd_DISPLAY_OO_ON 0b00001100
#define lcd_DISPLAY_OO_OFF 0b00001000
#define lcd_DISPLAY_OO_CURSOR_ON 0b00001010
#define lcd_DISPLAY_OO_CURSOR_OFF 0b00001000
#define lcd_DISPLAY_OO_BLINKING_ON 0b00001001
#define lcd_DISPLAY_OO_BLINKING_OFF 0b00001000
#define lcd_SHIFT 0b00010000
#define lcd_SHIFT_DISPLAY_SHIFT 0b00011000
#define lcd_SHIFT_CURSOR_MOVE 0b00010000
#define lcd_SHIFT_RIGHT_SHIFT 0b00010100
#define lcd_SHIFT_LEFT_SHIFT 0b00010000
#define lcd_SET_FUNCTION 0b00100000
#define lcd_SET_FUNCTION_8BIT 0b00110000
#define lcd_SET_FUNCTION_4BIT 0b00100000
#define lcd_SET_FUNCTION_2LINE 0b00101000
#define lcd_SET_FUNCTION_1LINE 0b00100000
#define lcd_SET_FUNCTION_5X10 0b00100100
#define lcd_SET_FUNCTION_7X5 0b00100000
#define lcd_SET_CG_RAM 0b01000000
#define lcd_SET_DD_RAM 0b10000000
#endif