/** * \brief Initialize ST7565R controller and LCD display. * It will also write the graphic controller RAM to all zeroes. * * \note This function will clear the contents of the display. */ void gfx_mono_st7565r_init(void) { uint8_t page; uint8_t column; #ifdef CONFIG_ST7565R_FRAMEBUFFER gfx_mono_set_framebuffer(framebuffer); #endif /* Initialize the low-level display controller. */ st7565r_init(); /* Set display to output data from line 0 */ st7565r_set_display_start_line_address(0); /* Clear the contents of the display. * If using a framebuffer (SPI interface) it will both clear the * controller memory and the framebuffer. */ for (page = 0; page < GFX_MONO_LCD_PAGES; page++) { for (column = 0; column < GFX_MONO_LCD_WIDTH; column++) { gfx_mono_put_byte(page, column, 0x00); } } }
int main(void) { //! the page address to write to uint8_t page_address; //! the column address, or the X pixel. uint8_t column_address; //! store the LCD controller start draw line uint8_t start_line_address = 0; board_init(); sysclk_init(); // initialize the interface (SPI), ST7565R LCD controller and LCD st7565r_init(); // set addresses at beginning of display st7565r_set_page_address(0); st7565r_set_column_address(0); // fill display with lines for (page_address = 0; page_address <= 4; page_address++) { st7565r_set_page_address(page_address); for (column_address = 0; column_address < 128; column_address++) { st7565r_set_column_address(column_address); /* fill every other pixel in the display. This will produce horizontal lines on the display. */ st7565r_write_data(0xAA); } } // scroll the display using hardware support in the LCD controller while (true) { st7565r_set_display_start_line_address(start_line_address++); delay_ms(250); } }