void lcd_HD44780_print_char(char data) { if (data == '\n') { lcd_HD44780_set_position(++currentRow, 0); } else { lcd_2x16_write_data(data); } }
void lcd_HD44780_init(Logging *sharedLogger) { logger = sharedLogger; addConsoleAction("lcdinfo", lcdInfo); if (engineConfiguration->displayMode > DM_HD44780_OVER_PCF8574) { firmwareError("Unexpected displayMode %d", engineConfiguration->displayMode); return; } printMsg(logger, "lcd_HD44780_init %d", engineConfiguration->displayMode); if (engineConfiguration->displayMode == DM_HD44780) { // initialize hardware lines mySetPadMode2("lcd RS", boardConfiguration->HD44780_rs, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd E", boardConfiguration->HD44780_e, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB4", boardConfiguration->HD44780_db4, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB6", boardConfiguration->HD44780_db5, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB7", boardConfiguration->HD44780_db6, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode2("lcd DB8", boardConfiguration->HD44780_db7, PAL_MODE_OUTPUT_PUSHPULL); // and zero values palWritePad(getHwPort(boardConfiguration->HD44780_rs), getHwPin(boardConfiguration->HD44780_rs), 0); palWritePad(getHwPort(boardConfiguration->HD44780_e), getHwPin(boardConfiguration->HD44780_e), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db4), getHwPin(boardConfiguration->HD44780_db4), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db5), getHwPin(boardConfiguration->HD44780_db5), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db6), getHwPin(boardConfiguration->HD44780_db6), 0); palWritePad(getHwPort(boardConfiguration->HD44780_db7), getHwPin(boardConfiguration->HD44780_db7), 0); } chThdSleepMilliseconds(20); // LCD needs some time to wake up lcd_HD44780_write(LCD_HD44780_RESET); // reset 1x chThdSleepMilliseconds(1); lcd_HD44780_write(LCD_HD44780_RESET); // reset 2x lcd_HD44780_write(LCD_HD44780_RESET); // reset 3x lcd_HD44780_write(LCD_HD44780_4_BIT_BUS); // 4 bit, 2 line chThdSleepMicroseconds(40); lcd_HD44780_write(LCD_HD44780_4_BIT_BUS); // 4 bit, 2 line lcd_HD44780_write(0x80); chThdSleepMicroseconds(40); lcd_HD44780_write_command(0x08); // display and cursor control chThdSleepMicroseconds(40); lcd_HD44780_write_command(LCD_HD44780_DISPLAY_CLEAR); chThdSleepMilliseconds(2); lcd_HD44780_write_command(LCD_HD44780_SHIFT_CURSOR_RIGHT); chThdSleepMilliseconds(2); lcd_HD44780_write_command(LCD_HD44780_DISPLAY_ON); lcd_HD44780_set_position(0, 0); printMsg(logger, "lcd_HD44780_init() done"); }
void updateHD44780lcd(void) { lcd_HD44780_set_position(0, 9); /** * this would blink so that we know the LCD is alive */ if (getTimeNowSeconds() % 2 == 0) { lcd_HD44780_print_char('R'); } else { lcd_HD44780_print_char(' '); } lcd_HD44780_set_position(0, 10); char * ptr = itoa10(buffer, getRpm()); ptr[0] = 0; int len = ptr - buffer; for (int i = 0; i < 6 - len; i++) { lcd_HD44780_print_char(' '); } lcd_HD44780_print_string(buffer); if (hasFirmwareError()) { memcpy(buffer, getFirmwareError(), LCD_WIDTH); buffer[LCD_WIDTH] = 0; lcd_HD44780_set_position(1, 0); lcd_HD44780_print_string(buffer); return; } lcd_HD44780_set_position(1, 0); memset(buffer, ' ', LCD_WIDTH); memcpy(buffer, getWarninig(), LCD_WIDTH); buffer[LCD_WIDTH] = 0; lcd_HD44780_print_string(buffer); if (engineConfiguration->HD44780height < 3) { return; } int index = (getTimeNowSeconds() / 2) % (NUMBER_OF_DIFFERENT_LINES / 2); prepareCurrentSecondLine(index); buffer[LCD_WIDTH] = 0; lcd_HD44780_set_position(2, 0); lcd_HD44780_print_string(buffer); prepareCurrentSecondLine(index + NUMBER_OF_DIFFERENT_LINES / 2); buffer[LCD_WIDTH] = 0; lcd_HD44780_set_position(3, 0); lcd_HD44780_print_string(buffer); #if EFI_PROD_CODE dateToString(dateBuffer); lcd_HD44780_set_position(1, 0); lcd_HD44780_print_string(dateBuffer); #endif /* EFI_PROD_CODE */ }
void lcd_HD44780_init(void) { initLogging(&logger, "HD44780 driver"); addConsoleAction("lcdinfo", lcdInfo); if (engineConfiguration->displayMode == DM_HD44780) { mySetPadMode("lcd RS", HD44780_PORT_RS, HD44780_PIN_RS, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd E", HD44780_PORT_E, HD44780_PIN_E, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB4", HD44780_PORT_DB4, HD44780_PIN_DB4, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB6", HD44780_PORT_DB5, HD44780_PIN_DB5, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB7", HD44780_PORT_DB6, HD44780_PIN_DB6, PAL_MODE_OUTPUT_PUSHPULL); mySetPadMode("lcd DB8", HD44780_PORT_DB7, HD44780_PIN_DB7, PAL_MODE_OUTPUT_PUSHPULL); palWritePad(HD44780_PORT_RS, HD44780_PIN_RS, 0); palWritePad(HD44780_PORT_E, HD44780_PIN_E, 0); palWritePad(HD44780_PORT_DB4, HD44780_PIN_DB4, 0); palWritePad(HD44780_PORT_DB5, HD44780_PIN_DB5, 0); palWritePad(HD44780_PORT_DB6, HD44780_PIN_DB6, 0); palWritePad(HD44780_PORT_DB7, HD44780_PIN_DB7, 0); } // LCD needs some time to wake up chThdSleepMilliseconds(50); lcd_HD44780_write(LCD_2X16_RESET); chThdSleepMilliseconds(1); lcd_HD44780_write(0x30); lcd_HD44780_write(LCD_2X16_4_BIT_BUS); // 4 bit, 2 line chThdSleepMicroseconds(40); lcd_HD44780_write(LCD_2X16_4_BIT_BUS); // 4 bit, 2 line lcd_HD44780_write(0x80); chThdSleepMicroseconds(40); lcd_HD44780_write(0x00); // display and cursor control lcd_HD44780_write(0xC0); chThdSleepMicroseconds(40); lcd_HD44780_write(0x00); // display clear lcd_HD44780_write(0x01); chThdSleepMilliseconds(2); lcd_HD44780_write(0x00); // entry mode set lcd_HD44780_write(0x60); lcd_HD44780_set_position(0, 0); lcd_HD44780_print_string("rusefi here\n"); lcd_HD44780_print_string(__DATE__); }
void lcdShowFatalMessage(char *message) { BUSY_WAIT_DELAY = TRUE; lcd_HD44780_set_position(0, 0); lcd_HD44780_print_string("fatal\n"); lcd_HD44780_print_string(message); }
void updateHD44780lcd(Engine *engine) { MenuItem *p = tree.topVisible; int screenY = 0; for (; screenY < tree.linesCount && p != NULL; screenY++) { lcd_HD44780_set_position(screenY, 0); char firstChar; if (p == tree.current) { if (p->callback != NULL) { firstChar = '!'; } else { firstChar = p->firstChild == NULL ? '*' : '>'; } } else { firstChar = ' '; } lcd_HD44780_print_char(firstChar); if (p->lcdLine == LL_STRING) { lcd_HD44780_print_string(p->text); } else { showLine(p->lcdLine, screenY); } fillWithSpaces(); p = p->next; } for (; screenY < tree.linesCount; screenY++) { lcd_HD44780_set_position(screenY, 0); fillWithSpaces(); } memcpy(buffer, getWarninig(), engineConfiguration->HD44780width); buffer[engineConfiguration->HD44780width] = 0; lcd_HD44780_set_position(engineConfiguration->HD44780height - 1, 0); lcd_HD44780_print_string(buffer); fillWithSpaces(); // // lcd_HD44780_set_position(0, 9); // /** // * this would blink so that we know the LCD is alive // */ // if (isEven) { // lcd_HD44780_print_char('R'); // } else { // lcd_HD44780_print_char(' '); // } // lcd_HD44780_set_position(0, 10); // // char * ptr = itoa10(buffer, getRpmE(engine)); // ptr[0] = 0; // int len = ptr - buffer; // for (int i = 0; i < 6 - len; i++) { // lcd_HD44780_print_char(' '); // } // lcd_HD44780_print_string(buffer); // // if (hasFirmwareError()) { // memcpy(buffer, getFirmwareError(), LCD_WIDTH); // buffer[LCD_WIDTH] = 0; // lcd_HD44780_set_position(1, 0); // lcd_HD44780_print_string(buffer); // return; // } // // lcd_HD44780_set_position(1, 0); // memset(buffer, ' ', LCD_WIDTH); // memcpy(buffer, getWarninig(), LCD_WIDTH); // buffer[LCD_WIDTH] = 0; // lcd_HD44780_print_string(buffer); // // if (engineConfiguration->HD44780height < 3) { // return; // } // // int index = (getTimeNowSeconds() / 2) % (NUMBER_OF_DIFFERENT_LINES / 2); // // prepareCurrentSecondLine(engine, index); // buffer[LCD_WIDTH] = 0; // lcd_HD44780_set_position(2, 0); // lcd_HD44780_print_string(buffer); // // prepareCurrentSecondLine(engine, index + NUMBER_OF_DIFFERENT_LINES / 2); // buffer[LCD_WIDTH] = 0; // lcd_HD44780_set_position(3, 0); // lcd_HD44780_print_string(buffer); // //#if EFI_PROD_CODE // dateToString(dateBuffer); // lcd_HD44780_set_position(1, 0); // lcd_HD44780_print_string(dateBuffer); //#endif /* EFI_PROD_CODE */ }