Latest changes from who knows when...
This commit is contained in:
parent
2272510d3e
commit
95083cb46c
|
@ -87,7 +87,7 @@
|
|||
},
|
||||
"activated-channels": [ 0, 1],
|
||||
"interval": 1,
|
||||
"use_difference": false,
|
||||
"use_difference": true,
|
||||
"thresholds-for": "inside",
|
||||
"thresholds": {
|
||||
"off":{
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#! /usr/bin/env python3
|
||||
#import RPIO
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
switch = 15
|
||||
pwm = 14
|
||||
switch = 17
|
||||
pwm = 18
|
||||
fan_speed =18
|
||||
#RPIO.setup(switch, RPIO.OUT)
|
||||
|
||||
|
@ -17,7 +18,14 @@ GPIO.setup(switch, GPIO.OUT)
|
|||
GPIO.setup(pwm, GPIO.OUT)
|
||||
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 current_ts
|
||||
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")
|
||||
|
||||
|
||||
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:
|
||||
GPIO.output(switch, True)
|
||||
GPIO.output(uswitch, True)
|
||||
step = 10
|
||||
c = 0
|
||||
direction = 1
|
||||
diff=timedelta()
|
||||
fan.start(c)
|
||||
ufan.start(c)
|
||||
while True:
|
||||
if c == 100:
|
||||
direction = -1
|
||||
elif c == 0:
|
||||
direction = 1
|
||||
c += step*direction
|
||||
fan.ChangeDutyCycle(c)
|
||||
l = input().strip().split(" ")
|
||||
if len(l) == 2:
|
||||
if int(l[0]) < 0:
|
||||
GPIO.output(switch, False)
|
||||
else:
|
||||
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))
|
||||
time.sleep(5)
|
||||
# while True:
|
||||
time.sleep(0.1)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
fan.stop()
|
||||
GPIO.output(switch, False)
|
||||
#fan.stop()
|
||||
#GPIO.output(switch, False)
|
||||
GPIO.cleanup()
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import spidev
|
||||
import time
|
||||
|
@ -9,12 +9,12 @@ tnom = 25
|
|||
rnom = 10000.0
|
||||
corr = 4800
|
||||
temp_gpio = {
|
||||
0: {
|
||||
"BCM": 20,
|
||||
"Rk": 9770.0 #9770,
|
||||
},
|
||||
1: {
|
||||
"BCM": 26,
|
||||
"Rk": 9770.0 #9770,
|
||||
},
|
||||
0: {
|
||||
"BCM": 20,
|
||||
"Rk": 10000.0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,11 +61,11 @@ class LowLevel(metaclass=Singleton):
|
|||
GPIO.output(self.__cfg.get_pwm_upper()["on-off"]["BCM"], on)
|
||||
|
||||
def upper_fan_pwm(self, percent):
|
||||
self.__pwmu.ChangeDutyCycle(percent)
|
||||
self.__pwmu.ChangeDutyCycle(100 - percent)
|
||||
|
||||
def lower_fan(self, on):
|
||||
GPIO.output(self.__cfg.get_pwm_lower()["on-off"]["BCM"], on)
|
||||
|
||||
def lower_fan_pwm(self, percent):
|
||||
self.__pwml.ChangeDutyCycle(percent)
|
||||
self.__pwml.ChangeDutyCycle(100 - percent)
|
||||
|
||||
|
|
Loading…
Reference in New Issue