updated for 256x64 display
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
**/.DS_Store
|
||||||
BIN
CAD/Datasheets/OLED-31-SPI-33-V-WHI-004.jpg
Normal file
|
After Width: | Height: | Size: 155 KiB |
BIN
CAD/Datasheets/OLED-31-SPI-33-V-WHI-006.jpg
Normal file
|
After Width: | Height: | Size: 343 KiB |
BIN
CAD/Datasheets/OLED_256x64_1.jpg
Normal file
|
After Width: | Height: | Size: 198 KiB |
BIN
CAD/Datasheets/OLED_256x64_2.jpg
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
CAD/Datasheets/OLED_256x64_bus.jpg
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
CAD/Datasheets/OLED_256x64_pins.jpg
Normal file
|
After Width: | Height: | Size: 266 KiB |
BIN
CAD/Datasheets/SSD1322.pdf
Normal file
BIN
CAD/Datasheets/W256064-XALG.jpg
Normal file
|
After Width: | Height: | Size: 69 KiB |
@@ -93,11 +93,11 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum OLEDDISPLAY_COLOR {
|
// enum OLEDDISPLAY_COLOR {
|
||||||
BLACK = 0,
|
// BLACK = 0,
|
||||||
WHITE = 1,
|
// WHITE = 1,
|
||||||
INVERSE = 2
|
// INVERSE = 2
|
||||||
};
|
// };
|
||||||
|
|
||||||
enum OLEDDISPLAY_TEXT_ALIGNMENT {
|
enum OLEDDISPLAY_TEXT_ALIGNMENT {
|
||||||
TEXT_ALIGN_LEFT = 0,
|
TEXT_ALIGN_LEFT = 0,
|
||||||
|
|||||||
@@ -13,5 +13,7 @@ platform = espressif32
|
|||||||
board = heltec_wifi_lora_32_V2
|
board = heltec_wifi_lora_32_V2
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
lib_ldf_mode = deep+
|
||||||
lib_deps =
|
lib_deps =
|
||||||
#heltecautomation/Heltec ESP32 Dev-Boards@^1.1.0
|
winneymj/ESP8266 SSD1322@^1.0.6
|
||||||
|
adafruit/Adafruit GFX Library@^1.10.10
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void initBoard(void);
|
void initBoard(void);
|
||||||
|
|
||||||
|
#define HAS_DISPLAY
|
||||||
|
#define HAS_SSD1322
|
||||||
|
//#define HAS_SSD1306
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define OLED_CS 5 // , CS - Chip select
|
||||||
|
#define OLED_DC 17 // DC digital signal
|
||||||
|
#define OLED_RESET 0 // using hardware !RESET from Arduino insteadx
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
SSD1306Wire display(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_128_64);
|
|
||||||
;
|
#ifdef HAS_SSD1306
|
||||||
|
SSD1306Wire display(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_128_64);
|
||||||
|
|
||||||
OLEDDisplayUi ui(&display);
|
OLEDDisplayUi ui(&display);
|
||||||
displayState displaystate = mainscreen;
|
displayState displaystate = mainscreen;
|
||||||
bool stateMutex = true;
|
bool stateMutex = true;
|
||||||
@@ -207,4 +209,358 @@ void handleDisplay(void)
|
|||||||
int remainingTimeBudget = ui.update();
|
int remainingTimeBudget = ui.update();
|
||||||
|
|
||||||
Serial.printf("DT=%u;", remainingTimeBudget);
|
Serial.printf("DT=%u;", remainingTimeBudget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_SSD1322
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ATMega32u4 pins
|
||||||
|
//#define OLED_DC 8 // D8 - B4
|
||||||
|
//#define OLED_CS 17 // D17 - B0
|
||||||
|
//#define OLED_RESET 9 // D9 - B5
|
||||||
|
|
||||||
|
//hardware SPI - only way to go. Can get 110 FPS
|
||||||
|
ESP8266_SSD1322 display(1,MOSI,OLED_DC,0, OLED_CS);
|
||||||
|
//int8_t SID, int8_t SDA, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS
|
||||||
|
|
||||||
|
#define NUMFLAKES 10
|
||||||
|
#define XPOS 0
|
||||||
|
#define YPOS 1
|
||||||
|
#define DELTAY 2
|
||||||
|
|
||||||
|
#define LOGO16_GLCD_HEIGHT 16
|
||||||
|
#define LOGO16_GLCD_WIDTH 16
|
||||||
|
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||||
|
{ B00000000, B11000000,
|
||||||
|
B00000001, B11000000,
|
||||||
|
B00000001, B11000000,
|
||||||
|
B00000011, B11100000,
|
||||||
|
B11110011, B11100000,
|
||||||
|
B11111110, B11111000,
|
||||||
|
B01111110, B11111111,
|
||||||
|
B00110011, B10011111,
|
||||||
|
B00011111, B11111100,
|
||||||
|
B00001101, B01110000,
|
||||||
|
B00011011, B10100000,
|
||||||
|
B00111111, B11100000,
|
||||||
|
B00111111, B11110000,
|
||||||
|
B01111100, B11110000,
|
||||||
|
B01110000, B01110000,
|
||||||
|
B00000000, B00110000 };
|
||||||
|
|
||||||
|
#if (SSD1322_LCDHEIGHT != 64)
|
||||||
|
#error("Height incorrect, please fix ESP8266_SSD1322.h!");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// void c_displayMeasureMode::drawMeasureMode(OLEDDisplay *display, measureMode mode, int16_t x, int16_t y)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||||
|
uint8_t icons[NUMFLAKES][3];
|
||||||
|
|
||||||
|
// initialize
|
||||||
|
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||||
|
icons[f][XPOS] = random(display.width());
|
||||||
|
icons[f][YPOS] = 0;
|
||||||
|
icons[f][DELTAY] = random(5) + 1;
|
||||||
|
|
||||||
|
Serial.print("x: ");
|
||||||
|
Serial.print(icons[f][XPOS], DEC);
|
||||||
|
Serial.print(" y: ");
|
||||||
|
Serial.print(icons[f][YPOS], DEC);
|
||||||
|
Serial.print(" dy: ");
|
||||||
|
Serial.println(icons[f][DELTAY], DEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
// draw each icon
|
||||||
|
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||||
|
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
|
||||||
|
}
|
||||||
|
display.display();
|
||||||
|
delay(200);
|
||||||
|
|
||||||
|
// then erase it + move it
|
||||||
|
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||||
|
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
|
||||||
|
// move it
|
||||||
|
icons[f][YPOS] += icons[f][DELTAY];
|
||||||
|
// if its gone, reinit
|
||||||
|
if (icons[f][YPOS] > display.height()) {
|
||||||
|
icons[f][XPOS] = random(display.width());
|
||||||
|
icons[f][YPOS] = 0;
|
||||||
|
icons[f][DELTAY] = random(5) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void testdrawchar(void) {
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setCursor(0,0);
|
||||||
|
|
||||||
|
for (uint8_t i=0; i < 168; i++) {
|
||||||
|
if (i == '\n') continue;
|
||||||
|
display.write(i);
|
||||||
|
if ((i > 0) && (i % 21 == 0))
|
||||||
|
display.println();
|
||||||
|
}
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
void testdrawcircle(void) {
|
||||||
|
for (int16_t i=0; i<display.height(); i+=2) {
|
||||||
|
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testfillrect(void) {
|
||||||
|
uint8_t color = 1;
|
||||||
|
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||||
|
// alternate colors
|
||||||
|
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||||
|
display.display();
|
||||||
|
color++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testdrawtriangle(void) {
|
||||||
|
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||||
|
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||||
|
display.width()/2-i, display.height()/2+i,
|
||||||
|
display.width()/2+i, display.height()/2+i, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testfilltriangle(void) {
|
||||||
|
uint8_t color = WHITE;
|
||||||
|
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||||
|
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||||
|
display.width()/2-i, display.height()/2+i,
|
||||||
|
display.width()/2+i, display.height()/2+i, WHITE);
|
||||||
|
if (color == WHITE) color = BLACK;
|
||||||
|
else color = WHITE;
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testdrawroundrect(void) {
|
||||||
|
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||||
|
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testfillroundrect(void) {
|
||||||
|
uint8_t color = WHITE;
|
||||||
|
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||||
|
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||||
|
if (color == WHITE) color = BLACK;
|
||||||
|
else color = WHITE;
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testdrawrect(void) {
|
||||||
|
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||||
|
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testdrawline() {
|
||||||
|
for (int16_t i=0; i<display.width(); i+=4) {
|
||||||
|
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
for (int16_t i=0; i<display.height(); i+=4) {
|
||||||
|
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
|
||||||
|
display.clearDisplay();
|
||||||
|
for (int16_t i=0; i<display.width(); i+=4) {
|
||||||
|
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||||
|
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
|
||||||
|
display.clearDisplay();
|
||||||
|
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||||
|
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||||
|
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
|
||||||
|
display.clearDisplay();
|
||||||
|
for (int16_t i=0; i<display.height(); i+=4) {
|
||||||
|
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
for (int16_t i=0; i<display.width(); i+=4) {
|
||||||
|
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
|
delay(250);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testscrolltext(void) {
|
||||||
|
display.setTextSize(2);
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setCursor(10,0);
|
||||||
|
display.clearDisplay();
|
||||||
|
display.println("scroll");
|
||||||
|
display.display();
|
||||||
|
|
||||||
|
display.startscrollright(0x00, 0x0F);
|
||||||
|
delay(2000);
|
||||||
|
display.stopscroll();
|
||||||
|
delay(1000);
|
||||||
|
display.startscrollleft(0x00, 0x0F);
|
||||||
|
delay(2000);
|
||||||
|
display.stopscroll();
|
||||||
|
delay(1000);
|
||||||
|
display.startscrolldiagright(0x00, 0x07);
|
||||||
|
delay(2000);
|
||||||
|
display.startscrolldiagleft(0x00, 0x07);
|
||||||
|
delay(2000);
|
||||||
|
display.stopscroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initDisplay() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
|
||||||
|
// Initialize and perform reset
|
||||||
|
display.begin(true);
|
||||||
|
// init done
|
||||||
|
|
||||||
|
// Show image buffer on the display hardware.
|
||||||
|
// Since the buffer is intialized with an Adafruit splashscreen
|
||||||
|
// internally, this will display the splashscreen.
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
// Clear the buffer.
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw a single pixel
|
||||||
|
display.drawPixel(10, 10, WHITE);
|
||||||
|
// Show the display buffer on the hardware.
|
||||||
|
// NOTE: You _must_ call display after making any drawing commands
|
||||||
|
// to make them visible on the display hardware!
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw many lines
|
||||||
|
testdrawline();
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw rectangles
|
||||||
|
testdrawrect();
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw multiple rectangles
|
||||||
|
testfillrect();
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw mulitple circles
|
||||||
|
testdrawcircle();
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw a white circle, 10 pixel radius
|
||||||
|
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
testdrawroundrect();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
testfillroundrect();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
testdrawtriangle();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
testfilltriangle();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw the first ~12 characters in the font
|
||||||
|
testdrawchar();
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// draw scrolling text
|
||||||
|
testscrolltext();
|
||||||
|
delay(2000);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// text display tests
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setCursor(0,0);
|
||||||
|
display.println("Hello, world!");
|
||||||
|
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||||
|
display.println(3.141592);
|
||||||
|
display.setTextSize(2);
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||||
|
display.display();
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
// miniature bitmap display
|
||||||
|
display.clearDisplay();
|
||||||
|
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||||
|
display.display();
|
||||||
|
|
||||||
|
// invert the display
|
||||||
|
display.invertDisplay(true);
|
||||||
|
delay(1000);
|
||||||
|
display.invertDisplay(false);
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
// draw a bitmap icon and 'animate' movement
|
||||||
|
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void handleDisplay() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,8 +1,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "SSD1306Wire.h"
|
|
||||||
#include "OLEDDisplayUi.h"
|
#include <SPI.h>
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
#ifdef HAS_SSD1306
|
||||||
|
#include "SSD1306Wire.h"
|
||||||
|
#include "OLEDDisplayUi.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_SSD1322
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <ESP8266_SSD1322.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "measure.h"
|
#include "measure.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
#define CONTROLSTRIP_YPOS 63 - 10 - 4
|
#define CONTROLSTRIP_YPOS 63 - 10 - 4
|
||||||
@@ -19,6 +34,7 @@ enum displayState
|
|||||||
setupscreen
|
setupscreen
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAS_SSD1306
|
||||||
class c_displayMeasureMode
|
class c_displayMeasureMode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -29,6 +45,7 @@ public:
|
|||||||
c_displayMeasureMode(measureMode mode, uint16_t xpos, uint16_t width, String name) : _mode(mode), _xpos(xpos), _width(width), _name(name) {}
|
c_displayMeasureMode(measureMode mode, uint16_t xpos, uint16_t width, String name) : _mode(mode), _xpos(xpos), _width(width), _name(name) {}
|
||||||
void drawMeasureMode(OLEDDisplay *display, measureMode mode, int16_t x, int16_t y);
|
void drawMeasureMode(OLEDDisplay *display, measureMode mode, int16_t x, int16_t y);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
void initDisplay(void);
|
void initDisplay(void);
|
||||||
void handleDisplay(void);
|
void handleDisplay(void);
|
||||||