Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
Last active November 22, 2021 18:30
Show Gist options
  • Select an option

  • Save tlrobinson/dd8cf7d0638bdf49f64812a77f7a798c to your computer and use it in GitHub Desktop.

Select an option

Save tlrobinson/dd8cf7d0638bdf49f64812a77f7a798c to your computer and use it in GitHub Desktop.

Revisions

  1. tlrobinson revised this gist Jan 5, 2020. 1 changed file with 25 additions and 10 deletions.
    35 changes: 25 additions & 10 deletions ttgo_oled_example.ino
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,44 @@
    #include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
    #include "SSD1306Wire.h" // legacy: #include "SSD1306.h"
    #include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
    #include "SSD1306Wire.h" // legacy: #include "SSD1306.h"

    // TTGO LoRa32-OLED V1
    //
    //
    // #define OLED_SDA 4
    // #define OLED_SCL 15
    // #define OLED_RST 16

    // TTGO LoRa32-OLED v2.0 and V2.1
    //
    // #define OLED_SDA 21
    // #define OLED_SCL 22
    // #define OLED_RST NOT_A_PIN

    SSD1306Wire display(0x3c, OLED_SDA, OLED_SCL);

    void setup() {
    void setup()
    {
    Serial.begin(9600);
    delay(100);
    Serial.println("hello world");

    // reset the OLED:
    pinMode(OLED_RST, OUTPUT);
    digitalWrite(OLED_RST, LOW); // set GPIO16 low to reset OLED
    delay(50);
    digitalWrite(OLED_RST, HIGH); // while OLED is running, must set GPIO16 in high
    if (OLED_RST != NOT_A_PIN)
    {
    pinMode(OLED_RST, OUTPUT);
    digitalWrite(OLED_RST, LOW); // set GPIO16 low to reset OLED
    delay(50);
    digitalWrite(OLED_RST, HIGH); // while OLED is running, must set GPIO16 in high
    }

    display.init();
    display.flipScreenVertically();

    display.clear();
    display.setFont(ArialMT_Plain_10);
    display.drawString(0, 0, "Hello world");
    display.display();
    }

    void loop() {
    void loop()
    {
    }
  2. tlrobinson revised this gist Jan 3, 2020. No changes.
  3. tlrobinson revised this gist Jan 3, 2020. 1 changed file with 12 additions and 9 deletions.
    21 changes: 12 additions & 9 deletions ttgo_oled_example.ino
    Original file line number Diff line number Diff line change
    @@ -1,26 +1,29 @@
    #include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
    #include "SSD1306Wire.h" // legacy: #include "SSD1306.h"

    // TTGO LoRa32-OLED V1
    //
    // #define OLED_SDA 4
    // #define OLED_SCL 15
    // #define OLED_RST 16

    SSD1306Wire display(0x3c, OLED_SDA, OLED_SCL);

    void setup() {
    pinMode(16, OUTPUT);
    digitalWrite(16, LOW); // set GPIO16 low to reset OLED
    // reset the OLED:
    pinMode(OLED_RST, OUTPUT);
    digitalWrite(OLED_RST, LOW); // set GPIO16 low to reset OLED
    delay(50);
    digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high
    digitalWrite(OLED_RST, HIGH); // while OLED is running, must set GPIO16 in high

    display.init();
    display.flipScreenVertically();

    display.setFont(ArialMT_Plain_10);
    display.setTextAlignment(TEXT_ALIGN_LEFT);

    display.clear();
    display.drawStringMaxWidth(0, 0, 128,
    "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." );
    display.setFont(ArialMT_Plain_10);
    display.drawString(0, 0, "Hello world");
    display.display();
    }

    void loop() {

    }
  4. tlrobinson revised this gist Jan 3, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ttgo_oled_example.ino
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
    #include "SSD1306Wire.h" // legacy: #include "SSD1306.h"

    SSD1306Wire display(0x3c, 4, 15);
    SSD1306Wire display(0x3c, OLED_SDA, OLED_SCL);

    void setup() {
    pinMode(16, OUTPUT);
  5. tlrobinson created this gist Jan 3, 2020.
    26 changes: 26 additions & 0 deletions ttgo_oled_example.ino
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
    #include "SSD1306Wire.h" // legacy: #include "SSD1306.h"

    SSD1306Wire display(0x3c, 4, 15);

    void setup() {
    pinMode(16, OUTPUT);
    digitalWrite(16, LOW); // set GPIO16 low to reset OLED
    delay(50);
    digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high

    display.init();
    display.flipScreenVertically();

    display.setFont(ArialMT_Plain_10);
    display.setTextAlignment(TEXT_ALIGN_LEFT);

    display.clear();
    display.drawStringMaxWidth(0, 0, 128,
    "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." );
    display.display();
    }

    void loop() {

    }