Skip to content

Instantly share code, notes, and snippets.

@SpiZeak
Created June 26, 2020 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpiZeak/ece36c1e57da8a6b14038d2fb0c6287f to your computer and use it in GitHub Desktop.
Save SpiZeak/ece36c1e57da8a6b14038d2fb0c6287f to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int temp;
int clk;
int mem;
int load;
void setup() {
Serial.begin(9600);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
}
void loop() {
if (Serial.available()) {
clk = Serial.parseInt();
mem = Serial.parseInt();
temp = Serial.parseInt();
load = Serial.parseInt();
}
display.setCursor(0, 0);
display.print("GPU CLCK: ");
display.print(clk);
display.println(" MHz");
display.setCursor(0, 8);
display.print("GPU M.CLCK: ");
display.print(mem);
display.println(" MHz");
display.setCursor(0, 16);
display.print("GPU TEMP: ");
display.print(temp);
display.println(" C");
display.setCursor(0, 24);
display.print("GPU LOAD: ");
display.print(load);
display.println("%");
display.display();
display.clearDisplay();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment