| 8 | |
| 9 | # This class implements the view that shows the splash screen on startup. |
| 10 | class SplashScreen: |
| 11 | def __init__(self, display, xres, yres): |
| 12 | self.display = display # Display driver |
| 13 | self.xres = xres |
| 14 | self.yres = yres |
| 15 | self.anim_frame = 0 # Animation frame to show |
| 16 | |
| 17 | def next_frame(self): |
| 18 | self.anim_frame += 1 |
| 19 | |
| 20 | def draw_logo(self): |
| 21 | self.display.fill(0) |
| 22 | for x in range(0,self.xres,2): |
| 23 | for y in range(0,self.yres+8,8): |
| 24 | f1 = self.anim_frame/5 |
| 25 | dy = math.sin(f1+x/(1+(y*17%11)))*4 |
| 26 | self.display.pixel(int(x),y+int(dy),1) |
| 27 | dx = 15 |
| 28 | dy = 8 |
| 29 | self.display.fill_rect(dx+0,dy+0,40,10,0); |
| 30 | self.display.fill_rect(dx+0,dy+20,40,10,0); |
| 31 | self.display.fill_rect(dx+0,dy+0,10,50,0); |
| 32 | self.display.line(dx+0,dy+0,dx+0,dy+50,1) |
| 33 | self.display.line(dx+0,dy+0,dx+30,dy+0,1) |
| 34 | self.display.line(dx+10,dy+20,dx+30,dy+20,1) |
| 35 | dx = 55 |
| 36 | dy = 8 |
| 37 | for x in range(10): |
| 38 | self.display.line(dx+x+0,dy+0,dx+x+15,dy+50,0) |
| 39 | self.display.line(dx+x+30,dy+0,dx+x+15+30,dy+50,0) |
| 40 | self.display.line(dx+x+25,dy+0,dx+x+10,dy+50,0) |
| 41 | self.display.line(dx+x+55,dy+0,dx+x+40,dy+50,0) |
| 42 | self.display.line(dx,dy,dx+15,dy+50,1) |
| 43 | self.display.line(dx+30,dy,dx+45,dy+50,1) |
| 44 | |
| 45 | def refresh(self): |
| 46 | if not self.display: return |
| 47 | self.draw_logo() |
| 48 | self.display.show() |
| 49 | |
| 50 | # Only useful in order to test the animation quickly in the SD1306 |
| 51 | if __name__ == "__main__": |