bool nrf6350_lcd_init(void) { if (!twi_master_init()) return false; // Sometimes the first command doesn't get through, so we'll try // sending non-important command first and don't care if it fails. (void)nrf6350_lcd_clear(); if (!nrf6350_lcd_set_instruction(0x38)) // Function set return false; if (!nrf6350_lcd_set_instruction(0x39)) // Choose two-line mode return false; if (!nrf6350_lcd_set_instruction(0x14)) // Internal OSC frequency return false; if (!nrf6350_lcd_set_contrast(LCD_CONTRAST_HIGH)) // Contrast set (low byte) return false; if (!nrf6350_lcd_set_instruction(0x5F)) // Power/ICON control/ return false; if (!nrf6350_lcd_set_instruction(0x6A)) // Follower control return false; nrf_delay_us(200000); // Need to wait 200ms here according to datasheet if (!nrf6350_lcd_on()) // Display ON return false; if (!nrf6350_lcd_clear()) // Clear display return false; return nrf6350_lcd_set_instruction(0x06); // Entry mode set }
/* * Display text of the correct section with correct offset on the display */ static void display_text(void) { if(!nrf6350_lcd_clear()) { show_error(); } if(in_menu) { if(!nrf6350_lcd_write_string(&help_menu[current_menu_pos][current_scroll_pos], MAX_CHARACTERS_PER_LINE, LCD_UPPER_LINE, 0)) { show_error(); } } else { if(p_variables[current_menu_pos] != 0) { char buffer[3]; sprintf(buffer, "%lu", (int32_t)(*(uint8_t *)p_variables[current_menu_pos])); if(!nrf6350_lcd_write_string(buffer, 3, LCD_UPPER_LINE, 7)) { show_error(); } } } }
bool nrf6350_lcd_init(void) { if (!twi_master_init()) return false; if (!nrf6350_lcd_set_instruction(0x38)) // Function set return false; if (!nrf6350_lcd_set_instruction(0x39)) // Choose two-line mode return false; if (!nrf6350_lcd_set_instruction(0x14)) // Internal OSC frequency return false; if (!nrf6350_lcd_set_contrast(LCD_CONTRAST_HIGH)) // Contrast set (low byte) return false; if (!nrf6350_lcd_set_instruction(0x5F)) // Power/ICON control/ return false; if (!nrf6350_lcd_set_instruction(0x6A)) // Follower control return false; nrf_delay_us(200000); // Need to wait 200ms here according to datasheet if (!nrf6350_lcd_on()) // Display ON return false; if (!nrf6350_lcd_clear()) // Clear display return false; return nrf6350_lcd_set_instruction(0x06); // Entry mode set }