[OLED] shrink codeside of draw swapped
This commit is contained in:
@@ -22,6 +22,7 @@ bool OLED::inLeftHandedMode; // Whether the screen is in left or not (used for
|
|||||||
OLED::DisplayState OLED::displayState;
|
OLED::DisplayState OLED::displayState;
|
||||||
uint8_t OLED::fontWidth, OLED::fontHeight;
|
uint8_t OLED::fontWidth, OLED::fontHeight;
|
||||||
int16_t OLED::cursor_x, OLED::cursor_y;
|
int16_t OLED::cursor_x, OLED::cursor_y;
|
||||||
|
bool OLED::initDone = false;
|
||||||
uint8_t OLED::displayOffset;
|
uint8_t OLED::displayOffset;
|
||||||
uint8_t OLED::screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
|
uint8_t OLED::screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
|
||||||
uint8_t OLED::secondFrameBuffer[OLED_WIDTH * 2];
|
uint8_t OLED::secondFrameBuffer[OLED_WIDTH * 2];
|
||||||
@@ -102,6 +103,7 @@ void OLED::initialize() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setDisplayState(DisplayState::ON);
|
setDisplayState(DisplayState::ON);
|
||||||
|
initDone = true;
|
||||||
}
|
}
|
||||||
void OLED::setFramebuffer(uint8_t *buffer) {
|
void OLED::setFramebuffer(uint8_t *buffer) {
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
@@ -390,16 +392,14 @@ void OLED::drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, co
|
|||||||
|
|
||||||
if (y == 0) {
|
if (y == 0) {
|
||||||
// Splat first line of data
|
// Splat first line of data
|
||||||
for (uint8_t xx = visibleStart; xx < visibleEnd; xx += 2) {
|
for (uint8_t xx = visibleStart; xx < visibleEnd; xx ++) {
|
||||||
firstStripPtr[xx + x] = ptr[xx + 1];
|
firstStripPtr[xx + x] = ptr[xx + 1];
|
||||||
firstStripPtr[xx + x + 1] = ptr[xx];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (y == 8 || height == 16) {
|
if (y == 8 || height == 16) {
|
||||||
// Splat the second line
|
// Splat the second line
|
||||||
for (uint8_t xx = visibleStart; xx < visibleEnd; xx += 2) {
|
for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) {
|
||||||
secondStripPtr[x + xx] = ptr[xx + 1 + (height == 16 ? wide : 0)];
|
secondStripPtr[x + xx] = ptr[xx + 1 + (height == 16 ? wide : 0)];
|
||||||
secondStripPtr[x + xx + 1] = ptr[xx + (height == 16 ? wide : 0)];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -481,3 +481,7 @@ void OLED::drawHeatSymbol(uint8_t state) {
|
|||||||
drawSymbol(14);
|
drawSymbol(14);
|
||||||
drawFilledRect(cursor_x_temp, 0, cursor_x_temp + 12, 2 + (8 - state), true);
|
drawFilledRect(cursor_x_temp, 0, cursor_x_temp + 12, 2 + (8 - state), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OLED::isInitDone() {
|
||||||
|
return initDone;
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void initialize(); // Startup the I2C coms (brings screen out of reset etc)
|
static void initialize(); // Startup the I2C coms (brings screen out of reset etc)
|
||||||
|
static bool isInitDone();
|
||||||
// Draw the buffer out to the LCD using the DMA Channel
|
// Draw the buffer out to the LCD using the DMA Channel
|
||||||
static void refresh() {
|
static void refresh() {
|
||||||
FRToSI2C::Transmit( DEVICEADDR_OLED, screenBuffer,
|
FRToSI2C::Transmit( DEVICEADDR_OLED, screenBuffer,
|
||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
static int16_t getCursorX() {
|
static int16_t getCursorX() {
|
||||||
return cursor_x;
|
return cursor_x;
|
||||||
}
|
}
|
||||||
static void print(const char *string);// Draw a string to the current location, with current font
|
static void print(const char *string); // Draw a string to the current location, with current font
|
||||||
// Set the cursor location by pixels
|
// Set the cursor location by pixels
|
||||||
static void setCursor(int16_t x, int16_t y) {
|
static void setCursor(int16_t x, int16_t y) {
|
||||||
cursor_x = x;
|
cursor_x = x;
|
||||||
@@ -73,8 +73,7 @@ public:
|
|||||||
drawArea(x, 0, width, 16, buffer);
|
drawArea(x, 0, width, 16, buffer);
|
||||||
}
|
}
|
||||||
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
||||||
static void printNumber(uint16_t number, uint8_t places,
|
static void printNumber(uint16_t number, uint8_t places, bool noLeaderZeros = true);
|
||||||
bool noLeaderZeros = true);
|
|
||||||
// Draws a number at the current cursor location
|
// Draws a number at the current cursor location
|
||||||
// Clears the buffer
|
// Clears the buffer
|
||||||
static void clearScreen() {
|
static void clearScreen() {
|
||||||
@@ -89,15 +88,11 @@ public:
|
|||||||
drawSymbol((state) ? 16 : 17);
|
drawSymbol((state) ? 16 : 17);
|
||||||
}
|
}
|
||||||
static void debugNumber(int32_t val);
|
static void debugNumber(int32_t val);
|
||||||
static void drawSymbol(uint8_t symbolID);//Used for drawing symbols of a predictable width
|
static void drawSymbol(uint8_t symbolID); //Used for drawing symbols of a predictable width
|
||||||
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); //Draw an area, but y must be aligned on 0/8 offset
|
||||||
const uint8_t *ptr); //Draw an area, but y must be aligned on 0/8 offset
|
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); //Draw an area, but y must be aligned on 0/8 offset
|
||||||
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide,
|
static void fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t value); //Fill an area, but y must be aligned on 0/8 offset
|
||||||
uint8_t height, const uint8_t *ptr); //Draw an area, but y must be aligned on 0/8 offset
|
static void drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, bool clear);
|
||||||
static void fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
|
||||||
const uint8_t value); //Fill an area, but y must be aligned on 0/8 offset
|
|
||||||
static void drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
|
|
||||||
bool clear);
|
|
||||||
static void drawHeatSymbol(uint8_t state);
|
static void drawHeatSymbol(uint8_t state);
|
||||||
static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator
|
static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator
|
||||||
static void transitionSecondaryFramebuffer(bool forwardNavigation);
|
static void transitionSecondaryFramebuffer(bool forwardNavigation);
|
||||||
@@ -109,6 +104,7 @@ private:
|
|||||||
static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
||||||
static uint8_t *secondStripPtr; //Pointers to the strips
|
static uint8_t *secondStripPtr; //Pointers to the strips
|
||||||
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
|
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
|
||||||
|
static bool initDone;
|
||||||
static DisplayState displayState;
|
static DisplayState displayState;
|
||||||
static uint8_t fontWidth, fontHeight;
|
static uint8_t fontWidth, fontHeight;
|
||||||
static int16_t cursor_x, cursor_y;
|
static int16_t cursor_x, cursor_y;
|
||||||
|
|||||||
Reference in New Issue
Block a user