parent
							
								
									020c14a31f
								
							
						
					
					
						commit
						27e4cd2f32
					
				@ -0,0 +1,71 @@ | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Empty battery | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdint.h> | 
				
			||||||
 | 
					#include "ssd1306.h" | 
				
			||||||
 | 
					#include "user_interface.h" | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void show_empty_battery() | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
					    ssd1306_clearScreen(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //     *********
 | 
				
			||||||
 | 
					    //  ****       *
 | 
				
			||||||
 | 
					    //  ****     x *
 | 
				
			||||||
 | 
					    //  ****       *
 | 
				
			||||||
 | 
					    //     *********
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define capwid 6 | 
				
			||||||
 | 
					#define hei 24 | 
				
			||||||
 | 
					#define caphei 12 | 
				
			||||||
 | 
					#define wid 50 | 
				
			||||||
 | 
					#define thic 2 | 
				
			||||||
 | 
					#define inpad 2 | 
				
			||||||
 | 
					#define charge 2 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define ofsx ((DISPLAY_W - capwid - wid)/2) | 
				
			||||||
 | 
					#define ofsy ((DISPLAY_H - hei)/2) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const uint8_t rects[6][4] = { | 
				
			||||||
 | 
					            // cap
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    0, (hei - caphei) / 2, | 
				
			||||||
 | 
					                    capwid - 1, hei - (hei - caphei) / 2 - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // left line
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    capwid, 0, | 
				
			||||||
 | 
					                    capwid+thic - 1, hei - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // top line
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    capwid + thic, 0, | 
				
			||||||
 | 
					                    capwid + wid - thic - 1, thic - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // right line
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    capwid + wid - thic, 0, | 
				
			||||||
 | 
					                    capwid + wid - 1, hei - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // "remaining charge" line
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    capwid + wid - thic - inpad - charge, thic + inpad, | 
				
			||||||
 | 
					                    capwid + wid - thic - inpad - 1, hei - thic - inpad - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // bottom line
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    capwid + thic, hei - thic, | 
				
			||||||
 | 
					                    capwid + wid - thic - 1, hei - 1 | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					    }; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int i = 0; i < 6; i++) { | 
				
			||||||
 | 
					        ssd1306_fillRect( | 
				
			||||||
 | 
					                ofsx + rects[i][0], | 
				
			||||||
 | 
					                ofsy + rects[i][1], | 
				
			||||||
 | 
					                ofsx + rects[i][2], | 
				
			||||||
 | 
					                ofsy + rects[i][3] | 
				
			||||||
 | 
					        ); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,65 @@ | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Loading | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdint.h> | 
				
			||||||
 | 
					#include <stdbool.h> | 
				
			||||||
 | 
					#include "ssd1306.h" | 
				
			||||||
 | 
					#include "user_interface.h" | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void show_loading_screen(uint8_t progress_percent, bool clear) | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
					    if (clear) { | 
				
			||||||
 | 
					        ssd1306_clearScreen(); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // bar in a box
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define hei 20 | 
				
			||||||
 | 
					#define wid DISPLAY_W | 
				
			||||||
 | 
					#define thic 2 | 
				
			||||||
 | 
					#define inpad 3 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define ofsx ((DISPLAY_W - wid)/2) | 
				
			||||||
 | 
					#define ofsy ((DISPLAY_H - hei)/2) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const uint8_t rects[4][4] = { | 
				
			||||||
 | 
					            // top
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    0, 0, | 
				
			||||||
 | 
					                    wid - 1, thic - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // left
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    0, thic, | 
				
			||||||
 | 
					                    thic - 1, hei - thic - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // right
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    wid - thic, thic, | 
				
			||||||
 | 
					                    wid - 1, hei - thic - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					            // bot
 | 
				
			||||||
 | 
					            { | 
				
			||||||
 | 
					                    0, hei - thic, | 
				
			||||||
 | 
					                    wid - 1, hei - 1 | 
				
			||||||
 | 
					            }, | 
				
			||||||
 | 
					    }; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int i = 0; i < 4; i++) { | 
				
			||||||
 | 
					        ssd1306_fillRect( | 
				
			||||||
 | 
					                ofsx + rects[i][0], | 
				
			||||||
 | 
					                ofsy + rects[i][1], | 
				
			||||||
 | 
					                ofsx + rects[i][2], | 
				
			||||||
 | 
					                ofsy + rects[i][3] | 
				
			||||||
 | 
					        ); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					    ssd1306_fillRect( | 
				
			||||||
 | 
					            ofsx + thic + inpad, | 
				
			||||||
 | 
					            ofsy + thic + inpad, | 
				
			||||||
 | 
					            ofsx + (uint8_t)(((uint16_t)wid * (uint16_t)progress_percent)/(uint16_t)100) - thic - inpad - 1, | 
				
			||||||
 | 
					            ofsy + hei - thic - inpad - 1 | 
				
			||||||
 | 
					    ); | 
				
			||||||
 | 
					} | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue