From 5b28fb099e3a3eb226813f38e34d4695c17c1348 Mon Sep 17 00:00:00 2001 From: Romain Bazile Date: Thu, 1 Jul 2021 16:25:16 +0200 Subject: [PATCH] python3 function final fix --- docs/expert_setup.md | 8 ++++++++ flows/main.json | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/expert_setup.md b/docs/expert_setup.md index 880255d..1a79c12 100644 --- a/docs/expert_setup.md +++ b/docs/expert_setup.md @@ -110,6 +110,10 @@ You can then run the following to make sure your Raspberry has the necessary com ```sh 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 ``` @@ -474,7 +478,9 @@ The MorphoCut documentation can be found [on this page](https://morphocut.readth ### Nginx Setup +To display the gallery, we need to setup an nginx webserver. +Type in the following commands: ``` sudo apt install nginx 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 ``` +If you navigate to http://planktoscope.local:80, you should see the library opened. + ### Install Node-RED #### Download and installation diff --git a/flows/main.json b/flows/main.json index ce66feb..e905f15 100644 --- a/flows/main.json +++ b/flows/main.json @@ -1413,7 +1413,7 @@ "type": "python3-function", "z": "1371dec5.76e671", "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, "x": 1110, "y": 40, @@ -5060,9 +5060,9 @@ "z": "1371dec5.76e671", "d": true, "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, - "x": 1520, + "x": 1500, "y": 40, "wires": [ []