Skip to content

Instantly share code, notes, and snippets.

@witnessmenow
Created July 4, 2020 12:33
Show Gist options
  • Save witnessmenow/3555de27acd3f488abc433a217a8202d to your computer and use it in GitHub Desktop.
Save witnessmenow/3555de27acd3f488abc433a217a8202d to your computer and use it in GitHub Desktop.
Simple TinyPico Play shield example just for display
#include <TinyPICO.h>
#include <SPI.h>
#include <Wire.h>
#include <WiFi.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
const uint8_t PROGMEM TP_Logo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x3c, 0x00, 0x06, 0x1f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0xfe, 0x1f, 0xf0, 0x1f, 0xfc, 0x07, 0xf8,
0x3c, 0x00, 0x06, 0x1f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x3e, 0x1f, 0xc0, 0x07, 0xf0, 0x01, 0xf8,
0x3c, 0x00, 0x06, 0x1f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x1e, 0x1f, 0x80, 0x07, 0xc0, 0x00, 0xfc,
0x3f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3e, 0x0e, 0x1f, 0x07, 0xe7, 0x83, 0xf0, 0x7c,
0x3f,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
0x3f, 0xf0, 0xfe, 0x1c, 0x3f, 0x0f, 0x80, 0xfc, 0x3f, 0xfe, 0x1e, 0x1f, 0xff, 0x87, 0xfc, 0x3c,
0x3f, 0xf0, 0xfe, 0x1c, 0x3f, 0x0f, 0xc0, 0xfc, 0x3f, 0xfe, 0x1f, 0x0f, 0xf7, 0x83, 0xf8, 0x7c,
0x3f, 0xf0, 0xfe, 0x1c, 0x3f, 0x0f, 0xc0, 0xfc, 0x3f, 0xfe, 0x1f, 0x80, 0x07, 0xc0, 0x00, 0xfc,
0x3f, 0xf0, 0xfe, 0x1c, 0x3f, 0x0f, 0xe1, 0xfc, 0x3f, 0xfe, 0x1f, 0xc0, 0x07, 0xe0, 0x01, 0xfc,
0x1f, 0xf0, 0xfe, 0x1c, 0x3f, 0x0f, 0xe1, 0xfc, 0x3f, 0xfe, 0x1f, 0xe0, 0x0f, 0xf8, 0x03, 0xf8,
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Declaration for the SSD1306 display connected to I2C with a resolution of 128x64 (SDA, SCL pins and -1 for reset pin as it's not used)
Adafruit_SSD1306 display( 128, 64, &Wire, -1 );
void setup()
{
Serial.begin(115200);
WiFi.disconnect(true);
WiFi.mode(WIFI_OFF);
delay(200);
// Initialise the SSD1306 OLED at address 0x03C
// Alternate I2C Address is 0x3D
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println("SSD1306 allocation failed - Execution halted!");
// Don't proceed, loop forever
while (1);
}
Serial.println("SSD1306 OLED initialised");
// Show initial TinyPICO Logo as a splash screen.
display.clearDisplay();
display.drawBitmap( 0, (64 - 30) / 2, TP_Logo, 128, 30, 1);
display.display();
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.println("hello World");
display.display();
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment