Latest changes from who knows when...

This commit is contained in:
MMO 2019-11-24 21:16:03 +01:00
parent 2272510d3e
commit 95083cb46c
4 changed files with 53 additions and 30 deletions

View File

@ -87,7 +87,7 @@
}, },
"activated-channels": [ 0, 1], "activated-channels": [ 0, 1],
"interval": 1, "interval": 1,
"use_difference": false, "use_difference": true,
"thresholds-for": "inside", "thresholds-for": "inside",
"thresholds": { "thresholds": {
"off":{ "off":{

51
scripts/pwm.py Normal file → Executable file
View File

@ -1,10 +1,11 @@
#! /usr/bin/env python3
#import RPIO #import RPIO
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
import time import time
from datetime import datetime from datetime import datetime
from datetime import timedelta from datetime import timedelta
switch = 15 switch = 17
pwm = 14 pwm = 18
fan_speed =18 fan_speed =18
#RPIO.setup(switch, RPIO.OUT) #RPIO.setup(switch, RPIO.OUT)
@ -17,7 +18,14 @@ GPIO.setup(switch, GPIO.OUT)
GPIO.setup(pwm, GPIO.OUT) GPIO.setup(pwm, GPIO.OUT)
fan = GPIO.PWM(pwm, 25000) fan = GPIO.PWM(pwm, 25000)
GPIO.setup(fan_speed, GPIO.IN, pull_up_down=GPIO.PUD_UP) uswitch = 22
upwm = 23
GPIO.setup(uswitch, GPIO.OUT)
GPIO.setup(upwm, GPIO.OUT)
ufan = GPIO.PWM(pwm,25000)
# GPIO.setup(fan_speed, GPIO.IN, pull_up_down=GPIO.PUD_UP)
global last_ts global last_ts
global current_ts global current_ts
global diff global diff
@ -45,29 +53,44 @@ def speed_callback(channel):
# print("{:d} | \t{:.2f} | \t{} | \t{} | \t{}".format(diff.microseconds, rpm, diff, current_ts, last_ts), end="\r") # print("{:d} | \t{:.2f} | \t{} | \t{} | \t{}".format(diff.microseconds, rpm, diff, current_ts, last_ts), end="\r")
GPIO.add_event_detect(fan_speed, GPIO.FALLING, callback=speed_callback) # GPIO.add_event_detect(fan_speed, GPIO.FALLING, callback=speed_callback)
import sys
try: try:
GPIO.output(switch, True) GPIO.output(switch, True)
GPIO.output(uswitch, True)
step = 10 step = 10
c = 0 c = 0
direction = 1 direction = 1
diff=timedelta() diff=timedelta()
fan.start(c) fan.start(c)
ufan.start(c)
while True: while True:
if c == 100: l = input().strip().split(" ")
direction = -1 if len(l) == 2:
elif c == 0: if int(l[0]) < 0:
direction = 1 GPIO.output(switch, False)
c += step*direction else:
fan.ChangeDutyCycle(c) GPIO.output(switch, True)
fan.ChangeDutyCycle(100 - int(l[0]))
if int(l[1]) < 0:
GPIO.output(uswitch, False)
else:
GPIO.output(uswitch, True)
ufan.ChangeDutyCycle(100 - int(l[1]))
# if c == 100:
# direction = -1
# elif c == 0:
# direction = 1
# c += step*direction
# fan.ChangeDutyCycle(c)
# print("{} ".format(c)) # print("{} ".format(c))
time.sleep(5) # while True:
time.sleep(0.1)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
finally: finally:
fan.stop() #fan.stop()
GPIO.output(switch, False) #GPIO.output(switch, False)
GPIO.cleanup() GPIO.cleanup()

10
scripts/test.py Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/usr/bin/python #! /usr/bin/env python3
import spidev import spidev
import time import time
@ -9,12 +9,12 @@ tnom = 25
rnom = 10000.0 rnom = 10000.0
corr = 4800 corr = 4800
temp_gpio = { temp_gpio = {
0: {
"BCM": 20,
"Rk": 9770.0 #9770,
},
1: { 1: {
"BCM": 26, "BCM": 26,
"Rk": 9770.0 #9770,
},
0: {
"BCM": 20,
"Rk": 10000.0 "Rk": 10000.0
} }
} }

View File

@ -61,11 +61,11 @@ class LowLevel(metaclass=Singleton):
GPIO.output(self.__cfg.get_pwm_upper()["on-off"]["BCM"], on) GPIO.output(self.__cfg.get_pwm_upper()["on-off"]["BCM"], on)
def upper_fan_pwm(self, percent): def upper_fan_pwm(self, percent):
self.__pwmu.ChangeDutyCycle(percent) self.__pwmu.ChangeDutyCycle(100 - percent)
def lower_fan(self, on): def lower_fan(self, on):
GPIO.output(self.__cfg.get_pwm_lower()["on-off"]["BCM"], on) GPIO.output(self.__cfg.get_pwm_lower()["on-off"]["BCM"], on)
def lower_fan_pwm(self, percent): def lower_fan_pwm(self, percent):
self.__pwml.ChangeDutyCycle(percent) self.__pwml.ChangeDutyCycle(100 - percent)