Skip to content

Commit

Permalink
Display driver fixes for non-functioning displays (OpenStickCommunity…
Browse files Browse the repository at this point in the history
…#974)

* Added debug mode to display addon & drivers

* Fixed hang issue in debug mode

* Removed debug mode options.
Added new buffer copying method for 132x64 SH1106 displays.

* Removed remaining debug mode references.
Added extra SH1106 check.

* Fix issue where drawPixel x position goes beyond the bounds of the display area.

* Added refresh check when custom button layouts are in use.

* Added Rock Band/Guitar Hero layouts.

* Fixed issue with missing setPower functionality on new screen driver.

* Implemented button layout API functionality to Display configuration, removing the need for hard-coded layout selections.
Added 6GAWD layouts (stick & all button)
  • Loading branch information
mikepparks authored Apr 27, 2024
1 parent 3336200 commit 922acab
Show file tree
Hide file tree
Showing 15 changed files with 454 additions and 103 deletions.
83 changes: 83 additions & 0 deletions headers/buttonlayouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,22 @@
{GP_ELEMENT_DIR_BUTTON, { 18, 32, 52, 36, 1, 1, GAMEPAD_MASK_UP, GP_SHAPE_SQUARE, 0, 0, 0}},\
}

#define BUTTON_GROUP_BANDHERO_FRET_A {\
{GP_ELEMENT_BTN_BUTTON, { 5, 26, 14, 36, 1, 1, GAMEPAD_MASK_B2, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 18, 26, 27, 36, 1, 1, GAMEPAD_MASK_B1, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 31, 26, 40, 36, 1, 1, GAMEPAD_MASK_B4, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 44, 26, 53, 36, 1, 1, GAMEPAD_MASK_B3, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 57, 26, 66, 36, 1, 1, GAMEPAD_MASK_L2, GP_SHAPE_SQUARE, 0, 0, 0}},\
}

