News:

LATEST RELEASE:  FPP 8.0 - Download from here - https://github.com/FalconChristmas/fpp/releases/tag/8.0

+-+-

+-User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+-Site Stats

Members
Total Members: 16528
Latest: fugley
New This Month: 16
New This Week: 1
New Today: 1
Stats
Total Posts: 133169
Total Topics: 16554
Most Online Today: 87
Most Online Ever: 7634
(January 21, 2020, 02:14:03 AM)
Users Online
Members: 4
Guests: 29
Total: 33

Touchscreen

Started by breese, May 19, 2022, 10:19:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

breese

I managed to get pictures and videos to display and run on my Pi B touchscreen.
I have the jumpers installed from the touchscreen to the GPIO ports 2 and 3 that are assigned for I2C1 SDA and I2C1 SCL.

I cannot figure out how to set the GPIO ports in FPP to react to a simple touch on the screen.
What I have is a picture of Santa and if someone touches the screen a video would start.
Suggestion?

You cannot view this attachment. You cannot view this attachment.

CaptainMurdoch

The touchscreen doesn't generate simple GPIO on/off events on those two pins which would trigger FPP to do anything.  The touchscreen connects to the i2c bus and generates events in Linux on a device under /dev/input and the application using the touchscreen needs to be able to read that device file, parse the events and act on them.

I have been wanting to make either a plugin or add code directly to FPP which would read from /dev/input and trigger FPP commands.  I looked into this a little with some test code but haven't tried tying it to FPP yet.  The thought was that a plugin could draw an interface on a screen using the new Pixel Overlay Model sub-model support and have regions of the screen which were 'buttons' and tied to FPP Commands.  I have a small 3.5" touchscreen display on an old Pi v1, but have only tested it for functionality, I haven't tried making any code for it yet.
-
Chris

breese

Quote from: CaptainMurdoch on May 19, 2022, 11:09:10 AMThe touchscreen doesn't generate simple GPIO on/off events on those two pins which would trigger FPP to do anything.  The touchscreen connects to the i2c bus and generates events in Linux on a device under /dev/input and the application using the touchscreen needs to be able to read that device file, parse the events and act on them.

I have been wanting to make either a plugin or add code directly to FPP which would read from /dev/input and trigger FPP commands.  I looked into this a little with some test code but haven't tried tying it to FPP yet.  The thought was that a plugin could draw an interface on a screen using the new Pixel Overlay Model sub-model support and have regions of the screen which were 'buttons' and tied to FPP Commands.  I have a small 3.5" touchscreen display on an old Pi v1, but have only tested it for functionality, I haven't tried making any code for it yet.
Thanks for the great info... I did not know any of that.
I have the 7 inch touchscreen and have a plan to put it in the dash of the Santa Sleigh I am building.
Was hoping to just have the function of a touch anywhere on the screen switch from the Santa picture, over to running the video, and when done go back to the picture.
Thanks again and I look forward to what you or anyone might come up with.

CaptainMurdoch

Save the contents of the code below to a file called TouchscreenAsButton.sh and upload it to your FPP instance and run it via the Run button on the Scripts tab in the File Manager.  You will also need to create a "TOUCH_ON" Command Preset and set it up to start your playlist or whatever other action you want.  The TOUCH_ON preset will run any time the screen is touched after the script has started.  Create the Preset first before running the script since the preset will require a fppd restart.

I tested here.  If it works for you we can get it in the FPP Script Repository.

#!/bin/bash

# ID = the device ID of the touchscreen.  This should be a number and probably will
# be 0 on a Pi with no mouse or keyboard connected.
ID=0

# You should also make a "TOUCH_ON" Command Preset in FPP and the preset will be
# run whenever the screen is touched.
# You can optionally make a "TOUCH_OFF" Command preset for when the user stops
# touching the screen.

if [ ! -f '/usr/bin/evtest' ]
then
    sudo apt-get install -y evtest
fi

DEVICE="/dev/input/event${ID}"

# Press Event   =  'type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1'
# Release Event = 'type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0'

