int main() { //specifies the pins that will be used int selectedPins[]= {P8_14,P8_12,P8_11,P8_5,P8_4,P8_3}; const char *pinDescription[] = {"DB7","DB6","DB5","DB4","RS","E"}; int i; struct gpioID enabled_gpio[6]; //initialized the screen initialize_Screen(enabled_gpio,selectedPins); //clear the screen from everything that may be in there for (i=65; i<122; i++) { //type every single character characters clear_Screen(enabled_gpio); charToScreen((char)i,enabled_gpio); sleep(1); } //this instruction must be added or the LCD may not work as expected next //time... unless you reboot it. terminate_Screen(enabled_gpio,selectedPins); }
/** * @brief Prints a string to the screen. * @param full_string String that needs to be printed on the LCD * @param enabled_gpio[] Initialized array of gpioID. **/ void stringToScreen(const char *full_string, struct gpioID enabled_gpio[]) { int i; int length = strlen(full_string); for (i=0; i<length; i++) { charToScreen(full_string[i],enabled_gpio); } }
/** * @brief Prints a string to the screen. * @param full_string String that needs to be printed on the LCD * @param selected_GPIOs[] Initialized array of gpioID. **/ void stringToScreen(const char *full_string, int line, struct gpioID enabled_gpio[]) { int i; int length = strlen(full_string); /* set DDRAM address to first line offset : 0x00 */ if (1 == line) { execute_command(enabled_gpio, 0x80); } /* set DDRAM address to second line offset : 0x28 */ if (2 == line) { execute_command(enabled_gpio, 0xa8); } for (i=0; i<length; i++) { charToScreen(full_string[i],enabled_gpio); //printf("%c\n",full_string[i]); } }