#define BUTTON_GROUP_BANDHERO_STRUM_A {\
{GP_ELEMENT_DIR_BUTTON, { 21, 27, 45, 30, 1, 1, GAMEPAD_MASK_DOWN, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_DIR_BUTTON, { 21, 32, 45, 35, 1, 1, GAMEPAD_MASK_UP, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_LEVER, { 54, 16, 5, 5, 1, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 14, 44, 4, 4, 1, 1, GAMEPAD_MASK_S1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, { 6, 50, 4, 4, 1, 1, GAMEPAD_MASK_S2, GP_SHAPE_ELLIPSE}},\
}

#define BUTTON_GROUP_DANCEPAD_DDR_RIGHT {\
{GP_ELEMENT_BTN_BUTTON, { 69, 29, 84, 44, 1, 1, GAMEPAD_MASK_B3, GP_SHAPE_SQUARE}},\
{GP_ELEMENT_BTN_BUTTON, { 86, 46, 101, 61, 1, 1, GAMEPAD_MASK_B1, GP_SHAPE_SQUARE}},\
Expand Down Expand Up @@ -461,4 +477,71 @@
{GP_ELEMENT_DIR_BUTTON, { 75, 32, 109, 36, 1, 1, GAMEPAD_MASK_UP, GP_SHAPE_SQUARE, 0, 0, 0}},\
}

#define BUTTON_GROUP_BANDHERO_FRET_B {\
{GP_ELEMENT_BTN_BUTTON, {113, 26, 122, 36, 1, 1, GAMEPAD_MASK_B2, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, {100, 26, 109, 36, 1, 1, GAMEPAD_MASK_B1, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 87, 26, 96, 36, 1, 1, GAMEPAD_MASK_B4, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 74, 26, 83, 36, 1, 1, GAMEPAD_MASK_B3, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, { 61, 26, 70, 36, 1, 1, GAMEPAD_MASK_L2, GP_SHAPE_SQUARE, 0, 0, 0}},\
}

#define BUTTON_GROUP_BANDHERO_STRUM_B {\
{GP_ELEMENT_DIR_BUTTON, { 75, 26, 109, 30, 1, 1, GAMEPAD_MASK_DOWN, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_DIR_BUTTON, { 75, 32, 109, 36, 1, 1, GAMEPAD_MASK_UP, GP_SHAPE_SQUARE, 0, 0, 0}},\
{GP_ELEMENT_LEVER, { 72, 16, 5, 5, 1, 0, 0, 0}},\
{GP_ELEMENT_BTN_BUTTON, {113, 44, 4, 4, 1, 1, GAMEPAD_MASK_S1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {120, 50, 4, 4, 1, 1, GAMEPAD_MASK_S2, GP_SHAPE_ELLIPSE}},\
}

#define BUTTON_GROUP_6GAWD_A {\
{GP_ELEMENT_LEVER, { 22, 30, 10, 10, 1, 0, 0}}\
}

#define BUTTON_GROUP_6GAWD_B {\
{GP_ELEMENT_BTN_BUTTON, {69, 25, 6, 6, 1, 1, GAMEPAD_MASK_B3, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {81, 16, 6, 6, 1, 1, GAMEPAD_MASK_B4, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {95, 16, 6, 6, 1, 1, GAMEPAD_MASK_R1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {109,24, 7, 7, 1, 1, GAMEPAD_MASK_L1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {69, 43, 6, 6, 1, 1, GAMEPAD_MASK_B1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {81, 34, 6, 6, 1, 1, GAMEPAD_MASK_B2, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {95, 34, 6, 6, 1, 1, GAMEPAD_MASK_R2, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {58, 53, 7, 7, 1, 1, GAMEPAD_MASK_L2, GP_SHAPE_ELLIPSE}}\
}

#define BUTTON_GROUP_6GAWD_ALLBUTTON_A {\
{GP_ELEMENT_DIR_BUTTON, {22, 28, 6, 6, 1, 1, GAMEPAD_MASK_LEFT, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_DIR_BUTTON, {40, 28, 6, 6, 1, 1, GAMEPAD_MASK_DOWN, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_DIR_BUTTON, {56, 32, 6, 6, 1, 1, GAMEPAD_MASK_RIGHT, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_DIR_BUTTON, {58, 53, 7, 7, 1, 1, GAMEPAD_MASK_UP, GP_SHAPE_ELLIPSE}}\
}

#define BUTTON_GROUP_6GAWD_ALLBUTTON_B {\
{GP_ELEMENT_BTN_BUTTON, {69, 25, 6, 6, 1, 1, GAMEPAD_MASK_B3, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {81, 16, 6, 6, 1, 1, GAMEPAD_MASK_B4, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {95, 16, 6, 6, 1, 1, GAMEPAD_MASK_R1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {109,24, 7, 7, 1, 1, GAMEPAD_MASK_L1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {69, 43, 6, 6, 1, 1, GAMEPAD_MASK_B1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {81, 34, 6, 6, 1, 1, GAMEPAD_MASK_B2, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {95, 34, 6, 6, 1, 1, GAMEPAD_MASK_R2, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {80, 53, 7, 7, 1, 1, GAMEPAD_MASK_L2, GP_SHAPE_ELLIPSE}}\
}

#define BUTTON_GROUP_6GAWD_ALLBUTTONPLUS_A {\
{GP_ELEMENT_BTN_BUTTON, {12, 32, 6, 6, 1, 1, GAMEPAD_MASK_L2, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_DIR_BUTTON, {26, 28, 6, 6, 1, 1, GAMEPAD_MASK_LEFT, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_DIR_BUTTON, {40, 28, 6, 6, 1, 1, GAMEPAD_MASK_DOWN, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_DIR_BUTTON, {54, 33, 6, 6, 1, 1, GAMEPAD_MASK_RIGHT, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_DIR_BUTTON, {58, 53, 7, 7, 1, 1, GAMEPAD_MASK_UP, GP_SHAPE_ELLIPSE}},\
}

#define BUTTON_GROUP_6GAWD_ALLBUTTONPLUS_B {\
{GP_ELEMENT_BTN_BUTTON, {69, 25, 6, 6, 1, 1, GAMEPAD_MASK_B3, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {81, 16, 6, 6, 1, 1, GAMEPAD_MASK_B4, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {95, 16, 6, 6, 1, 1, GAMEPAD_MASK_R1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {109,24, 7, 7, 1, 1, GAMEPAD_MASK_L1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {69, 43, 6, 6, 1, 1, GAMEPAD_MASK_B1, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {81, 34, 6, 6, 1, 1, GAMEPAD_MASK_B2, GP_SHAPE_ELLIPSE}},\
{GP_ELEMENT_BTN_BUTTON, {95, 34, 6, 6, 1, 1, GAMEPAD_MASK_R2, GP_SHAPE_ELLIPSE}}\
}

#endif
3 changes: 3 additions & 0 deletions headers/display/ui/screens/ButtonLayoutScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,14 @@ class ButtonLayoutScreen : public GPScreen {
uint8_t prevLayoutLeft = 0;
uint8_t prevLayoutRight = 0;
uint8_t prevProfileNumber = 0;
ButtonLayoutParamsLeft prevLeftOptions;
ButtonLayoutParamsRight prevRightOptions;

bool macroEnabled;

uint16_t map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
void processInputHistory();
bool compareCustomLayouts();
bool pressedUp();
bool pressedDown();
bool pressedLeft();
Expand Down
11 changes: 11 additions & 0 deletions headers/interfaces/i2c/ssd1306/tiny_ssd1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class GPGFX_TinySSD1306 : public GPGFX_DisplayBase {
void drawSprite(uint8_t* spriteData, uint16_t width, uint16_t height, uint16_t pitch, uint16_t x, uint16_t y, uint8_t priority);

void drawBuffer(uint8_t *pBuffer);

bool isSH1106(int detectedDisplay);
private:
typedef enum {
SET_LOW_COLUMN = 0x00,
Expand Down Expand Up @@ -60,6 +62,13 @@ class GPGFX_TinySSD1306 : public GPGFX_DisplayBase {
SET_VCOM_DETECT = 0xDB,
} CommandOps;

typedef enum {
SCREEN_128x64_MAIN = 3,
SCREEN_128x64_ALT0 = 6,
SCREEN_128x64_ALT1 = 7,
SCREEN_132x64 = 8,
} ScreenAlternatives;

bool _isPowered = false;

static const uint16_t MAX_SCREEN_WIDTH = 128;
Expand All @@ -73,6 +82,8 @@ class GPGFX_TinySSD1306 : public GPGFX_DisplayBase {

uint8_t frameBuffer[MAX_SCREEN_SIZE];
uint8_t framePage = 0;

uint8_t screenType;
};

#endif
10 changes: 10 additions & 0 deletions headers/layoutmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ class LayoutManager {
LayoutList drawBM7KeyA();
LayoutList drawGitadoraFretA();
LayoutList drawGitadoraStrumA();
LayoutList drawBandHeroFretA();
LayoutList drawBandHeroStrumA();
LayoutList draw6GAWDLeft();
LayoutList draw6GAWDAllButtonLeft();
LayoutList draw6GAWDAllButtonPlusLeft();
LayoutList drawDancepadDDRRight();
LayoutList drawDancepadPIURight();
LayoutList drawPopnB();
Expand All @@ -118,6 +123,11 @@ class LayoutManager {
LayoutList drawBM7KeyB();
LayoutList drawGitadoraFretB();
LayoutList drawGitadoraStrumB();
LayoutList drawBandHeroFretB();
LayoutList drawBandHeroStrumB();
LayoutList draw6GAWDRight();
LayoutList draw6GAWDAllButtonRight();
LayoutList draw6GAWDAllButtonPlusRight();
private:
LayoutManager(){}

Expand Down
1 change: 1 addition & 0 deletions lib/OneBitDisplay/OneBitDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ uint8_t mode; // data/command mode for 9-bit SPI
uint8_t iDCPin, iMOSIPin, iCLKPin, iCSPin;
uint8_t iLEDPin; // backlight
uint8_t bBitBang;
uint8_t registerValue;
} OBDISP;

typedef char * (*SIMPLECALLBACK)(int iMenuItem);
Expand Down
10 changes: 10 additions & 0 deletions proto/enums.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ enum ButtonLayout
BUTTON_LAYOUT_GITADORA_FRET_A = 25;
BUTTON_LAYOUT_GITADORA_STRUM_A = 26;
BUTTON_LAYOUT_BOARD_DEFINED_A = 27;
BUTTON_LAYOUT_BANDHERO_FRET_A = 28;
BUTTON_LAYOUT_BANDHERO_STRUM_A = 29;
BUTTON_LAYOUT_6GAWD_A = 30;
BUTTON_LAYOUT_6GAWD_ALLBUTTON_A = 31;
BUTTON_LAYOUT_6GAWD_ALLBUTTONPLUS_A = 32;
}

enum ButtonLayoutRight
Expand Down Expand Up @@ -72,6 +77,11 @@ enum ButtonLayoutRight
BUTTON_LAYOUT_GITADORA_FRET_B = 29;
BUTTON_LAYOUT_GITADORA_STRUM_B = 30;
BUTTON_LAYOUT_BOARD_DEFINED_B = 31;
BUTTON_LAYOUT_BANDHERO_FRET_B = 32;
BUTTON_LAYOUT_BANDHERO_STRUM_B = 33;
BUTTON_LAYOUT_6GAWD_B = 34;
BUTTON_LAYOUT_6GAWD_ALLBUTTON_B = 35;
BUTTON_LAYOUT_6GAWD_ALLBUTTONPLUS_B = 36;
}

enum SplashMode
Expand Down
4 changes: 1 addition & 3 deletions src/addons/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ bool DisplayAddon::available() {
}

void DisplayAddon::setup() {
//stdio_init_all();
const DisplayOptions& options = Storage::getInstance().getDisplayOptions();
PeripheralI2C* i2c = PeripheralManager::getInstance().getI2C(options.i2cBlock);

Expand Down Expand Up @@ -111,8 +110,7 @@ bool DisplayAddon::updateDisplayScreen() {
prevDisplayMode = currDisplayMode;
return true;
}

return false;
return true;
}

bool DisplayAddon::isDisplayPowerOff()
Expand Down
15 changes: 14 additions & 1 deletion src/display/ui/screens/ButtonLayoutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void ButtonLayoutScreen::init() {
prevProfileNumber = -1;
prevLayoutLeft = Storage::getInstance().getDisplayOptions().buttonLayout;
prevLayoutRight = Storage::getInstance().getDisplayOptions().buttonLayoutRight;
prevLeftOptions = Storage::getInstance().getDisplayOptions().buttonLayoutCustomOptions.paramsLeft;
prevRightOptions = Storage::getInstance().getDisplayOptions().buttonLayoutCustomOptions.paramsRight;

// we cannot look at macro options enabled, pull the pins

Expand Down Expand Up @@ -76,7 +78,7 @@ int8_t ButtonLayoutScreen::update() {
uint8_t layoutLeft = Storage::getInstance().getDisplayOptions().buttonLayout;
uint8_t layoutRight = Storage::getInstance().getDisplayOptions().buttonLayoutRight;
bool inputHistoryEnabled = Storage::getInstance().getAddonOptions().inputHistoryOptions.enabled;
if ((prevLayoutLeft != layoutLeft) || (prevLayoutRight != layoutRight) || (isInputHistoryEnabled != inputHistoryEnabled)) {
if ((prevLayoutLeft != layoutLeft) || (prevLayoutRight != layoutRight) || (isInputHistoryEnabled != inputHistoryEnabled) || compareCustomLayouts()) {
shutdown();
init();
}
Expand Down Expand Up @@ -362,6 +364,17 @@ void ButtonLayoutScreen::processInputHistory() {
footer = historyString;
}

bool ButtonLayoutScreen::compareCustomLayouts()
{
ButtonLayoutParamsLeft leftOptions = Storage::getInstance().getDisplayOptions().buttonLayoutCustomOptions.paramsLeft;
ButtonLayoutParamsRight rightOptions = Storage::getInstance().getDisplayOptions().buttonLayoutCustomOptions.paramsRight;

bool leftChanged = ((leftOptions.layout != prevLeftOptions.layout) || (leftOptions.common.startX != prevLeftOptions.common.startX) || (leftOptions.common.startY != prevLeftOptions.common.startY) || (leftOptions.common.buttonPadding != prevLeftOptions.common.buttonPadding) || (leftOptions.common.buttonRadius != prevLeftOptions.common.buttonRadius));
bool rightChanged = ((rightOptions.layout != prevRightOptions.layout) || (rightOptions.common.startX != prevRightOptions.common.startX) || (rightOptions.common.startY != prevRightOptions.common.startY) || (rightOptions.common.buttonPadding != prevRightOptions.common.buttonPadding) || (rightOptions.common.buttonRadius != prevRightOptions.common.buttonRadius));

return (leftChanged || rightChanged);
}

bool ButtonLayoutScreen::pressedUp()
{
switch (getGamepad()->getOptions().dpadMode)
Expand Down
98 changes: 85 additions & 13 deletions src/interfaces/i2c/ssd1306/tiny_ssd1306.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ void GPGFX_TinySSD1306::init(GPGFX_DisplayTypeOptions options) {
_options.inverted = options.inverted;
_options.font = options.font;

_options.i2c->readRegister(_options.address, 0x00, &this->screenType, 1);
this->screenType &= 0x0F;

if (isSH1106(this->screenType)) {
this->screenType = SCREEN_132x64;
}

uint8_t commands[] = {
0x00,
CommandOps::DISPLAY_OFF,
Expand Down Expand Up @@ -59,8 +66,48 @@ void GPGFX_TinySSD1306::init(GPGFX_DisplayTypeOptions options) {
drawBuffer(NULL);
}

bool GPGFX_TinySSD1306::isSH1106(int detectedDisplay) {

this->setPower(false);

const uint8_t RANDOM_DATA[] = { 0xbf, 0x88, 0x13, 0x41, 0x00 };
uint8_t buffer[4];
uint8_t i = 0;
for (; i < sizeof(RANDOM_DATA); ++i) {
buffer[0] = 0x80; // one command
buffer[1] = 0xE0; // read-modify-write
buffer[2] = 0xC0; // one data
if (_options.i2c->write(_options.address, buffer, 3, false) == 0) {
break;
}

// Read two bytes back, the first byte is a dummy read and the second byte is the byte was actually want.
if (_options.i2c->read(_options.address, buffer, 2, false) == 0) {
break;
}

// Check whether the byte we read is the byte we previously wrote.
if (i > 0 && buffer[1] != RANDOM_DATA[i - 1]) {
break;
}

// Write the current byte, we will attempt to read it in the next loop iteration.
buffer[0] = 0xc0; // one data
buffer[1] = RANDOM_DATA[i]; // data byte
buffer[2] = 0x80; // one command
buffer[3] = 0xEE; // end read-modify-write
if (_options.i2c->write(_options.address, buffer, 4, false) == 0) {
break;
}
}

this->setPower(true);
return i == sizeof(RANDOM_DATA);
}

void GPGFX_TinySSD1306::setPower(bool isPowered) {
_isPowered = isPowered;
sendCommand(_isPowered ? CommandOps::DISPLAY_ON : CommandOps::DISPLAY_OFF);
}

void GPGFX_TinySSD1306::clear() {
Expand All @@ -72,7 +119,13 @@ void GPGFX_TinySSD1306::drawPixel(uint8_t x, uint8_t y, uint32_t color) {

if ((x<MAX_SCREEN_WIDTH) and (y<MAX_SCREEN_HEIGHT))
{
row=((y/8)*128)+x;
if (this->screenType == ScreenAlternatives::SCREEN_132x64) {
x+=2;
}

if (x>=MAX_SCREEN_WIDTH) return;

row=((y/8)*MAX_SCREEN_WIDTH)+x;
bitIndex=y % 8;

if (color == 1) {
Expand Down Expand Up @@ -317,18 +370,37 @@ void GPGFX_TinySSD1306::drawBuffer(uint8_t* pBuffer) {

int result = -1;

sendCommand(CommandOps::PAGE_ADDRESS);
sendCommand(0x00);
sendCommand(0x07);
sendCommand(CommandOps::COLUMN_ADDRESS);
sendCommand(0x00);
sendCommand(0x7F);
if (pBuffer == NULL) {
memcpy(&buffer[1],frameBuffer,bufferSize);
} else {
memcpy(&buffer[1],pBuffer,bufferSize);
}
result = _options.i2c->write(_options.address, buffer, sizeof(buffer), false);
if (this->screenType == ScreenAlternatives::SCREEN_132x64) {
uint16_t x = 0;
uint16_t y = 0;
for (y = 0; y < (MAX_SCREEN_HEIGHT/8); y++) {
sendCommand(0xB0 + y);
sendCommand(x & 0x0F);
sendCommand(0x10 | (x >> 4));

if (pBuffer == NULL) {
memcpy(&buffer[1],&frameBuffer[y*MAX_SCREEN_WIDTH],MAX_SCREEN_WIDTH);
} else {
memcpy(&buffer[1],&pBuffer[y*MAX_SCREEN_WIDTH],MAX_SCREEN_WIDTH);
}

result = _options.i2c->write(_options.address, buffer, MAX_SCREEN_WIDTH+3, false);
}
} else {
sendCommand(CommandOps::PAGE_ADDRESS);
sendCommand(0x00);
sendCommand(0x07);
sendCommand(CommandOps::COLUMN_ADDRESS);
sendCommand(0x00);
sendCommand(0x7F);

if (pBuffer == NULL) {
memcpy(&buffer[1],frameBuffer,bufferSize);
} else {
memcpy(&buffer[1],pBuffer,bufferSize);
}
result = _options.i2c->write(_options.address, buffer, sizeof(buffer), false);
}

if (framePage < MAX_SCREEN_HEIGHT/8) {
framePage++;
Expand Down
Loading

0 comments on commit 922acab

Please sign in to comment.