SSD1306
图5-1:OLED1 Xplained Pro
OLED1 Xplained Pro是Atmel设计的配件开发板,上面总共呆了三个LED和三个Key以及一个128*32的OLED液晶屏幕。
图5-2:OLED1 Xplained Pro Overview
打开AtmelStudio 新建一个SSD1306的工程。
图5-3:Example
代码如下:
int main(void)
{
//! the pageaddress to write to
uint8_t page_address;
//! the columnaddress, or the X pixel.
uint8_t column_address;
//! store the LCDcontroller start draw line
uint8_t start_line_address = 0;
system_init();
delay_init();
// Initialize SPIand SSD1306 controller
ssd1306_init();
// set addressesat beginning of display
ssd1306_set_page_address(0);
ssd1306_set_column_address(0);
// fill displaywith lines
for (page_address = 0; page_address <= 8; page_address++) {
ssd1306_set_page_address(page_address);
for (column_address = 0; column_address < 128; column_address++) {
ssd1306_set_column_address(column_address);
/* fill every other pixel in the display. This will produce
horizontal lines on thedisplay. */
ssd1306_write_data(0x0f);
}
}
// scroll thedisplay using hardware support in the LCD controller
while (true) {
ssd1306_set_display_start_line_address(start_line_address++);
delay_ms(250);
}
}
将OLED1插在开发板上,烧写代码,即可看到SSD1306上显示条形黑白间隔的图案。
图5-4
SSD1306是这个OLED液晶屏的主控芯片。