Xadow - OLED 128*64 (180° rotation with remap)

Xadow series products.

Moderators: lily.li, violet, jessie, nosk

Post Reply
User avatar
avoid
Pre-kindergarten
Pre-kindergarten
Posts: 12
Joined: Mon Apr 06, 2015 5:42 pm

Xadow - OLED 128*64 (180° rotation with remap)

Post by avoid » Sun Apr 26, 2015 2:30 am

I have edited the Library files "SeeedOLED.cpp" and "SeeedOLED.h" to rotate the display by 180 ° with the help of "remap".

On "SeeedOLED.h" i have added:

Code: Select all

void setRotation(bool Rotation);
On "SeeedOLED.cpp" i have added:

Code: Select all

void SeeedOLED::setRotation(bool Rotation) // Rotation=true/false
{
	if (Rotation == true) {
		// Display rotation 180°
		sendCommand(0xA8); // mux ratio(3F=[64 lines])
		sendCommand(0x3F);
		sendCommand(0xA0); // segment remap(top / bottom reversed)
		sendCommand(0xC9);
		sendCommand(0xA0); // segment remap(left / right reversed)
		sendCommand(0xA1);
	}
	else {
		// Display rotation 0°
		sendCommand(0xA8); // mux ratio(3F=[64 lines])
		sendCommand(0x3F);
		sendCommand(0xA0); // segment remap(top / bottom normal)
		sendCommand(0xC0);
		sendCommand(0xA0); // segment remap(left / right normal)
		sendCommand(0xA0);
	}
	setTextXY(0,0);
}
This is an edited OLED_Horizontal_Addressing_Mode example:

Code: Select all

#include <Wire.h>
#include <SeeedOLED.h>


void setup()
{
  Wire.begin();	
  SeeedOled.init();  //initialze SEEED OLED display
  DDRB|=0x21;        
  PORTB |= 0x21;

  SeeedOled.clearDisplay();           //clear the screen and set start position to top left corner
  SeeedOled.setNormalDisplay();       //Set display to Normal mode
  SeeedOled.setHorizontalMode();      //Set addressing mode to Horizontal Mode
}

void loop()
{
  SeeedOled.clearDisplay();
  SeeedOled.setRotation(true);
  SeeedOled.putString("rotated         orientation");
  delay(1500);
  SeeedOled.clearDisplay();
  SeeedOled.setRotation(false);
  SeeedOled.putString("normal          orientation");
  delay(1500);
}
The display has contains much more functions than the Library.
For more features, I recommend a look at the datasheet of the display controller.
I hope it helps.

much greetings,
avoid
Good questions are like a science experiment. They put a lot of knowledge ahead already.
bitcoin:1J5dgQQp8eUy8wkUxyztBUVCkCpo5MQEQs?label=Thanks

Post Reply