Ejemplo n.º 1
0
void
hd44780_cursor(int x, int y, int cursor, int blink)
{
	uint8_t p = x + (y ? 40 : 0);
//	printf("{%d,%d,%d,%d -> %d}",x,y,cursor,blink,p);
	hd44780_cmd(HD44780_CMD_DC(1,cursor,blink));
	hd44780_cmd(HD44780_CMD_DDRAM(p));
}
Ejemplo n.º 2
0
void hd44780_init() {
	
	data[0] = 0x00 | backlight;
	data[1] = 0x00 | backlight;

	// Reset all
	I2C_Master_BufferWrite(I2C1, data, 1, Polling, hd44780_address << 1);

	hd44780_cmd(0x03);
	delay_us(5000);
	hd44780_cmd(0x03);
	delay_us(100);
	hd44780_cmd(0x02);
	delay_us(200);

	hd44780_cmd(0x28); // 4 bit mode
	hd44780_cmd(0x06); // set direction of cursor to right
	hd44780_cmd(0x01); // clear display, go to 0x0
	hd44780_cmd(0x0E); // turn on display, set solid cursor
	hd44780_cmd(0x0C); // turn on display, set invisiblecursor

	hd44780_cgram_write(0, (u8[]){0,10,31,31,14,4,0,0});
	hd44780_cgram_write(1, (u8[]){0,10,21,17,10,4,0,0});

	hd44780_cmd(0x01); // clear display, go to 0x0

}
Ejemplo n.º 3
0
void
hd44780_reset()
{
	/* force 8-bit interface: */
	hd44780_cmd(0x33); /* special HD44780_CMD_FUN, two nibbles 0x03 */
	hd44780_cmd(0x33); /* special HD44780_CMD_FUN, two nibbles 0x03 */
	hd44780_cmd(HD44780_CMD_FUN(1,1,0)); /* 8bit, 2line, 5x7 font */

	hd44780_cmd(HD44780_CMD_MOD(1,0)); /* cursor moves left to right */
	hd44780_cmd(HD44780_CMD_DC(1,0,0)); /* display on, cursor off, blink off */
	hd44780_clear();
}
Ejemplo n.º 4
0
void hd44780_go_to_line(u8 line) {
    switch(line) {
        case 0:
            hd44780_cmd(0x80);
            break;
        case 1:
            hd44780_cmd(0xC0);
            break;
        case 2:
            hd44780_cmd(0x94);
            break;
        case 3:
            hd44780_cmd(0xD4);
            break;
        default:
            break;
    }
}
Ejemplo n.º 5
0
void hd44780_cgram_write(u8 pos, u8 data_[8]) {
    if (pos > 7) {
        return;
    }
    pos = 64 + pos * 8;
    hd44780_cmd(pos);
    u8 i;
    for (i = 0; i < 8; ++i) {
    	hd44780_send(data_[i], true);
    }
}
Ejemplo n.º 6
0
void hd44780_init(TIM_TypeDef *t) {
    timer = t;
    // Setup clock
    setup_delay_timer(timer);

    hd44780_data[0] = 0x00 | backlight;
    hd44780_data[1] = 0x00 | backlight;

    // Init I2C
    I2C_LowLevel_Init(I2C1);

    // Reset all
    I2C_Master_BufferWrite(I2C1, hd44780_data, 1, Polling, hd44780_address << 1);

    hd44780_cmd(0x03);
    delay_us(timer, 5000);
    hd44780_cmd(0x03);
    delay_us(timer, 100);
    hd44780_cmd(HD44780_MOVE_TO_HOME);
    delay_us(timer, 200);

    hd44780_cmd(0x28); // 4 bit mode
    hd44780_cmd(0x06); // set direction of cursor to right
    hd44780_cmd(HD44780_DISPLAY_ERASE); // clear display, go to 0x0
//    hd44780_cmd(0x0E); // turn on display, set solid cursor
    hd44780_cmd(HD44780_DISPLAY_SHOW); // turn on display, set invisiblecursor

//    u8 arr[] = {0,10,31,31,14,4,0,0};
//    u8 arr2[]= {0,10,21,17,10,4,0,0};

//    hd44780_cgram_write(0, arr);
//    hd44780_cgram_write(1, arr2);

    hd44780_cmd(0x01); // clear display, go to 0x0

//    hd44780_backlight(initial_backlight);
//    hd44780_print("Linia 0");
//    hd44780_go_to_line(1);
//    hd44780_print("Linia 1");
//    hd44780_go_to_line(2);
//    hd44780_print("Linia 2");
//    hd44780_go_to_line(3);
//    hd44780_print("Linia 3");

//    hd44780_char(0);
//    hd44780_char(1);
}
Ejemplo n.º 7
0
void hd44780_init(struct dev_hd44780_ctx *a_disp) {
	
	uint8_t x = HD44780_DATALINES;

	GPIO_CONFIGURE_AS_OUTPUT(&a_disp->rs);
	GPIO_CONFIGURE_AS_OUTPUT(&a_disp->e);

#if HD44780_USE_RW_LINE == 1
	GPIO_CONFIGURE_AS_OUTPUT(&a_disp->rw);
	GPIO_SET_LOW(&a_disp->rw);
#endif

	// set control lines low
	GPIO_SET_LOW(&a_disp->rs);
	GPIO_SET_LOW(&a_disp->e);

	// set all data lines high
	while (x--) {
		GPIO_CONFIGURE_AS_OUTPUT(&a_disp->data[x]);
		GPIO_SET_HIGH(&a_disp->data[x]);
	}

	// wait for the display
	_delay_ms(HD44780_RESET_DELAY_MS);

#if HD44780_8BIT_MODE == 1
	GPIO_SET_LOW(&a_disp->data[7]);
	GPIO_SET_LOW(&a_disp->data[6]);
#else
	GPIO_SET_LOW(&a_disp->data[3]);
	GPIO_SET_LOW(&a_disp->data[2]);
#endif

	_hd44780_data_latch(a_disp);
	_delay_ms(5);

	_hd44780_data_latch(a_disp);
	_delay_us(100);

#if HD44780_8BIT_MODE == 0
	GPIO_SET_LOW(&a_disp->data[0]);
#endif

	_hd44780_data_latch(a_disp);

	// wait for a while before sending the "real" commands
	_delay_us(10);

	// set font and display lines
#if HD44780_8BIT_MODE == 1
	hd44780_cmd(a_disp, HD44780_CMD_FUNCTION_SET(1, (a_disp->lines >= 2), a_disp->font));
#else
	hd44780_cmd(a_disp, HD44780_CMD_FUNCTION_SET(0, (a_disp->lines >= 2), a_disp->font));
#endif

	// display on, cursor off, blink off
	hd44780_cmd(a_disp, HD44780_CMD_DISPLAY_CONTROL(1, 0, 0));

	// clear the screen
	hd44780_clrscr(a_disp);

	// set entry mode
	hd44780_cmd(a_disp, HD44780_CMD_ENTRY_MODE(1, 0));
}
Ejemplo n.º 8
0
void hd44780_go_to(u8 row, u8 col) {
    hd44780_go_to_line(row);
    u8 i = 0;
    while (i++ < col)
        hd44780_cmd(HD44780_MOVE_CURSOR_RIGHT);
}
Ejemplo n.º 9
0
void hd44780_go_to(u8 row, u8 col) {
    hd44780_go_to_line(row);
    u8 i = 0;
    while (i++ < col)
        hd44780_cmd(0x14);
}
Ejemplo n.º 10
0
// Added simple function
void hd44780_clear(){
	
	hd44780_cmd(0x01); // clear display, go to 0x0
}
Ejemplo n.º 11
0
void
hd44780_cgram(uint8_t i){
	hd44780_cmd(HD44780_CMD_CGRAM(i));
}
Ejemplo n.º 12
0
void
hd44780_home()
{
	hd44780_cmd(HD44780_CMD_HOME);
}
Ejemplo n.º 13
0
void
hd44780_clear()
{
	hd44780_cmd(HD44780_CMD_CLR);
	hd44780_cmd(HD44780_CMD_HOME);
}