Interfacing SSD1305 oled in 8080 mode

Post your cool example code here.
Post Reply
smithy
Posts: 37
Joined: Sat Aug 13, 2016 7:02 pm
Location: Gießen, Germany

Interfacing SSD1305 oled in 8080 mode

Post by smithy » Sun Aug 28, 2016 2:40 pm

I managed to write a simple test sketch for testing out displays in 8080 mode. The original code snippets came from martinayotte, thanks for sharing this in the first place.

Code: Select all

uint8_t LCD_CS = PA0;
uint8_t LCD_RST = PA1;
uint8_t LCD_WR = PA2;
uint8_t LCD_DC = PA3;
uint8_t LCD_RD = PA4;

uint8_t DPINS[] = {PB9, PB8, PB7, PB6, PB5, PB4, PB3, PA15};

void LCD_Init() {
  pinMode(LCD_RST, OUTPUT);
  pinMode(LCD_CS, OUTPUT);
  pinMode(LCD_DC, OUTPUT);
  pinMode(LCD_WR, OUTPUT);
  pinMode(LCD_RD, OUTPUT);
  for (uint8_t i = 0; i <= sizeof(DPINS) - 1; i++)
    pinMode(DPINS[i], OUTPUT);
  digitalWrite(LCD_CS, HIGH);
  digitalWrite(LCD_DC, HIGH);
  digitalWrite(LCD_WR, HIGH);
  digitalWrite(LCD_RD, HIGH);
  digitalWrite(LCD_RST, HIGH);
  delay(50);
  digitalWrite(LCD_RST, LOW);
  delay(150);
  digitalWrite(LCD_RST, HIGH);
  delay(150);
  digitalWrite(LCD_CS, LOW);
  lcd_cmd(0xae); // display off
  delay(10);
  lcd_cmd(0xa5); // entire display on
  delay(10);
  lcd_cmd(0xac); // display on
  delay(10);
  digitalWrite(LCD_CS, HIGH);
}

void lcd_write_bus(uint8_t val) {
  unsigned char i, temp, data;
  data = val;
  digitalWrite(LCD_WR, LOW);
  delay(10);
  for (i = 0; i <= sizeof(DPINS) - 1; i++) {
    temp = (data & 0x01);
    if (temp)
      digitalWrite(DPINS[i], HIGH);
    else
      digitalWrite(DPINS[i], LOW);
    data = data >> 1;
  }
  delay(10);
  digitalWrite(LCD_WR, HIGH);
}

void lcd_cmd(uint8_t cmd) {
  digitalWrite(LCD_DC, LOW);
  delay(10);
  lcd_write_bus(cmd);
}

void lcd_data(uint8_t data) { //Pull high for write/read display data
  digitalWrite(LCD_DC, HIGH);
  lcd_write_bus(data);
}

void lcd_cmd_data(uint8_t cmd, uint8_t data) { //Pull low for write command or read status
  lcd_cmd(cmd);
  lcd_data(data);
}

void setup() {
  LCD_Init();
}

void loop() {
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest