4747ts = adafruit_touchscreen .Touchscreen (board .TOUCH_XL , board .TOUCH_XR ,
4848 board .TOUCH_YD , board .TOUCH_YU ,
4949 calibration = (
50- (5200 , 59000 ), (5800 , 57000 )
51- ),
50+ (5200 , 59000 ),
51+ (5800 , 57000 )
52+ ),
5253 size = (WIDTH , HEIGHT ))
5354
5455class Beep (object ):
@@ -96,14 +97,17 @@ def __init__(self, pin):
9697 with open ("/config.json" , mode = "r" ) as fpr :
9798 self .config = json .load (fpr )
9899 fpr .close ()
99- self .sprofile = self .load_profile (self .config ["profile" ])
100+ with open ("/profiles/" + self .config ["profile" ] + ".json" , mode = "r" ) as fpr :
101+ self .sprofile = json .load (fpr )
102+ fpr .close ()
100103 i2c = busio .I2C (board .SCL , board . SDA , frequency = 200000 )
101104 try :
102105 self .sensor = MCP9600 (i2c , self .config ["sensor_address" ], "K" )
103106 except ValueError :
104107 print ("temperature sensor not available" )
105108 self .ontime = 0
106109 self .offtime = 0
110+ self .control = False
107111 self .reset ()
108112 self .reflow_start = 0
109113 self .beep = Beep ()
@@ -114,12 +118,6 @@ def reset(self):
114118 self .offtime = 0
115119 self .enable (False )
116120
117- def load_profile (self , filename ):
118- with open ("/profiles/" + filename + ".json" , mode = "r" ) as fpr :
119- profile = json .load (fpr )
120- fpr .close ()
121- return profile
122-
123121 def get_profile_temp (self , seconds ):
124122 x1 = self .sprofile ["profile" ][0 ][0 ]
125123 y1 = self .sprofile ["profile" ][0 ][1 ]
@@ -138,6 +136,7 @@ def set_state(self, state):
138136 self .check_state ()
139137 self .last_state = state
140138
139+ # pylint: disable=too-many-branches, too-many-statements
141140 def check_state (self ):
142141 try :
143142 temp = self .sensor .temperature
@@ -229,17 +228,18 @@ def __init__(self):
229228 self .width = WIDTH
230229 self .height = HEIGHT
231230
231+ # pylint: too-many-branches
232232 def draw_line (self , x1 , y1 , x2 , y2 , size = PLOT_SIZE , color = 1 , style = 1 ):
233233 # print("draw_line:", x1, y1, x2, y2)
234234 # convert graph coords to screen coords
235235 x1p = (self .xstart + self .width * (x1 - self .xmin )
236236 // (self .xmax - self .xmin ))
237237 y1p = (self .ystart + int (self .height * (y1 - self .ymin )
238- / (self .ymax - self .ymin )))
238+ / (self .ymax - self .ymin )))
239239 x2p = (self .xstart + self .width * (x2 - self .xmin ) //
240240 (self .xmax - self .xmin ))
241241 y2p = (self .ystart + int (self .height * (y2 - self .ymin ) /
242- (self .ymax - self .ymin )))
242+ (self .ymax - self .ymin )))
243243 # print("screen coords:", x1p, y1p, x2p, y2p)
244244
245245 if (max (x1p , x2p ) - min (x1p , x2p )) > (max (y1p , y2p ) - min (y1p , y2p )):
@@ -278,7 +278,7 @@ def draw_graph_point(self, x, y, size=PLOT_SIZE, color=1):
278278 xx = (self .xstart + self .width * (x - self .xmin )
279279 // (self .xmax - self .xmin ))
280280 yy = (self .ystart + int (self .height * (y - self .ymin )
281- / (self .ymax - self .ymin )))
281+ / (self .ymax - self .ymin )))
282282 print ("graph point:" , x , y , xx , yy )
283283 self .draw_point (xx , max (0 + size , yy ), size , color )
284284
@@ -340,7 +340,7 @@ def draw_profile(graph, profile):
340340 xp = (graph .xstart + graph .width * (x - graph .xmin )
341341 // (graph .xmax - graph .xmin ))
342342 yp = (graph .ystart + int (graph .height * (y - graph .ymin )
343- / (graph .ymax - graph .ymin )))
343+ / (graph .ymax - graph .ymin )))
344344
345345 label_reflow .x = xp
346346 label_reflow .y = yp + 16 # fudge factor here to get close to line
0 commit comments