2020display_group = displayio .Group (max_size = 20 )
2121board .DISPLAY .show (display_group )
2222
23- PLOT_SIZE = 2 # plot thickness
24- PLOT_COLOR = 0x00FF55 # plot color
23+ PROFILE_SIZE = 2 # plot thickness
24+ PROFILE_COLOR = 0x00FF55 # plot color
2525GRID_SIZE = 2
2626GRID_COLOR = 0x2020FF
2727GRID_STYLE = 3
2828TEMP_SIZE = 2
29- TEMP_COLOR = 0xFFFF00
29+ TEMP_COLOR = 0xFF0000
3030LABEL_COLOR = 0x8080FF
31+ AXIS_SIZE = 2
32+ AXIS_COLOR = 0xFFFF00
3133
3234WIDTH = board .DISPLAY .width
3335HEIGHT = board .DISPLAY .height
3436
3537pyportal = PyPortal ()
3638
37- palette = displayio .Palette (4 )
39+ palette = displayio .Palette (5 )
3840palette [0 ] = 0x0
39- palette [1 ] = PLOT_COLOR
41+ palette [1 ] = PROFILE_COLOR
4042palette [2 ] = GRID_COLOR
4143palette [3 ] = TEMP_COLOR
44+ palette [4 ] = AXIS_COLOR
4245palette .make_transparent (0 )
4346
44- plot = displayio .Bitmap (WIDTH , HEIGHT , 3 )
47+ plot = displayio .Bitmap (WIDTH , HEIGHT , 8 )
4548pyportal .splash .append (displayio .TileGrid (plot , pixel_shader = palette ))
4649
4750ts = adafruit_touchscreen .Touchscreen (board .TOUCH_XL , board .TOUCH_XR ,
@@ -77,7 +80,6 @@ def play(self, duration=0.1):
7780 # otherwise, use refresh() in loop to turn off long beep
7881 time .sleep (duration )
7982 self .stop ()
80- print ("play" , duration , self .start )
8183
8284 def stop (self ):
8385 if pyportal ._speaker_enable .value :
@@ -101,7 +103,7 @@ def __init__(self, pin):
101103 with open ("/profiles/" + self .config ["profile" ] + ".json" , mode = "r" ) as fpr :
102104 self .sprofile = json .load (fpr )
103105 fpr .close ()
104- i2c = busio .I2C (board .SCL , board . SDA , frequency = 200000 )
106+ i2c = busio .I2C (board .SCL , board .SDA , frequency = 100000 )
105107 try :
106108 self .sensor = MCP9600 (i2c , self .config ["sensor_address" ], "K" )
107109 except ValueError :
@@ -230,7 +232,7 @@ def __init__(self):
230232 self .height = HEIGHT
231233
232234 # pylint: disable=too-many-branches
233- def draw_line (self , x1 , y1 , x2 , y2 , size = PLOT_SIZE , color = 1 , style = 1 ):
235+ def draw_line (self , x1 , y1 , x2 , y2 , size = PROFILE_SIZE , color = 1 , style = 1 ):
234236 # print("draw_line:", x1, y1, x2, y2)
235237 # convert graph coords to screen coords
236238 x1p = (self .xstart + self .width * (x1 - self .xmin )
@@ -274,7 +276,7 @@ def draw_line(self, x1, y1, x2, y2, size=PLOT_SIZE, color=1, style=1):
274276 else :
275277 self .draw_point (xx , yy , size , color )
276278
277- def draw_graph_point (self , x , y , size = PLOT_SIZE , color = 1 ):
279+ def draw_graph_point (self , x , y , size = PROFILE_SIZE , color = 1 ):
278280 """ draw point using graph coordinates """
279281 xx = (self .xstart + self .width * (x - self .xmin )
280282 // (self .xmax - self .xmin ))
@@ -283,7 +285,7 @@ def draw_graph_point(self, x, y, size=PLOT_SIZE, color=1):
283285 print ("graph point:" , x , y , xx , yy )
284286 self .draw_point (xx , max (0 + size , yy ), size , color )
285287
286- def draw_point (self , x , y , size = PLOT_SIZE , color = 1 ):
288+ def draw_point (self , x , y , size = PROFILE_SIZE , color = 1 ):
287289 """Draw data point on to the plot bitmap at (x,y)."""
288290 if y is None :
289291 return
@@ -343,17 +345,41 @@ def draw_profile(graph, profile):
343345 yp = (graph .ystart + int (graph .height * (y - graph .ymin )
344346 / (graph .ymax - graph .ymin )))
345347
346- label_reflow .x = xp
347- label_reflow .y = yp + 16 # fudge factor here to get close to line
348+ label_reflow .x = xp + 10
349+ label_reflow .y = HEIGHT - yp
348350 label_reflow .text = str (profile ["stages" ]["reflow" ][1 ])
349351 print ("reflow temp:" , str (profile ["stages" ]["reflow" ][1 ]))
352+ print ("graph point: " , x , y , "->" , xp , yp )
353+
354+ # draw time line (horizontal)
355+ graph .draw_line (graph .xmin , graph .ymin , graph .xmax , graph .ymin , AXIS_SIZE , 4 , 1 )
356+ graph .draw_line (graph .xmin , graph .ymax - AXIS_SIZE , graph .xmax , graph .ymax
357+ - AXIS_SIZE , AXIS_SIZE , 4 , 1 )
358+ # draw time ticks
359+ tick = graph .xmin
360+ while tick < (graph .xmax - graph .xmin ):
361+ graph .draw_line (tick , graph .ymin , tick , graph .ymin + 10 , AXIS_SIZE , 4 , 1 )
362+ graph .draw_line (tick , graph .ymax , tick , graph .ymax - 10 - AXIS_SIZE , AXIS_SIZE , 4 , 1 )
363+ tick += 60
364+
365+ # draw temperature line (vertical)
366+ graph .draw_line (graph .xmin , graph .ymin , graph .xmin , graph .ymax , AXIS_SIZE , 4 , 1 )
367+ graph .draw_line (graph .xmax - AXIS_SIZE , graph .ymin , graph .xmax - AXIS_SIZE ,
368+ graph .ymax , AXIS_SIZE , 4 , 1 )
369+ # draw temperature ticks
370+ tick = graph .ymin
371+ while tick < (graph .ymax - graph .ymin )* 1.1 :
372+ graph .draw_line (graph .xmin , tick , graph .xmin + 10 , tick , AXIS_SIZE , 4 , 1 )
373+ graph .draw_line (graph .xmax , tick , graph .xmax - 10 - AXIS_SIZE , tick , AXIS_SIZE , 4 , 1 )
374+ tick += 50
375+
350376 # draw profile
351377 x1 = profile ["profile" ][0 ][0 ]
352378 y1 = profile ["profile" ][0 ][1 ]
353379 for point in profile ["profile" ]:
354380 x2 = point [0 ]
355381 y2 = point [1 ]
356- graph .draw_line (x1 , y1 , x2 , y2 )
382+ graph .draw_line (x1 , y1 , x2 , y2 , PROFILE_SIZE , 1 , 1 )
357383 # print(point)
358384 x1 = x2
359385 y1 = y2
@@ -376,7 +402,7 @@ def format_time(seconds):
376402label_reflow .y = - 20
377403pyportal .splash .append (label_reflow )
378404title_label = label .Label (font3 , text = "EZ Make Oven Controller" )
379- title_label .x = 10
405+ title_label .x = 5
380406title_label .y = 14
381407pyportal .splash .append (title_label )
382408# version_label = label.Label(font1, text=VERSION, color=0xAAAAAA)
@@ -385,38 +411,38 @@ def format_time(seconds):
385411# pyportal.splash.append(version_label)
386412message = label .Label (font2 , text = "Wait" , max_glyphs = 20 )
387413message .x = 100
388- message .y = 50
414+ message .y = 40
389415pyportal .splash .append (message )
390- profile_label = label .Label (font1 , text = "Profile:" , color = 0xAAAAAA )
391- profile_label .x = 10
392- profile_label .y = 40
393- pyportal .splash .append (profile_label )
394- profile_data = label .Label (font1 , text = oven .sprofile ["title" ])
395- profile_data .x = 20
396- profile_data .y = 60
397- pyportal .splash .append (profile_data )
398416alloy_label = label .Label (font1 , text = "Alloy: " , color = 0xAAAAAA )
399- alloy_label .x = 10
400- alloy_label .y = 80
417+ alloy_label .x = 5
418+ alloy_label .y = 40
401419pyportal .splash .append (alloy_label )
402420alloy_data = label .Label (font1 , text = str (oven .sprofile ["alloy" ]))
403- alloy_data .x = 20
404- alloy_data .y = 100
421+ alloy_data .x = 10
422+ alloy_data .y = 60
405423pyportal .splash .append (alloy_data )
424+ profile_label = label .Label (font1 , text = "Profile:" , color = 0xAAAAAA )
425+ profile_label .x = 5
426+ profile_label .y = 80
427+ pyportal .splash .append (profile_label )
428+ profile_data = label .Label (font1 , text = oven .sprofile ["title" ])
429+ profile_data .x = 10
430+ profile_data .y = 100
431+ pyportal .splash .append (profile_data )
406432timer_label = label .Label (font1 , text = "Time:" , color = 0xAAAAAA )
407- timer_label .x = 10
433+ timer_label .x = 5
408434timer_label .y = 120
409435pyportal .splash .append (timer_label )
410436timer_data = label .Label (font3 , text = format_time (timediff ), max_glyphs = 10 )
411- timer_data .x = 20
437+ timer_data .x = 10
412438timer_data .y = 140
413439pyportal .splash .append (timer_data )
414440temp_label = label .Label (font1 , text = "Temp(C):" , color = 0xAAAAAA )
415- temp_label .x = 10
441+ temp_label .x = 5
416442temp_label .y = 160
417443pyportal .splash .append (temp_label )
418444temp_data = label .Label (font3 , text = "--" , max_glyphs = 10 )
419- temp_data .x = 20
445+ temp_data .x = 10
420446temp_data .y = 180
421447pyportal .splash .append (temp_data )
422448circle = Circle (308 , 12 , 8 , fill = 0 )
@@ -425,8 +451,8 @@ def format_time(seconds):
425451sgraph = Graph ()
426452
427453sgraph .xstart = 100
428- sgraph .ystart = 0
429- sgraph .width = 220
454+ sgraph .ystart = 4
455+ sgraph .width = 216
430456sgraph .height = 160
431457sgraph .xmin = oven .sprofile ["time_range" ][0 ]
432458sgraph .xmax = oven .sprofile ["time_range" ][1 ]
0 commit comments