Removed the u8g2 thing for now and the table component is "working"
This commit is contained in:
@@ -1,34 +0,0 @@
|
|||||||
#include "UIDrawing.h"
|
|
||||||
#include "UIComponent.h"
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* On the placement functions, change 5 to a variable or something
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint16_t calculateHeight(int16_t titleSize, int16_t textSize, int16_t nLines) {
|
|
||||||
return CHR_HEIGHT(titleSize) + CHR_HEIGHT(textSize) +
|
|
||||||
DEFAULT_TITLE_CONTENT_SPACING +
|
|
||||||
(2 * (DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t calculateWidth(int16_t textSize, int16_t nChars) {
|
|
||||||
return CHR_WIDTH(textSize) * nChars +
|
|
||||||
(2 * (DEFAULT_MARGIN + DEFAULT_BORDER_THICKNESS));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::horizontalCenter() {
|
|
||||||
uint16_t scrW = this->display->width();
|
|
||||||
this->dims.x = (scrW - this->dims.width) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We can add a mode of alignment here, center, left, right, whatever
|
|
||||||
void UIElement::placeBelow(UIElement *ref) {
|
|
||||||
// For now the default alignment will be left until I need some other
|
|
||||||
this->dims.x = ref->dims.x;
|
|
||||||
this->dims.y = ref->dims.y + ref->dims.height + 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::placeRight(UIElement *ref) {
|
|
||||||
this->dims.x = ref->dims.x + ref->dims.width + 5;
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
#include "UIComponent.h"
|
#include "UIComponent.h"
|
||||||
// #include "u8g2.h"
|
// #include "u8g2.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
#include "UIDrawing.h"
|
#include "UIDrawing.h"
|
||||||
// #include <U8g2lib.h>
|
// #include <U8g2lib.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#define DEBUG 1
|
||||||
|
|
||||||
UIElement::UIElement(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
UIElement::UIElement(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
||||||
char *title)
|
char *title)
|
||||||
: display(d), dims(dims), decor(decor), title(title) {}
|
: display(d), dims(dims), decor(decor), title(title) {}
|
||||||
@@ -13,12 +16,29 @@ UIDimensions::UIDimensions(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
|||||||
: x(x), y(y), width(w), height(h) {}
|
: x(x), y(y), width(w), height(h) {}
|
||||||
|
|
||||||
int16_t UIElement::getContentAreaX0() {
|
int16_t UIElement::getContentAreaX0() {
|
||||||
return this->dims.x + DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN;
|
if (this->decor->hasBorder) {
|
||||||
|
return this->dims.x + DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->dims.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t UIElement::getContentAreaY0() {
|
int16_t UIElement::getContentAreaY0() {
|
||||||
return this->dims.y + this->getTitleAreaHeight() +
|
if (this->decor->hasBorder) {
|
||||||
DEFAULT_TITLE_CONTENT_SPACING;
|
Serial2.print("Value to return: ");
|
||||||
|
Serial2.print(this->dims.y);
|
||||||
|
Serial2.print(" + ");
|
||||||
|
Serial2.print(this->getTitleAreaHeight());
|
||||||
|
Serial2.print(" + ");
|
||||||
|
Serial2.print(DEFAULT_TITLE_CONTENT_SPACING);
|
||||||
|
Serial2.print(" = ");
|
||||||
|
Serial2.println(this->dims.y + this->getTitleAreaHeight() +
|
||||||
|
DEFAULT_TITLE_CONTENT_SPACING);
|
||||||
|
return this->dims.y + this->getTitleAreaHeight() +
|
||||||
|
DEFAULT_TITLE_CONTENT_SPACING;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->dims.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t UIElement::getContentAreaHeight() {
|
uint16_t UIElement::getContentAreaHeight() {
|
||||||
@@ -56,51 +76,6 @@ uint16_t UIElement::getTitleAreaWidth() {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIElement::drawBox() {
|
|
||||||
// This is the border rectangle
|
|
||||||
for (int k = 0; k < DEFAULT_BORDER_THICKNESS; k++) {
|
|
||||||
this->display->drawRect(
|
|
||||||
this->dims.x + k, this->dims.y + k, this->dims.width - (k * 2),
|
|
||||||
this->dims.height - (k * 2), this->decor->borderColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For debugging purpouses
|
|
||||||
// title area
|
|
||||||
int16_t x = 0, y = 0;
|
|
||||||
uint16_t w = 0, h = 0;
|
|
||||||
|
|
||||||
// U8G2 u8g2; // No display pin setup needed since we're only using font data
|
|
||||||
// u8g2.setFont(u8g2_font_9x18_tf);
|
|
||||||
// int ascent = u8g2.getAscent();
|
|
||||||
|
|
||||||
h = this->getTitleAreaHeight();
|
|
||||||
uint16_t titleAreaWidth = this->getTitleAreaWidth();
|
|
||||||
int16_t titleTopLeftX = this->getTitleAreaX0();
|
|
||||||
#ifdef DEBUG
|
|
||||||
this->display->drawRect(titleTopLeftX, this->getTitleAreaY0(), titleAreaWidth,
|
|
||||||
h, BLUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// content area
|
|
||||||
x = this->getContentAreaX0();
|
|
||||||
y = this->getContentAreaY0();
|
|
||||||
w = this->getContentAreaWidth();
|
|
||||||
h = this->getContentAreaHeight();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
1 this->display->drawRect(x, y, w, h, BLUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Remove the border line behind the title
|
|
||||||
this->display->fillRect(titleTopLeftX - DEFAULT_MARGIN, this->dims.y,
|
|
||||||
titleAreaWidth + DEFAULT_MARGIN,
|
|
||||||
DEFAULT_BORDER_THICKNESS, MAIN_BG_COLOR);
|
|
||||||
|
|
||||||
// Render the title
|
|
||||||
this->display->setCursor(titleTopLeftX, this->dims.y);
|
|
||||||
this->display->print(this->title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::replaceString(char *oldVal, char *newVal) {
|
void UIElement::replaceString(char *oldVal, char *newVal) {
|
||||||
size_t newValLen = strlen(newVal);
|
size_t newValLen = strlen(newVal);
|
||||||
size_t oldValLen = strlen(oldVal);
|
size_t oldValLen = strlen(oldVal);
|
||||||
@@ -5,6 +5,11 @@
|
|||||||
#include "UIDecorations.h"
|
#include "UIDecorations.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
enum ComponentType {
|
||||||
|
STRING,
|
||||||
|
TABLE,
|
||||||
|
};
|
||||||
|
|
||||||
struct UIDimensions {
|
struct UIDimensions {
|
||||||
uint16_t x = 0, y = 0;
|
uint16_t x = 0, y = 0;
|
||||||
uint16_t width = 0, height = 0;
|
uint16_t width = 0, height = 0;
|
||||||
@@ -19,11 +24,10 @@ struct UIElement {
|
|||||||
char *title;
|
char *title;
|
||||||
uint64_t lastUpdate = 0;
|
uint64_t lastUpdate = 0;
|
||||||
uint16_t refreshRate = 0;
|
uint16_t refreshRate = 0;
|
||||||
|
ComponentType type;
|
||||||
|
|
||||||
UIElement(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
UIElement(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
||||||
char *Title);
|
char *Title);
|
||||||
void drawBox();
|
|
||||||
void replaceString(char *oldVal, char *newVal);
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
int16_t getContentAreaX0();
|
int16_t getContentAreaX0();
|
||||||
@@ -39,6 +43,11 @@ struct UIElement {
|
|||||||
void horizontalCenter();
|
void horizontalCenter();
|
||||||
void placeBelow(UIElement *reference);
|
void placeBelow(UIElement *reference);
|
||||||
void placeRight(UIElement *reference);
|
void placeRight(UIElement *reference);
|
||||||
|
|
||||||
|
// Drawing
|
||||||
|
void drawBox();
|
||||||
|
void noBox();
|
||||||
|
void replaceString(char *oldVal, char *newVal);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct UIDecorations {
|
struct UIDecorations {
|
||||||
|
bool hasBorder = true;
|
||||||
uint16_t bgColor = MAIN_BG_COLOR, fgColor = MAIN_FG_COLOR;
|
uint16_t bgColor = MAIN_BG_COLOR, fgColor = MAIN_FG_COLOR;
|
||||||
uint16_t titleColor = MAIN_FG_COLOR, borderColor = RED;
|
uint16_t titleColor = MAIN_FG_COLOR, borderColor = RED;
|
||||||
uint8_t titleSize = 2, textSize = 4;
|
uint8_t titleSize = 2, textSize = 4;
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#include "UIDrawing.h"
|
||||||
|
#include "Arduino_GFX.h"
|
||||||
|
#include "UIComponent.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
/* TODO:
|
||||||
|
* On the placement functions, change 5 to a variable or something
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEBUG
|
||||||
|
|
||||||
|
uint16_t calculateHeight(int16_t titleSize, int16_t textSize, int16_t nLines) {
|
||||||
|
return CHR_HEIGHT(titleSize) + CHR_HEIGHT(textSize) +
|
||||||
|
DEFAULT_TITLE_CONTENT_SPACING +
|
||||||
|
(2 * (DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t calculateWidth(int16_t textSize, int16_t nChars) {
|
||||||
|
return CHR_WIDTH(textSize) * nChars +
|
||||||
|
(2 * (DEFAULT_MARGIN + DEFAULT_BORDER_THICKNESS));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIElement::horizontalCenter() {
|
||||||
|
uint16_t scrW = this->display->width();
|
||||||
|
this->dims.x = (scrW - this->dims.width) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can add a mode of alignment here, center, left, right, whatever
|
||||||
|
void UIElement::placeBelow(UIElement *ref) {
|
||||||
|
// For now the default alignment will be left until I need some other
|
||||||
|
this->dims.x = ref->dims.x;
|
||||||
|
this->dims.y = ref->dims.y + ref->dims.height + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIElement::placeRight(UIElement *ref) {
|
||||||
|
this->dims.x = ref->dims.x + ref->dims.width + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIElement::drawBox() {
|
||||||
|
// This is the border rectangle
|
||||||
|
if (this->decor->hasBorder) {
|
||||||
|
for (int k = 0; k < DEFAULT_BORDER_THICKNESS; k++) {
|
||||||
|
this->display->drawRect(
|
||||||
|
this->dims.x + k, this->dims.y + k, this->dims.width - (k * 2),
|
||||||
|
this->dims.height - (k * 2), this->decor->borderColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// For debugging purpouses
|
||||||
|
// title area
|
||||||
|
int16_t x = 0, y = 0;
|
||||||
|
uint16_t w = 0, h = 0;
|
||||||
|
|
||||||
|
// U8G2 u8g2; // No display pin setup needed since we're only using font data
|
||||||
|
// u8g2.setFont(u8g2_font_9x18_tf);
|
||||||
|
// int ascent = u8g2.getAscent();
|
||||||
|
|
||||||
|
h = this->getTitleAreaHeight();
|
||||||
|
uint16_t titleAreaWidth = this->getTitleAreaWidth();
|
||||||
|
int16_t titleTopLeftX = this->getTitleAreaX0();
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Title area bounds
|
||||||
|
this->display->drawRect(titleTopLeftX, this->getTitleAreaY0(), titleAreaWidth,
|
||||||
|
h, GREEN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// content area
|
||||||
|
x = this->getContentAreaX0();
|
||||||
|
y = this->getContentAreaY0();
|
||||||
|
w = this->getContentAreaWidth();
|
||||||
|
h = this->getContentAreaHeight();
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Content area bounds
|
||||||
|
this->display->drawRect(x, y, w, h, BLUE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (this->decor->hasBorder) {
|
||||||
|
// Remove the border line behind the title
|
||||||
|
this->display->fillRect(titleTopLeftX - DEFAULT_MARGIN, this->dims.y,
|
||||||
|
titleAreaWidth + DEFAULT_MARGIN,
|
||||||
|
DEFAULT_BORDER_THICKNESS, MAIN_BG_COLOR);
|
||||||
|
|
||||||
|
// Render the title
|
||||||
|
this->display->setCursor(titleTopLeftX, this->dims.y);
|
||||||
|
this->display->print(this->title);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Element bounds
|
||||||
|
this->display->drawRect(this->dims.x, this->dims.y, this->dims.width,
|
||||||
|
this->dims.height, PURPLE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -2,9 +2,15 @@
|
|||||||
#include "UIComponent.h"
|
#include "UIComponent.h"
|
||||||
#include <Arduino_GFX.h>
|
#include <Arduino_GFX.h>
|
||||||
|
|
||||||
|
UIString::UIString() : UIElement(nullptr, {0, 0, 0, 0}, nullptr, (char *)"") {
|
||||||
|
this->type = STRING;
|
||||||
|
}
|
||||||
|
|
||||||
UIString::UIString(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
UIString::UIString(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
||||||
char *title)
|
char *title)
|
||||||
: UIElement(d, dims, decor, title) {}
|
: UIElement(d, dims, decor, title) {
|
||||||
|
this->type = STRING;
|
||||||
|
}
|
||||||
|
|
||||||
void UIString::Update(const char *v) {
|
void UIString::Update(const char *v) {
|
||||||
uint64_t time = millis();
|
uint64_t time = millis();
|
||||||
@@ -8,6 +8,7 @@ struct UIString : UIElement {
|
|||||||
static const size_t bufferSize = 256;
|
static const size_t bufferSize = 256;
|
||||||
char value[bufferSize];
|
char value[bufferSize];
|
||||||
|
|
||||||
|
UIString();
|
||||||
UIString(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
UIString(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
||||||
char *title);
|
char *title);
|
||||||
void Update(const char *value);
|
void Update(const char *value);
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#include "UITable.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#include "UIDecorations.h"
|
||||||
|
#include "UIDrawing.h"
|
||||||
|
|
||||||
|
#define DEBUG
|
||||||
|
|
||||||
|
UITable::UITable(Arduino_GFX *gfx, UIDimensions dims, UIDecorations *decor,
|
||||||
|
char *title)
|
||||||
|
: UIElement(gfx, dims, decor, title) {
|
||||||
|
this->type = TABLE;
|
||||||
|
|
||||||
|
// Default decoration for every cell
|
||||||
|
UIDecorations *cellDecor = new UIDecorations();
|
||||||
|
|
||||||
|
for (int k = 0; k < ROWS * COLUMNS; k++) {
|
||||||
|
this->tableData[k].decor = cellDecor;
|
||||||
|
this->tableData[k].dims.x = 0;
|
||||||
|
this->tableData[k].dims.y = 0;
|
||||||
|
this->tableData[k].dims.width = 0;
|
||||||
|
this->tableData[k].dims.height = 0;
|
||||||
|
this->tableData[k].display = this->display;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t UITable::getContentAreaHeight() {
|
||||||
|
return this->dims.height - (DEFAULT_MARGIN * 2) - DEFAULT_BORDER_THICKNESS -
|
||||||
|
this->getTitleAreaHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Very shitty hardcoded function to get this going, only works for th
|
||||||
|
* relative
|
||||||
|
* POS NAME DELTA
|
||||||
|
* 3 | 24 | 5
|
||||||
|
*/
|
||||||
|
void UITable::setup() {
|
||||||
|
// Define the cell dimensions
|
||||||
|
int tableCellW[] = {3 * (CHR_WIDTH(this->decor->textSize) + 2),
|
||||||
|
24 * (CHR_WIDTH(this->decor->textSize) + 2),
|
||||||
|
5 * (CHR_WIDTH(this->decor->textSize) + 2)};
|
||||||
|
int cellH = CHR_HEIGHT(this->decor->textSize) + CELL_MARGIN;
|
||||||
|
|
||||||
|
// Initialize the cells
|
||||||
|
uint16_t yOffset = this->getContentAreaY0();
|
||||||
|
for (int r = 0; r < ROWS; r++) {
|
||||||
|
int16_t xOffset = this->getContentAreaX0();
|
||||||
|
for (int c = 0; c < COLUMNS; c++) {
|
||||||
|
this->tableData[r * COLUMNS + c].decor->textSize = this->decor->textSize;
|
||||||
|
this->tableData[r * COLUMNS + c].decor->hasBorder = false;
|
||||||
|
this->tableData[r * COLUMNS + c].dims.x = xOffset + CELL_MARGIN;
|
||||||
|
this->tableData[r * COLUMNS + c].dims.y = (cellH * r) + yOffset;
|
||||||
|
this->tableData[r * COLUMNS + c].dims.height = cellH;
|
||||||
|
this->tableData[r * COLUMNS + c].dims.width = tableCellW[c];
|
||||||
|
|
||||||
|
xOffset += tableCellW[c];
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
this->tableData[r * COLUMNS + c].drawBox();
|
||||||
|
this->tableData[r * COLUMNS + c].Update("123");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the table dimensions
|
||||||
|
this->dims.height = ROWS * cellH + this->getTitleAreaHeight();
|
||||||
|
this->dims.width =
|
||||||
|
(3 + 24 + 5 + CELL_MARGIN) * CHR_WIDTH(this->decor->textSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITable::initDimensions() {
|
||||||
|
// Calculate the height
|
||||||
|
|
||||||
|
// Calculate the width
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef __UI_TABLE
|
||||||
|
#define __UI_TABLE
|
||||||
|
|
||||||
|
#include "Arduino_GFX.h"
|
||||||
|
#include "UIComponent.h"
|
||||||
|
#include "UIString.h"
|
||||||
|
|
||||||
|
#define COLUMNS 3
|
||||||
|
#define ROWS 5
|
||||||
|
#define CELL_MARGIN 2
|
||||||
|
|
||||||
|
/* Very shitty table element, only works for the relative as of now
|
||||||
|
*/
|
||||||
|
struct UITable : UIElement {
|
||||||
|
// will hold rows * columns UIStrings to fill the table
|
||||||
|
int rows = ROWS;
|
||||||
|
int columns = COLUMNS;
|
||||||
|
UIString tableData[ROWS * COLUMNS];
|
||||||
|
|
||||||
|
UITable(Arduino_GFX *gfx, UIDimensions dims, UIDecorations *decor, char *t);
|
||||||
|
|
||||||
|
// void Update(StandingLine standings[5]);
|
||||||
|
void initDimensions();
|
||||||
|
void setup();
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
uint16_t getContentAreaHeight();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
*.o
|
|
||||||
*.~
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[submodule "sys/arm-linux/c-periphery"]
|
|
||||||
path = sys/arm-linux/c-periphery
|
|
||||||
url = https://github.com/vsergeev/c-periphery
|
|
||||||
Vendored
-10
@@ -1,10 +0,0 @@
|
|||||||
FROM gitpod/workspace-full
|
|
||||||
|
|
||||||
USER gitpod
|
|
||||||
|
|
||||||
# Install custom tools, runtime, etc. using apt-get
|
|
||||||
# For example, the command below would install "bastet" - a command line tetris clone:
|
|
||||||
#
|
|
||||||
# RUN sudo apt-get -q update && # sudo apt-get install -yq bastet && # sudo rm -rf /var/lib/apt/lists/*
|
|
||||||
#
|
|
||||||
# More information: https://www.gitpod.io/docs/config-docker/
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
tasks:
|
|
||||||
- init: cmake .
|
|
||||||
image:
|
|
||||||
file: .gitpod.Dockerfile
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS csrc)
|
|
||||||
file(GLOB COMPONENT_SRCS csrc/*.c)
|
|
||||||
file(GLOB COMPONENT_HDRS csrc/*.h)
|
|
||||||
|
|
||||||
if(COMMAND idf_component_register)
|
|
||||||
idf_component_register(SRCS "${COMPONENT_SRCS}" INCLUDE_DIRS csrc)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
project(u8g2)
|
|
||||||
|
|
||||||
if(COMMAND register_component)
|
|
||||||
set(COMPONENT_NAME ".")
|
|
||||||
register_component()
|
|
||||||
else()
|
|
||||||
add_library(u8g2 ${COMPONENT_SRCS})
|
|
||||||
target_include_directories(u8g2 PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/csrc>" "$<INSTALL_INTERFACE:include>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS u8g2
|
|
||||||
EXPORT u8g2-targets
|
|
||||||
ARCHIVE DESTINATION lib)
|
|
||||||
|
|
||||||
install(FILES ${COMPONENT_HDRS}
|
|
||||||
DESTINATION include/u8g2)
|
|
||||||
|
|
||||||
install(EXPORT u8g2-targets
|
|
||||||
DESTINATION lib/cmake/u8g2)
|
|
||||||
|
|
||||||
install(FILES ${u8g2_SOURCE_DIR}/pkg/u8g2-config.cmake
|
|
||||||
DESTINATION lib/cmake/u8g2)
|
|
||||||
@@ -1,355 +0,0 @@
|
|||||||
|
|
||||||
https://github.com/olikraus/u8g2 ChangeLog
|
|
||||||
|
|
||||||
|
|
||||||
2016-04-30 v2.0.1 olikraus@gmail.com
|
|
||||||
* Support for DOGS102, ST7920, SSD1306
|
|
||||||
* Most graphics primitives are implemented
|
|
||||||
2016-05-15 v2.0.3 olikraus@gmail.com
|
|
||||||
* Support for Adafruit FeatherWing 128x32 OLED
|
|
||||||
* Added Wire.h support (I2C for SSD1306)
|
|
||||||
* Successfully tested with Adafruit ESP8266 Feather Board (HW+SW I2C)
|
|
||||||
* Successfully tested with Adafruit Feather M0 Basic Board (HW+SW I2C)
|
|
||||||
2016-06-12 v2.0.4 olikraus@gmail.com
|
|
||||||
* Support for ST7565
|
|
||||||
2016-06-25 v2.0.6 olikraus@gmail.com
|
|
||||||
* User interface functions
|
|
||||||
* Little Rook Chess ported
|
|
||||||
* ST7920 HW and SW SPI
|
|
||||||
2016-06-26 v2.0.7 olikraus@gmail.com
|
|
||||||
* drawLine
|
|
||||||
* GraphicsTest Example
|
|
||||||
2016-08-09 v2.1.5 olikraus@gmail.com
|
|
||||||
* T6963 Support
|
|
||||||
* Experimental Support for SSD1322 256x64
|
|
||||||
* A2 Thermoprinter Support
|
|
||||||
* Added several fonts from http://int10h.org/oldschool-pc-fonts/
|
|
||||||
* Added Arabic, Greek and Cyrillic fonts.
|
|
||||||
* Code cleanup (assert, spi modes, void * warning)
|
|
||||||
2016-08-17 v2.2.7 olikraus@gmail.com
|
|
||||||
* U8x8: Upscale by 2 (Issue 41)
|
|
||||||
* Fixed SSD1306 I2C procedures (mirror pixel in last tile column, issue 44)
|
|
||||||
* Experimental support für mini12864 (pull request)
|
|
||||||
* Use beginTransaction for SPI. This requires Arduino 1.6.0
|
|
||||||
2016-08-18 v2.3.2 olikraus@gmail.com
|
|
||||||
* MINI12874; Fixed HW Flip Mode (pull request 49)
|
|
||||||
* Fixed ST7920 HW SPI with very fast uC, issue 50
|
|
||||||
* Improved HW SPI for SH1106 and SSD1306 displays
|
|
||||||
* Fixed issue with missing fonts
|
|
||||||
2016-08-21 v2.4.1 olikraus@gmail.com
|
|
||||||
* Fixed HW SPI Modes (issue 52)
|
|
||||||
2016-10-01 v2.5.2 olikraus@gmail.com
|
|
||||||
* Added crox fonts (issue 57)
|
|
||||||
* Support for RA8835 (issue 45)
|
|
||||||
* Added support for SSD1322 and SSD1325
|
|
||||||
* Added DrawXBMP (AVR: Assume bitmap in PROGMEM)
|
|
||||||
* Added japanese fonts (issue 65)
|
|
||||||
2016-11-13 v2.6.3 olikraus@gmail.com
|
|
||||||
* Added support for UC1610 (EA DOGXL160)
|
|
||||||
* Use Wire.setClock() for improved HW I2C performance (issue 79). This
|
|
||||||
requires Arduino IDE 1.6.0 or higher.
|
|
||||||
* Added Thai Fonts (issue 73)
|
|
||||||
* Added support for "\n" in the print function for u8x8 (issue 74)
|
|
||||||
* Screen mirror option for U8g2 (issue 76)
|
|
||||||
* Added support for second wire interface (Constructor postfix 2ND_HW_I2C)
|
|
||||||
* Added support for UC1611 (EA DOGM240 and EA DOGXL240, issue 66)
|
|
||||||
2016-11-28 v2.7.5 olikraus@gmail.com
|
|
||||||
* Added support for 0.66" 64x48 SSD1306 OLED (issue 89)
|
|
||||||
* Support for UC1608 (issue 92)
|
|
||||||
* Speed improvements for SW SPI und 8080 mode (issues 87, 90 and 95)
|
|
||||||
* Fixed issue with ST7920 not using the optimized SW SPI procedures (issue 87)
|
|
||||||
* Direct buffer API (issue 93)
|
|
||||||
2016-12-11 v2.8.4 olikraus@gmail.com
|
|
||||||
* Increased contrast range for SSD1306 (issue 98)
|
|
||||||
* Support for KS0108 (issue 88)
|
|
||||||
* Support for UC1608 240x128 (issue 101)
|
|
||||||
* Speed improvement (issue 96)
|
|
||||||
2016-12-12 v2.8.5 olikraus@gmail.com
|
|
||||||
* Bugfix for issue 96 (issue 106)
|
|
||||||
2016-12-20 v2.9.1 olikraus@gmail.com
|
|
||||||
* Speed improvement for AVR/KS0108 (issue 104)
|
|
||||||
* Support for UC1604 (issue 111)
|
|
||||||
* Support for PCD8544/Nokia Display (issue 107)
|
|
||||||
* Change/fixed behavior of userInterfaceSelectionList (issue 112)
|
|
||||||
2016-12-23 v2.9.2 olikraus@gmail.com
|
|
||||||
* Reverted the setup for SSD1306_NONAME to the original setup (undo issue 98)
|
|
||||||
* Introduced SSD1306_VCOMH0 for the max range setup (issue 116)
|
|
||||||
2016-12-30 v2.10.1 olikraus@gmail.com
|
|
||||||
* ST7565 LM6059 Display (issue 123)
|
|
||||||
* SSD1606 eInk/ePaper Display (issue 100)
|
|
||||||
* Documentation updates
|
|
||||||
2017-01-08 v2.11.4 olikraus@gmail.com
|
|
||||||
* Support for LC7981 (issue 134)
|
|
||||||
* Support for PCF8812 (issue 135)
|
|
||||||
* Fixed wrong half-move notation in Little Rook Chess (issue 137)
|
|
||||||
* Support for ST7567, Pax Instruments GLCD Shield (issue 138)
|
|
||||||
* Support for NT7534 (issue 143)
|
|
||||||
* Support for SSD1327, Seeedstudio OLED (issue 145)
|
|
||||||
* Support for SSD1305 (issue 146)
|
|
||||||
* Support for DOGM132 (issue 147)
|
|
||||||
* Fixed a bug in the draw pixel procedure which appears in full buffer mode,
|
|
||||||
if the display width is not a multiple of 8 (issue 148)
|
|
||||||
* Added XOR mode (setDrawColor 2, issue 56)
|
|
||||||
2017-01-15 v2.12.6 olikraus@gmail.com
|
|
||||||
* Support for SSD1309 (issue 113)
|
|
||||||
* Enabled U8G2_HVLINE_SPEED_OPTIMIZATION (not sure why this was disabled)
|
|
||||||
* Improved speed for ST7920 (up to 40%, issue 151)
|
|
||||||
* Support for IST3020 (issue 153)
|
|
||||||
2017-02-07 v2.13.6 olikraus@gmail.com
|
|
||||||
* Support for ST7588 (issue 154)
|
|
||||||
* ESP8266: Avoid RAM copy of the fonts (issue 159)
|
|
||||||
* Support for SSD1607 (issue 133)
|
|
||||||
* Support for hardware pin remapping on the ESP8266 (issue 158)
|
|
||||||
* Bugfix for the KS0108 support (issue 168)
|
|
||||||
* More fonts: https://github.com/olikraus/u8g2/wiki/fntgrpnbp (issue 174)
|
|
||||||
2017-03-11 v2.14.7 olikraus@gmail.com
|
|
||||||
* Bugfix: setFont does no longer resets the reference position (issue 195)
|
|
||||||
* Support for ST7565 NHD C12864 (issue 186)
|
|
||||||
* Support for SSD1329 128x96 OLED (issue 208)
|
|
||||||
* Support for LC7981 240x128 (issue 193)
|
|
||||||
* Performance improvement for the ST7920 (issue 200)
|
|
||||||
2017-05-22 v2.15.2 olikraus@gmail.com
|
|
||||||
* Added setBitmapMode (pull request 220)
|
|
||||||
Warning: Default behavior of drawXBM has changed in this release.
|
|
||||||
* Increased SPI speed to 8MHz for SSD1306, SH1106 and SSD1322 (issue 215)
|
|
||||||
* Added some more examples (issue 216)
|
|
||||||
* Added Urdu, Bengali, Hebrew and Polish language fonts (issues 221, 246 and 266)
|
|
||||||
* Added more examples (issue 216)
|
|
||||||
* Updated code for NHD C12864 (issues 219 and 241)
|
|
||||||
* Improved speed for HW SPI with SSD13xx OLEDs (issue 215)
|
|
||||||
2017-08-12 v2.16.9 olikraus@gmail.com
|
|
||||||
* Fonts u8g2_font_unifont_t_korean1, u8g2_font_unifont_t_korean2 (issue 266)
|
|
||||||
* Added support for 64128N ST7565 based display (issue 292)
|
|
||||||
* Added extended fonts (_te, unicodes 32-701, issue 284)
|
|
||||||
* Added support for MAX7219 (issue 280)
|
|
||||||
* Performance optimization for SSD1322/25/27 (issue 302)
|
|
||||||
* Fixed setContrast for SSD1322 (issue 328)
|
|
||||||
* Support for 96x16 SSD1306 OLED (issue 295)
|
|
||||||
* Fixed OldStandard-Bold fonts (osb, issue 306)
|
|
||||||
* Support for SED1520/SBN1661 (issue 324)
|
|
||||||
2017-09-10 v2.17.11 olikraus@gmail.com
|
|
||||||
* Additional _m_ and _h_ symbol fonts (issue 335)
|
|
||||||
* Added parallel interfaces for several UC16xx devices (issue 339)
|
|
||||||
* Support for IL3820, WaveShare 2.9" e-paper (issues 318 & 347)
|
|
||||||
* Improved debounce algorithm (issue 338)
|
|
||||||
* Power save mode for SSD1607 device (issue 352)
|
|
||||||
2017-09-30 v2.18.13 olikraus@gmail.com
|
|
||||||
* Support for ST7567_JLX12864 (issue 365)
|
|
||||||
* Support for UC1611 (no "s") (issue 339)
|
|
||||||
* Fixed several issues related to the _F_ (full buffer) mode (issue 370)
|
|
||||||
2017-10-13 v2.19.8 olikraus@gmail.com
|
|
||||||
* Support for UC1601 (issue 378)
|
|
||||||
* Support for ESP32 I2C pin remapping (issue 377)
|
|
||||||
* Support for ST75256 (SPI), JLX256128, JLX172104 (issue 163)
|
|
||||||
* Added uw-ttyp0 fonts (issue 349)
|
|
||||||
2017-12-09 v2.20.13 olikraus@gmail.com
|
|
||||||
* Bugfix for drawBitmap (issue 391)
|
|
||||||
* I2C support for ST75256 (issue 384)
|
|
||||||
* Support for SSD1327 128x128 display (issue 397)
|
|
||||||
* Support for ST75256 JLX25664 display (issue 399)
|
|
||||||
* Added keywords.txt (issue 402)
|
|
||||||
* Experimental support for SSD1326 (issue 398)
|
|
||||||
* Experimental alternative COM config for SSD1306 128x64 (issue 408)
|
|
||||||
* New SH1106 init sequence (SH1106_WINSTAR, issue 316)
|
|
||||||
* Support for SSD1322 NHD 128x64 (issue 412)
|
|
||||||
* Fixed profont17 (issue 438)
|
|
||||||
2018-02-18 v2.21.8 olikraus@gmail.com
|
|
||||||
* Support for SH1107 (issue 501)
|
|
||||||
* Support for HX1230 (issue 469)
|
|
||||||
* Bugfix for displays with display height not a multiple of 8 (issue 469)
|
|
||||||
* FontUsage demo for full buffer mode (issue 490)
|
|
||||||
* Added 1x2 (double height) draw procedures to U8x8 (issue 474)
|
|
||||||
With this feature a 128x32 display can replace a 16x2 Char LCD.
|
|
||||||
* New constructor for the Good Display 200x200 eInk (issue 454)
|
|
||||||
* Update for the ST7920 device for more stable output (issue 487)
|
|
||||||
* Double height (2x1) chars for U8x8 API (issue 474)
|
|
||||||
* Excluded I2C for several ATMega uC which do not have HW I2C (issue 508)
|
|
||||||
* Fixed UC1610 contrast command (issue 428)
|
|
||||||
* Added WQY Chinese fonts at sizes 12, 13, 14, 15 and 16
|
|
||||||
including gb2312 support (issue 455)
|
|
||||||
* Added new full buffer demo for the Chinese fonts (Shennong.ino, issue #455)
|
|
||||||
* Added siji icon font u8g2_font_siji_t_6x10 (issue 451)
|
|
||||||
2018-04-30 v2.22.18 olikraus@gmail.com
|
|
||||||
* Bugfix for draw1x2string (u8x8 API)
|
|
||||||
* Changed return value for "begin()" (issue 518)
|
|
||||||
* New feature: U8log, https://github.com/olikraus/u8g2/wiki/u8logreference
|
|
||||||
* Added SSD1306 128x64 Adafruit OLED (issue 521)
|
|
||||||
* Added Winstart SSD1306 64x48 OLED variant (issue 522)
|
|
||||||
* Added support for JLX240160 (issue 556)
|
|
||||||
* Added support for JLX12864 (ST7565 variant, issue 440)
|
|
||||||
* Added support for JLX256160 (issue 561)
|
|
||||||
* Added support for SH1122 256x64 OLED (issue 420)
|
|
||||||
* Added open iconic icons (issue 535)
|
|
||||||
* Added several Persian fonts (issue 541)
|
|
||||||
* Added additional Japanese font variants (issue 581)
|
|
||||||
* Added Devanagari/Hindi font variant (issue 584)
|
|
||||||
* Added tom-thumb font (issue 563)
|
|
||||||
* Added AVR specific optimization for 3-wire Software SPI (issue 586)
|
|
||||||
2018-08-24 v2.23.18 olikraus@gmail.com
|
|
||||||
* NEW FONT FORMAT for speedup of the unicode font section (issue 596)
|
|
||||||
* Fixed a bug in the font construction for monospaced fonts (issue 669)
|
|
||||||
* Fixed a bug with the CS line for huge KS0108 displays (issue 631)
|
|
||||||
* Fixed #if's for some AVR uC (issue 662)
|
|
||||||
* Added support for SH1108 controller (issue 619)
|
|
||||||
* Added support for T6963 160x80 Displays (issue 635)
|
|
||||||
* Added support for EA W128128 (issue 641)
|
|
||||||
* Added support for LC7981 240x64 (issue 642)
|
|
||||||
* Added support for ST7567 ENH-DG128064 (issue 616)
|
|
||||||
* Included pull request for ST7586, support for ERC240160 & s028hn118a (pull request 660)
|
|
||||||
* Added SpaceTrash game (issue 622)
|
|
||||||
* Added contributed 7-segment font, https://github.com/olikraus/u8g2/wiki/fntgrpu8g#7segments_26x42 (issue 634)
|
|
||||||
* Added several fonts from fontstruct.com, https://github.com/olikraus/u8g2/wiki/fntgrpfontstruct (issue 687)#
|
|
||||||
This also includes several outline fonts.
|
|
||||||
2018-10-28 v2.24.3 olikraus@gmail.com
|
|
||||||
* Added clip window support (issue 364)
|
|
||||||
* Added setBusClock() proc to change the I2C/SPI bus clock speed (Arduino only, issue 705)
|
|
||||||
* Added sleep mode for ST7920 (issue 245)
|
|
||||||
* Added support for SSD0323 (issue 720)
|
|
||||||
2019-02-09 v2.25.10 olikraus@gmail.com
|
|
||||||
* Improved speed for I2C with SSD1306 controller: 4% faster now (issue 735)
|
|
||||||
* Fixed code problems (issues 766 and 754)
|
|
||||||
* Added battery symbols and emoticons (issue 747)
|
|
||||||
* New U8x8 font format, added large U8x8 fonts (issue 771)
|
|
||||||
* Added alternative version for ERC12864 (issue 790)
|
|
||||||
* Added Waveshare SSD1607 200x200 support (issue 637)
|
|
||||||
* Added support for SSD1318 (issue 784)
|
|
||||||
* Partial display update with updateDisplayArea (issue 736)
|
|
||||||
* Several new decorative and fancy fonts from pentacom.jp (issue 801)
|
|
||||||
2019-06-30 v2.26.14 olikraus@gmail.com
|
|
||||||
* Support for Pimoroni 128x128 OLED SH1107 (issue 803)
|
|
||||||
* Support for Grove 128x128 OLED SH1107 (issue 877)
|
|
||||||
* Support for Winstar 256x128 ST75256 (ST75256_WO256X128, issue 891)
|
|
||||||
* Bugfix: Open Iconic 1x for U8x8 (issue 828)
|
|
||||||
* Added sendF command for direct communication with the display (issues 822, 878, 896)
|
|
||||||
* Support for CG160160 UC1611 (issue 884)
|
|
||||||
* Support for LM6063 128x64 ST7565 (issue 893)
|
|
||||||
* Added fonts from pentacom (issue 810)
|
|
||||||
* Support for ST7511 (issue 876)
|
|
||||||
* Support for SSD1316 132x32 (issue 919)
|
|
||||||
* Support for ST75320 (issue 921)
|
|
||||||
* Added JLX256160M for mirrored version of the JLX256160 display (issue 930)
|
|
||||||
* Unifont update to 12.1.02, added several plane 1 fonts (issue 931)
|
|
||||||
* bdfconv.exe: Windows exe created, bugfix with -d option (issue 833)
|
|
||||||
2020-01-27 v2.27.6 olikraus@gmail.com
|
|
||||||
* Support for IST7920 (issue 999). Note: IST7920 has nothing todo with ST7920
|
|
||||||
* Added screenshot/screencapture for full buffer mode (issue 1005)
|
|
||||||
See: https://github.com/olikraus/u8g2/wiki/u8g2reference#writebufferpbm
|
|
||||||
* Bugfix for draw 1x2 and 2x2 procedures for big 8x8 fonts (issue 1054)
|
|
||||||
* Added fast software SPI support for Arduino Nano Every (issue 987)
|
|
||||||
* Added "LoadFromSD" example to demonstrate reading XBM binary from SD card (issue #1059)
|
|
||||||
* Added png to XBM binary conversion tool (https://github.com/olikraus/u8g2/tree/master/tools/png2bin)
|
|
||||||
* Support for SSD1306 72x40 (issue 1047)
|
|
||||||
* Bugfix for print() and setFontDirection() (issue 963)
|
|
||||||
* Support for Visionox SSD1327 128x96 OLED (issue 1090)
|
|
||||||
* Support for Open-Smart ST7567 128x64 LCD (issue 1088)
|
|
||||||
* Added Lucida X11 fonts (issue 271)
|
|
||||||
* Added several fonts from dafont.com (issue 1093)
|
|
||||||
* Added 3-wire HW SPI (issue 1041)
|
|
||||||
2020-12-28 v2.28.10 olikraus@gmail.com
|
|
||||||
* Added Euro Symbol to _te fonts (issue 1321)
|
|
||||||
* Added support for ST7528 (issue 986)
|
|
||||||
* Added support for ST7571 (issue 1298)
|
|
||||||
* Added support for ST7586 YMC240160 (issue 1183)
|
|
||||||
* Added support for UC1617 JLX128128 (issue 1151)
|
|
||||||
* Added support for SH1106 Visionox 128X32 (issue 1250)
|
|
||||||
* Added support for Raystar SSD1305 (issue 1111)
|
|
||||||
* Added support for KS0713 controller (issue 1314)
|
|
||||||
* Added support for ST7567_HEM6432 (issue 1159)
|
|
||||||
* U8g2 16 Bit Mode enabled by default for ARM and ESP Systems (issue 1222)
|
|
||||||
2021-09-03 v2.29.11 olikraus@gmail.com
|
|
||||||
* Update for getStrWidth/getUTF8Width: The new return value might be little bit larger (issue 1561)
|
|
||||||
* New draw procedure drawButtonUTF8 (issue 1577)
|
|
||||||
* Added vertical mirror option U8G2_MIRROR_VERTICAL for u8g2 (mattnutsch@gmail.com, issue 1474).
|
|
||||||
* Added support for UC1638 based 196x96 display (issue 371)
|
|
||||||
* Added support for HD44102 and T7932 displays (issue 1492)
|
|
||||||
* Added support for SSD1320 (issue 1351)
|
|
||||||
* Added support for S1D15721 (issue 1473)
|
|
||||||
* Added support for SSD1306 EA OLEDS102 (issue 1493)
|
|
||||||
* Added support for UC1601 128x64 (issue 1501)
|
|
||||||
* Font Wiki page splitted into four sub-pages to avoid the GitHub 'abuse' message.
|
|
||||||
2021-09-07 v2.30.1 olikraus@gmail.com
|
|
||||||
* Bugfix drawButtonUTF8 (added C++ code, issue 1577)
|
|
||||||
2021-09-19 v2.31.1 olikraus@gmail.com
|
|
||||||
* Added icons from https://app.streamlinehq.com/icons/pixel (issue 1589)
|
|
||||||
2021-09-20 v2.31.2 olikraus@gmail.com
|
|
||||||
* Bugfix release for include error (issues 1592 and 1594)
|
|
||||||
2022-04-03 v2.32.15 olikraus@gmail.com
|
|
||||||
* SH1107 128x80 (issue 1598)
|
|
||||||
* ST7920 256x32 (issue 1593)
|
|
||||||
* ST7567 122x32 (issue 1759)
|
|
||||||
* ST7571 128X96 (issue 1575)
|
|
||||||
* SSD1312 (issue 1806)
|
|
||||||
* ST7571 128x128 (bugfix issue 1576)
|
|
||||||
* Added support for UC1609 (issue 1565)
|
|
||||||
* Added support for GU800 series of Vacuum Fluorescent Displays (VFD, issue 1604)
|
|
||||||
* Changed SPI Mode for Sharp displays (ls013..., issue 1771)
|
|
||||||
* Added many more fonts (issues 1794, 1775, 1706, 1769)
|
|
||||||
* Fixed several bugs and compiler errors
|
|
||||||
2022-09-04 v2.33.15 olikraus@gmail.com
|
|
||||||
* ST7567 ERC13232 (issue 1869)
|
|
||||||
* Bugfix for ST7567: (re-)added I2C and 3-wire-SPI (issue 1939)
|
|
||||||
* ST7920 160x32 (issue 1873)
|
|
||||||
* ST7586 JLX384160 (issue 1932)
|
|
||||||
* LC7981 128X128, NOT TESTED (issue 1913)
|
|
||||||
* SSD1316 96x32 (issue 1938, not tested, moved to 2.34.x)
|
|
||||||
* GP1287AI 256X50, GP1247AI 253X63 contributed (issue 1907)
|
|
||||||
* Added support for IST3088 (issue 1887)
|
|
||||||
* Double size font functions: drawGlyphX2, drawStrX2, drawUTF8X2 (issue 1919)
|
|
||||||
* Experimental support for ST75160, TESTING REQUIRED (issue 1642)
|
|
||||||
* Bugfix font compression: Reduced fontsize by up to 4% (issue 1941)
|
|
||||||
* Changed SPI mode for SH1106 from 3 to 0 (issue 1901)
|
|
||||||
2023-06-18 v2.34.22 olikraus@gmail.com
|
|
||||||
* SSD1327 ZJY M150 128x128 (issue 1960)
|
|
||||||
* SSD1316 96x32 (issue 1938)
|
|
||||||
* SSD1322 240x128 (issue 2092)
|
|
||||||
* SH1108 128x160 (issue 1998)
|
|
||||||
* SSD1306 96x39 (issue 1959)
|
|
||||||
* S1D15300 128x64, flip mode 1 not supported, (issue 2063)
|
|
||||||
* SSD1362 256x64 (issue 1322, issue 2051)
|
|
||||||
* ST75256 JLX160x80 (NOT TESTED, issue 2058)
|
|
||||||
* UC1638 240x128 (issue 2075)
|
|
||||||
* SED1330 320x200 (issue 1086)
|
|
||||||
* Bugfix: Clear font_height_mode during setup to ensure correct default values in
|
|
||||||
cases where the u8g2 struct / class is created via dynamic memory allocation (issue 2046)
|
|
||||||
* Bugfix: Fix line draw procedure in 16 bit mode (issue 2053)
|
|
||||||
* Added Spleen Monospaced Font from https://github.com/fcambus/spleen (issue 2015)
|
|
||||||
* Extended the "E" font range with subscript characters if available in the original font (issue 2079)
|
|
||||||
* Bugfix for ESP32 HW SPI Pin Remapping (issue 377, PR 2123)
|
|
||||||
* Bugfix for LoadFromSD example (issue 2179)
|
|
||||||
* Changed MUI_LABEL to support UTF8 (issue 2196)
|
|
||||||
* Compiler Warning Cleanup for polygon draw (issue 1999, PR 2101)
|
|
||||||
* Added MUI fixed width bar graph (issue 2200)
|
|
||||||
* Added 04b fonts from u8glib (issue 2157)
|
|
||||||
* Added "font_tiny5" (issue 2185)
|
|
||||||
* Added MUI (https://github.com/olikraus/u8g2/wiki/muimanual) examples (issue 1747)
|
|
||||||
2024-09-18 v2.35.30 olikraus@gmail.com
|
|
||||||
* ST7586S JLX320160, MD240128 (no flipmode, no u8x8, issues 2186, 2363)
|
|
||||||
* ST75161 JLX160160 (issue 2481)
|
|
||||||
* GP1294AI 256X48 (issue 2213, PR 2222)
|
|
||||||
* UC1628 256x128 (tested), 256x32 (tested), 128x64 (not tested) (issue 2260):
|
|
||||||
* ST7567 96x65 (issue 2332)
|
|
||||||
* ST7539 192x64 (issues 2146 & 2081)
|
|
||||||
* SSD1363 256x128 (issue 2490)
|
|
||||||
* SSD1322 ZJY 256x64 (issue 2386)
|
|
||||||
* UC1604 JLX128x64 (issue 2497)
|
|
||||||
* LS011B7DH03 160x68 (issue 2210)
|
|
||||||
* ST7302 122x250 (no flipmode, no u8x8, issue 2436)
|
|
||||||
* U8x8 example for 90 degree string rotation (issue 2271)
|
|
||||||
* Bugfix for drawUTF8X2 with negative x values (issue 2228)
|
|
||||||
* Examples for I2C adapter board for parallel gfx displays (issue 2191)
|
|
||||||
* New function drawArc (issue 2243, see also https://motla.github.io/arc-algorithm/)
|
|
||||||
* Added "-y" option to otf2bdf. "-y" can be used to fix issues with some fonts (issue 2406)
|
|
||||||
* Fixed a bug with '\n' in u8log (issue 2319)
|
|
||||||
* getXOffset for font glyphs (issue 2398)
|
|
||||||
* Improved performance for drawXBM/drawXBMP (issue 2477)
|
|
||||||
* Unifont upgrade from 12.1.02 to 15.1.05 (issue 2502)
|
|
||||||
* Added unifont_jp (issue 2502)
|
|
||||||
* Added BoutiqueBitmap fonts (issue 2265)
|
|
||||||
* MUI: More features and examples
|
|
||||||
2025-xx-xx v2.36.xx olikraus@gmail.com
|
|
||||||
* SED1330 240x64 (issue 2518)
|
|
||||||
* SSD1309 128x128 (issue 2546)
|
|
||||||
* ST7571 128x96 (issue 2575)
|
|
||||||
* SSD1320 128x72 (issue 2565)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
|
|
||||||
The U8g2lib code (https://github.com/olikraus/u8g2) is licensed under the terms of
|
|
||||||
the new-bsd license (two-clause bsd license).
|
|
||||||
See also: http://www.opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
Fonts are licensed under different conditions.
|
|
||||||
See
|
|
||||||
https://github.com/olikraus/u8g2/wiki/fntgrp
|
|
||||||
for detailed information on the licensing conditions for each font.
|
|
||||||
|
|
||||||
The example code in sys/raspi_gpio/hal will use the bcm2835 lib from Mike McCauley
|
|
||||||
which is licensed under GPL V3: http://www.airspayce.com/mikem/bcm2835/
|
|
||||||
|
|
||||||
============ X11 Fonts COUR, HELV, NCEN, TIM, SYMB ============
|
|
||||||
|
|
||||||
For fonts derived from the following files, the license below applies.
|
|
||||||
COURB08.BDF COURB10.BDF COURB12.BDF COURB14.BDF COURB18.BDF
|
|
||||||
COURB24.BDF COURR08.BDF COURR10.BDF COURR12.BDF COURR14.BDF
|
|
||||||
COURR18.BDF COURR24.BDF HELVB08.BDF HELVB10.BDF HELVB12.BDF HELVB14.BDF
|
|
||||||
HELVB18.BDF HELVB24.BDF HELVR08.BDF HELVR10.BDF HELVR12.BDF HELVR14.BDF
|
|
||||||
HELVR18.BDF HELVR24.BDF NCENB08.BDF NCENB10.BDF NCENB12.BDF
|
|
||||||
NCENB14.BDF NCENB18.BDF NCENB24.BDF NCENR08.BDF NCENR10.BDF
|
|
||||||
NCENR12.BDF NCENR14.BDF NCENR18.BDF NCENR24.BDF SYMB08.BDF SYMB10.BDF
|
|
||||||
SYMB12.BDF SYMB14.BDF SYMB18.BDF SYMB24.BDF TIMB08.BDF TIMB10.BDF
|
|
||||||
TIMB12.BDF TIMB14.BDF TIMB18.BDF TIMB24.BDF TIMR08.BDF TIMR10.BDF
|
|
||||||
TIMR12.BDF TIMR14.BDF TIMR18.BDF TIMR24.BDF
|
|
||||||
|
|
||||||
Copyright 1984-1989, 1994 Adobe Systems Incorporated.
|
|
||||||
Copyright 1988, 1994 Digital Equipment Corporation.
|
|
||||||
|
|
||||||
Adobe is a trademark of Adobe Systems Incorporated which may be
|
|
||||||
registered in certain jurisdictions.
|
|
||||||
Permission to use these trademarks is hereby granted only in
|
|
||||||
association with the images described in this file.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute and sell this software
|
|
||||||
and its documentation for any purpose and without fee is hereby
|
|
||||||
granted, provided that the above copyright notices appear in all
|
|
||||||
copies and that both those copyright notices and this permission
|
|
||||||
notice appear in supporting documentation, and that the names of
|
|
||||||
Adobe Systems and Digital Equipment Corporation not be used in
|
|
||||||
advertising or publicity pertaining to distribution of the software
|
|
||||||
without specific, written prior permission. Adobe Systems and
|
|
||||||
Digital Equipment Corporation make no representations about the
|
|
||||||
suitability of this software for any purpose. It is provided "as
|
|
||||||
is" without express or implied warranty.
|
|
||||||
|
|
||||||
|
|
||||||
============ BSD License for U8g2lib Code ============
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
[](https://gitpod.io/#https://github.com/olikraus/u8g2)
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
U8g2: Library for monochrome displays, version 2
|
|
||||||
|
|
||||||
U8g2 is a monochrome graphics library for embedded devices.
|
|
||||||
U8g2 supports monochrome OLEDs and LCDs, which include the following controllers:
|
|
||||||
SSD1305, SSD1306, SSD1309, SSD1312, SSD1316, SSD1318, SSD1320, SSD1322,
|
|
||||||
SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, SH1107, SH1108, SH1122,
|
|
||||||
T6963, RA8835, LC7981, PCD8544, PCF8812, HX1230, UC1601, UC1604, UC1608, UC1610,
|
|
||||||
UC1611, UC1617, UC1638, UC1701, ST7511, ST7528, ST7565, ST7567, ST7571, ST7586,
|
|
||||||
ST7588, ST75160, ST75256, ST75320, NT7534, ST7920, IST3020, IST3088, IST7920,
|
|
||||||
LD7032, KS0108, KS0713, HD44102, T7932, SED1520, SBN1661, IL3820, MAX7219,
|
|
||||||
GP1287, GP1247, GU800
|
|
||||||
(see [here](https://github.com/olikraus/u8g2/wiki/u8g2setupcpp) for a full list).
|
|
||||||
|
|
||||||
The Arduino library U8g2 can be installed from the library manager of the Arduino IDE. U8g2 also includes U8x8 library:
|
|
||||||
* U8g2
|
|
||||||
* Includes all graphics procedures (line/box/circle draw).
|
|
||||||
* Supports many fonts. (Almost) no restriction on the font height.
|
|
||||||
* Requires some memory in the microcontroller to render the display.
|
|
||||||
* U8x8
|
|
||||||
* Text output only (character) device.
|
|
||||||
* Only fonts allowed with fit into a 8x8 pixel grid.
|
|
||||||
* Writes directly to the display. No buffer in the microcontroller required.
|
|
||||||
|
|
||||||
|
|
||||||
[Setup Guide and Reference Manual](https://github.com/olikraus/u8g2/wiki)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# RT-Thread building script for bridge
|
|
||||||
|
|
||||||
import os
|
|
||||||
from building import *
|
|
||||||
|
|
||||||
objs = []
|
|
||||||
cwd = GetCurrentDir()
|
|
||||||
|
|
||||||
objs = objs + SConscript(cwd + '/sys/rt-thread/SConscript')
|
|
||||||
|
|
||||||
Return('objs')
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
COMPONENT_SRCDIRS:=csrc
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS:=csrc
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
MUIU8g2.h
|
|
||||||
|
|
||||||
C++ Arduino wrapper for mui.h (monochome minimal user interface)
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef MUIU8G2_HH
|
|
||||||
#define MUIU8G2_HH
|
|
||||||
|
|
||||||
#include "mui.h"
|
|
||||||
#include "mui_u8g2.h"
|
|
||||||
|
|
||||||
class MUIU8G2
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
mui_t mui;
|
|
||||||
public:
|
|
||||||
MUIU8G2(void) { }
|
|
||||||
|
|
||||||
MUIU8G2(U8G2 &u8g2, fds_t *fds, muif_t *muif_list, size_t muif_cnt) {
|
|
||||||
mui_Init(&mui, (void *)u8g2.getU8g2(), fds, muif_list, muif_cnt);
|
|
||||||
}
|
|
||||||
void begin(U8G2 &u8g2, fds_t *fds, muif_t *muif_list, size_t muif_cnt) {
|
|
||||||
mui_Init(&mui, (void *)u8g2.getU8g2(), fds, muif_list, muif_cnt);
|
|
||||||
}
|
|
||||||
mui_t *getMUI(void) { return &mui; }
|
|
||||||
|
|
||||||
uint8_t getCurrentCursorFocusPosition(void) { return mui_GetCurrentCursorFocusPosition(&mui); }
|
|
||||||
|
|
||||||
int getCurrentFormId(void) { return mui_GetCurrentFormId(&mui); }
|
|
||||||
|
|
||||||
|
|
||||||
void draw(void) { mui_Draw(&mui); }
|
|
||||||
//void getSelectableFieldTextOption(fds_t *fds, uint8_t nth_token)
|
|
||||||
// { mui_GetSelectableFieldTextOption(&mui, fds, nth_token); }
|
|
||||||
void enterForm(fds_t *fds, uint8_t initial_cursor_position) { mui_EnterForm(&mui, fds, initial_cursor_position); }
|
|
||||||
void leaveForm(void) { mui_LeaveForm(&mui); }
|
|
||||||
uint8_t gotoForm(uint8_t form_id, uint8_t initial_cursor_position) { return mui_GotoForm(&mui, form_id, initial_cursor_position); }
|
|
||||||
|
|
||||||
void saveForm(void) { mui_SaveForm(&mui); }
|
|
||||||
void restoreForm(void) { mui_RestoreForm(&mui); }
|
|
||||||
void nextField(void) { mui_NextField(&mui); }
|
|
||||||
void prevField(void) { mui_PrevField(&mui); }
|
|
||||||
void sendSelect(void) { mui_SendSelect(&mui); }
|
|
||||||
|
|
||||||
void sendSelectWithExecuteOnSelectFieldSearch(void) { mui_SendSelectWithExecuteOnSelectFieldSearch(&mui); }
|
|
||||||
|
|
||||||
|
|
||||||
int isFormActive(void) { return mui_IsFormActive(&mui); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* MUIU8G2_HH */
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
U8g2lib.cpp
|
|
||||||
|
|
||||||
Arduino specific functions
|
|
||||||
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "U8g2lib.h"
|
|
||||||
|
|
||||||
#ifdef ARDUINO
|
|
||||||
static Print *u8g2_print_for_screenshot;
|
|
||||||
|
|
||||||
void u8g2_print_callback(const char *s)
|
|
||||||
{
|
|
||||||
yield();
|
|
||||||
u8g2_print_for_screenshot->print(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void U8G2::writeBufferPBM(Print &p)
|
|
||||||
{
|
|
||||||
u8g2_print_for_screenshot = &p;
|
|
||||||
u8g2_WriteBufferPBM(getU8g2(), u8g2_print_callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void U8G2::writeBufferXBM(Print &p)
|
|
||||||
{
|
|
||||||
u8g2_print_for_screenshot = &p;
|
|
||||||
u8g2_WriteBufferXBM(getU8g2(), u8g2_print_callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void U8G2::writeBufferPBM2(Print &p)
|
|
||||||
{
|
|
||||||
u8g2_print_for_screenshot = &p;
|
|
||||||
u8g2_WriteBufferPBM2(getU8g2(), u8g2_print_callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void U8G2::writeBufferXBM2(Print &p)
|
|
||||||
{
|
|
||||||
u8g2_print_for_screenshot = &p;
|
|
||||||
u8g2_WriteBufferXBM2(getU8g2(), u8g2_print_callback);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
-1004
File diff suppressed because it is too large
Load Diff
@@ -1,614 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
mui.h
|
|
||||||
|
|
||||||
Monochrome minimal user interface: Core library.
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2021, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
MUIF (Monochrome User Interface Functions)
|
|
||||||
n: A number 0 to 9 without any quotes, e.g.: 5
|
|
||||||
id: Exactly two characters or numbers in double quotes, e.g. "G5".
|
|
||||||
cb: A callback function with the following prototype: "uint8_t muif_cb(mui_t *ui, uint8_t msg)"
|
|
||||||
There are MANY predefined callback functions, see separate list
|
|
||||||
var: Address of a variable.
|
|
||||||
text: Normal text, but special characters might be required for some callback functions, for
|
|
||||||
example the text might contain a list of selectable elements separated with the '|' symbol.
|
|
||||||
|
|
||||||
MUIF_STYLE(n,cb)
|
|
||||||
Corresponding FDS command: MUI_STYLE(n)
|
|
||||||
Change the style of any other elements after MUI_STYLE(n), does not draw anything
|
|
||||||
|
|
||||||
MUIF_RO(id,cb)
|
|
||||||
Corresponding FDS command: MUI_DATA(id, text) MUI_XY(id, x, y), MUI_XYT(id, x,y,text), MUI_XYA(id, x,y,a), MUI_XYAT(id, x,y,a,text)
|
|
||||||
Places a read only element on the form.
|
|
||||||
The correct FDS command depends on the callback function.
|
|
||||||
|
|
||||||
MUIF_LABEL(cb)
|
|
||||||
Corresponding FDS command: MUI_LABEL(x,y,text)
|
|
||||||
Places a text at the specified position, similar to MUIF_RO
|
|
||||||
|
|
||||||
MUIF_GOTO(cb)
|
|
||||||
Corresponding FDS command: MUI_GOTO(x,y,n,text)
|
|
||||||
Places a button at the specified position, similar to MUIF_BUTTON, but does not require an ID.
|
|
||||||
|
|
||||||
MUIF_BUTTON(id,cb)
|
|
||||||
Corresponding FDS command: MUI_XY(id, x, y), MUI_XYT(id, x,y,text), MUI_XYA(id, x,y,a), MUI_XYAT(id, x,y,a,text)
|
|
||||||
Places a selectable element on the form.
|
|
||||||
|
|
||||||
MUIF_VARIABLE(id,var,cb)
|
|
||||||
Corresponding FDS command: MUI_XY(id, x, y), MUI_XYA(id, x,y,a)
|
|
||||||
Places a user input element at the specified location.
|
|
||||||
The correct FDS command depends on the callback function.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MUI_H
|
|
||||||
#define MUI_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*==========================================*/
|
|
||||||
/* C++ compatible */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*==========================================*/
|
|
||||||
/* defines */
|
|
||||||
|
|
||||||
#define MUI_CHECK_EOFDS
|
|
||||||
|
|
||||||
|
|
||||||
/*==========================================*/
|
|
||||||
/* GNUC AVR PROGMEM interface */
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# define MUI_NOINLINE __attribute__((noinline))
|
|
||||||
#else
|
|
||||||
# define MUI_NOINLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
# define mui_pgm_read(adr) pgm_read_byte_near(adr)
|
|
||||||
# define mui_pgm_wread(adr) pgm_read_word_near(adr)
|
|
||||||
# define MUI_PROGMEM PROGMEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef mui_pgm_read
|
|
||||||
# ifndef CHAR_BIT
|
|
||||||
# define mui_pgm_read(adr) (*(const uint8_t *)(adr))
|
|
||||||
# else
|
|
||||||
# if CHAR_BIT > 8
|
|
||||||
# define mui_pgm_read(adr) ((*(const uint8_t *)(adr)) & 0x0ff)
|
|
||||||
# else
|
|
||||||
# define mui_pgm_read(adr) (*(const uint8_t *)(adr))
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef mui_pgm_wread
|
|
||||||
# define mui_pgm_wread(adr) (*(const uint16_t *)(adr))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MUI_PROGMEM
|
|
||||||
# define MUI_PROGMEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*=== forward declarations ===*/
|
|
||||||
typedef struct mui_struct mui_t;
|
|
||||||
typedef const struct muif_struct muif_t;
|
|
||||||
typedef uint8_t (*muif_cb)(mui_t *ui, uint8_t msg);
|
|
||||||
typedef const char fds_t MUI_PROGMEM;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*=== struct declarations === */
|
|
||||||
|
|
||||||
struct muif_struct
|
|
||||||
{
|
|
||||||
uint8_t id0;
|
|
||||||
uint8_t id1;
|
|
||||||
uint8_t cflags; // config flags e.g. MUIF_CFLAG_IS_CURSOR_SELECTABLE, if so, then it will not receive any cursor/touch msgs
|
|
||||||
uint8_t extra;
|
|
||||||
void *data; // might be a pointer to a variable
|
|
||||||
muif_cb cb; // callback
|
|
||||||
} MUI_PROGMEM;
|
|
||||||
|
|
||||||
/* assumes that pointers are 16 bit so encapsulate the wread i another ifdef __AVR__ */
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
# define muif_get_id0(muif) mui_pgm_read(&((muif)->id0))
|
|
||||||
# define muif_get_id1(muif) mui_pgm_read(&((muif)->id1))
|
|
||||||
# define muif_get_cflags(muif) mui_pgm_read(&((muif)->cflags))
|
|
||||||
# define muif_get_extra(muif) mui_pgm_read(&((muif)->extra))
|
|
||||||
# define muif_get_data(muif) ((void *)mui_pgm_wread(&((muif)->data)))
|
|
||||||
# define muif_get_cb(muif) ((muif_cb)mui_pgm_wread(&((muif)->cb)))
|
|
||||||
#else
|
|
||||||
# define muif_get_id0(muif) ((muif)->id0)
|
|
||||||
# define muif_get_id1(muif) ((muif)->id1)
|
|
||||||
# define muif_get_cflags(muif) ((muif)->cflags)
|
|
||||||
# define muif_get_extra(muif) ((muif)->extra)
|
|
||||||
# define muif_get_data(muif) ((muif)->data)
|
|
||||||
# define muif_get_cb(muif) ((muif)->cb)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MUIF_MSG_NONE 0
|
|
||||||
#define MUIF_MSG_DRAW 1
|
|
||||||
#define MUIF_MSG_FORM_START 2
|
|
||||||
#define MUIF_MSG_FORM_END 3
|
|
||||||
/* MUIF_MSG_CURSOR_ENTER return values: 255=skip this field, <255, continue*/
|
|
||||||
#define MUIF_MSG_CURSOR_ENTER 4
|
|
||||||
#define MUIF_MSG_CURSOR_SELECT 5
|
|
||||||
|
|
||||||
/* optional VALUE messages, ignored by the mui core, but can be used inside the field functions */
|
|
||||||
/* usually MUIF_MSG_VALUE_INCREMENT behaves like MUIF_MSG_CURSOR_SELECT */
|
|
||||||
#define MUIF_MSG_VALUE_INCREMENT 6
|
|
||||||
#define MUIF_MSG_VALUE_DECREMENT 7
|
|
||||||
|
|
||||||
|
|
||||||
#define MUIF_MSG_CURSOR_LEAVE 8
|
|
||||||
#define MUIF_MSG_TOUCH_DOWN 9
|
|
||||||
#define MUIF_MSG_TOUCH_UP 10
|
|
||||||
/* MUIF_MSG_EVENT_NEXT return values: 0=not handled, 1=handled, do nothing */
|
|
||||||
/* If MUIF_MSG_EVENT_NEXT/PREV are NOT handled by the field function, then this msg will change the field */
|
|
||||||
#define MUIF_MSG_EVENT_NEXT 11
|
|
||||||
/* MUIF_MSG_EVENT_PREV return values: 0=not handled, 1=handled, do nothing */
|
|
||||||
#define MUIF_MSG_EVENT_PREV 12
|
|
||||||
|
|
||||||
/* dynamic flags */
|
|
||||||
#define MUIF_DFLAG_IS_CURSOR_FOCUS 0x01
|
|
||||||
#define MUIF_DFLAG_IS_TOUCH_FOCUS 0x02
|
|
||||||
|
|
||||||
/* config flags */
|
|
||||||
#define MUIF_CFLAG_IS_CURSOR_SELECTABLE 0x01
|
|
||||||
#define MUIF_CFLAG_IS_TOUCH_SELECTABLE 0x02
|
|
||||||
#define MUIF_CFLAG_IS_EXECUTE_ON_SELECT 0x04
|
|
||||||
|
|
||||||
|
|
||||||
/* end user MUIF entries */
|
|
||||||
#define MUIF(id,cflags,data,cb) { id[0], id[1], cflags, 0, data, cb}
|
|
||||||
#define MUIF_STYLE(n,cb) MUIF("S" #n, 0, 0, cb)
|
|
||||||
#define MUIF_RO(id,cb) MUIF(id,0, 0,cb)
|
|
||||||
#define MUIF_LABEL(cb) MUIF(".L",0, 0,cb)
|
|
||||||
#define MUIF_GOTO(cb) MUIF(".G",MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,cb)
|
|
||||||
#define MUIF_BUTTON(id,cb) MUIF(id,MUIF_CFLAG_IS_CURSOR_SELECTABLE,0,cb)
|
|
||||||
#define MUIF_EXECUTE_ON_SELECT_BUTTON(id,cb) MUIF(id,MUIF_CFLAG_IS_CURSOR_SELECTABLE|MUIF_CFLAG_IS_EXECUTE_ON_SELECT,0,cb)
|
|
||||||
#define MUIF_VARIABLE(id,var,cb) MUIF(id,MUIF_CFLAG_IS_CURSOR_SELECTABLE,(var),cb)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* must be smaller than or equal to 255 */
|
|
||||||
#ifndef MUI_MAX_TEXT_LEN
|
|
||||||
#define MUI_MAX_TEXT_LEN 41
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MUI_MENU_CACHE_CNT 4
|
|
||||||
|
|
||||||
#define MUI_MENU_LAST_FORM_STACK_SIZE 4
|
|
||||||
|
|
||||||
struct mui_struct
|
|
||||||
{
|
|
||||||
void *graphics_data;
|
|
||||||
fds_t *root_fds;
|
|
||||||
|
|
||||||
muif_t *muif_tlist;
|
|
||||||
size_t muif_tcnt;
|
|
||||||
|
|
||||||
fds_t *current_form_fds; // the current form, NULL if the ui is not active at the moment
|
|
||||||
fds_t *cursor_focus_fds; // the field which has the current cursor focus, NULL if there is no current focus
|
|
||||||
fds_t *touch_focus_fds; // the field which has touch focus
|
|
||||||
|
|
||||||
fds_t *token; // current token position
|
|
||||||
|
|
||||||
uint16_t form_scroll_total; // reserved for MUIF, not used by mui
|
|
||||||
uint16_t form_scroll_top; // reserved for MUIF, not used by mui
|
|
||||||
uint8_t form_scroll_visible; // reserved for MUIF, not used by mui
|
|
||||||
|
|
||||||
|
|
||||||
//uint8_t selected_value; // This variable is not used by the user interface but can be used by any field function
|
|
||||||
uint8_t tmp8;
|
|
||||||
|
|
||||||
/* 0: mse, 1: mud */
|
|
||||||
uint8_t is_mud; // a temp variable for the MUIF function to store remember up down mode. This variable will be cleared before sending MUIF_MSG_CURSOR_ENTER
|
|
||||||
/* current field/style variables */
|
|
||||||
//uint8_t cursor_focus_position; // the index of the field which has focus, can be used as last argument for mui_EnterForm
|
|
||||||
|
|
||||||
uint8_t delimiter; // outer delimiter of the text part of a field
|
|
||||||
uint8_t cmd; // current cmd or field (e.g. U or F)
|
|
||||||
uint8_t id0; // identifier of the field, manually provided or derived (G cmd has fixed id "FG")
|
|
||||||
uint8_t id1;
|
|
||||||
uint8_t x; // position of the field
|
|
||||||
uint8_t y;
|
|
||||||
uint8_t dflags;
|
|
||||||
uint8_t arg; // extra argument of the field. For example the G: form is put here
|
|
||||||
int len; // length of the current command
|
|
||||||
fds_t *fds; // current position, *fds = cmd
|
|
||||||
muif_t *uif; // user interface field or style for the given id0 / id1, assigned by mui_prepare_current_field()
|
|
||||||
char text[MUI_MAX_TEXT_LEN+1];
|
|
||||||
|
|
||||||
/* target */
|
|
||||||
fds_t *tmp_fds;
|
|
||||||
fds_t *target_fds; // used by several task functions as a return / result value
|
|
||||||
|
|
||||||
/* last form and field, used by mui_SaveForm and mui_RestoreForm */
|
|
||||||
uint8_t last_form_id[MUI_MENU_LAST_FORM_STACK_SIZE];
|
|
||||||
uint8_t last_form_cursor_focus_position[MUI_MENU_LAST_FORM_STACK_SIZE];
|
|
||||||
fds_t *last_form_fds; // not used by mui_RestoreForm, but can be used by field functions, warning: this is the FDS of the field, from where the jump started to the child (cursor_focus_fds)
|
|
||||||
int8_t last_form_stack_pos;
|
|
||||||
|
|
||||||
/* menu cursor position backup */
|
|
||||||
/* idea is, to restore the cursor position if we jump to that form */
|
|
||||||
uint8_t menu_form_last_added;
|
|
||||||
uint8_t menu_form_id[MUI_MENU_CACHE_CNT];
|
|
||||||
uint8_t menu_form_cursor_focus_position[MUI_MENU_CACHE_CNT];
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#define mui_IsCursorFocus(mui) ((mui)->dflags & MUIF_DFLAG_IS_CURSOR_FOCUS)
|
|
||||||
#define mui_IsTouchFocus(mui) ((mui)->dflags & MUIF_CFLAG_IS_TOUCH_SELECTABLE)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*=== form string definitions ===*/
|
|
||||||
|
|
||||||
#define MUI_0 "\x00"
|
|
||||||
#define MUI_1 "\x01"
|
|
||||||
#define MUI_2 "\x02"
|
|
||||||
#define MUI_3 "\x03"
|
|
||||||
#define MUI_4 "\x04"
|
|
||||||
#define MUI_5 "\x05"
|
|
||||||
#define MUI_6 "\x06"
|
|
||||||
#define MUI_7 "\x07"
|
|
||||||
#define MUI_8 "\x08"
|
|
||||||
#define MUI_9 "\x09"
|
|
||||||
#define MUI_10 "\x0a"
|
|
||||||
#define MUI_11 "\x0b"
|
|
||||||
#define MUI_12 "\x0c"
|
|
||||||
#define MUI_13 "\x0d"
|
|
||||||
#define MUI_14 "\x0e"
|
|
||||||
#define MUI_15 "\x0f"
|
|
||||||
#define MUI_16 "\x10"
|
|
||||||
#define MUI_17 "\x11"
|
|
||||||
#define MUI_18 "\x12"
|
|
||||||
#define MUI_19 "\x13"
|
|
||||||
#define MUI_20 "\x14"
|
|
||||||
#define MUI_21 "\x15"
|
|
||||||
#define MUI_22 "\x16"
|
|
||||||
#define MUI_23 "\x17"
|
|
||||||
#define MUI_24 "\x18"
|
|
||||||
#define MUI_25 "\x19"
|
|
||||||
#define MUI_26 "\x1a"
|
|
||||||
#define MUI_27 "\x1b"
|
|
||||||
#define MUI_28 "\x1c"
|
|
||||||
#define MUI_29 "\x1d"
|
|
||||||
#define MUI_30 "\x1e"
|
|
||||||
#define MUI_31 "\x1f"
|
|
||||||
#define MUI_32 "\x20"
|
|
||||||
#define MUI_33 "\x21"
|
|
||||||
#define MUI_34 "\x22"
|
|
||||||
#define MUI_35 "\x23"
|
|
||||||
#define MUI_36 "\x24"
|
|
||||||
#define MUI_37 "\x25"
|
|
||||||
#define MUI_38 "\x26"
|
|
||||||
#define MUI_39 "\x27"
|
|
||||||
#define MUI_40 "\x28"
|
|
||||||
#define MUI_41 "\x29"
|
|
||||||
#define MUI_42 "\x2a"
|
|
||||||
#define MUI_43 "\x2b"
|
|
||||||
#define MUI_44 "\x2c"
|
|
||||||
#define MUI_45 "\x2d"
|
|
||||||
#define MUI_46 "\x2e"
|
|
||||||
#define MUI_47 "\x2f"
|
|
||||||
#define MUI_48 "\x30"
|
|
||||||
#define MUI_49 "\x31"
|
|
||||||
#define MUI_50 "\x32"
|
|
||||||
#define MUI_51 "\x33"
|
|
||||||
#define MUI_52 "\x34"
|
|
||||||
#define MUI_53 "\x35"
|
|
||||||
#define MUI_54 "\x36"
|
|
||||||
#define MUI_55 "\x37"
|
|
||||||
#define MUI_56 "\x38"
|
|
||||||
#define MUI_57 "\x39"
|
|
||||||
#define MUI_58 "\x3a"
|
|
||||||
#define MUI_59 "\x3b"
|
|
||||||
#define MUI_60 "\x3c"
|
|
||||||
#define MUI_61 "\x3d"
|
|
||||||
#define MUI_62 "\x3e"
|
|
||||||
#define MUI_63 "\x3f"
|
|
||||||
#define MUI_64 "\x40"
|
|
||||||
#define MUI_65 "\x41"
|
|
||||||
#define MUI_66 "\x42"
|
|
||||||
#define MUI_67 "\x43"
|
|
||||||
#define MUI_68 "\x44"
|
|
||||||
#define MUI_69 "\x45"
|
|
||||||
#define MUI_70 "\x46"
|
|
||||||
#define MUI_71 "\x47"
|
|
||||||
#define MUI_72 "\x48"
|
|
||||||
#define MUI_73 "\x49"
|
|
||||||
#define MUI_74 "\x4a"
|
|
||||||
#define MUI_75 "\x4b"
|
|
||||||
#define MUI_76 "\x4c"
|
|
||||||
#define MUI_77 "\x4d"
|
|
||||||
#define MUI_78 "\x4e"
|
|
||||||
#define MUI_79 "\x4f"
|
|
||||||
#define MUI_80 "\x50"
|
|
||||||
#define MUI_81 "\x51"
|
|
||||||
#define MUI_82 "\x52"
|
|
||||||
#define MUI_83 "\x53"
|
|
||||||
#define MUI_84 "\x54"
|
|
||||||
#define MUI_85 "\x55"
|
|
||||||
#define MUI_86 "\x56"
|
|
||||||
#define MUI_87 "\x57"
|
|
||||||
#define MUI_88 "\x58"
|
|
||||||
#define MUI_89 "\x59"
|
|
||||||
#define MUI_90 "\x5a"
|
|
||||||
#define MUI_91 "\x5b"
|
|
||||||
#define MUI_92 "\x5c"
|
|
||||||
#define MUI_93 "\x5d"
|
|
||||||
#define MUI_94 "\x5e"
|
|
||||||
#define MUI_95 "\x5f"
|
|
||||||
#define MUI_96 "\x60"
|
|
||||||
#define MUI_97 "\x61"
|
|
||||||
#define MUI_98 "\x62"
|
|
||||||
#define MUI_99 "\x63"
|
|
||||||
#define MUI_100 "\x64"
|
|
||||||
#define MUI_101 "\x65"
|
|
||||||
#define MUI_102 "\x66"
|
|
||||||
#define MUI_103 "\x67"
|
|
||||||
#define MUI_104 "\x68"
|
|
||||||
#define MUI_105 "\x69"
|
|
||||||
#define MUI_106 "\x6a"
|
|
||||||
#define MUI_107 "\x6b"
|
|
||||||
#define MUI_108 "\x6c"
|
|
||||||
#define MUI_109 "\x6d"
|
|
||||||
#define MUI_110 "\x6e"
|
|
||||||
#define MUI_111 "\x6f"
|
|
||||||
#define MUI_112 "\x70"
|
|
||||||
#define MUI_113 "\x71"
|
|
||||||
#define MUI_114 "\x72"
|
|
||||||
#define MUI_115 "\x73"
|
|
||||||
#define MUI_116 "\x74"
|
|
||||||
#define MUI_117 "\x75"
|
|
||||||
#define MUI_118 "\x76"
|
|
||||||
#define MUI_119 "\x77"
|
|
||||||
#define MUI_120 "\x78"
|
|
||||||
#define MUI_121 "\x79"
|
|
||||||
#define MUI_122 "\x7a"
|
|
||||||
#define MUI_123 "\x7b"
|
|
||||||
#define MUI_124 "\x7c"
|
|
||||||
#define MUI_125 "\x7d"
|
|
||||||
#define MUI_126 "\x7e"
|
|
||||||
#define MUI_127 "\x7f"
|
|
||||||
#define MUI_128 "\x80"
|
|
||||||
#define MUI_129 "\x81"
|
|
||||||
#define MUI_130 "\x82"
|
|
||||||
#define MUI_131 "\x83"
|
|
||||||
#define MUI_132 "\x84"
|
|
||||||
#define MUI_133 "\x85"
|
|
||||||
#define MUI_134 "\x86"
|
|
||||||
#define MUI_135 "\x87"
|
|
||||||
#define MUI_136 "\x88"
|
|
||||||
#define MUI_137 "\x89"
|
|
||||||
#define MUI_138 "\x8a"
|
|
||||||
#define MUI_139 "\x8b"
|
|
||||||
#define MUI_140 "\x8c"
|
|
||||||
#define MUI_141 "\x8d"
|
|
||||||
#define MUI_142 "\x8e"
|
|
||||||
#define MUI_143 "\x8f"
|
|
||||||
#define MUI_144 "\x90"
|
|
||||||
#define MUI_145 "\x91"
|
|
||||||
#define MUI_146 "\x92"
|
|
||||||
#define MUI_147 "\x93"
|
|
||||||
#define MUI_148 "\x94"
|
|
||||||
#define MUI_149 "\x95"
|
|
||||||
#define MUI_150 "\x96"
|
|
||||||
#define MUI_151 "\x97"
|
|
||||||
#define MUI_152 "\x98"
|
|
||||||
#define MUI_153 "\x99"
|
|
||||||
#define MUI_154 "\x9a"
|
|
||||||
#define MUI_155 "\x9b"
|
|
||||||
#define MUI_156 "\x9c"
|
|
||||||
#define MUI_157 "\x9d"
|
|
||||||
#define MUI_158 "\x9e"
|
|
||||||
#define MUI_159 "\x9f"
|
|
||||||
#define MUI_160 "\xa0"
|
|
||||||
#define MUI_161 "\xa1"
|
|
||||||
#define MUI_162 "\xa2"
|
|
||||||
#define MUI_163 "\xa3"
|
|
||||||
#define MUI_164 "\xa4"
|
|
||||||
#define MUI_165 "\xa5"
|
|
||||||
#define MUI_166 "\xa6"
|
|
||||||
#define MUI_167 "\xa7"
|
|
||||||
#define MUI_168 "\xa8"
|
|
||||||
#define MUI_169 "\xa9"
|
|
||||||
#define MUI_170 "\xaa"
|
|
||||||
#define MUI_171 "\xab"
|
|
||||||
#define MUI_172 "\xac"
|
|
||||||
#define MUI_173 "\xad"
|
|
||||||
#define MUI_174 "\xae"
|
|
||||||
#define MUI_175 "\xaf"
|
|
||||||
#define MUI_176 "\xb0"
|
|
||||||
#define MUI_177 "\xb1"
|
|
||||||
#define MUI_178 "\xb2"
|
|
||||||
#define MUI_179 "\xb3"
|
|
||||||
#define MUI_180 "\xb4"
|
|
||||||
#define MUI_181 "\xb5"
|
|
||||||
#define MUI_182 "\xb6"
|
|
||||||
#define MUI_183 "\xb7"
|
|
||||||
#define MUI_184 "\xb8"
|
|
||||||
#define MUI_185 "\xb9"
|
|
||||||
#define MUI_186 "\xba"
|
|
||||||
#define MUI_187 "\xbb"
|
|
||||||
#define MUI_188 "\xbc"
|
|
||||||
#define MUI_189 "\xbd"
|
|
||||||
#define MUI_190 "\xbe"
|
|
||||||
#define MUI_191 "\xbf"
|
|
||||||
#define MUI_192 "\xc0"
|
|
||||||
#define MUI_193 "\xc1"
|
|
||||||
#define MUI_194 "\xc2"
|
|
||||||
#define MUI_195 "\xc3"
|
|
||||||
#define MUI_196 "\xc4"
|
|
||||||
#define MUI_197 "\xc5"
|
|
||||||
#define MUI_198 "\xc6"
|
|
||||||
#define MUI_199 "\xc7"
|
|
||||||
#define MUI_200 "\xc8"
|
|
||||||
#define MUI_201 "\xc9"
|
|
||||||
#define MUI_202 "\xca"
|
|
||||||
#define MUI_203 "\xcb"
|
|
||||||
#define MUI_204 "\xcc"
|
|
||||||
#define MUI_205 "\xcd"
|
|
||||||
#define MUI_206 "\xce"
|
|
||||||
#define MUI_207 "\xcf"
|
|
||||||
#define MUI_208 "\xd0"
|
|
||||||
#define MUI_209 "\xd1"
|
|
||||||
#define MUI_210 "\xd2"
|
|
||||||
#define MUI_211 "\xd3"
|
|
||||||
#define MUI_212 "\xd4"
|
|
||||||
#define MUI_213 "\xd5"
|
|
||||||
#define MUI_214 "\xd6"
|
|
||||||
#define MUI_215 "\xd7"
|
|
||||||
#define MUI_216 "\xd8"
|
|
||||||
#define MUI_217 "\xd9"
|
|
||||||
#define MUI_218 "\xda"
|
|
||||||
#define MUI_219 "\xdb"
|
|
||||||
#define MUI_220 "\xdc"
|
|
||||||
#define MUI_221 "\xdd"
|
|
||||||
#define MUI_222 "\xde"
|
|
||||||
#define MUI_223 "\xdf"
|
|
||||||
#define MUI_224 "\xe0"
|
|
||||||
#define MUI_225 "\xe1"
|
|
||||||
#define MUI_226 "\xe2"
|
|
||||||
#define MUI_227 "\xe3"
|
|
||||||
#define MUI_228 "\xe4"
|
|
||||||
#define MUI_229 "\xe5"
|
|
||||||
#define MUI_230 "\xe6"
|
|
||||||
#define MUI_231 "\xe7"
|
|
||||||
#define MUI_232 "\xe8"
|
|
||||||
#define MUI_233 "\xe9"
|
|
||||||
#define MUI_234 "\xea"
|
|
||||||
#define MUI_235 "\xeb"
|
|
||||||
#define MUI_236 "\xec"
|
|
||||||
#define MUI_237 "\xed"
|
|
||||||
#define MUI_238 "\xee"
|
|
||||||
#define MUI_239 "\xef"
|
|
||||||
#define MUI_240 "\xf0"
|
|
||||||
#define MUI_241 "\xf1"
|
|
||||||
#define MUI_242 "\xf2"
|
|
||||||
#define MUI_243 "\xf3"
|
|
||||||
#define MUI_244 "\xf4"
|
|
||||||
#define MUI_245 "\xf5"
|
|
||||||
#define MUI_246 "\xf6"
|
|
||||||
#define MUI_247 "\xf7"
|
|
||||||
#define MUI_248 "\xf8"
|
|
||||||
#define MUI_249 "\xf9"
|
|
||||||
#define MUI_250 "\xfa"
|
|
||||||
#define MUI_251 "\xfb"
|
|
||||||
#define MUI_252 "\xfc"
|
|
||||||
#define MUI_253 "\xfd"
|
|
||||||
#define MUI_254 "\xfe"
|
|
||||||
#define MUI_255 "\xff"
|
|
||||||
|
|
||||||
/* form: one id only */
|
|
||||||
#define MUI_FORM(n) "U" MUI_##n
|
|
||||||
|
|
||||||
/* style: one id only */
|
|
||||||
#define MUI_STYLE(n) "S" #n
|
|
||||||
|
|
||||||
#define MUI_AUX(id) "Z" id
|
|
||||||
|
|
||||||
#define MUI_DATA(id, text) "D" id "\xff" text "\xff"
|
|
||||||
|
|
||||||
#define MUI_XY(id, x, y) "F" id MUI_##x MUI_##y
|
|
||||||
/* button id must be two chars, but must be unique everywhere */
|
|
||||||
#define MUI_XYT(id, x,y,text) "B" id MUI_##x MUI_##y "\xff" text "\xff"
|
|
||||||
#define MUI_XYA(id, x,y,a) "A" id MUI_##x MUI_##y MUI_##a
|
|
||||||
#define MUI_XYAT(id, x,y,a,text) "T" id MUI_##x MUI_##y MUI_##a "\xff" text "\xff"
|
|
||||||
|
|
||||||
#define MUI_LABEL(x,y,text) "L" MUI_##x MUI_##y "\xff" text "\xff"
|
|
||||||
#define MUI_GOTO(x,y,n,text) "G" MUI_##x MUI_##y MUI_##n "\xff" text "\xff"
|
|
||||||
#define MUI_goto(x,y,n,text) "g" MUI_##x MUI_##y MUI_##n "\xff" text "\xff"
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t mui_get_fds_char(fds_t *s) MUI_NOINLINE;
|
|
||||||
|
|
||||||
uint8_t mui_fds_first_token(mui_t *ui) MUI_NOINLINE;
|
|
||||||
uint8_t mui_fds_next_token(mui_t *ui) MUI_NOINLINE;
|
|
||||||
uint8_t mui_fds_get_nth_token(mui_t *ui, uint8_t n) MUI_NOINLINE;
|
|
||||||
uint8_t mui_fds_get_token_cnt(mui_t *ui) MUI_NOINLINE;
|
|
||||||
|
|
||||||
void mui_Init(mui_t *ui, void *graphics_data, fds_t *fds, muif_t *muif_tlist, size_t muif_tcnt);
|
|
||||||
uint8_t mui_GetCurrentCursorFocusPosition(mui_t *ui) ;
|
|
||||||
void mui_Draw(mui_t *ui);
|
|
||||||
/* warning: The next function will overwrite the ui field variables like ui->arg, etc. 26 sep 2021: only ui->text is modified */
|
|
||||||
uint8_t mui_GetSelectableFieldTextOption(mui_t *ui, fds_t *fds, uint8_t nth_token);
|
|
||||||
/* warning: The next function will overwrite the ui field variables like ui->arg, etc 26 sep 2021: only ui->text is modified*/
|
|
||||||
uint8_t mui_GetSelectableFieldOptionCnt(mui_t *ui, fds_t *fds);
|
|
||||||
void mui_EnterForm(mui_t *ui, fds_t *fds, uint8_t initial_cursor_position);
|
|
||||||
void mui_LeaveForm(mui_t *ui);
|
|
||||||
uint8_t mui_GotoForm(mui_t *ui, uint8_t form_id, uint8_t initial_cursor_position);
|
|
||||||
void mui_SaveFormWithCursorPosition(mui_t *ui, uint8_t cursor_pos); /* Save current form with manully provied cursor position, Used together with mui_RestoreForm */
|
|
||||||
void mui_SaveForm(mui_t *ui); /* Save current form+cursor position. Used together with mui_RestoreForm */
|
|
||||||
uint8_t mui_RestoreForm(mui_t *ui); /* Restore form and cursor position, previously saved with mui_SaveForm */
|
|
||||||
void mui_SaveCursorPosition(mui_t *ui, uint8_t cursor_position); /* stores a cursor position for use with mui_GotoFormAutoCursorPosition */
|
|
||||||
uint8_t mui_GotoFormAutoCursorPosition(mui_t *ui, uint8_t form_id);
|
|
||||||
|
|
||||||
int mui_GetCurrentFormId(mui_t *ui); /* form id or -1 if the menu system is inactive */
|
|
||||||
void mui_NextField(mui_t *ui);
|
|
||||||
void mui_PrevField(mui_t *ui);
|
|
||||||
void mui_SendSelect(mui_t *ui);
|
|
||||||
void mui_SendSelectWithExecuteOnSelectFieldSearch(mui_t *ui); /* use this if MUIF_EXECUTE_ON_SELECT_BUTTON is used */
|
|
||||||
|
|
||||||
void mui_SendValueIncrement(mui_t *ui);
|
|
||||||
void mui_SendValueDecrement(mui_t *ui);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define mui_IsFormActive(ui) ((ui)->current_form_fds != NULL)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* MUI_H */
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,350 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
mui_u8g2.h
|
|
||||||
|
|
||||||
Monochrome minimal user interface: Glue code between mui and u8g2.
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2021, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
Reference Manual:
|
|
||||||
https://github.com/olikraus/u8g2/wiki/muiref
|
|
||||||
|
|
||||||
MUIF_U8G2_LABEL()
|
|
||||||
replacement for MUIF_LABEL(mui_u8g2_draw_text),
|
|
||||||
used by MUI_LABEL(x,y,"text")
|
|
||||||
Supports UTF8
|
|
||||||
|
|
||||||
MUIF_U8G2_FONT_STYLE(n, font)
|
|
||||||
A special u8g2 style function, which replaces MUIF_STYLE, but restricts the style change to the
|
|
||||||
specific font argument (however, this should be good enough in most cases).
|
|
||||||
As usual, the style "n" can be activated with MUI_STYLE(n) in FDS.
|
|
||||||
Example:
|
|
||||||
muif_t muif_list[] MUI_PROGMEM = {
|
|
||||||
MUIF_U8G2_LABEL(),
|
|
||||||
MUIF_U8G2_FONT_STYLE(0, u8g2_font_5x8_tr)
|
|
||||||
};
|
|
||||||
fds_t fds[] MUI_PROGMEM =
|
|
||||||
MUI_FORM(1)
|
|
||||||
MUI_STYLE(0)
|
|
||||||
MUI_LABEL(5,12, "5x8 Font")
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MUI_U8G2_H
|
|
||||||
#define MUI_U8G2_H
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
#include "mui.h"
|
|
||||||
|
|
||||||
/*==========================================*/
|
|
||||||
/* C++ compatible */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define MUI_U8G2_COMMA ,
|
|
||||||
|
|
||||||
typedef const char * (*mui_u8g2_get_list_element_cb)(void *data, uint16_t index);
|
|
||||||
typedef uint16_t (*mui_u8g2_get_list_count_cb)(void *data);
|
|
||||||
|
|
||||||
struct mui_u8g2_list_struct
|
|
||||||
{
|
|
||||||
uint16_t *selection;
|
|
||||||
void *data;
|
|
||||||
mui_u8g2_get_list_element_cb get_list_element;
|
|
||||||
mui_u8g2_get_list_count_cb get_list_count;
|
|
||||||
} MUI_PROGMEM;
|
|
||||||
|
|
||||||
typedef const struct mui_u8g2_list_struct mui_u8g2_list_t;
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
# define mui_u8g2_list_get_selection_ptr(list) ((uint16_t *)mui_pgm_wread(&((list)->selection)))
|
|
||||||
# define mui_u8g2_list_get_data_ptr(list) ((void *)mui_pgm_wread(&((list)->data)))
|
|
||||||
# define mui_u8g2_list_get_element_cb(list) ((mui_u8g2_get_list_element_cb)mui_pgm_wread(&((list)->get_list_element)))
|
|
||||||
# define mui_u8g2_list_get_count_cb(list) ((mui_u8g2_get_list_count_cb)mui_pgm_wread(&((list)->get_list_count)))
|
|
||||||
#else
|
|
||||||
# define mui_u8g2_list_get_selection_ptr(list) ((list)->selection)
|
|
||||||
# define mui_u8g2_list_get_data_ptr(list) ((list)->data)
|
|
||||||
# define mui_u8g2_list_get_element_cb(list) ((list)->get_list_element)
|
|
||||||
# define mui_u8g2_list_get_count_cb(list) ((list)->get_list_count)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
struct mui_u8g2_u8_min_max_struct
|
|
||||||
{
|
|
||||||
uint8_t *value;
|
|
||||||
uint8_t min;
|
|
||||||
uint8_t max;
|
|
||||||
} MUI_PROGMEM;
|
|
||||||
|
|
||||||
typedef const struct mui_u8g2_u8_min_max_struct mui_u8g2_u8_min_max_t;
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
# define mui_u8g2_u8mm_get_min(u8mm) mui_pgm_read(&((u8mm)->min))
|
|
||||||
# define mui_u8g2_u8mm_get_max(u8mm) mui_pgm_read(&((u8mm)->max))
|
|
||||||
# define mui_u8g2_u8mm_get_valptr(u8mm) ((uint8_t *)mui_pgm_wread(&((u8mm)->value)))
|
|
||||||
#else
|
|
||||||
# define mui_u8g2_u8mm_get_min(u8mm) ((u8mm)->min)
|
|
||||||
# define mui_u8g2_u8mm_get_max(u8mm) ((u8mm)->max)
|
|
||||||
# define mui_u8g2_u8mm_get_valptr(u8mm) ((u8mm)->value)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct mui_u8g2_s8_min_max_struct
|
|
||||||
{
|
|
||||||
int8_t *value;
|
|
||||||
int8_t min;
|
|
||||||
int8_t max;
|
|
||||||
} MUI_PROGMEM;
|
|
||||||
|
|
||||||
typedef const struct mui_u8g2_s8_min_max_struct mui_u8g2_s8_min_max_t;
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
# define mui_u8g2_s8mm_get_min(u8mm) ((int8_t)mui_pgm_read(&((u8mm)->min)))
|
|
||||||
# define mui_u8g2_s8mm_get_max(u8mm) ((int8_t)mui_pgm_read(&((u8mm)->max)))
|
|
||||||
# define mui_u8g2_s8mm_get_valptr(u8mm) ((int8_t *)mui_pgm_wread(&((u8mm)->value)))
|
|
||||||
#else
|
|
||||||
# define mui_u8g2_s8mm_get_min(u8mm) ((u8mm)->min)
|
|
||||||
# define mui_u8g2_s8mm_get_max(u8mm) ((u8mm)->max)
|
|
||||||
# define mui_u8g2_s8mm_get_valptr(u8mm) ((u8mm)->value)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct mui_u8g2_u8_min_max_step_struct
|
|
||||||
{
|
|
||||||
uint8_t *value;
|
|
||||||
uint8_t min;
|
|
||||||
uint8_t max;
|
|
||||||
uint8_t step;
|
|
||||||
uint8_t flags;
|
|
||||||
uint8_t width; // added with issue 2200, might not be used by all bar graph functions
|
|
||||||
} MUI_PROGMEM;
|
|
||||||
|
|
||||||
typedef const struct mui_u8g2_u8_min_max_step_struct mui_u8g2_u8_min_max_step_t;
|
|
||||||
|
|
||||||
/* list of bit values for the "flags" variable */
|
|
||||||
#define MUI_MMS_2X_BAR 0x01
|
|
||||||
#define MUI_MMS_4X_BAR 0x02
|
|
||||||
#define MUI_MMS_SHOW_VALUE 0x04
|
|
||||||
#define MUI_MMS_NO_WRAP 0x08
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
# define mui_u8g2_u8mms_get_width(u8mm) mui_pgm_read(&((u8mm)->width))
|
|
||||||
# define mui_u8g2_u8mms_get_step(u8mm) mui_pgm_read(&((u8mm)->step))
|
|
||||||
# define mui_u8g2_u8mms_get_flags(u8mm) mui_pgm_read(&((u8mm)->flags))
|
|
||||||
# define mui_u8g2_u8mms_get_min(u8mm) mui_pgm_read(&((u8mm)->min))
|
|
||||||
# define mui_u8g2_u8mms_get_max(u8mm) mui_pgm_read(&((u8mm)->max))
|
|
||||||
# define mui_u8g2_u8mms_get_valptr(u8mm) ((uint8_t *)mui_pgm_wread(&((u8mm)->value)))
|
|
||||||
#else
|
|
||||||
# define mui_u8g2_u8mms_get_width(u8mm) ((u8mm)->width)
|
|
||||||
# define mui_u8g2_u8mms_get_step(u8mm) ((u8mm)->step)
|
|
||||||
# define mui_u8g2_u8mms_get_flags(u8mm) ((u8mm)->flags)
|
|
||||||
# define mui_u8g2_u8mms_get_min(u8mm) ((u8mm)->min)
|
|
||||||
# define mui_u8g2_u8mms_get_max(u8mm) ((u8mm)->max)
|
|
||||||
# define mui_u8g2_u8mms_get_valptr(u8mm) ((u8mm)->value)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* helper functions */
|
|
||||||
|
|
||||||
u8g2_uint_t mui_get_x(mui_t *ui);
|
|
||||||
u8g2_uint_t mui_get_y(mui_t *ui);
|
|
||||||
u8g2_t *mui_get_U8g2(mui_t *ui);
|
|
||||||
|
|
||||||
void mui_u8g2_draw_button_utf(mui_t *ui, u8g2_uint_t flags, u8g2_uint_t width, u8g2_uint_t padding_h, u8g2_uint_t padding_v, const char *text);
|
|
||||||
u8g2_uint_t mui_u8g2_get_pi_flags(mui_t *ui);
|
|
||||||
void mui_u8g2_draw_button_pi(mui_t *ui, u8g2_uint_t width, u8g2_uint_t padding_h, const char *text);
|
|
||||||
u8g2_uint_t mui_u8g2_get_fi_flags(mui_t *ui);
|
|
||||||
void mui_u8g2_draw_button_fi(mui_t *ui, u8g2_uint_t width, u8g2_uint_t padding_h, const char *text);
|
|
||||||
u8g2_uint_t mui_u8g2_get_pf_flags(mui_t *ui);
|
|
||||||
void mui_u8g2_draw_button_pf(mui_t *ui, u8g2_uint_t width, u8g2_uint_t padding_h, const char *text);
|
|
||||||
u8g2_uint_t mui_u8g2_get_if_flags(mui_t *ui);
|
|
||||||
void mui_u8g2_draw_button_if(mui_t *ui, u8g2_uint_t width, u8g2_uint_t padding_h, const char *text);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ready to use field functions */
|
|
||||||
|
|
||||||
uint8_t mui_hline(mui_t *ui, uint8_t msg);
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_draw_text(mui_t *ui, uint8_t msg);
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_btn_goto_wm_fi(mui_t *ui, uint8_t msg); /* GIF */
|
|
||||||
uint8_t mui_u8g2_btn_goto_wm_if(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_btn_goto_w2_fi(mui_t *ui, uint8_t msg); /* GIF */
|
|
||||||
uint8_t mui_u8g2_btn_goto_w2_if(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_btn_goto_w1_pi(mui_t *ui, uint8_t msg); /* GIF */
|
|
||||||
uint8_t mui_u8g2_btn_goto_w1_fi(mui_t *ui, uint8_t msg); /* GIF */
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_btn_back_wm_fi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_btn_back_wm_if(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_btn_back_w2_fi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_btn_back_w2_if(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_btn_back_w1_pi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_btn_back_w1_fi(mui_t *ui, uint8_t msg);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_btn_exit_wm_fi(mui_t *ui, uint8_t msg); /* similar to 'mui_u8g2_btn_goto_wm_fi' but will exit the menu system */
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_u8_chkbox_wm_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XY */
|
|
||||||
uint8_t mui_u8g2_u8_radio_wm_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_u8_opt_line_wa_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
|
||||||
uint8_t mui_u8g2_u8_opt_line_wa_mse_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
|
||||||
uint8_t mui_u8g2_u8_opt_line_wa_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
|
||||||
uint8_t mui_u8g2_u8_opt_line_wa_mud_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XYAT */
|
|
||||||
|
|
||||||
/* dropdown list / combo box */
|
|
||||||
/* The text part of the parent defines a '|' separated list of elements, which can be selected by the child. */
|
|
||||||
/* Argument is a form number where the child element is placed multiple times */
|
|
||||||
/* The child form does not require the ok button, because the child function will return to the parent with the select element */
|
|
||||||
uint8_t mui_u8g2_u8_opt_parent_wm_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XYAT */
|
|
||||||
uint8_t mui_u8g2_u8_opt_radio_child_wm_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XYA */
|
|
||||||
uint8_t mui_u8g2_u8_opt_radio_child_w1_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE, MUI_XYA */
|
|
||||||
uint8_t mui_u8g2_u8_opt_child_wm_pi(mui_t *ui, uint8_t msg); /* MUIF_VARIABLE, MUI_XYA */
|
|
||||||
/* Note: there is no opt_child_goto muif, because this can be done with mui_u8g2_goto_form_w1_pi */
|
|
||||||
|
|
||||||
/* (scrollable) jump menu */
|
|
||||||
/* The text part of the parent defines a '|' separated list of elements, which can be selected goto_form functions. */
|
|
||||||
/* Each '|' separated element must be prefixed with the form number (MUI_x) */
|
|
||||||
uint8_t mui_u8g2_goto_data(mui_t *ui, uint8_t msg); /* REF, MUIF_RO, MUI_DATA (WARNING: Must appear only once per form!!! */
|
|
||||||
uint8_t mui_u8g2_goto_form_w1_pi(mui_t *ui, uint8_t msg); /* REF, MUIF_BUTTON, MUI_XYA */
|
|
||||||
uint8_t mui_u8g2_goto_form_w1_pf(mui_t *ui, uint8_t msg); /* REF, MUIF_BUTTON, MUI_XYA */
|
|
||||||
|
|
||||||
|
|
||||||
/* character input */
|
|
||||||
uint8_t mui_u8g2_u8_char_wm_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_VARIABLE,MUI_XY, usually requires a monospaced font line profont12 */
|
|
||||||
|
|
||||||
|
|
||||||
/*===== MUIF U8g2 Label =====*/
|
|
||||||
|
|
||||||
#define MUIF_U8G2_LABEL() MUIF_LABEL(mui_u8g2_draw_text)
|
|
||||||
|
|
||||||
|
|
||||||
/*===== data = u8g2 font data =====*/
|
|
||||||
|
|
||||||
//#define MUIF_U8G2_FONT_STYLE(n,font) MUIF("S" #n, 0, (void *)(font), mui_u8g2_set_font_style_function)
|
|
||||||
#define MUIF_U8G2_FONT_STYLE(n, font) { 'S', #n[0], 0, 0, (void *)(font), mui_u8g2_set_font_style_function}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_set_font_style_function(mui_t *ui, uint8_t msg);
|
|
||||||
|
|
||||||
|
|
||||||
/*===== data = mui_u8g2_u8_min_max_t* =====*/
|
|
||||||
|
|
||||||
/* gcc note: the macro uses array compound literals to extend the lifetime in C++, see last section in https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html */
|
|
||||||
#define MUIF_U8G2_U8_MIN_MAX(id, valptr, min, max, muif) \
|
|
||||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
|
||||||
(void *)((mui_u8g2_u8_min_max_t [] ) {{ (valptr) MUI_U8G2_COMMA (min) MUI_U8G2_COMMA (max)}}), \
|
|
||||||
(muif))
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_u8_min_max_wm_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
|
||||||
uint8_t mui_u8g2_u8_min_max_wm_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
|
||||||
uint8_t mui_u8g2_u8_min_max_wm_mse_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
|
||||||
uint8_t mui_u8g2_u8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U8_MIN_MAX, MUI_XY */
|
|
||||||
|
|
||||||
#define MUIF_U8G2_S8_MIN_MAX(id, valptr, min, max, muif) \
|
|
||||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
|
||||||
(void *)((mui_u8g2_s8_min_max_t [] ) {{ (valptr) MUI_U8G2_COMMA (min) MUI_U8G2_COMMA (max)}}), \
|
|
||||||
(muif))
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_s8_min_max_wm_mse_pi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_s8_min_max_wm_mud_pi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_s8_min_max_wm_mse_pf(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_s8_min_max_wm_mud_pf(mui_t *ui, uint8_t msg);
|
|
||||||
|
|
||||||
|
|
||||||
/*===== data = mui_u8g2_u8_min_max_step_t* =====*/
|
|
||||||
|
|
||||||
/* gcc note: the macro uses array compound literals to extend the lifetime in C++, see last section in https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html */
|
|
||||||
#define MUIF_U8G2_U8_MIN_MAX_STEP(id, valptr, min, max, step, flags, muif) \
|
|
||||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
|
||||||
(void *)((mui_u8g2_u8_min_max_step_t [] ) {{ (valptr) MUI_U8G2_COMMA (min) MUI_U8G2_COMMA (max) MUI_U8G2_COMMA (step) MUI_U8G2_COMMA (flags) MUI_U8G2_COMMA (0) }}), \
|
|
||||||
(muif))
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_u8_bar_wm_mse_pi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_u8_bar_wm_mud_pi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_u8_bar_wm_mse_pf(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_u8_bar_wm_mud_pf(mui_t *ui, uint8_t msg);
|
|
||||||
|
|
||||||
|
|
||||||
#define MUIF_U8G2_U8_MIN_MAX_STEP_WIDTH(id, valptr, min, max, step, width, flags, muif) \
|
|
||||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
|
||||||
(void *)((mui_u8g2_u8_min_max_step_t [] ) {{ (valptr) MUI_U8G2_COMMA (min) MUI_U8G2_COMMA (max) MUI_U8G2_COMMA (step) MUI_U8G2_COMMA (flags) MUI_U8G2_COMMA (width) }}), \
|
|
||||||
(muif))
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_u8_fixed_width_bar_wm_mse_pi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_u8_fixed_width_bar_wm_mud_pi(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_u8_fixed_width_bar_wm_mse_pf(mui_t *ui, uint8_t msg);
|
|
||||||
uint8_t mui_u8g2_u8_fixed_width_bar_wm_mud_pf(mui_t *ui, uint8_t msg);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*===== data = mui_u8g2_list_t* =====*/
|
|
||||||
/* similar to mui_u8g2_u8_opt_line, but u16 and dynamic list */
|
|
||||||
|
|
||||||
|
|
||||||
#define MUIF_U8G2_U16_LIST(id, valptr, dataptr, getcb, cntcb, muif) \
|
|
||||||
MUIF(id, MUIF_CFLAG_IS_CURSOR_SELECTABLE, \
|
|
||||||
(void *)((mui_u8g2_list_t [] ) {{ (valptr) MUI_U8G2_COMMA (dataptr) MUI_U8G2_COMMA (getcb) MUI_U8G2_COMMA (cntcb)}}), \
|
|
||||||
(muif))
|
|
||||||
|
|
||||||
uint8_t mui_u8g2_u16_list_line_wa_mse_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=pixel fieldsize */
|
|
||||||
uint8_t mui_u8g2_u16_list_line_wa_mud_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=pixel fieldsize */
|
|
||||||
|
|
||||||
|
|
||||||
/* dropdown list / combo box with 16 size and callback functions for MUIF_U8G2_U16_LIST */
|
|
||||||
uint8_t mui_u8g2_u16_list_parent_wm_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=subform */
|
|
||||||
uint8_t mui_u8g2_u16_list_child_w1_pi(mui_t *ui, uint8_t msg); /* GIF, MUIF_U8G2_U16_LIST, MUI_XYA, arg=sub element number */
|
|
||||||
uint8_t mui_u8g2_u16_list_goto_w1_pi(mui_t *ui, uint8_t msg); /* REF, MUIF_U8G2_U16_LIST first char of the string denotes the target form */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* MUI_U8G2_H */
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_arc.c
|
|
||||||
|
|
||||||
Contributed... see here: https://github.com/olikraus/u8g2/issues/2243
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2023, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
|
|
||||||
static void u8g2_draw_arc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t start, uint8_t end)
|
|
||||||
{
|
|
||||||
// Manage angle inputs
|
|
||||||
uint8_t full = (start == end);
|
|
||||||
uint8_t inverted = (start > end);
|
|
||||||
uint8_t a_start = inverted ? end : start;
|
|
||||||
uint8_t a_end = inverted ? start : end;
|
|
||||||
|
|
||||||
// Initialize variables
|
|
||||||
uint32_t ratio;
|
|
||||||
u8g2_int_t x = 0;
|
|
||||||
u8g2_int_t y = rad;
|
|
||||||
u8g2_int_t d = rad - 1;
|
|
||||||
|
|
||||||
// Trace arc radius with the Andres circle algorithm (process each pixel of a 1/8th circle of radius rad)
|
|
||||||
while (y >= x)
|
|
||||||
{
|
|
||||||
// Get the percentage of 1/8th circle drawn with a fast approximation of arctan(x/y)
|
|
||||||
ratio = x * 255 / y; // x/y [0..255]
|
|
||||||
ratio = ratio * (770195 - (ratio - 255) * (ratio + 941)) / 6137491; // arctan(x/y) [0..32]
|
|
||||||
|
|
||||||
// Fill the pixels of the 8 sections of the circle, but only on the arc defined by the angles (start and end)
|
|
||||||
if(full || ((ratio >= a_start && ratio < a_end) ^ inverted)) u8g2_DrawPixel(u8g2, x0 + y, y0 - x);
|
|
||||||
if(full || (((ratio + a_end) > 63 && (ratio + a_start) <= 63) ^ inverted)) u8g2_DrawPixel(u8g2, x0 + x, y0 - y);
|
|
||||||
if(full || (((ratio + 64) >= a_start && (ratio + 64) < a_end) ^ inverted)) u8g2_DrawPixel(u8g2, x0 - x, y0 - y);
|
|
||||||
if(full || (((ratio + a_end) > 127 && (ratio + a_start) <= 127) ^ inverted)) u8g2_DrawPixel(u8g2, x0 - y, y0 - x);
|
|
||||||
if(full || (((ratio + 128) >= a_start && (ratio + 128) < a_end) ^ inverted)) u8g2_DrawPixel(u8g2, x0 - y, y0 + x);
|
|
||||||
if(full || (((ratio + a_end) > 191 && (ratio + a_start) <= 191) ^ inverted)) u8g2_DrawPixel(u8g2, x0 - x, y0 + y);
|
|
||||||
if(full || (((ratio + 192) >= a_start && (ratio + 192) < a_end) ^ inverted)) u8g2_DrawPixel(u8g2, x0 + x, y0 + y);
|
|
||||||
if(full || (((ratio + a_end) > 255 && (ratio + a_start) <= 255) ^ inverted)) u8g2_DrawPixel(u8g2, x0 + y, y0 + x);
|
|
||||||
|
|
||||||
// Run Andres circle algorithm to get to the next pixel
|
|
||||||
if (d >= 2 * x)
|
|
||||||
{
|
|
||||||
d = d - 2 * x - 1;
|
|
||||||
x = x + 1;
|
|
||||||
}
|
|
||||||
else if (d < 2 * (rad - y))
|
|
||||||
{
|
|
||||||
d = d + 2 * y - 1;
|
|
||||||
y = y - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
d = d + 2 * (y - x - 1);
|
|
||||||
y = y - 1;
|
|
||||||
x = x + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawArc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t start, uint8_t end)
|
|
||||||
{
|
|
||||||
/* check for bounding box */
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
{
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x0-rad, y0-rad, x0+rad+1, y0+rad+1) == 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
|
|
||||||
/* draw arc */
|
|
||||||
u8g2_draw_arc(u8g2, x0, y0, rad, start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_bitmap.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_SetBitmapMode(u8g2_t *u8g2, uint8_t is_transparent) {
|
|
||||||
u8g2->bitmap_transparency = is_transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y Position on the display
|
|
||||||
len Length of bitmap line in pixel. Note: This differs from u8glib which had a bytecount here.
|
|
||||||
b Pointer to the bitmap line.
|
|
||||||
Only draw pixels which are set.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void u8g2_DrawHorizontalBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
|
|
||||||
{
|
|
||||||
uint8_t mask;
|
|
||||||
uint8_t color = u8g2->draw_color;
|
|
||||||
uint8_t ncolor = (color == 0 ? 1 : 0);
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
mask = 128;
|
|
||||||
while(len > 0)
|
|
||||||
{
|
|
||||||
if ( *b & mask ) {
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
|
||||||
} else if ( u8g2->bitmap_transparency == 0 ) {
|
|
||||||
u8g2->draw_color = ncolor;
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
x++;
|
|
||||||
mask >>= 1;
|
|
||||||
if ( mask == 0 )
|
|
||||||
{
|
|
||||||
mask = 128;
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* u8glib compatible bitmap draw function */
|
|
||||||
void u8g2_DrawBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap)
|
|
||||||
{
|
|
||||||
u8g2_uint_t w;
|
|
||||||
w = cnt;
|
|
||||||
w *= 8;
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
while( h > 0 )
|
|
||||||
{
|
|
||||||
u8g2_DrawHorizontalBitmap(u8g2, x, y, w, bitmap);
|
|
||||||
bitmap += cnt;
|
|
||||||
y++;
|
|
||||||
h--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_DrawHXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
|
|
||||||
{
|
|
||||||
uint8_t mask;
|
|
||||||
uint8_t color = u8g2->draw_color;
|
|
||||||
uint8_t ncolor = (color == 0 ? 1 : 0);
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
mask = 1;
|
|
||||||
while(len > 0) {
|
|
||||||
uint8_t current_bit = (*b) & mask;
|
|
||||||
#ifdef OLD
|
|
||||||
if ( current_bit ) {
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
|
||||||
} else if ( u8g2->bitmap_transparency == 0 ) {
|
|
||||||
u8g2->draw_color = ncolor;
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
|
||||||
}
|
|
||||||
x++;
|
|
||||||
mask <<= 1;
|
|
||||||
if ( mask == 0 )
|
|
||||||
{
|
|
||||||
mask = 1;
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
len--;
|
|
||||||
#else
|
|
||||||
u8g2_uint_t run_length = 0;
|
|
||||||
// Determine the run length of consecutive bits with the same color
|
|
||||||
while (len > 0 && (current_bit == 0 ? (((*b) & mask) == 0) : (((*b) & mask) != 0 ) ))
|
|
||||||
{
|
|
||||||
run_length++;
|
|
||||||
x++;
|
|
||||||
mask <<= 1;
|
|
||||||
if (mask == 0)
|
|
||||||
{
|
|
||||||
mask = 1;
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
if (current_bit)
|
|
||||||
{
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
u8g2_DrawHVLine(u8g2, x - run_length, y, run_length, 0);
|
|
||||||
}
|
|
||||||
else if (u8g2->bitmap_transparency == 0)
|
|
||||||
{
|
|
||||||
u8g2->draw_color = ncolor;
|
|
||||||
u8g2_DrawHVLine(u8g2, x - run_length, y, run_length, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_DrawXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
|
|
||||||
{
|
|
||||||
u8g2_uint_t blen;
|
|
||||||
blen = w;
|
|
||||||
blen += 7;
|
|
||||||
blen >>= 3;
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
while( h > 0 )
|
|
||||||
{
|
|
||||||
u8g2_DrawHXBM(u8g2, x, y, w, bitmap);
|
|
||||||
bitmap += blen;
|
|
||||||
y++;
|
|
||||||
h--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_DrawHXBMP(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
|
|
||||||
{
|
|
||||||
uint8_t mask;
|
|
||||||
uint8_t color = u8g2->draw_color;
|
|
||||||
uint8_t ncolor = (color == 0 ? 1 : 0);
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
mask = 1;
|
|
||||||
while(len > 0)
|
|
||||||
{
|
|
||||||
uint8_t current_bit = u8x8_pgm_read(b) & mask;
|
|
||||||
//#define OLD
|
|
||||||
#ifdef OLD
|
|
||||||
if ( current_bit ) {
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
|
||||||
} else if( u8g2->bitmap_transparency == 0 ) {
|
|
||||||
u8g2->draw_color = ncolor;
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
x++;
|
|
||||||
mask <<= 1;
|
|
||||||
if ( mask == 0 )
|
|
||||||
{
|
|
||||||
mask = 1;
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
len--;
|
|
||||||
#else
|
|
||||||
u8g2_uint_t run_length = 0;
|
|
||||||
// Determine the run length of consecutive bits with the same color
|
|
||||||
while (len > 0 && (current_bit == 0 ? ((u8x8_pgm_read(b) & mask) == 0) : ((u8x8_pgm_read(b) & mask) != 0 ) ))
|
|
||||||
{
|
|
||||||
run_length++;
|
|
||||||
x++;
|
|
||||||
mask <<= 1;
|
|
||||||
if (mask == 0)
|
|
||||||
{
|
|
||||||
mask = 1;
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
if (current_bit)
|
|
||||||
{
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
u8g2_DrawHVLine(u8g2, x - run_length, y, run_length, 0);
|
|
||||||
}
|
|
||||||
else if (u8g2->bitmap_transparency == 0)
|
|
||||||
{
|
|
||||||
u8g2->draw_color = ncolor;
|
|
||||||
u8g2_DrawHVLine(u8g2, x - run_length, y, run_length, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
u8g2->draw_color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_DrawXBMP(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
|
|
||||||
{
|
|
||||||
u8g2_uint_t blen;
|
|
||||||
blen = w;
|
|
||||||
blen += 7;
|
|
||||||
blen >>= 3;
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
while( h > 0 )
|
|
||||||
{
|
|
||||||
u8g2_DrawHXBMP(u8g2, x, y, w, bitmap);
|
|
||||||
bitmap += blen;
|
|
||||||
y++;
|
|
||||||
h--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_box.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
draw a filled box
|
|
||||||
restriction: does not work for w = 0 or h = 0
|
|
||||||
*/
|
|
||||||
void u8g2_DrawBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
|
|
||||||
{
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
while( h != 0 )
|
|
||||||
{
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, w, 0);
|
|
||||||
y++;
|
|
||||||
h--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
draw a frame (empty box)
|
|
||||||
restriction: does not work for w = 0 or h = 0
|
|
||||||
*/
|
|
||||||
void u8g2_DrawFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
|
|
||||||
{
|
|
||||||
u8g2_uint_t xtmp = x;
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, w, 0);
|
|
||||||
if (h >= 2) {
|
|
||||||
h-=2;
|
|
||||||
y++;
|
|
||||||
if (h > 0) {
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, h, 1);
|
|
||||||
x+=w;
|
|
||||||
x--;
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, h, 1);
|
|
||||||
y+=h;
|
|
||||||
}
|
|
||||||
u8g2_DrawHVLine(u8g2, xtmp, y, w, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_DrawRBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r)
|
|
||||||
{
|
|
||||||
u8g2_uint_t xl, yu;
|
|
||||||
u8g2_uint_t yl, xr;
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
xl = x;
|
|
||||||
xl += r;
|
|
||||||
yu = y;
|
|
||||||
yu += r;
|
|
||||||
|
|
||||||
xr = x;
|
|
||||||
xr += w;
|
|
||||||
xr -= r;
|
|
||||||
xr -= 1;
|
|
||||||
|
|
||||||
yl = y;
|
|
||||||
yl += h;
|
|
||||||
yl -= r;
|
|
||||||
yl -= 1;
|
|
||||||
|
|
||||||
u8g2_DrawDisc(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
|
|
||||||
u8g2_DrawDisc(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
|
|
||||||
u8g2_DrawDisc(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
|
|
||||||
u8g2_DrawDisc(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
|
|
||||||
|
|
||||||
{
|
|
||||||
u8g2_uint_t ww, hh;
|
|
||||||
|
|
||||||
ww = w;
|
|
||||||
ww -= r;
|
|
||||||
ww -= r;
|
|
||||||
xl++;
|
|
||||||
yu++;
|
|
||||||
|
|
||||||
if ( ww >= 3 )
|
|
||||||
{
|
|
||||||
ww -= 2;
|
|
||||||
u8g2_DrawBox(u8g2, xl, y, ww, r+1);
|
|
||||||
u8g2_DrawBox(u8g2, xl, yl, ww, r+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
hh = h;
|
|
||||||
hh -= r;
|
|
||||||
hh -= r;
|
|
||||||
//h--;
|
|
||||||
if ( hh >= 3 )
|
|
||||||
{
|
|
||||||
hh -= 2;
|
|
||||||
u8g2_DrawBox(u8g2, x, yu, w, hh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_DrawRFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r)
|
|
||||||
{
|
|
||||||
u8g2_uint_t xl, yu;
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
xl = x;
|
|
||||||
xl += r;
|
|
||||||
yu = y;
|
|
||||||
yu += r;
|
|
||||||
|
|
||||||
{
|
|
||||||
u8g2_uint_t yl, xr;
|
|
||||||
|
|
||||||
xr = x;
|
|
||||||
xr += w;
|
|
||||||
xr -= r;
|
|
||||||
xr -= 1;
|
|
||||||
|
|
||||||
yl = y;
|
|
||||||
yl += h;
|
|
||||||
yl -= r;
|
|
||||||
yl -= 1;
|
|
||||||
|
|
||||||
u8g2_DrawCircle(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
|
|
||||||
u8g2_DrawCircle(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
|
|
||||||
u8g2_DrawCircle(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
|
|
||||||
u8g2_DrawCircle(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
u8g2_uint_t ww, hh;
|
|
||||||
|
|
||||||
ww = w;
|
|
||||||
ww -= r;
|
|
||||||
ww -= r;
|
|
||||||
hh = h;
|
|
||||||
hh -= r;
|
|
||||||
hh -= r;
|
|
||||||
|
|
||||||
xl++;
|
|
||||||
yu++;
|
|
||||||
|
|
||||||
if ( ww >= 3 )
|
|
||||||
{
|
|
||||||
ww -= 2;
|
|
||||||
h--;
|
|
||||||
u8g2_DrawHLine(u8g2, xl, y, ww);
|
|
||||||
u8g2_DrawHLine(u8g2, xl, y+h, ww);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( hh >= 3 )
|
|
||||||
{
|
|
||||||
hh -= 2;
|
|
||||||
w--;
|
|
||||||
u8g2_DrawVLine(u8g2, x, yu, hh);
|
|
||||||
u8g2_DrawVLine(u8g2, x+w, yu, hh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_buffer.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
void u8g2_ClearBuffer(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
size_t cnt;
|
|
||||||
cnt = u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
|
||||||
cnt *= u8g2->tile_buf_height;
|
|
||||||
cnt *= 8;
|
|
||||||
memset(u8g2->tile_buf_ptr, 0, cnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
|
|
||||||
static void u8g2_send_tile_row(u8g2_t *u8g2, uint8_t src_tile_row, uint8_t dest_tile_row)
|
|
||||||
{
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint16_t offset;
|
|
||||||
uint8_t w;
|
|
||||||
|
|
||||||
w = u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
|
||||||
offset = src_tile_row;
|
|
||||||
ptr = u8g2->tile_buf_ptr;
|
|
||||||
offset *= w;
|
|
||||||
offset *= 8;
|
|
||||||
ptr += offset;
|
|
||||||
u8x8_DrawTile(u8g2_GetU8x8(u8g2), 0, dest_tile_row, w, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
write the buffer to the display RAM.
|
|
||||||
For most displays, this will make the content visible to the user.
|
|
||||||
Some displays (like the SSD1606) require a u8x8_RefreshDisplay()
|
|
||||||
*/
|
|
||||||
static void u8g2_send_buffer(u8g2_t *u8g2) U8X8_NOINLINE;
|
|
||||||
static void u8g2_send_buffer(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
uint8_t src_row;
|
|
||||||
uint8_t src_max;
|
|
||||||
uint8_t dest_row;
|
|
||||||
uint8_t dest_max;
|
|
||||||
|
|
||||||
src_row = 0;
|
|
||||||
src_max = u8g2->tile_buf_height;
|
|
||||||
dest_row = u8g2->tile_curr_row;
|
|
||||||
dest_max = u8g2_GetU8x8(u8g2)->display_info->tile_height;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8g2_send_tile_row(u8g2, src_row, dest_row);
|
|
||||||
src_row++;
|
|
||||||
dest_row++;
|
|
||||||
} while( src_row < src_max && dest_row < dest_max );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* same as u8g2_send_buffer but also send the DISPLAY_REFRESH message (used by SSD1606) */
|
|
||||||
void u8g2_SendBuffer(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2_send_buffer(u8g2);
|
|
||||||
u8x8_RefreshDisplay( u8g2_GetU8x8(u8g2) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row)
|
|
||||||
{
|
|
||||||
u8g2->tile_curr_row = row;
|
|
||||||
u8g2->cb->update_dimension(u8g2);
|
|
||||||
u8g2->cb->update_page_win(u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_FirstPage(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
if ( u8g2->is_auto_page_clear )
|
|
||||||
{
|
|
||||||
u8g2_ClearBuffer(u8g2);
|
|
||||||
}
|
|
||||||
u8g2_SetBufferCurrTileRow(u8g2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8g2_NextPage(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
uint8_t row;
|
|
||||||
u8g2_send_buffer(u8g2);
|
|
||||||
row = u8g2->tile_curr_row;
|
|
||||||
row += u8g2->tile_buf_height;
|
|
||||||
if ( row >= u8g2_GetU8x8(u8g2)->display_info->tile_height )
|
|
||||||
{
|
|
||||||
u8x8_RefreshDisplay( u8g2_GetU8x8(u8g2) );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if ( u8g2->is_auto_page_clear )
|
|
||||||
{
|
|
||||||
u8g2_ClearBuffer(u8g2);
|
|
||||||
}
|
|
||||||
u8g2_SetBufferCurrTileRow(u8g2, row);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
/*
|
|
||||||
Description:
|
|
||||||
Update a sub area of the display, given by tile position, width and height.
|
|
||||||
The arguments are "tile" coordinates. Any u8g2 rotation is ignored.
|
|
||||||
This procedure only checks whether full buffer mode is active.
|
|
||||||
There is no error checking for the arguments: It is the responsibility of the
|
|
||||||
user to ensure, that the provided arguments are correct.
|
|
||||||
|
|
||||||
Limitations:
|
|
||||||
- Only available in full buffer mode (will not do anything in page mode)
|
|
||||||
- Tile positions and sizes (pixel position divided by 8)
|
|
||||||
- Any display rotation/mirror is ignored
|
|
||||||
- Only works with displays, which support U8x8 API
|
|
||||||
- Will not send the e-paper refresh message (will probably not work with e-paper devices)
|
|
||||||
*/
|
|
||||||
void u8g2_UpdateDisplayArea(u8g2_t *u8g2, uint8_t tx, uint8_t ty, uint8_t tw, uint8_t th)
|
|
||||||
{
|
|
||||||
uint16_t page_size;
|
|
||||||
uint8_t *ptr;
|
|
||||||
|
|
||||||
/* check, whether we are in full buffer mode */
|
|
||||||
if ( u8g2->tile_buf_height != u8g2_GetU8x8(u8g2)->display_info->tile_height )
|
|
||||||
return; /* not in full buffer mode, do nothing */
|
|
||||||
|
|
||||||
page_size = u8g2->pixel_buf_width; /* 8*u8g2->u8g2_GetU8x8(u8g2)->display_info->tile_width */
|
|
||||||
|
|
||||||
ptr = u8g2_GetBufferPtr(u8g2);
|
|
||||||
ptr += tx*8;
|
|
||||||
ptr += page_size*ty;
|
|
||||||
|
|
||||||
while( th > 0 )
|
|
||||||
{
|
|
||||||
u8x8_DrawTile( u8g2_GetU8x8(u8g2), tx, ty, tw, ptr );
|
|
||||||
ptr += page_size;
|
|
||||||
ty++;
|
|
||||||
th--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* same as sendBuffer, but does not send the ePaper refresh message */
|
|
||||||
void u8g2_UpdateDisplay(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2_send_buffer(u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
|
|
||||||
/* vertical_top memory architecture */
|
|
||||||
void u8g2_WriteBufferPBM(u8g2_t *u8g2, void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
|
|
||||||
u8x8_capture_write_pbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_1, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_WriteBufferXBM(u8g2_t *u8g2, void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
|
|
||||||
u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_1, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* horizontal right memory architecture */
|
|
||||||
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
|
|
||||||
void u8g2_WriteBufferPBM2(u8g2_t *u8g2, void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
|
|
||||||
u8x8_capture_write_pbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_2, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_WriteBufferXBM2(u8g2_t *u8g2, void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
|
|
||||||
u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_2, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,313 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_button.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Description:
|
|
||||||
Draws normal or inverted text with optional frame around text.
|
|
||||||
The text (and the frame) can be horizontally centered around the provided reference position.
|
|
||||||
This procedure will use the current draw color and current font. The height of the frame
|
|
||||||
depends on the setting of setFontRefHeightText(), setFontRefHeightExtendedText() or setFontRefHeightAll()
|
|
||||||
|
|
||||||
|
|
||||||
Note 1: drawColor 2 (XOR) is not supported. Result will be broken with draw color 2.
|
|
||||||
Note 2: This procedure will enforce font mode 1 (transparent mode)
|
|
||||||
Note 3: Some fonts may add an extra gap on the right side. This is a font problem and can not be avoided (for example inb16 has this problem).
|
|
||||||
|
|
||||||
|
|
||||||
The height of the button is defined by the current font and
|
|
||||||
setFontRefHeightText,
|
|
||||||
setFontRefHeightExtendedText
|
|
||||||
setFontRefHeightAll
|
|
||||||
Right padding might be influenced by the font.
|
|
||||||
For example u8g2_font_inb16 may add an extra pixel gap (increase padding by one)
|
|
||||||
on the right side.
|
|
||||||
The current draw color is considered, but only draw color 0 and 1 are supported
|
|
||||||
|
|
||||||
This function requires transparent font mode: setFontMode(1)
|
|
||||||
|
|
||||||
Side effect: Font transparent mode is enabled setFontMode(1)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
flags:
|
|
||||||
|
|
||||||
U8G2_BTN_BW1 0x01
|
|
||||||
U8G2_BTN_BW2 0x02
|
|
||||||
U8G2_BTN_BW3 0x03
|
|
||||||
|
|
||||||
|
|
||||||
U8G2_BTN_SHADOW0 0x08
|
|
||||||
U8G2_BTN_SHADOW1 0x10
|
|
||||||
U8G2_BTN_SHADOW2 0x18
|
|
||||||
|
|
||||||
U8G2_BTN_INV 0x20
|
|
||||||
|
|
||||||
U8G2_BTN_HCENTER 0x40
|
|
||||||
|
|
||||||
U8G2_BTN_XFRAME 0x80
|
|
||||||
|
|
||||||
Total size without shadow: width+2*padding_h+2*border
|
|
||||||
Total size with U8G2_BTN_SHADOW0: width+2*padding_h+3*border
|
|
||||||
Total size with U8G2_BTN_SHADOW1: width+2*padding_h+3*border+1
|
|
||||||
Total size with U8G2_BTN_SHADOW2: width+2*padding_h+3*border+2
|
|
||||||
|
|
||||||
U8G2_BTN_XFRAME:
|
|
||||||
draw another one pixel frame with one pixel gap, will not look good with shadow
|
|
||||||
*/
|
|
||||||
|
|
||||||
void u8g2_DrawButtonFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t text_width, u8g2_uint_t padding_h, u8g2_uint_t padding_v)
|
|
||||||
{
|
|
||||||
u8g2_uint_t w = text_width;
|
|
||||||
|
|
||||||
u8g2_uint_t xx, yy, ww, hh;
|
|
||||||
|
|
||||||
u8g2_uint_t gap_frame = U8G2_BTN_BW_MASK+1;
|
|
||||||
|
|
||||||
u8g2_uint_t border_width = flags & U8G2_BTN_BW_MASK;
|
|
||||||
|
|
||||||
int8_t a = u8g2_GetAscent(u8g2);
|
|
||||||
int8_t d = u8g2_GetDescent(u8g2);
|
|
||||||
|
|
||||||
uint8_t color_backup = u8g2->draw_color;
|
|
||||||
|
|
||||||
|
|
||||||
if ( flags & U8G2_BTN_XFRAME )
|
|
||||||
{
|
|
||||||
border_width++;
|
|
||||||
gap_frame = border_width;
|
|
||||||
border_width++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
|
|
||||||
xx = x;
|
|
||||||
xx -= padding_h;
|
|
||||||
xx -= border_width;
|
|
||||||
ww = w+2*padding_h+2*border_width;
|
|
||||||
|
|
||||||
yy = y;
|
|
||||||
yy += u8g2->font_calc_vref(u8g2);
|
|
||||||
yy -= a;
|
|
||||||
yy -= padding_v;
|
|
||||||
yy -= border_width;
|
|
||||||
hh = a-d+2*padding_v+2*border_width;
|
|
||||||
if ( border_width == 0 )
|
|
||||||
break;
|
|
||||||
if ( border_width == gap_frame )
|
|
||||||
{
|
|
||||||
u8g2_SetDrawColor(u8g2, color_backup == 0 ? 1 : 0);
|
|
||||||
}
|
|
||||||
u8g2_DrawFrame(u8g2, xx, yy, ww, hh);
|
|
||||||
u8g2_SetDrawColor(u8g2, color_backup);
|
|
||||||
|
|
||||||
if ( flags & U8G2_BTN_SHADOW_MASK )
|
|
||||||
{
|
|
||||||
if ( border_width == (flags & U8G2_BTN_BW_MASK) )
|
|
||||||
{
|
|
||||||
u8g2_uint_t i;
|
|
||||||
u8g2_uint_t shadow_gap = (flags & U8G2_BTN_SHADOW_MASK) >> U8G2_BTN_SHADOW_POS;
|
|
||||||
shadow_gap--;
|
|
||||||
for( i = 0; i < border_width; i++ )
|
|
||||||
{
|
|
||||||
u8g2_DrawHLine(u8g2, xx+border_width+shadow_gap,yy+hh+i+shadow_gap,ww);
|
|
||||||
u8g2_DrawVLine(u8g2, xx+ww+i+shadow_gap,yy+border_width+shadow_gap,hh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
border_width--;
|
|
||||||
} /* for */
|
|
||||||
|
|
||||||
if ( flags & U8G2_BTN_INV )
|
|
||||||
{
|
|
||||||
u8g2_SetDrawColor(u8g2, 2); /* XOR */
|
|
||||||
u8g2_DrawBox(u8g2, xx, yy, ww, hh);
|
|
||||||
u8g2_SetDrawColor(u8g2, color_backup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t width, u8g2_uint_t padding_h, u8g2_uint_t padding_v, const char *text)
|
|
||||||
{
|
|
||||||
u8g2_uint_t w = u8g2_GetUTF8Width(u8g2, text);
|
|
||||||
|
|
||||||
u8g2_uint_t text_x_offset = 0;
|
|
||||||
|
|
||||||
if ( flags & U8G2_BTN_HCENTER )
|
|
||||||
x -= (w+1)/2;
|
|
||||||
|
|
||||||
if ( w < width )
|
|
||||||
{
|
|
||||||
if ( flags & U8G2_BTN_HCENTER )
|
|
||||||
{
|
|
||||||
text_x_offset = (width-w)/2;
|
|
||||||
}
|
|
||||||
w = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2_SetFontMode(u8g2, 1);
|
|
||||||
u8g2_DrawUTF8(u8g2, x,y, text);
|
|
||||||
u8g2_DrawButtonFrame(u8g2, x-text_x_offset, y, flags, w, padding_h, padding_v);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef NOT_USED
|
|
||||||
void u8g2_Draw4Pixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w)
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x,y-1);
|
|
||||||
u8g2_DrawPixel(u8g2, x+w-1,y-1);
|
|
||||||
u8g2_DrawPixel(u8g2, x+w-1,y-w);
|
|
||||||
u8g2_DrawPixel(u8g2, x,y-w);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawRadio(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t is_checked)
|
|
||||||
{
|
|
||||||
uint8_t color_backup = u8g2->draw_color;
|
|
||||||
u8g2_DrawCheckbox(u8g2, x,y,w,is_checked);
|
|
||||||
u8g2_SetDrawColor(u8g2, 2);
|
|
||||||
u8g2_Draw4Pixel(u8g2, x,y,w);
|
|
||||||
if ( is_checked )
|
|
||||||
{
|
|
||||||
//u8g2_Draw4Pixel(u8g2, x+2,y-2,w-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2_SetDrawColor(u8g2, color_backup );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _THIS_CODE_SHOULD_BE_REWRITTEN_WITHOUT_PADWIDTH_
|
|
||||||
|
|
||||||
/*
|
|
||||||
Shadow is not supported
|
|
||||||
Note: radius must be at least as high as the border width
|
|
||||||
|
|
||||||
border width | good radius values
|
|
||||||
1 | 3, 5, 7, 8, ...
|
|
||||||
2 | 3, 5, 7, 8, ...
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
void u8g2_DrawRButtonUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t flags, u8g2_uint_t padding_h_or_width, u8g2_uint_t padding_v, u8g2_uint_t r, const char *text)
|
|
||||||
{
|
|
||||||
u8g2_uint_t w = u8g2_GetUTF8Width(u8g2, text);
|
|
||||||
//u8g2_uint_t w = u8g2_GetExactStrWidth(u8g2, text);
|
|
||||||
|
|
||||||
u8g2_uint_t xx, yy, ww, hh;
|
|
||||||
|
|
||||||
u8g2_uint_t border_width = flags & U8G2_BTN_BW_MASK;
|
|
||||||
u8g2_uint_t padding_h = padding_h_or_width;
|
|
||||||
u8g2_uint_t text_x_offset = 0; // used for U8G2_BTN_PADWIDTH mode
|
|
||||||
|
|
||||||
int8_t a = u8g2_GetAscent(u8g2);
|
|
||||||
int8_t d = u8g2_GetDescent(u8g2);
|
|
||||||
uint8_t color_backup = u8g2->draw_color;
|
|
||||||
|
|
||||||
|
|
||||||
if ( flags & U8G2_BTN_HCENTER )
|
|
||||||
x -= w/2;
|
|
||||||
|
|
||||||
if ( flags & U8G2_BTN_PADWIDTH )
|
|
||||||
{
|
|
||||||
padding_h = 0;
|
|
||||||
if ( w < padding_h_or_width )
|
|
||||||
{
|
|
||||||
if ( flags & U8G2_BTN_HCENTER )
|
|
||||||
{
|
|
||||||
text_x_offset = (padding_h_or_width-w)/2;
|
|
||||||
}
|
|
||||||
w = padding_h_or_width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
u8g2_SetFontMode(u8g2, 1);
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
if ( padding_h >= u8g2_GetDisplayWidth(u8g2)/2 ) // padding_h is zero if U8G2_BTN_PADWIDTH is set
|
|
||||||
{
|
|
||||||
xx = (flags & U8G2_BTN_BW_MASK) - border_width;
|
|
||||||
ww = u8g2_GetDisplayWidth(u8g2);
|
|
||||||
ww -= 2*((flags & U8G2_BTN_BW_MASK) - border_width);
|
|
||||||
//printf("xx=%d ww=%d\n", xx, ww);
|
|
||||||
//printf("clip_x1=%d clip_x0=%d\n", u8g2->clip_x1, u8g2->clip_x0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xx = x;
|
|
||||||
xx -= text_x_offset;
|
|
||||||
xx -= padding_h;
|
|
||||||
xx -= border_width;
|
|
||||||
ww = w+2*padding_h+2*border_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
yy = y;
|
|
||||||
yy += u8g2->font_calc_vref(u8g2);
|
|
||||||
yy -= a;
|
|
||||||
yy -= padding_v;
|
|
||||||
yy -= border_width;
|
|
||||||
hh = a-d+2*padding_v+2*border_width;
|
|
||||||
if ( border_width == 0 )
|
|
||||||
break;
|
|
||||||
u8g2_DrawRFrame(u8g2, xx, yy, ww, hh, r);
|
|
||||||
if ( (flags & U8G2_BTN_BW_MASK) > 1 )
|
|
||||||
u8g2_DrawRFrame(u8g2, xx, yy, ww, hh, r+1);
|
|
||||||
|
|
||||||
border_width--;
|
|
||||||
if ( r > 1 )
|
|
||||||
r--;
|
|
||||||
}
|
|
||||||
if ( flags & U8G2_BTN_INV )
|
|
||||||
{
|
|
||||||
u8g2_DrawRBox(u8g2, xx, yy, ww, hh,r);
|
|
||||||
u8g2_SetDrawColor(u8g2, 1-u8g2->draw_color);
|
|
||||||
}
|
|
||||||
u8g2_DrawUTF8(u8g2, x,y, text);
|
|
||||||
u8g2_SetDrawColor(u8g2, color_backup);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,479 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_circle.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
/*==============================================*/
|
|
||||||
/* Circle */
|
|
||||||
|
|
||||||
static void u8g2_draw_circle_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
|
|
||||||
|
|
||||||
static void u8g2_draw_circle_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
|
|
||||||
{
|
|
||||||
/* upper right */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 + x, y0 - y);
|
|
||||||
u8g2_DrawPixel(u8g2, x0 + y, y0 - x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* upper left */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 - x, y0 - y);
|
|
||||||
u8g2_DrawPixel(u8g2, x0 - y, y0 - x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower right */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 + x, y0 + y);
|
|
||||||
u8g2_DrawPixel(u8g2, x0 + y, y0 + x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower left */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 - x, y0 + y);
|
|
||||||
u8g2_DrawPixel(u8g2, x0 - y, y0 + x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8g2_draw_circle(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
|
|
||||||
{
|
|
||||||
u8g2_int_t f;
|
|
||||||
u8g2_int_t ddF_x;
|
|
||||||
u8g2_int_t ddF_y;
|
|
||||||
u8g2_uint_t x;
|
|
||||||
u8g2_uint_t y;
|
|
||||||
|
|
||||||
f = 1;
|
|
||||||
f -= rad;
|
|
||||||
ddF_x = 1;
|
|
||||||
ddF_y = 0;
|
|
||||||
ddF_y -= rad;
|
|
||||||
ddF_y *= 2;
|
|
||||||
x = 0;
|
|
||||||
y = rad;
|
|
||||||
|
|
||||||
u8g2_draw_circle_section(u8g2, x, y, x0, y0, option);
|
|
||||||
|
|
||||||
while ( x < y )
|
|
||||||
{
|
|
||||||
if (f >= 0)
|
|
||||||
{
|
|
||||||
y--;
|
|
||||||
ddF_y += 2;
|
|
||||||
f += ddF_y;
|
|
||||||
}
|
|
||||||
x++;
|
|
||||||
ddF_x += 2;
|
|
||||||
f += ddF_x;
|
|
||||||
|
|
||||||
u8g2_draw_circle_section(u8g2, x, y, x0, y0, option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawCircle(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
|
|
||||||
{
|
|
||||||
/* check for bounding box */
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
{
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x0-rad, y0-rad, x0+rad+1, y0+rad+1) == 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
|
|
||||||
/* draw circle */
|
|
||||||
u8g2_draw_circle(u8g2, x0, y0, rad, option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================================*/
|
|
||||||
/* Disk */
|
|
||||||
|
|
||||||
static void u8g2_draw_disc_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
|
|
||||||
|
|
||||||
static void u8g2_draw_disc_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
|
|
||||||
{
|
|
||||||
/* upper right */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0+x, y0-y, y+1);
|
|
||||||
u8g2_DrawVLine(u8g2, x0+y, y0-x, x+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* upper left */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0-x, y0-y, y+1);
|
|
||||||
u8g2_DrawVLine(u8g2, x0-y, y0-x, x+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower right */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0+x, y0, y+1);
|
|
||||||
u8g2_DrawVLine(u8g2, x0+y, y0, x+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower left */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0-x, y0, y+1);
|
|
||||||
u8g2_DrawVLine(u8g2, x0-y, y0, x+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8g2_draw_disc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
|
|
||||||
{
|
|
||||||
u8g2_int_t f;
|
|
||||||
u8g2_int_t ddF_x;
|
|
||||||
u8g2_int_t ddF_y;
|
|
||||||
u8g2_uint_t x;
|
|
||||||
u8g2_uint_t y;
|
|
||||||
|
|
||||||
f = 1;
|
|
||||||
f -= rad;
|
|
||||||
ddF_x = 1;
|
|
||||||
ddF_y = 0;
|
|
||||||
ddF_y -= rad;
|
|
||||||
ddF_y *= 2;
|
|
||||||
x = 0;
|
|
||||||
y = rad;
|
|
||||||
|
|
||||||
u8g2_draw_disc_section(u8g2, x, y, x0, y0, option);
|
|
||||||
|
|
||||||
while ( x < y )
|
|
||||||
{
|
|
||||||
if (f >= 0)
|
|
||||||
{
|
|
||||||
y--;
|
|
||||||
ddF_y += 2;
|
|
||||||
f += ddF_y;
|
|
||||||
}
|
|
||||||
x++;
|
|
||||||
ddF_x += 2;
|
|
||||||
f += ddF_x;
|
|
||||||
|
|
||||||
u8g2_draw_disc_section(u8g2, x, y, x0, y0, option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawDisc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
|
|
||||||
{
|
|
||||||
/* check for bounding box */
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
{
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x0-rad, y0-rad, x0+rad+1, y0+rad+1) == 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
/* draw disc */
|
|
||||||
u8g2_draw_disc(u8g2, x0, y0, rad, option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================================*/
|
|
||||||
/* Ellipse */
|
|
||||||
|
|
||||||
/*
|
|
||||||
Source:
|
|
||||||
Foley, Computer Graphics, p 90
|
|
||||||
*/
|
|
||||||
static void u8g2_draw_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
|
|
||||||
static void u8g2_draw_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
|
|
||||||
{
|
|
||||||
/* upper right */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 + x, y0 - y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* upper left */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 - x, y0 - y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower right */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 + x, y0 + y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower left */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawPixel(u8g2, x0 - x, y0 + y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8g2_draw_ellipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
|
|
||||||
{
|
|
||||||
u8g2_uint_t x, y;
|
|
||||||
u8g2_long_t xchg, ychg;
|
|
||||||
u8g2_long_t err;
|
|
||||||
u8g2_long_t rxrx2;
|
|
||||||
u8g2_long_t ryry2;
|
|
||||||
u8g2_long_t stopx, stopy;
|
|
||||||
|
|
||||||
rxrx2 = rx;
|
|
||||||
rxrx2 *= rx;
|
|
||||||
rxrx2 *= 2;
|
|
||||||
|
|
||||||
ryry2 = ry;
|
|
||||||
ryry2 *= ry;
|
|
||||||
ryry2 *= 2;
|
|
||||||
|
|
||||||
x = rx;
|
|
||||||
y = 0;
|
|
||||||
|
|
||||||
xchg = 1;
|
|
||||||
xchg -= rx;
|
|
||||||
xchg -= rx;
|
|
||||||
xchg *= ry;
|
|
||||||
xchg *= ry;
|
|
||||||
|
|
||||||
ychg = rx;
|
|
||||||
ychg *= rx;
|
|
||||||
|
|
||||||
err = 0;
|
|
||||||
|
|
||||||
stopx = ryry2;
|
|
||||||
stopx *= rx;
|
|
||||||
stopy = 0;
|
|
||||||
|
|
||||||
while( stopx >= stopy )
|
|
||||||
{
|
|
||||||
u8g2_draw_ellipse_section(u8g2, x, y, x0, y0, option);
|
|
||||||
y++;
|
|
||||||
stopy += rxrx2;
|
|
||||||
err += ychg;
|
|
||||||
ychg += rxrx2;
|
|
||||||
if ( 2*err+xchg > 0 )
|
|
||||||
{
|
|
||||||
x--;
|
|
||||||
stopx -= ryry2;
|
|
||||||
err += xchg;
|
|
||||||
xchg += ryry2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x = 0;
|
|
||||||
y = ry;
|
|
||||||
|
|
||||||
xchg = ry;
|
|
||||||
xchg *= ry;
|
|
||||||
|
|
||||||
ychg = 1;
|
|
||||||
ychg -= ry;
|
|
||||||
ychg -= ry;
|
|
||||||
ychg *= rx;
|
|
||||||
ychg *= rx;
|
|
||||||
|
|
||||||
err = 0;
|
|
||||||
|
|
||||||
stopx = 0;
|
|
||||||
|
|
||||||
stopy = rxrx2;
|
|
||||||
stopy *= ry;
|
|
||||||
|
|
||||||
|
|
||||||
while( stopx <= stopy )
|
|
||||||
{
|
|
||||||
u8g2_draw_ellipse_section(u8g2, x, y, x0, y0, option);
|
|
||||||
x++;
|
|
||||||
stopx += ryry2;
|
|
||||||
err += xchg;
|
|
||||||
xchg += ryry2;
|
|
||||||
if ( 2*err+ychg > 0 )
|
|
||||||
{
|
|
||||||
y--;
|
|
||||||
stopy -= rxrx2;
|
|
||||||
err += ychg;
|
|
||||||
ychg += rxrx2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
|
|
||||||
{
|
|
||||||
/* check for bounding box */
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
{
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x0-rx, y0-ry, x0+rx+1, y0+ry+1) == 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
u8g2_draw_ellipse(u8g2, x0, y0, rx, ry, option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================================*/
|
|
||||||
/* Filled Ellipse */
|
|
||||||
|
|
||||||
static void u8g2_draw_filled_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
|
|
||||||
static void u8g2_draw_filled_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
|
|
||||||
{
|
|
||||||
/* upper right */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0+x, y0-y, y+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* upper left */
|
|
||||||
if ( option & U8G2_DRAW_UPPER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0-x, y0-y, y+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower right */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_RIGHT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0+x, y0, y+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lower left */
|
|
||||||
if ( option & U8G2_DRAW_LOWER_LEFT )
|
|
||||||
{
|
|
||||||
u8g2_DrawVLine(u8g2, x0-x, y0, y+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8g2_draw_filled_ellipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
|
|
||||||
{
|
|
||||||
u8g2_uint_t x, y;
|
|
||||||
u8g2_long_t xchg, ychg;
|
|
||||||
u8g2_long_t err;
|
|
||||||
u8g2_long_t rxrx2;
|
|
||||||
u8g2_long_t ryry2;
|
|
||||||
u8g2_long_t stopx, stopy;
|
|
||||||
|
|
||||||
rxrx2 = rx;
|
|
||||||
rxrx2 *= rx;
|
|
||||||
rxrx2 *= 2;
|
|
||||||
|
|
||||||
ryry2 = ry;
|
|
||||||
ryry2 *= ry;
|
|
||||||
ryry2 *= 2;
|
|
||||||
|
|
||||||
x = rx;
|
|
||||||
y = 0;
|
|
||||||
|
|
||||||
xchg = 1;
|
|
||||||
xchg -= rx;
|
|
||||||
xchg -= rx;
|
|
||||||
xchg *= ry;
|
|
||||||
xchg *= ry;
|
|
||||||
|
|
||||||
ychg = rx;
|
|
||||||
ychg *= rx;
|
|
||||||
|
|
||||||
err = 0;
|
|
||||||
|
|
||||||
stopx = ryry2;
|
|
||||||
stopx *= rx;
|
|
||||||
stopy = 0;
|
|
||||||
|
|
||||||
while( stopx >= stopy )
|
|
||||||
{
|
|
||||||
u8g2_draw_filled_ellipse_section(u8g2, x, y, x0, y0, option);
|
|
||||||
y++;
|
|
||||||
stopy += rxrx2;
|
|
||||||
err += ychg;
|
|
||||||
ychg += rxrx2;
|
|
||||||
if ( 2*err+xchg > 0 )
|
|
||||||
{
|
|
||||||
x--;
|
|
||||||
stopx -= ryry2;
|
|
||||||
err += xchg;
|
|
||||||
xchg += ryry2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x = 0;
|
|
||||||
y = ry;
|
|
||||||
|
|
||||||
xchg = ry;
|
|
||||||
xchg *= ry;
|
|
||||||
|
|
||||||
ychg = 1;
|
|
||||||
ychg -= ry;
|
|
||||||
ychg -= ry;
|
|
||||||
ychg *= rx;
|
|
||||||
ychg *= rx;
|
|
||||||
|
|
||||||
err = 0;
|
|
||||||
|
|
||||||
stopx = 0;
|
|
||||||
|
|
||||||
stopy = rxrx2;
|
|
||||||
stopy *= ry;
|
|
||||||
|
|
||||||
|
|
||||||
while( stopx <= stopy )
|
|
||||||
{
|
|
||||||
u8g2_draw_filled_ellipse_section(u8g2, x, y, x0, y0, option);
|
|
||||||
x++;
|
|
||||||
stopx += ryry2;
|
|
||||||
err += xchg;
|
|
||||||
xchg += ryry2;
|
|
||||||
if ( 2*err+ychg > 0 )
|
|
||||||
{
|
|
||||||
y--;
|
|
||||||
stopy -= rxrx2;
|
|
||||||
err += ychg;
|
|
||||||
ychg += rxrx2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawFilledEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
|
|
||||||
{
|
|
||||||
/* check for bounding box */
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
{
|
|
||||||
if ( u8g2_IsIntersection(u8g2, x0-rx, y0-ry, x0+rx+1, y0+ry+1) == 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
u8g2_draw_filled_ellipse(u8g2, x0, y0, rx, ry, option);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_cleardisplay.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
/* Clear screen buffer & display reliable for all u8g2 displays. */
|
|
||||||
/* This is done with u8g2 picture loop, because we can not use the u8x8 function in all cases */
|
|
||||||
void u8g2_ClearDisplay(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2_FirstPage(u8g2);
|
|
||||||
do {
|
|
||||||
} while ( u8g2_NextPage(u8g2) );
|
|
||||||
/*
|
|
||||||
This function is usually called during startup (u8g2.begin()).
|
|
||||||
However the user might want to use full buffer mode with clear and
|
|
||||||
send commands.
|
|
||||||
This will not work because the current tile row is modified by the picture
|
|
||||||
loop above. To fix this, reset the tile row to 0, issue #370
|
|
||||||
A workaround would be, that the user sets the current tile row to 0 manually.
|
|
||||||
*/
|
|
||||||
u8g2_SetBufferCurrTileRow(u8g2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
-431276
File diff suppressed because it is too large
Load Diff
@@ -1,255 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_hvline.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
Calltree
|
|
||||||
|
|
||||||
void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
u8g2->cb->draw_l90
|
|
||||||
u8g2_draw_hv_line_2dir
|
|
||||||
u8g2->ll_hvline(u8g2, x, y, len, dir);
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
/*==========================================================*/
|
|
||||||
/* intersection procedure */
|
|
||||||
|
|
||||||
/*
|
|
||||||
Description:
|
|
||||||
clip range from pos a (included) with line len (a+len excluded) agains c (included) to d (excluded)
|
|
||||||
Assumptions:
|
|
||||||
len > 0
|
|
||||||
c <= d (this is not checked)
|
|
||||||
will return 0 if there is no intersection and if a > b
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_uint_t c, u8g2_uint_t d)
|
|
||||||
{
|
|
||||||
u8g2_uint_t a = *ap;
|
|
||||||
u8g2_uint_t b;
|
|
||||||
b = a;
|
|
||||||
b += *len;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Description:
|
|
||||||
clip range from a (included) to b (excluded) agains c (included) to d (excluded)
|
|
||||||
Assumptions:
|
|
||||||
a <= b (violation is checked and handled correctly)
|
|
||||||
c <= d (this is not checked)
|
|
||||||
will return 0 if there is no intersection and if a > b
|
|
||||||
|
|
||||||
optimized clipping: c is set to 0 --> 27 Oct 2018: again removed the c==0 assumption
|
|
||||||
|
|
||||||
replaced by uint8_t u8g2_clip_intersection2
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* handle the a>b case correctly. If code and time is critical, this could */
|
|
||||||
/* be removed completly (be aware about memory curruption for wrong */
|
|
||||||
/* arguments) or return 0 for a>b (will lead to skipped lines for wrong */
|
|
||||||
/* arguments) */
|
|
||||||
|
|
||||||
/* removing the following if clause completly may lead to memory corruption of a>b */
|
|
||||||
if ( a > b )
|
|
||||||
{
|
|
||||||
/* replacing this if with a simple "return 0;" will not handle the case with negative a */
|
|
||||||
if ( a < d )
|
|
||||||
{
|
|
||||||
b = d;
|
|
||||||
b--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
a = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* from now on, the asumption a <= b is ok */
|
|
||||||
|
|
||||||
if ( a >= d )
|
|
||||||
return 0;
|
|
||||||
if ( b <= c )
|
|
||||||
return 0;
|
|
||||||
if ( a < c )
|
|
||||||
a = c;
|
|
||||||
if ( b > d )
|
|
||||||
b = d;
|
|
||||||
|
|
||||||
*ap = a;
|
|
||||||
b -= a;
|
|
||||||
*len = b;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*==========================================================*/
|
|
||||||
/* draw procedures */
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y Upper left position of the line within the pixel buffer
|
|
||||||
len length of the line in pixel, len must not be 0
|
|
||||||
dir 0: horizontal line (left to right)
|
|
||||||
1: vertical line (top to bottom)
|
|
||||||
This function first adjusts the y position to the local buffer. Then it
|
|
||||||
will clip the line and call u8g2_draw_low_level_hv_line()
|
|
||||||
|
|
||||||
*/
|
|
||||||
void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* clipping happens before the display rotation */
|
|
||||||
|
|
||||||
/* transform to pixel buffer coordinates */
|
|
||||||
y -= u8g2->pixel_curr_row;
|
|
||||||
|
|
||||||
u8g2->ll_hvline(u8g2, x, y, len, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
This is the toplevel function for the hv line draw procedures.
|
|
||||||
This function should be called by the user.
|
|
||||||
|
|
||||||
"dir" may have 4 directions: 0 (left to right), 1, 2, 3 (down up)
|
|
||||||
*/
|
|
||||||
void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
/* Make a call to the callback function (e.g. u8g2_draw_l90_r0). */
|
|
||||||
/* The callback may rotate the hv line */
|
|
||||||
/* after rotation this will call u8g2_draw_hv_line_4dir() */
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
if ( u8g2->is_page_clip_window_intersection != 0 )
|
|
||||||
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
|
||||||
if ( len != 0 )
|
|
||||||
{
|
|
||||||
|
|
||||||
/* convert to two directions */
|
|
||||||
if ( len > 1 )
|
|
||||||
{
|
|
||||||
if ( dir == 2 )
|
|
||||||
{
|
|
||||||
x -= len;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
else if ( dir == 3 )
|
|
||||||
{
|
|
||||||
y -= len;
|
|
||||||
y++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dir &= 1;
|
|
||||||
|
|
||||||
/* clip against the user window */
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
if ( y < u8g2->user_y0 )
|
|
||||||
return;
|
|
||||||
if ( y >= u8g2->user_y1 )
|
|
||||||
return;
|
|
||||||
if ( u8g2_clip_intersection2(&x, &len, u8g2->user_x0, u8g2->user_x1) == 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( x < u8g2->user_x0 )
|
|
||||||
return;
|
|
||||||
if ( x >= u8g2->user_x1 )
|
|
||||||
return;
|
|
||||||
if ( u8g2_clip_intersection2(&y, &len, u8g2->user_y0, u8g2->user_y1) == 0 )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
u8g2->cb->draw_l90(u8g2, x, y, len, dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
|
|
||||||
{
|
|
||||||
// #ifdef U8G2_WITH_INTERSECTION
|
|
||||||
// if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
|
|
||||||
// return;
|
|
||||||
// #endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, len, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
|
|
||||||
{
|
|
||||||
// #ifdef U8G2_WITH_INTERSECTION
|
|
||||||
// if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 )
|
|
||||||
// return;
|
|
||||||
// #endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, len, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
|
|
||||||
{
|
|
||||||
#ifdef U8G2_WITH_INTERSECTION
|
|
||||||
if ( y < u8g2->user_y0 )
|
|
||||||
return;
|
|
||||||
if ( y >= u8g2->user_y1 )
|
|
||||||
return;
|
|
||||||
if ( x < u8g2->user_x0 )
|
|
||||||
return;
|
|
||||||
if ( x >= u8g2->user_x1 )
|
|
||||||
return;
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Assign the draw color for all drawing functions.
|
|
||||||
color may be 0 or 1. The actual color is defined by the display.
|
|
||||||
With color = 1 the drawing function will set the display memory to 1.
|
|
||||||
For OLEDs this ususally means, that the pixel is enabled and the LED
|
|
||||||
at the pixel is turned on.
|
|
||||||
On an LCD it usually means that the LCD segment of the pixel is enabled,
|
|
||||||
which absorbs the light.
|
|
||||||
For eInk/ePaper it means black ink.
|
|
||||||
|
|
||||||
7 Jan 2017: Allow color value 2 for XOR operation.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color)
|
|
||||||
{
|
|
||||||
u8g2->draw_color = color; /* u8g2_SetDrawColor: just assign the argument */
|
|
||||||
if ( color >= 3 )
|
|
||||||
u8g2->draw_color = 1; /* u8g2_SetDrawColor: make color as one if arg is invalid */
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_input_value.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
return:
|
|
||||||
0: value is not changed (HOME/Break Button pressed)
|
|
||||||
1: value has been updated
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t u8g2_UserInterfaceInputValue(u8g2_t *u8g2, const char *title, const char *pre, uint8_t *value, uint8_t lo, uint8_t hi, uint8_t digits, const char *post)
|
|
||||||
{
|
|
||||||
uint8_t line_height;
|
|
||||||
uint8_t height;
|
|
||||||
u8g2_uint_t pixel_height;
|
|
||||||
u8g2_uint_t y, yy;
|
|
||||||
u8g2_uint_t pixel_width;
|
|
||||||
u8g2_uint_t x, xx;
|
|
||||||
|
|
||||||
uint8_t local_value = *value;
|
|
||||||
//uint8_t r; /* not used ??? */
|
|
||||||
uint8_t event;
|
|
||||||
|
|
||||||
/* only horizontal strings are supported, so force this here */
|
|
||||||
u8g2_SetFontDirection(u8g2, 0);
|
|
||||||
|
|
||||||
/* force baseline position */
|
|
||||||
u8g2_SetFontPosBaseline(u8g2);
|
|
||||||
|
|
||||||
/* calculate line height */
|
|
||||||
line_height = u8g2_GetAscent(u8g2);
|
|
||||||
line_height -= u8g2_GetDescent(u8g2);
|
|
||||||
|
|
||||||
|
|
||||||
/* calculate overall height of the input value box */
|
|
||||||
height = 1; /* value input line */
|
|
||||||
height += u8x8_GetStringLineCnt(title);
|
|
||||||
|
|
||||||
/* calculate the height in pixel */
|
|
||||||
pixel_height = height;
|
|
||||||
pixel_height *= line_height;
|
|
||||||
|
|
||||||
|
|
||||||
/* calculate offset from top */
|
|
||||||
y = 0;
|
|
||||||
if ( pixel_height < u8g2_GetDisplayHeight(u8g2) )
|
|
||||||
{
|
|
||||||
y = u8g2_GetDisplayHeight(u8g2);
|
|
||||||
y -= pixel_height;
|
|
||||||
y /= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* calculate offset from left for the label */
|
|
||||||
x = 0;
|
|
||||||
pixel_width = u8g2_GetUTF8Width(u8g2, pre);
|
|
||||||
pixel_width += u8g2_GetUTF8Width(u8g2, "0") * digits;
|
|
||||||
pixel_width += u8g2_GetUTF8Width(u8g2, post);
|
|
||||||
if ( pixel_width < u8g2_GetDisplayWidth(u8g2) )
|
|
||||||
{
|
|
||||||
x = u8g2_GetDisplayWidth(u8g2);
|
|
||||||
x -= pixel_width;
|
|
||||||
x /= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* event loop */
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
u8g2_FirstPage(u8g2);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
/* render */
|
|
||||||
yy = y;
|
|
||||||
yy += u8g2_DrawUTF8Lines(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), line_height, title);
|
|
||||||
xx = x;
|
|
||||||
xx += u8g2_DrawUTF8(u8g2, xx, yy, pre);
|
|
||||||
xx += u8g2_DrawUTF8(u8g2, xx, yy, u8x8_u8toa(local_value, digits));
|
|
||||||
u8g2_DrawUTF8(u8g2, xx, yy, post);
|
|
||||||
} while( u8g2_NextPage(u8g2) );
|
|
||||||
|
|
||||||
#ifdef U8G2_REF_MAN_PIC
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
event = u8x8_GetMenuEvent(u8g2_GetU8x8(u8g2));
|
|
||||||
if ( event == U8X8_MSG_GPIO_MENU_SELECT )
|
|
||||||
{
|
|
||||||
*value = local_value;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_HOME )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_UP )
|
|
||||||
{
|
|
||||||
if ( local_value >= hi )
|
|
||||||
local_value = lo;
|
|
||||||
else
|
|
||||||
local_value++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_DOWN )
|
|
||||||
{
|
|
||||||
if ( local_value <= lo )
|
|
||||||
local_value = hi;
|
|
||||||
else
|
|
||||||
local_value--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* never reached */
|
|
||||||
//return r;
|
|
||||||
}
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_intersection.c
|
|
||||||
|
|
||||||
Intersection calculation, code taken from u8g_clip.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define U8G2_ALWAYS_INLINE __inline__ __attribute__((always_inline))
|
|
||||||
#else
|
|
||||||
#define U8G2_ALWAYS_INLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(U8G2_WITH_INTERSECTION) || defined(U8G2_WITH_CLIP_WINDOW_SUPPORT)
|
|
||||||
|
|
||||||
#ifdef OLD_VERSION_WITH_SYMETRIC_BOUNDARIES
|
|
||||||
|
|
||||||
/*
|
|
||||||
intersection assumptions:
|
|
||||||
a1 <= a2 is always true
|
|
||||||
|
|
||||||
minimized version
|
|
||||||
---1----0 1 b1 <= a2 && b1 > b2
|
|
||||||
-----1--0 1 b2 >= a1 && b1 > b2
|
|
||||||
---1-1--- 1 b1 <= a2 && b2 >= a1
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
calculate the intersection between a0/a1 and v0/v1
|
|
||||||
The intersection check returns one if the range of a0/a1 has an intersection with v0/v1.
|
|
||||||
The intersection check includes the boundary values v1 and a1.
|
|
||||||
|
|
||||||
The following asserts will succeed:
|
|
||||||
assert( u8g2_is_intersection_decision_tree(4, 6, 7, 9) == 0 );
|
|
||||||
assert( u8g2_is_intersection_decision_tree(4, 6, 6, 9) != 0 );
|
|
||||||
assert( u8g2_is_intersection_decision_tree(6, 9, 4, 6) != 0 );
|
|
||||||
assert( u8g2_is_intersection_decision_tree(7, 9, 4, 6) == 0 );
|
|
||||||
*/
|
|
||||||
|
|
||||||
//static uint8_t U8G2_ALWAYS_INLINE u8g2_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
|
||||||
static uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1)
|
|
||||||
{
|
|
||||||
if ( v0 <= a1 )
|
|
||||||
{
|
|
||||||
if ( v1 >= a0 )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( v0 > v1 )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( v1 >= a0 )
|
|
||||||
{
|
|
||||||
if ( v0 > v1 )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* OLD_VERSION_WITH_SYMETRIC_BOUNDARIES */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
version with asymetric boundaries.
|
|
||||||
a1 and v1 are excluded
|
|
||||||
v0 == v1 is not support end return 1
|
|
||||||
*/
|
|
||||||
uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1)
|
|
||||||
{
|
|
||||||
if ( v0 < a1 ) // v0 <= a1
|
|
||||||
{
|
|
||||||
if ( v1 > a0 ) // v1 >= a0
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( v0 > v1 ) // v0 > v1
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( v1 > a0 ) // v1 >= a0
|
|
||||||
{
|
|
||||||
if ( v0 > v1 ) // v0 > v1
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* upper limits are not included (asymetric boundaries) */
|
|
||||||
uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t x1, u8g2_uint_t y1)
|
|
||||||
{
|
|
||||||
if ( u8g2_is_intersection_decision_tree(u8g2->user_y0, u8g2->user_y1, y0, y1) == 0 )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return u8g2_is_intersection_decision_tree(u8g2->user_x0, u8g2->user_x1, x0, x1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* U8G2_WITH_INTERSECTION */
|
|
||||||
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_kerning.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
/* this function is used as "u8g2_get_kerning_cb" */
|
|
||||||
/*
|
|
||||||
uint8_t u8g2_GetNullKerning(u8g2_t *u8g2, uint16_t e1, uint16_t e2)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* this function is used as "u8g2_get_kerning_cb" */
|
|
||||||
uint8_t u8g2_GetKerning(U8X8_UNUSED u8g2_t *u8g2, u8g2_kerning_t *kerning, uint16_t e1, uint16_t e2)
|
|
||||||
{
|
|
||||||
uint16_t i1, i2, cnt, end;
|
|
||||||
if ( kerning == NULL )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* search for the encoding in the first table */
|
|
||||||
cnt = kerning->first_table_cnt;
|
|
||||||
cnt--; /* ignore the last element of the table, which is 0x0ffff */
|
|
||||||
for( i1 = 0; i1 < cnt; i1++ )
|
|
||||||
{
|
|
||||||
if ( kerning->first_encoding_table[i1] == e1 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( i1 >= cnt )
|
|
||||||
return 0; /* e1 not part of the kerning table, return 0 */
|
|
||||||
|
|
||||||
/* get the upper index for i2 */
|
|
||||||
end = kerning->index_to_second_table[i1+1];
|
|
||||||
for( i2 = kerning->index_to_second_table[i1]; i2 < end; i2++ )
|
|
||||||
{
|
|
||||||
if ( kerning->second_encoding_table[i2] == e2 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( i2 >= end )
|
|
||||||
return 0; /* e2 not part of any pair with e1, return 0 */
|
|
||||||
|
|
||||||
return kerning->kerning_values[i2];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8g2_GetKerningByTable(U8X8_UNUSED u8g2_t *u8g2, const uint16_t *kt, uint16_t e1, uint16_t e2)
|
|
||||||
{
|
|
||||||
uint16_t i;
|
|
||||||
i = 0;
|
|
||||||
if ( kt == NULL )
|
|
||||||
return 0;
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
if ( kt[i] == 0x0ffff )
|
|
||||||
break;
|
|
||||||
if ( kt[i] == e1 && kt[i+1] == e2 )
|
|
||||||
return kt[i+2];
|
|
||||||
i+=3;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_box.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_DrawLine(u8g2_t *u8g2, u8g2_uint_t x1, u8g2_uint_t y1, u8g2_uint_t x2, u8g2_uint_t y2)
|
|
||||||
{
|
|
||||||
u8g2_uint_t tmp;
|
|
||||||
u8g2_uint_t x,y;
|
|
||||||
u8g2_uint_t dx, dy;
|
|
||||||
u8g2_int_t err;
|
|
||||||
u8g2_int_t ystep;
|
|
||||||
|
|
||||||
uint8_t swapxy = 0;
|
|
||||||
|
|
||||||
/* no intersection check at the moment, should be added... */
|
|
||||||
|
|
||||||
if ( x1 > x2 ) dx = x1-x2; else dx = x2-x1;
|
|
||||||
if ( y1 > y2 ) dy = y1-y2; else dy = y2-y1;
|
|
||||||
|
|
||||||
if ( dy > dx )
|
|
||||||
{
|
|
||||||
swapxy = 1;
|
|
||||||
tmp = dx; dx =dy; dy = tmp;
|
|
||||||
tmp = x1; x1 =y1; y1 = tmp;
|
|
||||||
tmp = x2; x2 =y2; y2 = tmp;
|
|
||||||
}
|
|
||||||
if ( x1 > x2 )
|
|
||||||
{
|
|
||||||
tmp = x1; x1 =x2; x2 = tmp;
|
|
||||||
tmp = y1; y1 =y2; y2 = tmp;
|
|
||||||
}
|
|
||||||
err = dx >> 1;
|
|
||||||
if ( y2 > y1 ) ystep = 1; else ystep = -1;
|
|
||||||
y = y1;
|
|
||||||
|
|
||||||
#ifndef U8G2_16BIT
|
|
||||||
if ( x2 == 255 )
|
|
||||||
x2--;
|
|
||||||
#else
|
|
||||||
if ( x2 == 0xffff )
|
|
||||||
x2--;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for( x = x1; x <= x2; x++ )
|
|
||||||
{
|
|
||||||
if ( swapxy == 0 )
|
|
||||||
u8g2_DrawPixel(u8g2, x, y);
|
|
||||||
else
|
|
||||||
u8g2_DrawPixel(u8g2, y, x);
|
|
||||||
err -= (u8g2_uint_t)dy;
|
|
||||||
if ( err < 0 )
|
|
||||||
{
|
|
||||||
y += (u8g2_uint_t)ystep;
|
|
||||||
err += (u8g2_uint_t)dx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,371 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_ll_hvline.c
|
|
||||||
|
|
||||||
low level hvline
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*ptr |= or_mask
|
|
||||||
*ptr ^= xor_mask
|
|
||||||
|
|
||||||
color = 0: or_mask = 1, xor_mask = 1
|
|
||||||
color = 1: or_mask = 1, xor_mask = 0
|
|
||||||
color = 2: or_mask = 0, xor_mask = 1
|
|
||||||
|
|
||||||
if ( color <= 1 )
|
|
||||||
or_mask = mask;
|
|
||||||
if ( color != 1 )
|
|
||||||
xor_mask = mask;
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
/*
|
|
||||||
u8g2_ll_hvline_vertical_top_lsb
|
|
||||||
SSD13xx
|
|
||||||
UC1701
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_HVLINE_SPEED_OPTIMIZATION
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y Upper left position of the line within the local buffer (not the display!)
|
|
||||||
len length of the line in pixel, len must not be 0
|
|
||||||
dir 0: horizontal line (left to right)
|
|
||||||
1: vertical line (top to bottom)
|
|
||||||
asumption:
|
|
||||||
all clipping done
|
|
||||||
*/
|
|
||||||
void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
uint16_t offset;
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t bit_pos, mask;
|
|
||||||
uint8_t or_mask, xor_mask;
|
|
||||||
#ifdef __unix
|
|
||||||
uint8_t *max_ptr = u8g2->tile_buf_ptr + u8g2_GetU8x8(u8g2)->display_info->tile_width*u8g2->tile_buf_height*8;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//assert(x >= u8g2->buf_x0);
|
|
||||||
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
|
|
||||||
//assert(y >= u8g2->buf_y0);
|
|
||||||
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
|
|
||||||
|
|
||||||
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
|
|
||||||
bit_pos = y; /* overflow truncate is ok here... */
|
|
||||||
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
|
|
||||||
mask = 1;
|
|
||||||
mask <<= bit_pos;
|
|
||||||
|
|
||||||
or_mask = 0;
|
|
||||||
xor_mask = 0;
|
|
||||||
if ( u8g2->draw_color <= 1 )
|
|
||||||
or_mask = mask;
|
|
||||||
if ( u8g2->draw_color != 1 )
|
|
||||||
xor_mask = mask;
|
|
||||||
|
|
||||||
|
|
||||||
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
|
|
||||||
offset &= ~7;
|
|
||||||
offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
|
||||||
ptr = u8g2->tile_buf_ptr;
|
|
||||||
ptr += offset;
|
|
||||||
ptr += x;
|
|
||||||
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
#ifdef __unix
|
|
||||||
assert(ptr < max_ptr);
|
|
||||||
#endif
|
|
||||||
*ptr |= or_mask;
|
|
||||||
*ptr ^= xor_mask;
|
|
||||||
ptr++;
|
|
||||||
len--;
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
#ifdef __unix
|
|
||||||
assert(ptr < max_ptr);
|
|
||||||
#endif
|
|
||||||
*ptr |= or_mask;
|
|
||||||
*ptr ^= xor_mask;
|
|
||||||
|
|
||||||
bit_pos++;
|
|
||||||
bit_pos &= 7;
|
|
||||||
|
|
||||||
len--;
|
|
||||||
|
|
||||||
if ( bit_pos == 0 )
|
|
||||||
{
|
|
||||||
ptr+=u8g2->pixel_buf_width; /* 6 Jan 17: Changed u8g2->width to u8g2->pixel_buf_width, issue #148 */
|
|
||||||
|
|
||||||
if ( u8g2->draw_color <= 1 )
|
|
||||||
or_mask = 1;
|
|
||||||
if ( u8g2->draw_color != 1 )
|
|
||||||
xor_mask = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
or_mask <<= 1;
|
|
||||||
xor_mask <<= 1;
|
|
||||||
}
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y position within the buffer
|
|
||||||
*/
|
|
||||||
static void u8g2_draw_pixel_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
|
|
||||||
{
|
|
||||||
uint16_t offset;
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t bit_pos, mask;
|
|
||||||
|
|
||||||
//assert(x >= u8g2->buf_x0);
|
|
||||||
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
|
|
||||||
//assert(y >= u8g2->buf_y0);
|
|
||||||
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
|
|
||||||
|
|
||||||
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
|
|
||||||
bit_pos = y; /* overflow truncate is ok here... */
|
|
||||||
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
|
|
||||||
mask = 1;
|
|
||||||
mask <<= bit_pos;
|
|
||||||
|
|
||||||
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
|
|
||||||
offset &= ~7;
|
|
||||||
offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
|
||||||
ptr = u8g2->tile_buf_ptr;
|
|
||||||
ptr += offset;
|
|
||||||
ptr += x;
|
|
||||||
|
|
||||||
|
|
||||||
if ( u8g2->draw_color <= 1 )
|
|
||||||
*ptr |= mask;
|
|
||||||
if ( u8g2->draw_color != 1 )
|
|
||||||
*ptr ^= mask;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y Upper left position of the line within the local buffer (not the display!)
|
|
||||||
len length of the line in pixel, len must not be 0
|
|
||||||
dir 0: horizontal line (left to right)
|
|
||||||
1: vertical line (top to bottom)
|
|
||||||
asumption:
|
|
||||||
all clipping done
|
|
||||||
*/
|
|
||||||
void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8g2_draw_pixel_vertical_top_lsb(u8g2, x, y);
|
|
||||||
x++;
|
|
||||||
len--;
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8g2_draw_pixel_vertical_top_lsb(u8g2, x, y);
|
|
||||||
y++;
|
|
||||||
len--;
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
/*
|
|
||||||
u8g2_ll_hvline_horizontal_right_lsb
|
|
||||||
ST7920
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_HVLINE_SPEED_OPTIMIZATION
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y Upper left position of the line within the local buffer (not the display!)
|
|
||||||
len length of the line in pixel, len must not be 0
|
|
||||||
dir 0: horizontal line (left to right)
|
|
||||||
1: vertical line (top to bottom)
|
|
||||||
asumption:
|
|
||||||
all clipping done
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
|
|
||||||
void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
uint16_t offset;
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t bit_pos;
|
|
||||||
uint8_t mask;
|
|
||||||
uint8_t tile_width = u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
|
||||||
|
|
||||||
bit_pos = x; /* overflow truncate is ok here... */
|
|
||||||
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
|
|
||||||
mask = 128;
|
|
||||||
mask >>= bit_pos;
|
|
||||||
|
|
||||||
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
|
|
||||||
offset *= tile_width;
|
|
||||||
offset += x>>3;
|
|
||||||
ptr = u8g2->tile_buf_ptr;
|
|
||||||
ptr += offset;
|
|
||||||
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8g2->draw_color <= 1 )
|
|
||||||
*ptr |= mask;
|
|
||||||
if ( u8g2->draw_color != 1 )
|
|
||||||
*ptr ^= mask;
|
|
||||||
|
|
||||||
mask >>= 1;
|
|
||||||
if ( mask == 0 )
|
|
||||||
{
|
|
||||||
mask = 128;
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
//x++;
|
|
||||||
len--;
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if ( u8g2->draw_color <= 1 )
|
|
||||||
*ptr |= mask;
|
|
||||||
if ( u8g2->draw_color != 1 )
|
|
||||||
*ptr ^= mask;
|
|
||||||
|
|
||||||
ptr += tile_width;
|
|
||||||
//y++;
|
|
||||||
len--;
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y position within the buffer
|
|
||||||
*/
|
|
||||||
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
|
|
||||||
static void u8g2_draw_pixel_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
|
|
||||||
{
|
|
||||||
uint16_t offset;
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t bit_pos, mask;
|
|
||||||
|
|
||||||
//assert(x >= u8g2->buf_x0);
|
|
||||||
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
|
|
||||||
//assert(y >= u8g2->buf_y0);
|
|
||||||
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
|
|
||||||
|
|
||||||
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
|
|
||||||
bit_pos = x; /* overflow truncate is ok here... */
|
|
||||||
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
|
|
||||||
mask = 128;
|
|
||||||
mask >>= bit_pos;
|
|
||||||
x >>= 3;
|
|
||||||
|
|
||||||
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
|
|
||||||
offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
|
||||||
offset += x;
|
|
||||||
ptr = u8g2->tile_buf_ptr;
|
|
||||||
ptr += offset;
|
|
||||||
|
|
||||||
|
|
||||||
if ( u8g2->draw_color <= 1 )
|
|
||||||
*ptr |= mask;
|
|
||||||
if ( u8g2->draw_color != 1 )
|
|
||||||
*ptr ^= mask;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
x,y Upper left position of the line within the local buffer (not the display!)
|
|
||||||
len length of the line in pixel, len must not be 0
|
|
||||||
dir 0: horizontal line (left to right)
|
|
||||||
1: vertical line (top to bottom)
|
|
||||||
asumption:
|
|
||||||
all clipping done
|
|
||||||
*/
|
|
||||||
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
|
|
||||||
void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8g2_draw_pixel_horizontal_right_lsb(u8g2, x, y);
|
|
||||||
x++;
|
|
||||||
len--;
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8g2_draw_pixel_horizontal_right_lsb(u8g2, x, y);
|
|
||||||
y++;
|
|
||||||
len--;
|
|
||||||
} while( len != 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_message.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
#define SPACE_BETWEEN_BUTTONS_IN_PIXEL 6
|
|
||||||
#define SPACE_BETWEEN_TEXT_AND_BUTTONS_IN_PIXEL 3
|
|
||||||
|
|
||||||
uint8_t u8g2_draw_button_line(u8g2_t *u8g2, u8g2_uint_t y, u8g2_uint_t w, uint8_t cursor, const char *s)
|
|
||||||
{
|
|
||||||
u8g2_uint_t button_line_width;
|
|
||||||
|
|
||||||
uint8_t i;
|
|
||||||
uint8_t cnt;
|
|
||||||
uint8_t is_invert;
|
|
||||||
|
|
||||||
u8g2_uint_t d;
|
|
||||||
u8g2_uint_t x;
|
|
||||||
|
|
||||||
cnt = u8x8_GetStringLineCnt(s);
|
|
||||||
|
|
||||||
|
|
||||||
/* calculate the width of the button line */
|
|
||||||
button_line_width = 0;
|
|
||||||
for( i = 0; i < cnt; i++ )
|
|
||||||
{
|
|
||||||
button_line_width += u8g2_GetUTF8Width(u8g2, u8x8_GetStringLineStart(i, s));
|
|
||||||
}
|
|
||||||
button_line_width += (cnt-1)*SPACE_BETWEEN_BUTTONS_IN_PIXEL; /* add some space between the buttons */
|
|
||||||
|
|
||||||
/* calculate the left offset */
|
|
||||||
d = 0;
|
|
||||||
if ( button_line_width < w )
|
|
||||||
{
|
|
||||||
d = w;
|
|
||||||
d -= button_line_width;
|
|
||||||
d /= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* draw the buttons */
|
|
||||||
x = d;
|
|
||||||
for( i = 0; i < cnt; i++ )
|
|
||||||
{
|
|
||||||
is_invert = 0;
|
|
||||||
if ( i == cursor )
|
|
||||||
is_invert = 1;
|
|
||||||
|
|
||||||
u8g2_DrawUTF8Line(u8g2, x, y, 0, u8x8_GetStringLineStart(i, s), 1, is_invert);
|
|
||||||
x += u8g2_GetUTF8Width(u8g2, u8x8_GetStringLineStart(i, s));
|
|
||||||
x += SPACE_BETWEEN_BUTTONS_IN_PIXEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return the number of buttons */
|
|
||||||
return cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
title1: Multiple lines,separated by '\n'
|
|
||||||
title2: A single line/string which is terminated by '\0' or '\n' . "title2" accepts the return value from u8x8_GetStringLineStart()
|
|
||||||
title3: Multiple lines,separated by '\n'
|
|
||||||
buttons: one more more buttons separated by '\n' and terminated with '\0'
|
|
||||||
side effects:
|
|
||||||
u8g2_SetFontDirection(u8g2, 0);
|
|
||||||
u8g2_SetFontPosBaseline(u8g2);
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t u8g2_UserInterfaceMessage(u8g2_t *u8g2, const char *title1, const char *title2, const char *title3, const char *buttons)
|
|
||||||
{
|
|
||||||
uint8_t height;
|
|
||||||
uint8_t line_height;
|
|
||||||
u8g2_uint_t pixel_height;
|
|
||||||
u8g2_uint_t y, yy;
|
|
||||||
|
|
||||||
uint8_t cursor = 0;
|
|
||||||
uint8_t button_cnt;
|
|
||||||
uint8_t event;
|
|
||||||
|
|
||||||
/* only horizontal strings are supported, so force this here */
|
|
||||||
u8g2_SetFontDirection(u8g2, 0);
|
|
||||||
|
|
||||||
/* force baseline position */
|
|
||||||
u8g2_SetFontPosBaseline(u8g2);
|
|
||||||
|
|
||||||
|
|
||||||
/* calculate line height */
|
|
||||||
line_height = u8g2_GetAscent(u8g2);
|
|
||||||
line_height -= u8g2_GetDescent(u8g2);
|
|
||||||
|
|
||||||
/* calculate overall height of the message box in lines*/
|
|
||||||
height = 1; /* button line */
|
|
||||||
height += u8x8_GetStringLineCnt(title1);
|
|
||||||
if ( title2 != NULL )
|
|
||||||
height++;
|
|
||||||
height += u8x8_GetStringLineCnt(title3);
|
|
||||||
|
|
||||||
/* calculate the height in pixel */
|
|
||||||
pixel_height = height;
|
|
||||||
pixel_height *= line_height;
|
|
||||||
|
|
||||||
/* ... and add the space between the text and the buttons */
|
|
||||||
pixel_height +=SPACE_BETWEEN_TEXT_AND_BUTTONS_IN_PIXEL;
|
|
||||||
|
|
||||||
/* calculate offset from top */
|
|
||||||
y = 0;
|
|
||||||
if ( pixel_height < u8g2_GetDisplayHeight(u8g2) )
|
|
||||||
{
|
|
||||||
y = u8g2_GetDisplayHeight(u8g2);
|
|
||||||
y -= pixel_height;
|
|
||||||
y /= 2;
|
|
||||||
}
|
|
||||||
y += u8g2_GetAscent(u8g2);
|
|
||||||
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
u8g2_FirstPage(u8g2);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
yy = y;
|
|
||||||
/* draw message box */
|
|
||||||
|
|
||||||
yy += u8g2_DrawUTF8Lines(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), line_height, title1);
|
|
||||||
if ( title2 != NULL )
|
|
||||||
{
|
|
||||||
u8g2_DrawUTF8Line(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), title2, 0, 0);
|
|
||||||
yy+=line_height;
|
|
||||||
}
|
|
||||||
yy += u8g2_DrawUTF8Lines(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), line_height, title3);
|
|
||||||
yy += SPACE_BETWEEN_TEXT_AND_BUTTONS_IN_PIXEL;
|
|
||||||
|
|
||||||
button_cnt = u8g2_draw_button_line(u8g2, yy, u8g2_GetDisplayWidth(u8g2), cursor, buttons);
|
|
||||||
|
|
||||||
} while( u8g2_NextPage(u8g2) );
|
|
||||||
|
|
||||||
#ifdef U8G2_REF_MAN_PIC
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
event = u8x8_GetMenuEvent(u8g2_GetU8x8(u8g2));
|
|
||||||
if ( event == U8X8_MSG_GPIO_MENU_SELECT )
|
|
||||||
return cursor+1;
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_HOME )
|
|
||||||
return 0;
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_DOWN )
|
|
||||||
{
|
|
||||||
cursor++;
|
|
||||||
if ( cursor >= button_cnt )
|
|
||||||
cursor = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_UP )
|
|
||||||
{
|
|
||||||
if ( cursor == 0 )
|
|
||||||
cursor = button_cnt;
|
|
||||||
cursor--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* never reached */
|
|
||||||
//return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,346 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g22_polygon.c
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*===========================================*/
|
|
||||||
/* local definitions */
|
|
||||||
|
|
||||||
typedef int16_t pg_word_t;
|
|
||||||
|
|
||||||
|
|
||||||
struct pg_point_struct
|
|
||||||
{
|
|
||||||
pg_word_t x;
|
|
||||||
pg_word_t y;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct _pg_struct pg_struct; /* forward declaration */
|
|
||||||
|
|
||||||
struct pg_edge_struct
|
|
||||||
{
|
|
||||||
pg_word_t x_direction; /* 1, if x2 is greater than x1, -1 otherwise */
|
|
||||||
pg_word_t height;
|
|
||||||
pg_word_t current_x_offset;
|
|
||||||
pg_word_t error_offset;
|
|
||||||
|
|
||||||
/* --- line loop --- */
|
|
||||||
pg_word_t current_y;
|
|
||||||
pg_word_t max_y;
|
|
||||||
pg_word_t current_x;
|
|
||||||
pg_word_t error;
|
|
||||||
|
|
||||||
/* --- outer loop --- */
|
|
||||||
uint8_t (*next_idx_fn)(pg_struct *pg, uint8_t i);
|
|
||||||
uint8_t curr_idx;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* maximum number of points in the polygon */
|
|
||||||
/* can be redefined, but highest possible value is 254 */
|
|
||||||
#define PG_MAX_POINTS 6
|
|
||||||
|
|
||||||
/* index numbers for the pge structures below */
|
|
||||||
#define PG_LEFT 0
|
|
||||||
#define PG_RIGHT 1
|
|
||||||
|
|
||||||
|
|
||||||
struct _pg_struct
|
|
||||||
{
|
|
||||||
struct pg_point_struct list[PG_MAX_POINTS];
|
|
||||||
uint8_t cnt;
|
|
||||||
uint8_t is_min_y_not_flat;
|
|
||||||
pg_word_t total_scan_line_cnt;
|
|
||||||
struct pg_edge_struct pge[2]; /* left and right line draw structures */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*===========================================*/
|
|
||||||
/* procedures, which should not be inlined (save as much flash ROM as possible */
|
|
||||||
|
|
||||||
#define PG_NOINLINE U8G2_NOINLINE
|
|
||||||
|
|
||||||
static uint8_t pge_Next(struct pg_edge_struct *pge) PG_NOINLINE;
|
|
||||||
static uint8_t pg_inc(pg_struct *pg, uint8_t i) PG_NOINLINE;
|
|
||||||
static uint8_t pg_dec(pg_struct *pg, uint8_t i) PG_NOINLINE;
|
|
||||||
static void pg_expand_min_y(pg_struct *pg, pg_word_t min_y, uint8_t pge_idx) PG_NOINLINE;
|
|
||||||
static void pg_line_init(pg_struct * const pg, uint8_t pge_index) PG_NOINLINE;
|
|
||||||
|
|
||||||
/*===========================================*/
|
|
||||||
/* line draw algorithm */
|
|
||||||
|
|
||||||
static uint8_t pge_Next(struct pg_edge_struct *pge)
|
|
||||||
{
|
|
||||||
if ( pge->current_y >= pge->max_y )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
pge->current_x += pge->current_x_offset;
|
|
||||||
pge->error += pge->error_offset;
|
|
||||||
if ( pge->error > 0 )
|
|
||||||
{
|
|
||||||
pge->current_x += pge->x_direction;
|
|
||||||
pge->error -= pge->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
pge->current_y++;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* assumes y2 > y1 */
|
|
||||||
static void pge_Init(struct pg_edge_struct *pge, pg_word_t x1, pg_word_t y1, pg_word_t x2, pg_word_t y2)
|
|
||||||
{
|
|
||||||
pg_word_t dx = x2 - x1;
|
|
||||||
pg_word_t width;
|
|
||||||
|
|
||||||
pge->height = y2 - y1;
|
|
||||||
pge->max_y = y2;
|
|
||||||
pge->current_y = y1;
|
|
||||||
pge->current_x = x1;
|
|
||||||
|
|
||||||
if ( dx >= 0 )
|
|
||||||
{
|
|
||||||
pge->x_direction = 1;
|
|
||||||
width = dx;
|
|
||||||
pge->error = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pge->x_direction = -1;
|
|
||||||
width = -dx;
|
|
||||||
pge->error = 1 - pge->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
pge->current_x_offset = dx / pge->height;
|
|
||||||
pge->error_offset = width % pge->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===========================================*/
|
|
||||||
/* convex polygon algorithm */
|
|
||||||
|
|
||||||
static uint8_t pg_inc(pg_struct *pg, uint8_t i)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if ( i >= pg->cnt )
|
|
||||||
i = 0;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t pg_dec(pg_struct *pg, uint8_t i)
|
|
||||||
{
|
|
||||||
i--;
|
|
||||||
if ( i >= pg->cnt )
|
|
||||||
i = pg->cnt-1;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pg_expand_min_y(pg_struct *pg, pg_word_t min_y, uint8_t pge_idx)
|
|
||||||
{
|
|
||||||
uint8_t i = pg->pge[pge_idx].curr_idx;
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
i = pg->pge[pge_idx].next_idx_fn(pg, i);
|
|
||||||
if ( pg->list[i].y != min_y )
|
|
||||||
break;
|
|
||||||
pg->pge[pge_idx].curr_idx = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t pg_prepare(pg_struct *pg)
|
|
||||||
{
|
|
||||||
pg_word_t max_y;
|
|
||||||
pg_word_t min_y;
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
/* setup the next index procedures */
|
|
||||||
pg->pge[PG_RIGHT].next_idx_fn = pg_inc;
|
|
||||||
pg->pge[PG_LEFT].next_idx_fn = pg_dec;
|
|
||||||
|
|
||||||
/* search for highest and lowest point */
|
|
||||||
max_y = pg->list[0].y;
|
|
||||||
min_y = pg->list[0].y;
|
|
||||||
pg->pge[PG_LEFT].curr_idx = 0;
|
|
||||||
for( i = 1; i < pg->cnt; i++ )
|
|
||||||
{
|
|
||||||
if ( max_y < pg->list[i].y )
|
|
||||||
{
|
|
||||||
max_y = pg->list[i].y;
|
|
||||||
}
|
|
||||||
if ( min_y > pg->list[i].y )
|
|
||||||
{
|
|
||||||
pg->pge[PG_LEFT].curr_idx = i;
|
|
||||||
min_y = pg->list[i].y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* calculate total number of scan lines */
|
|
||||||
pg->total_scan_line_cnt = max_y;
|
|
||||||
pg->total_scan_line_cnt -= min_y;
|
|
||||||
|
|
||||||
/* exit if polygon height is zero */
|
|
||||||
if ( pg->total_scan_line_cnt == 0 )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* if the minimum y side is flat, try to find the lowest and highest x points */
|
|
||||||
pg->pge[PG_RIGHT].curr_idx = pg->pge[PG_LEFT].curr_idx;
|
|
||||||
pg_expand_min_y(pg, min_y, PG_RIGHT);
|
|
||||||
pg_expand_min_y(pg, min_y, PG_LEFT);
|
|
||||||
|
|
||||||
/* check if the min side is really flat (depends on the x values) */
|
|
||||||
pg->is_min_y_not_flat = 1;
|
|
||||||
if ( pg->list[pg->pge[PG_LEFT].curr_idx].x != pg->list[pg->pge[PG_RIGHT].curr_idx].x )
|
|
||||||
{
|
|
||||||
pg->is_min_y_not_flat = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pg->total_scan_line_cnt--;
|
|
||||||
if ( pg->total_scan_line_cnt == 0 )
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pg_hline(pg_struct *pg, u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
pg_word_t x1, x2, y;
|
|
||||||
x1 = pg->pge[PG_LEFT].current_x;
|
|
||||||
x2 = pg->pge[PG_RIGHT].current_x;
|
|
||||||
y = pg->pge[PG_RIGHT].current_y;
|
|
||||||
|
|
||||||
if ( y < 0 )
|
|
||||||
return;
|
|
||||||
if ( y >= (pg_word_t)u8g2_GetDisplayHeight(u8g2) ) // does not work for 256x64 display???
|
|
||||||
return;
|
|
||||||
if ( x1 < x2 )
|
|
||||||
{
|
|
||||||
if ( x2 < 0 )
|
|
||||||
return;
|
|
||||||
if ( x1 >= (pg_word_t)u8g2_GetDisplayWidth(u8g2) )
|
|
||||||
return;
|
|
||||||
if ( x1 < 0 )
|
|
||||||
x1 = 0;
|
|
||||||
if ( x2 >= (pg_word_t)u8g2_GetDisplayWidth(u8g2) )
|
|
||||||
x2 = u8g2_GetDisplayWidth(u8g2);
|
|
||||||
u8g2_DrawHLine(u8g2, x1, y, x2 - x1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( x1 < 0 )
|
|
||||||
return;
|
|
||||||
if ( x2 >= (pg_word_t)u8g2_GetDisplayWidth(u8g2) )
|
|
||||||
return;
|
|
||||||
if ( x2 < 0 )
|
|
||||||
x1 = 0;
|
|
||||||
if ( x1 >= (pg_word_t)u8g2_GetDisplayWidth(u8g2) )
|
|
||||||
x1 = u8g2_GetDisplayWidth(u8g2);
|
|
||||||
u8g2_DrawHLine(u8g2, x2, y, x1 - x2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pg_line_init(pg_struct * const pg, uint8_t pge_index)
|
|
||||||
{
|
|
||||||
struct pg_edge_struct *pge = pg->pge+pge_index;
|
|
||||||
uint8_t idx;
|
|
||||||
pg_word_t x1;
|
|
||||||
pg_word_t y1;
|
|
||||||
pg_word_t x2;
|
|
||||||
pg_word_t y2;
|
|
||||||
|
|
||||||
idx = pge->curr_idx;
|
|
||||||
y1 = pg->list[idx].y;
|
|
||||||
x1 = pg->list[idx].x;
|
|
||||||
idx = pge->next_idx_fn(pg, idx);
|
|
||||||
y2 = pg->list[idx].y;
|
|
||||||
x2 = pg->list[idx].x;
|
|
||||||
pge->curr_idx = idx;
|
|
||||||
|
|
||||||
pge_Init(pge, x1, y1, x2, y2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pg_exec(pg_struct *pg, u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
pg_word_t i = pg->total_scan_line_cnt;
|
|
||||||
|
|
||||||
/* first line is skipped if the min y line is not flat */
|
|
||||||
pg_line_init(pg, PG_LEFT);
|
|
||||||
pg_line_init(pg, PG_RIGHT);
|
|
||||||
|
|
||||||
if ( pg->is_min_y_not_flat != 0 )
|
|
||||||
{
|
|
||||||
pge_Next(&(pg->pge[PG_LEFT]));
|
|
||||||
pge_Next(&(pg->pge[PG_RIGHT]));
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
pg_hline(pg, u8g2);
|
|
||||||
while ( pge_Next(&(pg->pge[PG_LEFT])) == 0 )
|
|
||||||
{
|
|
||||||
pg_line_init(pg, PG_LEFT);
|
|
||||||
}
|
|
||||||
while ( pge_Next(&(pg->pge[PG_RIGHT])) == 0 )
|
|
||||||
{
|
|
||||||
pg_line_init(pg, PG_RIGHT);
|
|
||||||
}
|
|
||||||
i--;
|
|
||||||
} while( i > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===========================================*/
|
|
||||||
/* API procedures */
|
|
||||||
|
|
||||||
static void pg_ClearPolygonXY(pg_struct *pg)
|
|
||||||
{
|
|
||||||
pg->cnt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pg_AddPolygonXY(pg_struct *pg, int16_t x, int16_t y)
|
|
||||||
{
|
|
||||||
if ( pg->cnt < PG_MAX_POINTS )
|
|
||||||
{
|
|
||||||
pg->list[pg->cnt].x = x;
|
|
||||||
pg->list[pg->cnt].y = y;
|
|
||||||
pg->cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pg_DrawPolygon(pg_struct *pg, u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
if ( pg_prepare(pg) == 0 )
|
|
||||||
return;
|
|
||||||
pg_exec(pg, u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
pg_struct u8g2_pg;
|
|
||||||
|
|
||||||
void u8g2_ClearPolygonXY(void)
|
|
||||||
{
|
|
||||||
pg_ClearPolygonXY(&u8g2_pg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_AddPolygonXY(U8X8_UNUSED u8g2_t *u8g2, int16_t x, int16_t y)
|
|
||||||
{
|
|
||||||
pg_AddPolygonXY(&u8g2_pg, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawPolygon(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
pg_DrawPolygon(&u8g2_pg, u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawTriangle(u8g2_t *u8g2, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
|
|
||||||
{
|
|
||||||
u8g2_ClearPolygonXY();
|
|
||||||
u8g2_AddPolygonXY(u8g2, x0, y0);
|
|
||||||
u8g2_AddPolygonXY(u8g2, x1, y1);
|
|
||||||
u8g2_AddPolygonXY(u8g2, x2, y2);
|
|
||||||
u8g2_DrawPolygon(u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,289 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_selection_list.c
|
|
||||||
|
|
||||||
selection list with scroll option
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
|
|
||||||
#define MY_BORDER_SIZE 1
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Draw a string at x,y
|
|
||||||
Center string within w (left adjust if w < pixel len of s)
|
|
||||||
|
|
||||||
Side effects:
|
|
||||||
u8g2_SetFontDirection(u8g2, 0);
|
|
||||||
u8g2_SetFontPosBaseline(u8g2);
|
|
||||||
|
|
||||||
*/
|
|
||||||
void u8g2_DrawUTF8Line(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, const char *s, uint8_t border_size, uint8_t is_invert)
|
|
||||||
{
|
|
||||||
u8g2_uint_t d, str_width;
|
|
||||||
u8g2_uint_t fx, fy, fw, fh;
|
|
||||||
|
|
||||||
/* only horizontal strings are supported, so force this here */
|
|
||||||
u8g2_SetFontDirection(u8g2, 0);
|
|
||||||
|
|
||||||
/* revert y position back to baseline ref */
|
|
||||||
y += u8g2->font_calc_vref(u8g2);
|
|
||||||
|
|
||||||
/* calculate the width of the string in pixel */
|
|
||||||
str_width = u8g2_GetUTF8Width(u8g2, s);
|
|
||||||
|
|
||||||
#ifdef U8G2_BALANCED_STR_WIDTH_CALCULATION
|
|
||||||
/* subtract the first character offset added by the width calculation */
|
|
||||||
str_width -= u8g2_GetXOffsetUTF8(u8g2, s);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* calculate delta d within the box */
|
|
||||||
d = 0;
|
|
||||||
if ( str_width < w )
|
|
||||||
{
|
|
||||||
d = w;
|
|
||||||
d -=str_width;
|
|
||||||
d /= 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
w = str_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* caluclate text box */
|
|
||||||
fx = x;
|
|
||||||
fy = y - u8g2_GetAscent(u8g2) ;
|
|
||||||
fw = w;
|
|
||||||
fh = u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2) ;
|
|
||||||
|
|
||||||
/* draw the box, if inverted */
|
|
||||||
u8g2_SetDrawColor(u8g2, 1);
|
|
||||||
if ( is_invert )
|
|
||||||
{
|
|
||||||
u8g2_DrawBox(u8g2, fx, fy, fw, fh);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* draw the frame */
|
|
||||||
while( border_size > 0 )
|
|
||||||
{
|
|
||||||
fx--;
|
|
||||||
fy--;
|
|
||||||
fw +=2;
|
|
||||||
fh +=2;
|
|
||||||
u8g2_DrawFrame(u8g2, fx, fy, fw, fh );
|
|
||||||
border_size--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_invert )
|
|
||||||
{
|
|
||||||
u8g2_SetDrawColor(u8g2, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8g2_SetDrawColor(u8g2, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* draw the text */
|
|
||||||
u8g2_DrawUTF8(u8g2, x+d, y, s);
|
|
||||||
|
|
||||||
/* revert draw color */
|
|
||||||
u8g2_SetDrawColor(u8g2, 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
draw several lines at position x,y.
|
|
||||||
lines are stored in s and must be separated with '\n'.
|
|
||||||
lines can be centered with respect to "w"
|
|
||||||
if s == NULL nothing is drawn and 0 is returned
|
|
||||||
returns the number of lines in s multiplied with line_height
|
|
||||||
*/
|
|
||||||
u8g2_uint_t u8g2_DrawUTF8Lines(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t line_height, const char *s)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint8_t cnt;
|
|
||||||
u8g2_uint_t yy = 0;
|
|
||||||
cnt = u8x8_GetStringLineCnt(s);
|
|
||||||
//printf("str=%s\n", s);
|
|
||||||
//printf("cnt=%d, y=%d, line_height=%d\n", cnt, y, line_height);
|
|
||||||
for( i = 0; i < cnt; i++ )
|
|
||||||
{
|
|
||||||
//printf(" i=%d, y=%d, line_height=%d\n", i, y, line_height);
|
|
||||||
u8g2_DrawUTF8Line(u8g2, x, y, w, u8x8_GetStringLineStart(i, s), 0, 0);
|
|
||||||
y+=line_height;
|
|
||||||
yy+=line_height;
|
|
||||||
}
|
|
||||||
return yy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
selection list with string line
|
|
||||||
returns line height
|
|
||||||
*/
|
|
||||||
static u8g2_uint_t u8g2_draw_selection_list_line(u8g2_t *u8g2, u8sl_t *u8sl, u8g2_uint_t y, uint8_t idx, const char *s) U8G2_NOINLINE;
|
|
||||||
static u8g2_uint_t u8g2_draw_selection_list_line(u8g2_t *u8g2, u8sl_t *u8sl, u8g2_uint_t y, uint8_t idx, const char *s)
|
|
||||||
{
|
|
||||||
//u8g2_uint_t yy;
|
|
||||||
uint8_t border_size = 0;
|
|
||||||
uint8_t is_invert = 0;
|
|
||||||
|
|
||||||
u8g2_uint_t line_height = u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2)+MY_BORDER_SIZE;
|
|
||||||
|
|
||||||
/* calculate offset from display upper border */
|
|
||||||
//yy = idx;
|
|
||||||
//yy -= u8sl->first_pos;
|
|
||||||
//yy *= line_height;
|
|
||||||
//yy += y;
|
|
||||||
|
|
||||||
/* check whether this is the current cursor line */
|
|
||||||
if ( idx == u8sl->current_pos )
|
|
||||||
{
|
|
||||||
border_size = MY_BORDER_SIZE;
|
|
||||||
is_invert = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the line from the array */
|
|
||||||
s = u8x8_GetStringLineStart(idx, s);
|
|
||||||
|
|
||||||
/* draw the line */
|
|
||||||
if ( s == NULL )
|
|
||||||
s = "";
|
|
||||||
u8g2_DrawUTF8Line(u8g2, MY_BORDER_SIZE, y, u8g2_GetDisplayWidth(u8g2)-2*MY_BORDER_SIZE, s, border_size, is_invert);
|
|
||||||
return line_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_DrawSelectionList(u8g2_t *u8g2, u8sl_t *u8sl, u8g2_uint_t y, const char *s)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
for( i = 0; i < u8sl->visible; i++ )
|
|
||||||
{
|
|
||||||
y += u8g2_draw_selection_list_line(u8g2, u8sl, y, i+u8sl->first_pos, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
title: NULL for no title, valid str for title line. Can contain mutliple lines, separated by '\n'
|
|
||||||
start_pos: default position for the cursor, first line is 1.
|
|
||||||
sl: string list (list of strings separated by \n)
|
|
||||||
returns 0 if user has pressed the home key
|
|
||||||
returns the selected line if user has pressed the select key
|
|
||||||
side effects:
|
|
||||||
u8g2_SetFontDirection(u8g2, 0);
|
|
||||||
u8g2_SetFontPosBaseline(u8g2);
|
|
||||||
|
|
||||||
*/
|
|
||||||
uint8_t u8g2_UserInterfaceSelectionList(u8g2_t *u8g2, const char *title, uint8_t start_pos, const char *sl)
|
|
||||||
{
|
|
||||||
u8sl_t u8sl;
|
|
||||||
u8g2_uint_t yy;
|
|
||||||
|
|
||||||
uint8_t event;
|
|
||||||
|
|
||||||
u8g2_uint_t line_height = u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2)+MY_BORDER_SIZE;
|
|
||||||
|
|
||||||
uint8_t title_lines = u8x8_GetStringLineCnt(title);
|
|
||||||
uint8_t display_lines;
|
|
||||||
|
|
||||||
|
|
||||||
if ( start_pos > 0 ) /* issue 112 */
|
|
||||||
start_pos--; /* issue 112 */
|
|
||||||
|
|
||||||
|
|
||||||
if ( title_lines > 0 )
|
|
||||||
{
|
|
||||||
display_lines = (u8g2_GetDisplayHeight(u8g2)-3) / line_height;
|
|
||||||
u8sl.visible = display_lines;
|
|
||||||
u8sl.visible -= title_lines;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
display_lines = u8g2_GetDisplayHeight(u8g2) / line_height;
|
|
||||||
u8sl.visible = display_lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8sl.total = u8x8_GetStringLineCnt(sl);
|
|
||||||
u8sl.first_pos = 0;
|
|
||||||
u8sl.current_pos = start_pos;
|
|
||||||
|
|
||||||
if ( u8sl.current_pos >= u8sl.total )
|
|
||||||
u8sl.current_pos = u8sl.total-1;
|
|
||||||
if ( u8sl.first_pos+u8sl.visible <= u8sl.current_pos )
|
|
||||||
u8sl.first_pos = u8sl.current_pos-u8sl.visible+1;
|
|
||||||
|
|
||||||
u8g2_SetFontPosBaseline(u8g2);
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
u8g2_FirstPage(u8g2);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
yy = u8g2_GetAscent(u8g2);
|
|
||||||
if ( title_lines > 0 )
|
|
||||||
{
|
|
||||||
yy += u8g2_DrawUTF8Lines(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), line_height, title);
|
|
||||||
|
|
||||||
u8g2_DrawHLine(u8g2, 0, yy-line_height- u8g2_GetDescent(u8g2) + 1, u8g2_GetDisplayWidth(u8g2));
|
|
||||||
|
|
||||||
yy += 3;
|
|
||||||
}
|
|
||||||
u8g2_DrawSelectionList(u8g2, &u8sl, yy, sl);
|
|
||||||
} while( u8g2_NextPage(u8g2) );
|
|
||||||
|
|
||||||
#ifdef U8G2_REF_MAN_PIC
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
event = u8x8_GetMenuEvent(u8g2_GetU8x8(u8g2));
|
|
||||||
if ( event == U8X8_MSG_GPIO_MENU_SELECT )
|
|
||||||
return u8sl.current_pos+1; /* +1, issue 112 */
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_HOME )
|
|
||||||
return 0; /* issue 112: return 0 instead of start_pos */
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_DOWN )
|
|
||||||
{
|
|
||||||
u8sl_Next(&u8sl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_UP )
|
|
||||||
{
|
|
||||||
u8sl_Prev(&u8sl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,469 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8g2_setup.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
|
|
||||||
void u8g2_SetMaxClipWindow(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2->clip_x0 = 0;
|
|
||||||
u8g2->clip_y0 = 0;
|
|
||||||
u8g2->clip_x1 = (u8g2_uint_t)~(u8g2_uint_t)0;
|
|
||||||
u8g2->clip_y1 = (u8g2_uint_t)~(u8g2_uint_t)0;
|
|
||||||
|
|
||||||
u8g2->cb->update_page_win(u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 )
|
|
||||||
{
|
|
||||||
u8g2->clip_x0 = clip_x0;
|
|
||||||
u8g2->clip_y0 = clip_y0;
|
|
||||||
u8g2->clip_x1 = clip_x1;
|
|
||||||
u8g2->clip_y1 = clip_y1;
|
|
||||||
u8g2->cb->update_page_win(u8g2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
/*
|
|
||||||
This procedure is called after setting up the display (u8x8 structure).
|
|
||||||
--> This is the central init procedure for u8g2 object
|
|
||||||
*/
|
|
||||||
void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_draw_ll_hvline_cb ll_hvline_cb, const u8g2_cb_t *u8g2_cb)
|
|
||||||
{
|
|
||||||
u8g2->font = NULL;
|
|
||||||
//u8g2->kerning = NULL;
|
|
||||||
//u8g2->get_kerning_cb = u8g2_GetNullKerning;
|
|
||||||
|
|
||||||
//u8g2->ll_hvline = u8g2_ll_hvline_vertical_top_lsb;
|
|
||||||
u8g2->ll_hvline = ll_hvline_cb;
|
|
||||||
|
|
||||||
u8g2->tile_buf_ptr = buf;
|
|
||||||
u8g2->tile_buf_height = tile_buf_height;
|
|
||||||
|
|
||||||
u8g2->tile_curr_row = 0;
|
|
||||||
|
|
||||||
u8g2->font_decode.is_transparent = 0; /* issue 443 */
|
|
||||||
u8g2->bitmap_transparency = 0;
|
|
||||||
|
|
||||||
u8g2->font_height_mode = 0; /* issue 2046 */
|
|
||||||
u8g2->draw_color = 1;
|
|
||||||
u8g2->is_auto_page_clear = 1;
|
|
||||||
|
|
||||||
u8g2->cb = u8g2_cb;
|
|
||||||
u8g2->cb->update_dimension(u8g2);
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
u8g2_SetMaxClipWindow(u8g2); /* assign a clip window and call the update() procedure */
|
|
||||||
#else
|
|
||||||
u8g2->cb->update_page_win(u8g2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
u8g2_SetFontPosBaseline(u8g2); /* issue 195 */
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_FONT_ROTATION
|
|
||||||
u8g2->font_decode.dir = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Usually the display rotation is set initially, but it could be done later also
|
|
||||||
u8g2_cb can be U8G2_R0..U8G2_R3
|
|
||||||
*/
|
|
||||||
void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
|
|
||||||
{
|
|
||||||
u8g2->cb = u8g2_cb;
|
|
||||||
u8g2->cb->update_dimension(u8g2);
|
|
||||||
u8g2->cb->update_page_win(u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
|
|
||||||
void u8g2_SendF(u8g2_t * u8g2, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list va;
|
|
||||||
va_start(va, fmt);
|
|
||||||
u8x8_cad_vsendf(u8g2_GetU8x8(u8g2), fmt, va);
|
|
||||||
va_end(va);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
/*
|
|
||||||
update dimension:
|
|
||||||
calculate the following variables:
|
|
||||||
u8g2_uint_t buf_x0; left corner of the buffer
|
|
||||||
u8g2_uint_t buf_x1; right corner of the buffer (excluded)
|
|
||||||
u8g2_uint_t buf_y0;
|
|
||||||
u8g2_uint_t buf_y1;
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void u8g2_update_dimension_common(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
const u8x8_display_info_t *display_info = u8g2_GetU8x8(u8g2)->display_info;
|
|
||||||
u8g2_uint_t t;
|
|
||||||
|
|
||||||
t = u8g2->tile_buf_height;
|
|
||||||
t *= 8;
|
|
||||||
u8g2->pixel_buf_height = t;
|
|
||||||
|
|
||||||
t = display_info->tile_width;
|
|
||||||
#ifndef U8G2_16BIT
|
|
||||||
if ( t >= 32 )
|
|
||||||
t = 31;
|
|
||||||
#endif
|
|
||||||
t *= 8;
|
|
||||||
u8g2->pixel_buf_width = t;
|
|
||||||
|
|
||||||
t = u8g2->tile_curr_row;
|
|
||||||
t *= 8;
|
|
||||||
u8g2->pixel_curr_row = t;
|
|
||||||
|
|
||||||
t = u8g2->tile_buf_height;
|
|
||||||
/* handle the case, where the buffer is larger than the (remaining) part of the display */
|
|
||||||
if ( t + u8g2->tile_curr_row > display_info->tile_height )
|
|
||||||
t = display_info->tile_height - u8g2->tile_curr_row;
|
|
||||||
t *= 8;
|
|
||||||
|
|
||||||
u8g2->buf_y0 = u8g2->pixel_curr_row;
|
|
||||||
u8g2->buf_y1 = u8g2->buf_y0;
|
|
||||||
u8g2->buf_y1 += t;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef U8G2_16BIT
|
|
||||||
u8g2->width = display_info->pixel_width;
|
|
||||||
u8g2->height = display_info->pixel_height;
|
|
||||||
#else
|
|
||||||
u8g2->width = 240;
|
|
||||||
if ( display_info->pixel_width <= 240 )
|
|
||||||
u8g2->width = display_info->pixel_width;
|
|
||||||
u8g2->height = display_info->pixel_height;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==========================================================*/
|
|
||||||
/* apply clip window */
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
static void u8g2_apply_clip_window(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
/* check aganst the current user_??? window */
|
|
||||||
if ( u8g2_IsIntersection(u8g2, u8g2->clip_x0, u8g2->clip_y0, u8g2->clip_x1, u8g2->clip_y1) == 0 )
|
|
||||||
{
|
|
||||||
u8g2->is_page_clip_window_intersection = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8g2->is_page_clip_window_intersection = 1;
|
|
||||||
|
|
||||||
if ( u8g2->user_x0 < u8g2->clip_x0 )
|
|
||||||
u8g2->user_x0 = u8g2->clip_x0;
|
|
||||||
if ( u8g2->user_x1 > u8g2->clip_x1 )
|
|
||||||
u8g2->user_x1 = u8g2->clip_x1;
|
|
||||||
if ( u8g2->user_y0 < u8g2->clip_y0 )
|
|
||||||
u8g2->user_y0 = u8g2->clip_y0;
|
|
||||||
if ( u8g2->user_y1 > u8g2->clip_y1 )
|
|
||||||
u8g2->user_y1 = u8g2->clip_y1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
|
||||||
|
|
||||||
/*==========================================================*/
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_update_dimension_r0(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2_update_dimension_common(u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_update_page_win_r0(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2->user_x0 = 0;
|
|
||||||
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
|
|
||||||
|
|
||||||
u8g2->user_y0 = u8g2->buf_y0;
|
|
||||||
u8g2->user_y1 = u8g2->buf_y1;
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
u8g2_apply_clip_window(u8g2);
|
|
||||||
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_update_dimension_r1(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2_update_dimension_common(u8g2);
|
|
||||||
|
|
||||||
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
|
|
||||||
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_update_page_win_r1(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2->user_x0 = u8g2->buf_y0;
|
|
||||||
u8g2->user_x1 = u8g2->buf_y1;
|
|
||||||
|
|
||||||
u8g2->user_y0 = 0;
|
|
||||||
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (which is the real pixel width) */
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
u8g2_apply_clip_window(u8g2);
|
|
||||||
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_update_dimension_r2(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2_update_dimension_common(u8g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_update_page_win_r2(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2->user_x0 = 0;
|
|
||||||
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
|
|
||||||
|
|
||||||
/* there are ases where the height is not a multiple of 8. */
|
|
||||||
/* in such a case u8g2->buf_y1 might be heigher than u8g2->height */
|
|
||||||
u8g2->user_y0 = 0;
|
|
||||||
if ( u8g2->height >= u8g2->buf_y1 )
|
|
||||||
u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
|
|
||||||
u8g2->user_y1 = u8g2->height - u8g2->buf_y0;
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
u8g2_apply_clip_window(u8g2);
|
|
||||||
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_update_dimension_r3(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
u8g2_update_dimension_common(u8g2);
|
|
||||||
|
|
||||||
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
|
|
||||||
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_update_page_win_r3(u8g2_t *u8g2)
|
|
||||||
{
|
|
||||||
/* there are ases where the height is not a multiple of 8. */
|
|
||||||
/* in such a case u8g2->buf_y1 might be heigher than u8g2->width */
|
|
||||||
u8g2->user_x0 = 0;
|
|
||||||
if ( u8g2->width >= u8g2->buf_y1 )
|
|
||||||
u8g2->user_x0 = u8g2->width - u8g2->buf_y1;
|
|
||||||
u8g2->user_x1 = u8g2->width - u8g2->buf_y0;
|
|
||||||
|
|
||||||
u8g2->user_y0 = 0;
|
|
||||||
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (pixel_width) */
|
|
||||||
|
|
||||||
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
||||||
u8g2_apply_clip_window(u8g2);
|
|
||||||
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
extern void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
|
|
||||||
|
|
||||||
|
|
||||||
void u8g2_draw_l90_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
#ifdef __unix
|
|
||||||
assert( dir <= 1 );
|
|
||||||
#endif
|
|
||||||
u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_draw_l90_mirrorr_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
u8g2_uint_t xx;
|
|
||||||
xx = u8g2->width;
|
|
||||||
xx -= x;
|
|
||||||
if ( (dir & 1) == 0 )
|
|
||||||
{
|
|
||||||
xx -= len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xx--;
|
|
||||||
}
|
|
||||||
u8g2_draw_hv_line_2dir(u8g2, xx, y, len, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_draw_mirror_vertical_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
u8g2_uint_t yy;
|
|
||||||
yy = u8g2->height;
|
|
||||||
yy -= y;
|
|
||||||
if ( (dir & 1) == 1 )
|
|
||||||
{
|
|
||||||
yy -= len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yy--;
|
|
||||||
}
|
|
||||||
u8g2_draw_hv_line_2dir(u8g2, x, yy, len, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dir = 0 or 1 */
|
|
||||||
void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
u8g2_uint_t xx, yy;
|
|
||||||
|
|
||||||
#ifdef __unix
|
|
||||||
assert( dir <= 1 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
yy = x;
|
|
||||||
|
|
||||||
xx = u8g2->height;
|
|
||||||
xx -= y;
|
|
||||||
xx--;
|
|
||||||
|
|
||||||
dir ++;
|
|
||||||
if ( dir == 2 )
|
|
||||||
{
|
|
||||||
xx -= len;
|
|
||||||
xx++;
|
|
||||||
dir = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_draw_l90_r2(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
u8g2_uint_t xx, yy;
|
|
||||||
|
|
||||||
/*
|
|
||||||
yy = u8g2->height;
|
|
||||||
yy -= y;
|
|
||||||
yy--;
|
|
||||||
|
|
||||||
xx = u8g2->width;
|
|
||||||
xx -= x;
|
|
||||||
xx--;
|
|
||||||
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
xx -= len;
|
|
||||||
xx++;
|
|
||||||
}
|
|
||||||
else if ( dir == 1 )
|
|
||||||
{
|
|
||||||
yy -= len;
|
|
||||||
yy++;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
yy = u8g2->height;
|
|
||||||
yy -= y;
|
|
||||||
|
|
||||||
xx = u8g2->width;
|
|
||||||
xx -= x;
|
|
||||||
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
yy--;
|
|
||||||
xx -= len;
|
|
||||||
}
|
|
||||||
else if ( dir == 1 )
|
|
||||||
{
|
|
||||||
xx--;
|
|
||||||
yy -= len;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8g2_draw_l90_r3(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
||||||
{
|
|
||||||
u8g2_uint_t xx, yy;
|
|
||||||
|
|
||||||
xx = y;
|
|
||||||
|
|
||||||
yy = u8g2->width;
|
|
||||||
yy -= x;
|
|
||||||
|
|
||||||
if ( dir == 0 )
|
|
||||||
{
|
|
||||||
yy--;
|
|
||||||
yy -= len;
|
|
||||||
yy++;
|
|
||||||
dir = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yy--;
|
|
||||||
dir = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_r0 };
|
|
||||||
const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_update_page_win_r1, u8g2_draw_l90_r1 };
|
|
||||||
const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_update_page_win_r2, u8g2_draw_l90_r2 };
|
|
||||||
const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_update_page_win_r3, u8g2_draw_l90_r3 };
|
|
||||||
|
|
||||||
const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_mirrorr_r0 };
|
|
||||||
const u8g2_cb_t u8g2_cb_mirror_vertical = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_mirror_vertical_r0 };
|
|
||||||
|
|
||||||
/*============================================*/
|
|
||||||
/* setup for the null device */
|
|
||||||
|
|
||||||
/* setup for the null (empty) device */
|
|
||||||
void u8g2_Setup_null(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
|
|
||||||
{
|
|
||||||
static uint8_t buf[8];
|
|
||||||
u8g2_SetupDisplay(u8g2, u8x8_d_null_cb, u8x8_cad_empty, byte_cb, gpio_and_delay_cb);
|
|
||||||
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, rotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,261 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8log.c
|
|
||||||
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2018, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
static uint8_t u8log_is_on_screen(u8log_t *u8log, uint8_t x, uint8_t y)
|
|
||||||
{
|
|
||||||
if ( x >= u8log->width )
|
|
||||||
return 0;
|
|
||||||
if ( y >= u8log->height )
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void u8log_clear_screen(u8log_t *u8log)
|
|
||||||
{
|
|
||||||
uint8_t *dest = u8log->screen_buffer;
|
|
||||||
uint16_t cnt = u8log->height;
|
|
||||||
cnt *= u8log->width;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
*dest++ = ' ';
|
|
||||||
cnt--;
|
|
||||||
} while( cnt > 0 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* scroll the content of the complete buffer, set redraw_line to 255 */
|
|
||||||
static void u8log_scroll_up(u8log_t *u8log)
|
|
||||||
{
|
|
||||||
uint8_t *dest = u8log->screen_buffer;
|
|
||||||
uint8_t *src = dest+u8log->width;
|
|
||||||
uint16_t cnt = u8log->height;
|
|
||||||
cnt--;
|
|
||||||
cnt *= u8log->width;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
*dest++ = *src++;
|
|
||||||
cnt--;
|
|
||||||
} while( cnt > 0 );
|
|
||||||
cnt = u8log->width;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
*dest++ = ' ';
|
|
||||||
cnt--;
|
|
||||||
} while(cnt > 0);
|
|
||||||
|
|
||||||
if ( u8log->is_redraw_line_for_each_char )
|
|
||||||
u8log->is_redraw_all = 1;
|
|
||||||
else
|
|
||||||
u8log->is_redraw_all_required_for_next_nl = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Place the cursor on the screen. This will also scroll, if required
|
|
||||||
*/
|
|
||||||
static void u8log_cursor_on_screen(u8log_t *u8log)
|
|
||||||
{
|
|
||||||
//printf("u8log_cursor_on_screen, cursor_y=%d\n", u8log->cursor_y);
|
|
||||||
if ( u8log->cursor_x >= u8log->width )
|
|
||||||
{
|
|
||||||
u8log->cursor_x = 0;
|
|
||||||
u8log->cursor_y++;
|
|
||||||
}
|
|
||||||
while ( u8log->cursor_y >= u8log->height )
|
|
||||||
{
|
|
||||||
u8log_scroll_up(u8log);
|
|
||||||
u8log->cursor_y--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Write a printable, single char on the screen, do any kind of scrolling
|
|
||||||
*/
|
|
||||||
static void u8log_write_to_screen(u8log_t *u8log, uint8_t c)
|
|
||||||
{
|
|
||||||
u8log_cursor_on_screen(u8log);
|
|
||||||
u8log->screen_buffer[u8log->cursor_y * u8log->width + u8log->cursor_x] = c;
|
|
||||||
u8log->cursor_x++;
|
|
||||||
|
|
||||||
if ( u8log->is_redraw_line_for_each_char )
|
|
||||||
{
|
|
||||||
u8log->is_redraw_line = 1;
|
|
||||||
u8log->redraw_line = u8log->cursor_y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Handle control codes or write the char to the screen.
|
|
||||||
Supported control codes are:
|
|
||||||
|
|
||||||
\n 10 Goto first position of the next line. Line is marked for redraw.
|
|
||||||
\r 13 Goto first position in the same line. Line is marked for redraw.
|
|
||||||
\t 9 Jump to the next tab position
|
|
||||||
\f 12 Clear the screen and mark redraw for whole screen
|
|
||||||
any other char Write char to screen. Line redraw mark depends on
|
|
||||||
is_redraw_line_for_each_char flag.
|
|
||||||
*/
|
|
||||||
void u8log_write_char(u8log_t *u8log, uint8_t c)
|
|
||||||
{
|
|
||||||
switch(c)
|
|
||||||
{
|
|
||||||
case '\n': // 10
|
|
||||||
u8log->is_redraw_line = 1;
|
|
||||||
u8log->redraw_line = u8log->cursor_y;
|
|
||||||
if ( u8log->is_redraw_all_required_for_next_nl )
|
|
||||||
u8log->is_redraw_all = 1;
|
|
||||||
u8log->is_redraw_all_required_for_next_nl = 0;
|
|
||||||
u8log->cursor_y++;
|
|
||||||
u8log->cursor_x = 0;
|
|
||||||
u8log_cursor_on_screen(u8log); // 31 Aug 2024 https://github.com/olikraus/u8g2/issues/2319
|
|
||||||
break;
|
|
||||||
case '\r': // 13
|
|
||||||
u8log->is_redraw_line = 1;
|
|
||||||
u8log->redraw_line = u8log->cursor_y;
|
|
||||||
u8log->cursor_x = 0;
|
|
||||||
break;
|
|
||||||
case '\t': // 9
|
|
||||||
u8log->cursor_x = (u8log->cursor_x + 8) & 0xf8;
|
|
||||||
break;
|
|
||||||
case '\f': // 12
|
|
||||||
u8log_clear_screen(u8log);
|
|
||||||
u8log->is_redraw_all = 1;
|
|
||||||
u8log->cursor_x = 0;
|
|
||||||
u8log->cursor_y = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
u8log_write_to_screen(u8log, c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8log_Init(u8log_t *u8log, uint8_t width, uint8_t height, uint8_t *buf)
|
|
||||||
{
|
|
||||||
memset(u8log, 0, sizeof(u8log_t));
|
|
||||||
u8log->width = width;
|
|
||||||
u8log->height = height;
|
|
||||||
u8log->screen_buffer = buf;
|
|
||||||
u8log_clear_screen(u8log);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8log_SetCallback(u8log_t *u8log, u8log_cb cb, void *aux_data)
|
|
||||||
{
|
|
||||||
u8log->cb = cb;
|
|
||||||
u8log->aux_data = aux_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8log_SetRedrawMode(u8log_t *u8log, uint8_t is_redraw_line_for_each_char)
|
|
||||||
{
|
|
||||||
u8log->is_redraw_line_for_each_char = is_redraw_line_for_each_char;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* offset can be negative or positive, it is 0 by default */
|
|
||||||
void u8log_SetLineHeightOffset(u8log_t *u8log, int8_t line_height_offset)
|
|
||||||
{
|
|
||||||
u8log->line_height_offset = line_height_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void u8log_WriteChar(u8log_t *u8log, uint8_t c)
|
|
||||||
{
|
|
||||||
u8log_write_char(u8log, c);
|
|
||||||
if ( u8log->is_redraw_line || u8log->is_redraw_all )
|
|
||||||
{
|
|
||||||
if ( u8log->cb != 0 )
|
|
||||||
{
|
|
||||||
u8log->cb(u8log);
|
|
||||||
}
|
|
||||||
u8log->is_redraw_line = 0;
|
|
||||||
u8log->is_redraw_all = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8log_WriteString(u8log_t *u8log, const char *s)
|
|
||||||
{
|
|
||||||
while( *s != '\0' )
|
|
||||||
{
|
|
||||||
u8log_WriteChar(u8log, *s);
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8log_WriteHexHalfByte(u8log_t *u8log, uint8_t b) U8X8_NOINLINE;
|
|
||||||
static void u8log_WriteHexHalfByte(u8log_t *u8log, uint8_t b)
|
|
||||||
{
|
|
||||||
b &= 0x0f;
|
|
||||||
if ( b < 10 )
|
|
||||||
u8log_WriteChar(u8log, b+'0');
|
|
||||||
else
|
|
||||||
u8log_WriteChar(u8log, b+'a'-10);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8log_WriteHex8(u8log_t *u8log, uint8_t b)
|
|
||||||
{
|
|
||||||
u8log_WriteHexHalfByte(u8log, b >> 4);
|
|
||||||
u8log_WriteHexHalfByte(u8log, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8log_WriteHex16(u8log_t *u8log, uint16_t v)
|
|
||||||
{
|
|
||||||
u8log_WriteHex8(u8log, v>>8);
|
|
||||||
u8log_WriteHex8(u8log, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8log_WriteHex32(u8log_t *u8log, uint32_t v)
|
|
||||||
{
|
|
||||||
u8log_WriteHex16(u8log, v>>16);
|
|
||||||
u8log_WriteHex16(u8log, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* v = value, d = number of digits (1..3) */
|
|
||||||
void u8log_WriteDec8(u8log_t *u8log, uint8_t v, uint8_t d)
|
|
||||||
{
|
|
||||||
u8log_WriteString(u8log, u8x8_u8toa(v, d));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* v = value, d = number of digits (1..5) */
|
|
||||||
void u8log_WriteDec16(u8log_t *u8log, uint16_t v, uint8_t d)
|
|
||||||
{
|
|
||||||
u8log_WriteString(u8log, u8x8_u16toa(v, d));
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8log_u8g2.c
|
|
||||||
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2018, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8g2.h"
|
|
||||||
/*
|
|
||||||
Draw the u8log text at the specified x/y position.
|
|
||||||
x/y position is the reference position of the first char of the first line.
|
|
||||||
the line height is
|
|
||||||
u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2) + line_height_offset;
|
|
||||||
line_height_offset can be set with u8log_SetLineHeightOffset()
|
|
||||||
Use
|
|
||||||
u8g2_SetFontRefHeightText(u8g2_t *u8g2);
|
|
||||||
u8g2_SetFontRefHeightExtendedText(u8g2_t *u8g2);
|
|
||||||
u8g2_SetFontRefHeightAll(u8g2_t *u8g2);
|
|
||||||
to change the return values for u8g2_GetAscent and u8g2_GetDescent
|
|
||||||
|
|
||||||
*/
|
|
||||||
void u8g2_DrawLog(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8log_t *u8log)
|
|
||||||
{
|
|
||||||
u8g2_uint_t disp_x, disp_y;
|
|
||||||
uint8_t buf_x, buf_y;
|
|
||||||
uint8_t c;
|
|
||||||
|
|
||||||
disp_y = y;
|
|
||||||
u8g2_SetFontDirection(u8g2, 0);
|
|
||||||
for( buf_y = 0; buf_y < u8log->height; buf_y++ )
|
|
||||||
{
|
|
||||||
disp_x = x;
|
|
||||||
for( buf_x = 0; buf_x < u8log->width; buf_x++ )
|
|
||||||
{
|
|
||||||
c = u8log->screen_buffer[buf_y * u8log->width + buf_x];
|
|
||||||
disp_x += u8g2_DrawGlyph(u8g2, disp_x, disp_y, c);
|
|
||||||
}
|
|
||||||
disp_y += u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2);
|
|
||||||
disp_y += u8log->line_height_offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
u8lib callback for u8g2
|
|
||||||
|
|
||||||
Only font direction 0 is supported: u8g2_SetFontDirection(u8g2, 0)
|
|
||||||
Use
|
|
||||||
u8g2_SetFontRefHeightText(u8g2_t *u8g2);
|
|
||||||
u8g2_SetFontRefHeightExtendedText(u8g2_t *u8g2);
|
|
||||||
u8g2_SetFontRefHeightAll(u8g2_t *u8g2);
|
|
||||||
to change the top offset and the line height and
|
|
||||||
u8log_SetLineHeightOffset(u8log_t *u8log, int8_t line_height_offset)
|
|
||||||
to change the line height.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void u8log_u8g2_cb(u8log_t * u8log)
|
|
||||||
{
|
|
||||||
u8g2_t *u8g2 = (u8g2_t *)(u8log->aux_data);
|
|
||||||
if ( u8log->is_redraw_line || u8log->is_redraw_all )
|
|
||||||
{
|
|
||||||
u8g2_FirstPage(u8g2);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8g2_DrawLog( u8g2, 0, u8g2_GetAscent(u8g2), u8log);
|
|
||||||
}
|
|
||||||
while( u8g2_NextPage(u8g2) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8log_u8x8.c
|
|
||||||
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2018, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
static void u8x8_DrawLogLine(u8x8_t *u8x8, uint8_t disp_x, uint8_t disp_y, uint8_t buf_y, u8log_t *u8log) U8X8_NOINLINE;
|
|
||||||
static void u8x8_DrawLogLine(u8x8_t *u8x8, uint8_t disp_x, uint8_t disp_y, uint8_t buf_y, u8log_t *u8log)
|
|
||||||
{
|
|
||||||
uint8_t buf_x;
|
|
||||||
uint8_t c;
|
|
||||||
for( buf_x = 0; buf_x < u8log->width; buf_x++ )
|
|
||||||
{
|
|
||||||
c = u8log->screen_buffer[buf_y * u8log->width + buf_x];
|
|
||||||
u8x8_DrawGlyph(u8x8, disp_x, disp_y, c);
|
|
||||||
disp_x++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8x8_DrawLog(u8x8_t *u8x8, uint8_t x, uint8_t y, u8log_t *u8log)
|
|
||||||
{
|
|
||||||
uint8_t buf_y;
|
|
||||||
for( buf_y = 0; buf_y < u8log->height; buf_y++ )
|
|
||||||
{
|
|
||||||
u8x8_DrawLogLine(u8x8, x, y, buf_y, u8log);
|
|
||||||
y++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8log_u8x8_cb(u8log_t * u8log)
|
|
||||||
{
|
|
||||||
u8x8_t *u8x8 = (u8x8_t *)(u8log->aux_data);
|
|
||||||
if ( u8log->is_redraw_all )
|
|
||||||
{
|
|
||||||
u8x8_DrawLog(u8x8, 0, 0, u8log);
|
|
||||||
}
|
|
||||||
else if ( u8log->is_redraw_line )
|
|
||||||
{
|
|
||||||
u8x8_DrawLogLine(u8x8, 0, u8log->redraw_line, u8log->redraw_line, u8log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,493 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_8x8.c
|
|
||||||
|
|
||||||
font procedures, directly interfaces display procedures
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
#if defined(ESP8266)
|
|
||||||
uint8_t u8x8_pgm_read_esp(const uint8_t * addr)
|
|
||||||
{
|
|
||||||
uint32_t bytes;
|
|
||||||
bytes = *(uint32_t*)((uint32_t)addr & ~3);
|
|
||||||
return ((uint8_t*)&bytes)[(uint32_t)addr & 3];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void u8x8_SetFont(u8x8_t *u8x8, const uint8_t *font_8x8)
|
|
||||||
{
|
|
||||||
u8x8->font = font_8x8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Args:
|
|
||||||
u8x8: ptr to u8x8 structure
|
|
||||||
encoding: glyph for which the data is requested (must be between 0 and 255)
|
|
||||||
buf: pointer to 8 bytes
|
|
||||||
*/
|
|
||||||
void u8x8_get_glyph_data(u8x8_t *u8x8, uint8_t encoding, uint8_t *buf, uint8_t tile_offset) U8X8_NOINLINE;
|
|
||||||
void u8x8_get_glyph_data(u8x8_t *u8x8, uint8_t encoding, uint8_t *buf, uint8_t tile_offset)
|
|
||||||
{
|
|
||||||
uint8_t first, last, tiles, i;
|
|
||||||
uint16_t offset;
|
|
||||||
first = u8x8_pgm_read(u8x8->font+0);
|
|
||||||
last = u8x8_pgm_read(u8x8->font+1);
|
|
||||||
tiles = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
|
|
||||||
tiles *= u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
|
|
||||||
|
|
||||||
/* get the glyph bitmap from the font */
|
|
||||||
if ( first <= encoding && encoding <= last )
|
|
||||||
{
|
|
||||||
offset = encoding;
|
|
||||||
offset -= first;
|
|
||||||
offset *= tiles; /* new 2019 format */
|
|
||||||
offset += tile_offset; /* new 2019 format */
|
|
||||||
offset *= 8;
|
|
||||||
offset +=4; /* changed from 2 to 4, new 2019 format */
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
buf[i] = u8x8_pgm_read(u8x8->font+offset);
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
buf[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* invert the bitmap if required */
|
|
||||||
if ( u8x8->is_font_inverse_mode )
|
|
||||||
{
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
buf[i] ^= 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8x8_DrawGlyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
|
|
||||||
{
|
|
||||||
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
|
|
||||||
uint8_t tv = u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
|
|
||||||
uint8_t xx, tile;
|
|
||||||
uint8_t buf[8];
|
|
||||||
th += x;
|
|
||||||
tv += y;
|
|
||||||
tile = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
xx = x;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
|
|
||||||
u8x8_DrawTile(u8x8, xx, y, 1, buf);
|
|
||||||
tile++;
|
|
||||||
xx++;
|
|
||||||
} while( xx < th );
|
|
||||||
y++;
|
|
||||||
} while( y < tv );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Source: http://graphics.stanford.edu/~seander/bithacks.html
|
|
||||||
Section: Interleave bits by Binary Magic Numbers
|
|
||||||
Original codes is here:
|
|
||||||
static const unsigned int B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF};
|
|
||||||
static const unsigned int S[] = {1, 2, 4, 8};
|
|
||||||
|
|
||||||
unsigned int x; // Interleave lower 16 bits of x and y, so the bits of x
|
|
||||||
unsigned int y; // are in the even positions and bits from y in the odd;
|
|
||||||
unsigned int z; // z gets the resulting 32-bit Morton Number.
|
|
||||||
// x and y must initially be less than 65536.
|
|
||||||
|
|
||||||
x = (x | (x << S[3])) & B[3];
|
|
||||||
x = (x | (x << S[2])) & B[2];
|
|
||||||
x = (x | (x << S[1])) & B[1];
|
|
||||||
x = (x | (x << S[0])) & B[0];
|
|
||||||
|
|
||||||
y = (y | (y << S[3])) & B[3];
|
|
||||||
y = (y | (y << S[2])) & B[2];
|
|
||||||
y = (y | (y << S[1])) & B[1];
|
|
||||||
y = (y | (y << S[0])) & B[0];
|
|
||||||
|
|
||||||
z = x | (y << 1);
|
|
||||||
*/
|
|
||||||
uint16_t u8x8_upscale_byte(uint8_t x)
|
|
||||||
{
|
|
||||||
uint16_t y = x;
|
|
||||||
y |= (y << 4); // x = (x | (x << S[2])) & B[2];
|
|
||||||
y &= 0x0f0f;
|
|
||||||
y |= (y << 2); // x = (x | (x << S[1])) & B[1];
|
|
||||||
y &= 0x3333;
|
|
||||||
y |= (y << 1); // x = (x | (x << S[0])) & B[0];
|
|
||||||
y &= 0x5555;
|
|
||||||
|
|
||||||
y |= (y << 1); // z = x | (y << 1);
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8x8_upscale_buf(uint8_t *src, uint8_t *dest) U8X8_NOINLINE;
|
|
||||||
static void u8x8_upscale_buf(uint8_t *src, uint8_t *dest)
|
|
||||||
{
|
|
||||||
uint8_t i = 4;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
*dest++ = *src;
|
|
||||||
*dest++ = *src++;
|
|
||||||
i--;
|
|
||||||
} while( i > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8x8_draw_2x2_subglyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding, uint8_t tile)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint16_t t;
|
|
||||||
uint8_t buf[8];
|
|
||||||
uint8_t buf1[8];
|
|
||||||
uint8_t buf2[8];
|
|
||||||
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
|
|
||||||
for( i = 0; i < 8; i ++ )
|
|
||||||
{
|
|
||||||
t = u8x8_upscale_byte(buf[i]);
|
|
||||||
buf1[i] = t >> 8;
|
|
||||||
buf2[i] = t & 255;
|
|
||||||
}
|
|
||||||
u8x8_upscale_buf(buf2, buf);
|
|
||||||
u8x8_DrawTile(u8x8, x, y, 1, buf);
|
|
||||||
|
|
||||||
u8x8_upscale_buf(buf2+4, buf);
|
|
||||||
u8x8_DrawTile(u8x8, x+1, y, 1, buf);
|
|
||||||
|
|
||||||
u8x8_upscale_buf(buf1, buf);
|
|
||||||
u8x8_DrawTile(u8x8, x, y+1, 1, buf);
|
|
||||||
|
|
||||||
u8x8_upscale_buf(buf1+4, buf);
|
|
||||||
u8x8_DrawTile(u8x8, x+1, y+1, 1, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8x8_Draw2x2Glyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
|
|
||||||
{
|
|
||||||
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
|
|
||||||
uint8_t tv = u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
|
|
||||||
uint8_t xx, tile;
|
|
||||||
th *= 2;
|
|
||||||
th += x;
|
|
||||||
tv *= 2;
|
|
||||||
tv += y;
|
|
||||||
tile = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
xx = x;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_draw_2x2_subglyph(u8x8, xx, y, encoding, tile);
|
|
||||||
tile++;
|
|
||||||
xx+=2;
|
|
||||||
} while( xx < th );
|
|
||||||
y+=2;
|
|
||||||
} while( y < tv );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/474 */
|
|
||||||
static void u8x8_draw_1x2_subglyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding, uint8_t tile)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint16_t t;
|
|
||||||
uint8_t buf[8];
|
|
||||||
uint8_t buf1[8];
|
|
||||||
uint8_t buf2[8];
|
|
||||||
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
|
|
||||||
for( i = 0; i < 8; i ++ )
|
|
||||||
{
|
|
||||||
t = u8x8_upscale_byte(buf[i]);
|
|
||||||
buf1[i] = t >> 8;
|
|
||||||
buf2[i] = t & 255;
|
|
||||||
}
|
|
||||||
u8x8_DrawTile(u8x8, x, y, 1, buf2);
|
|
||||||
u8x8_DrawTile(u8x8, x, y+1, 1, buf1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8x8_Draw1x2Glyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
|
|
||||||
{
|
|
||||||
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
|
|
||||||
uint8_t tv = u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
|
|
||||||
uint8_t xx, tile;
|
|
||||||
th += x;
|
|
||||||
tv *= 2;
|
|
||||||
tv += y;
|
|
||||||
tile = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
xx = x;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_draw_1x2_subglyph(u8x8, xx, y, encoding, tile);
|
|
||||||
tile++;
|
|
||||||
xx++;
|
|
||||||
} while( xx < th );
|
|
||||||
y+=2;
|
|
||||||
} while( y < tv );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
source: https://en.wikipedia.org/wiki/UTF-8
|
|
||||||
Bits from to bytes Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
|
|
||||||
7 U+0000 U+007F 1 0xxxxxxx
|
|
||||||
11 U+0080 U+07FF 2 110xxxxx 10xxxxxx
|
|
||||||
16 U+0800 U+FFFF 3 1110xxxx 10xxxxxx 10xxxxxx
|
|
||||||
21 U+10000 U+1FFFFF 4 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
|
||||||
26 U+200000 U+3FFFFFF 5 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
|
||||||
31 U+4000000 U+7FFFFFFF 6 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* reset the internal state machine */
|
|
||||||
void u8x8_utf8_init(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
u8x8->utf8_state = 0; /* also reset during u8x8_SetupDefaults() */
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t u8x8_ascii_next(U8X8_UNUSED u8x8_t *u8x8, uint8_t b)
|
|
||||||
{
|
|
||||||
if ( b == 0 || b == '\n' ) /* '\n' terminates the string to support the string list procedures */
|
|
||||||
return 0x0ffff; /* end of string detected*/
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
pass a byte from an utf8 encoded string to the utf8 decoder state machine
|
|
||||||
returns
|
|
||||||
0x0fffe: no glyph, just continue
|
|
||||||
0x0ffff: end of string
|
|
||||||
anything else: The decoded encoding
|
|
||||||
*/
|
|
||||||
uint16_t u8x8_utf8_next(u8x8_t *u8x8, uint8_t b)
|
|
||||||
{
|
|
||||||
if ( b == 0 || b == '\n' ) /* '\n' terminates the string to support the string list procedures */
|
|
||||||
return 0x0ffff; /* end of string detected, pending UTF8 is discarded */
|
|
||||||
if ( u8x8->utf8_state == 0 )
|
|
||||||
{
|
|
||||||
if ( b >= 0xfc ) /* 6 byte sequence */
|
|
||||||
{
|
|
||||||
u8x8->utf8_state = 5;
|
|
||||||
b &= 1;
|
|
||||||
}
|
|
||||||
else if ( b >= 0xf8 )
|
|
||||||
{
|
|
||||||
u8x8->utf8_state = 4;
|
|
||||||
b &= 3;
|
|
||||||
}
|
|
||||||
else if ( b >= 0xf0 )
|
|
||||||
{
|
|
||||||
u8x8->utf8_state = 3;
|
|
||||||
b &= 7;
|
|
||||||
}
|
|
||||||
else if ( b >= 0xe0 )
|
|
||||||
{
|
|
||||||
u8x8->utf8_state = 2;
|
|
||||||
b &= 15;
|
|
||||||
}
|
|
||||||
else if ( b >= 0xc0 )
|
|
||||||
{
|
|
||||||
u8x8->utf8_state = 1;
|
|
||||||
b &= 0x01f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* do nothing, just use the value as encoding */
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
u8x8->encoding = b;
|
|
||||||
return 0x0fffe;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8->utf8_state--;
|
|
||||||
/* The case b < 0x080 (an illegal UTF8 encoding) is not checked here. */
|
|
||||||
u8x8->encoding<<=6;
|
|
||||||
b &= 0x03f;
|
|
||||||
u8x8->encoding |= b;
|
|
||||||
if ( u8x8->utf8_state != 0 )
|
|
||||||
return 0x0fffe; /* nothing to do yet */
|
|
||||||
}
|
|
||||||
return u8x8->encoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_draw_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) U8X8_NOINLINE;
|
|
||||||
static uint8_t u8x8_draw_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
uint16_t e;
|
|
||||||
uint8_t cnt = 0;
|
|
||||||
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
|
|
||||||
|
|
||||||
u8x8_utf8_init(u8x8);
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
e = u8x8->next_cb(u8x8, (uint8_t)*s);
|
|
||||||
if ( e == 0x0ffff )
|
|
||||||
break;
|
|
||||||
s++;
|
|
||||||
if ( e != 0x0fffe )
|
|
||||||
{
|
|
||||||
u8x8_DrawGlyph(u8x8, x, y, e);
|
|
||||||
x+=th;
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_DrawString(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
u8x8->next_cb = u8x8_ascii_next;
|
|
||||||
return u8x8_draw_string(u8x8, x, y, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_DrawUTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
u8x8->next_cb = u8x8_utf8_next;
|
|
||||||
return u8x8_draw_string(u8x8, x, y, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_draw_2x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) U8X8_NOINLINE;
|
|
||||||
static uint8_t u8x8_draw_2x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
uint16_t e;
|
|
||||||
uint8_t cnt = 0;
|
|
||||||
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
|
|
||||||
|
|
||||||
th <<= 1;
|
|
||||||
|
|
||||||
u8x8_utf8_init(u8x8);
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
e = u8x8->next_cb(u8x8, (uint8_t)*s);
|
|
||||||
if ( e == 0x0ffff )
|
|
||||||
break;
|
|
||||||
s++;
|
|
||||||
if ( e != 0x0fffe )
|
|
||||||
{
|
|
||||||
u8x8_Draw2x2Glyph(u8x8, x, y, e);
|
|
||||||
x+=th;
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_Draw2x2String(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
u8x8->next_cb = u8x8_ascii_next;
|
|
||||||
return u8x8_draw_2x2_string(u8x8, x, y, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_Draw2x2UTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
u8x8->next_cb = u8x8_utf8_next;
|
|
||||||
return u8x8_draw_2x2_string(u8x8, x, y, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_draw_1x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) U8X8_NOINLINE;
|
|
||||||
static uint8_t u8x8_draw_1x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
uint16_t e;
|
|
||||||
uint8_t cnt = 0;
|
|
||||||
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
|
|
||||||
u8x8_utf8_init(u8x8);
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
e = u8x8->next_cb(u8x8, (uint8_t)*s);
|
|
||||||
if ( e == 0x0ffff )
|
|
||||||
break;
|
|
||||||
s++;
|
|
||||||
if ( e != 0x0fffe )
|
|
||||||
{
|
|
||||||
u8x8_Draw1x2Glyph(u8x8, x, y, e);
|
|
||||||
x+=th;
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_Draw1x2String(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
u8x8->next_cb = u8x8_ascii_next;
|
|
||||||
return u8x8_draw_1x2_string(u8x8, x, y, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_Draw1x2UTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
|
|
||||||
{
|
|
||||||
u8x8->next_cb = u8x8_utf8_next;
|
|
||||||
return u8x8_draw_1x2_string(u8x8, x, y, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_GetUTF8Len(u8x8_t *u8x8, const char *s)
|
|
||||||
{
|
|
||||||
uint16_t e;
|
|
||||||
uint8_t cnt = 0;
|
|
||||||
u8x8_utf8_init(u8x8);
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
e = u8x8_utf8_next(u8x8, *s);
|
|
||||||
if ( e == 0x0ffff )
|
|
||||||
break;
|
|
||||||
s++;
|
|
||||||
if ( e != 0x0fffe )
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
return cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,667 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_byte.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_SetDC(u8x8_t *u8x8, uint8_t dc)
|
|
||||||
{
|
|
||||||
return u8x8->byte_cb(u8x8, U8X8_MSG_BYTE_SET_DC, dc, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_SendBytes(u8x8_t *u8x8, uint8_t cnt, uint8_t *data)
|
|
||||||
{
|
|
||||||
return u8x8->byte_cb(u8x8, U8X8_MSG_BYTE_SEND, cnt, (void *)data);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_SendByte(u8x8_t *u8x8, uint8_t byte)
|
|
||||||
{
|
|
||||||
return u8x8_byte_SendBytes(u8x8, 1, &byte);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_StartTransfer(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
return u8x8->byte_cb(u8x8, U8X8_MSG_BYTE_START_TRANSFER, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_EndTransfer(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
return u8x8->byte_cb(u8x8, U8X8_MSG_BYTE_END_TRANSFER, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================*/
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_empty(U8X8_UNUSED u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
break; /* do nothing */
|
|
||||||
}
|
|
||||||
return 1; /* always succeed */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*=========================================*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Uses:
|
|
||||||
u8x8->display_info->sda_setup_time_ns
|
|
||||||
u8x8->display_info->sck_pulse_width_ns
|
|
||||||
u8x8->display_info->spi_mode
|
|
||||||
u8x8->display_info->chip_disable_level
|
|
||||||
u8x8->display_info->chip_enable_level
|
|
||||||
u8x8->display_info->post_chip_enable_wait_ns
|
|
||||||
u8x8->display_info->pre_chip_disable_wait_ns
|
|
||||||
Calls to GPIO and DELAY:
|
|
||||||
U8X8_MSG_DELAY_NANO
|
|
||||||
U8X8_MSG_GPIO_DC
|
|
||||||
U8X8_MSG_GPIO_CS
|
|
||||||
U8X8_MSG_GPIO_CLOCK
|
|
||||||
U8X8_MSG_GPIO_DATA
|
|
||||||
Handles:
|
|
||||||
U8X8_MSG_BYTE_INIT
|
|
||||||
U8X8_MSG_BYTE_SEND
|
|
||||||
U8X8_MSG_BYTE_SET_DC
|
|
||||||
U8X8_MSG_BYTE_START_TRANSFER
|
|
||||||
U8X8_MSG_BYTE_END_TRANSFER
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_4wire_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i, b;
|
|
||||||
uint8_t *data;
|
|
||||||
uint8_t takeover_edge = u8x8_GetSPIClockPhase(u8x8);
|
|
||||||
uint8_t not_takeover_edge = 1 - takeover_edge;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
b = *data;
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
if ( b & 128 )
|
|
||||||
u8x8_gpio_SetSPIData(u8x8, 1);
|
|
||||||
else
|
|
||||||
u8x8_gpio_SetSPIData(u8x8, 0);
|
|
||||||
b <<= 1;
|
|
||||||
|
|
||||||
u8x8_gpio_SetSPIClock(u8x8, not_takeover_edge);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->sda_setup_time_ns);
|
|
||||||
u8x8_gpio_SetSPIClock(u8x8, takeover_edge);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->sck_pulse_width_ns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
/* disable chipselect */
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
/* no wait required here */
|
|
||||||
|
|
||||||
/* for SPI: setup correct level of the clock signal */
|
|
||||||
u8x8_gpio_SetSPIClock(u8x8, u8x8_GetSPIClockPhase(u8x8));
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
u8x8_gpio_SetDC(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_enable_level);
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->post_chip_enable_wait_ns, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================*/
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_8bit_6800mode(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i, b;
|
|
||||||
uint8_t *data;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
b = *data;
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
for( i = U8X8_MSG_GPIO_D0; i <= U8X8_MSG_GPIO_D7; i++ )
|
|
||||||
{
|
|
||||||
u8x8_gpio_call(u8x8, i, b&1);
|
|
||||||
b >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->data_setup_time_ns);
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 1);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->write_pulse_width_ns);
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
/* disable chipselect */
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
/* ensure that the enable signal is high */
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
u8x8_gpio_SetDC(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_enable_level);
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->post_chip_enable_wait_ns, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_8bit_8080mode(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i, b;
|
|
||||||
uint8_t *data;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
b = *data;
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
for( i = U8X8_MSG_GPIO_D0; i <= U8X8_MSG_GPIO_D7; i++ )
|
|
||||||
{
|
|
||||||
u8x8_gpio_call(u8x8, i, b&1);
|
|
||||||
b >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->data_setup_time_ns);
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->write_pulse_width_ns);
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
/* disable chipselect */
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
/* ensure that the enable signal is high */
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 1);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
u8x8_gpio_SetDC(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_enable_level);
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->post_chip_enable_wait_ns, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================*/
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_3wire_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint8_t *data;
|
|
||||||
uint8_t takeover_edge = u8x8_GetSPIClockPhase(u8x8);
|
|
||||||
uint8_t not_takeover_edge = 1 - takeover_edge;
|
|
||||||
uint16_t b;
|
|
||||||
static uint8_t last_dc;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
b = *data;
|
|
||||||
if ( last_dc != 0 )
|
|
||||||
b |= 256;
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
for( i = 0; i < 9; i++ )
|
|
||||||
{
|
|
||||||
if ( b & 256 )
|
|
||||||
u8x8_gpio_SetSPIData(u8x8, 1);
|
|
||||||
else
|
|
||||||
u8x8_gpio_SetSPIData(u8x8, 0);
|
|
||||||
b <<= 1;
|
|
||||||
|
|
||||||
u8x8_gpio_SetSPIClock(u8x8, not_takeover_edge);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->sda_setup_time_ns);
|
|
||||||
u8x8_gpio_SetSPIClock(u8x8, takeover_edge);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->sck_pulse_width_ns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
/* disable chipselect */
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
/* no wait required here */
|
|
||||||
|
|
||||||
/* for SPI: setup correct level of the clock signal */
|
|
||||||
u8x8_gpio_SetSPIClock(u8x8, u8x8_GetSPIClockPhase(u8x8));
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
last_dc = arg_int;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_enable_level);
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->post_chip_enable_wait_ns, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================*/
|
|
||||||
|
|
||||||
void u8x8_byte_set_ks0108_cs(u8x8_t *u8x8, uint8_t arg)
|
|
||||||
{
|
|
||||||
u8x8_gpio_SetCS(u8x8, arg&1);
|
|
||||||
arg = arg >> 1;
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_CS1, arg&1);
|
|
||||||
arg = arg >> 1;
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_CS2, arg&1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 6800 mode */
|
|
||||||
uint8_t u8x8_byte_ks0108(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i, b;
|
|
||||||
uint8_t *data;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
b = *data;
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
for( i = U8X8_MSG_GPIO_D0; i <= U8X8_MSG_GPIO_D7; i++ )
|
|
||||||
{
|
|
||||||
u8x8_gpio_call(u8x8, i, b&1);
|
|
||||||
b >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->data_setup_time_ns);
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 1);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->write_pulse_width_ns);
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
/* disable chipselect */
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
/* ensure that the enable signal is low */
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
u8x8_gpio_SetDC(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
/* expects 3 bits in arg_int for the chip select lines */
|
|
||||||
u8x8_byte_set_ks0108_cs(u8x8, arg_int);
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->post_chip_enable_wait_ns, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL);
|
|
||||||
u8x8_byte_set_ks0108_cs(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* sed1520 or sbn1661
|
|
||||||
U8X8_MSG_GPIO_E --> E1
|
|
||||||
U8X8_MSG_GPIO_CS --> E2
|
|
||||||
*/
|
|
||||||
uint8_t u8x8_byte_sed1520(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i, b;
|
|
||||||
uint8_t *data;
|
|
||||||
static uint8_t enable_pin;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
b = *data;
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
for( i = U8X8_MSG_GPIO_D0; i <= U8X8_MSG_GPIO_D7; i++ )
|
|
||||||
{
|
|
||||||
u8x8_gpio_call(u8x8, i, b&1);
|
|
||||||
b >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->data_setup_time_ns);
|
|
||||||
u8x8_gpio_call(u8x8, enable_pin, 1);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 200); /* KS0108 requires 450 ns, use 200 here */
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->write_pulse_width_ns); /* expect 250 here */
|
|
||||||
u8x8_gpio_call(u8x8, enable_pin, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
/* disable chipselect */
|
|
||||||
u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level);
|
|
||||||
/* ensure that the enable signals are low */
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_E, 0);
|
|
||||||
u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_CS, 0);
|
|
||||||
enable_pin = U8X8_MSG_GPIO_E;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
u8x8_gpio_SetDC(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
/* cs lines are not supported for the SED1520/SBN1661 */
|
|
||||||
/* instead, this will select the E1 or E2 line */
|
|
||||||
/* arg_int is set by u8x8_d_sbn1661_122x32() function */
|
|
||||||
enable_pin = U8X8_MSG_GPIO_E;
|
|
||||||
if ( arg_int != 0 )
|
|
||||||
enable_pin = U8X8_MSG_GPIO_CS;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
software i2c,
|
|
||||||
ignores ACK response (which is anyway not provided by some displays)
|
|
||||||
also does not allow reading from the device
|
|
||||||
*/
|
|
||||||
static void i2c_delay(u8x8_t *u8x8) U8X8_NOINLINE;
|
|
||||||
static void i2c_delay(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
//u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_10MICRO, u8x8->display_info->i2c_bus_clock_100kHz);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_I2C, u8x8->display_info->i2c_bus_clock_100kHz);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_init(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
u8x8_gpio_SetI2CClock(u8x8, 1);
|
|
||||||
u8x8_gpio_SetI2CData(u8x8, 1);
|
|
||||||
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* actually, the scl line is not observed, so this procedure does not return a value */
|
|
||||||
|
|
||||||
static void i2c_read_scl_and_delay(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
/* set as input (line will be high) */
|
|
||||||
u8x8_gpio_SetI2CClock(u8x8, 1);
|
|
||||||
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_clear_scl(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
u8x8_gpio_SetI2CClock(u8x8, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_read_sda(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
/* set as input (line will be high) */
|
|
||||||
u8x8_gpio_SetI2CData(u8x8, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_clear_sda(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
/* set open collector and drive low */
|
|
||||||
u8x8_gpio_SetI2CData(u8x8, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_start(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
if ( u8x8->i2c_started != 0 )
|
|
||||||
{
|
|
||||||
/* if already started: do restart */
|
|
||||||
i2c_read_sda(u8x8); /* SDA = 1 */
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
i2c_read_scl_and_delay(u8x8);
|
|
||||||
}
|
|
||||||
i2c_read_sda(u8x8);
|
|
||||||
/* send the start condition, both lines go from 1 to 0 */
|
|
||||||
i2c_clear_sda(u8x8);
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
i2c_clear_scl(u8x8);
|
|
||||||
u8x8->i2c_started = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void i2c_stop(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
/* set SDA to 0 */
|
|
||||||
i2c_clear_sda(u8x8);
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
|
|
||||||
/* now release all lines */
|
|
||||||
i2c_read_scl_and_delay(u8x8);
|
|
||||||
|
|
||||||
/* set SDA to 1 */
|
|
||||||
i2c_read_sda(u8x8);
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
u8x8->i2c_started = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_write_bit(u8x8_t *u8x8, uint8_t val)
|
|
||||||
{
|
|
||||||
if (val)
|
|
||||||
i2c_read_sda(u8x8);
|
|
||||||
else
|
|
||||||
i2c_clear_sda(u8x8);
|
|
||||||
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
i2c_read_scl_and_delay(u8x8);
|
|
||||||
i2c_clear_scl(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_read_bit(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
//uint8_t val;
|
|
||||||
/* do not drive SDA */
|
|
||||||
i2c_read_sda(u8x8);
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
i2c_read_scl_and_delay(u8x8);
|
|
||||||
i2c_read_sda(u8x8);
|
|
||||||
i2c_delay(u8x8);
|
|
||||||
i2c_clear_scl(u8x8);
|
|
||||||
//return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void i2c_write_byte(u8x8_t *u8x8, uint8_t b)
|
|
||||||
{
|
|
||||||
i2c_write_bit(u8x8, b & 128);
|
|
||||||
i2c_write_bit(u8x8, b & 64);
|
|
||||||
i2c_write_bit(u8x8, b & 32);
|
|
||||||
i2c_write_bit(u8x8, b & 16);
|
|
||||||
i2c_write_bit(u8x8, b & 8);
|
|
||||||
i2c_write_bit(u8x8, b & 4);
|
|
||||||
i2c_write_bit(u8x8, b & 2);
|
|
||||||
i2c_write_bit(u8x8, b & 1);
|
|
||||||
|
|
||||||
/* read ack from client */
|
|
||||||
/* 0: ack was given by client */
|
|
||||||
/* 1: nothing happend during ack cycle */
|
|
||||||
i2c_read_bit(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_sw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *data;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
i2c_write_byte(u8x8, *data);
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
i2c_init(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
i2c_start(u8x8);
|
|
||||||
i2c_write_byte(u8x8, u8x8_GetI2CAddress(u8x8));
|
|
||||||
//i2c_write_byte(u8x8, 0x078);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
i2c_stop(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================*/
|
|
||||||
|
|
||||||
/* alternative i2c byte procedure */
|
|
||||||
#ifdef ALTERNATIVE_I2C_BYTE_PROCEDURE
|
|
||||||
|
|
||||||
|
|
||||||
void i2c_transfer(u8x8_t *u8x8, uint8_t adr, uint8_t cnt, uint8_t *data)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
i2c_start(u8x8);
|
|
||||||
i2c_write_byte(u8x8, adr);
|
|
||||||
for( i = 0; i < cnt; i++ )
|
|
||||||
i2c_write_byte(u8x8, data[i]);
|
|
||||||
i2c_stop(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_byte_sw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
static uint8_t buffer[32]; /* u8g2/u8x8 will never send more than 32 bytes */
|
|
||||||
static uint8_t buf_idx;
|
|
||||||
uint8_t *data;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_BYTE_SEND:
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
buffer[buf_idx++] = *data;
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_INIT:
|
|
||||||
i2c_init(u8x8); /* init i2c communication */
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
/* ignored for i2c */
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
buf_idx = 0;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
i2c_transfer(u8x8, u8x8_GetI2CAddress(u8x8), buf_idx, buffer);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,951 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_cad.c
|
|
||||||
|
|
||||||
"command arg data" interface to the graphics controller
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
The following sequence must be used for any data, which is set to the display:
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_StartTransfer(u8x8_t *u8x8)
|
|
||||||
|
|
||||||
any of the following calls
|
|
||||||
uint8_t u8x8_cad_SendCmd(u8x8_t *u8x8, uint8_t cmd)
|
|
||||||
uint8_t u8x8_cad_SendArg(u8x8_t *u8x8, uint8_t arg)
|
|
||||||
uint8_t u8x8_cad_SendData(u8x8_t *u8x8, uint8_t cnt, uint8_t *data)
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
uint8_t u8x8_cad_template(u8x8_t *u8x8, uint8_t msg, uint16_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_mcd_byte_SetDC(mcd->next, 1);
|
|
||||||
u8x8_mcd_byte_Send(mcd->next, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_mcd_byte_SetDC(mcd->next, 1);
|
|
||||||
u8x8_mcd_byte_Send(mcd->next, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
u8x8_mcd_byte_SetDC(mcd->next, 0);
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
u8x8_mcd_byte_Send(mcd->next, ((uint8_t *)arg_ptr)[i]);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_RESET:
|
|
||||||
return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr);
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_SendCmd(u8x8_t *u8x8, uint8_t cmd)
|
|
||||||
{
|
|
||||||
return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_SEND_CMD, cmd, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_SendArg(u8x8_t *u8x8, uint8_t arg)
|
|
||||||
{
|
|
||||||
return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_SEND_ARG, arg, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_SendMultipleArg(u8x8_t *u8x8, uint8_t cnt, uint8_t arg)
|
|
||||||
{
|
|
||||||
while( cnt > 0 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_SEND_ARG, arg, NULL);
|
|
||||||
cnt--;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_SendData(u8x8_t *u8x8, uint8_t cnt, uint8_t *data)
|
|
||||||
{
|
|
||||||
return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, cnt, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_StartTransfer(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8x8_cad_vsendf(u8x8_t * u8x8, const char *fmt, va_list va)
|
|
||||||
{
|
|
||||||
uint8_t d;
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
while( *fmt != '\0' )
|
|
||||||
{
|
|
||||||
d = (uint8_t)va_arg(va, int);
|
|
||||||
switch(*fmt)
|
|
||||||
{
|
|
||||||
case 'a': u8x8_cad_SendArg(u8x8, d); break;
|
|
||||||
case 'c': u8x8_cad_SendCmd(u8x8, d); break;
|
|
||||||
case 'd': u8x8_cad_SendData(u8x8, 1, &d); break;
|
|
||||||
}
|
|
||||||
fmt++;
|
|
||||||
}
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8x8_SendF(u8x8_t * u8x8, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list va;
|
|
||||||
va_start(va, fmt);
|
|
||||||
u8x8_cad_vsendf(u8x8, fmt, va);
|
|
||||||
va_end(va);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
21 c send command c
|
|
||||||
22 a send arg a
|
|
||||||
23 d send data d
|
|
||||||
24 CS on
|
|
||||||
25 CS off
|
|
||||||
254 milli delay by milliseconds
|
|
||||||
255 end of sequence
|
|
||||||
*/
|
|
||||||
|
|
||||||
void u8x8_cad_SendSequence(u8x8_t *u8x8, uint8_t const *data)
|
|
||||||
{
|
|
||||||
uint8_t cmd;
|
|
||||||
uint8_t v;
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
cmd = *data;
|
|
||||||
data++;
|
|
||||||
switch( cmd )
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
v = *data;
|
|
||||||
u8x8->cad_cb(u8x8, cmd, v, NULL);
|
|
||||||
data++;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
v = *data;
|
|
||||||
u8x8_cad_SendData(u8x8, 1, &v);
|
|
||||||
data++;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
u8x8->cad_cb(u8x8, cmd, 0, NULL);
|
|
||||||
break;
|
|
||||||
case 0x0fe:
|
|
||||||
v = *data;
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, v);
|
|
||||||
data++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_cad_empty(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
convert to bytes by using
|
|
||||||
dc = 1 for commands and args and
|
|
||||||
dc = 0 for data
|
|
||||||
*/
|
|
||||||
uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
//u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr);
|
|
||||||
//break;
|
|
||||||
/* fall through */
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
convert to bytes by using
|
|
||||||
dc = 1 for commands and args and
|
|
||||||
dc = 0 for data
|
|
||||||
*/
|
|
||||||
uint8_t u8x8_gu800_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *data;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, *data);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
convert to bytes by using
|
|
||||||
dc = 1 for commands and args and
|
|
||||||
dc = 0 for data
|
|
||||||
t6963
|
|
||||||
*/
|
|
||||||
uint8_t u8x8_cad_100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
//u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr);
|
|
||||||
//break;
|
|
||||||
/* fall through */
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
convert to bytes by using
|
|
||||||
dc = 0 for commands and args and
|
|
||||||
dc = 1 for data
|
|
||||||
*/
|
|
||||||
uint8_t u8x8_cad_001(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
//u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr);
|
|
||||||
//break;
|
|
||||||
/* fall through */
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
convert to bytes by using
|
|
||||||
dc = 0 for commands
|
|
||||||
dc = 1 for args and data
|
|
||||||
*/
|
|
||||||
uint8_t u8x8_cad_011(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
//u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr);
|
|
||||||
//break;
|
|
||||||
/* fall through */
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cad procedure for the ST7920 in SPI mode */
|
|
||||||
/* u8x8_byte_SetDC is not used */
|
|
||||||
uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *data;
|
|
||||||
uint8_t b;
|
|
||||||
uint8_t i;
|
|
||||||
static uint8_t buf[16];
|
|
||||||
uint8_t *ptr;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x0f8);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int & 0x0f0);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int << 4);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x0f8);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int & 0x0f0);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int << 4);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x0fa);
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
|
|
||||||
|
|
||||||
/* this loop should be optimized: multiple bytes should be sent */
|
|
||||||
/* u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr); */
|
|
||||||
data = (uint8_t *)arg_ptr;
|
|
||||||
|
|
||||||
/* the following loop increases speed by 20% */
|
|
||||||
while( arg_int >= 8 )
|
|
||||||
{
|
|
||||||
i = 8;
|
|
||||||
ptr = buf;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
b = *data++;
|
|
||||||
*ptr++= b & 0x0f0;
|
|
||||||
b <<= 4;
|
|
||||||
*ptr++= b;
|
|
||||||
i--;
|
|
||||||
} while( i > 0 );
|
|
||||||
arg_int -= 8;
|
|
||||||
u8x8_byte_SendBytes(u8x8, 16, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
while( arg_int > 0 )
|
|
||||||
{
|
|
||||||
b = *data;
|
|
||||||
u8x8_byte_SendByte(u8x8, b & 0x0f0);
|
|
||||||
u8x8_byte_SendByte(u8x8, b << 4);
|
|
||||||
data++;
|
|
||||||
arg_int--;
|
|
||||||
}
|
|
||||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, 1);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* cad procedure for the SSD13xx family in I2C mode */
|
|
||||||
/* this procedure is also used by the ST7588 */
|
|
||||||
/* u8x8_byte_SetDC is not used */
|
|
||||||
/* U8X8_MSG_BYTE_START_TRANSFER starts i2c transfer, U8X8_MSG_BYTE_END_TRANSFER stops transfer */
|
|
||||||
/* After transfer start, a full byte indicates command or data mode */
|
|
||||||
|
|
||||||
static void u8x8_i2c_data_transfer(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr) U8X8_NOINLINE;
|
|
||||||
static void u8x8_i2c_data_transfer(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x040);
|
|
||||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, arg_int, arg_ptr);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* classic version: will put a start/stop condition around each command and arg */
|
|
||||||
/* implements CAD = 001 */
|
|
||||||
uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *p;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
/* 7 Nov 2016: Can this be improved? */
|
|
||||||
//u8x8_byte_SetDC(u8x8, 0);
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
//u8x8_byte_SendByte(u8x8, u8x8_GetI2CAddress(u8x8));
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x000);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
//u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
|
|
||||||
/* the FeatherWing OLED with the 32u4 transfer of long byte */
|
|
||||||
/* streams was not possible. This is broken down to */
|
|
||||||
/* smaller streams, 32 seems to be the limit... */
|
|
||||||
/* I guess this is related to the size of the Wire buffers in Arduino */
|
|
||||||
/* Unfortunately, this can not be handled in the byte level drivers, */
|
|
||||||
/* so this is done here. Even further, only 24 bytes will be sent, */
|
|
||||||
/* because there will be another byte (DC) required during the transfer */
|
|
||||||
p = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 24 )
|
|
||||||
{
|
|
||||||
u8x8_i2c_data_transfer(u8x8, 24, p);
|
|
||||||
arg_int-=24;
|
|
||||||
p+=24;
|
|
||||||
}
|
|
||||||
u8x8_i2c_data_transfer(u8x8, arg_int, p);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
|
||||||
if ( u8x8->i2c_address == 255 )
|
|
||||||
u8x8->i2c_address = 0x078;
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
/* cad transfer commands are ignored */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* classic version: will put a start/stop condition around each command and arg */
|
|
||||||
/* implements CAD = 011 for the SSD1363 */
|
|
||||||
uint8_t u8x8_cad_011_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *p;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x000);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x040);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
p = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 24 )
|
|
||||||
{
|
|
||||||
u8x8_i2c_data_transfer(u8x8, 24, p);
|
|
||||||
arg_int-=24;
|
|
||||||
p+=24;
|
|
||||||
}
|
|
||||||
u8x8_i2c_data_transfer(u8x8, arg_int, p);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
|
||||||
if ( u8x8->i2c_address == 255 )
|
|
||||||
u8x8->i2c_address = 0x078;
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
/* cad transfer commands are ignored */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* fast version with reduced data start/stops, issue 735 */
|
|
||||||
uint8_t u8x8_cad_ssd13xx_fast_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
static uint8_t in_transfer = 0;
|
|
||||||
uint8_t *p;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
/* improved version, takeover from ld7032 */
|
|
||||||
/* assumes, that the args of a command is not longer than 31 bytes */
|
|
||||||
/* speed improvement is about 4% compared to the classic version */
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x000); /* cmd byte for ssd13xx controller */
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
in_transfer = 1;
|
|
||||||
/* lightning version: can replace the improved version from above */
|
|
||||||
/* the drawback of the lightning version is this: The complete init sequence */
|
|
||||||
/* must fit into the 32 byte Arduino Wire buffer, which might not always be the case */
|
|
||||||
/* speed improvement is about 6% compared to the classic version */
|
|
||||||
// if ( in_transfer == 0 )
|
|
||||||
// {
|
|
||||||
// u8x8_byte_StartTransfer(u8x8);
|
|
||||||
// u8x8_byte_SendByte(u8x8, 0x000); /* cmd byte for ssd13xx controller */
|
|
||||||
// in_transfer = 1;
|
|
||||||
// }
|
|
||||||
//u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
|
|
||||||
|
|
||||||
/* the FeatherWing OLED with the 32u4 transfer of long byte */
|
|
||||||
/* streams was not possible. This is broken down to */
|
|
||||||
/* smaller streams, 32 seems to be the limit... */
|
|
||||||
/* I guess this is related to the size of the Wire buffers in Arduino */
|
|
||||||
/* Unfortunately, this can not be handled in the byte level drivers, */
|
|
||||||
/* so this is done here. Even further, only 24 bytes will be sent, */
|
|
||||||
/* because there will be another byte (DC) required during the transfer */
|
|
||||||
p = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 24 )
|
|
||||||
{
|
|
||||||
u8x8_i2c_data_transfer(u8x8, 24, p);
|
|
||||||
arg_int-=24;
|
|
||||||
p+=24;
|
|
||||||
}
|
|
||||||
u8x8_i2c_data_transfer(u8x8, arg_int, p);
|
|
||||||
in_transfer = 0;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
|
||||||
if ( u8x8->i2c_address == 255 )
|
|
||||||
u8x8->i2c_address = 0x078;
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
in_transfer = 0;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
in_transfer = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* the st75256 i2c driver is a copy of the ssd13xx driver, but with arg=1 */
|
|
||||||
/* modified from cad001 (ssd13xx) to cad011 */
|
|
||||||
uint8_t u8x8_cad_st75256_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *p;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x000);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x040);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
/* see ssd13xx driver */
|
|
||||||
p = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 24 )
|
|
||||||
{
|
|
||||||
u8x8_i2c_data_transfer(u8x8, 24, p);
|
|
||||||
arg_int-=24;
|
|
||||||
p+=24;
|
|
||||||
}
|
|
||||||
u8x8_i2c_data_transfer(u8x8, arg_int, p);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
|
||||||
if ( u8x8->i2c_address == 255 )
|
|
||||||
u8x8->i2c_address = 0x078; /* ST75256, often this is 0x07e */
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
/* cad transfer commands are ignored */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cad i2c procedure for the ld7032 controller */
|
|
||||||
/* Issue https://github.com/olikraus/u8g2/issues/865 mentiones, that I2C does not work */
|
|
||||||
/* Workaround is to remove the while loop (or increase the value in the condition) */
|
|
||||||
uint8_t u8x8_cad_ld7032_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
static uint8_t in_transfer = 0;
|
|
||||||
uint8_t *p;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
in_transfer = 1;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
//u8x8_byte_SetDC(u8x8, 1);
|
|
||||||
|
|
||||||
/* the FeatherWing OLED with the 32u4 transfer of long byte */
|
|
||||||
/* streams was not possible. This is broken down to */
|
|
||||||
/* smaller streams, 32 seems to be the limit... */
|
|
||||||
/* I guess this is related to the size of the Wire buffers in Arduino */
|
|
||||||
/* Unfortunately, this can not be handled in the byte level drivers, */
|
|
||||||
/* so this is done here. Even further, only 24 bytes will be sent, */
|
|
||||||
/* because there will be another byte (DC) required during the transfer */
|
|
||||||
p = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 24 )
|
|
||||||
{
|
|
||||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, 24, p);
|
|
||||||
arg_int-=24;
|
|
||||||
p+=24;
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
u8x8_byte_SendByte(u8x8, 0x08); /* data write for LD7032 */
|
|
||||||
}
|
|
||||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, arg_int, p);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
|
||||||
if ( u8x8->i2c_address == 255 )
|
|
||||||
u8x8->i2c_address = 0x060;
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
in_transfer = 0;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cad procedure for the UC16xx family in I2C mode */
|
|
||||||
/* u8x8_byte_SetDC is not used */
|
|
||||||
/* DC bit is encoded into the adr byte, structure is CAD001 */
|
|
||||||
uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
static uint8_t in_transfer = 0;
|
|
||||||
static uint8_t is_data = 0;
|
|
||||||
uint8_t *p;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
{
|
|
||||||
if ( is_data != 0 )
|
|
||||||
{
|
|
||||||
/* transfer mode is active, but data transfer */
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, u8x8_GetI2CAddress(u8x8)&0x0fc );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, u8x8_GetI2CAddress(u8x8)&0x0fc );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
in_transfer = 1;
|
|
||||||
// is_data = 0; // 20 Jun 2021: I assume that this is missing here
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
{
|
|
||||||
if ( is_data == 0 )
|
|
||||||
{
|
|
||||||
/* transfer mode is active, but data transfer */
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
in_transfer = 1;
|
|
||||||
// is_data = 1; // 20 Jun 2021: I assume that this is missing here
|
|
||||||
|
|
||||||
p = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 24 )
|
|
||||||
{
|
|
||||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, 24, p);
|
|
||||||
arg_int-=24;
|
|
||||||
p+=24;
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, arg_int, p);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
|
||||||
if ( u8x8->i2c_address == 255 )
|
|
||||||
u8x8->i2c_address = 0x070;
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
in_transfer = 0;
|
|
||||||
/* actual start is delayed, because we do not whether this is data or cmd transfer */
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
in_transfer = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* cad procedure for the UC1638 in I2C mode */
|
|
||||||
/* same as u8x8_cad_uc16xx_i2c but CAD structure is CAD011 */
|
|
||||||
uint8_t u8x8_cad_uc1638_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
static uint8_t in_transfer = 0;
|
|
||||||
static uint8_t is_data = 0;
|
|
||||||
uint8_t *p;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_CAD_SEND_CMD:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
{
|
|
||||||
if ( is_data != 0 )
|
|
||||||
{
|
|
||||||
/* transfer mode is active, but data transfer */
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, u8x8_GetI2CAddress(u8x8)&0x0fc );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, u8x8_GetI2CAddress(u8x8)&0x0fc );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
in_transfer = 1;
|
|
||||||
is_data = 0;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_ARG:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
{
|
|
||||||
if ( is_data == 0 )
|
|
||||||
{
|
|
||||||
/* transfer mode is active, but data transfer */
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
u8x8_byte_SendByte(u8x8, arg_int);
|
|
||||||
in_transfer = 1;
|
|
||||||
is_data = 1;
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_SEND_DATA:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
{
|
|
||||||
if ( is_data == 0 )
|
|
||||||
{
|
|
||||||
/* transfer mode is active, but data transfer */
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* clear the lowest two bits of the adr */
|
|
||||||
u8x8_SetI2CAddress( u8x8, (u8x8_GetI2CAddress(u8x8)&0x0fc)|2 );
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
in_transfer = 1;
|
|
||||||
is_data = 1;
|
|
||||||
|
|
||||||
p = (uint8_t *)arg_ptr;
|
|
||||||
while( arg_int > 24 )
|
|
||||||
{
|
|
||||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, 24, p);
|
|
||||||
arg_int-=24;
|
|
||||||
p+=24;
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
u8x8_byte_StartTransfer(u8x8);
|
|
||||||
}
|
|
||||||
u8x8->byte_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, arg_int, p);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_INIT:
|
|
||||||
/* apply default i2c adr if required so that the start transfer msg can use this */
|
|
||||||
if ( u8x8->i2c_address == 255 )
|
|
||||||
u8x8->i2c_address = 0x078; /* see also https://github.com/olikraus/u8g2/issues/371 for a discussion on this value */
|
|
||||||
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
case U8X8_MSG_CAD_START_TRANSFER:
|
|
||||||
in_transfer = 0;
|
|
||||||
/* actual start is delayed, because we do not whether this is data or cmd transfer */
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_CAD_END_TRANSFER:
|
|
||||||
if ( in_transfer != 0 )
|
|
||||||
u8x8_byte_EndTransfer(u8x8);
|
|
||||||
in_transfer = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_capture.c
|
|
||||||
|
|
||||||
Screen capture funcion
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/*========================================================*/
|
|
||||||
|
|
||||||
|
|
||||||
/* vertical top lsb memory architecture */
|
|
||||||
uint8_t u8x8_capture_get_pixel_1(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width)
|
|
||||||
{
|
|
||||||
//uint8_t *dest_ptr = capture->buffer;
|
|
||||||
//if ( dest_ptr == NULL )
|
|
||||||
//return 0;
|
|
||||||
//dest_ptr += (y/8)*capture->tile_width*8;
|
|
||||||
dest_ptr += (y/8)*tile_width*8;
|
|
||||||
y &= 7;
|
|
||||||
dest_ptr += x;
|
|
||||||
if ( (*dest_ptr & (1<<y)) == 0 )
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* horizontal right lsb memory architecture */
|
|
||||||
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
|
|
||||||
uint8_t u8x8_capture_get_pixel_2(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width)
|
|
||||||
{
|
|
||||||
//uint8_t *dest_ptr = capture->buffer;
|
|
||||||
//if ( dest_ptr == NULL )
|
|
||||||
// return 0;
|
|
||||||
//dest_ptr += y*capture->tile_width;
|
|
||||||
y *= tile_width;
|
|
||||||
dest_ptr += y;
|
|
||||||
dest_ptr += x>>3;
|
|
||||||
if ( (*dest_ptr & (128>>(x&7))) == 0 )
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8x8_capture_write_pbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
out("P1\n");
|
|
||||||
out(u8x8_utoa((uint16_t)tile_width*8));
|
|
||||||
out("\n");
|
|
||||||
out(u8x8_utoa((uint16_t)tile_height*8));
|
|
||||||
out("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void u8x8_capture_write_pbm_buffer(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, uint8_t (*get_pixel)(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width), void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
uint16_t x, y;
|
|
||||||
uint16_t w, h;
|
|
||||||
|
|
||||||
w = tile_width;
|
|
||||||
w *= 8;
|
|
||||||
h = tile_height;
|
|
||||||
h *= 8;
|
|
||||||
|
|
||||||
for( y = 0; y < h; y++)
|
|
||||||
{
|
|
||||||
for( x = 0; x < w; x++)
|
|
||||||
{
|
|
||||||
if ( get_pixel(x, y, buffer, tile_width) )
|
|
||||||
out("1");
|
|
||||||
else
|
|
||||||
out("0");
|
|
||||||
}
|
|
||||||
out("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void u8x8_capture_write_xbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
out("#define xbm_width ");
|
|
||||||
out(u8x8_utoa((uint16_t)tile_width*8));
|
|
||||||
out("\n");
|
|
||||||
out("#define xbm_height ");
|
|
||||||
out(u8x8_utoa((uint16_t)tile_height*8));
|
|
||||||
out("\n");
|
|
||||||
out("static unsigned char xbm_bits[] = {\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void u8x8_capture_write_xbm_buffer(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, uint8_t (*get_pixel)(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width), void (*out)(const char *s))
|
|
||||||
{
|
|
||||||
uint16_t x, y;
|
|
||||||
uint16_t w, h;
|
|
||||||
uint8_t v, b;
|
|
||||||
char s[2];
|
|
||||||
s[1] = '\0';
|
|
||||||
|
|
||||||
w = tile_width;
|
|
||||||
w *= 8;
|
|
||||||
h = tile_height;
|
|
||||||
h *= 8;
|
|
||||||
|
|
||||||
y = 0;
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
x = 0;
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
v = 0;
|
|
||||||
for( b = 0; b < 8; b++ )
|
|
||||||
{
|
|
||||||
v <<= 1;
|
|
||||||
if ( get_pixel(x+7-b, y, buffer, tile_width) )
|
|
||||||
v |= 1;
|
|
||||||
}
|
|
||||||
out("0x");
|
|
||||||
s[0] = (v>>4);
|
|
||||||
if ( s[0] <= 9 )
|
|
||||||
s[0] += '0';
|
|
||||||
else
|
|
||||||
s[0] += 'a'-10;
|
|
||||||
out(s);
|
|
||||||
s[0] = (v&15);
|
|
||||||
if ( s[0] <= 9 )
|
|
||||||
s[0] += '0';
|
|
||||||
else
|
|
||||||
s[0] += 'a'-10;
|
|
||||||
out(s);
|
|
||||||
x += 8;
|
|
||||||
if ( x >= w )
|
|
||||||
break;
|
|
||||||
out(",");
|
|
||||||
}
|
|
||||||
y++;
|
|
||||||
if ( y >= h )
|
|
||||||
break;
|
|
||||||
out(",");
|
|
||||||
out("\n");
|
|
||||||
}
|
|
||||||
out("};\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*========================================================*/
|
|
||||||
|
|
||||||
#ifdef NOT_YET_IMPLEMENTED_U8X8_SCREEN_CAPTURE
|
|
||||||
|
|
||||||
struct _u8x8_capture_struct
|
|
||||||
{
|
|
||||||
u8x8_msg_cb old_cb;
|
|
||||||
uint8_t *buffer; /* tile_width*tile_height*8 bytes */
|
|
||||||
uint8_t tile_width;
|
|
||||||
uint8_t tile_height;
|
|
||||||
};
|
|
||||||
typedef struct _u8x8_capture_struct u8x8_capture_t;
|
|
||||||
|
|
||||||
|
|
||||||
u8x8_capture_t u8x8_capture;
|
|
||||||
|
|
||||||
|
|
||||||
static void u8x8_capture_memory_copy(uint8_t *dest, uint8_t *src, uint16_t cnt)
|
|
||||||
{
|
|
||||||
while( cnt > 0 )
|
|
||||||
{
|
|
||||||
*dest++ = *src++;
|
|
||||||
cnt--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8x8_capture_DrawTiles(u8x8_capture_t *capture, uint8_t tx, uint8_t ty, uint8_t tile_cnt, uint8_t *tile_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *dest_ptr = capture->buffer;
|
|
||||||
//printf("tile pos: %d %d, cnt=%d\n", tx, ty, tile_cnt);
|
|
||||||
if ( dest_ptr == NULL )
|
|
||||||
return;
|
|
||||||
dest_ptr += (uint16_t)ty*capture->tile_width*8;
|
|
||||||
dest_ptr += (uint16_t)tx*8;
|
|
||||||
u8x8_capture_memory_copy(dest_ptr, tile_ptr, tile_cnt*8);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_capture(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_DRAW_TILE )
|
|
||||||
{
|
|
||||||
uint8_t x, y, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_capture_DrawTiles(&u8x8_capture, x, y, c, ptr);
|
|
||||||
x += c;
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
}
|
|
||||||
return u8x8_capture.old_cb(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_GetCaptureMemoryPixel(u8x8_t *u8x8, uint16_t x, uint16_t y)
|
|
||||||
{
|
|
||||||
return u8x8_capture_GetPixel(&u8x8_capture, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* memory: tile_width*tile_height*8 bytes */
|
|
||||||
void u8x8_ConnectCapture(u8x8_t *u8x8, uint8_t tile_width, uint8_t tile_height, uint8_t *memory)
|
|
||||||
{
|
|
||||||
if ( u8x8->display_cb == u8x8_d_capture )
|
|
||||||
return; /* do nothing, capture already installed */
|
|
||||||
|
|
||||||
u8x8_capture.buffer = memory; /* tile_width*tile_height*8 bytes */
|
|
||||||
u8x8_capture.tile_width = tile_width;
|
|
||||||
u8x8_capture.tile_height = tile_height;
|
|
||||||
u8x8_capture.old_cb = u8x8->display_cb;
|
|
||||||
u8x8->display_cb = u8x8_d_capture;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_a2printer.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
Use DC2 bitmap command of the A2 Micro panel termal printer
|
|
||||||
double stroke
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
#define LINE_MIN_DELAY_MS 15
|
|
||||||
/* higher values improve quality */
|
|
||||||
/* however if the value is too high (>=5) then form feed does not work any more */
|
|
||||||
#define LINE_EXTRA_8PIXEL_DELAY_MS 3
|
|
||||||
/* this must be a power of two and between 1 and 8 */
|
|
||||||
/* best quality only with 1 */
|
|
||||||
#define NO_OF_LINES_TO_SEND_WITHOUT_DELAY 1
|
|
||||||
|
|
||||||
/* calculates the delay, based on the number of black pixel */
|
|
||||||
/* actually only "none-zero" bytes are calculated which is, of course not so accurate, but should be good enough */
|
|
||||||
uint16_t get_delay_in_milliseconds(uint8_t cnt, uint8_t *data)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint16_t time = LINE_MIN_DELAY_MS;
|
|
||||||
for ( i = 0; i < cnt; i++ )
|
|
||||||
if ( data[i] != 0 )
|
|
||||||
time += LINE_EXTRA_8PIXEL_DELAY_MS;
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_a2printer_common(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t c, i, j;
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint16_t delay_in_milliseconds;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
|
||||||
/*
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
// no setup required
|
|
||||||
// u8x8_cad_SendSequence(u8x8, u8x8_d_a2printer_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
// no powersave
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 27); /* ESC */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 55 ); /* parameter command */
|
|
||||||
/* increasing the "max printing dots" requires a good power supply, but LINE_EXTRA_8PIXEL_DELAY_MS could be reduced then */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1) ... lower values improve, probably my current supply is not sufficient */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 200); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 2); /* 0-255 Heating interval,Unit(10us),Default:2(20us) ... does not have much influence */
|
|
||||||
|
|
||||||
//c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
c = u8x8->display_info->tile_width;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 18); /* DC2 */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 42 ); /* * */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 8 ); /* height */
|
|
||||||
u8x8_cad_SendCmd(u8x8, c ); /* c, u8x8->display_info->tile_width */
|
|
||||||
|
|
||||||
for( j = 0; j < 8 / NO_OF_LINES_TO_SEND_WITHOUT_DELAY; j ++ )
|
|
||||||
{
|
|
||||||
|
|
||||||
delay_in_milliseconds = 0;
|
|
||||||
for( i = 0; i < NO_OF_LINES_TO_SEND_WITHOUT_DELAY; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* c, note: SendData can not handle more than 255 bytes, send one line of data */
|
|
||||||
delay_in_milliseconds += get_delay_in_milliseconds(c, ptr);
|
|
||||||
ptr += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
while( delay_in_milliseconds > 200 )
|
|
||||||
{
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_MILLI, 200, NULL);
|
|
||||||
delay_in_milliseconds -= 200;
|
|
||||||
}
|
|
||||||
u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_MILLI, delay_in_milliseconds, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set parameters back to their default values */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 27); /* ESC */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 55 ); /* parameter command */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 7); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
|
|
||||||
u8x8_cad_SendCmd(u8x8, 80); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 2); /* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_a2printer_384x240_display_info =
|
|
||||||
{
|
|
||||||
/* most of the settings are not required, because this is a serial RS232 printer */
|
|
||||||
|
|
||||||
/* chip_enable_level = */ 1,
|
|
||||||
/* chip_disable_level = */ 0,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 5,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 5,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 20,
|
|
||||||
/* sck_pulse_width_ns = */ 140,
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* old: sck_takeover_edge, new: active high (bit 1), rising edge (bit 0) */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 30,
|
|
||||||
/* write_pulse_width_ns = */ 40,
|
|
||||||
/* tile_width = */ 48,
|
|
||||||
/* tile_height = */ 30,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 384,
|
|
||||||
/* pixel_height = */ 240
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_a2printer_384x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_a2printer_384x240_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_a2printer_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ch1120.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2018, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
code copyied from sh1107
|
|
||||||
ch1120: 160x160 controller from Sino Wealth
|
|
||||||
https://github.com/olikraus/u8g2/issues/2496
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ch1120_noname_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ch1120_noname_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ch1120_160x160_noname_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ch1120_160x160_noname_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ch1120_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ch1120_64x128_noname_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ch1120_64x128_noname_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ch1120_noname_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ch1120_noname_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ch1120_160x160_noname_powersave0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ch1120_160x160_noname_powersave1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ch1120 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
//u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
|
||||||
|
|
||||||
// set column address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
|
|
||||||
|
|
||||||
// set page address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 ); // page cmd is a two byte command
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
|
|
||||||
#ifdef NOT_YET_REQUESTED
|
|
||||||
/* 160x160 OLED */
|
|
||||||
static const uint8_t u8x8_d_ch1120_160x160_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x060), /* clock divide ratio and oscillator frequency */
|
|
||||||
U8X8_CA(0x0a9, 0x003), /* set display resolution, 0=64x160, 1=96x160, 2=128x160, 3=160x160 */
|
|
||||||
U8X8_C(0x020), /* addressing mode */
|
|
||||||
U8X8_CA(0x081, 0x01f), /* set contrast control */
|
|
||||||
U8X8_CA(0x0ad, 0x80), /* DC/DC control 80=Use external Vpp, 89=Use internal DC/DC*/
|
|
||||||
U8X8_C(0x030), /* set discharge VSL level, 0x030..0x03f */
|
|
||||||
U8X8_CA(0x0d9, 0x028), /* pre-charge period */
|
|
||||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
|
||||||
U8X8_CA(0x0dc, 0x035), /* VSEGM Deselect Level */
|
|
||||||
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ch1120_160x160_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 60,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* ch1120: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* sometimes OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* ch1120: 100ns */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* ch1120: 100ns */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* ch1120: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 20,
|
|
||||||
/* tile_height = */ 20,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 160,
|
|
||||||
/* pixel_height = */ 160
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ch1120_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ch1120_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ch1120_160x160_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ch1120_160x160_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
|
|
||||||
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/2496, 128x160 OLED */
|
|
||||||
static const uint8_t u8x8_d_ch1120_128x160_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
//U8X8_CAA(0x21, 0x00, 0x1f), /* Set Column Start/End Address of Display RAM, mono mode */
|
|
||||||
//U8X8_CAA(0x22, 0x00, 0x4f), /* Set Row Start/End Address of Display RAM, mono mode */
|
|
||||||
U8X8_CA(0x0a2, 0x000), /* display start */
|
|
||||||
U8X8_CA(0x081, 0x08f), /* set contrast control */
|
|
||||||
U8X8_CA(0x0ac, 0x001), /* mono mode, or 0x003???*/
|
|
||||||
U8X8_CA(0x020, 0x000), /* addressing mode */
|
|
||||||
U8X8_C(0x0C8), /* scan direction */
|
|
||||||
U8X8_CA(0x0a3, 0x000), /* display rotation */
|
|
||||||
|
|
||||||
U8X8_CA(0x0a8, 0x07f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x010), /* display offset */
|
|
||||||
|
|
||||||
U8X8_CA(0x0d5, 0x01f), /* clock divide ratio and oscillator frequency */
|
|
||||||
|
|
||||||
U8X8_CA(0x048, 0x002), /* */
|
|
||||||
U8X8_CA(0x093, 0x002), /* */
|
|
||||||
U8X8_CA(0x0d8, 0x001), /* */
|
|
||||||
U8X8_CA(0x049, 0x006), /* */
|
|
||||||
U8X8_CA(0x0d9, 0x00f), /* */
|
|
||||||
U8X8_CA(0x094, 0x01f), /* */
|
|
||||||
U8X8_CA(0x04b, 0x004), /* */
|
|
||||||
U8X8_CA(0x0da, 0x000), /* */
|
|
||||||
U8X8_CA(0x0dc, 0x040), /* VSEGM Deselect Level */
|
|
||||||
U8X8_CA(0x0ad, 0x002), /* */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ch1120_128x160_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* ch1120: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* sometimes OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* ch1120: 100ns */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* ch1120: 100ns */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 40, /* ch1120: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 20,
|
|
||||||
/* default_x_offset = */ 16,
|
|
||||||
/* flipmode_x_offset = */ 16,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 160
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ch1120_128x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ch1120_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ch1120_128x160_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ch1120_128x160_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
@@ -1,206 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_gp1247ai.c
|
|
||||||
|
|
||||||
252x64
|
|
||||||
|
|
||||||
https://github.com/olikraus/u8g2/issues/1907
|
|
||||||
https://github.com/olikraus/u8g2/pull/1892
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2022, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
#define SWAP8(a) ((((a)&0x80) >> 7) | (((a)&0x40) >> 5) | (((a)&0x20) >> 3) | (((a)&0x10) >> 1) | (((a)&0x08) << 1) | (((a)&0x04) << 3) | (((a)&0x02) << 5) | (((a)&0x01) << 7))
|
|
||||||
|
|
||||||
/* ========== GP1247AI ========== */
|
|
||||||
static const u8x8_display_info_t u8x8_gp1247ai_display_info = {
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 240, /* tCS-CLK */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120, /* tCLK-CS */
|
|
||||||
/* reset_pulse_width_ms = */ 1, /* Trw */
|
|
||||||
/* post_reset_wait_ms = */ 1, /* Trth */
|
|
||||||
/* sda_setup_time_ns = */ 60, /* tsu */
|
|
||||||
/* sck_pulse_width_ns = */ 120, /* tcyc/2 */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* MAX 4.16 MHz */
|
|
||||||
/* spi_mode = */ 3, /* active low, falling edge, MSBFIRST */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* */
|
|
||||||
/* data_setup_time_ns = */ 60, /* tsu */
|
|
||||||
/* write_pulse_width_ns = */ 120, /* tcyc/2 */
|
|
||||||
/* tile_width = */ 32, /* 32*8=256 memory size */
|
|
||||||
/* tile_height = */ 8, /* 8*8=64 memory size */
|
|
||||||
/* default_x_offset = */ 0, /* */
|
|
||||||
/* flipmode_x_offset = */ 0, /* */
|
|
||||||
/* pixel_width = */ 253, /* display size */
|
|
||||||
/* pixel_height = */ 63 /* display size */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1247ai_init_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x0AA)), /* Software reset */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(1), /* Wait for reset */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x078), SWAP8(0x008)), /* Oscillation Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0CC), SWAP8(0x005), SWAP8(0x000)), /* VFD Mode Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAAA(SWAP8(0x0E0), SWAP8(0x0FC), SWAP8(0x03E), SWAP8(0x000)), /* Display Area Setting */
|
|
||||||
U8X8_A4(SWAP8(0x020), SWAP8(0x080), SWAP8(0x080), SWAP8(0x080)), /* Display Area Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAAAA(SWAP8(0x0B1), SWAP8(0x020), SWAP8(0x03F), SWAP8(0x000), SWAP8(0x001)), /* Internal Speed Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0A0), SWAP8(0x000), SWAP8(0x028)), /* Dimming level Setting (1024 level, 0x3FF max) */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x055)), /* Memory Map Clear */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(15), /* Wait for memory clear */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0C0), SWAP8(0x000), SWAP8(0x000)), /* DW1 position setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0D0), SWAP8(0x000), SWAP8(0x040)), /* DW2 position setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x080), SWAP8(0x080)), /* Display Mode Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x061)), /* Standby Mode */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1247ai_standby_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x061)), /* Standby */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1247ai_wakeup_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x06D)), /* Wake up */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(1), /* Wait for OSC stabilize */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x080), SWAP8(0x080)), /* After entering standby mode, the SC bit will be automatically cleared */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
uint8_t u8x8_d_gp1247ai_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t x, y;
|
|
||||||
uint16_t tx_cnt;
|
|
||||||
uint8_t swapped_byte;
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if (arg_int == 0)
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1247ai_wakeup_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1247ai_standby_seq);
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(0x0A0));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8((arg_int * 4) >> 8)); /* Dimming level */
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8((arg_int * 4) & 0xFF)); /* Dimming level */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos * 8;
|
|
||||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos * 8;
|
|
||||||
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(0x0F0));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(x));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(y));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(0x007)); /* return every 8 pixels */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
tx_cnt = ((u8x8_tile_t *)arg_ptr)->cnt * 8;
|
|
||||||
while (tx_cnt > 0)
|
|
||||||
{
|
|
||||||
swapped_byte = SWAP8(*ptr);
|
|
||||||
u8x8_cad_SendData(u8x8, 1, &swapped_byte);
|
|
||||||
ptr += 1;
|
|
||||||
tx_cnt -= 1;
|
|
||||||
}
|
|
||||||
arg_int--;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
uint8_t u8x8_d_gp1247ai_253x63(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_gp1247ai_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1247ai_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_gp1247ai_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,212 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_gp1287ai.c
|
|
||||||
|
|
||||||
https://github.com/olikraus/u8g2/issues/1907
|
|
||||||
https://github.com/olikraus/u8g2/pull/1892
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2022, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
#define SWAP8(a) ((((a)&0x80) >> 7) | (((a)&0x40) >> 5) | (((a)&0x20) >> 3) | (((a)&0x10) >> 1) | (((a)&0x08) << 1) | (((a)&0x04) << 3) | (((a)&0x02) << 5) | (((a)&0x01) << 7))
|
|
||||||
|
|
||||||
/* ========== GP1287AI ========== */
|
|
||||||
static const u8x8_display_info_t u8x8_gp1287ai_display_info = {
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 240, /* tCS-CLK */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120, /* tCLK-CS */
|
|
||||||
/* reset_pulse_width_ms = */ 1, /* Trw */
|
|
||||||
/* post_reset_wait_ms = */ 1, /* Trth */
|
|
||||||
/* sda_setup_time_ns = */ 60, /* tsu */
|
|
||||||
/* sck_pulse_width_ns = */ 120, /* tcyc/2 */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* MAX 4.16 MHz */
|
|
||||||
/* spi_mode = */ 3, /* active low, falling edge, MSBFIRST */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* */
|
|
||||||
/* data_setup_time_ns = */ 60, /* tsu */
|
|
||||||
/* write_pulse_width_ns = */ 120, /* tcyc/2 */
|
|
||||||
/* tile_width = */ 32, /* 32*8=256 memory size */
|
|
||||||
/* tile_height = */ 7, /* 7*8=56 memory size */
|
|
||||||
/* default_x_offset = */ 0, /* */
|
|
||||||
/* flipmode_x_offset = */ 0, /* */
|
|
||||||
/* pixel_width = */ 256, /* display size */
|
|
||||||
/* pixel_height = */ 50 /* display size */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1287ai_init_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x0AA)), /* Software reset */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(1), /* Wait for reset */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x078), SWAP8(0x008)), /* Oscillation Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0CC), SWAP8(0x002), SWAP8(0x000)), /* VFD Mode Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAAA(SWAP8(0x0E0), SWAP8(0x0FF), SWAP8(0x031), SWAP8(0x000)), /* Display Area Setting */
|
|
||||||
U8X8_A4(SWAP8(0x020), SWAP8(0x000), SWAP8(0x000), SWAP8(0x080)), /* Display Area Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAAAA(SWAP8(0x0B1), SWAP8(0x020), SWAP8(0x03F), SWAP8(0x000), SWAP8(0x001)), /* Internal Speed Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0A0), SWAP8(0x000), SWAP8(0x028)), /* Dimming level Setting (1024 level, 0x3FF max) */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x055)), /* Memory Map Clear */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(15), /* Waiting for memory clear */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0C0), SWAP8(0x000), SWAP8(0x004)), /* DW1 position setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0D0), SWAP8(0x000), SWAP8(0x03C)), /* DW2 position setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x090), SWAP8(0x000)), /* Internal Command */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x008), SWAP8(0x000)), /* T1 INT Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x080), SWAP8(0x000)), /* Display Mode Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x061)), /* Standby Mode */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1287ai_standby_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x061)), /* Standby */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1287ai_wakeup_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x06D)), /* Wake up */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(1), /* Wait for OSC stabilize */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x080), SWAP8(0x000)), /* After entering standby mode, the SC bit will be automatically cleared */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
uint8_t u8x8_d_gp1287ai_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t x, y;
|
|
||||||
uint16_t tx_cnt;
|
|
||||||
uint8_t swapped_byte;
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if (arg_int == 0)
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1287ai_wakeup_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1287ai_standby_seq);
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(0x0A0));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8((arg_int * 4) >> 8)); /* Dimming level */
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8((arg_int * 4) & 0xFF)); /* Dimming level */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos * 8;
|
|
||||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos * 8 + 4;
|
|
||||||
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(0x0F0));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(x));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(y));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(0x007)); /* return every 8 pixels */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
tx_cnt = ((u8x8_tile_t *)arg_ptr)->cnt * 8;
|
|
||||||
while (tx_cnt > 0)
|
|
||||||
{
|
|
||||||
swapped_byte = SWAP8(*ptr);
|
|
||||||
u8x8_cad_SendData(u8x8, 1, &swapped_byte);
|
|
||||||
ptr += 1;
|
|
||||||
tx_cnt -= 1;
|
|
||||||
}
|
|
||||||
arg_int--;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
uint8_t u8x8_d_gp1287ai_256x50(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_gp1287ai_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1287ai_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_gp1287ai_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_gp1294ai.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2023, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
#define SWAP8(a) ((((a)&0x80) >> 7) | (((a)&0x40) >> 5) | (((a)&0x20) >> 3) | (((a)&0x10) >> 1) | (((a)&0x08) << 1) | (((a)&0x04) << 3) | (((a)&0x02) << 5) | (((a)&0x01) << 7))
|
|
||||||
|
|
||||||
/* ========== GP1294AI ========== */
|
|
||||||
static const u8x8_display_info_t u8x8_gp1294ai_display_info = {
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 240, /* tCS-CLK */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120, /* tCLK-CS */
|
|
||||||
/* reset_pulse_width_ms = */ 1, /* Trw */
|
|
||||||
/* post_reset_wait_ms = */ 1, /* Trth */
|
|
||||||
/* sda_setup_time_ns = */ 60, /* tsu */
|
|
||||||
/* sck_pulse_width_ns = */ 120, /* tcyc/2 */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* MAX 4.16 MHz */
|
|
||||||
/* spi_mode = */ 3, /* active low, falling edge, MSBFIRST */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* */
|
|
||||||
/* data_setup_time_ns = */ 60, /* tsu */
|
|
||||||
/* write_pulse_width_ns = */ 120, /* tcyc/2 */
|
|
||||||
/* tile_width = */ 32, /* 32*8=256 memory size */
|
|
||||||
/* tile_height = */ 6, /* 6*8=48 memory size */
|
|
||||||
/* default_x_offset = */ 0, /* */
|
|
||||||
/* flipmode_x_offset = */ 0, /* */
|
|
||||||
/* pixel_width = */ 256, /* display size */
|
|
||||||
/* pixel_height = */ 48 /* display size */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1294ai_init_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x0AA)), /* Software reset */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(1), /* Wait for reset */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAAA(SWAP8(0x0CC), SWAP8(0x001), SWAP8(0x01F), SWAP8(0x000)), /* VFD Mode Setting */
|
|
||||||
U8X8_A4(SWAP8(0x0FF), SWAP8(0x02F), SWAP8(0x000), SWAP8(0x020)),
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0A0), SWAP8(0x028), SWAP8(0x000)), /* Dimming level Setting (1024 level, 0x3FF max) */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CAA(SWAP8(0x0C0), SWAP8(0x000), SWAP8(0x000)), /* DW1 position setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x080), SWAP8(0x010)), /* Display Mode Setting (Scan STOP) */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x008), SWAP8(0x000)), /* T1 INT Setting */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1294ai_standby_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x061)), /* Standby */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
static const uint8_t u8x8_d_gp1294ai_wakeup_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_C(SWAP8(0x06D)), /* Wake up */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
U8X8_DLY(1), /* Wait for OSC stabilize */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(),
|
|
||||||
U8X8_CA(SWAP8(0x080), SWAP8(0x000)), /* After entering standby mode, the SC bit will be automatically cleared */
|
|
||||||
U8X8_END_TRANSFER(),
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
uint8_t u8x8_d_gp1294ai_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t x, y;
|
|
||||||
uint16_t tx_cnt;
|
|
||||||
uint8_t swapped_byte;
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if (arg_int == 0)
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1294ai_wakeup_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1294ai_standby_seq);
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(0x0A0));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8((arg_int * 4) & 0xFF)); /* Dimming level */
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8((arg_int * 4) >> 8)); /* Dimming level */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos * 8;
|
|
||||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos * 8 + 4;
|
|
||||||
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(0x0F0));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(x));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(y));
|
|
||||||
u8x8_cad_SendArg(u8x8, SWAP8(0x007)); /* return every 8 pixels */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
tx_cnt = ((u8x8_tile_t *)arg_ptr)->cnt * 8;
|
|
||||||
while (tx_cnt > 0)
|
|
||||||
{
|
|
||||||
swapped_byte = SWAP8(*ptr);
|
|
||||||
u8x8_cad_SendData(u8x8, 1, &swapped_byte);
|
|
||||||
ptr += 1;
|
|
||||||
tx_cnt -= 1;
|
|
||||||
}
|
|
||||||
arg_int--;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
uint8_t u8x8_d_gp1294ai_256x48(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_gp1294ai_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1294ai_init_seq);
|
|
||||||
u8x8_ClearDisplay(u8x8); /* GP1294AI does not have the command to clear the memory and needs to be cleared manually */
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gp1294ai_standby_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_gp1294ai_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,296 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_gu800.c
|
|
||||||
|
|
||||||
Support for GU800 series of VFD displays
|
|
||||||
https://www.noritake-elec.com/products/vfd-display-module/dot-matrix-graphic-display/gu-800-series
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2021, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
u8x8_gu800_cad_110
|
|
||||||
|
|
||||||
WARNING: DO NOT USE THIS FILE AS TEMPLATE:
|
|
||||||
|
|
||||||
This code requires a special cad callback which includes the start
|
|
||||||
and end transfer code. As a consequence this code does not include any
|
|
||||||
start / end transfer calls.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_gu800_128x64_powersave0_seq[] = {
|
|
||||||
U8X8_CA(0x024, 0x040), /* Byte 1: Layer 0010xx00, Byte 2: 0x40 (graphics on, normal mode, no or/xor) */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_gu800_128x64_powersave1_seq[] = {
|
|
||||||
U8X8_CA(0x020, 0x040), /* Byte 1: Layer 0010xx00, Byte 2: 0x40 (graphics on, normal mode, no or/xor) */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* hardware flip is not supported by GU800 */
|
|
||||||
#ifdef NOT_SUPPORTED
|
|
||||||
static const uint8_t u8x8_d_gu800_128x64_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_gu800_128x64_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t u8x8_d_gu800_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_powersave1_seq);
|
|
||||||
break;
|
|
||||||
#ifdef NOT_SUPPORTED
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x4f - ((arg_int >> 4)&0x0f) ); /* GU800 has range from 0..15, max brightness is 0x040 */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x064 );
|
|
||||||
u8x8_cad_SendArg(u8x8, x );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x060 );
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos) );
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
/* SendData can not handle more than 255 bytes, treat c > 31 correctly */
|
|
||||||
if ( c > 31 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */
|
|
||||||
ptr+=248;
|
|
||||||
c -= 31;
|
|
||||||
}
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr);
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_gu800_128x64_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x05f), /* clear all RAM, clear address counters */
|
|
||||||
U8X8_DLY(1), /* delay for 1 ms (see datasheet) */
|
|
||||||
|
|
||||||
/* configure all area as graphics RAM */
|
|
||||||
U8X8_CA(0x62,0), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,1), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,2), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,3), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,4), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,5), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,6), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,7), U8X8_D1(0xff),
|
|
||||||
|
|
||||||
U8X8_CA(0x70, 0), /* horizontal shift */
|
|
||||||
U8X8_C(0xb0), /* vertical shift */
|
|
||||||
U8X8_C(0x40), /* min (0x04f) / max (0x040) brightness */
|
|
||||||
U8X8_C(0x84), /* x increment */
|
|
||||||
|
|
||||||
// U8X8_CA(0x024, 0x040) /* display on */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_d_gu800_128x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* GU800: CSS signal */
|
|
||||||
/* chip_disable_level = */ 1, /* GU800: CSS signal */
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 40,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 150,
|
|
||||||
/* reset_pulse_width_ms = */ 2, /* GU800: Unspecified in datasheet */
|
|
||||||
/* post_reset_wait_ms = */ 2, /* GU800: Min 1.5ms per datasheet */
|
|
||||||
/* sda_setup_time_ns = */ 40, /* GU800: 40ns according to the timing diagram */
|
|
||||||
/* sck_pulse_width_ns = */ 80, /* GU800: Min 80ns per datasheet */
|
|
||||||
/* sck_clock_hz = */ 4000000UL,
|
|
||||||
/* spi_mode = */ 2, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* GU800: Not used */
|
|
||||||
/* data_setup_time_ns = */ 40, /* GU800: Min 40ns per datasheet */
|
|
||||||
/* write_pulse_width_ns = */ 150, /* GU800: Min 150ns per datasheet */
|
|
||||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_gu800_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_gu800_common(u8x8, msg, arg_int, arg_ptr) )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_d_gu800_128x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_128x64_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/1970 */
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_gu800_160x16_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x05f), /* clear all RAM, clear address counters */
|
|
||||||
U8X8_DLY(1), /* delay for 1 ms (see datasheet) */
|
|
||||||
|
|
||||||
/* configure all area as graphics RAM */
|
|
||||||
U8X8_CA(0x62,0), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,1), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,2), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,3), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,4), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,5), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,6), U8X8_D1(0xff),
|
|
||||||
U8X8_CA(0x62,7), U8X8_D1(0xff),
|
|
||||||
|
|
||||||
U8X8_CA(0x70, 0), /* horizontal shift */
|
|
||||||
U8X8_C(0xb0), /* vertical shift */
|
|
||||||
U8X8_C(0x40), /* min (0x04f) / max (0x040) brightness */
|
|
||||||
U8X8_C(0x84), /* x increment */
|
|
||||||
|
|
||||||
// U8X8_CA(0x024, 0x040) /* display on */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_d_gu800_160x16_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* GU800: CSS signal */
|
|
||||||
/* chip_disable_level = */ 1, /* GU800: CSS signal */
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 40,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 150,
|
|
||||||
/* reset_pulse_width_ms = */ 2, /* GU800: Unspecified in datasheet */
|
|
||||||
/* post_reset_wait_ms = */ 2, /* GU800: Min 1.5ms per datasheet */
|
|
||||||
/* sda_setup_time_ns = */ 40, /* GU800: 40ns according to the timing diagram */
|
|
||||||
/* sck_pulse_width_ns = */ 80, /* GU800: Min 80ns per datasheet */
|
|
||||||
/* sck_clock_hz = */ 4000000UL,
|
|
||||||
/* spi_mode = */ 3, /* active high, rising edge, ISSUE 1970 */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* GU800: Not used */
|
|
||||||
/* data_setup_time_ns = */ 40, /* GU800: Min 40ns per datasheet */
|
|
||||||
/* write_pulse_width_ns = */ 150, /* GU800: Min 150ns per datasheet */
|
|
||||||
/* tile_width = */ 20, /* width of 8*20=160 pixel */
|
|
||||||
/* tile_height = */ 2,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 160,
|
|
||||||
/* pixel_height = */ 16
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_gu800_160x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_gu800_common(u8x8, msg, arg_int, arg_ptr) )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_d_gu800_160x16_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_gu800_160x16_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
|
|
||||||
@@ -1,352 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_hd44102.c
|
|
||||||
|
|
||||||
Support for HD44102 and T7932 controller (https://github.com/olikraus/u8g2/issues/1492)
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2021, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hd44102_init_seq[] = {
|
|
||||||
U8X8_C(0x03b), /* upcount */
|
|
||||||
U8X8_C(0x03e), /* start at the top */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hd44102_powersave0_seq[] = {
|
|
||||||
U8X8_C(0x039), /* display on */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hd44102_powersave1_seq[] = {
|
|
||||||
U8X8_C(0x038), /* display off */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
data: pointer to "cnt" bytes
|
|
||||||
cnt: number of bytes, which should be sent
|
|
||||||
page: 0..3: the current page within the display
|
|
||||||
offset: offset location on the display, where the data should be placed
|
|
||||||
cs_none: 3-bit chip select pattern for not selecting any display
|
|
||||||
cs0: 3-bit chip select pattern for the left display (0..49)
|
|
||||||
cs1: 3-bit chip select pattern for the middle display (50..99)
|
|
||||||
cs2: 3-bit chip select pattern for the right display (100..149)
|
|
||||||
|
|
||||||
The csX bit pattern is:
|
|
||||||
bit 0: CS
|
|
||||||
bit 1: CS1
|
|
||||||
bit 2: CS2
|
|
||||||
see u8x8_byte_set_ks0108_cs() in u8x8_byte.c
|
|
||||||
|
|
||||||
*/
|
|
||||||
static void u8x8_hd44102_outy(u8x8_t *u8x8, uint8_t *data, uint8_t cnt, uint8_t page, uint8_t offset, uint8_t cs_none, uint8_t cs0, uint8_t cs1, uint8_t cs2)
|
|
||||||
{
|
|
||||||
uint8_t pos = offset;
|
|
||||||
uint8_t data_cnt;
|
|
||||||
|
|
||||||
/* write to left display? */
|
|
||||||
if ( pos < 50 && cnt > 0 )
|
|
||||||
{
|
|
||||||
/* calculate number of bytes to sent */
|
|
||||||
data_cnt = 50 - pos;
|
|
||||||
if ( data_cnt > cnt )
|
|
||||||
data_cnt = cnt;
|
|
||||||
if ( data_cnt > 50 )
|
|
||||||
data_cnt = 50;
|
|
||||||
|
|
||||||
/* sent the data */
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs0, NULL);
|
|
||||||
u8x8_cad_SendCmd(u8x8, (page << 6) | pos );
|
|
||||||
u8x8_cad_SendData(u8x8, data_cnt, data);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs_none, NULL);
|
|
||||||
|
|
||||||
/* adjust the data */
|
|
||||||
data += data_cnt;
|
|
||||||
pos += data_cnt;
|
|
||||||
cnt -= data_cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write to middle display? */
|
|
||||||
if ( pos < 100 && cnt > 0 )
|
|
||||||
{
|
|
||||||
/* calculate number of bytes to sent */
|
|
||||||
data_cnt = 100 - pos;
|
|
||||||
if ( data_cnt > cnt )
|
|
||||||
data_cnt = cnt;
|
|
||||||
if ( data_cnt > 50 )
|
|
||||||
data_cnt = 50;
|
|
||||||
|
|
||||||
/* sent the data */
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs1, NULL);
|
|
||||||
u8x8_cad_SendCmd(u8x8, (page << 6) | (pos-50) );
|
|
||||||
u8x8_cad_SendData(u8x8, data_cnt, data);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs_none, NULL);
|
|
||||||
|
|
||||||
/* adjust the data */
|
|
||||||
data += data_cnt;
|
|
||||||
pos += data_cnt;
|
|
||||||
cnt -= data_cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write to right display? */
|
|
||||||
if ( pos < 150 && cnt > 0 )
|
|
||||||
{
|
|
||||||
/* calculate number of bytes to sent */
|
|
||||||
data_cnt = 150 - pos;
|
|
||||||
if ( data_cnt > cnt )
|
|
||||||
data_cnt = cnt;
|
|
||||||
if ( data_cnt > 50 )
|
|
||||||
data_cnt = 50;
|
|
||||||
|
|
||||||
/* sent the data */
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs2, NULL);
|
|
||||||
u8x8_cad_SendCmd(u8x8, (page << 6) | (pos-100) );
|
|
||||||
u8x8_cad_SendData(u8x8, data_cnt, data);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs_none, NULL);
|
|
||||||
|
|
||||||
/* adjust the data */
|
|
||||||
data += data_cnt;
|
|
||||||
pos += data_cnt;
|
|
||||||
cnt -= data_cnt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_hd44102_150x32_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* KS0108/HD44102: Not used */
|
|
||||||
/* chip_disable_level = */ 1, /* KS0108/HD44102: Not used */
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 12,
|
|
||||||
/* sck_pulse_width_ns = */ 75, /* KS0108/HD44102: Not used */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* KS0108/HD44102: Not used */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108/HD44102: Not used */
|
|
||||||
/* data_setup_time_ns = */ 200,
|
|
||||||
/* write_pulse_width_ns = */ 250, /* KS0108/HD44102: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
|
||||||
/* tile_width = */ 19, /* width of 19*8=152 pixel */
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 150,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
//uint8_t u8x8_d_hd44102_150x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
|
|
||||||
uint8_t u8x8_d_t7932_150x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t cs[4] = {1, 2, 4, 0};
|
|
||||||
uint8_t i;
|
|
||||||
uint8_t x, cnt;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hd44102_150x32_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
|
|
||||||
for( i = 0; i < 3; i++ )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs[i], NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs[3], NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
|
|
||||||
for( i = 0; i < 3; i++ )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, cs[i], NULL);
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave0_seq);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave1_seq);
|
|
||||||
}
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, cs[3], NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// The HD44102 can not mirror the cols and rows, use U8g2 for rotation
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
// break;
|
|
||||||
// The HD44102 has no internal contrast command
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
// break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
cnt = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
x*=8;
|
|
||||||
cnt*=8;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_hd44102_outy(u8x8,
|
|
||||||
((u8x8_tile_t *)arg_ptr)->tile_ptr,
|
|
||||||
cnt,
|
|
||||||
((u8x8_tile_t *)arg_ptr)->y_pos,
|
|
||||||
x,
|
|
||||||
cs[3], cs[0], cs[1], cs[2]);
|
|
||||||
arg_int--;
|
|
||||||
x += cnt;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_hd44102_100x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* KS0108/HD44102: Not used */
|
|
||||||
/* chip_disable_level = */ 1, /* KS0108/HD44102: Not used */
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 12,
|
|
||||||
/* sck_pulse_width_ns = */ 75, /* KS0108/HD44102: Not used */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* KS0108/HD44102: Not used */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108/HD44102: Not used */
|
|
||||||
/* data_setup_time_ns = */ 200,
|
|
||||||
/* write_pulse_width_ns = */ 250, /* KS0108/HD44102: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
|
||||||
/* tile_width = */ 13, /* width of 13*8=104 pixel */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 100,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_hd44102_100x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
uint8_t x, cnt, page;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hd44102_100x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
|
|
||||||
for( i = 0; i < 4; i++ )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, i, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
|
|
||||||
for( i = 0; i < 4; i++ )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, i, NULL);
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave0_seq);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hd44102_powersave1_seq);
|
|
||||||
}
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// The HD44102 can not mirror the cols and rows, use U8g2 for rotation
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
// break;
|
|
||||||
// The HD44102 has no internal contrast command
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
// break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
cnt = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
page = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
|
||||||
x*=8;
|
|
||||||
cnt*=8;
|
|
||||||
if ( page < 4 )
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_hd44102_outy(u8x8,
|
|
||||||
((u8x8_tile_t *)arg_ptr)->tile_ptr,
|
|
||||||
cnt,
|
|
||||||
page,
|
|
||||||
x,
|
|
||||||
7, 0, 1, 7);
|
|
||||||
arg_int--;
|
|
||||||
x += cnt;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_hd44102_outy(u8x8,
|
|
||||||
((u8x8_tile_t *)arg_ptr)->tile_ptr,
|
|
||||||
cnt,
|
|
||||||
page-4,
|
|
||||||
x,
|
|
||||||
7, 2, 3, 7);
|
|
||||||
arg_int--;
|
|
||||||
x += cnt;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,552 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_il3820_296x128.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2017, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
il3820: 200x300x1
|
|
||||||
|
|
||||||
command
|
|
||||||
0x22: assign actions
|
|
||||||
0x20: execute actions
|
|
||||||
|
|
||||||
action for command 0x022 are (more or less guessed)
|
|
||||||
bit 7: Enable Clock
|
|
||||||
bit 6: Enable Charge Pump
|
|
||||||
bit 5: Load Temparture Value (???)
|
|
||||||
bit 4: Load LUT (???)
|
|
||||||
bit 3: Initial Display (???)
|
|
||||||
bit 2: Pattern Display --> Requires about 945ms with the LUT from below
|
|
||||||
bit 1: Disable Charge Pump
|
|
||||||
bit 0: Disable Clock
|
|
||||||
|
|
||||||
Disable Charge Pump and Clock require about 10ms
|
|
||||||
Enable Charge Pump and Clock require about 100 to 300ms
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- Introduced a refresh display message, which copies RAM to display
|
|
||||||
- Charge pump is always enabled. Charge pump can be enabled/disabled via power save message
|
|
||||||
- U8x8 will not really work because of the two buffers in the SSD1606, however U8g2 should be ok.
|
|
||||||
|
|
||||||
LUT for the 296x128 device (IL3820)
|
|
||||||
LUT (cmd: 0x032 has 30 bytes)
|
|
||||||
section 6.8 of the datasheet mentions 256 bits = 32 bytes for the LUT
|
|
||||||
chapter 7 tells 30 bytes
|
|
||||||
|
|
||||||
according to section 6.8:
|
|
||||||
20 bytes waveform
|
|
||||||
10 bytes timing
|
|
||||||
1 byte named as VSH/VSL
|
|
||||||
1 empty byte
|
|
||||||
according to the command table, the lut has 240 bits (=30 bytes * 8 bits)
|
|
||||||
|
|
||||||
|
|
||||||
LUT / Refresh time
|
|
||||||
total_refresh_time = (refresh_lines + dummy_lines*2)*TGate*TS_Sum/f_OSC
|
|
||||||
|
|
||||||
f_OSC=1MHz (according to the datasheets)
|
|
||||||
refreh_lines = 296 (for the waveshare display, 0x045 cmd)
|
|
||||||
dummy_lines = 22 (for the upcoming u8g2 code, 0x03a cmd)
|
|
||||||
TGate = 62 (POR default, 0x03b cmd)
|
|
||||||
TS_Sum: Sum of all TS entries of the second part of the LUT
|
|
||||||
f_OSC: 1MHz according to the datasheet.
|
|
||||||
|
|
||||||
so we have
|
|
||||||
|
|
||||||
total_refresh_time = 21080*TS_Sum/1000000 = 21ms * TS_Sum
|
|
||||||
|
|
||||||
|
|
||||||
This file includes two devices:
|
|
||||||
u8x8_d_il3820_296x128 --> includes LUT which is probably from the WaveShare 2.9 Vendor
|
|
||||||
u8x8_d_il3820_v2_296x128 --> includes LUT which was optimized for faster speed and lesser flicker
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Waveform part of the LUT (20 bytes) */
|
|
||||||
/* bit 7/6: 1 - 1 transition */
|
|
||||||
/* bit 5/4: 1 - 0 transition */
|
|
||||||
/* bit 3/2: 0 - 1 transition */
|
|
||||||
/* bit 1/0: 0 - 0 transition */
|
|
||||||
/* 00 – VSS */
|
|
||||||
/* 01 – VSH */
|
|
||||||
/* 10 – VSL */
|
|
||||||
/* 11 – NA */
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
/* common code for all devices */
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_il3820_296x128_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x22, 0xc0), /* enable clock and charge pump */
|
|
||||||
U8X8_C(0x20), /* execute sequence */
|
|
||||||
U8X8_DLY(200), /* according to my measures it may take up to 150ms */
|
|
||||||
U8X8_DLY(100), /* but it might take longer */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_il3820_296x128_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
/* disable clock and charge pump only, deep sleep is not entered, because we will loose RAM content */
|
|
||||||
U8X8_CA(0x22, 0x02), /* only disable charge pump, HW reset seems to be required if the clock is disabled */
|
|
||||||
U8X8_C(0x20), /* execute sequence */
|
|
||||||
U8X8_DLY(20),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
// static const uint8_t u8x8_d_il3820_296x128_flip0_seq[] = {
|
|
||||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
// U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
// U8X8_END() /* end of sequence */
|
|
||||||
// };
|
|
||||||
|
|
||||||
// static const uint8_t u8x8_d_il3820_296x128_flip1_seq[] = {
|
|
||||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
// U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
// U8X8_END() /* end of sequence */
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_il3820_296x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 120,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 60,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 50, /* IL3820 */
|
|
||||||
/* sck_pulse_width_ns = */ 125, /* IL3820: 125ns, clock cycle = 250ns */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 37, /* 37*8 = 296 */
|
|
||||||
/* tile_height = */ 16, /* 16*8 = 128 */
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 296,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t *u8x8_convert_tile_for_il3820(uint8_t *t)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
static uint8_t buf[8];
|
|
||||||
uint8_t *pbuf = buf;
|
|
||||||
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
*pbuf++ = ~(*t++);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void u8x8_d_il3820_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr) U8X8_NOINLINE;
|
|
||||||
static void u8x8_d_il3820_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint16_t x;
|
|
||||||
uint8_t c, page;
|
|
||||||
uint8_t *ptr;
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
page = u8x8->display_info->tile_height;
|
|
||||||
page --;
|
|
||||||
page -= (((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
//u8x8_cad_SendCmd(u8x8, 0x011 ); /* cursor increment mode */
|
|
||||||
//u8x8_cad_SendArg(u8x8, 7);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x04f ); /* set cursor column */
|
|
||||||
u8x8_cad_SendArg(u8x8, x&255);
|
|
||||||
u8x8_cad_SendArg(u8x8, x>>8);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x04e ); /* set cursor row */
|
|
||||||
u8x8_cad_SendArg(u8x8, page);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x024 );
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_il3820(ptr));
|
|
||||||
ptr += 8;
|
|
||||||
x += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_il3820_exec_1000dly_seq[] = {
|
|
||||||
// assumes, that the start transfer has happend
|
|
||||||
U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display */
|
|
||||||
U8X8_C(0x20), /* execute sequence */
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static void u8x8_d_il3820_first_init(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
u8x8_ClearDisplay(u8x8);
|
|
||||||
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x032); // program update sequence
|
|
||||||
u8x8_cad_SendMultipleArg(u8x8, 8, 0x055); // all black
|
|
||||||
u8x8_cad_SendMultipleArg(u8x8, 12, 0x0aa); // all white
|
|
||||||
u8x8_cad_SendMultipleArg(u8x8, 10, 0x022); // 830ms
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_exec_1000dly_seq);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef OBSOLETE
|
|
||||||
static void u8x8_d_il3820_second_init(u8x8_t *u8x8)
|
|
||||||
{
|
|
||||||
u8x8_ClearDisplay(u8x8);
|
|
||||||
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x032); // program update sequence
|
|
||||||
u8x8_cad_SendMultipleArg(u8x8, 20, 0x000); // do nothing
|
|
||||||
u8x8_cad_SendMultipleArg(u8x8, 10, 0x011); // 414ms dly
|
|
||||||
/* reuse sequence from above, ok some time is wasted here, */
|
|
||||||
/* delay could be lesser */
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_exec_1000dly_seq);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
/* first version, LUT from WaveShare */
|
|
||||||
|
|
||||||
|
|
||||||
/* http://www.waveshare.com/wiki/File:2.9inch_e-Paper_Module_code.7z */
|
|
||||||
static const uint8_t u8x8_d_il3820_296x128_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: Disable */
|
|
||||||
U8X8_C(0x01),
|
|
||||||
U8X8_A(295 % 256), U8X8_A(295/256), U8X8_A(0),
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_CA(0x03, 0x00), /* Gate Driving voltage: 15V (lowest value)*/
|
|
||||||
U8X8_CA(0x04, 0x0a), /* Source Driving voltage: 15V (mid value and POR)*/
|
|
||||||
|
|
||||||
//U8X8_CA(0x22, 0xc0), /* display update seq. option: enable clk, enable CP, .... todo: this is never activated */
|
|
||||||
|
|
||||||
//U8X8_CA(0x0b, 7), /* Set Delay of gate and source non overlap period, POR = 7 */
|
|
||||||
U8X8_CA(0x2c, 0xa8), /* write vcom value*/
|
|
||||||
U8X8_CA(0x3a, 0x16), /* dummy lines POR=22 (0x016) */
|
|
||||||
U8X8_CA(0x3b, 0x08), /* gate time POR=0x08*/
|
|
||||||
U8X8_CA(0x3c, 0x33), /* select boarder waveform */
|
|
||||||
//U8X8_CA(0x22, 0xc4), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_CA(0x11, 0x07), /* Define data entry mode, x&y inc, x first*/
|
|
||||||
|
|
||||||
U8X8_CAA(0x44, 0, 29), /* RAM x start & end, issue 920: end should be (128/8)-1=15. */
|
|
||||||
U8X8_CAAAA(0x45, 0, 0, 295&255, 295>>8), /* RAM y start & end */
|
|
||||||
|
|
||||||
//U8X8_CA(0x4e, 0), /* set x pos, 0..29? */
|
|
||||||
//U8X8_CAA(0x4f, 0, 0), /* set y pos, 0...320??? */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_il3820_to_display_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
/*
|
|
||||||
0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
measured 1582 ms
|
|
||||||
*/
|
|
||||||
U8X8_C(0x32), /* write LUT register*/
|
|
||||||
/* original values */
|
|
||||||
U8X8_A(0x50),
|
|
||||||
U8X8_A(0xaa),
|
|
||||||
U8X8_A(0x55),
|
|
||||||
U8X8_A(0xaa),
|
|
||||||
U8X8_A(0x11),
|
|
||||||
|
|
||||||
U8X8_A(0x11),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
/* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
|
|
||||||
U8X8_A(0xff),
|
|
||||||
U8X8_A(0xff),
|
|
||||||
U8X8_A(0x3f),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display, assumes clk and charge pump are enabled */
|
|
||||||
U8X8_C(0x20), /* execute sequence */
|
|
||||||
|
|
||||||
U8X8_DLY(250), /* delay for 1620ms. The current sequence takes 1582ms */
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(120),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_il3820_296x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_il3820_296x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_init_seq);
|
|
||||||
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
|
||||||
u8x8_d_il3820_first_init(u8x8);
|
|
||||||
|
|
||||||
/* usually the DISPLAY_INIT message leaves the display in power save state */
|
|
||||||
/* however this is not done for e-paper devices, see: */
|
|
||||||
/* https://github.com/olikraus/u8g2/wiki/internal#powersave-mode */
|
|
||||||
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_d_il3820_draw_tile(u8x8, arg_int, arg_ptr);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_REFRESH:
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_to_display_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=================================================*/
|
|
||||||
/* second version for the IL3820 display */
|
|
||||||
|
|
||||||
|
|
||||||
/* http://www.waveshare.com/wiki/File:2.9inch_e-Paper_Module_code.7z */
|
|
||||||
static const uint8_t u8x8_d_il3820_v2_296x128_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
// U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: POR: Normal mode */
|
|
||||||
U8X8_C(0x01),
|
|
||||||
U8X8_A(295 % 256), U8X8_A(295/256), U8X8_A(0),
|
|
||||||
|
|
||||||
/* the driving voltagesmust not be that high, in order to aviod level change after */
|
|
||||||
/* some seconds (which happens with 0xea */
|
|
||||||
U8X8_CA(0x03, 0x75), /* Gate Driving voltage: +/-15V =0x00 POR (+22/-20V) = 0x0ea*/
|
|
||||||
U8X8_CA(0x04, 0x0a), /* Source Driving voltage: (POR=0x0a=15V), max=0x0e*/
|
|
||||||
|
|
||||||
U8X8_CA(0x0b, 7), /* Set Delay of gate and source non overlap period, POR = 7 */
|
|
||||||
U8X8_CA(0x2c, 0xa8), /* write vcom value*/
|
|
||||||
U8X8_CA(0x3a, 0x16), /* dummy lines POR=22 (0x016) */
|
|
||||||
U8X8_CA(0x3b, 0x08), /* gate time POR=0x08*/
|
|
||||||
U8X8_CA(0x3c, 0x33), /* select boarder waveform */
|
|
||||||
|
|
||||||
U8X8_CA(0x11, 0x07), /* Define data entry mode, x&y inc, x first*/
|
|
||||||
U8X8_CAA(0x44, 0, 29), /* RAM x start & end, 32*4=128 */
|
|
||||||
U8X8_CAAAA(0x45, 0, 0, 295&255, 295>>8), /* RAM y start & end, 0..295 */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_il3820_v2_to_display_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
/*
|
|
||||||
0xaa, 0x09, 0x09, 0x19, 0x19,
|
|
||||||
0x11, 0x11, 0x11, 0x11, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
|
|
||||||
0x75, 0x77, 0x77, 0x77, 0x07,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
measured 1240 ms
|
|
||||||
*/
|
|
||||||
U8X8_C(0x32), /* write LUT register*/
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/347 */
|
|
||||||
U8X8_A(0xaa),
|
|
||||||
U8X8_A(0x09),
|
|
||||||
U8X8_A(0x09),
|
|
||||||
U8X8_A(0x19),
|
|
||||||
U8X8_A(0x19),
|
|
||||||
|
|
||||||
U8X8_A(0x11),
|
|
||||||
U8X8_A(0x11),
|
|
||||||
U8X8_A(0x11),
|
|
||||||
U8X8_A(0x11),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
/* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
|
|
||||||
U8X8_A(0x75),
|
|
||||||
U8X8_A(0x77),
|
|
||||||
U8X8_A(0x77),
|
|
||||||
U8X8_A(0x77),
|
|
||||||
U8X8_A(0x07),
|
|
||||||
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
U8X8_A(0x00),
|
|
||||||
|
|
||||||
U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display */
|
|
||||||
U8X8_C(0x20), /* execute sequence */
|
|
||||||
|
|
||||||
U8X8_DLY(250), /* delay for 1400ms. The current sequence takes 1240ms, it was reported, that longer delays are better */
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(250),
|
|
||||||
|
|
||||||
U8X8_DLY(250),
|
|
||||||
U8X8_DLY(150), /* extended, #318 */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_il3820_v2_296x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_il3820_296x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_v2_296x128_init_seq);
|
|
||||||
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
|
||||||
u8x8_d_il3820_first_init(u8x8);
|
|
||||||
/* u8x8_d_il3820_second_init(u8x8); */ /* not required, u8g2.begin() will also clear the display once more */
|
|
||||||
|
|
||||||
/* usually the DISPLAY_INIT message leaves the display in power save state */
|
|
||||||
/* however this is not done for e-paper devices, see: */
|
|
||||||
/* https://github.com/olikraus/u8g2/wiki/internal#powersave-mode */
|
|
||||||
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_d_il3820_draw_tile(u8x8, arg_int, arg_ptr);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_REFRESH:
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_v2_to_display_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ist3020.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2017, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3020_erc19264_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a4), /* all pixel off, issue 142 */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3020_erc19264_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3020_erc19264_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3020_erc19264_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ist3020_erc19264_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 150, /* IST3020 datasheet, page 56 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 150, /* IST3020 datasheet, page 56 */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 1,
|
|
||||||
/* sda_setup_time_ns = */ 100, /* IST3020 datasheet, page 56 */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* IST3020 datasheet, page 56 */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40, /* IST3020 datasheet, page 54 */
|
|
||||||
/* write_pulse_width_ns = */ 60, /* IST3020 datasheet, page 54 */
|
|
||||||
/* tile_width = */ 24, /* width of 24*8=192 pixel */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 64,
|
|
||||||
/* pixel_width = */ 192,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3020_erc19264_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0e2), /* soft reset */
|
|
||||||
U8X8_C(0x0ab), /* build in osc on, used in ER code, but not mentioned in data sheet */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
|
|
||||||
U8X8_C(0x0a0), /* ADC set to reverse */
|
|
||||||
U8X8_C(0x0c8), /* common output mode */
|
|
||||||
// Flipmode
|
|
||||||
//U8X8_C(0x0a0), /* ADC set to reverse */
|
|
||||||
//U8X8_C(0x0c8), /* common output mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
|
|
||||||
U8X8_C(0x0a3), /* FIX: LCD bias 1/7, old value was 1/9 (0x0a2) */
|
|
||||||
|
|
||||||
U8X8_C(0x028|4), /* all power control circuits on */
|
|
||||||
U8X8_DLY(50),
|
|
||||||
U8X8_C(0x028|6), /* all power control circuits on */
|
|
||||||
U8X8_DLY(50),
|
|
||||||
U8X8_C(0x028|7), /* all power control circuits on */
|
|
||||||
U8X8_DLY(50),
|
|
||||||
|
|
||||||
U8X8_C(0x020), /* v0 voltage resistor ratio */
|
|
||||||
U8X8_CA(0x081, 0x019), /* set contrast, contrast value (from ER code: 45) */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ist3020_erc19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ist3020_erc19264_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* st7567 has range from 0 to 63 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
c *= 8;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ist3088.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2019, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
IST3088: 320x240 monochrome LCD, 16 gray levels with B/W mode
|
|
||||||
|
|
||||||
https://github.com/olikraus/u8g2/issues/1887
|
|
||||||
|
|
||||||
CAD: 011
|
|
||||||
commands and arg/data are always 16 bit, MSB first
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/* powersave: maybe we could go to sleep mode, see register 3 */
|
|
||||||
static const uint8_t u8x8_d_ist3088_320x240_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CCAA(0x0, 0x07, 0x00, 0x01), // Display Control Bit 2: BW, 1: Invert, 0: Display enable
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3088_320x240_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CCAA(0x0, 0x07, 0x00, 0x00), // Display Control Bit 2: BW, 1: Invert, 0: Display enable
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3088_320x240_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CCAA(0x0, 0x01, 0x00, 0x00), // Driver Control, 1/240 Duty
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist3088_320x240_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CCAA(0x0, 0x01, 0x00, 0x00), // Driver Control, 1/240 Duty
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*===================================================*/
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ist3088_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
//uint16_t x;
|
|
||||||
int i;
|
|
||||||
uint8_t y;
|
|
||||||
uint8_t c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ist3088_320x240_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3088_320x240_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3088_320x240_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3088_320x240_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3088_320x240_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3088_320x240_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x00 );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x05 );
|
|
||||||
u8x8_cad_SendArg(u8x8, 0 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int );
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
/*
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
*/
|
|
||||||
|
|
||||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
y*=8;
|
|
||||||
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x8);
|
|
||||||
u8x8_cad_SendArg(u8x8, y);
|
|
||||||
u8x8_cad_SendArg(u8x8, 0 );
|
|
||||||
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0); // write data
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x9); // write data
|
|
||||||
|
|
||||||
|
|
||||||
//c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
|
|
||||||
|
|
||||||
ptr += u8x8->display_info->tile_width;
|
|
||||||
y ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===================================================*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
SdCmd(0x01); // driver control
|
|
||||||
SdData(0x00); SdData(0x00); // c1-->c240 s1-->s240 duty=1/240
|
|
||||||
SdCmd(0x02); // driver control
|
|
||||||
SdData(0x01); SdData(0x4c); //0x15
|
|
||||||
SdCmd(0x03); // power control
|
|
||||||
SdData(0x00); SdData(0x70); // VC VR Vf=1
|
|
||||||
SdCmd(0x04); // power control
|
|
||||||
SdData(0x04); SdData(0x61); //0x61 //1/14b
|
|
||||||
SdCmd(0x05); // CT control
|
|
||||||
SdData(0x00); SdData(0x6a); // 0X76
|
|
||||||
SdCmd(0x06); // CT control
|
|
||||||
SdData(0x00); SdData(0x03);
|
|
||||||
SdCmd(0x23); // B/W MODE,16G NEED REMOVE
|
|
||||||
SdData(0x00); SdData(0x04); //04:mono
|
|
||||||
SdCmd(0x28); // OSC
|
|
||||||
SdData(0x00); SdData(0x0c);
|
|
||||||
SdCmd(0x37);
|
|
||||||
SdData(0x00); SdData(0x12);
|
|
||||||
SdCmd(0x07);
|
|
||||||
SdData(0x00); SdData(0x01);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/1887 */
|
|
||||||
static const uint8_t u8x8_d_ist3088_320x240_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
/* disableLCD */
|
|
||||||
U8X8_CCAA(0x0, 0x07, 0x00, 0x00), // Display Control Bit 2: BW, 1: Invert, 0: Display enable
|
|
||||||
|
|
||||||
U8X8_CCAA(0x0, 0x01, 0x00, 0x00), // Driver Control, 1/240 Duty
|
|
||||||
U8X8_CCAA(0x0, 0x02, 0x01, 0x4c), // Polarity Control
|
|
||||||
|
|
||||||
U8X8_CCAA(0x0, 0x06, 0x00, 0x03), // Entry mode: h/v increment
|
|
||||||
//U8X8_CCAA(0x0, 0x04, 0x07, 0x61), // Power Control 2: 0x07: 1/16 Bias, Vout1 x 4
|
|
||||||
U8X8_CCAA(0x0, 0x04, 0x04, 0x61), // Power Control 2: 0x07: 1/16 Bias, Vout1 x 4
|
|
||||||
U8X8_CCAA(0x0, 0x05, 0x00, 0x6a), // Contrast, 0..255,
|
|
||||||
|
|
||||||
U8X8_CCAA(0x0, 0x03, 0x00, 0x40), // Enable voltage converter
|
|
||||||
U8X8_DLY(10),
|
|
||||||
U8X8_CCAA(0x0, 0x03, 0x00, 0x60), // Enable voltage regulator
|
|
||||||
U8X8_DLY(10),
|
|
||||||
U8X8_CCAA(0x0, 0x03, 0x00, 0x70), // Enable voltage follower
|
|
||||||
U8X8_DLY(10),
|
|
||||||
|
|
||||||
U8X8_CCAA(0x0, 0x23, 0x00, 0x04), // Monochrome mode
|
|
||||||
U8X8_CCAA(0x0, 0x28, 0x00, 0x0c), // Frame Rate Control
|
|
||||||
U8X8_CCAA(0x0, 0x37, 0x00, 0x01), // Frame Rate Control
|
|
||||||
U8X8_CCAA(0x0, 0x0d, 39, 0x00), // X End and X Start
|
|
||||||
|
|
||||||
U8X8_CCAA(0x0, 0x0e, 239, 0x00), // Y End and Y Start
|
|
||||||
|
|
||||||
/* enable LCD (will be done by powersave0) */
|
|
||||||
//U8X8_CCAA(0x0, 0x07, 0x00, 0x01), // Display Control Bit 2: BW, 1: Invert, 0: Display enable
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ist3088_320x240_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 110,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 110,
|
|
||||||
/* reset_pulse_width_ms = */ 10,
|
|
||||||
/* post_reset_wait_ms = */ 10, /**/
|
|
||||||
/* sda_setup_time_ns = */ 110, /* */
|
|
||||||
/* sck_pulse_width_ns = */ 125, /* */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* 250ns cycle, see page 49 of the IST3088 datasheet*/
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* 400KHz, IST8033 das not include a I2C interface */
|
|
||||||
/* data_setup_time_ns = */ 70,
|
|
||||||
/* write_pulse_width_ns = */ 60,
|
|
||||||
/* tile_width = */ 40,
|
|
||||||
/* tile_height = */ 30,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 320,
|
|
||||||
/* pixel_height = */ 240
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ist3088_320x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ist3088_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist3088_320x240_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ist3088_320x240_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ist7920.c
|
|
||||||
|
|
||||||
this is NOT ST7920!
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2019, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist7920_128x128_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x03d), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist7920_128x128_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x03c), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist7920_128x128_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x064), /* Display Ctrl: Bit3: SHL 2:ADC 1:EON, 0:REV */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ist7920_128x128_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x068), /* Display Ctrl: Bit3: SHL 2:ADC 1:EON, 0:REV */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ist7920_128x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 90, /* IST7920 datasheet, page 48 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 90, /* IST7920 datasheet, page 48 */
|
|
||||||
/* reset_pulse_width_ms = */ 10,
|
|
||||||
/* post_reset_wait_ms = */ 20, /* IST7920 Startup Seq.. */
|
|
||||||
/* sda_setup_time_ns = */ 45, /* IST7920 datasheet, page 48 */
|
|
||||||
/* sck_pulse_width_ns = */ 130, /* IST7920 datasheet, page 48 */
|
|
||||||
/* sck_clock_hz = */ 3000000UL, /* IST7920 datasheet: 260ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge (not verified) */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* 400kHz according to IST7920 datasheet */
|
|
||||||
/* data_setup_time_ns = */ 60, /* IST7920 datasheet, page 47 */
|
|
||||||
/* write_pulse_width_ns = */ 150, /* IST7920 datasheet, page 47 */
|
|
||||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 1/128 Duty, 1/10 Bias, 128x128 round display */
|
|
||||||
static const uint8_t u8x8_d_ist7920_128x128_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x076), /* Software Reset */
|
|
||||||
U8X8_DLY(50),
|
|
||||||
U8X8_C(0x03c), /* display off */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_CA(0x090, 128), /* Set Duty */
|
|
||||||
//U8X8_CAA(0x0b2, 0x011, 0x00), /* Set Frame Control */
|
|
||||||
|
|
||||||
U8X8_CA(0x030, 16), /* Set Bias 0: 1/8, 8: 1/9, 16: 1/10, 24: 1/11, 48: 1/12 ... */
|
|
||||||
U8X8_CA(0x031, 0x03f), /* Set voltage generate clock(31H/11H) */
|
|
||||||
//U8X8_CA(0x032, 0x015), /* Temperature compensation */
|
|
||||||
U8X8_CA(0x033, 0x020), /* Power Control */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_CA(0x033, 0x02c), /* Power Control */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_C(0xfd), /* set booster */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_CA(0x033, 0x02f), /* Power Control */
|
|
||||||
U8X8_DLY(200),
|
|
||||||
|
|
||||||
U8X8_C(0x064), /* Display Ctrl: Bit3: SHL 2:ADC 1:EON, 0:REV */
|
|
||||||
|
|
||||||
U8X8_CAA(0x074, 0x000, 0x00f), /* AY Window */
|
|
||||||
U8X8_CAA(0x075, 0x000, 0x07f), /* AX Window */
|
|
||||||
|
|
||||||
U8X8_CA(0x040, 64), /* Start line at 64 */
|
|
||||||
|
|
||||||
U8X8_CA(0x0b1, 100), /* electronic volume */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ist7920_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ist7920_128x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ist7920_128x128_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b1 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* st7920 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0c0 );
|
|
||||||
u8x8_cad_SendArg(u8x8, x );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x001 );
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos) );
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
c *= 8;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,344 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ks0108.c
|
|
||||||
|
|
||||||
The classic 5V LCD
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ks0108_init_seq[] = {
|
|
||||||
U8X8_C(0x0c0), /* start at the top */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ks0108_powersave0_seq[] = {
|
|
||||||
U8X8_C(0x03f), /* display on */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ks0108_powersave1_seq[] = {
|
|
||||||
U8X8_C(0x03e), /* display off */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct u8x8_ks0108_vars
|
|
||||||
{
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t x;
|
|
||||||
uint8_t c;
|
|
||||||
uint8_t arg_int;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void u8x8_ks0108_out(u8x8_t *u8x8, struct u8x8_ks0108_vars *v, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t cnt;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x040 | ((v->x << 3) & 63) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
while( v->arg_int > 0 )
|
|
||||||
{
|
|
||||||
/* calculate tiles to next boundary (end or chip limit) */
|
|
||||||
cnt = v->x;
|
|
||||||
cnt += 8;
|
|
||||||
cnt &= 0x0f8;
|
|
||||||
cnt -= v->x;
|
|
||||||
|
|
||||||
if ( cnt > v->c )
|
|
||||||
cnt = v->c;
|
|
||||||
|
|
||||||
/* of cours we still could use cnt=1 here... */
|
|
||||||
/* but setting cnt to 1 is not very efficient */
|
|
||||||
//cnt = 1;
|
|
||||||
|
|
||||||
v->x +=cnt;
|
|
||||||
v->c-=cnt;
|
|
||||||
cnt<<=3;
|
|
||||||
u8x8_cad_SendData(u8x8, cnt, v->ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
v->ptr += cnt;
|
|
||||||
|
|
||||||
if ( v->c == 0 )
|
|
||||||
{
|
|
||||||
v->ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
v->c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
v->arg_int--;
|
|
||||||
}
|
|
||||||
if ( ((v->x) & 7) == 0 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ks0108_128x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* KS0108: Not used */
|
|
||||||
/* chip_disable_level = */ 1, /* KS0108: Not used */
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 5,
|
|
||||||
/* post_reset_wait_ms = */ 6, /* could be faster for the KS0108 */
|
|
||||||
/* sda_setup_time_ns = */ 12,
|
|
||||||
/* sck_pulse_width_ns = */ 75, /* KS0108: Not used */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* KS0108: Not used */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108: Not used */
|
|
||||||
/* data_setup_time_ns = */ 200,
|
|
||||||
/* write_pulse_width_ns = */ 250, /* KS0108: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
|
||||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ks0108_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
struct u8x8_ks0108_vars v;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ks0108_128x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// The KS0108 can not mirror the cols and rows, use U8g2 for rotation
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
// break;
|
|
||||||
// The KS0108 has no internal contrast command
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
// break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
|
|
||||||
v.ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
v.x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
v.c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
v.arg_int = arg_int;
|
|
||||||
|
|
||||||
|
|
||||||
if ( v.x < 8 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
}
|
|
||||||
if ( v.x < 16 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 2, NULL);
|
|
||||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
}
|
|
||||||
//if ( v.x < 24 )
|
|
||||||
//{
|
|
||||||
//u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 4, NULL);
|
|
||||||
//u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
|
||||||
//u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
//}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ks0108_192x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* KS0108: Not used */
|
|
||||||
/* chip_disable_level = */ 1, /* KS0108: Not used */
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 5,
|
|
||||||
/* post_reset_wait_ms = */ 6, /* could be faster for the KS0108 */
|
|
||||||
/* sda_setup_time_ns = */ 12,
|
|
||||||
/* sck_pulse_width_ns = */ 75, /* KS0108: Not used */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* KS0108: Not used */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* KS0108: Not used */
|
|
||||||
/* data_setup_time_ns = */ 200,
|
|
||||||
/* write_pulse_width_ns = */ 250, /* KS0108: actially 450 ns, but additional 200 ns are added by the byte transfer function */
|
|
||||||
/* tile_width = */ 24, /* width of 24*8=192 pixel */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 192,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* east rising (buydisplay.com) ERM19264 */
|
|
||||||
/* left: 011, middle: 101, right: 110, no chip select: 111 */
|
|
||||||
uint8_t u8x8_d_ks0108_erm19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
struct u8x8_ks0108_vars v;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ks0108_192x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave0_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ks0108_powersave1_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// The KS0108 can not mirror the cols and rows, use U8g2 for rotation
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
// break;
|
|
||||||
// The KS0108 has no internal contrast command
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
// break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
|
|
||||||
v.ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
v.x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
v.c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
v.arg_int = arg_int;
|
|
||||||
|
|
||||||
/*
|
|
||||||
3-bit CS value:
|
|
||||||
In u8x8_byte_set_ks0108_cs(u8x8_t *u8x8, uint8_t arg) the lowest
|
|
||||||
bit is assigned to CS and highest bit if the 3-bit value to CS2
|
|
||||||
|
|
||||||
CS: left part of the display --> 6
|
|
||||||
CS1: middle part --> 5
|
|
||||||
CS2: right part of the display --> 3
|
|
||||||
|
|
||||||
Reference: https://github.com/olikraus/u8g2/issues/631
|
|
||||||
*/
|
|
||||||
if ( v.x < 8 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 6, NULL); // 3-->6, issue 631
|
|
||||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
}
|
|
||||||
if ( v.x < 16 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 5, NULL);
|
|
||||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
}
|
|
||||||
if ( v.x < 24 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 3, NULL); // 6-->3, // issue 631
|
|
||||||
u8x8_ks0108_out(u8x8, &v, arg_ptr);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 7, NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,542 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_lc7981.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* no powersave mode for the LC7981 */
|
|
||||||
// static const uint8_t u8x8_d_lc7981_powersave0_seq[] = {
|
|
||||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
// U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
// U8X8_END() /* end of sequence */
|
|
||||||
// };
|
|
||||||
|
|
||||||
// static const uint8_t u8x8_d_lc7981_powersave1_seq[] = {
|
|
||||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
// U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
// U8X8_END() /* end of sequence */
|
|
||||||
// };
|
|
||||||
|
|
||||||
/* no hardware flip for the LC7981 */
|
|
||||||
// static const uint8_t u8x8_d_lc7981_flip0_seq[] = {
|
|
||||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
// U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
// U8X8_END() /* end of sequence */
|
|
||||||
// };
|
|
||||||
|
|
||||||
// static const uint8_t u8x8_d_lc7981_flip1_seq[] = {
|
|
||||||
// U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
// U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
// U8X8_END() /* end of sequence */
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
/* http://graphics.stanford.edu/~seander/bithacks.html */
|
|
||||||
static uint8_t reverse_byte(uint8_t v)
|
|
||||||
{
|
|
||||||
// if ( v != 0 && v != 255 ) does not help much
|
|
||||||
{
|
|
||||||
// swap odd and even bits
|
|
||||||
v = ((v >> 1) & 0x055) | ((v & 0x055) << 1);
|
|
||||||
// swap consecutive pairs
|
|
||||||
v = ((v >> 2) & 0x033) | ((v & 0x033) << 2);
|
|
||||||
// swap nibbles ...
|
|
||||||
v = ((v >> 4) & 0x00F) | ((v & 0x00F) << 4);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_lc7981_common(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t c, i, j;
|
|
||||||
uint16_t y;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
y*=8;
|
|
||||||
y*= u8x8->display_info->tile_width;
|
|
||||||
/* x = ((u8x8_tile_t *)arg_ptr)->x_pos; x is ignored... no u8x8 support */
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
/*
|
|
||||||
Tile structure is reused here for the t6963, however u8x8 is not supported
|
|
||||||
tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles)
|
|
||||||
Buffer is expected to have 8 lines of code fitting to the t6963 internal memory
|
|
||||||
"cnt" includes the number of horizontal bytes. width is equal to cnt*8
|
|
||||||
|
|
||||||
x is assumed to be zero
|
|
||||||
|
|
||||||
TODO: Consider arg_int, however arg_int is not used by u8g2
|
|
||||||
*/
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0a ); /* display ram (cursor) address low byte */
|
|
||||||
u8x8_cad_SendArg(u8x8, y&255);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b ); /* display ram (cursor) address high byte */
|
|
||||||
u8x8_cad_SendArg(u8x8, y>>8);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0c ); /* write start */
|
|
||||||
/*
|
|
||||||
The LC7981 has the MSB at the right position, which is exactly the opposite to the T6963.
|
|
||||||
Instead of writing a third hvline procedure for this device, we just revert the bytes before
|
|
||||||
transmit. This is slow because:
|
|
||||||
- the bit reverse itself
|
|
||||||
- the single byte transfer
|
|
||||||
The one byte is transmitted via SendArg, which is ok, because CAD = 100
|
|
||||||
*/
|
|
||||||
for( j = 0; j < c; j++ )
|
|
||||||
u8x8_cad_SendArg(u8x8, reverse_byte(*ptr++));
|
|
||||||
|
|
||||||
//u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
|
|
||||||
//ptr += u8x8->display_info->tile_width;
|
|
||||||
|
|
||||||
y += u8x8->display_info->tile_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
/* handled in the calling procedure
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_128x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* power save is not there...
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_powersave1_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* hardware flip not is not available
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
/* no contrast setting :-(
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int );
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* LC7981 160x80 LCD*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_lc7981_160x80_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* from here... */
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 10,
|
|
||||||
/* sda_setup_time_ns = */ 30,
|
|
||||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
|
||||||
|
|
||||||
/* data_setup_time_ns = */ 220,
|
|
||||||
/* write_pulse_width_ns = */ 20,
|
|
||||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
|
||||||
/* tile_height = */ 10,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 160,
|
|
||||||
/* pixel_height = */ 80
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_lc7981_160x80_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_DLY(50),
|
|
||||||
|
|
||||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
|
||||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
|
||||||
U8X8_CA(0x02, 160/8-1), /* number of chars/byte width of the screen */
|
|
||||||
U8X8_CA(0x03, 0x50), /* time division: 50 (1/80 duty cycle) */
|
|
||||||
U8X8_CA(0x08, 0x00), /* display start low */
|
|
||||||
U8X8_CA(0x09, 0x00), /* display start high */
|
|
||||||
|
|
||||||
U8X8_DLY(10),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_lc7981_160x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_160x80_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_160x80_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* LC7981 160x160 LCD*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_lc7981_160x160_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* from here... */
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 10,
|
|
||||||
/* sda_setup_time_ns = */ 30,
|
|
||||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
|
||||||
|
|
||||||
/* data_setup_time_ns = */ 220,
|
|
||||||
/* write_pulse_width_ns = */ 20,
|
|
||||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
|
||||||
/* tile_height = */ 20,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 160,
|
|
||||||
/* pixel_height = */ 160
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_lc7981_160x160_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_DLY(50),
|
|
||||||
|
|
||||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
|
||||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
|
||||||
U8X8_CA(0x02, 160/8-1), /* number of chars/byte width of the screen */
|
|
||||||
U8X8_CA(0x03, 159), /* time division */
|
|
||||||
U8X8_CA(0x08, 0x00), /* display start low */
|
|
||||||
U8X8_CA(0x09, 0x00), /* display start high */
|
|
||||||
|
|
||||||
U8X8_DLY(10),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_lc7981_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_160x160_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_160x160_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* LC7981 240x128 LCD*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_lc7981_240x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* from here... */
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 10,
|
|
||||||
/* sda_setup_time_ns = */ 30,
|
|
||||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
|
||||||
|
|
||||||
/* data_setup_time_ns = */ 220,
|
|
||||||
/* write_pulse_width_ns = */ 20,
|
|
||||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 240,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_lc7981_240x128_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_DLY(50),
|
|
||||||
|
|
||||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
|
||||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
|
||||||
U8X8_CA(0x02, 240/8-1), /* number of chars/byte width of the screen */
|
|
||||||
U8X8_CA(0x03, 16*8-1), /* time division */
|
|
||||||
U8X8_CA(0x08, 0x00), /* display start low */
|
|
||||||
U8X8_CA(0x09, 0x00), /* display start high */
|
|
||||||
|
|
||||||
U8X8_DLY(10),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_lc7981_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_240x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_240x128_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* LC7981 240x64 LCD*/
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/642 */
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_lc7981_240x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* from here... */
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 10,
|
|
||||||
/* sda_setup_time_ns = */ 30,
|
|
||||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
|
||||||
|
|
||||||
/* data_setup_time_ns = */ 220,
|
|
||||||
/* write_pulse_width_ns = */ 20,
|
|
||||||
/* tile_width = */ 30, /* width of 30*8=240 pixel */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 240,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_lc7981_240x64_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_DLY(50),
|
|
||||||
|
|
||||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
|
||||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
|
||||||
U8X8_CA(0x02, 240/8-1), /* number of chars/byte width of the screen */
|
|
||||||
U8X8_CA(0x03, 0x7f), /* time division */
|
|
||||||
U8X8_CA(0x08, 0x00), /* display start low */
|
|
||||||
U8X8_CA(0x09, 0x00), /* display start high */
|
|
||||||
|
|
||||||
U8X8_DLY(10),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_lc7981_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_240x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_240x64_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* LC7981 128x128 LCD, https://github.com/olikraus/u8g2/issues/1913*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_lc7981_128x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* from here... */
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 10,
|
|
||||||
/* sda_setup_time_ns = */ 30,
|
|
||||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* ... to here, values are ignored, because this is a parallel interface only */
|
|
||||||
|
|
||||||
/* data_setup_time_ns = */ 220,
|
|
||||||
/* write_pulse_width_ns = */ 20,
|
|
||||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_lc7981_128x128_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_DLY(50),
|
|
||||||
|
|
||||||
U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
|
|
||||||
U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
|
|
||||||
U8X8_CA(0x02, 128/8-1), /* number of chars/byte width of the screen */
|
|
||||||
U8X8_CA(0x03, 128), /* time division, issue https://github.com/olikraus/u8g2/issues/1581 */
|
|
||||||
U8X8_CA(0x08, 0x00), /* display start low */
|
|
||||||
U8X8_CA(0x09, 0x00), /* display start high */
|
|
||||||
|
|
||||||
U8X8_DLY(10),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_lc7981_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_128x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_128x128_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,457 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ld7032_60x32.c
|
|
||||||
Note: Flip Mode is NOT supported
|
|
||||||
|
|
||||||
Also contains 128x36 OLED variant
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2023, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* testboard U8GLIB_LD7032_60x32 u8g(11, 12, 9, 10, 8); // SPI Com: SCK = 11, MOSI = 12, CS = 9, A0 = 10, RST = 8 (SW SPI Nano Board) */
|
|
||||||
/* http://www.seeedstudio.com/document/pdf/0.5OLED%20SPEC.pdf */
|
|
||||||
#ifdef OBSOLETE
|
|
||||||
static const uint8_t u8x8_d_ld7032_60x32_init_seq_old[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
//U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
|
|
||||||
U8X8_CA(0x014, 0x000), /* Stand-by OFF */
|
|
||||||
U8X8_CA(0x01a, 0x004), /* Dot Matrix Frame Rate, special value for this OLED from manual*/
|
|
||||||
U8X8_CA(0x01d, 0x000), /* Graphics Memory Writing Direction: reset default (right down, horizontal) */
|
|
||||||
U8X8_CA(0x009, 0x000), /* Display Direction: reset default (x,y: min --> max) */
|
|
||||||
U8X8_CAA(0x030, 0x000, 0x03b), /* Display Size X, Column Start - End*/
|
|
||||||
U8X8_CAA(0x032, 0x000, 0x01f), /* Display Size Y, Row Start - End*/
|
|
||||||
U8X8_CA(0x010, 0x000), /* Peak Pulse Width Set: 0 SCLK */
|
|
||||||
U8X8_CA(0x016, 0x000), /* Peak Pulse Delay Set: 0 SCLK */
|
|
||||||
U8X8_CA(0x012, 0x040), /* Dot Matrix Current Level Set: 0x050 * 1 uA = 80 uA */
|
|
||||||
U8X8_CA(0x018, 0x003), /* Pre-Charge Pulse Width: 3 SCLK */
|
|
||||||
U8X8_CA(0x044, 0x002), /* Pre-Charge Mode: Every Time */
|
|
||||||
U8X8_CA(0x048, 0x003), /* Row overlap timing: Pre-Charge + Peak Delay + Peak boot Timing */
|
|
||||||
U8X8_CA(0x03f, 0x011), /* VCC_R_SEL: ??? */
|
|
||||||
U8X8_CA(0x03d, 0x000), /* VSS selection: 2.8V */
|
|
||||||
//U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* new sequence https://github.com/olikraus/u8g2/issues/865 */
|
|
||||||
static const uint8_t u8x8_d_ld7032_60x32_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_CA(0x02, 0x00), /* Dot Matrix Display OFF */
|
|
||||||
U8X8_CA(0x14, 0x00), /* Stand-by OFF, OSCA Start */
|
|
||||||
U8X8_CA(0x1a, 0x04), /* Dot Matrix Frame Rate, special value for this OLED from manual 4 => 120Hz*/
|
|
||||||
U8X8_CA(0x1d, 0x00), /* Graphics Memory Writing Direction: reset default (right down, horizontal) */
|
|
||||||
U8X8_CA(0x09, 0x00), /* Display Direction: reset default (x,y: min --> max) */
|
|
||||||
U8X8_CAA(0x30, 0x00, 0x3B), /* Display Size X, Column Start - End 0-0x3b(59)*/
|
|
||||||
U8X8_CAA(0x32, 0x00, 0x1F), /* Display Size Y, Row Start - End 0-0x1f(31)*/
|
|
||||||
U8X8_CA(0x34, 0x00), /* Data Reading/Writing Box X start */
|
|
||||||
U8X8_CA(0x35, 0x07), /* Data Reading/Writing Box X end */
|
|
||||||
U8X8_CA(0x36, 0x00), /* Data Reading/Writing Box Y start */
|
|
||||||
U8X8_CA(0x37, 0x1F), /* Data Reading/Writing Box Y end */
|
|
||||||
U8X8_CA(0x38, 0x00), /* Display Start Address X */
|
|
||||||
U8X8_CA(0x39, 0x00), /* Display Start Address Y */
|
|
||||||
U8X8_CA(0x10, 0x00), /* Peak Pulse Width Set: 0 SCLK */
|
|
||||||
U8X8_CA(0x16, 0x00), /* Peak Pulse Delay Set: 0 SCLK */
|
|
||||||
U8X8_CA(0x12, 0x40), /* 0x32, 0x50 or 0x40 Dot Matrix Current Level Set: 0x050 * 1 uA = 80 uA */
|
|
||||||
U8X8_CA(0x18, 0x03), /* Pre-Charge Pulse Width: 3 SCLK */
|
|
||||||
U8X8_CA(0x44, 0x02), /* Pre-Charge Mode: Every Time */
|
|
||||||
U8X8_CA(0x48, 0x03), /* Row overlap timing: Pre-Charge + Peak Delay + Peak boot Timing */
|
|
||||||
U8X8_CA(0x17, 0x00), /* Row Scan */
|
|
||||||
U8X8_CA(0x13, 0x00), /* Row Scan Sequence Setting */
|
|
||||||
U8X8_CA(0x1C, 0x00), /* Data Reverse */
|
|
||||||
U8X8_CA(0x3f, 0x11), /* VCC_R_SEL: Internal Regulator enabled(D4=1) and VCC_R=VCC_C*0.7(D0=1) */
|
|
||||||
U8X8_CA(0x3d, 0x00), /* VSS selection: 2.8V */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ld7032_60x32_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ld7032_60x32_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x002, 0x000), /* Dot Matrix Display ON */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ld7032_60x32_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x009, 0x000), /* Display Direction: reset default (x,y: min --> max) */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ld7032_60x32_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
//U8X8_CA(0x009, 0x002), /* Display Direction: reset default (x,y: min --> max) */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ld7032_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x012 );
|
|
||||||
if ( arg_int > 0x07f ) /* default is 0x040, limit to 0x07f to be on the safe side (hopefully) */
|
|
||||||
arg_int= 0x07f;
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* values from 0x00 to 0x0ff are allowed, bit will all values be safe??? */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x += u8x8->x_offset/8;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x034 );
|
|
||||||
u8x8_cad_SendArg(u8x8, x );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x035 );
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x007 );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x036 );
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)*8 );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x037 );
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x01f );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x008 );
|
|
||||||
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ld7032_60x32_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 15,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 20,
|
|
||||||
/* write_pulse_width_ns = */ 40,
|
|
||||||
/* tile_width = */ 8,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 60,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ld7032_60x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ld7032_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* alternative version, issue #1189 */
|
|
||||||
|
|
||||||
/* new sequence https://github.com/olikraus/u8g2/issues/1189 */
|
|
||||||
static const uint8_t u8x8_d_ld7032_60x32_alt_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_CA(0x02, 0x00),
|
|
||||||
U8X8_CA(0x14, 0x00),
|
|
||||||
U8X8_CA(0x1A, 0x05),
|
|
||||||
U8X8_CA(0x1D, 0x00),
|
|
||||||
U8X8_CA(0x09, 0x00),
|
|
||||||
U8X8_CAA(0x30, 0x00, 0x3F),
|
|
||||||
U8X8_CAA(0x32, 0x08, 0x27),
|
|
||||||
U8X8_CA(0x34, 0x00),
|
|
||||||
U8X8_CA(0x35, 0x07),
|
|
||||||
U8X8_CA(0x36, 0x08),
|
|
||||||
U8X8_CA(0x37, 0x27),
|
|
||||||
U8X8_CA(0x38, 0x00),
|
|
||||||
U8X8_CA(0x39, 0x20),
|
|
||||||
U8X8_CA(0x10, 0x05),
|
|
||||||
U8X8_CA(0x16, 0x00),
|
|
||||||
U8X8_CA(0x18, 0x08),
|
|
||||||
U8X8_CA(0x12, 0x2F),
|
|
||||||
U8X8_CA(0x3D, 0x01),
|
|
||||||
U8X8_CA(0x3F, 0x10),
|
|
||||||
U8X8_CA(0x44, 0x02),
|
|
||||||
U8X8_CA(0x48, 0x03),
|
|
||||||
U8X8_CA(0x17, 0x00),
|
|
||||||
U8X8_CA(0x13, 0x01),
|
|
||||||
U8X8_CA(0x3F, 0x11), // internal regulator enabled, vcc_c * 0.7
|
|
||||||
U8X8_CA(0x3D, 0x00),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ld7032_60x32_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( msg ==U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_alt_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return u8x8_d_ld7032_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==========================================*/
|
|
||||||
/*
|
|
||||||
128x36 Flip Mode is NOT supported
|
|
||||||
see https://github.com/olikraus/u8g2/issues/2135
|
|
||||||
*/
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ld7032_128_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x012 );
|
|
||||||
if ( arg_int > 0x07f ) /* default is 0x040, limit to 0x07f to be on the safe side (hopefully) */
|
|
||||||
arg_int= 0x07f;
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* values from 0x00 to 0x0ff are allowed, bit will all values be safe??? */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x += u8x8->x_offset/8;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x034 );
|
|
||||||
u8x8_cad_SendArg(u8x8, x );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x035 );
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x00f );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x036 );
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)*8 );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x037 );
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x027 );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x008 );
|
|
||||||
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ld7032_128x36_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 15,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 20,
|
|
||||||
/* write_pulse_width_ns = */ 40,
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 5,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 36
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ld7032_128x36_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_CA(0x14, 0x00), // standby mode
|
|
||||||
U8X8_CA(0x02, 0x00), // display off
|
|
||||||
U8X8_CA(0x1A, 0x05), // frame frequency
|
|
||||||
U8X8_CA(0x1D, 0x00), // data write direction (datasheet: 1d 0b
|
|
||||||
U8X8_CA(0x09, 0x00), // scan direction
|
|
||||||
U8X8_CAA(0x30, 0x00, 0x7F), // column driver active range
|
|
||||||
U8X8_CAA(0x32, 0x04, 0x27), // row driver active range
|
|
||||||
U8X8_CA(0x34, 0x00), // start line
|
|
||||||
U8X8_CA(0x35, 0x0f), // end line
|
|
||||||
U8X8_CA(0x36, 0x04), // row start line
|
|
||||||
U8X8_CA(0x37, 0x27), // row end line
|
|
||||||
U8X8_CA(0x38, 0x00), // x disp start, default 0
|
|
||||||
U8X8_CA(0x39, 0x00), // y disp start, default 0
|
|
||||||
U8X8_CA(0x10, 0x1f), // peak pulse width
|
|
||||||
U8X8_CA(0x16, 0x05), // pulse delay width
|
|
||||||
U8X8_CA(0x18, 0x1f), // pre charge width
|
|
||||||
U8X8_CA(0x12, 0x3F), // contrast control
|
|
||||||
U8X8_CA(0x44, 0x02), // PreC select, default: 2
|
|
||||||
//U8X8_CA(0x48, 0x00), // row overlap, default: 0 (was 3)
|
|
||||||
U8X8_CA(0x17, 0x00), // row scan, default: 0
|
|
||||||
U8X8_CA(0x13, 0x01), // scan mode sequence
|
|
||||||
//U8X8_CA(0x3F, 0x11), // VCC R Selection, default: 0 (int. reg. disabled, vcc_c*0.8)
|
|
||||||
U8X8_CA(0x3D, 0x01), // vdd selection 0: 2.8V-3.5, 1: 1.8V (1.65-2.5V)
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ld7032_128x36(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_128x36_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( msg ==U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_128x36_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return u8x8_d_ld7032_128_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
@@ -1,276 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ls013b7dh03.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
The LS013B7DH02 is a simple display and controller
|
|
||||||
--> no support for contrast adjustment, flip and power down.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
#define SWAP8(a) ((((a) & 0x80) >> 7) | (((a) & 0x40) >> 5) | (((a) & 0x20) >> 3) | (((a) & 0x10) >> 1) | (((a) & 0x08) << 1) | (((a) & 0x04) << 3) | (((a) & 0x02) << 5) | (((a) & 0x01) << 7))
|
|
||||||
|
|
||||||
#define LS013B7DH03_CMD_UPDATE (0x01)
|
|
||||||
#define LS013B7DH03_CMD_ALL_CLEAR (0x04)
|
|
||||||
#define LS013B7DH03_VAL_TRAILER (0x00)
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ls013b7dh03_128x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 1,
|
|
||||||
/* chip_disable_level = */ 0,
|
|
||||||
/* post_chip_enable_wait_ns = */ 50,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 50,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
|
||||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 100,
|
|
||||||
/* write_pulse_width_ns = */ 100,
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ls013b7dh03_128x128(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t y, c, i;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls013b7dh03_128x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
|
|
||||||
/* clear screen */
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_ALL_CLEAR) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
/* not available for the ls013b7dh03 */
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
/* each tile is 8 lines, with the data starting at the left edge */
|
|
||||||
y = ((((u8x8_tile_t *)arg_ptr)->y_pos) * 8) + 1;
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
|
|
||||||
/* send data mode byte */
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_UPDATE) );
|
|
||||||
|
|
||||||
/* send 8 lines of 16 bytes (=128 pixels) */
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendCmd(u8x8, SWAP8(y + i) );
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr);
|
|
||||||
u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
|
|
||||||
|
|
||||||
ptr += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* finish with a trailing byte */
|
|
||||||
u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===============================================*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ls027b7dh01_400x240_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 1,
|
|
||||||
/* chip_disable_level = */ 0,
|
|
||||||
/* post_chip_enable_wait_ns = */ 50,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 50,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
|
||||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 100,
|
|
||||||
/* write_pulse_width_ns = */ 100,
|
|
||||||
/* tile_width = */ 50,
|
|
||||||
/* tile_height = */ 30,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 400,
|
|
||||||
/* pixel_height = */ 240
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ls027b7dh01_400x240(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls027b7dh01_400x240_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===============================================*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ls027b7dh01_m0_400x240_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 1,
|
|
||||||
/* chip_disable_level = */ 0,
|
|
||||||
/* post_chip_enable_wait_ns = */ 50,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 50,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
|
||||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active low, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 100,
|
|
||||||
/* write_pulse_width_ns = */ 100,
|
|
||||||
/* tile_width = */ 50,
|
|
||||||
/* tile_height = */ 30,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 400,
|
|
||||||
/* pixel_height = */ 240
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ls027b7dh01_m0_400x240(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls027b7dh01_m0_400x240_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===============================================*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ls013b7dh05_144x168_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 1,
|
|
||||||
/* chip_disable_level = */ 0,
|
|
||||||
/* post_chip_enable_wait_ns = */ 50,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 50,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
|
||||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 100,
|
|
||||||
/* write_pulse_width_ns = */ 100,
|
|
||||||
/* tile_width = */ 18,
|
|
||||||
/* tile_height = */ 21,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 144,
|
|
||||||
/* pixel_height = */ 168
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ls013b7dh05_144x168(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls013b7dh05_144x168_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===============================================*/
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/2210 */
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ls011b7dh03_160x68_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 1,
|
|
||||||
/* chip_disable_level = */ 0,
|
|
||||||
/* post_chip_enable_wait_ns = */ 50,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 50,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
|
|
||||||
/* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* changed from 2 to 0 (https://github.com/olikraus/u8g2/issues/1771) */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 100,
|
|
||||||
/* write_pulse_width_ns = */ 100,
|
|
||||||
/* tile_width = */ 20,
|
|
||||||
/* tile_height = */ 9,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 160,
|
|
||||||
/* pixel_height = */ 68
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ls011b7dh03_160x68(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls011b7dh03_160x68_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_ls013b7dh03_128x128(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,459 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_max7219.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2017, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_max7219_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
|
|
||||||
//U8X8_CA(12, 0), /* shutdown */
|
|
||||||
|
|
||||||
//U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_max7219_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_max7219_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_max7219_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t c, j, i;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* not supported by MAX7219
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
for( i = 0; i < u8x8->display_info->tile_width; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendCmd(u8x8, 10 ); /* brightness */
|
|
||||||
u8x8_cad_SendArg(u8x8, (arg_int>>4) ); /* 0..15 for contrast */
|
|
||||||
}
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
/* transfer always has to start at x pos 0 (u8x8 is not supported) */
|
|
||||||
/* also y pos has to be 0 */
|
|
||||||
/* arg_int is ignored */
|
|
||||||
//x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
for( j = 0; j < c; j++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendCmd(u8x8, i+1); /* commands 1..8 select the byte */
|
|
||||||
u8x8_cad_SendArg(u8x8, *ptr );
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_max7219_32x8_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 100,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 100,
|
|
||||||
/* sck_pulse_width_ns = */ 100,
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 4,
|
|
||||||
/* tile_height = */ 1,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 32,
|
|
||||||
/* pixel_height = */ 8
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_max7219_32x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_32x8_display_info);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_max7219_16x16_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 100,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 100,
|
|
||||||
/* sck_pulse_width_ns = */ 100,
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 2,
|
|
||||||
/* tile_height = */ 2,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 16,
|
|
||||||
/* pixel_height = */ 16
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Multiple page rows are not supported, so 16x16 will not work.
|
|
||||||
Due to the hardware structure of such displays all tiles of the display
|
|
||||||
must be written at once.
|
|
||||||
This is not possible with the current u8g2 structure.
|
|
||||||
So u8x8_d_max7219_16x16 will not work.
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t u8x8_d_max7219_16x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_16x16_display_info);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==============================*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_max7219_8x8_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 100,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 100,
|
|
||||||
/* sck_pulse_width_ns = */ 100,
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 1,
|
|
||||||
/* tile_height = */ 1,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 8,
|
|
||||||
/* pixel_height = */ 8
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_max7219_8x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_8x8_display_info);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*==============================*/
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_max7219_8_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_CA(15, 0), /* test mode off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_CA(12, 0), /* */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_CA(9, 0), /* decode mode: graphics */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_CA(10, 10), /* medium high intensity */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
|
|
||||||
|
|
||||||
//U8X8_CA(12, 0), /* shutdown */
|
|
||||||
|
|
||||||
//U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_max7219_8_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_CA(12, 1), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_max7219_8_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_CA(12, 0), /* shutdown */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_max7219_64x8_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 100,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 100,
|
|
||||||
/* sck_pulse_width_ns = */ 100,
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 8,
|
|
||||||
/* tile_height = */ 1,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 64,
|
|
||||||
/* pixel_height = */ 8
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_max7219_64x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY :
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_64x8_display_info);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_8_init_seq);
|
|
||||||
return 1;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_8_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_8_powersave1_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_pcd8544_84x48.c (so called "Nokia 5110" displays)
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_pcd8544_84x48_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x021), /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
|
||||||
U8X8_C(0x006), /* temp. control: b10 = 2 */
|
|
||||||
U8X8_C(0x013), /* bias system 1:48 */
|
|
||||||
U8X8_C(0x0c0), /* medium Vop */
|
|
||||||
|
|
||||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
U8X8_C(0x008), /* blank */
|
|
||||||
U8X8_C(0x024), /* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_pcd8544_84x48_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
U8X8_C(0x00c), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_pcd8544_84x48_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
U8X8_C(0x008), /* blank */
|
|
||||||
U8X8_C(0x024), /* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_pcd8544_84x48_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 5,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 5,
|
|
||||||
/* reset_pulse_width_ms = */ 2,
|
|
||||||
/* post_reset_wait_ms = */ 2,
|
|
||||||
/* sda_setup_time_ns = */ 12,
|
|
||||||
/* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 30,
|
|
||||||
/* write_pulse_width_ns = */ 40,
|
|
||||||
/* tile_width = */ 11, /* width of 11*8=88 pixel */
|
|
||||||
/* tile_height = */ 6,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 84,
|
|
||||||
/* pixel_height = */ 48
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_pcd8544_84x48(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcd8544_84x48_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_powersave1_seq);
|
|
||||||
break;
|
|
||||||
// case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
// break; NOT SUPPORTED
|
|
||||||
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x080 | (arg_int >> 1) );
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x080 | (x) ); /* set X address */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x040 | (((u8x8_tile_t *)arg_ptr)->y_pos) ); /* set Y address */
|
|
||||||
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
c *= 8;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if ( c + x > 84u )
|
|
||||||
{
|
|
||||||
if ( x >= 84u )
|
|
||||||
break;
|
|
||||||
c = 84u;
|
|
||||||
c -= x;
|
|
||||||
}
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
x += c;
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,331 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_pcf8812.c
|
|
||||||
|
|
||||||
pcf8812: 65x102
|
|
||||||
pcf8814: 65x96
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2017, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_pcf8812_96x65_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
U8X8_C(0x008), /* blank display */
|
|
||||||
|
|
||||||
U8X8_C(0x021), /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
|
||||||
U8X8_C(0x006), /* temp. control: b10 = 2 */
|
|
||||||
U8X8_C(0x013), /* bias system, 0x010..0x07 1:48 */
|
|
||||||
U8X8_C(0x09f), /* contrast setting, 0..127 */
|
|
||||||
//U8X8_CA(0x020 | 2, 0x080 | 0), /* contrast setting, pcf8814 */
|
|
||||||
|
|
||||||
U8X8_C(0x024), /* deactivate chip (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_pcf8812_101x64_init_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x21), // PowerON, ExtCommandSet
|
|
||||||
U8X8_C(0x09), // Internal HV-gen x3
|
|
||||||
U8X8_C(0xB7), // Set Vop
|
|
||||||
U8X8_C(0x16), // Bias n=2 //15
|
|
||||||
U8X8_C(0x06), // Temperature coeff 2
|
|
||||||
U8X8_C(0x20), // StandartCommandSet
|
|
||||||
U8X8_C(0x0C), // normal mode, display non-inverted
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_pcf8812_96x65_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x020), /* power on */
|
|
||||||
U8X8_C(0x00c), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_pcf8812_96x65_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x020), /* power on */
|
|
||||||
U8X8_C(0x008), /* blank display */
|
|
||||||
U8X8_C(0x024), /* power down */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_pcf8812_96x65_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave1_seq);
|
|
||||||
break;
|
|
||||||
/*
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
|
|
||||||
u8x8_cad_SendArg(u8x8, (arg_int>>1)|0x80 ); /* 0..127 for contrast */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x080 | x);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x040 | ((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_pcf8812_101x64_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_101x64_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave1_seq);
|
|
||||||
break;
|
|
||||||
/*
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
|
|
||||||
u8x8_cad_SendArg(u8x8, (arg_int>>1)|0x80 ); /* 0..127 for contrast */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x080 | x);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x040 | ((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_pcf8812_96x65_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 100,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 100,
|
|
||||||
/* sck_pulse_width_ns = */ 100,
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 12,
|
|
||||||
/* tile_height = */ 9,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 96,
|
|
||||||
/* pixel_height = */ 65
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_pcf8812_96x65(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_pcf8812_96x65_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/2421 */
|
|
||||||
static const u8x8_display_info_t u8x8_pcf8812_101x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 100,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 100,
|
|
||||||
/* sck_pulse_width_ns = */ 100,
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 13,
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 101,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_pcf8812_101x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_101x64_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_101x64_init_seq);
|
|
||||||
}
|
|
||||||
return u8x8_d_pcf8812_101x64_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_pcf8814_hc1230.c
|
|
||||||
|
|
||||||
pcf8814: 65x96
|
|
||||||
hx1230: 68x96
|
|
||||||
|
|
||||||
pcf8814 and hc1230 are almost identical.
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2017, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hx1230_96x68_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x020), /* power off */
|
|
||||||
U8X8_C(0x080), /* contrast setting, 0..31, set to 0 */
|
|
||||||
U8X8_C(0x0a6), /* not inverted display */
|
|
||||||
U8X8_C(0x0a4), /* normal display mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a0), /* */
|
|
||||||
U8X8_C(0x0c0), /* */
|
|
||||||
|
|
||||||
U8X8_C(0x040), /* start at scanline 0 */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hx1230_96x68_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x02f), /* power on */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hx1230_96x68_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x0a5), /* All pixels on = powersave */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hx1230_96x68_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* */
|
|
||||||
U8X8_C(0x0c0), /* */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_hx1230_96x68_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* */
|
|
||||||
U8X8_C(0x0c8), /* */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_hx1230_96x68_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hx1230_96x68_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, (arg_int>>3)|0x80 ); /* 0..31 for contrast */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, x&15);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | ((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_hx1230_96x68_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 100,
|
|
||||||
/* reset_pulse_width_ms = */ 100,
|
|
||||||
/* post_reset_wait_ms = */ 100,
|
|
||||||
/* sda_setup_time_ns = */ 100,
|
|
||||||
/* sck_pulse_width_ns = */ 100,
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150,
|
|
||||||
/* tile_width = */ 12,
|
|
||||||
/* tile_height = */ 9,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 96,
|
|
||||||
/* pixel_height = */ 68
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_hx1230_96x68(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hx1230_96x68_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_hx1230_96x68_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,474 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_s1d15300.c
|
|
||||||
|
|
||||||
WARNING: As of today, flip mode 1 doesn't seem to work (see issue 2063)
|
|
||||||
|
|
||||||
Created as a copy of u8x8_d_st7565.c, see https://github.com/olikraus/u8g2/issues/2063
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2022, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15300_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a4), /* all pixel off, see datasheet for the s1d15300 */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15300_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x0a5), /* enter powersafe, see datasheet for the s1d15300 */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15300_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15300_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15300_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
c *= 8;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
/*
|
|
||||||
The following if condition checks the hardware limits of the st7565
|
|
||||||
controller: It is not allowed to write beyond the display limits.
|
|
||||||
This is in fact an issue within flip mode.
|
|
||||||
*/
|
|
||||||
if ( c + x > 132u )
|
|
||||||
{
|
|
||||||
c = 132u;
|
|
||||||
c -= x;
|
|
||||||
}
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_powersave1_seq);
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x080 | (arg_int >> 3) ); /* s1d15300 has only 5 bits for contrast */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* LM6023, S1D15300 controller, issue 2063 */
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_s1d15300_lm6023_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 250, /* */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120, /* */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 1,
|
|
||||||
/* sda_setup_time_ns = */ 200, /* */
|
|
||||||
/* sck_pulse_width_ns = */ 200, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 200, /* st7565 datasheet, table 24, tds8 */
|
|
||||||
/* write_pulse_width_ns = */ 200, /* st7565 datasheet, table 24, tcclw */
|
|
||||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 4,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15300_lm6023_init_seq[] = {
|
|
||||||
|
|
||||||
#ifdef OBSOLETE
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0e2), /* soft reset */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* ADC set to reverse */
|
|
||||||
U8X8_C(0x0c0), /* common output mode */
|
|
||||||
// Flipmode
|
|
||||||
//U8X8_C(0x0a0), /* ADC set to reverse */
|
|
||||||
//U8X8_C(0x0c8), /* common output mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
|
|
||||||
U8X8_C(0x0a2), /* LCD bias 1/9 */
|
|
||||||
U8X8_C(0x02f), /* all power control circuits on */
|
|
||||||
U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */
|
|
||||||
U8X8_C(0x025), /* set V0 voltage resistor ratio to large, issue 1678: changed from 0x23 to 0x25 */
|
|
||||||
U8X8_CA(0x081, 170), /* set contrast, contrast value NHD C12864, see issue 186, increased contrast to 180 (issue 219), reduced to 170 (issue 1678) */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0e2), /* soft reset */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_C(0x0a0), /* ADC set to normal */
|
|
||||||
U8X8_C(0x0a6), /* Display normal */
|
|
||||||
U8X8_C(0x0a4), /* all point normal */
|
|
||||||
|
|
||||||
U8X8_C(0x0a2), /* LCD bias 1/8 */
|
|
||||||
U8X8_C(0x0c0), /* common output mode */
|
|
||||||
U8X8_C(0x02f), /* all power control circuits on */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x090), /* set contrast */
|
|
||||||
//U8X8_C(0x0af), /* display on */
|
|
||||||
|
|
||||||
U8X8_C(0x0b0), /* set page address */
|
|
||||||
U8X8_C(0x01f), /* set column address upper */
|
|
||||||
U8X8_C(0x000), /* set column address lower */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15300_lm6023(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_s1d15300_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15300_lm6023_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_lm6023_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/2377 */
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_s1d15300_97x32_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 250, /* */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120, /* */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 1,
|
|
||||||
/* sda_setup_time_ns = */ 200, /* */
|
|
||||||
/* sck_pulse_width_ns = */ 200, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 200, /* st7565 datasheet, table 24, tds8 */
|
|
||||||
/* write_pulse_width_ns = */ 200, /* st7565 datasheet, table 24, tcclw */
|
|
||||||
/* tile_width = */ 13, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 97,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_s1d15300_100x32_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 250, /* */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120, /* */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 1,
|
|
||||||
/* sda_setup_time_ns = */ 200, /* */
|
|
||||||
/* sck_pulse_width_ns = */ 200, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 200, /* st7565 datasheet, table 24, tds8 */
|
|
||||||
/* write_pulse_width_ns = */ 200, /* st7565 datasheet, table 24, tcclw */
|
|
||||||
/* tile_width = */ 13, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 100,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_s1d15300_100x32i_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 1,
|
|
||||||
/* chip_disable_level = */ 0,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 250, /* */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120, /* */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 1,
|
|
||||||
/* sda_setup_time_ns = */ 200, /* */
|
|
||||||
/* sck_pulse_width_ns = */ 200, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 200, /* st7565 datasheet, table 24, tds8 */
|
|
||||||
/* write_pulse_width_ns = */ 200, /* st7565 datasheet, table 24, tcclw */
|
|
||||||
/* tile_width = */ 13, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 100,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15300_100x32_init_seq[] = {
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0e2), /* soft reset */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_C(0x0a0), /* ADC set to normal */
|
|
||||||
U8X8_C(0x0a6), /* Display normal */
|
|
||||||
U8X8_C(0x0a4), /* all point normal */
|
|
||||||
|
|
||||||
U8X8_C(0x0a2), /* LCD bias 1/8 */
|
|
||||||
U8X8_C(0x0c8), /* common output mode */
|
|
||||||
U8X8_C(0x02f), /* power, might be 0x02c */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x094), /* set contrast */
|
|
||||||
//U8X8_C(0x0af), /* display on */
|
|
||||||
|
|
||||||
U8X8_C(0x0b0), /* set page address */
|
|
||||||
U8X8_C(0x010), /* set column address upper */
|
|
||||||
U8X8_C(0x000), /* set column address lower */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15300_97x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_s1d15300_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15300_97x32_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_100x32_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
/* needs to be fixed regarding a0/c0 */
|
|
||||||
/*
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15300_100x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_s1d15300_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15300_100x32_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_100x32_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
/* needs to be fixed regarding a0/c0 */
|
|
||||||
/*
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15300_100x32i(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
/* call common procedure first and handle messages there */
|
|
||||||
if ( u8x8_d_s1d15300_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15300_100x32i_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_100x32_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
/* needs to be fixed regarding a0/c0 */
|
|
||||||
/*
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15300_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_s1d15721.c
|
|
||||||
|
|
||||||
240x64 display
|
|
||||||
https://github.com/olikraus/u8g2/issues/1473
|
|
||||||
http://datasheet.datasheetarchive.com/originals/library/Datasheets-ISS16/DSAIH000309343.pdf
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2020, olikraus@gmail.com
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15721_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA8), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15721_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA8|1), /* display off, enter sleep mode */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15721_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA6), /* LCD Mapping */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15721_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA7), /* LCD Mapping */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15721_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, y, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
x *= 8;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0xB1); //Page Address - Row
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x13); /* col */
|
|
||||||
u8x8_cad_SendArg(u8x8, x);
|
|
||||||
|
|
||||||
/* 4 Mar 2022: added the missing page address, issue 1802 */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0xb1); /* page address */
|
|
||||||
u8x8_cad_SendArg(u8x8, y);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x1D ); //Data Write
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
c *= 8;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
/* handled in the calling procedure
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_128x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* s1d15721 240x64 */
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_s1d15721_240x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* low active CS */
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 10, /* */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20, /* */
|
|
||||||
/* reset_pulse_width_ms = */ 1, /* */
|
|
||||||
/* post_reset_wait_ms = */ 10,
|
|
||||||
/* sda_setup_time_ns = */ 30, /* */
|
|
||||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ /* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 30, /* */
|
|
||||||
/* write_pulse_width_ns = */ 65, /* */
|
|
||||||
/* tile_width = */ 30, /* width of 20*8=160 pixel (30*8 = 240) */
|
|
||||||
/* tile_height = */ 8, /* height 8*8 = 64*/
|
|
||||||
/* default_x_offset = */ 1,
|
|
||||||
/* flipmode_x_offset = */ 1,
|
|
||||||
/* pixel_width = */ 240,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15721_240x64_init_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xC4|1), /* (5) Common Output Status (Reverse) */
|
|
||||||
U8X8_CA(0xA6, 0x01), /* (3) Display Normal Reverse (Normal) */
|
|
||||||
U8X8_CA(0xA4, 0x00), /* (4) Display All Light (Normal) */
|
|
||||||
U8X8_CAA(0x6D,0x10,0x02), /* (18) Duty Set Command */
|
|
||||||
U8X8_CA(0x66, 0x01), /* (15) Display Mode, Parameter 0 (0 = Gray Scale 1 = Binary */
|
|
||||||
U8X8_CA(0x39, 0x36), /* (16) Gray Scale Pattern Set, Pattern */
|
|
||||||
U8X8_CA(0x2B, 0x07), /* (27) LCD Drive Mode Voltage Select, Parameter */
|
|
||||||
U8X8_CA(0x81, 0x0a), /* (28) Electronic Volume, Parameter */
|
|
||||||
U8X8_CA(0x5F, 0x00), /* (24) Built-in Oscillator Frequency, Parameter */
|
|
||||||
U8X8_C(0xAA|1), /* (23) Built-in OSC On */
|
|
||||||
U8X8_CA(0x25, 0x1f), /* (25) Power Control Set, Parameter */
|
|
||||||
U8X8_CA(0x8A, 0x00), /* (6) Start Line Setup, Parameter */
|
|
||||||
U8X8_CA(0xB1, 0x00), /* (7) Page Address Set, Parameter */
|
|
||||||
U8X8_CA(0x13, 0x00), /* (8) Column Address Set */
|
|
||||||
U8X8_C(0xAE|1), /* (1) Display ON/OFF */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15721_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* checking for the flip mode cmd first */
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
|
||||||
{
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* call the common procedure, this now leads to the effect, that the flip code is executed again */
|
|
||||||
/* maybe we should paste the common code here to avoid this */
|
|
||||||
|
|
||||||
|
|
||||||
if ( u8x8_d_s1d15721_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15721_240x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15721_240x64_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,250 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_s1d15e06.c
|
|
||||||
|
|
||||||
https://github.com/olikraus/u8g2/pull/1190
|
|
||||||
https://github.com/olikraus/u8g2/issues/1172
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2020, olikraus@gmail.com
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15e06_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA8), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15e06_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA8|1), /* display off, enter sleep mode */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15e06_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA6), /* LCD Mapping */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15e06_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xA7), /* LCD Mapping */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15e06_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, y, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0xB1); //Page Address - Row
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
|
||||||
y += u8x8->x_offset;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x13); /* col */
|
|
||||||
u8x8_cad_SendArg(u8x8, x);
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x1D ); //Data Write
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
c *= 8;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
/* handled in the calling procedure
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1608_128x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* s1d15e06 160x100 */
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_s1d15e06_160100_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* s1d15e06 has low active CS */
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 10, /* uc1608 datasheet, page 39, actually 0 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20, /* uc1608 datasheet, page 39 */
|
|
||||||
/* reset_pulse_width_ms = */ 1, /* uc1608 datasheet, page 42 */
|
|
||||||
/* post_reset_wait_ms = */ 10,
|
|
||||||
/* sda_setup_time_ns = */ 30, /* uc1608 datasheet, page 41 */
|
|
||||||
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 30, /* uc1608 datasheet, page 39 */
|
|
||||||
/* write_pulse_width_ns = */ 65, /* uc1608 datasheet, page 39 */
|
|
||||||
/* tile_width = */ 20, /* width of 20*8=160 pixel */
|
|
||||||
/* tile_height = */ 13,
|
|
||||||
/* default_x_offset = */ 0, /* reused as y page offset */
|
|
||||||
/* flipmode_x_offset = */ 0, /* reused as y page offset */
|
|
||||||
/* pixel_width = */ 160,
|
|
||||||
/* pixel_height = */ 100
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_s1d15e06_160100_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
/* (Command no in datasheet) Description */
|
|
||||||
U8X8_C(0xA0|1), /* (12) Column Address Direction (Reverse) */
|
|
||||||
|
|
||||||
U8X8_C(0xC4|1), /* (5) Common Output Status (Reverse) */
|
|
||||||
U8X8_C(0x84), /* (11) Display Data In. Direction (Normal) */
|
|
||||||
|
|
||||||
U8X8_C(0xA6), /* (3) Display Normal Reverse (Normal) */
|
|
||||||
U8X8_C(0xA4), /* (4) Display All Light (Normal) */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_CAA(0x6D,0x18,0x04), /* (18) Duty Set Command,
|
|
||||||
Parameter "Duty Set" 1/96 ,
|
|
||||||
Parameter "Start Point Set" */
|
|
||||||
|
|
||||||
U8X8_CA(0x66, 0x01), /* (15) Display Mode, Parameter 0 (4 Gray Scale) 1 (Binary) */
|
|
||||||
U8X8_CA(0x39, 0x43), /* (16) Gray Scale Pattern Set, Pattern */
|
|
||||||
U8X8_C(0xBE|1), /* (2) Display Off Mode (0 VSS / 1 Vcc) */
|
|
||||||
|
|
||||||
U8X8_CA(0x2B, 0x03), /* (27) LCD Drive Mode Voltage Select, Parameter */
|
|
||||||
|
|
||||||
U8X8_CA(0x81, 0x32), /* (28) Electronic Volume, Parameter */
|
|
||||||
U8X8_C(0xE4|1), /* (14) N-Line On Off (On) */
|
|
||||||
U8X8_CA(0x36, 0x05), /* (13) N-Line Inversion Drive, Parameter (6x4) */
|
|
||||||
|
|
||||||
U8X8_CA(0x41, 0x03), /* (13) (26) Step-up CK Frequency Select, fosc/8 */
|
|
||||||
U8X8_CA(0x5F, 0x04), /* (24) Built-in Oscillator Frequency, Parameter */
|
|
||||||
U8X8_C(0xAA|1), /* (23) Built-in OSC On */
|
|
||||||
|
|
||||||
U8X8_CA(0x25, 0x1F), /* (25) Power Control Set, Parameter */
|
|
||||||
|
|
||||||
U8X8_CA(0x8A, 0x00), /* (6) Start Line Setup, Parameter */
|
|
||||||
U8X8_CA(0xB1, 0x00), /* (7) Page Address Set, Parameter */
|
|
||||||
U8X8_CA(0x13, 0x00), /* (8) Column Address Set */
|
|
||||||
|
|
||||||
U8X8_C(0xAE|1), /* (1) Display ON/OFF */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_s1d15e06_160100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* checking for the flip mode cmd first */
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE )
|
|
||||||
{
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* call the common procedure, this now leads to the effect, that the flip code is executed again */
|
|
||||||
/* maybe we should paste the common code here to avoid this */
|
|
||||||
|
|
||||||
|
|
||||||
if ( u8x8_d_s1d15e06_common(u8x8, msg, arg_int, arg_ptr) == 0 )
|
|
||||||
{
|
|
||||||
/* msg not handled, then try here */
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_s1d15e06_160100_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_s1d15e06_160100_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0; /* msg unknown */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_sbn1661.c
|
|
||||||
|
|
||||||
SED1520 / SBN1661 122x32 5V LCD
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sbn1661_init_seq[] = {
|
|
||||||
U8X8_C(0x0c0), /* display start at line 0 */
|
|
||||||
U8X8_C(0x0a0), /* a0: ADC forward, a1: ADC reverse */
|
|
||||||
U8X8_C(0x0a4), /* a4: normal driving, a5: power save */
|
|
||||||
U8X8_C(0x0a9), /* a8: 1/16, a9: 1/32 duty */
|
|
||||||
|
|
||||||
//U8X8_C(0x0af), /* display on */
|
|
||||||
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sbn1661_powersave0_seq[] = {
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sbn1661_powersave1_seq[] = {
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct u8x8_sbn1661_vars
|
|
||||||
{
|
|
||||||
uint8_t *ptr;
|
|
||||||
uint8_t x;
|
|
||||||
uint8_t c;
|
|
||||||
uint8_t arg_int;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef NOT_USED
|
|
||||||
static void u8x8_sbn1661_out(u8x8_t *u8x8, struct u8x8_sbn1661_vars *v, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t cnt;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((v->x << 3) & 63) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
while( v->arg_int > 0 )
|
|
||||||
{
|
|
||||||
/* calculate tiles to next boundary (end or chip limit) */
|
|
||||||
cnt = v->x;
|
|
||||||
cnt += 8;
|
|
||||||
cnt &= 0x0f8;
|
|
||||||
cnt -= v->x;
|
|
||||||
|
|
||||||
if ( cnt > v->c )
|
|
||||||
cnt = v->c;
|
|
||||||
|
|
||||||
/* of course we still could use cnt=1 here... */
|
|
||||||
/* but setting cnt to 1 is not very efficient */
|
|
||||||
//cnt = 1;
|
|
||||||
|
|
||||||
v->x +=cnt;
|
|
||||||
v->c-=cnt;
|
|
||||||
cnt<<=3;
|
|
||||||
u8x8_cad_SendData(u8x8, cnt, v->ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
v->ptr += cnt;
|
|
||||||
|
|
||||||
if ( v->c == 0 )
|
|
||||||
{
|
|
||||||
v->ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
v->c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
v->arg_int--;
|
|
||||||
}
|
|
||||||
if ( ((v->x) & 7) == 0 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* NOT_USED */
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sbn1661_122x32_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0, /* sbn1661: Not used */
|
|
||||||
/* chip_disable_level = */ 1, /* sbn1661: Not used */
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 100,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 20,
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6, /* */
|
|
||||||
/* sda_setup_time_ns = */ 12,
|
|
||||||
/* sck_pulse_width_ns = */ 75, /* sbn1661: Not used */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* sbn1661: Not used */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4, /* sbn1661: Not used */
|
|
||||||
/* data_setup_time_ns = */ 200,
|
|
||||||
/* write_pulse_width_ns = */ 200, /* */
|
|
||||||
/* tile_width = */ 16, /* width of 16*8=128 pixel */
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 122,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sbn1661_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t *ptr;
|
|
||||||
//uint8_t x;
|
|
||||||
//uint8_t c;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sbn1661_122x32_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
// x and c are ignored (u8g2 only)
|
|
||||||
//x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
//c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
|
|
||||||
|
|
||||||
ptr += 61;
|
|
||||||
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sed1520_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
return u8x8_d_sbn1661_122x32(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,617 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_sed1330.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
The device might also work with the RA8835, SED1335 and SED1336 controller.
|
|
||||||
The following devices might be compatible:
|
|
||||||
RA8835
|
|
||||||
SED1330
|
|
||||||
SED1335
|
|
||||||
S1D13700
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sed1330_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
|
||||||
U8X8_CA(0x059, 0x004), /* send display on command (hex 0x059, see p37 ) */
|
|
||||||
/* display cmd has one arg: 01010100 should enable all three blocks, but disable the cursor*/
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sed1330_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x058, 0x000), /* send display off command (hex 0x059, see p37) and turn of all banks */
|
|
||||||
/* maybe send a sleep in cmd */
|
|
||||||
//U8X8_C(0x053) /* sleep in: 0x053 */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sed1330_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t c, i;
|
|
||||||
uint16_t y;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
|
||||||
/*
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
y*=8;
|
|
||||||
y*= u8x8->display_info->tile_width;
|
|
||||||
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x046 ); /* CSRW command*/
|
|
||||||
u8x8_cad_SendArg(u8x8, y&255); /* CSRW low adr byte */
|
|
||||||
u8x8_cad_SendArg(u8x8, y>>8); /* CSRW high adr byte */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x042 ); /* MWRITE */
|
|
||||||
|
|
||||||
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
|
|
||||||
|
|
||||||
ptr += u8x8->display_info->tile_width;
|
|
||||||
y += u8x8->display_info->tile_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sometimes the display switches off... so just sent a display on command */
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x059 ); /* display on */
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x004); /* arg for display on */
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
//u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================*/
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sed1330_240x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 20,
|
|
||||||
/* sck_pulse_width_ns = */ 140,
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0,
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
|
|
||||||
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
|
|
||||||
/* tile_width = */ 0x01e,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 240,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 240x128 Seiko G242C */
|
|
||||||
static const uint8_t u8x8_d_sed1330_240x128_init_seq[] = {
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
|
|
||||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
|
||||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
|
||||||
/* system init has total 8 parameters, so 7 more are here */
|
|
||||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
|
||||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
|
||||||
U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
|
||||||
U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
|
||||||
U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
|
||||||
|
|
||||||
U8X8_C(0x044), /* SCROLL */
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x040),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
|
|
||||||
U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
|
||||||
|
|
||||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* RA8835 NHD-240128BZ */
|
|
||||||
static const uint8_t u8x8_d_rh8835_nhd_240128_init_seq[] = {
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
|
|
||||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
|
||||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
|
||||||
/* system init has total 8 parameters, so 7 more are here */
|
|
||||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
|
||||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
|
||||||
U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
|
||||||
U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
|
||||||
U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
|
||||||
|
|
||||||
U8X8_C(0x044), /* SCROLL */
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x040),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
|
|
||||||
//U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
|
||||||
|
|
||||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
|
||||||
|
|
||||||
//U8X8_CA(0x059, 0x04), /* send display on command (hex 0x059, see p37 ) */
|
|
||||||
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sed1330_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_240x128_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ra8835_nhd_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_rh8835_nhd_240128_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================*/
|
|
||||||
/* issue 2518 https://github.com/olikraus/u8g2/issues/2518 */
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sed1330_240x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 20,
|
|
||||||
/* sck_pulse_width_ns = */ 140,
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0,
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
|
|
||||||
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
|
|
||||||
/* tile_width = */ 30,
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 240,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sed1330_240x64_init_seq[] = {
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
|
|
||||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
|
||||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
|
||||||
/* system init has total 8 parameters, so 7 more are here */
|
|
||||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
|
||||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
|
||||||
U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
|
||||||
U8X8_A(0x03f), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
|
||||||
U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
|
||||||
|
|
||||||
U8X8_C(0x044), /* SCROLL */
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x040),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
|
|
||||||
U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
|
||||||
|
|
||||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sed1330_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_240x64_init_seq);
|
|
||||||
u8x8_SendF(u8x8, "caaaaaaaa", 0x40, 0x30, 0x87, 0x07, 0x1d, 0x50, 0x3f, 0x1e, 0x00); /* send init again, issue 2518 https://github.com/olikraus/u8g2/issues/2518 */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*=============================================*/
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sed1330_320x240_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 20,
|
|
||||||
/* sck_pulse_width_ns = */ 140,
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0,
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
|
|
||||||
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
|
|
||||||
/* tile_width = */ 40,
|
|
||||||
/* tile_height = */ 30,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 320,
|
|
||||||
/* pixel_height = */ 240
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sed1330_320x240_init_seq[] = {
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
|
|
||||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
|
||||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
|
||||||
/* system init has total 8 parameters, so 7 more are here */
|
|
||||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
|
||||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
|
||||||
U8X8_A(0x027), /* 40-1 */ /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0x039), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
|
||||||
U8X8_A(0x0ef), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
|
||||||
U8X8_A(0x028), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
|
||||||
|
|
||||||
U8X8_C(0x044), /* SCROLL */
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x0ef),
|
|
||||||
U8X8_A(0x0b0),
|
|
||||||
U8X8_A(0x004),
|
|
||||||
U8X8_A(0x0ef),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
|
|
||||||
U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
|
||||||
|
|
||||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ra8835_320x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_320x240_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_320x240_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================*/
|
|
||||||
/*
|
|
||||||
https://github.com/olikraus/u8g2/issues/1908
|
|
||||||
https://www.allelectronics.com/mas_assets/media/allelectronics2018/spec/LCD-101.pdf
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sed1330_256x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 20,
|
|
||||||
/* sck_pulse_width_ns = */ 140,
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0,
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
|
|
||||||
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
|
|
||||||
/* tile_width = */ 32,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 256,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* 256x128 Hyundai HG25604 (HG25504???) */
|
|
||||||
static const uint8_t u8x8_d_sed1330_256x128_init_seq[] = {
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
|
|
||||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
|
||||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
|
||||||
/* system init has total 8 parameters, so 7 more are here */
|
|
||||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
|
||||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
|
||||||
U8X8_A(0x01f), /* 32-1*/ /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
|
||||||
U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
|
||||||
U8X8_A(0x020), /* 32 */ /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */
|
|
||||||
|
|
||||||
U8X8_C(0x044), /* SCROLL, 11 Bytes in total */
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x040),
|
|
||||||
U8X8_A(0x080),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
|
|
||||||
U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
|
||||||
|
|
||||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sed1330_256x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_256x128_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_256x128_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*=============================================*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
https://github.com/olikraus/u8g2/issues/1086
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sed1330_320x200_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */
|
|
||||||
/* reset_pulse_width_ms = */ 1,
|
|
||||||
/* post_reset_wait_ms = */ 6,
|
|
||||||
/* sda_setup_time_ns = */ 20,
|
|
||||||
/* sck_pulse_width_ns = */ 140,
|
|
||||||
/* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0,
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */
|
|
||||||
/* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */
|
|
||||||
/* tile_width = */ 40,
|
|
||||||
/* tile_height = */ 25,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 320,
|
|
||||||
/* pixel_height = */ 200
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sed1330_320x200_init_seq[] = {
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
|
|
||||||
/* system init command, see also u8x8_d_sed1330_powersave0_seq */
|
|
||||||
U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */
|
|
||||||
/* system init has total 8 parameters, so 7 more are here */
|
|
||||||
|
|
||||||
U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */
|
|
||||||
U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */
|
|
||||||
U8X8_A(0x027), /* 40-1 */ /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0x02F), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/
|
|
||||||
U8X8_A(0x0c7), /* 0xc7=199, L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/
|
|
||||||
U8X8_A(0x028), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */
|
|
||||||
U8X8_A(0x000), /* High byte of the virtual screen size, see also section 9.1.2 */
|
|
||||||
|
|
||||||
U8X8_C(0x044), /* SCROLL, 11 Bytes in total */
|
|
||||||
U8X8_A(0x000), /* Screen 1 Start Address (Low) = 00H */
|
|
||||||
U8X8_A(0x000), /* Screen 1 Start Address (High) = 00H */
|
|
||||||
U8X8_A(0x0c7), /* Screen Layer 1 Number of lines = 200d */
|
|
||||||
U8X8_A(0x0b0), /* Screen 2 Start Address (Low) = 00H */
|
|
||||||
U8X8_A(0x005), /* Screen 2 Start Address (High) = 00H */
|
|
||||||
U8X8_A(0x0c7), /* Screen Layer 2 Number of lines = 200d */
|
|
||||||
U8X8_C(0x04C), /* Cursor Direction 0,0 Shift Direction = Right */
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
U8X8_A(0x000),
|
|
||||||
|
|
||||||
U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */
|
|
||||||
|
|
||||||
U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_DLY(100),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_DLY(100),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sed1330_320x200(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_320x200_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_320x200_init_seq);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,215 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_sh1106_64x32.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2018, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* issue 568 */
|
|
||||||
static const uint8_t u8x8_d_sh1106_64x32_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio, 0.42 OLED */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.42 OLED */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0, 0.42 OLED */
|
|
||||||
U8X8_CA(0xad, 0x8b), /* DC-DC ON/OFF Mode Set: Built-in DC-DC is used, Normal Display (POR = 0x8b) */
|
|
||||||
U8X8_C(0x33), /* set charge pump voltage 0x30 (POR) .. 0x33 */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
|
||||||
U8X8_CA(0x081, 0x080), /* [2] set contrast control, 0.42 OLED datasheet: 0xcf */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
|
|
||||||
U8X8_CA(0x0db, 0x028), /* vcomh deselect level, 0.42 OLED datasheet: 0x00 */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_64x32_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_64x32_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_64x32_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_CA(0x0d3, 0), /* display offset, 0.42 OLED */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_64x32_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_CA(0x0d3, 0), /* What is the correct offset in flip 1 mode? --> Issue 547 */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_sh1106_64x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_64x32_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copied from SSD1306 */
|
|
||||||
static const u8x8_display_info_t u8x8_sh1106_64x32_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 8,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 32,
|
|
||||||
/* flipmode_x_offset = */ 36,
|
|
||||||
/* pixel_width = */ 64,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1106_64x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_64x32_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_64x32_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_sh1106_64x32_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_sh1106_72x40.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2018, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* WiseChip 0.42 OLED, issue 547 */
|
|
||||||
static const uint8_t u8x8_d_sh1106_72x40_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x027), /* multiplex ratio, 0.42 OLED */
|
|
||||||
U8X8_CA(0x0d3, 0x00c), /* display offset, 0.42 OLED */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0, 0.42 OLED */
|
|
||||||
U8X8_CA(0xad, 0x8b), /* DC-DC ON/OFF Mode Set: Built-in DC-DC is used, Normal Display (POR = 0x8b) */
|
|
||||||
U8X8_C(0x33), /* set charge pump voltage 0x30 (POR) .. 0x33 */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
|
||||||
U8X8_CA(0x081, 0x080), /* [2] set contrast control, 0.42 OLED datasheet: 0xcf */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
|
|
||||||
U8X8_CA(0x0db, 0x028), /* vcomh deselect level, 0.42 OLED datasheet: 0x00 */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_72x40_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_72x40_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_72x40_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_CA(0x0d3, 12), /* display offset, 0.42 OLED */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_72x40_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_CA(0x0d3, 52), /* What is the correct offset in flip 1 mode? --> Issue 547 */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_sh1106_72x40_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_72x40_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copied from SSD1306 */
|
|
||||||
static const u8x8_display_info_t u8x8_sh1106_72x40_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 9,
|
|
||||||
/* tile_height = */ 5,
|
|
||||||
/* default_x_offset = */ 30,
|
|
||||||
/* flipmode_x_offset = */ 30,
|
|
||||||
/* pixel_width = */ 72,
|
|
||||||
/* pixel_height = */ 40
|
|
||||||
};
|
|
||||||
|
|
||||||
/* WiseChip 0.42" OLED */
|
|
||||||
uint8_t u8x8_d_sh1106_72x40_wise(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_72x40_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_72x40_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_sh1106_72x40_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,868 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_sh1107.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2017, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/* code copyied from SSD1306 */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1107_64x128_noname_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1107_64x128_noname_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1107_64x128_noname_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1107_64x128_noname_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_sh1107_HJR_OEL1M0201_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1107 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
//u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
|
||||||
|
|
||||||
// set column address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15))); /* probably wrong, should be SendCmd */
|
|
||||||
|
|
||||||
// set page address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (2+(((u8x8_tile_t *)arg_ptr)->y_pos))); /* probably wrong, should be SendCmd */
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_sh1107_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1107 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
//u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
|
||||||
|
|
||||||
// set column address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15))); /* probably wrong, should be SendCmd */
|
|
||||||
|
|
||||||
// set page address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
|
|
||||||
/* QG-6428TSWKG01 */
|
|
||||||
static const uint8_t u8x8_d_sh1107_64x128_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0dc, 0x000), /* start line */
|
|
||||||
U8X8_CA(0x081, 0x02f), /* [2] set contrast control */
|
|
||||||
U8X8_C(0x020), /* addressing mode */
|
|
||||||
|
|
||||||
// U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0a8, 0x7f), /* 0x03f) multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x060), /* display offset */
|
|
||||||
U8X8_CA(0x0d5, 0x051), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
|
||||||
|
|
||||||
U8X8_C(0x0b0), /* set page address */
|
|
||||||
U8X8_CA(0x0da, 0x012), /* set com pins */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1107_64x128_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* sh1107: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* sh1107: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* sh1107: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 8,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 64,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1107_64x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
|
|
||||||
/* init sequence from Grove OLED 96x96 */
|
|
||||||
static const uint8_t u8x8_d_sh1107_seeed_96x96_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x050), /* clock divide ratio (0x00=1) and oscillator frequency (0x5) */
|
|
||||||
U8X8_C(0x020), /* use page addressing mode */
|
|
||||||
//U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_CA(0x0dc, 0x000), /* start line */
|
|
||||||
//U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
//U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
|
|
||||||
U8X8_CA(0x081, 0x080), /* [2] set contrast control */
|
|
||||||
U8X8_CA(0x0ad, 0x080), /* */
|
|
||||||
U8X8_CA(0x0d9, 0x01f), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x027), /* vcomh deselect level */
|
|
||||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
|
||||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
|
||||||
|
|
||||||
//U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1107_seeed_96x96_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 12,
|
|
||||||
/* tile_height = */ 12,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 96,
|
|
||||||
/* pixel_height = */ 96
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1107_seeed_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_seeed_96x96_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_seeed_96x96_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1107_HJR_OEL1M0201_96x96_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0xAE),//
|
|
||||||
|
|
||||||
U8X8_C(0x0F),//
|
|
||||||
U8X8_C(0x17),//
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0xD9),//
|
|
||||||
U8X8_C(0x89), //
|
|
||||||
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_CA(0x0dc, 0x070), /* start line */
|
|
||||||
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1 A0��??A1?���?a|��1D����*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_C(0xD5),//
|
|
||||||
U8X8_C(0xB0),//
|
|
||||||
|
|
||||||
U8X8_C(0x20),//
|
|
||||||
|
|
||||||
U8X8_C(0xDB),//
|
|
||||||
U8X8_C(0x35),//
|
|
||||||
|
|
||||||
U8X8_C(0x81),//
|
|
||||||
|
|
||||||
U8X8_C(0xC7),//
|
|
||||||
|
|
||||||
U8X8_C(0xA4),//A5����????��
|
|
||||||
|
|
||||||
U8X8_C(0xA6),//A6��??A7?���?a?��??��|?
|
|
||||||
|
|
||||||
U8X8_C(0xAD),//
|
|
||||||
U8X8_C(0x80),//
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1107_hjr_oel1m0201_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( u8x8_d_sh1107_HJR_OEL1M0201_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_HJR_OEL1M0201_96x96_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_seeed_96x96_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
/* 128x128 OLED: this display has a very strange x offset */
|
|
||||||
|
|
||||||
/*
|
|
||||||
6 Feb 2025:
|
|
||||||
There is an issue
|
|
||||||
https://github.com/olikraus/u8g2/issues/2581#issuecomment-2628394758
|
|
||||||
Looks like there are displays where the x offset must be 0
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* sequence taken over from 64x128 sequence, because it seems to work mostly */
|
|
||||||
static const uint8_t u8x8_d_sh1107_128x128_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0dc, 0x000), /* start line */
|
|
||||||
U8X8_CA(0x081, 0x02f), /* [2] set contrast control */
|
|
||||||
U8X8_C(0x020), /* use page addressing mode */
|
|
||||||
|
|
||||||
// U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0a8, 0x7f), /* 0x03f multiplex ratio */
|
|
||||||
//U8X8_CA(0x0d3, 0x060), /* display offset (removed, not in datasheet ) */
|
|
||||||
U8X8_CA(0x0d5, 0x050), /* clock divide ratio (0x00=1) and oscillator frequency (0x8), changed to 0x051, issue 501 */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
|
||||||
|
|
||||||
U8X8_C(0x0b0), /* set page address */
|
|
||||||
U8X8_CA(0x0da, 0x012), /* set com pins */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1107_128x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 96,
|
|
||||||
/* flipmode_x_offset = */ 96,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1107_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_128x128_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
/* 128x80 OLED, copyied from SEEED 128x128 oled, this display has a very strange x offset */
|
|
||||||
/* https://github.com/olikraus/u8g2/issues/1598 */
|
|
||||||
/* this is actually a 80x128 display, but let's keep the 128x80 name */
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1107_128x80_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 10,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 24,
|
|
||||||
/* flipmode_x_offset = */ 24,
|
|
||||||
/* pixel_width = */ 80,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1107_128x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_128x80_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
/* pimoroni_128x128_display */
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1107_pimoroni_128x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1107_pimoroni_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_pimoroni_128x128_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
/*
|
|
||||||
Name: SH1107_seeed_128x128
|
|
||||||
URL: https://www.seeedstudio.com/Grove-OLED-Display-1-12-V2.html
|
|
||||||
Display is there in my lab. Backside PCB label: "OLED Display 1.12 inch v1.0"
|
|
||||||
Tookover code from SSD1327_SEEED_96X96 because none of the other displays did work
|
|
||||||
and at least the 96x96 driver did show something.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_seeed_128x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 2, // 400kHz does not work, but 200kHz seems to be ok
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1107_seeed_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_seeed_128x128_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
static const uint8_t u8x8_d_sh1107_80x128_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0xAE), /*display off*/
|
|
||||||
U8X8_C(0x00), /*set lower column address*/
|
|
||||||
U8X8_C(0x10), /*set higher column address*/
|
|
||||||
U8X8_C(0x20), /* Set Memory addressing mode (0x20/0x21) */
|
|
||||||
U8X8_C(0x81), /*contract control*/
|
|
||||||
U8X8_C(0x6f), /*b0*/
|
|
||||||
U8X8_C(0xA0), /*set segment remap*/
|
|
||||||
U8X8_C(0xC0), /*Com scan direction*/
|
|
||||||
U8X8_C(0xA4), /*Disable Entire Display On (0xA4/0xA5)*/
|
|
||||||
U8X8_C(0xA6), /*normal / reverse*/
|
|
||||||
U8X8_C(0xD5), /*set osc division*/
|
|
||||||
U8X8_C(0x91),
|
|
||||||
U8X8_C(0xD9), /*set pre-charge period*/
|
|
||||||
U8X8_C(0x22),
|
|
||||||
U8X8_C(0xdb), /*set vcomh*/
|
|
||||||
U8X8_C(0x3f),
|
|
||||||
U8X8_C(0xA8), /*multiplex ratio*/
|
|
||||||
U8X8_C(0x4F), /*duty = 1/80*/
|
|
||||||
U8X8_C(0xD3), /*set display offset*/
|
|
||||||
U8X8_C(0x68), /*18*/
|
|
||||||
U8X8_C(0xdc), /*Set Display Start Line*/
|
|
||||||
U8X8_C(0x00),
|
|
||||||
U8X8_C(0xad), /*set charge pump enable*/
|
|
||||||
U8X8_C(0x8a), /*Set DC-DC enable (a=0:disable, a=1:enable) */
|
|
||||||
// OLED_Clear(),
|
|
||||||
U8X8_C(0xAF), /*display ON*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//U8X8_CA(0x0dc, 0x000), /* start line */
|
|
||||||
// U8X8_CA(0x081, 0x02f), /* [2] set contrast control */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
static uint8_t u8x8_d_sh1107_TK078F288_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1107 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
//u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
|
||||||
|
|
||||||
// set column address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15))); /* probably wrong, should be SendCmd */
|
|
||||||
|
|
||||||
// set page address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
static const u8x8_display_info_t u8x8_TK078F288_80x128_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 2, // 400kHz does not work, but 200kHz seems to be ok
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 10,
|
|
||||||
/* tile_height = */ 16,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 80,
|
|
||||||
/* pixel_height = */ 128
|
|
||||||
};
|
|
||||||
uint8_t u8x8_d_sh1107_tk078f288_80x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1107_TK078F288_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_80x128_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_TK078F288_80x128_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,299 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_sh1108.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2018, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
code copyied from sh1107
|
|
||||||
SH1108: 160x160 controller from Sino Wealth
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1108_noname_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1108_noname_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1108_160x160_noname_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1108_160x160_noname_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_sh1108_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1108_64x128_noname_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_64x128_noname_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_noname_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_noname_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_160x160_noname_powersave0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_160x160_noname_powersave1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1108 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
//u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
|
||||||
|
|
||||||
// set column address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
|
|
||||||
|
|
||||||
// set page address
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 ); // page cmd is a two byte command
|
|
||||||
u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
|
|
||||||
/* issue #619, 160x160 OLED */
|
|
||||||
static const uint8_t u8x8_d_sh1108_160x160_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x060), /* clock divide ratio and oscillator frequency */
|
|
||||||
U8X8_CA(0x0a9, 0x003), /* set display resolution, 0=64x160, 1=96x160, 2=128x160, 3=160x160 */
|
|
||||||
U8X8_C(0x020), /* addressing mode */
|
|
||||||
U8X8_CA(0x081, 0x01f), /* set contrast control */
|
|
||||||
U8X8_CA(0x0ad, 0x80), /* DC/DC control 80=Use external Vpp, 89=Use internal DC/DC*/
|
|
||||||
U8X8_C(0x030), /* set discharge VSL level, 0x030..0x03f */
|
|
||||||
U8X8_CA(0x0d9, 0x028), /* pre-charge period */
|
|
||||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
|
||||||
U8X8_CA(0x0dc, 0x035), /* VSEGM Deselect Level */
|
|
||||||
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1108_160x160_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 60,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* sh1108: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* sometimes OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* sh1108: 100ns */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* sh1108: 100ns */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1108: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 20,
|
|
||||||
/* tile_height = */ 20,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 160,
|
|
||||||
/* pixel_height = */ 160
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1108_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1108_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_160x160_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1108_160x160_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
|
|
||||||
|
|
||||||
/* issue #1998, 128x160 OLED */
|
|
||||||
static const uint8_t u8x8_d_sh1108_128x160_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x060), /* clock divide ratio and oscillator frequency */
|
|
||||||
U8X8_CA(0x0a9, 0x002), /* set display resolution, 0=64x160, 1=96x160, 2=128x160, 3=160x160 */
|
|
||||||
U8X8_C(0x020), /* addressing mode */
|
|
||||||
U8X8_CA(0x081, 0x01f), /* set contrast control */
|
|
||||||
U8X8_CA(0x0ad, 0x80), /* DC/DC control 80=Use external Vpp, 89=Use internal DC/DC*/
|
|
||||||
U8X8_C(0x030), /* set discharge VSL level, 0x030..0x03f */
|
|
||||||
U8X8_CA(0x0d9, 0x028), /* pre-charge period */
|
|
||||||
U8X8_CA(0x0db, 0x035), /* vcomh deselect level */
|
|
||||||
U8X8_CA(0x0dc, 0x035), /* VSEGM Deselect Level */
|
|
||||||
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1108_128x160_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 60,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 120,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* sh1108: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* sometimes OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 100, /* sh1108: 100ns */
|
|
||||||
/* sck_pulse_width_ns = */ 100, /* sh1108: 100ns */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1108: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 20,
|
|
||||||
/* default_x_offset = */ 16,
|
|
||||||
/* flipmode_x_offset = */ 16,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 160
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1108_128x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_sh1108_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1108_128x160_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1108_128x160_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==================================================*/
|
|
||||||
@@ -1,290 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_sh1122.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
Idea: SH1122 is a horizontal device, which doesn't support u8x8
|
|
||||||
However in the similar SSD1362 device, we do the correct tile conversion,
|
|
||||||
so maybe takeover code from SSD1362 to SH1122, so that SH1122 can also
|
|
||||||
support u8x8
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1122_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* sh1122: display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1122_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* sh1122: display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
input:
|
|
||||||
one tile (8 Bytes)
|
|
||||||
output:
|
|
||||||
Tile for SH1122 (32 Bytes)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
static uint8_t u8x8_sh1122_to32_dest_buf[32];
|
|
||||||
|
|
||||||
static uint8_t *u8x8_sh1122_8to32(U8X8_UNUSED u8x8_t *u8x8, uint8_t *ptr)
|
|
||||||
{
|
|
||||||
uint8_t v;
|
|
||||||
uint8_t a,b;
|
|
||||||
uint8_t i, j;
|
|
||||||
uint8_t *dest;
|
|
||||||
|
|
||||||
for( j = 0; j < 4; j++ )
|
|
||||||
{
|
|
||||||
dest = u8x8_sh1122_to32_dest_buf;
|
|
||||||
dest += j;
|
|
||||||
a =*ptr;
|
|
||||||
ptr++;
|
|
||||||
b = *ptr;
|
|
||||||
ptr++;
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
v = 0;
|
|
||||||
if ( a&1 ) v |= 0xf0;
|
|
||||||
if ( b&1 ) v |= 0x0f;
|
|
||||||
*dest = v;
|
|
||||||
dest+=4;
|
|
||||||
a >>= 1;
|
|
||||||
b >>= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return u8x8_sh1122_to32_dest_buf;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_write_byte_to_16gr_device(u8x8_t *u8x8, uint8_t b)
|
|
||||||
{
|
|
||||||
static uint8_t buf[4];
|
|
||||||
static uint8_t map[4] = { 0, 0x00f, 0x0f0, 0x0ff };
|
|
||||||
buf [3] = map[b & 3];
|
|
||||||
b>>=2;
|
|
||||||
buf [2] = map[b & 3];
|
|
||||||
b>>=2;
|
|
||||||
buf [1] = map[b & 3];
|
|
||||||
b>>=2;
|
|
||||||
buf [0] = map[b & 3];
|
|
||||||
return u8x8_cad_SendData(u8x8, 4, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1122_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x;
|
|
||||||
uint8_t y, c, i;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
|
|
||||||
/*
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_powersave1_seq);
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* sh1122 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 2; // 4 Mar 2022: probably this needs to be 4, but this device is call with x=0 only
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
y = (((u8x8_tile_t *)arg_ptr)->y_pos);
|
|
||||||
y *= 8;
|
|
||||||
|
|
||||||
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
|
|
||||||
for( i = 0; i < 8; i++ )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 ); /* set row address */
|
|
||||||
u8x8_cad_SendArg(u8x8, y);
|
|
||||||
u8x8_cad_SendCmd(u8x8, x & 15 ); /* lower 4 bit*/
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4) ); /* higher 3 bit */
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
|
|
||||||
|
|
||||||
while ( c > 0 )
|
|
||||||
{
|
|
||||||
u8x8_write_byte_to_16gr_device(u8x8, *ptr);
|
|
||||||
c--;
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
y++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================================*/
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1122_256x64_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* remap */
|
|
||||||
U8X8_C(0x0c8), /* remap */
|
|
||||||
U8X8_C(0x060),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1122_256x64_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* remap */
|
|
||||||
U8X8_C(0x0c0), /* remap */
|
|
||||||
U8X8_C(0x040),
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1122_256x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 10, /* sh1122: 10 us */
|
|
||||||
/* post_reset_wait_ms = */ 20, /* */
|
|
||||||
/* sda_setup_time_ns = */ 125, /* sh1122: cycle time is 250ns, so use 250/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 125, /* sh1122: cycle time is 250ns, so use 250/2 */
|
|
||||||
/* sck_clock_hz = */ 40000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 10,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* sh1122: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 32, /* 256 pixel, so we require 32 bytes for this */
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0, /* this is the byte offset (there are two pixel per byte with 4 bit per pixel) */
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 256,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1122_256x64_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_DLY(1),
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_DLY(1),
|
|
||||||
|
|
||||||
U8X8_C(0xae), /* display off */
|
|
||||||
U8X8_C(0x40), /* display start line */
|
|
||||||
U8X8_C(0x0a0), /* remap */
|
|
||||||
U8X8_C(0x0c0), /* remap */
|
|
||||||
U8X8_CA(0x81, 0x80), /* set display contrast */
|
|
||||||
U8X8_CA(0xa8, 0x3f), /* multiplex ratio 1/64 Duty (0x0F~0x3F) */
|
|
||||||
U8X8_CA(0xad, 0x81), /* use buildin DC-DC with 0.6 * 500 kHz */
|
|
||||||
|
|
||||||
U8X8_CA(0xd5, 0x50), /* set display clock divide ratio (lower 4 bit)/oscillator frequency (upper 4 bit) */
|
|
||||||
U8X8_CA(0xd3, 0x00), /* display offset, shift mapping ram counter */
|
|
||||||
U8X8_CA(0xd9, 0x22), /* pre charge (lower 4 bit) and discharge(higher 4 bit) period */
|
|
||||||
U8X8_CA(0xdb, 0x35), /* VCOM deselect level */
|
|
||||||
U8X8_CA(0xdc, 0x35), /* Pre Charge output voltage */
|
|
||||||
U8X8_C(0x030), /* discharge level */
|
|
||||||
|
|
||||||
U8X8_DLY(1), /* delay */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1122_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1122_256x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1122_256x64_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return u8x8_d_sh1122_common(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,514 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1305.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2017, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1305_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1305_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1305_128x32_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x0d3, 32), /* display offset to 32 */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1305_128x32_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_CA(0x0d3, 0), /* display offset to */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1305_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos) );
|
|
||||||
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_powersave1_seq);
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1305 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* timing from SSD1306 */
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1305_128x32_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 2,
|
|
||||||
/* flipmode_x_offset = */ 2,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1305_128x32_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 32), /* display offset to 32 */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
|
|
||||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */
|
|
||||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
|
||||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
|
||||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1305_128x32_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x32_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* issue 2002: Waveshare */
|
|
||||||
|
|
||||||
#ifdef SAME_AS_ADAFRUIT
|
|
||||||
/* timing from SSD1306 */
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1305_128x32_waveshare_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 4,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1305_128x32_waveshare(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x32_waveshare_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* adafruit 128x32 SSD1305 OLED, https://www.adafruit.com/product/2675 */
|
|
||||||
/* issue 724 */
|
|
||||||
|
|
||||||
/* timing from SSD1306 */
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1305_128x32_adafruit_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 4,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1305_128x32_adafruit(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x32_adafruit_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* adafruit SSD1305 OLED */
|
|
||||||
|
|
||||||
/* timing from SSD1306 */
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1305_128x64_adafruit_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 2,
|
|
||||||
/* flipmode_x_offset = */ 2,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1305_128x64_adafruit_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x0f0), /* clock divide ratio (0x00=1) and oscillator frequency */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x040), /* display offset to 32 */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
|
|
||||||
U8X8_CA(0x081, 0x032), /* [2] set contrast control */
|
|
||||||
U8X8_CA(0x082, 0x080), /* set area brightness (reset=0x080) */
|
|
||||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
|
||||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
|
||||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1305_128x64_adafruit(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x64_adafruit_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x64_adafruit_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*================================================*/
|
|
||||||
/* Raystar RET012864 OLED, issue https://github.com/olikraus/u8g2/issues/1111 */
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1305_128x64_raystar_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 4,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1305_128x64_raystar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1305_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1305_128x64_adafruit_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1305_128x64_raystar_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,323 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_128x32.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* UG-2832HSWEG02 Datasheet, Section 4.4 */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x002), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
U8X8_CA(0x081, 0x08f), /* [2] set contrast control */
|
|
||||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_128x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x32_univision_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_128x32_univision_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_128x32_univision(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x32_univision_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_128x32_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=============================================*/
|
|
||||||
/* issue 756 */
|
|
||||||
|
|
||||||
#define ADDR_MODE 0 //0:horizontal, 1:vertical, 2:page
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_128x32_winstar_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 125,
|
|
||||||
/* flipmode_x_offset = */ 125,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_128x32_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x32_winstar_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_128x32_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*=============================================*/
|
|
||||||
/* visionox 132x32 OLED, https://github.com/olikraus/u8g2/issues/1250 */
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_sh1106_128x32_visionox_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0xAE),
|
|
||||||
U8X8_CA(0xD5, 0x91),
|
|
||||||
U8X8_CA(0xA8, 0x1F),
|
|
||||||
U8X8_CA(0xD3, 0x10),
|
|
||||||
U8X8_C(0x40),
|
|
||||||
U8X8_CA(0xAD, 0x8B),
|
|
||||||
U8X8_C(0x33),
|
|
||||||
U8X8_C(0xA1),
|
|
||||||
U8X8_C(0xC8),
|
|
||||||
U8X8_CA(0xDA, 0x12),
|
|
||||||
U8X8_CA(0x81, 0xAF),
|
|
||||||
U8X8_CA(0xD9, 0x1F),
|
|
||||||
U8X8_CA(0xDB, 0x25),
|
|
||||||
U8X8_C(0xA4),
|
|
||||||
U8X8_C(0xA6),
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_d_sh1106_128x32_visionox_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 2,
|
|
||||||
/* flipmode_x_offset = */ 2,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1106_128x32_visionox(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_d_sh1106_128x32_visionox_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_128x32_visionox_init_seq);
|
|
||||||
}
|
|
||||||
|
|
||||||
return u8x8_d_ssd1306_128x32_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
@@ -1,544 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_128x64_noname.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* more or less generic setup of all these small OLEDs */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, SSD1306 only, should be removed for SH1106 */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
|
|
||||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */
|
|
||||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
|
||||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
|
||||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* this setup maximizes the brightness range, that can be set with setContrast() */
|
|
||||||
/* Drawback: VCOMH deselect level is set to 0, which das not work so good with all OLEDs, issue #116 */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x64_vcomh0_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
U8X8_CA(0x081, 0x0ef), /* [2] set contrast control, */
|
|
||||||
U8X8_CA(0x0d9, 0x0a1), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level 0x000 .. 0x070, low nibble always 0 */
|
|
||||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* same as u8x8_d_ssd1306_128x64_noname_init_seq, but 0x0da bit 4 is set to 0 */
|
|
||||||
/* this will disable the alternative COM configuration */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x64_alt0_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, SSD1306 only, should be removed for SH1106 */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x002), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
|
|
||||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */
|
|
||||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
|
||||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
|
||||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* issue 316: a special sh1106 setup, https://www.mikrocontroller.net/topic/431371?goto=5087807#5087807 */
|
|
||||||
static const uint8_t u8x8_d_sh1106_128x64_winstar_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0xae), // Display OFF/ON: off (POR = 0xae)
|
|
||||||
U8X8_C(0xa4), // Set Entire Display OFF/ON: off (POR = 0xa4)
|
|
||||||
U8X8_CA(0xd5, 0x50), // Divide Ratio/Oscillator FrequencyData Set: divide ratio = 1 (POR = 1), Oscillator Frequency = +/- 0% (POR = +/- 0%)
|
|
||||||
U8X8_CA(0xa8, 0x3f), // Multiplex Ratio Data Set: 64 (POR = 0x3f, 64)
|
|
||||||
U8X8_CA(0xd3, 0x00), // Display OffsetData Set: 0 (POR = 0x00)
|
|
||||||
U8X8_C(0x40), // Set Display Start Line: 0
|
|
||||||
U8X8_CA(0xad, 0x8b), // DC-DC ON/OFF Mode Set: Built-in DC-DC is used, Normal Display (POR = 0x8b)
|
|
||||||
U8X8_CA(0xd9, 0x22), // Dis-charge/Pre-charge PeriodData Set: pre-charge 2 DCLKs, dis-charge 2 DCLKs (POR = 0x22, pre-charge 2 DCLKs, dis-charge 2 DCLKs)
|
|
||||||
U8X8_CA(0xdb, 0x35), // VCOM Deselect LevelData Set: 0,770V (POR = 0x35, 0,770 V)
|
|
||||||
U8X8_C(0x32), // Set Pump voltage value: 8,0 V (POR = 0x32, 8,0 V)
|
|
||||||
U8X8_CA(0x81, 0xff), // Contrast Data Register Set: 255 (large) (POR = 0x80)
|
|
||||||
U8X8_C(0x0a6), // Set Normal/Reverse Display: normal (POR = 0xa6)
|
|
||||||
U8X8_CA(0x0da, 0x012), // com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5)
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1312_128x64_noname_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, SSD1306 only, should be removed for SH1106 */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
|
|
||||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */
|
|
||||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level */
|
|
||||||
// if vcomh is 0, then this will give the biggest range for contrast control issue #98
|
|
||||||
// restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_128x64_noname_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1312_128x64_noname_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1312_128x64_noname_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_sh1106_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */
|
|
||||||
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x000 | ((x&15))); /* probably wrong, should be SendCmd */
|
|
||||||
u8x8_cad_SendArg(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */
|
|
||||||
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
/*
|
|
||||||
do
|
|
||||||
{
|
|
||||||
u8x8_cad_SendData(u8x8, 8, ptr);
|
|
||||||
ptr += 8;
|
|
||||||
c--;
|
|
||||||
} while( c > 0 );
|
|
||||||
*/
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_128x64_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 0,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1312_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1312_128x64_noname_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1312_128x64_noname_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1312_128x64_noname_init_seq); /* update 27 mar 2022 */
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_128x64_vcomh0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_vcomh0_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_128x64_alt0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_alt0_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_sh1106_128x64_noname_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* issue 1901: changed mode from 3 to 0 */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 16,
|
|
||||||
/* tile_height = */ 8,
|
|
||||||
/* default_x_offset = */ 2,
|
|
||||||
/* flipmode_x_offset = */ 2,
|
|
||||||
/* pixel_width = */ 128,
|
|
||||||
/* pixel_height = */ 64
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1106_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
/* maybe use a better init sequence */
|
|
||||||
/* https://www.mikrocontroller.net/topic/431371 */
|
|
||||||
/* the new sequence is added in the winstar constructor (see below), this is kept untouched */
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1106_128x64_vcomh0(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_vcomh0_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8x8_d_sh1106_128x64_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( u8x8_d_ssd1306_sh1106_generic(u8x8, msg, arg_int, arg_ptr) != 0 )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_sh1106_128x64_winstar_init_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1106_128x64_noname_display_info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_2040x16.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/* virtual device, issue 1291 */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_2040x16_init_seq[] =
|
|
||||||
{
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio, 0.71 OLED: changed from 0x2f to 0x3f */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.71 OLED */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0, 0.71 OLED */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.71 OLED 0x14*/
|
|
||||||
|
|
||||||
/// according to the datasheet, 0x00 is NOT page addressing mode, but horizontal addressing mode;
|
|
||||||
/// so it looks like u8g2 expects horizontal addressing (and the inline comment is wrong) while the Winstar example
|
|
||||||
/// actually uses page addressing (which is the reset default)
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.71 OLED */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.71 OLED */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.71 OLED */
|
|
||||||
U8X8_CA(0x081, 0x07f), /* [2] set contrast control, 0.71 OLED datasheet: 0x7f */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.71 OLED datasheet: 0x22 */
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level, 0.71 OLED datasheet: 0x40 */
|
|
||||||
|
|
||||||
// U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_2040x16_powersave0_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_2040x16_powersave1_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_2040x16_flip0_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_2040x16_flip1_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_2040x16_generic(u8x8_t *u8x8, uint8_t msg,
|
|
||||||
uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_2040x16_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if (arg_int == 0)
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if (arg_int == 0)
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081);
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *) arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *) arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *) arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *) arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c * 8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_2040x16_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */0,
|
|
||||||
/* chip_disable_level = */1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */20,
|
|
||||||
/* pre_chip_disable_wait_ns = */10,
|
|
||||||
/* reset_pulse_width_ms = */100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */4,
|
|
||||||
/* data_setup_time_ns = */40,
|
|
||||||
/* write_pulse_width_ns = */150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */255,
|
|
||||||
/* tile_height = */2,
|
|
||||||
/* default_x_offset = */0,
|
|
||||||
/* flipmode_x_offset = */0,
|
|
||||||
/* pixel_width = */2040,
|
|
||||||
/* pixel_height = */16 };
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_2040x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if (msg == U8X8_MSG_DISPLAY_SETUP_MEMORY)
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_2040x16_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (msg == U8X8_MSG_DISPLAY_INIT)
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_2040x16_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_2040x16_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,215 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_48x64_winstar.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
/* Winstar 0.71 OLED */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_48x64_winstar_init_seq[] =
|
|
||||||
{
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x03f), /* multiplex ratio, 0.71 OLED: changed from 0x2f to 0x3f */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.71 OLED */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0, 0.71 OLED */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.71 OLED 0x14*/
|
|
||||||
|
|
||||||
/// according to the datasheet, 0x00 is NOT page addressing mode, but horizontal addressing mode;
|
|
||||||
/// so it looks like u8g2 expects horizontal addressing (and the inline comment is wrong) while the Winstar example
|
|
||||||
/// actually uses page addressing (which is the reset default)
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.71 OLED */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.71 OLED */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.71 OLED */
|
|
||||||
U8X8_CA(0x081, 0x07f), /* [2] set contrast control, 0.71 OLED datasheet: 0x7f */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.71 OLED datasheet: 0x22 */
|
|
||||||
U8X8_CA(0x0db, 0x040), /* vcomh deselect level, 0.71 OLED datasheet: 0x40 */
|
|
||||||
|
|
||||||
// U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_48x64_powersave0_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_48x64_powersave1_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_48x64_flip0_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_48x64_flip1_seq[] =
|
|
||||||
{
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_48x64_generic(u8x8_t *u8x8, uint8_t msg,
|
|
||||||
uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_48x64_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_winstar_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if (arg_int == 0)
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if (arg_int == 0)
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081);
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *) arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *) arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *) arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *) arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c * 8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while (arg_int > 0);
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_48x64_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */0,
|
|
||||||
/* chip_disable_level = */1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */20,
|
|
||||||
/* pre_chip_disable_wait_ns = */10,
|
|
||||||
/* reset_pulse_width_ms = */100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */4,
|
|
||||||
/* data_setup_time_ns = */40,
|
|
||||||
/* write_pulse_width_ns = */150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */6,
|
|
||||||
/* tile_height = */8,
|
|
||||||
/* default_x_offset = */40,
|
|
||||||
/* flipmode_x_offset = */40,
|
|
||||||
/* pixel_width = */48,
|
|
||||||
/* pixel_height = */64 };
|
|
||||||
|
|
||||||
/* Winstar 0.71" OLED */
|
|
||||||
uint8_t u8x8_d_ssd1306_48x64_winstar(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
|
|
||||||
void *arg_ptr)
|
|
||||||
{
|
|
||||||
if (msg == U8X8_MSG_DISPLAY_SETUP_MEMORY)
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_48x64_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (msg == U8X8_MSG_DISPLAY_INIT)
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_48x64_winstar_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_48x64_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_64x32.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x32_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x32_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x32_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x32_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_64x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x32_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_noname_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*======================================================*/
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_64x32_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 8,
|
|
||||||
/* tile_height = */ 4,
|
|
||||||
/* default_x_offset = */ 32,
|
|
||||||
/* flipmode_x_offset = */ 32,
|
|
||||||
/* pixel_width = */ 64,
|
|
||||||
/* pixel_height = */ 32
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*======================================================*/
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x32_noname_init_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x02f), /* multiplex ratio: changed from 0x1f to 0x2f */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1 */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control datasheet: 0xcf */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1 */
|
|
||||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_64x32_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x32_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_noname_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_64x32_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*======================================================*/
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x32_1f_init_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x01f), /* multiplex ratio: changed from 0x1f to 0x2f, 23 Sep 17: changed back to 1f */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1 */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
|
||||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control datasheet: 0xcf */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1 */
|
|
||||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t u8x8_d_ssd1306_64x32_1f(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x32_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x32_1f_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_64x32_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_64x48.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* EastRising 0.66 OLED */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x48_er_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x02f), /* multiplex ratio, 0.66 OLED: changed from 0x1f to 0x2f */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.66 OLED */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0, 0.66 OLED */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.66 OLED 0x14*/
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
|
||||||
U8X8_CA(0x081, 0x0cf), /* [2] set contrast control, 0.66 OLED datasheet: 0xcf */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.66 OLED datasheet: 0x22 */
|
|
||||||
U8X8_CA(0x0db, 0x000), /* vcomh deselect level, 0.66 OLED datasheet: 0x00 */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x48_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x48_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x48_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_64x48_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_64x48_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x48_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_er_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_64x48_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 8,
|
|
||||||
/* tile_height = */ 6,
|
|
||||||
/* default_x_offset = */ 32,
|
|
||||||
/* flipmode_x_offset = */ 32,
|
|
||||||
/* pixel_width = */ 64,
|
|
||||||
/* pixel_height = */ 48
|
|
||||||
};
|
|
||||||
|
|
||||||
/* East Rising 0.66" OLED */
|
|
||||||
uint8_t u8x8_d_ssd1306_64x48_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_64x48_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_64x48_er_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_64x48_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_72x40.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2019, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
EastRising 0.41 OLED
|
|
||||||
https://www.buydisplay.com/default/white-0-42-inch-oled-display-panel-72x40-iic-i2c-serial-spi-ssd1306
|
|
||||||
|
|
||||||
|
|
||||||
command(0xae);//--turn off oled panel
|
|
||||||
|
|
||||||
command(0xd5);//--set display clock divide ratio/oscillator frequency
|
|
||||||
command(0x80);//--set divide ratio
|
|
||||||
|
|
||||||
command(0xa8);//--set multiplex ratio
|
|
||||||
command(0x27);//--1/40 duty
|
|
||||||
|
|
||||||
command(0xd3);//-set display offset
|
|
||||||
command(0x00);//-not offset
|
|
||||||
|
|
||||||
command(0xad);//--Internal IREF Setting
|
|
||||||
command(0x30);//--
|
|
||||||
|
|
||||||
command(0x8d);//--set Charge Pump enable/disable
|
|
||||||
command(0x14);//--set(0x10) disable
|
|
||||||
|
|
||||||
command(0x40);//--set start line address
|
|
||||||
|
|
||||||
command(0xa6);//--set normal display
|
|
||||||
|
|
||||||
command(0xa4);//Disable Entire Display On
|
|
||||||
|
|
||||||
command(0xa1);//--set segment re-map 128 to 0
|
|
||||||
|
|
||||||
command(0xC8);//--Set COM Output Scan Direction 64 to 0
|
|
||||||
|
|
||||||
command(0xda);//--set com pins hardware configuration
|
|
||||||
command(0x12);
|
|
||||||
|
|
||||||
command(0x81);//--set contrast control register
|
|
||||||
command(0xaf);
|
|
||||||
|
|
||||||
command(0xd9);//--set pre-charge period
|
|
||||||
command(0x22);
|
|
||||||
|
|
||||||
command(0xdb);//--set vcomh
|
|
||||||
command(0x20);
|
|
||||||
|
|
||||||
command(0xaf);//--turn on oled panel
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
static const uint8_t u8x8_d_ssd1306_72x40_er_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x027), /* multiplex ratio, 0.42 OLED: 0x27*/
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.42 OLED */
|
|
||||||
U8X8_CA(0x0ad, 0x030), /* Internal IREF Setting for the 0.42 OLED, see also issue https://github.com/olikraus/u8g2/issues/1047 */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.66 OLED 0x14*/
|
|
||||||
|
|
||||||
U8X8_C(0x040), /* set display start line to 0, 0.66 OLED */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
|
||||||
U8X8_CA(0x081, 0x0af), /* [2] set contrast control, 0.42 OLED */
|
|
||||||
U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1, 0.42 OLED datasheet: 0x22 */
|
|
||||||
U8X8_CA(0x0db, 0x020), /* vcomh deselect level, 0.42 OLED datasheet: 0x20 */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_72x40_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_72x40_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_72x40_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_72x40_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_72x40_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_72x40_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_er_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_72x40_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 9,
|
|
||||||
/* tile_height = */ 5,
|
|
||||||
/* default_x_offset = */ 28,
|
|
||||||
/* flipmode_x_offset = */ 28,
|
|
||||||
/* pixel_width = */ 72,
|
|
||||||
/* pixel_height = */ 40
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
EastRising 0.41 OLED
|
|
||||||
https://www.buydisplay.com/default/white-0-42-inch-oled-display-panel-72x40-iic-i2c-serial-spi-ssd1306
|
|
||||||
*/
|
|
||||||
uint8_t u8x8_d_ssd1306_72x40_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_72x40_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_72x40_er_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_72x40_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
u8x8_d_ssd1306_96x16.c
|
|
||||||
|
|
||||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
|
||||||
|
|
||||||
Copyright (c) 2016, olikraus@gmail.com
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
||||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "u8x8.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* EastRising 0.69 OLED */
|
|
||||||
static const uint8_t u8x8_d_ssd1306_96x16_er_init_seq[] = {
|
|
||||||
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
|
|
||||||
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
|
||||||
U8X8_CA(0x0a8, 0x00f), /* multiplex ratio, 0.69 OLED: 0x0f */
|
|
||||||
U8X8_CA(0x0d3, 0x000), /* display offset, 0.69 OLED */
|
|
||||||
U8X8_C(0x040), /* set display start line to 0, 0.69 OLED */
|
|
||||||
U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable, 0.66 OLED 0x14*/
|
|
||||||
U8X8_CA(0x020, 0x000), /* horizontal addressing mode */
|
|
||||||
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1, 0.66 OLED */
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse, 0.66 OLED */
|
|
||||||
// Flipmode
|
|
||||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
|
|
||||||
U8X8_CA(0x0da, 0x002), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), 0.66 OLED */
|
|
||||||
U8X8_CA(0x081, 0x0af), /* [2] set contrast control, 0.69 OLED datasheet: 0xaf */
|
|
||||||
U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x0f1, 0.69 OLED datasheet: 0xf1 */
|
|
||||||
U8X8_CA(0x0db, 0x020), /* vcomh deselect level, 0.69 OLED datasheet: 0x20 */
|
|
||||||
|
|
||||||
U8X8_C(0x02e), /* Deactivate scroll */
|
|
||||||
U8X8_C(0x0a4), /* output ram to display */
|
|
||||||
U8X8_C(0x0a6), /* none inverted normal display mode */
|
|
||||||
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_96x16_powersave0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0af), /* display on */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_96x16_powersave1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0ae), /* display off */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_96x16_flip0_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t u8x8_d_ssd1306_96x16_flip1_seq[] = {
|
|
||||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
|
||||||
U8X8_C(0x0a0), /* segment remap a0/a1*/
|
|
||||||
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
|
||||||
U8X8_END_TRANSFER(), /* disable chip */
|
|
||||||
U8X8_END() /* end of sequence */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t u8x8_d_ssd1306_96x16_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
uint8_t x, c;
|
|
||||||
uint8_t *ptr;
|
|
||||||
switch(msg)
|
|
||||||
{
|
|
||||||
/* handled by the calling function
|
|
||||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_96x16_display_info);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_INIT:
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_er_init_seq);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_powersave0_seq);
|
|
||||||
else
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_powersave1_seq);
|
|
||||||
break;
|
|
||||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
|
||||||
if ( arg_int == 0 )
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_flip0_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_flip1_seq);
|
|
||||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef U8X8_WITH_SET_CONTRAST
|
|
||||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x081 );
|
|
||||||
u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
|
||||||
u8x8_cad_StartTransfer(u8x8);
|
|
||||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
|
||||||
x *= 8;
|
|
||||||
x += u8x8->x_offset;
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
|
|
||||||
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
|
||||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
|
||||||
u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
|
|
||||||
arg_int--;
|
|
||||||
} while( arg_int > 0 );
|
|
||||||
|
|
||||||
u8x8_cad_EndTransfer(u8x8);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const u8x8_display_info_t u8x8_ssd1306_96x16_display_info =
|
|
||||||
{
|
|
||||||
/* chip_enable_level = */ 0,
|
|
||||||
/* chip_disable_level = */ 1,
|
|
||||||
|
|
||||||
/* post_chip_enable_wait_ns = */ 20,
|
|
||||||
/* pre_chip_disable_wait_ns = */ 10,
|
|
||||||
/* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */
|
|
||||||
/* post_reset_wait_ms = */ 100, /* OLEDs need much longer setup time */
|
|
||||||
/* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */
|
|
||||||
/* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
|
|
||||||
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns, increased to 8MHz (issue 215) */
|
|
||||||
/* spi_mode = */ 0, /* active high, rising edge */
|
|
||||||
/* i2c_bus_clock_100kHz = */ 4,
|
|
||||||
/* data_setup_time_ns = */ 40,
|
|
||||||
/* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */
|
|
||||||
/* tile_width = */ 12,
|
|
||||||
/* tile_height = */ 2,
|
|
||||||
/* default_x_offset = */ 0,
|
|
||||||
/* flipmode_x_offset = */ 32,
|
|
||||||
/* pixel_width = */ 96,
|
|
||||||
/* pixel_height = */ 16
|
|
||||||
};
|
|
||||||
|
|
||||||
/* East Rising 0.69" OLED */
|
|
||||||
uint8_t u8x8_d_ssd1306_96x16_er(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
{
|
|
||||||
if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1306_96x16_display_info);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( msg == U8X8_MSG_DISPLAY_INIT )
|
|
||||||
{
|
|
||||||
u8x8_d_helper_display_init(u8x8);
|
|
||||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_96x16_er_init_seq);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return u8x8_d_ssd1306_96x16_generic(u8x8, msg, arg_int, arg_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user