1
0
Fork 0

Optimize flash usage of calc app

Signed-off-by: Francesco Gazzetta <fgaz@fgaz.me>
This commit is contained in:
Francesco Gazzetta 2021-11-30 16:10:02 +01:00 committed by Daniel Thompson
parent c876f7cfdb
commit fc756bccc9

View file

@ -88,29 +88,32 @@ class CalculatorApp():
def _draw(self): def _draw(self):
draw = wasp.watch.drawable draw = wasp.watch.drawable
theme = wasp.system.theme
line = draw.line
fill = draw.fill
hi = wasp.system.theme('bright') hi = theme('bright')
lo = wasp.system.theme('mid') lo = theme('mid')
mid = draw.lighten(lo, 2) mid = draw.lighten(lo, 2)
bg = draw.darken(wasp.system.theme('ui'), wasp.system.theme('contrast')) bg = draw.darken(theme('ui'), theme('contrast'))
bg2 = draw.darken(bg, 2) bg2 = draw.darken(bg, 2)
# Draw the background # Draw the background
draw.fill(0, 0, 0, 239, 47) fill(0, 0, 0, 239, 47)
draw.fill(0, 236, 239, 3) fill(0, 236, 239, 3)
draw.fill(bg, 141, 48, 239-141, 236-48) fill(bg, 141, 48, 239-141, 236-48)
draw.fill(bg2, 0, 48, 141, 236-48) fill(bg2, 0, 48, 141, 236-48)
# Make grid: # Make grid:
draw.set_color(lo) draw.set_color(lo)
for i in range(4): for i in range(4):
# horizontal lines # horizontal lines
draw.line(x0=0,y0=(i+1)*47,x1=239,y1=(i+1)*47) line(x0=0,y0=(i+1)*47,x1=239,y1=(i+1)*47)
# vertical lines # vertical lines
draw.line(x0=(i+1)*47,y0=47,x1=(i+1)*47,y1=235) line(x0=(i+1)*47,y0=47,x1=(i+1)*47,y1=235)
draw.line(x0=0, y0=47, x1=0, y1=236) line(x0=0, y0=47, x1=0, y1=236)
draw.line(x0=239, y0=47, x1=239, y1=236) line(x0=239, y0=47, x1=239, y1=236)
draw.line(x0=0, y0=236, x1=239, y1=236) line(x0=0, y0=236, x1=239, y1=236)
# Draw button labels # Draw button labels
draw.set_color(hi, bg2) draw.set_color(hi, bg2)