From c076fa6079d40cd7cd1fb1890317c17305180755 Mon Sep 17 00:00:00 2001 From: Jason Bruce Date: Wed, 14 Apr 2021 18:16:03 -0400 Subject: [PATCH 1/4] - added a few significant digits in logging statements to temps - changed the wording of the emergency shutoff temp setting --- config.py | 7 ++++--- lib/oven.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 353eacc..29b9420 100644 --- a/config.py +++ b/config.py @@ -86,9 +86,10 @@ temp_scale = "f" # c = Celsius | f = Fahrenheit - Unit to display time_scale_slope = "h" # s = Seconds | m = Minutes | h = Hours - Slope displayed in temp_scale per time_scale_slope time_scale_profile = "m" # s = Seconds | m = Minutes | h = Hours - Enter and view target time in time_scale_profile -# emergency shutoff the kiln if this temp is reached. -# when solid state relays fail, they usually fail closed. this means your -# kiln receives full power until your house burns down. +# emergency shutoff the profile if this temp is reached or exceeded. +# This just shuts off the profile. If your SSR is working, your kiln will +# naturally cool off. If your SSR has failed/shorted/closed circuit, this +# means your kiln receives full power until your house burns down. # this should not replace you watching your kiln or use of a kiln-sitter emergency_shutoff_temp = 2264 #cone 7 diff --git a/lib/oven.py b/lib/oven.py index 16e94ad..ec5679d 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -296,7 +296,7 @@ class SimulatedOven(Oven): int(self.p_env))) time_left = self.totaltime - self.runtime - log.info("temp=%.1f, target=%.1f, pid=%.3f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" % + log.info("temp=%.2f, target=%.2f, pid=%.3f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" % (self.board.temp_sensor.temperature + config.thermocouple_offset, self.target, pid, @@ -339,7 +339,7 @@ class RealOven(Oven): self.output.heat(heat_on) self.output.cool(heat_off) time_left = self.totaltime - self.runtime - log.info("temp=%.1f, target=%.1f, pid=%.3f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" % + log.info("temp=%.2f, target=%.2f, pid=%.3f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" % (self.board.temp_sensor.temperature + config.thermocouple_offset, self.target, pid, From 38161150d7ab7789d6ff98e9cd5edf25366a0b46 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Tue, 20 Apr 2021 23:29:27 +0100 Subject: [PATCH 2/4] Automatically copy with ssl --- public/assets/js/picoreflow.js | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/public/assets/js/picoreflow.js b/public/assets/js/picoreflow.js index 4f0e3e7..94afd4c 100644 --- a/public/assets/js/picoreflow.js +++ b/public/assets/js/picoreflow.js @@ -14,7 +14,11 @@ var temp_scale_display = "C"; var kwh_rate = 0.26; var currency_type = "EUR"; -var host = "ws://" + window.location.hostname + ":" + window.location.port; +var protocol = 'ws://'; +if (window.location.protocol == 'https:') { + protocol = 'wss://'; +} +var host = "" + protocol + window.location.hostname + ":" + window.location.port; var ws_status = new WebSocket(host+"/status"); var ws_control = new WebSocket(host+"/control"); var ws_config = new WebSocket(host+"/config"); @@ -134,15 +138,15 @@ function updateProfileTable() var fields = id.split("-"); var col = parseInt(fields[1]); var row = parseInt(fields[2]); - + if (graph.profile.data.length > 0) { if (col == 0) { - graph.profile.data[row][col] = timeProfileFormatter(value,false); + graph.profile.data[row][col] = timeProfileFormatter(value,false); } else { graph.profile.data[row][col] = value; } - + graph.plot = $.plot("#graph_container", [ graph.profile, graph.live ], getOptions()); } updateProfileTable(); @@ -157,7 +161,7 @@ function timeProfileFormatter(val, down) { if (down) {rval = val / 60;} else {rval = val * 60;} break; case "h": - if (down) {rval = val / 3600;} else {rval = val * 3600;} + if (down) {rval = val / 3600;} else {rval = val * 3600;} break; } return Math.round(rval); @@ -166,7 +170,7 @@ function timeProfileFormatter(val, down) { function formatDPS(val) { var tval = val; if (time_scale_slope == "m") { - tval = val * 60; + tval = val * 60; } if (time_scale_slope == "h") { tval = (val * 60) * 60; @@ -175,10 +179,10 @@ function formatDPS(val) { } function hazardTemp(){ - + if (temp_scale == "f") { return (1500 * 9 / 5) + 32 - } + } else { return 1500 } @@ -555,8 +559,8 @@ $(document).ready(function() } $('#act_temp').html(parseInt(x.temperature)); - - if (x.heat > 0.0) { + + if (x.heat > 0.0) { setTimeout(function() { $('#heat').addClass("ds-led-heat-active") }, 0 ) setTimeout(function() { $('#heat').removeClass("ds-led-heat-active") }, (x.heat*1000.0)-5) } @@ -571,7 +575,7 @@ $(document).ready(function() }; // Config Socket ///////////////////////////////// - + ws_config.onopen = function() { ws_config.send('GET'); @@ -586,9 +590,9 @@ $(document).ready(function() time_scale_profile = x.time_scale_profile; kwh_rate = x.kwh_rate; currency_type = x.currency_type; - + if (temp_scale == "c") {temp_scale_display = "C";} else {temp_scale_display = "F";} - + $('#act_temp_scale').html('º'+temp_scale_display); $('#target_temp_scale').html('º'+temp_scale_display); @@ -604,7 +608,7 @@ $(document).ready(function() time_scale_long = "Hours"; break; } - + } // Control Socket //////////////////////////////// @@ -665,12 +669,12 @@ $(document).ready(function() // if not, update with first available profile name var valid_profile_names = profiles.map(function(a) {return a.name;}); if ( - valid_profile_names.length > 0 && + valid_profile_names.length > 0 && $.inArray(selected_profile_name, valid_profile_names) === -1 ) { selected_profile = 0; selected_profile_name = valid_profile_names[0]; - } + } // fill select with new options from websocket for (var i=0; i Date: Tue, 20 Apr 2021 23:31:14 +0100 Subject: [PATCH 3/4] Clean up protocol --- public/assets/js/picoreflow.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/js/picoreflow.js b/public/assets/js/picoreflow.js index 94afd4c..479b7b7 100644 --- a/public/assets/js/picoreflow.js +++ b/public/assets/js/picoreflow.js @@ -14,11 +14,11 @@ var temp_scale_display = "C"; var kwh_rate = 0.26; var currency_type = "EUR"; -var protocol = 'ws://'; +var protocol = 'ws:'; if (window.location.protocol == 'https:') { - protocol = 'wss://'; + protocol = 'wss:'; } -var host = "" + protocol + window.location.hostname + ":" + window.location.port; +var host = "" + protocol + "//" + window.location.hostname + ":" + window.location.port; var ws_status = new WebSocket(host+"/status"); var ws_control = new WebSocket(host+"/control"); var ws_config = new WebSocket(host+"/config"); From f1b8cdc91cb80aa8b129feec966f82660e2fe108 Mon Sep 17 00:00:00 2001 From: Jason Bruce Date: Wed, 28 Apr 2021 16:17:22 -0400 Subject: [PATCH 4/4] added config.gpio_sensor_di to the config file and the code for max-31856. Thanks Mark Tilles. --- config.py | 1 + lib/oven.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 29b9420..293aed7 100644 --- a/config.py +++ b/config.py @@ -41,6 +41,7 @@ thermocouple_type = MAX31856.MAX31856_S_TYPE gpio_sensor_cs = 27 gpio_sensor_clock = 22 gpio_sensor_data = 17 +gpio_sensor_di = 10 # only used with max31856 ### duty cycle of the entire system in seconds. Every N seconds a decision ### is made about switching the relay[s] on & off and for how long. diff --git a/lib/oven.py b/lib/oven.py index 17ea994..4a1f5b0 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -107,7 +107,8 @@ class TempSensorReal(TempSensor): from max31856 import MAX31856 software_spi = { 'cs': config.gpio_sensor_cs, 'clk': config.gpio_sensor_clock, - 'do': config.gpio_sensor_data } + 'do': config.gpio_sensor_data, + 'di': config.gpio_sensor_di } self.thermocouple = MAX31856(tc_type=config.thermocouple_type, software_spi = sofware_spi, units = config.temp_scale