Skip to content

Instantly share code, notes, and snippets.

@jboecker
Last active December 12, 2020 15:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jboecker/ab0b8a4c466438c8f833375755e86dad to your computer and use it in GitHub Desktop.
Save jboecker/ab0b8a4c466438c8f833375755e86dad to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
#include <Servo.h>
#include "hg_font.h"
// If using software SPI (the default case):
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SSD1306 pressureDisplay(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
void drawDigit(unsigned int index, unsigned int offset, const unsigned char* bits) {
unsigned int y_offset_lines = offset / 273;
pressureDisplay.fillRect(15*index, 0, 16, 24, BLACK);
pressureDisplay.drawXBitmap(15*index, 0, &bits[2*y_offset_lines], 16, 24, WHITE);
pressureDisplay.display();
}
DcsBios::IntegerBuffer altPressure0Buffer(0x1086, 0xffff, 0, NULL);
DcsBios::IntegerBuffer altPressure1Buffer(0x1088, 0xffff, 0, NULL);
DcsBios::IntegerBuffer altPressure2Buffer(0x108a, 0xffff, 0, NULL);
DcsBios::IntegerBuffer altPressure3Buffer(0x108c, 0xffff, 0, NULL);
void setup() {
DcsBios::setup();
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
pressureDisplay.begin(SSD1306_SWITCHCAPVCC);
pressureDisplay.clearDisplay();
pressureDisplay.setTextSize(3);
pressureDisplay.setTextColor(WHITE);
pressureDisplay.display();
}
void loop() {
DcsBios::loop();
if (altPressure0Buffer.hasUpdatedData() || altPressure1Buffer.hasUpdatedData() || altPressure2Buffer.hasUpdatedData() || altPressure3Buffer.hasUpdatedData()) {
drawDigit(3, altPressure0Buffer.getData(), hg_font);
drawDigit(2, altPressure1Buffer.getData(), hg_font);
drawDigit(1, altPressure2Buffer.getData(), hg_font);
drawDigit(0, altPressure3Buffer.getData(), hg_font);
pressureDisplay.display();
}
}
static const unsigned char hg_font[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xf8, 0x07, 0xfc, 0x0f,
0x1c, 0x0e, 0x1e, 0x1e, 0x0e, 0x1c, 0x0e, 0x1c, 0x0e, 0x1c, 0x0e, 0x1c,
0x0e, 0x1c, 0x0e, 0x1c, 0x0e, 0x1c, 0x1e, 0x1e, 0x1c, 0x0e, 0xfc, 0x0f,
0xf8, 0x07, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0xf0, 0x01, 0xf8, 0x01,
0xdc, 0x01, 0xcc, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xfc, 0x0f,
0xfc, 0x0f, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xfc, 0x07, 0xfc, 0x0f,
0x0c, 0x0f, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x07, 0x80, 0x03,
0x80, 0x03, 0xc0, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x38, 0x00, 0xfc, 0x1f,
0xfc, 0x1f, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xfc, 0x07, 0xfc, 0x0f,
0x0c, 0x0f, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x07, 0xf0, 0x07, 0xf0, 0x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, 0x80, 0x07, 0x80, 0x07, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xe0, 0x01, 0xe0, 0x01, 0xf0, 0x00, 0xf0, 0x00,
0x78, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0xfc, 0x0f, 0xfe, 0x1f,
0x1e, 0x1e, 0x0e, 0x1c, 0x0e, 0x1c, 0x3c, 0x0f, 0xf8, 0x07, 0xf0, 0x07,
0xf8, 0x0f, 0x1c, 0x1e, 0x0e, 0x1c, 0x0e, 0x1c, 0x1e, 0x1e, 0xfe, 0x1f,
0xfc, 0x0f, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xf8, 0x07, 0xfc, 0x0f,
0x1e, 0x0e, 0x0e, 0x1c, 0x0e, 0x1c, 0x0e, 0x1c, 0x1e, 0x1e, 0xfe, 0x1f,
0xfc, 0x1f, 0xf0, 0x1d, 0x00, 0x1c, 0x00, 0x0e, 0x04, 0x0f, 0xfc, 0x07,
0xfc, 0x03, 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xf8, 0x07, 0xfc, 0x0f,
0x1c, 0x0e, 0x1e, 0x1e, 0x0e, 0x1c, 0x0e, 0x1c, 0x0e, 0x1c, 0x0e, 0x1c,
0x0e, 0x1c, 0x0e, 0x1c, 0x0e, 0x1c, 0x1e, 0x1e, 0x1c, 0x0e, 0xfc, 0x0f,
0xf8, 0x07, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment