[OurDev开源充电器]1602 LCD驱动程序
在 ouravr 上有很多 HD44780 的驱动程序,我再上传一份,不知可否用到?这个程序是网上的开源程序,我在电路上做了实验,可以良好运行,在 BSD/Windows 里都可以正常编译。
这个驱动库大概有这些函数:
/**
*@name Functions
*/
/**
@brief Initialize display and select type of cursor
@param dispAttr \b LCD_DISP_OFF display off\n
\b LCD_DISP_ON display on, cursor off\n
\b LCD_DISP_ON_CURSOR display on, cursor on\n
\b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing
@returnnone
*/
extern void lcd_init(uint8_t dispAttr);
/**
@brief Clear display and set cursor to home position
@param void
@return none
*/
extern void lcd_clrscr(void);
/**
@brief Set cursor to home position
@param void
@return none
*/
extern void lcd_home(void);
/**
@brief Set cursor to specified position
@param x horizontal position\n (0: left most position)
@param y vertical position\n (0: first line)
@return none
*/
extern void lcd_gotoxy(uint8_t x, uint8_t y);
/**
@brief Display character at current cursor position
@param c character to be displayed
@return none
*/
extern void lcd_putc(char c);
/**
@brief Display string without auto linefeed
@param s string to be displayed
@return none
*/
extern void lcd_puts(const char *s);
/**
@brief Display string from program memory without auto linefeed
@param s string from program memory be be displayed
@return none
@see lcd_puts_P
*/
extern void lcd_puts_p(const char *progmem_s);
/**
@brief Send LCD controller instruction command
@param cmd instruction to send to LCD controller, see HD44780 data sheet
@return none
*/
extern void lcd_command(uint8_t cmd);
// mtmt new function:
#ifdef LCD_SCROLL_FUNCTION
/**
@brief Scroll LCD up
@param none
@return none
*/
extern void lcd_scrollup(void);
#endif
// mtmt exported for debugging
extern uint8_t lcd_waitbusy(void);
点击此处下载ourdev_183454.rar(文件大小:9K)
压缩包内是 connect.txt, lcd.h 和 lcd.c
压缩包里支持的 LCD 是4x20,如果要让它支持16x2,需要对 lcd.h 进行设置,文件中有详细说明。 看上去很不错,值得借鉴 已阅!谢谢 能将电路图也上传上来吗? 谢谢。先置COOL。 (COOL需要有电路图) 程序不是我写的,阿莫不能乱加酷,要保证质量啊。
电路图在这里已经定义了:
#define LCD_PORT PORTB /**< port for the LCD lines */
#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0*/
#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1*/
#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2*/
#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3*/
#define LCD_RS_PORT LCD_PORT /**< port for RS line */
#define LCD_RS_PIN 0 /**< pinfor RS line */
#define LCD_RW_PORT LCD_PORT /**< port for RW line */
#define LCD_RW_PIN 1 /**< pinfor RW line */
#define LCD_E_PORT LCD_PORT /**< port for Enable line */
#define LCD_E_PIN 2 /**< pinfor Enable line */
我本来是学机械的,喜欢看图:)
http://cache.amobbs.com/bbs_upload782111/files_8/ourdev_184065.png 不错 谢谢、 回复【楼主位】atommann
-----------------------------------------------------------------------
标记
页:
[1]