/*=============================================================================
* File: dogm16x.h
* Created: September 12, 2010 [v.1.0]
* Last change: September 3, 2011 [v.1.4]
* Author: Fredrik Jonsson
*
* Copyright (C) 2011, Fredrik Jonsson
* Non-commercial copying welcome.
*===========================================================================*/
#define DOGM163_NUM_COLS (16) /* LCD width of 16 characters */
#define DOGM163_NUM_ROWS (3) /* LCD height of 3 rows */
#define DOGM162_NUM_COLS (16) /* LCD width of 16 characters */
#define DOGM162_NUM_ROWS (2) /* LCD height of 2 rows */
#define DOGM161_NUM_COLS (16) /* LCD width of 16 characters */
#define DOGM161_NUM_ROWS (1) /* LCD height of 2 rows */
#define DOGM_TAB_LENGTH (3) /* Number of spaces per tab */
#define LCDDATA (0x01) /* Address of data register */
#define LCDCMD (0x00) /* Address of command register */
#define PMDATA (PMDIN1) /* The PMP data buffer */
/*
* Define:s for the main Instruction Table of the DOGM display family, straight
* from the bit pattern settings listed in the data sheet.
*/
#define DOGM_CLEAR__DISPLAY (0x01) /* 00000001 = 0x01 */
#define DOGM_RETURN_HOME (0x02) /* 00000010 = 0x02 */
/*
* Define:s for cursor move direction and display shift; operations performed
* after data read and write. Concatenate patterns by bitwise OR:
* DOGM_ENTRY_MODE_SET
* |{DOGM_CURSOR_MOVE_DIR_FORWARD OR DOGM_CURSOR_MOVE_DIR_BACKWARD}
* |{DOGM_CURSOR_SHIFT_DIR_UP OR DOGM_CURSOR_SHIFT_DIR_DOWN}
*/
#define DOGM_ENTRY_MODE_SET (0x04) /* 00000100 = 0x04 */
#define DOGM_CURSOR_MOVE_DIR_FORWARD (0x02) /* 00000010 = 0x02 */
#define DOGM_CURSOR_MOVE_DIR_BACKWARD (0x00) /* 00000000 = 0x00 */
#define DOGM_CURSOR_SHIFT_DIR_UP (0x01) /* 00000001 = 0x01 */
#define DOGM_CURSOR_SHIFT_DIR_DOWN (0x00) /* 00000000 = 0x00 */
/*
* Display appearance for cursor etc. Concatenate patterns by bitwise OR:
* DOGM_DISPLAY_ON
* |{DOGM_ENTIRE_DISPLAY_ON OR DOGM_ENTIRE_DISPLAY_OFF}
* |{DOGM_CURSOR_ON OR DOGM_CURSOR_OFF}
* |{DOGM_CURSOR_POSITION_ON OR DOGM_CURSOR_POSITION_OFF}
*/
#define DOGM_DISPLAY_ON (0x08) /* 00001000 = 0x08 */
#define DOGM_ENTIRE_DISPLAY_ON (0x04) /* 00000100 = 0x04 */
#define DOGM_ENTIRE_DISPLAY_OFF (0x00) /* 00000000 = 0x00 */
#define DOGM_CURSOR_ON (0x02) /* 00000010 = 0x02 */
#define DOGM_CURSOR_OFF (0x00) /* 00000000 = 0x00 */
#define DOGM_CURSOR_POSITION_ON (0x01) /* 00000001 = 0x01 */
#define DOGM_CURSOR_POSITION_OFF (0x00) /* 00000000 = 0x00 */
/*
* Define:s for the set function and selection of instruction table.
* after data read and write. Concatenate patterns by bitwise OR:
* DOGM_FUNCTION_SET
* |{DOGM_EIGHT_BIT_INTERFACE OR DOGM_FOUR_BIT_INTERFACE}
* |{DOGM_NUM_LINE_IS_ONE OR DOGM_NUM_LINE_IS_TWO}
* |{DOGM_SINGLE_HEIGHT_FONT OR DOGM_DOUBLE_HEIGHT_FONT}
* |{DOGM_INSTRUCTION_TABLE_ONE OR DOGM_INSTRUCTION_TABLE_TWO}
*/
#define DOGM_FUNCTION_SET (0x20) /* 00100000 = 0x20 */
#define DOGM_EIGHT_BIT_INTERFACE (0x10) /* 00010000 = 0x10 */
#define DOGM_FOUR_BIT_INTERFACE (0x00) /* 00000000 = 0x00 */
#define DOGM_NUM_LINE_IS_ONE (0x00) /* 00000000 = 0x00 */
#define DOGM_NUM_LINE_IS_TWO (0x08) /* 00001000 = 0x08 */
#define DOGM_SINGLE_HEIGHT_FONT (0x00) /* 00000000 = 0x00 */
#define DOGM_DOUBLE_HEIGHT_FONT (0x04) /* 00000100 = 0x04 */
#define DOGM_INSTRUCTION_TABLE_ZERO (0x00)/* 00000000 = 0x00 */
#define DOGM_INSTRUCTION_TABLE_ONE (0x01) /* 00000001 = 0x01 */
#define DOGM_INSTRUCTION_TABLE_TWO (0x02) /* 00000002 = 0x02 */
/*
* Define:s for Instruction Table 1 of the DOGM display family, straight
* from the bit pattern settings listed in the data sheet. Concatenate
* patterns by bitwise OR:
* DOGM_BIAS_SET
* |{DOGM_ONE_FOURTH_BIAS OR DOGM_ONE_FIFTH_BIAS}
* |{DOGM_THREELINE_BIAS OR DOGM_TWOLINE_BIAS OR DOGM_ONELINE_BIAS}
*/
#define DOGM_BIAS_SET (0x14) /* 00010100 = 0x14 */
#define DOGM_ONE_FOURTH_BIAS (0x08) /* 00001000 = 0x08 */
#define DOGM_ONE_FIFTH_BIAS (0x00) /* 00000000 = 0x00 */
#define DOGM_THREELINE_BIAS (0x01) /* 00000001 = 0x01 */
#define DOGM_TWOLINE_BIAS (0x00) /* 00000000 = 0x00 */
#define DOGM_ONELINE_BIAS (0x00) /* 00000000 = 0x00 */
extern void delayms(unsigned t);
extern void initialize_display(void);
extern char read_display_register(int addr);
extern int read_current_address_counter(void);
extern char display_is_busy(void);
extern void write_to_display_register(int addr, char c);
extern void write_character_to_display(char c);
extern void send_command_to_display(char c);
extern void setLCDG(char a);
extern void setLCDC(char a);
extern void clear_display(void);
extern void move_to_position_on_display(int rowpos, int colpos);
extern void move_to_beginning_of_display(void);
extern void move_to_beginning_of_line(void);
extern void advance_to_next_line(void);
extern void write_string_to_display(char *s);