sudo evtest ${DEVICE} 2>&1 | while read LINE
do
    case "$LINE" in
        *EV_KEY*BTN_TOUCH*,\ value\ 1)
            curl -s 'http://127.0.0.1/api/command/Trigger%20Command%20Preset/TOUCH_ON' > /dev/null
            ;;
        *EV_KEY*BTN_TOUCH*,\ value\ 0)
            curl -s 'http://127.0.0.1/api/command/Trigger%20Command%20Preset/TOUCH_OFF' > /dev/null
            ;;
    esac
done
-
Chris

breese

Quote from: CaptainMurdoch on May 19, 2022, 02:56:14 PMSave the contents of the code below to a file called TouchscreenAsButton.sh and upload it to your FPP instance and run it via the Run button on the Scripts tab in the File Manager.  You will also need to create a "TOUCH_ON" Command Preset and set it up to start your playlist or whatever other action you want.  The TOUCH_ON preset will run any time the screen is touched after the script has started.  Create the Preset first before running the script since the preset will require a fppd restart.

I tested here.  If it works for you we can get it in the FPP Script Repository.

#!/bin/bash

# ID = the device ID of the touchscreen.  This should be a number and probably will
# be 0 on a Pi with no mouse or keyboard connected.
ID=0

# You should also make a "TOUCH_ON" Command Preset in FPP and the preset will be
# run whenever the screen is touched.
# You can optionally make a "TOUCH_OFF" Command preset for when the user stops
# touching the screen.

if [ ! -f '/usr/bin/evtest' ]
then
    sudo apt-get install -y evtest
fi

DEVICE="/dev/input/event${ID}"

# Press Event   =  'type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1'
# Release Event = 'type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0'

sudo evtest ${DEVICE} 2>&1 | while read LINE
do
    case "$LINE" in
        *EV_KEY*BTN_TOUCH*,\ value\ 1)
            curl -s 'http://127.0.0.1/api/command/Trigger%20Command%20Preset/TOUCH_ON' > /dev/null
            ;;
        *EV_KEY*BTN_TOUCH*,\ value\ 0)
            curl -s 'http://127.0.0.1/api/command/Trigger%20Command%20Preset/TOUCH_OFF' > /dev/null
            ;;
    esac
done
create a "TOUCH_ON" Command Preset?
Where do I do this?

CaptainMurdoch

Quote from: breese on May 19, 2022, 03:15:12 PMcreate a "TOUCH_ON" Command Preset?
Where do I do this?

In FPP, under the "Status/Control" menu, there is a "Command Presets" menu entry.  On the Command Presets page, click the 'Add' button.  In the "Preset Name" field, enter "TOUCH_ON" in all caps minus the quotes.  On the FPP Command dropdown, select the command you want to run.  In your case, I think you want the "Start Playlist" command. That should pop up a box asking for the args for the command.  Choose the playlist name, and the Repeat and If Not Running checkboxes should probably be unchecked.  Click 'Accept Changes' then the green Save button on the top right and restart fppd.

You can test the preset by clicking the 'Run Now' button.  If that works, then the preset should get fired when you touch the touchscreen if the script I posted is running.  The script monitors the events coming from the touchscreen and looks for touch events and calls the FPP API to trigger the command preset.
-
Chris

breese

Ran the script for the first time.
Looks like the packages did not install.

Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  evemu-tools libevdev2 libevemu3
The following NEW packages will be installed:
  evemu-tools evtest libevdev2 libevemu3
0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 63.6 kB of archives.
After this operation, 238 kB of additional disk space will be used.
Get:1 http://mirror.pit.teraswitch.com/raspbian/raspbian buster/main armhf libevdev2 armhf 1.6.0+dfsg-1 [24.9 kB]
Err:2 http://mirrors.gigenet.com/raspbian/raspbian buster/main armhf libevemu3 armhf 2.7.0-1
  Cannot initiate the connection to mirrors.gigenet.com:80 (2001:1850:f000:f000:f000:f000::). - connect (101: Network is unreachable) Could not connect to mirrors.gigenet.com:80 (69.65.16.171), connection timed out
