Exemplo n.º 1
0
void st7565r_set_column(unsigned char column)
{
    /* Make sure the address is 7 bits. */
	column &= 0x7F;
	st7565r_write_command(ST7565R_CMD_COLUMN_SET_MSB(column >> 4));
	st7565r_write_command(ST7565R_CMD_COLUMN_SET_LSB(column & 0x0F));
}
Exemplo n.º 2
0
void st7565r_init(gpio_pin_t data, gpio_pin_t clk, gpio_pin_t chip_select, gpio_pin_t a0, gpio_pin_t reset)
{
    LCD.data          = data;
    LCD.clk           = clk;
    LCD.chip_select   = chip_select;
    LCD.a0            = a0;
    LCD.reset         = reset;

    gpio_set_pin(LCD.clk);
    gpio_set_pin(LCD.chip_select);
    gpio_set_pin(LCD.reset);

    st7564r_hard_reset();

    st7565r_write_command(ST7565R_CMD_ADC_NORMAL);
    st7565r_write_command(ST7565R_CMD_DISPLAY_NORMAL);
    st7565r_write_command(ST7565R_CMD_REVERSE_SCAN_DIRECTION);
    st7565r_write_command(ST7565R_CMD_LCD_BIAS_1_DIV_6_DUTY33);
    st7565r_write_command(ST7565R_CMD_POWER_CTRL_ALL_ON);
    st7565r_write_command(ST7565R_CMD_BOOSTER_RATIO_SET);
    st7565r_write_command(ST7565R_CMD_BOOSTER_RATIO_2X_3X_4X);
    st7565r_write_command(ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_1);
    st7565r_write_command(ST7565R_CMD_DISPLAY_ON);
}
/**
 * \brief Initialize the LCD controller
 *
 * Call this function to initialize the hardware interface and the LCD
 * controller. When initialization is done the display is turned on and ready
 * to receive data.
 */
void st7565r_init(void)
{
	// Do a hard reset of the LCD display controller
	st7565r_hard_reset();

	// Initialize the interface
	st7565r_interface_init();

	// Set the A0 pin to the default state (command)
	ioport_set_pin_low(ST7565R_A0_PIN);

	// The column address is set to increasing
	st7565r_write_command(ST7565R_CMD_ADC_NORMAL);

	// Non-inverted display
	st7565r_display_invert_disable();

	// The common mode scan direction is reversed COM31->COM0
	st7565r_write_command(ST7565R_CMD_REVERSE_SCAN_DIRECTION);

	// Set the voltage bias ratio to 1/6
	st7565r_write_command(ST7565R_CMD_LCD_BIAS_1_DIV_6_DUTY33);

	// Set booster circuit, voltage regulator and voltage follower all to on
	st7565r_write_command(ST7565R_CMD_POWER_CTRL_ALL_ON);

	// Set the booster ratio to 2X,3X,4X
	st7565r_write_command(ST7565R_CMD_BOOSTER_RATIO_SET);
	st7565r_write_command(ST7565R_CMD_BOOSTER_RATIO_2X_3X_4X);

	// Set voltage resistor ratio to 1
	st7565r_write_command(ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_1);

	/* Set contrast to min value, no need to check return value as the contrast
	is set to the defined min*/
	st7565r_set_contrast(ST7565R_DISPLAY_CONTRAST_MIN);

	// Turn on the display
	st7565r_display_on();
}
Exemplo n.º 4
0
void st7565r_set_page(unsigned char page)
{
    /* Make sure that the address is 4 bits (only 8 pages). */
    page &= 0x0F;
    st7565r_write_command(ST7565R_CMD_PAGE_SET(page));
}