ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
2.01k stars 638 forks source link

Support for 64x48 OLED ? #73

Closed erkobg closed 4 years ago

erkobg commented 8 years ago

Hello, It will be very helpful if you add support for 64x48 OLED like the official display for Wemos :+1: http://www.wemos.cc/Products/oled_shield.html

Here they did almost the same : https://github.com/mcauser/Adafruit_SSD1306/tree/esp8266-64x48

Regards!

Testato commented 8 years ago

+1

64x48 pixel is a very common display, have you plan for support it ?

FWeinb commented 8 years ago

I would like to support it but I don't have one yet so I can't start working on that.

hallard commented 8 years ago

I ordered some last week, as soon as I got them I may take a look and do a PR. @FWeinb is there any tip should I know for being able to change resolution on library, such like current 128x64 resolution hard coded somewhere? may I just change then and OLED init code ?

FWeinb commented 8 years ago

To get this working you need to change the defines here and introduce a custom constructor/subclass of each driver to allow for selection of the width/height. Than you need to introduce local member variables to contain the width/height in the OLEDDisplay class and change every access to the defines to use these new local variables.

LimaLima commented 8 years ago

Being a lazy bastard, I took this lib and instead of adding support for different display, I just made it work with 128x32. Then to be a complete *hole, I took the latest version, dropped changed files over it instead of merging. But it might be still a useful starting point for your own changes - feel free to see diff and find what's needed to make other geometries work.

trepidacious commented 7 years ago

I've submitted a pull request https://github.com/squix78/esp8266-oled-ssd1306/pull/97 for changes to allow use of either 128x64 or 128x32 displays based on LimaLima's changes (thanks for working out the register values, I don't know what they do, but they work for me!)

artkeller commented 7 years ago

@FWeinb: to understand the tiny 64x48 display a bit better, refer to the following stuff

// cf. https://www.wemos.cc/product/oled-shield.html // cf. https://macsbug.files.wordpress.com/2016/04/zahyou_s.png?w=700 // cf. https://macsbug.wordpress.com/2016/04/01/using-the-wemos-i2c-oled-64x48/

Sorry - the last link goes to a japanese site, but it can be understood pretty good due to the well documented code examples in english, good links and nice pictures... (I like this stuff)

BTW: Thanks for the New Year stuff :-)

Thomas

tofrnr commented 6 years ago

I fixed that issue for a OLED 64x48:

HTH!

/*
 * for OLED 64x48:
 * x-offset=32
 * y-offset=16
 * 
 * exchange  in OLEDDisplay.h:
 * 
   //#define DISPLAY_WIDTH 128
   //#define DISPLAY_HEIGHT 64

   #define DISPLAY_WIDTH 96
   #define DISPLAY_HEIGHT 64
 *  
*/
/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 by Daniel Eichhorn
 * https://github.com/ThingPulse/esp8266-oled-ssd1306/issues ;
 *
 */

/*
 * for OLED 64x48:
 * x-offset=32
 * y-offset=16
 * 
 * exchange  in OLEDDisplay.h:
 * 
   //#define DISPLAY_WIDTH 128
   //#define DISPLAY_HEIGHT 64

   #define DISPLAY_WIDTH 96
   #define DISPLAY_HEIGHT 64
 *  
*/

// Include the correct displayBRK library
// For a connection via I2C using Wire include
#include <Wire.h>    // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`by Squix aka  Daniel Eichhorn

// Initialize the OLED displayBRK using Wire library
SSD1306  displayBRK(0x3d, D2, D1);

int counter = 1;

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println();

  Wire.begin();
  Wire.pins(D2,D1);

  // Initialising the UI will init the displayBRK too.
  displayBRK.init();

  displayBRK.flipScreenVertically();
  displayBRK.setFont(ArialMT_Plain_10);

}

void drawFontFaceDemo() {
    // Font Demo1
    // create more fonts at http://oleddisplayBRK.squix.ch/
    displayBRK.setTextAlignment(TEXT_ALIGN_LEFT);
    displayBRK.setFont(ArialMT_Plain_10);
    displayBRK.drawString(0+32, 0+16, "Hello world");
    displayBRK.setFont(ArialMT_Plain_16);
    displayBRK.drawString(0+32, 10+16, "Hello world");

    //displayBRK.setFont(ArialMT_Plain_24);
    //displayBRK.drawString(0, 26, "Hello world");
}

void drawTextFlowDemo() {
    displayBRK.setFont(ArialMT_Plain_10);
    displayBRK.setTextAlignment(TEXT_ALIGN_LEFT);
    displayBRK.drawStringMaxWidth(0+32, 0+16, 64,
    "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." );
}

void drawTextAlignmentDemo() {
    // Text alignment demo
  displayBRK.setFont(ArialMT_Plain_10);

  // The coordinates define the left starting point of the text
  displayBRK.setTextAlignment(TEXT_ALIGN_LEFT);
  displayBRK.drawString(0+32, 10+16, "Left aligned");

  // The coordinates define the center of the text
  displayBRK.setTextAlignment(TEXT_ALIGN_CENTER);
  displayBRK.drawString(32+32, 22+16, "Center aligned");

  // The coordinates define the right end of the text
  displayBRK.setTextAlignment(TEXT_ALIGN_RIGHT);
  displayBRK.drawString(64+32, 33+16, "Right aligned");

}

void drawCircleDemo() {
  for (int i=1; i < 8; i++) {
    displayBRK.setColor(WHITE);
    displayBRK.drawCircle(32+32, 24+16, i*3);
    if (i % 2 == 0) {
      displayBRK.setColor(BLACK);
    }
    displayBRK.fillCircle(32+32, 24+16, 32 - i* 3);
  }
}

void loop() {
  //------------------------------------
  // clear the displayBRK
  displayBRK.clear();
  drawFontFaceDemo();

  displayBRK.setTextAlignment(TEXT_ALIGN_LEFT);
  displayBRK.drawString(0+32, 32+16, String(millis()));

  displayBRK.display();

  delay(1000);

  //------------------------------------
  displayBRK.clear();
  drawTextFlowDemo();

  displayBRK.display();

  delay(1000);

  //------------------------------------
  displayBRK.clear();
  drawTextAlignmentDemo();

  displayBRK.display();

  delay(1000);

  //------------------------------------ 
  displayBRK.clear();
  drawCircleDemo();

  displayBRK.display();

  counter++;
  delay(1000);
}
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Testato commented 5 years ago

PR https://github.com/ThingPulse/esp8266-oled-ssd1306/pull/198 solve this Issue. Please accept it

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

LennartHennigs commented 4 years ago

please reopen this issue and apply PR