Use case 02 full hours bell in binary - yOyOeK1/oiyshTerminal GitHub Wiki
This use case is making full hours bell ringing hour in binary :) using two sounds. Bell rings 24 hour type. Nice brain exercise.
You will need: working node-red, sshd or other way to upload sounds files, termux-api
create file with content:
termux-media-player play /data/data/com.termux/files/home/sounds/$*
upload file to oiyshTerminal. Name it playSound.sh set properties to executable.
make directory sounds in '/data/data/com.termux/files/home/'. Upload your sound for 0 in binary there with the name bell0.mp3 and sound for 1 in binary different mp3 with name bell1.mp3.
import json to node red as a new flow. node red json:
[ { "id": "7f4830bea9c556f6", "type": "function", "z": "efa51897ea7cb7f4", "name": "", "func": "function dec2bin(dec) {\n return (dec >>> 0).toString(2);\n}\n\nconst d = new Date();\nvar hour = d.getHours();\nvar hBin = dec2bin( hour );\n\nnode.status({\n fill:'blue',\n shape: 'ring',\n text:\"houre: \"+hour+\" (\"+hBin+\")\"\n});\n\nfunction sendChar( tr, charNo, delay){\n try{\n setTimeout(\n function(){ node.send({\n payload: tr.charAt(charNo),\n mp3:\"bell\"+tr.charAt(charNo)+\".mp3\"\n }) \n },\n delay\n );\n }catch(e){}\n \n}\nfor(var c=(hBin.length-1);c>=0;c--){\n sendChar( hBin, c, (hBin.length-c)*2000);\n}\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 500, "y": 200, "wires": [ [ "b11858fd697c0a8c", "f31df6e7cb076ffe" ] ] } ]
deploy flow in node-red.