Created
January 1, 2021 19:03
-
-
Save MatsA/66278ec6b28d17a781de48735f9d3529 to your computer and use it in GitHub Desktop.
GUI for SANE scanner made with NodeRed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"974898cd.7d1728","type":"tab","label":"Scan ","disabled":false,"info":""},{"id":"def002f2.e31fc","type":"ui_text","z":"974898cd.7d1728","group":"2cc923ff.1cf05c","order":1,"width":6,"height":3,"name":"Selected options","label":"<h1>Selected Options<h1/>","format":"{{msg.payload}}","layout":"col-center","x":830,"y":120,"wires":[]},{"id":"13bb8db9.aaa432","type":"ui_dropdown","z":"974898cd.7d1728","name":"Resolution","label":"                  <b> Resolution<b/>","tooltip":"","place":"Select option","group":"2cc923ff.1cf05c","order":4,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Auto","value":"Auto","type":"str"},{"label":"75","value":75,"type":"num"},{"label":"150","value":150,"type":"num"},{"label":"300","value":300,"type":"num"},{"label":"600","value":600,"type":"num"},{"label":"1200","value":1200,"type":"num"}],"payload":"","topic":"resolution","x":290,"y":100,"wires":[["bec26866.40d118"]]},{"id":"bec26866.40d118","type":"function","z":"974898cd.7d1728","name":"New scan settings","func":"\nswitch(msg.topic) {\n case \"resolution\":\n flow.set(\"resolution\", msg.payload)\n break;\n case \"mode\":\n flow.set(\"mode\", msg.payload)\n break;\n default:\n // code block\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":120,"wires":[["35030885.54b998"]]},{"id":"58134beb.7dddf4","type":"ui_dropdown","z":"974898cd.7d1728","name":"Mode","label":"                   <b>Mode<b/>          ","tooltip":"","place":"Select option","group":"2cc923ff.1cf05c","order":5,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Auto","value":"auto","type":"str"},{"label":"Color","value":"Color","type":"str"},{"label":"Gray","value":"Gray","type":"str"},{"label":"Line Art","value":"Lineart","type":"str"}],"payload":"","topic":"mode","x":270,"y":160,"wires":[["bec26866.40d118"]]},{"id":"20d6e226.ab9cee","type":"inject","z":"974898cd.7d1728","name":"Initialize","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":300,"y":60,"wires":[["e8dde1df.2068c","6214cf0d.40f21"]]},{"id":"e8dde1df.2068c","type":"function","z":"974898cd.7d1728","name":"Default scan settings","func":"\nflow.set(\"resolution\", 300)\nflow.set(\"mode\", \"auto\")\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":60,"wires":[["35030885.54b998"]]},{"id":"35030885.54b998","type":"function","z":"974898cd.7d1728","name":"Display scan settings","func":"\nlet resolution = flow.get(\"resolution\")\nlet mode = flow.get(\"mode\")\n\nmsg.payload = \"<br/>Resolution: \" + resolution + \"<br/> Mode:            \" + mode\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":840,"y":60,"wires":[["def002f2.e31fc"]]},{"id":"5bf58978.68d378","type":"function","z":"974898cd.7d1728","name":"Issue scan command","func":"if(msg.payload == \"scan\") {\n\n let date = new Date();\n let fileNo = (date.toLocaleTimeString()).replace(/:/g, \"-\");\n let resolution = flow.get(\"resolution\");\n let mode = flow.get(\"mode\");\n\n msg.payload = \"sudo scanimage --resolution \" + resolution + \" --mode \" + mode + \" > scan-\" + fileNo + \".ppm\"\n\nreturn msg;\n\n}\nelse {\n\n return msg[null]; \n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":840,"y":220,"wires":[["213753c7.88084c"]]},{"id":"7abd5cbc.1af274","type":"function","z":"974898cd.7d1728","name":"Set \"Please wait\" + Red","func":"\nif(msg.payload == \"scan\") {\n\n msg.background = \"red\"\n msg.topic = \"Please wait !\"\n\nreturn msg;\n\n}\nelse {\n\n return msg[null]; \n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":160,"wires":[["5d15875c.71e5a8"]]},{"id":"6214cf0d.40f21","type":"change","z":"974898cd.7d1728","name":"Set \"Press for scan\" + green","rules":[{"t":"set","p":"background","pt":"msg","to":"#097479","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Press for Scan","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":220,"wires":[["5d15875c.71e5a8"]]},{"id":"213753c7.88084c","type":"exec","z":"974898cd.7d1728","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Execute","x":300,"y":280,"wires":[[],["f898b458.1c8078"],["6214cf0d.40f21"]]},{"id":"f898b458.1c8078","type":"ui_toast","z":"974898cd.7d1728","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":false,"topic":"","name":"Error display","x":490,"y":280,"wires":[[]]},{"id":"3a4e9af0.b4bf56","type":"ui_text","z":"974898cd.7d1728","group":"2cc923ff.1cf05c","order":3,"width":0,"height":0,"name":"Change options","label":"<h1>Change Options<h1/>","format":"{{msg.payload}}","layout":"col-center","x":820,"y":280,"wires":[]},{"id":"5d15875c.71e5a8","type":"ui_template","z":"974898cd.7d1728","group":"2cc923ff.1cf05c","name":"Scan","order":2,"width":"6","height":"3","format":"<style>\n .filled { height: 100%; }\n .rounded {border-radius: 35px;}\n .bigfont {font-size: 28px;}\n .bold {font-weight: bold;}\n .bordercolor {border-color: white;}\n .borderstyle {border-style: solid;}\n .borderwidth {border-width:10px;}\n</style>\n<md-button \n\tclass=\"filled rounded bigfont bold bordercolor borderstyle borderwidth\"\n\tstyle=\"{{'background-color:'+ msg.background}}\"\n\tng-click=\"send({payload: 'scan'})\">\n\t<div ng-bind-html= \"msg.topic\"></div>\n</md-button>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","x":790,"y":160,"wires":[["5bf58978.68d378","7abd5cbc.1af274"]]},{"id":"2cc923ff.1cf05c","type":"ui_group","name":"Col_1","tab":"5639bad4.c180a4","order":1,"disp":false,"width":"6","collapse":false},{"id":"5639bad4.c180a4","type":"ui_tab","name":"Scanning","icon":"dashboard","order":6,"disabled":false,"hidden":false}] |
Author
MatsA
commented
Jan 1, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment