Skip to content
Snippets Groups Projects
Commit 55146f9f authored by iggy's avatar iggy
Browse files

ui: debugging stuff out, fixes

parent f6965a4e
Branches
No related tags found
No related merge requests found
...@@ -27,7 +27,8 @@ class Application(): ...@@ -27,7 +27,8 @@ class Application():
condition=lambda e: e["type"]=="button" and e.get("from")==2 and e["change"] condition=lambda e: e["type"]=="button" and e.get("from")==2 and e["change"]
)) ))
#self.ui.add(ui.Icon(label=self.title)) self.ui.add(ui.Icon(label=self.title))
def __repr__(self): def __repr__(self):
return "App "+self.title return "App "+self.title
def init(self): def init(self):
......
...@@ -216,7 +216,6 @@ def render(): ...@@ -216,7 +216,6 @@ def render():
return return
ui.the_ctx.rectangle(-120,-120,240,240).rgb(0,0,0).fill() ui.the_ctx.rectangle(-120,-120,240,240).rgb(0,0,0).fill()
print("before draw")
active_menu.draw() active_menu.draw()
#hardware.display_update() #hardware.display_update()
...@@ -231,14 +230,11 @@ def menu_disable(): ...@@ -231,14 +230,11 @@ def menu_disable():
active_menu=None active_menu=None
def menu_back(): def menu_back():
print ("back")
if not menu_stack: if not menu_stack:
return return
previous = menu_stack.pop() previous = menu_stack.pop()
set_active_menu(previous) set_active_menu(previous)
#ui.the_ctx = hardware.reset_ctx()
print("almost")
render() render()
print("rendered")
\ No newline at end of file \ No newline at end of file
...@@ -79,7 +79,7 @@ class Icon(UIElement): ...@@ -79,7 +79,7 @@ class Icon(UIElement):
super().__init__() super().__init__()
def _draw(self,pos): def _draw(self,pos):
print("ui.Icon._draw()") #print("ui.Icon._draw()")
x = int(pos[0]) x = int(pos[0])
y = int(pos[1]) y = int(pos[1])
...@@ -94,7 +94,7 @@ class Icon(UIElement): ...@@ -94,7 +94,7 @@ class Icon(UIElement):
hs,hs,hs//2 hs,hs,hs//2
).fill() ).fill()
print(" arc") #print(" arc")
self.ctx.move_to(x,y).rgb(self.bg_r,self.bg_g,self.bg_b).arc(x,y,self.size/2,-math.pi,math.pi,True).fill() self.ctx.move_to(x,y).rgb(self.bg_r,self.bg_g,self.bg_b).arc(x,y,self.size/2,-math.pi,math.pi,True).fill()
#self.ctx.move_to(x,y-self.size/2).rgb(self.bg_r,self.bg_g,self.bg_b). #self.ctx.move_to(x,y-self.size/2).rgb(self.bg_r,self.bg_g,self.bg_b).
#.round_rectangle( #.round_rectangle(
...@@ -102,17 +102,14 @@ class Icon(UIElement): ...@@ -102,17 +102,14 @@ class Icon(UIElement):
# y-self.size/2, # y-self.size/2,
# self.size,self.size,self.size//2 # self.size,self.size,self.size//2
#).fill() #).fill()
micropython.mem_info()
gc.collect()
print(self.label)
self.ctx.rgb(1,1,1).move_to(x,y) #micropython.mem_info()
micropython.mem_info("data") #gc.collect()
print(" moved") #print(self.label)
print(" crash here:")
self.ctx.text(self.label) self.ctx.rgb(1,1,1).move_to(x,y).text(self.label)
#micropython.mem_info("data")
print(" text")
class IconValue(Icon): class IconValue(Icon):
def __init__(self, value=0, *args, **kwargs): def __init__(self, value=0, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
...@@ -145,12 +142,12 @@ class GroupRing(UIElement): ...@@ -145,12 +142,12 @@ class GroupRing(UIElement):
pos = (self.origin[0]+offset[0],self.origin[1]+offset[1]) pos = (self.origin[0]+offset[0],self.origin[1]+offset[1])
self._draw(pos) self._draw(pos)
for index in range(len(self.children)): for index in range(len(self.children)):
print("child",index) #print("child",index)
child = self.children[index] child = self.children[index]
angle = 2*math.pi/len(self.children)*index+self.angle_offset angle = 2*math.pi/len(self.children)*index+self.angle_offset
x = math.sin(angle)*self.r+pos[0] x = math.sin(angle)*self.r+pos[0]
y = -math.cos(angle)*self.r+pos[1] y = -math.cos(angle)*self.r+pos[1]
print("pos",(x,y)) #print("pos",(x,y))
child.draw(offset=(x,y)) child.draw(offset=(x,y))
def _draw(self,pos): def _draw(self,pos):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment