23 #include <avr/pgmspace.h> 24 #include <compat/deprecated.h> 30 #if defined BOARD_LOCO_DEV //EmbeddedLocoNet 31 #define LCD_DATA_PORT PORTC 32 #define LCD_DATA_DDR DDRC 34 #define LCD_DATA_D4_PIN 1 35 #define LCD_DATA_D5_PIN 0 36 #define LCD_DATA_D6_PIN 3 37 #define LCD_DATA_D7_PIN 2 39 #define LCD_RS_PORT PORTD 40 #define LCD_RS_DDR DDRD 43 #define LCD_E_PORT PORTD 44 #define LCD_E_DDR DDRD 47 #elif defined BOARD_PROTO_128 //ProtoBoardMega128 48 #define LCD_DATA_PORT PORTC 49 #define LCD_DATA_DDR DDRC 51 #define LCD_DATA_D4_PIN 0 52 #define LCD_DATA_D5_PIN 1 53 #define LCD_DATA_D6_PIN 2 54 #define LCD_DATA_D7_PIN 3 56 #define LCD_RS_PORT PORTC 57 #define LCD_RS_DDR DDRC 60 #define LCD_E_PORT PORTC 61 #define LCD_E_DDR DDRC 64 #elif defined BOARD_PROTO_48 //ProtoBoardMega48 65 #define LCD_DATA_PORT PORTD 66 #define LCD_DATA_DDR DDRD 68 #define LCD_DATA_D4_PIN 4 69 #define LCD_DATA_D5_PIN 5 70 #define LCD_DATA_D6_PIN 6 71 #define LCD_DATA_D7_PIN 7 73 #define LCD_RS_PORT PORTD 74 #define LCD_RS_DDR DDRD 77 #define LCD_E_PORT PORTD 78 #define LCD_E_DDR DDRD 82 #else //No Board defined (Error) 83 # warning "Board not defined" 89 #define LCD_ENTRY_MODE 2 90 #define LCD_ENTRY_INC 1 91 #define LCD_ENTRY_SHIFT 2 93 #define LCD_ON_DISPLAY 2 94 #define LCD_ON_CURSOR 1 95 #define LCD_ON_BLINK 0 97 #define LCD_MOVE_DISP 3 98 #define LCD_MOVE_RIGHT 2 99 #define LCD_FUNCTION 5 100 #define LCD_FUNCTION_8BIT 4 101 #define LCD_FUNCTION_2LINES 3 102 #define LCD_FUNCTION_10DOTS 2 108 #define LCD_ENTRY_DEC 0x04 109 #define LCD_ENTRY_DEC_SHIFT 0x05 110 #define LCD_ENTRY_INC_ 0x06 111 #define LCD_ENTRY_INC_SHIFT 0x07 114 #define LCD_MOVE_CURSOR_LEFT 0x10 115 #define LCD_MOVE_CURSOR_RIGHT 0x14 116 #define LCD_MOVE_DISP_LEFT 0x18 117 #define LCD_MOVE_DISP_RIGHT 0x1C 120 #define LCD_FUNCTION_4BIT_1LINE 0x20 121 #define LCD_FUNCTION_4BIT_2LINES 0x28 122 #define LCD_FUNCTION_8BIT_1LINE 0x30 123 #define LCD_FUNCTION_8BIT_2LINES 0x38 125 #define LCD_START_LINE1 0x00 126 #define LCD_START_LINE2 0x40 127 #define LCD_START_LINE3 0x10 128 #define LCD_START_LINE4 0x50 130 #define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) ) 132 #define LCD_STROBE() (sbi(LCD_E_PORT, LCD_E_PIN), cbi(LCD_E_PORT, LCD_E_PIN)) 133 #define LCD_DATA_BITS (_BV(LCD_DATA_D7_PIN) | _BV(LCD_DATA_D6_PIN) | _BV(LCD_DATA_D5_PIN) | _BV(LCD_DATA_D4_PIN)) 135 #define TIME_S1_MS ( 1*(F_CPU/4000) ) 136 #define delay_us(us) delay_short( ((TIME_S1_MS*(us))/1000) ) 141 __asm__
volatile (
"cp %A0,__zero_reg__ \n\t" \
142 "cpc %B0,__zero_reg__ \n\t" \
143 "breq L_EXIT_%= \n\t" \
149 :
"w" (number_of_loops) \
162 if (c & 0x80) dataBits |= _BV(LCD_DATA_D7_PIN);
163 if (c & 0x40) dataBits |= _BV(LCD_DATA_D6_PIN);
164 if (c & 0x20) dataBits |= _BV(LCD_DATA_D5_PIN);
165 if (c & 0x10) dataBits |= _BV(LCD_DATA_D4_PIN);
166 LCD_DATA_PORT = dataBits;
170 if (c & 0x08) dataBits |= _BV(LCD_DATA_D7_PIN);
171 if (c & 0x04) dataBits |= _BV(LCD_DATA_D6_PIN);
172 if (c & 0x02) dataBits |= _BV(LCD_DATA_D5_PIN);
173 if (c & 0x01) dataBits |= _BV(LCD_DATA_D4_PIN);
174 LCD_DATA_PORT = dataBits;
181 cbi(LCD_RS_PORT, LCD_RS_PIN);
188 sbi(LCD_RS_PORT, LCD_RS_PIN);
195 sbi(LCD_RS_PORT, LCD_RS_PIN);
197 for (c = pgm_read_byte(s); c; ++s, c = pgm_read_byte(s))
206 sbi(LCD_RS_PORT, LCD_RS_PIN);
212 cbi(LCD_RS_PORT, LCD_RS_PIN);
237 memset(outstr,
' ', 11);
239 len = strlen(utoa(value, outstr + 5, 10));
246 sbi(LCD_RS_DDR, LCD_RS_PIN);
247 sbi(LCD_E_DDR, LCD_E_PIN);
249 cbi(LCD_RS_PORT, LCD_RS_PIN);
250 cbi(LCD_E_PORT, LCD_E_PIN);
256 sbi(LCD_DATA_PORT, LCD_DATA_D4_PIN);
257 sbi(LCD_DATA_PORT, LCD_DATA_D5_PIN);
270 cbi(LCD_DATA_PORT, LCD_DATA_D4_PIN);
#define LCD_START_LINE3
DDRAM address of first char of line 3.
#define LCD_DDRAM
DB7: set DD RAM address.
#define LCD_START_LINE1
DDRAM address of first char of line 1.
void lcd_puts(const char *s)
Write a string of characters to the LCD.
#define LCD_START_LINE4
DDRAM address of first char of line 4.
void lcd_clear(void)
Clear and home the LCD.
void lcd_goto(uint8_t x, uint8_t y)
Go to the specified position.
static void delay_short(uint16_t number_of_loops)
lcdDisplayMode_t
display on/off, cursor on/off, blinking char at cursor position
void lcd_puts_P(const char *s)
Write a string from progmem of chars to the LCD.
void lcd_word(uint16_t value, uint8_t width)
Write numeric value to the LCD.
static void lcd_write(uint8_t c)
Write a byte to the LCD in 4 bit mode.
#define LCD_ENTRY_INC_
display shift off, inc cursor move dir
#define LCD_START_LINE2
DDRAM address of first char of line 2.
LCD interface header file.
System wide Definitions for FREMO Clock.
void lcd_init(lcdDisplayMode_t dispAttr)
Initialize the LCD - call before anything else.
#define LCD_FUNCTION_4BIT_2LINES
4-bit interface, dual line, 5x7 dots
void lcd_putc(char c)
Write a character to the LCD.
void lcd_clrxy(uint8_t x, uint8_t y, uint8_t count)
Clear count characters starting at position (x,y).