kopia lustrzana https://github.com/cyoung/stratux
Daemonize stratux-screen.py and fancontrol.py.
rodzic
333bb6c3ce
commit
0588f8b0e7
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
/usr/bin/stratux-screen.py
|
/usr/bin/stratux-screen.py start
|
||||||
/usr/bin/fancontrol.py
|
/usr/bin/fancontrol.py start
|
||||||
|
|
|
@ -9,20 +9,28 @@ import RPi.GPIO as GPIO
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Return CPU temperature as float
|
from daemon import runner
|
||||||
def getCPUtemp():
|
|
||||||
|
class FanControl():
|
||||||
|
# Return CPU temperature as float
|
||||||
|
def getCPUtemp(self):
|
||||||
cTemp = os.popen('vcgencmd measure_temp').readline()
|
cTemp = os.popen('vcgencmd measure_temp').readline()
|
||||||
return float(cTemp.replace("temp=","").replace("'C\n",""))
|
return float(cTemp.replace("temp=","").replace("'C\n",""))
|
||||||
|
|
||||||
GPIO.setmode(GPIO.BOARD)
|
def __init__(self):
|
||||||
GPIO.setup(11,GPIO.OUT)
|
self.stdin_path = '/dev/null'
|
||||||
GPIO.setwarnings(False)
|
self.stdout_path = '/dev/tty'
|
||||||
p=GPIO.PWM(11,1000)
|
self.stderr_path = '/dev/tty'
|
||||||
PWM = 50
|
self.pidfile_path = '/var/run/fancontrol.pid'
|
||||||
|
self.pidfile_timeout = 5
|
||||||
while True:
|
def run(self):
|
||||||
|
GPIO.setmode(GPIO.BOARD)
|
||||||
CPU_temp = getCPUtemp()
|
GPIO.setup(11,GPIO.OUT)
|
||||||
|
GPIO.setwarnings(False)
|
||||||
|
p=GPIO.PWM(11,1000)
|
||||||
|
PWM = 50
|
||||||
|
while True:
|
||||||
|
CPU_temp = self.getCPUtemp()
|
||||||
if CPU_temp > 40.5:
|
if CPU_temp > 40.5:
|
||||||
PWM = min(max(PWM + 1, 0), 100)
|
PWM = min(max(PWM + 1, 0), 100)
|
||||||
p.start(PWM)
|
p.start(PWM)
|
||||||
|
@ -30,5 +38,8 @@ while True:
|
||||||
PWM = min(max(PWM - 1, 0), 100)
|
PWM = min(max(PWM - 1, 0), 100)
|
||||||
p.start(PWM)
|
p.start(PWM)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
GPIO.cleanup()
|
||||||
|
|
||||||
GPIO.cleanup()
|
fancontrol = FanControl()
|
||||||
|
daemon_runner = runner.DaemonRunner(fancontrol)
|
||||||
|
daemon_runner.do_action()
|
||||||
|
|
|
@ -126,7 +126,7 @@ sed -i /etc/default/keyboard -e "/^XKBLAYOUT/s/\".*\"/\"us\"/"
|
||||||
cp -f config.txt mnt/boot/
|
cp -f config.txt mnt/boot/
|
||||||
|
|
||||||
#external OLED screen
|
#external OLED screen
|
||||||
apt-get install -y libjpeg-dev i2c-tools python-smbus python-pip python-dev python-pil screen
|
apt-get install -y libjpeg-dev i2c-tools python-smbus python-pip python-dev python-pil python-daemon screen
|
||||||
git clone https://github.com/rm-hull/ssd1306
|
git clone https://github.com/rm-hull/ssd1306
|
||||||
cd ssd1306 && python setup.py install
|
cd ssd1306 && python setup.py install
|
||||||
cp /root/stratux/test/screen/screen.py /usr/bin/stratux-screen.py
|
cp /root/stratux/test/screen/screen.py /usr/bin/stratux-screen.py
|
||||||
|
|
|
@ -9,18 +9,27 @@ import urllib2
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
|
||||||
font2 = ImageFont.truetype('/etc/stratux-screen/CnC_Red_Alert.ttf', 12)
|
from daemon import runner
|
||||||
oled = ssd1306(port=1, address=0x3C)
|
|
||||||
|
|
||||||
with canvas(oled) as draw:
|
class StratuxScreen():
|
||||||
|
def __init__(self):
|
||||||
|
self.stdin_path = '/dev/null'
|
||||||
|
self.stdout_path = '/dev/tty'
|
||||||
|
self.stderr_path = '/dev/tty'
|
||||||
|
self.pidfile_path = '/var/run/fancontrol.pid'
|
||||||
|
self.pidfile_timeout = 5
|
||||||
|
def run(self):
|
||||||
|
font2 = ImageFont.truetype('/etc/stratux-screen/CnC_Red_Alert.ttf', 12)
|
||||||
|
oled = ssd1306(port=1, address=0x3C)
|
||||||
|
|
||||||
|
with canvas(oled) as draw:
|
||||||
logo = Image.open('/etc/stratux-screen/stratux-logo-64x64.bmp')
|
logo = Image.open('/etc/stratux-screen/stratux-logo-64x64.bmp')
|
||||||
draw.bitmap((32, 0), logo, fill=1)
|
draw.bitmap((32, 0), logo, fill=1)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
n = 0
|
||||||
|
|
||||||
n = 0
|
while 1:
|
||||||
|
|
||||||
while 1:
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
response = urllib2.urlopen('http://localhost/getStatus')
|
response = urllib2.urlopen('http://localhost/getStatus')
|
||||||
getStatusHTML = response.read()
|
getStatusHTML = response.read()
|
||||||
|
@ -36,9 +45,6 @@ while 1:
|
||||||
getTowersData = json.loads(getTowersHTML)
|
getTowersData = json.loads(getTowersHTML)
|
||||||
NumTowers = len(getTowersData)
|
NumTowers = len(getTowersData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
with canvas(oled) as draw:
|
with canvas(oled) as draw:
|
||||||
pad = 2 # Two pixels on the left and right.
|
pad = 2 # Two pixels on the left and right.
|
||||||
text_margin = 25
|
text_margin = 25
|
||||||
|
@ -71,7 +77,12 @@ while 1:
|
||||||
t = "GPS Sat: %d/%d/%d" % (getStatusData["GPS_satellites_locked"], getStatusData["GPS_satellites_seen"], getStatusData["GPS_satellites_tracked"])
|
t = "GPS Sat: %d/%d/%d" % (getStatusData["GPS_satellites_locked"], getStatusData["GPS_satellites_seen"], getStatusData["GPS_satellites_tracked"])
|
||||||
if getStatusData["GPS_solution"] == "GPS + SBAS (WAAS / EGNOS)":
|
if getStatusData["GPS_solution"] == "GPS + SBAS (WAAS / EGNOS)":
|
||||||
t = t + " (WAAS)"
|
t = t + " (WAAS)"
|
||||||
print t
|
#print t
|
||||||
draw.text((pad, 45), t, font=font2, fill=255)
|
draw.text((pad, 45), t, font=font2, fill=255)
|
||||||
|
|
||||||
n = n+1
|
n = n+1
|
||||||
|
|
||||||
|
|
||||||
|
stratuxscreen = StratuxScreen()
|
||||||
|
daemon_runner = runner.DaemonRunner(stratuxscreen)
|
||||||
|
daemon_runner.do_action()
|
||||||
|
|
Ładowanie…
Reference in New Issue