Err:3 http://mirrors.gigenet.com/raspbian/raspbian buster/main armhf evemu-tools armhf 2.7.0-1
  Cannot initiate the connection to mirrors.gigenet.com:80 (2001:1850:f000:f000:f000:f000::). - connect (101: Network is unreachable)
Err:4 http://mirrors.gigenet.com/raspbian/raspbian buster/main armhf evtest armhf 1:1.33-2
  Cannot initiate the connection to mirrors.gigenet.com:80 (2001:1850:f000:f000:f000:f000::). - connect (101: Network is unreachable)
Fetched 24.9 kB in 31s (793 B/s)

CaptainMurdoch

Can the Pi get to the internet on the network it is on?

If so, try rebooting and see if it picks up a different host to get the package from.  We might need to put another apt command in there.  I tested that script on a freshly booted Pi and it did install but I may have run other commands on there before.
-
Chris

breese

Quote from: CaptainMurdoch on May 19, 2022, 04:33:56 PMCan the Pi get to the internet on the network it is on?

If so, try rebooting and see if it picks up a different host to get the package from.  We might need to put another apt command in there.  I tested that script on a freshly booted Pi and it did install but I may have run other commands on there before.
Failed again.
This Pi was built yesterday and was able to complete the O/S and other updates on the web.
Whatever this script is looking for, it cannot find it.

CaptainMurdoch

Can you add "sudo apt-get update" before the other apt line and retry?
-
Chris

breese

#10
Done, see below. will now try the script again

sudo apt-get update                                                                                                                           
Get:1 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Get:2 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages [13.0 MB]
Get:4 http://archive.raspberrypi.org/debian buster/main armhf Packages [393 kB]
Fetched 13.5 MB in 45s (299 kB/s)
Reading package lists... Done                                                                                                                             
N: Repository 'http://archive.raspberrypi.org/debian buster InRelease' changed its 'Suite' value from 'testing' to 'oldstable'



breese

Its working on it....
Looks like its going to take a little bit..
Going to have dinner. Will check status in the morning.
Thank You Sir!

breese

#12
Good morning
Changing this message...
I got it working!

For some odd reason the Preset I created disappeared.
I recreated it, rebooted, ran the script, and now my video plays when I touch the screen!
Thank You!
Now, how do I get the script to load on startup?

CaptainMurdoch

The easiest way to start the script when fppd starts is to create another Command Preset that uses the "FPPD_STARTED" canned preset name.  Any preset that uses the FPPD_STARTED name will get run automatically when FPPD starts.  For the preset action, use the 'Run Script' command and select the script from the list.
-
Chris

CaptainMurdoch

I will look at getting the script added to the FPP Script Repository now that you have confirmed it is working.
-
Chris

Support FPP

+- Recent Topics

K2-Pi0 Unable to Start FPPD by ironsniof
Today at 07:26:40 PM

Control lights directly from the GPIO of a PI by Poporacer
Today at 12:25:42 PM

New K16s by dkulp
Today at 08:23:40 AM

FPP After Hours Music Plugin has been updated by jcross
September 14, 2024, 08:49:51 PM

Intermittent Test Pattern failure on Channel Outputs > LED Panel by k6ccc
September 14, 2024, 08:11:30 PM

P5 Matrix on FPP 8.0 help by darylc
September 14, 2024, 07:09:50 PM

Does the Falcon f16v4 support TM1814 RGBW LEDs? by JonD
September 14, 2024, 03:12:11 PM

Does the Falcon f16v3 support TM1814 RGBW LEDs? by ric878
September 14, 2024, 01:53:57 PM

USB Monitor (AIDA64 Style) by jnealand
September 14, 2024, 08:39:50 AM

What am I missing - FPP 8 artnet input configuration by jnealand
September 14, 2024, 08:32:21 AM

Powered by EzPortal
Powered by SMFPacks Menu Editor Mod