python3 function final fix
This commit is contained in:
parent
b51347e5ee
commit
5b28fb099e
|
@ -110,6 +110,10 @@ You can then run the following to make sure your Raspberry has the necessary com
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt install build-essential python3 python3-pip
|
sudo apt install build-essential python3 python3-pip
|
||||||
|
sudo update-alternatives --install $(which python) python $(readlink -f $(which python2)) 1
|
||||||
|
sudo update-alternatives --install $(which python) python $(readlink -f $(which python3)) 2
|
||||||
|
sudo update-alternatives --config python
|
||||||
|
# Choose line 0
|
||||||
mkdir test libraries
|
mkdir test libraries
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -474,7 +478,9 @@ The MorphoCut documentation can be found [on this page](https://morphocut.readth
|
||||||
|
|
||||||
### Nginx Setup
|
### Nginx Setup
|
||||||
|
|
||||||
|
To display the gallery, we need to setup an nginx webserver.
|
||||||
|
|
||||||
|
Type in the following commands:
|
||||||
```
|
```
|
||||||
sudo apt install nginx
|
sudo apt install nginx
|
||||||
sudo rm /etc/nginx/sites-enabled/default
|
sudo rm /etc/nginx/sites-enabled/default
|
||||||
|
@ -482,6 +488,8 @@ sudo ln -s /home/pi/PlanktoScope/scripts/gallery/gallery.conf /etc/nginx/sites-e
|
||||||
sudo nginx -t && sudo systemctl reload nginx
|
sudo nginx -t && sudo systemctl reload nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you navigate to http://planktoscope.local:80, you should see the library opened.
|
||||||
|
|
||||||
### Install Node-RED
|
### Install Node-RED
|
||||||
|
|
||||||
#### Download and installation
|
#### Download and installation
|
||||||
|
|
|
@ -1413,7 +1413,7 @@
|
||||||
"type": "python3-function",
|
"type": "python3-function",
|
||||||
"z": "1371dec5.76e671",
|
"z": "1371dec5.76e671",
|
||||||
"name": "fan control",
|
"name": "fan control",
|
||||||
"func": "#!/usr/bin/python3\nimport smbus2 as smbus\n\nstate = msg[\"payload\"]\n\nbus = smbus.SMBus(1)\n\nDEVICE_ADDRESS = 0x0d\n\ntry:\n # command happens twice, for reasons\n if state == \"off\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n if state == \"on\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\nexcept:\n pass",
|
"func": "try:\n import smbus2 as smbus\n \n state = msg[\"payload\"]\n \n bus = smbus.SMBus(1)\n \n DEVICE_ADDRESS = 0x0d\n # command happens twice, for reasons\n if state == \"off\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n if state == \"on\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\nexcept:\n pass",
|
||||||
"outputs": 1,
|
"outputs": 1,
|
||||||
"x": 1110,
|
"x": 1110,
|
||||||
"y": 40,
|
"y": 40,
|
||||||
|
@ -5060,9 +5060,9 @@
|
||||||
"z": "1371dec5.76e671",
|
"z": "1371dec5.76e671",
|
||||||
"d": true,
|
"d": true,
|
||||||
"name": "fan temperature",
|
"name": "fan temperature",
|
||||||
"func": "import smbus2 as smbus\nbus = smbus.SMBus(1)\n\naddr = 0x0d\nfan_reg = 0x08\n\ntemp = float( msg[\"payload\"])\n\n# 0x01 full speed, 0x02: 20% speed, ..., 0x09: 90% speed\n\nif temp < 38:\n bus.write_byte_data(addr, fan_reg, 0x00)\nelif temp < 43:\n bus.write_byte_data(addr, fan_reg, 0x02)\nelif temp < 46:\n bus.write_byte_data(addr, fan_reg, 0x04)\nelif temp < 48:\n bus.write_byte_data(addr, fan_reg, 0x06)\nelif temp < 52:\n bus.write_byte_data(addr, fan_reg, 0x08)\nelse:\n bus.write_byte_data(addr, fan_reg, 0x01)\n\nreturn msg",
|
"func": "import smbus\nbus = smbus.SMBus(1)\n\naddr = 0x0d\nfan_reg = 0x08\n\ntemp = float( msg[\"payload\"])\n\n# 0x01 full speed, 0x02: 20% speed, ..., 0x09: 90% speed\n\nif temp < 38:\n bus.write_byte_data(addr, fan_reg, 0x00)\nelif temp < 43:\n bus.write_byte_data(addr, fan_reg, 0x02)\nelif temp < 46:\n bus.write_byte_data(addr, fan_reg, 0x04)\nelif temp < 48:\n bus.write_byte_data(addr, fan_reg, 0x06)\nelif temp < 52:\n bus.write_byte_data(addr, fan_reg, 0x08)\nelse:\n bus.write_byte_data(addr, fan_reg, 0x01)\n\nreturn msg",
|
||||||
"outputs": 1,
|
"outputs": 1,
|
||||||
"x": 1520,
|
"x": 1500,
|
||||||
"y": 40,
|
"y": 40,
|
||||||
"wires": [
|
"wires": [
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Reference in a new issue