diff --git a/main/oled.c b/main/oled.c index 2770d6fdf..801abda9f 100644 --- a/main/oled.c +++ b/main/oled.c @@ -172,13 +172,13 @@ static void oledSetPosition(int x, int y) } write_command(0xb0 | y); // go to page Y - write_command(0x00 | (x & 0xf)); // // lower col addr - write_command(0x10 | ((x >> 4) & 0xf)); // upper col addr + write_command(0x00 | (x & 0x0f)); // lower col addr + write_command(0x10 | ((x >> 4) & 0x0f));// upper col addr } // Write a block of pixel data to the OLED // Length can be anything from 1 to 1024 (whole display) -static void oledWriteDataBlock(uint8_t * ucBuf, int iLen) +static void oledWriteDataBlock(const uint8_t * ucBuf, int iLen) { uint8_t ucTemp[129]; @@ -217,6 +217,22 @@ int OLED_setPixel(int x, int y, uint8_t ucColor) return 0; } +// Write a bitmap to the screen +// The X position is in character widths (8 or 16) +// The Y position is in memory pages (8 lines each) +// Bitmap should be aligned vertical, 1 bit per pixel +// Width and Height must be per 8 pixels +// Conversion tool: https://javl.github.io/image2cpp/ +int OLED_showBitmap(int x, int y, const uint8_t *bitmap, int width, int height) +{ + for (int row = 0; row < (height >> 3); row++) { + oledSetPosition(x, y + row); + oledWriteDataBlock(&bitmap[row * width], width); + } + + return 0; +} + // // Draw a string of small (8x8), large (16x24), or very small (6x8) characters // At the given col+row diff --git a/main/oled.h b/main/oled.h index 538a14735..ba3d82c24 100644 --- a/main/oled.h +++ b/main/oled.h @@ -42,6 +42,7 @@ int OLED_writeString(int x, int y, const char *szText); // Sets a pixel to On (1) or Off (0) // Coordinate system is pixels, not text rows (0-127, 0-63) int OLED_setPixel(int x, int y, uint8_t ucPixel); +int OLED_showBitmap(int x, int y, const uint8_t *bitmap, int width, int height); // Sets the contrast (brightness) level of the display // Valid values are 0-255 where 0=off and 255=max brightness diff --git a/main/system.c b/main/system.c index 8fd87b69d..2fc7fb9f5 100644 --- a/main/system.c +++ b/main/system.c @@ -160,6 +160,41 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { _init_connection(GLOBAL_STATE); } +static const uint8_t bitaxe_splash[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x10, 0x18, 0x3c, + 0x7e, 0xfc, 0xf8, 0xf0, 0x38, 0x3c, 0x3c, 0x7c, 0xf8, 0xf8, 0xf8, 0x30, 0x10, 0x08, 0x00, 0x08, + 0x9c, 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xe0, 0xf0, 0x80, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x20, 0x20, 0x10, 0x08, + 0x00, 0xff, 0xff, 0xff, 0x80, 0xe0, 0xf0, 0xe0, 0xff, 0xff, 0xdf, 0xc0, 0x60, 0x00, 0x06, 0xff, + 0xff, 0xff, 0xfe, 0x02, 0x00, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x18, 0x18, + 0x3c, 0xfe, 0x87, 0x07, 0x0f, 0xff, 0xff, 0xfe, 0xfe, 0x06, 0x00, 0x04, 0xff, 0xff, 0xff, 0xfe, + 0x82, 0x00, 0x04, 0xff, 0xff, 0xff, 0xfe, 0x02, 0x00, 0x00, 0xf8, 0xfc, 0xfc, 0xfe, 0x07, 0x07, + 0x8f, 0xff, 0x7f, 0x3e, 0x1e, 0x12, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, + 0x82, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, 0xff, + 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0xf0, 0xf0, + 0xf8, 0xf8, 0x0c, 0x06, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x04, 0xf3, 0xf7, 0xff, 0xff, + 0x0f, 0x0f, 0x1f, 0xff, 0xff, 0xfe, 0xfc, 0x02, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x03, + 0x01, 0x80, 0x80, 0xc0, 0xe0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x46, 0x47, 0x03, 0x03, 0x07, + 0x07, 0x0f, 0x0f, 0x1f, 0x1e, 0x3e, 0x1c, 0x0c, 0x07, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x0f, + 0x1f, 0x3f, 0x1f, 0x0c, 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x3f, 0x1f, 0x0c, 0x04, 0x10, 0x0f, 0x0f, + 0x1f, 0x1f, 0x1e, 0x1e, 0x1c, 0x0f, 0x1f, 0x1f, 0x1f, 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x1f, 0x0f, + 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x1f, 0x0f, 0x04, 0x00, 0x10, 0x0f, 0x0f, 0x1f, 0x1f, 0x1e, 0x1e, + 0x1c, 0x0f, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + void SYSTEM_task(void * pvParameters) { GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters; @@ -181,6 +216,9 @@ void SYSTEM_task(void * pvParameters) vTaskDelay(1000 / portTICK_PERIOD_MS); } + OLED_showBitmap(0, 0, bitaxe_splash, 128, 32); + vTaskDelay(5000 / portTICK_PERIOD_MS); + int current_screen = 0; TickType_t last_update_time = xTaskGetTickCount();