diff --git a/src/display.c b/src/display.c index 67c9fd4..2dd5512 100644 --- a/src/display.c +++ b/src/display.c @@ -29,6 +29,6 @@ void display_show_version(void) { void display_splash(void) { // Print the splash screen directly to the OLED oled_clearScreen(); - oled_DrawArea(0, 0, 96, 16, logo_buffer); + oled_DrawArea(OLED_AREA_X, OLED_AREA_Y, 96, 16, logo_buffer); oled_Refresh(); } diff --git a/src/oled.c b/src/oled.c index 9dfa8b3..57eb3db 100644 --- a/src/oled.c +++ b/src/oled.c @@ -151,12 +151,11 @@ void oled_DrawArea(uint8_t x, uint8_t y, uint8_t wide, uint8_t height, const uin // Y is the height value (affects the bits) // Y is either 0 or 8, we dont do smaller bit blatting uint8_t lines = height / 8; - // We draw the 1 or two stripes seperately - for (uint8_t i = 0; i < (wide * lines); i++) { - uint8_t xp = x + (i % wide); - uint8_t yoffset = i < wide ? 0 : OLED_WIDTH; - if (y == 8) - yoffset = OLED_WIDTH; + // We draw the 1 or two stripes separately + for (uint16_t i = 0; i < (wide * lines); i++) { + uint16_t xp = x + (i % wide); + + uint16_t yoffset = ((i / wide) + (y / 8)) * OLED_WIDTH; displayBuffer[xp + yoffset] = ptr[i]; } @@ -166,7 +165,7 @@ void oled_DrawArea(uint8_t x, uint8_t y, uint8_t wide, uint8_t height, const uin Function:Clear_Screen Description:Clear the entire screen to off (black) *******************************************************************************/ -void oled_clearScreen(void) { memset(displayBuffer, 0, 96 * 2); } +void oled_clearScreen(void) { memset(displayBuffer, 0, OLED_WIDTH * (OLED_HEIGHT / 8)); } /* * Draws a string onto the screen starting at the left @@ -202,5 +201,5 @@ void OLED_DrawChar(char c, uint8_t x, const uint8_t row) { offset *= (FONT_WIDTH * (FONT_HEIGHT / 8)); ptr += offset; - oled_DrawArea(x, row * 8, FONT_WIDTH, FONT_HEIGHT, (uint8_t *)ptr); + oled_DrawArea(OLED_AREA_X + x, OLED_AREA_Y + (row * 8), FONT_WIDTH, FONT_HEIGHT, (uint8_t *)ptr); } diff --git a/src/oled.h b/src/oled.h index 227b874..eee4c8a 100644 --- a/src/oled.h +++ b/src/oled.h @@ -6,29 +6,34 @@ #define DEVICEADDR_OLED (0x3c << 1) #if MODEL_S60 || MODEL_S60P -// TODO; for now just cropping in on the screen from 128x32 to 96x16 -#define OLED_WIDTH 96 -#define OLED_HEIGHT 16 -#define OLED_GRAM_START 0x10 // Should be 0x00 when we have full width -#define OLED_GRAM_END 0x6F // Should be 0x7F when we have full width +#define OLED_AREA_X 16 +#define OLED_AREA_Y 8 +#define OLED_WIDTH 128 +#define OLED_HEIGHT 32 +#define OLED_GRAM_START 0x00 +#define OLED_GRAM_END 0x7F #define OLED_VCOM_LAYOUT 0x12 #define OLED_SEGMENT_MAP 0xA1 #else + +#define OLED_AREA_X 0 +#define OLED_AREA_Y 0 #define OLED_WIDTH 96 #define OLED_HEIGHT 16 #define OLED_VCOM_LAYOUT 0x02 #ifdef OLED_FLIP -#define OLED_GRAM_START 0 // Should be 0x00 when we have full width +#define OLED_GRAM_START 0 // Aligned to top left of buffer #define OLED_GRAM_END 95 #define OLED_SEGMENT_MAP 0xA1 #else -#define OLED_GRAM_START 0x20 // Should be 0x00 when we have full width +#define OLED_GRAM_START 0x20 // Align to bottom right of buffer #define OLED_GRAM_END 0x7F #define OLED_SEGMENT_MAP 0xA0 #endif #endif + #define FRAMEBUFFER_START 17 // Run OLED init