/** 
 * @brief Initializes the screen so we can use it.
 * @param selected_GPIOs[] An initialized array of gpioID. 
 * @param selectedPins[] The user defined pins.
 **/
void initialize_Screen(struct gpioID enabled_gpio[],int selectedPins[])
{
	int nbr_selectedPins=6;
	const char *pinDescription[] = {"","","","","",""};
	unsigned int data_to_write;

	initialize_each_enabled_gpio(enabled_gpio,selectedPins,nbr_selectedPins);
	if (DISPLAY_DATA_ON_SCREEN) display_each_enabled_gpio(enabled_gpio,nbr_selectedPins,pinDescription);

	//E RS DB4 DB5 DB6 DB7
	//0 0  1   1   0   0 	(base 2) which equals 12 (base 10)
    data_to_write=12; 
	turn_ON_OFF_pins(enabled_gpio,data_to_write,nbr_selectedPins,MAX_DELAY,pinDescription);
	pulsePin(enabled_gpio,data_to_write,nbr_selectedPins,DISPLAY_DATA_ON_SCREEN, pinDescription, 5, MAX_DELAY);
  	sleep(MAX_DELAY);

	//E RS DB4 DB5 DB6 DB7
	//0 0  0   1   0   0 	(base 2) which equals 4 (base 10) : 4 bit mode
    data_to_write=4; 
	turn_ON_OFF_pins(enabled_gpio,data_to_write,nbr_selectedPins,MAX_DELAY,pinDescription);
	pulsePin(enabled_gpio,data_to_write,nbr_selectedPins,DISPLAY_DATA_ON_SCREEN, pinDescription, 5, MAX_DELAY);
  	sleep(MAX_DELAY);

	//enable display part 1 - Display ON/OFF & Cursor
	//E RS DB4 DB5 DB6 DB7 = 000000 (2) == 0 (10)
    data_to_write=0; 
	turn_ON_OFF_pins(enabled_gpio,data_to_write,nbr_selectedPins,MAX_DELAY,pinDescription);
	pulsePin(enabled_gpio,data_to_write,nbr_selectedPins,DISPLAY_DATA_ON_SCREEN, pinDescription, 5, MAX_DELAY);
  	sleep(MAX_DELAY);

	//enable display part 2 - Display ON/OFF & Cursor
	//E RS DB4 DB5 DB6 DB7 = 000011 (2) == 3 (10)
    data_to_write=3; 
	turn_ON_OFF_pins(enabled_gpio,data_to_write,nbr_selectedPins,MAX_DELAY,pinDescription);
	pulsePin(enabled_gpio,data_to_write,nbr_selectedPins,DISPLAY_DATA_ON_SCREEN, pinDescription, 5, MAX_DELAY);
  	sleep(MAX_DELAY);
  	
  	//two line mode 5x7 part 1 
	//E RS DB4 DB5 DB6 DB7 = 000100 (2) == 4  (10)
    data_to_write=4; 
	turn_ON_OFF_pins(enabled_gpio,data_to_write,nbr_selectedPins,MAX_DELAY,pinDescription);
	pulsePin(enabled_gpio,data_to_write,nbr_selectedPins,DISPLAY_DATA_ON_SCREEN, pinDescription, 5, MAX_DELAY);
  	sleep(MAX_DELAY);

  	//two line mode 5x7 part 2 (the 0 next to the 1 specifies the 5x7)
	//E RS DB4 DB5 DB6 DB7 = 000001 (2) == 1 (10)
    data_to_write=1; 
	turn_ON_OFF_pins(enabled_gpio,data_to_write,nbr_selectedPins,MAX_DELAY,pinDescription);
	pulsePin(enabled_gpio,data_to_write,nbr_selectedPins,DISPLAY_DATA_ON_SCREEN, pinDescription, 5, MAX_DELAY);
  	sleep(MAX_DELAY);

}
Exemple #2
0
/** 
 * @brief Initializes the screen so we can use it.
 * @param selected_GPIOs[] An initialized array of gpioID. 
 * @param selectedPins[] The user defined pins.
 **/
void initialize_Screen(struct gpioID enabled_gpio[],int selectedPins[])
{
   int nbr_selectedPins=6;
   unsigned int data_to_write;
   
   initialize_each_enabled_gpio(enabled_gpio,selectedPins,nbr_selectedPins);
#if CONFIG_DEBUG_LCD
   display_each_enabled_gpio(enabled_gpio,nbr_selectedPins);
#endif

   /* INIT (cf wiki) */
   usleep (20000); // 15000
   execute_command(enabled_gpio, 0x30); 
   usleep (10000); //  4100
   execute_command(enabled_gpio, 0x30); 
   usleep (1000);  //   100
   execute_command(enabled_gpio, 0x30); 
   usleep ( 1000);

   // 4-bit 
   //execute_command(enabled_gpio, 0x20); 
   turn_ON_OFF_pins( enabled_gpio, 0x2, 6);
   pulsePin(         enabled_gpio, 0x2, 6, 5, 0.05);
   usleep ( 1000);

   /* FUNCTION SET : 4-bit, 2-line, 5x7,  */
   execute_command(enabled_gpio, 0x28);

   /* DISPLAY ON/OFF CONTROL : display ON, cursor OFF, blink OFF */
   execute_command(enabled_gpio, 0x0c); 

   /* CLEAR DISPLAY : clear display and return to home position */
   execute_command(enabled_gpio, 0x01); 
   
   /* ENTRY MODE SET : set direction to increment */
   execute_command(enabled_gpio, 0x06); 

   /* RETURN HOME : return to home position */
//  execute_command(enabled_gpio, 0x02); 

   /* CURSOR & DISPLAY SHIFT : cursor move, right direction */
//  execute_command(enabled_gpio, 0x14); 
   
}