Skip to content
Snippets Groups Projects
Select Git revision
  • 7ea488c6dba5238edc19aaa2781431a963d470db
  • master default protected
  • fix-warnings
  • tvbgone-fixes
  • genofire/ble-follow-py
  • schneider/ble-stability-new-phy-adv
  • schneider/ble-stability
  • msgctl/gfx_rle
  • schneider/ble-stability-new-phy
  • add_menu_vibration
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
36 results

default.nix

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    bootloader-display.c 2.02 KiB
    #include "bootloader.h"
    /* Autogenerated */
    #include "splash-screen.h"
    #include "card10-version.h"
    
    #include "gfx.h"
    #include "display.h"
    
    /*
     * "Decompress" splash-screen image.  The algorithm works as follows:
     *
     * Each byte encodes up to 127 pixels in either white or black.  The most
     * significant bit determines the color, the remaining 7 bits determine the
     * amount.
     */
    static void bootloader_display_splash(void)
    {
    	int idx = 0;
    
    	Color white = gfx_color(&display_screen, WHITE);
    	Color black = gfx_color(&display_screen, BLACK);
    	for (int i = 0; i < sizeof(splash); i++) {
    		Color color    = (splash[i] & 0x80) ? white : black;
    		uint8_t length = splash[i] & 0x7f;
    
    		for (int j = 0; j < length; j++) {
    			uint16_t x = idx % 160;
    			uint16_t y = idx / 160;
    			gfx_setpixel(&display_screen, x, y, color);
    			idx++;
    		}
    	}
    
    	gfx_update(&display_screen);
    }
    
    /*
     * Initialize the display.
     */
    void bootloader_display_init(void)
    {
    	bootloader_display_splash();
    }
    
    /*
     * Show the bootloader version on the display.
     */
    void bootloader_display_header(void)
    {
    	gfx_clear(&display_screen);
    
    	Color white = gfx_color(&display_screen, WHITE);
    	bootloader_display_line(0, "Bootloader", white);
    	bootloader_display_line(1, __DATE__, white);
    	bootloader_display_line(2, CARD10_VERSION, white);
    }
    
    void bootloader_display_error(char *errtype, char *line1, char *line2)
    {
    	gfx_clear(&display_screen);
    
    	Color red    = gfx_color(&display_screen, RED);
    	Color yellow = gfx_color(&display_screen, YELLOW);
    	Color white  = gfx_color(&display_screen, WHITE);
    
    	bootloader_display_line(0, "[FATAL ERROR]", red);
    	bootloader_display_line(1, errtype, yellow);
    	bootloader_display_line(2, CARD10_VERSION, white);
    	bootloader_display_line(3, line1, white);
    	bootloader_display_line(4, line2, white);
    }
    
    /*
     * Display a line of text on the display.
     */
    void bootloader_display_line(int line, char *string, uint16_t color)
    {
    	Color black = gfx_color(&display_screen, BLACK);
    	gfx_puts(&Font16, &display_screen, 0, 16 * line, string, color, black);
    	gfx_update(&display_screen);
    }