Skip to content

Commit

Permalink
Merge pull request apollo-ng#1 from apollo-ng/master
Browse files Browse the repository at this point in the history
getting up to date
  • Loading branch information
Igor-Rast authored Sep 3, 2016
2 parents af3a27b + b26a461 commit d7e7eeb
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 43 deletions.
16 changes: 16 additions & 0 deletions config.py.EXAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ log_format = '%(asctime)s %(levelname)s %(name)s: %(message)s'
listening_ip = "0.0.0.0"
listening_port = 8081

### Cost Estimate
kwh_rate = 0.26 # Rate in currency_type to calculate cost to run job
currency_type = "EUR" # Currency Symbol to show when calculating cost to run job

########################################################################
#
# GPIO Setup (BCM SoC Numbering Schema)
Expand All @@ -26,6 +30,8 @@ gpio_heat = 11 # Switches zero-cross solid-state-relay
gpio_cool = 10 # Regulates PWM for 12V DC Blower
gpio_air = 9 # Switches 0-phase det. solid-state-relay

heater_invert = 0 # switches the polarity of the heater control

### Inputs
gpio_door = 18

Expand Down Expand Up @@ -60,3 +66,13 @@ sim_R_o_nocool = 1.0 # K/W thermal resistance oven -> environment
sim_R_o_cool = 0.05 # K/W " with cooling
sim_R_ho_noair = 0.1 # K/W thermal resistance heat element -> oven
sim_R_ho_air = 0.05 # K/W " with internal air circulation


########################################################################
#
# Time and Temperature parameters

temp_scale = "c" # c = Celsius | f = Fahrenheit - Unit to display
time_scale_slope = "s" # s = Seconds | m = Minutes | h = Hours - Slope displayed in temp_scale per time_scale_slope
time_scale_profile = "s" # s = Seconds | m = Minutes | h = Hours - Enter and view target time in time_scale_profile

15 changes: 11 additions & 4 deletions lib/oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,17 @@ def set_heat(self, value):
if value:
self.heat = 1.0
if gpio_available:
GPIO.output(config.gpio_heat, GPIO.LOW)
if config.heater_invert:
GPIO.output(config.gpio_heat, GPIO.LOW)
else:
GPIO.output(config.gpio_heat, GPIO.HIGH)
else:
self.heat = 0.0
if gpio_available:
GPIO.output(config.gpio_heat, GPIO.HIGH)
if config.heater_invert:
GPIO.output(config.gpio_heat, GPIO.HIGH)
else:
GPIO.output(config.gpio_heat, GPIO.LOW)

def set_cool(self, value):
if value:
Expand Down Expand Up @@ -209,13 +215,14 @@ def __init__(self, time_step):
self.thermocouple = MAX6675(config.gpio_sensor_cs,
config.gpio_sensor_clock,
config.gpio_sensor_data,
"c")
config.temp_scale)

if config.max31855:
log.info("init MAX31855")
self.thermocouple = MAX31855(config.gpio_sensor_cs,
config.gpio_sensor_clock,
config.gpio_sensor_data,
"c")
config.temp_scale)

def run(self):
while True:
Expand Down
38 changes: 37 additions & 1 deletion picoreflowd.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def index():
@app.route('/picoreflow/:filename#.*#')
def send_static(filename):
log.debug("serving %s" % filename)
return bottle.static_file(filename, root='./public/')
return bottle.static_file(filename, root=os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), "public"))


def get_websocket_from_request():
Expand Down Expand Up @@ -110,6 +110,13 @@ def handle_storage():
if message == "GET":
log.info("GET command recived")
wsock.send(get_profiles())
elif msgdict.get("cmd") == "DELETE":
log.info("DELETE command received")
profile_obj = msgdict.get('profile')
if delete_profile(profile_obj):
msgdict["resp"] = "OK"
wsock.send(json.dumps(msgdict))
#wsock.send(get_profiles())
elif msgdict.get("cmd") == "PUT":
log.info("PUT command received")
profile_obj = msgdict.get('profile')
Expand All @@ -129,6 +136,19 @@ def handle_storage():
log.info("websocket (storage) closed")


@app.route('/config')
def handle_config():
wsock = get_websocket_from_request()
log.info("websocket (config) opened")
while True:
try:
message = wsock.receive()
wsock.send(get_config())
except WebSocketError:
break
log.info("websocket (config) closed")


@app.route('/status')
def handle_status():
wsock = get_websocket_from_request()
Expand Down Expand Up @@ -168,6 +188,22 @@ def save_profile(profile, force=False):
log.info("Wrote %s" % filepath)
return True

def delete_profile(profile):
profile_json = json.dumps(profile)
filename = profile['name']+".json"
filepath = os.path.join(profile_path, filename)
os.remove(filepath)
log.info("Deleted %s" % filepath)
return True


def get_config():
return json.dumps({"temp_scale": config.temp_scale,
"time_scale_slope": config.time_scale_slope,
"time_scale_profile": config.time_scale_profile,
"kwh_rate": config.kwh_rate,
"currency_type": config.currency_type})


def main():
ip = config.listening_ip
Expand Down
12 changes: 11 additions & 1 deletion public/assets/css/picoreflow.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ body {
background: radial-gradient(ellipse at center, rgba(242,195,67,1) 0%,rgba(241,218,54,0.26) 100%); /* W3C */
}

.ds-led-door-open {
color: rgb(214, 42, 0);
background: -moz-radial-gradient(center, ellipse cover, rgba(242,195,67,1) 0%, rgba(241,218,54,0.26) 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(242,195,67,1)), color-stop(100%,rgba(241,218,54,0.26))); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, rgba(242,195,67,1) 0%,rgba(241,218,54,0.26) 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, rgba(242,195,67,1) 0%,rgba(241,218,54,0.26) 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover, rgba(242,195,67,1) 0%,rgba(241,218,54,0.26) 100%); /* IE10+ */
background: radial-gradient(ellipse at center, rgba(242,195,67,1) 0%,rgba(241,218,54,0.26) 100%); /* W3C */
}

.ds-led-cool-active {
color: rgb(74, 159, 255);
background: -moz-radial-gradient(center, ellipse cover, rgba(124,197,239,1) 0%, rgba(48,144,209,0.26) 100%); /* FF3.6+ */
Expand Down Expand Up @@ -188,7 +198,7 @@ body {
border: none;
width: initial;
text-align: center;
width: 168px;
width: 210px;
padding: 0;
}

Expand Down
Loading

0 comments on commit d7e7eeb

Please sign in to comment.