RPI 3B+, turn-off touchscreen when inactive and activate on touch

Hello,

I am a new node-red user, and have got good a dashboard running on the official 7" touchscreen.

I want to turn the screen of when it is not in use, and turn it back on when need to. In future I will probably get a PIR sensor to do it, but now I have planned to implement following:

  • A watchdog is catching signals from ui_control node, and if no signals are present in for example 15 minutes, a command will be send via EXEC -node

echo 0 > /sys/class/backlight/rpi_backlight/bl_power -> this will turn the touchscreen backlight off but touching is still active. I would then deactivate/hide all tabs so that when black screen is pressed, there would be no accidental actions.

Then I would like to turn backlight back on with corresponding command
echo 1 > /sys/class/backlight/rpi_backlight/bl_power

but the problem is here:

UI_control node would send command only if something was activated or changed: I don't want to do it, as some active element should be touched, and when screen is black you don't know what you are pressing. So, is there a way for node-red to register a touch input even if tabs were inactive?

I think I could make it happen following way, but it's kinda workaround:

  • create a tab called 'screensaver'
  • add fullscreen button to than tab
  • make the fullscreen button activate all tabs and set backlight to 1

What do you think would be the best option?

Interesting and I am interested.

What I see:
You have routines that monitor the screen and if it isn't touched for... n minutes: it turns off the back light.

But you are also wanting to wipe the screen so no one can accidentally press anything.

Thought:
Make a blank screen.
When the back light is turned off, you also send a UI command (or what ever it is called) to then show the blank screen.

Example code:

[{"id":"9a3d3874.9fdf78","type":"ui_template","z":"6dd5ca4d.d1958c","group":"1a1680e.112ee7f","name":"TEL","order":1,"width":"1","height":"1","format":"<div id=\"GButtonM_TEL\">\n    <md-button class=\"md-button program-names darkred\">\n        <i class=\"material-icons\">\n            <span> track_changes</span>\n            <md-tooltip>Telemetry</md-tooltip>\n        </i>\n    </md-button>\n</div>\n\n<script>\n\n(function($scope) {\n\n$('#GButtonM_TEL').on('click', function(e) {\n    e.preventDefault(); //prevent default behavior\n    $scope.send({\"topic\":\"momentary_regular\",\"payload\": \"BedPi Telemetry\"});\n});\n    \n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":4650,"y":4560,"wires":[["aea8bfd3.caf268"]]},{"id":"aea8bfd3.caf268","type":"link out","z":"6dd5ca4d.d1958c","name":"Menu","links":["1211148c.996103","e4ee0bad.0a65d","9267665b.45b478"],"x":4830,"y":4560,"wires":[],"l":true},{"id":"9267665b.45b478","type":"link in","z":"6dd5ca4d.d1958c","name":"MENU","links":["aea8bfd3.caf268","f4cda30b.8f21d8","4c993a08.28ee04","4379483c.943be8","32a168f9.467de8","8b04cfd7.4c835","88d31639.e1251","ac9afb66.8f1578","89e46119.4b177","cd0f3073.020e58","4a15a967.ec2a58"],"x":4630,"y":4440,"wires":[["b81f023c.14308","ca8479a5.88833"]],"l":true},{"id":"b81f023c.14308","type":"ui_ui_control","z":"6dd5ca4d.d1958c","name":"","events":"all","x":4810,"y":4440,"wires":[[]]},{"id":"1a1680e.112ee7f","type":"ui_group","name":"EXIT","tab":"e92ac76d.c24e7","order":8,"disp":false,"width":"2","collapse":false},{"id":"e92ac76d.c24e7","type":"ui_tab","name":"Real_World_Control","icon":"dashboard","order":7,"disabled":false,"hidden":false}]

Yes, this is from a button, but I hope it explains the idea.

The name you inject is the same as the blank page/screen you make.

That's my way of seeing it.

Ok.... On the blank screen you make/put a full screen button.....

I can't read. :wink:

And....
(sorry)

When this button is pressed, you maybe want to do some tricks so if it is accidentally bumped, it turns on and then makes sure you want to then activate the screen/bring it back to life.

If not, it puts the screen back to sleep

(From another post)
example code as an example.... (oh boy, sorry)

[
    {
        "id": "4acb89a30b69f58e",
        "type": "ui_switch",
        "z": "2e6686c4918f199d",
        "name": "",
        "label": "safety lock",
        "tooltip": "",
        "group": "c7a27394.057878",
        "order": 14,
        "width": 4,
        "height": 1,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 230,
        "y": 2850,
        "wires": [
            [
                "d0fb6010062ab6ed"
            ]
        ]
    },
    {
        "id": "eea3e707e440f91b",
        "type": "ui_button",
        "z": "2e6686c4918f199d",
        "name": "",
        "group": "c7a27394.057878",
        "order": 15,
        "width": 5,
        "height": 1,
        "passthru": false,
        "label": "Action",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 570,
        "y": 2850,
        "wires": [
            [
                "7f2a4ffc73dbf79b",
                "086a722972596909"
            ]
        ]
    },
    {
        "id": "d0fb6010062ab6ed",
        "type": "change",
        "z": "2e6686c4918f199d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "enabled",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 410,
        "y": 2850,
        "wires": [
            [
                "eea3e707e440f91b"
            ]
        ]
    },
    {
        "id": "7f2a4ffc73dbf79b",
        "type": "change",
        "z": "2e6686c4918f199d",
        "name": "disable ",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 700,
        "y": 2800,
        "wires": [
            [
                "4acb89a30b69f58e"
            ]
        ]
    },
    {
        "id": "44496964eaa7257e",
        "type": "inject",
        "z": "2e6686c4918f199d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 170,
        "y": 2910,
        "wires": [
            [
                "4acb89a30b69f58e"
            ]
        ]
    },
    {
        "id": "086a722972596909",
        "type": "function",
        "z": "2e6686c4918f199d",
        "name": "actual action goes on",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 740,
        "y": 2880,
        "wires": [
            []
        ]
    },
    {
        "id": "c7a27394.057878",
        "type": "ui_group",
        "name": "CHART",
        "tab": "54e197d8.7f7fe8",
        "order": 2,
        "disp": false,
        "width": "9",
        "collapse": false
    },
    {
        "id": "54e197d8.7f7fe8",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

I hope you get the idea.

I did get the idea =) I will look into this later, right now I am thinking about buying a 8" Android tablet for UI in livingroom wall - after all, the raspberry case is quite thick as it holds the Pi inside also and the viewing angles are so narrow that it is difficult to find a nice spot for it. If you want to see what's on the screen while standing, and put the screen higher, you can't see the display from couch because of the viewing angle.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.