Jump to content

Soft Keypadlinc-like Console from Raspberry Pi


kck

Recommended Posts

@kck

As a bit more data, there were errors with the latest stretch on X.  The calibration was way off.  I solved the issue by adding the following to /etc/X11/xorg.conf.d/99-calibration.conf:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "Goodix Capacitive TouchScreen"
        Option  "TransformationMatrix"  "1.69 0 -0.68 0 0.63 0.38 0 0 1"
EndSection

Don't know if that means anything to you or could help.

Link to comment

That's odd because to my knowledge capacitive screens don't need calibration.  They just return pixel coordinates.  Just so I am clear, this latest somewhat working setup has pi7 as the screentype and the touchscreen type constant that matches what you get from the system device?  I may need to see if I can find some better documentation for the screen and possibly add some debug info to a beta to sort out the touch mismatches.  There are reports I find in Google about calibration issues on that screen but they make no sense if it really is a cap screen.

Link to comment

Hi again Kevin

I think I may have  hopefully only one more issue. The console doesn't seem to autostart. When I do a start using sudo systemctl start softconsole I get this error.

Failed to start boot-softconsole.mount Unit boot-softconsole.mount not found.

Thanks again for any suggestions.

Gary

Link to comment

@garybixler

That suggests something is wrong with your systemctl service file.  Did you edit it in some way?   I have never seen anything like "boot-softconsole" so I can't really help there - that is happening before softconsole ever starts apparently.  I can tell you that there should be a file in /usr/lib/system/system with the name softconsole.service and it should be identical to the file in ~/consolestable/scripts/softconsole.service.  By the way - what version of Raspbian did you load?  You should be on the Stretch version from 04-08 (or possibly an earlier version of Stretch).  There is a Buster release now available but I just briefly tried an install with that and there seemed to be issues.  But that only appeared in the last day or so.  Don't use that for now.

@bambamf16

When you say the console won't autostart what symptom are you seeing of that?  Look at systemctl status softconsole to see what was going on or scan /var/log/syslog for entries starting with "softconsole" to see if you see any error messages, exception reports etc.  By the way, those timestamp files are indeed debug log file that should be going elsewhere.  Just delete them and I will look at avoiding them on early exits for the future.

Regarding the screen calibration stuff;  I am attaching a file below that you should run to test the screen from the perspective of my console touchhandler.  First, turn off the creation of a desktop on the console screen by running (from the VNC terminal) sudo raspi-config and selecting boot options, then desktop, then Console Autologin (option B2).  This gets rid of any interference from the X desktop.  Reboot and you should just see a text terminal on the pi screen.  Then run the program  with sudo python testtouchhandler.py from the virtual terminal.  You should see some output then a request to touch the screen.  Every touch of the screen should result in some coordinates showing Press, possibly Move(s) when your finger shifts, and Release.  Drag your finger from someplace on the screen off to each side (left, right, top, bottom) a few times each.  What I'm trying to collect is the min and max coordinates reported in each direction.  Then hit ctl-C and you should see a report of those min and max values.  Those are what I'd like back.  By the way, you might also see if the screen seems sensitive at all places.  Any touch should give a set of touch coordinates so if you thought things seemed non-responsive with the console running on a part of the screen, see if you get a response in those same spots with the test program.  Hope this all makes sense - essentially I'm trying to discover what your screen reports for touches in the x (horizontal) and y (vertical) directions.  One other thing you can verify is that my x and y agree with the orientation you are using.  If you touch the left bottom corner of the screen you should be seeing a coordinate with a low first value and a high second value (ignore the 0 that shows as the first value in every touch report).  In fact, it would probably be useful to just do a touch in each corner and tell me the values for the upper left, upper right, lower left, and lower right to make sure I orient the touch space correctly to the display space. 

Kevin

testtouchhandler.py

Link to comment

No editing beyond the pisetup.sh file. I did find softconsole.service file in  /usr/lib/systemb/system.  No system/system. I also found the same file in 

~/consolestable/scripts/

Using  2019-04-08-raspbien-stretch-full.img

I have rebuilt the pi cd card a few times from scratch.  It did the updates.

Link to comment

@kck

This is the systemctl status info for softconsole:

● softconsole.service - SoftConsole
   Loaded: loaded (/usr/lib/systemd/system/softconsole.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2019-06-27 16:19:28 CDT; 2s ago
  Process: 1328 ExecStart=/home/pi/consolestable/runconsole.py (code=exited, status=203/EXEC)
  Process: 1327 ExecStartPre=/bin/sleep 5 (code=exited, status=0/SUCCESS)

Jun 27 16:19:28 SoftConsoleTest systemd[1]: softconsole.service: Unit entered failed state.
Jun 27 16:19:28 SoftConsoleTest systemd[1]: softconsole.service: Failed with result 'exit-code'.

I get the following error with the testtouchhandler.py:

pi@SoftConsoleTest:~/consolestable $ sudo python -u testtouchhandler.py
open /dev/fb1: No such file or directory
Starting touch hw search
/sys/class/input/event0
Touch device: Goodix Capacitive TouchScreen
Traceback (most recent call last):
  File "testtouchhandler.py", line 293, in <module>
    ts = Touchscreen()
  File "testtouchhandler.py", line 138, in __init__
    self._f_device = io.open(self._touch_device(), 'rb', self.EVENT_SIZE)
  File "testtouchhandler.py", line 273, in _touch_device
    raise RuntimeError('Unable to locate touchscreen device')
RuntimeError: Unable to locate touchscreen device

Thanks you for taking the time to help me.  While I am proficient in old, crappy programming languages (VisualBasic) I am not learned on anything newer.  Where would be a good place to start learning python, javascript, or anything new?

Jeff

Link to comment

I was able to get the log:

un 27 16:45:23 PiConsole systemd[1]: Started SoftConsole.
Jun 27 16:45:30 PiConsole softconsole[26717]: 06-27-19 16:45:30 Console ( 26719) starting in /home/pi/consolestable
Jun 27 16:45:31 PiConsole softconsole[26717]: 26726(1561668331.29783): Logger loop ended
Jun 27 16:45:31 PiConsole softconsole[26717]: Traceback (most recent call last):
Jun 27 16:45:31 PiConsole softconsole[26717]:   File "console.py", line 143, in <module>
Jun 27 16:45:31 PiConsole softconsole[26717]:     utilities.InitializeEnvironment()
Jun 27 16:45:31 PiConsole softconsole[26717]:   File "/home/pi/consolestable/utilities.py", line 98, in InitializeEnvironment
Jun 27 16:45:31 PiConsole softconsole[26717]:     hw.initOS(scrntyp)
Jun 27 16:45:31 PiConsole softconsole[26717]:   File "/home/pi/consolestable/hw.py", line 139, in initOS
Jun 27 16:45:31 PiConsole softconsole[26717]:     GoBright(100)
Jun 27 16:45:31 PiConsole softconsole[26717]:   File "/home/pi/consolestable/hw.py", line 56, in GoBright
Jun 27 16:45:31 PiConsole softconsole[26717]:     GoDimPi7(level)
Jun 27 16:45:31 PiConsole softconsole[26717]:   File "/home/pi/consolestable/hw.py", line 147, in GoDimPi7
Jun 27 16:45:31 PiConsole softconsole[26717]:     with open('/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/brightness', 'w') as f:
Jun 27 16:45:31 PiConsole softconsole[26717]: FileNotFoundError: [Errno 2] No such file or directory: '/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/brightness'
Jun 27 16:45:31 PiConsole softconsole[26717]: 06-27-19 16:45:30 Exiting with history trace (0)
Jun 27 16:45:31 PiConsole softconsole[26717]: mvtops exception: [Errno 2] No such file or directory: '/Current/'
Jun 27 16:45:31 PiConsole systemd[1]: softconsole.service: Main process exited, code=exited, status=1/FAILURE
Jun 27 16:45:31 PiConsole systemd[1]: softconsole.service: Unit entered failed state.
Jun 27 16:45:31 PiConsole systemd[1]: softconsole.service: Failed with result 'exit-code'.
Jun 27 16:45:34 PiConsole systemd[1]: softconsole.service: Service hold-off time over, scheduling restart.
Jun 27 16:45:34 PiConsole systemd[1]: Stopped SoftConsole.
Jun 27 16:45:34 PiConsole systemd[1]: Starting SoftConsole...
Jun 27 16:45:40 PiConsole softconsole[26736]: Starting using directory: consolestable
Jun 27 16:45:40 PiConsole systemd[1]: Started SoftConsole.
Jun 27 16:45:46 PiConsole softconsole[26736]: 06-27-19 16:45:46 Console ( 26738) starting in /home/pi/consolestable
Jun 27 16:45:47 PiConsole softconsole[26736]: 26746(1561668347.5379994): Logger loop ended
Jun 27 16:45:47 PiConsole softconsole[26736]: Traceback (most recent call last):
Jun 27 16:45:47 PiConsole softconsole[26736]:   File "console.py", line 143, in <module>
Jun 27 16:45:47 PiConsole softconsole[26736]:     utilities.InitializeEnvironment()
Jun 27 16:45:47 PiConsole softconsole[26736]:   File "/home/pi/consolestable/utilities.py", line 98, in InitializeEnvironment
Jun 27 16:45:47 PiConsole softconsole[26736]:     hw.initOS(scrntyp)
Jun 27 16:45:47 PiConsole softconsole[26736]:   File "/home/pi/consolestable/hw.py", line 139, in initOS
Jun 27 16:45:47 PiConsole softconsole[26736]:     GoBright(100)
Jun 27 16:45:47 PiConsole softconsole[26736]:   File "/home/pi/consolestable/hw.py", line 56, in GoBright
Jun 27 16:45:47 PiConsole softconsole[26736]:     GoDimPi7(level)
Jun 27 16:45:47 PiConsole softconsole[26736]:   File "/home/pi/consolestable/hw.py", line 147, in GoDimPi7
Jun 27 16:45:47 PiConsole softconsole[26736]:     with open('/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/brightness', 'w') as f:
Jun 27 16:45:47 PiConsole softconsole[26736]: FileNotFoundError: [Errno 2] No such file or directory: '/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/brightness'
Jun 27 16:45:47 PiConsole softconsole[26736]: 06-27-19 16:45:46 Exiting with history trace (0)
Jun 27 16:45:47 PiConsole softconsole[26736]: mvtops exception: [Errno 2] No such file or directory: '/Current/'
 

 

Link to comment

@bambamf16

Oops - I duplicated your type with capital S.  Can you just edit that test program to a) change the "fb1" to "fb0" and capitalize the S in the string with Goodix?  That should make it run.

That 203 Exit according to a google search says that systemd didn't know the interpreter to use.  But the runconsole.py (which is just a smaller version choosing program) has the #!/usr/bin/python3 at the top which works fine for me.  One person did comment that if the file had been left in DOS terminator mode that would mess up the interpretation of the shebang at the start.  Any chance you happened to have it open for an edit?  What you should see in a systemctl status is:

● softconsole.service - SoftConsole
   Loaded: loaded (/usr/lib/systemd/system/softconsole.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-06-04 10:19:01 PDT; 3 weeks 2 days ago
  Process: 4058 ExecStart=/home/pi/consolestable/runconsole.py (code=exited, status=0/SUCCESS)
  Process: 4057 ExecStartPre=/bin/sleep 5 (code=exited, status=0/SUCCESS)
 Main PID: 4062 (python3)
   CGroup: /system.slice/softconsole.service
           ├─4062 python3 console.py
           ├─4069 python3 console.py
           └─4093 python3 console.py

Worst case I think you could edit the service file to say 

ExecStart=/usr/bin/python3 /home/pi/consolestable/runconsole.py

but really it should work fine the way it is.

 

Link to comment

@garybixler

What screen are you using?  The console is looking for the control "file" for a 7 inch Adafruit PITFT.  So presumably you installed specifying that screen type?  If you have that screen the system should have created an entry with the path /sys/devices/platform/rpi_backlight/backlight/rpi_backlight/brightness.  Does that exist on your system?  If you are using one of the other supported screens then the dimming is done differently and that code would be replaced by other code.


 

 

Link to comment

This file does not exist. I am just using a 7" touch screen I got from amazon supposedly for PI.  So I picked pi7 as my screen type.

It does work fine on the pi but maybe not so much for the console. Also there was nothing to install for it's use.  What 7" screen should I have.

Link to comment

The screen that the system is tested for is the Raspberry Pi foundation official 7" screen.  I'd bet that you have a Chinese screen - that's fine but unfortunately may give issues for the Console.  How is the screen connected to the Pi - via HDMI cable or via the direct ribbon cable?  Also, does the screen have any documentation regarding dimming it?  I may be able to just disable dimming for you and see if things will work.

Kevin

Link to comment

Yup - that's definitely a different screen.  You can get by the dimming issue with a small edit to a file for now if you want to try it.  In consolestable open the file hw.py with sudo nano.

All the way at the very bottom of the file you will find:

def GoDimPi7(level):
   with open('/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/brightness', 'w') as f:
      f.write(str(level * 255 // 100))

Delete the last 2 lines and replace with a single line that has a tab then pass, i.e., it should then look like:

def GoDimPi7(level):
   pass

Make sure that the indentation is a single tab - not spaces.  Exit with ctl-X and accept the write of the file.  This should make brightness control a no-op.  Now beyond this I am not sure whether the HDMI screen will work.  It's a completely different type of output system but it is worth a try.  Unfortunately I don't have an HDMI screen to try things on.

Kevin

Link to comment

@kck

I am attaching a text file with the results of my touch test.  I did several runs.  The final run is labeled with each corner (UL, UR, LL, LR).  Thanks again.  I think you are close!

Here is the latest systemctl status softconsole:

● softconsole.service - SoftConsole
   Loaded: loaded (/usr/lib/systemd/system/softconsole.service; enabled; vendor preset: enabled)
   Active: activating (start-pre) since Thu 2019-06-27 19:52:58 CDT; 4s ago
  Process: 895 ExecStart=/usr/bin/python3 ExecStart=/home/pi/consolestable/runconsole.py (code=exited, status=2)
Cntrl PID: 899 (sleep)
   CGroup: /system.slice/softconsole.service
           └─control
             └─899 /bin/sleep 5

Jun 27 19:52:58 SoftConsoleTest systemd[1]: Starting SoftConsole...

 

Jeff

Hyperpixel 4.0 Touch Window Values.rtf

Link to comment

You have and extra ExecStart it looks like.  The stuff after the '=' is a normal Linux command to execute.  Also note that you should wait a bit before looking since the sleep thing always delays the actual console start by 5 seconds from when the service is nominally started.  It's really only there to keep tight error restarts from happening.  I'll look at the touch stuff in a bit (dinner time lest my wife get too upset with me :-))

Link to comment

Quick question: are you running the screen in portrait or landscape orientation?  Looks like portrait but wanted to check since the screen coordinates make it look like landscape.  That is one really weird set of touch outputs.  They look sort of arbitrarily shifted.  But I think I can figure out how to adjust for them.

Link to comment

@kck

I am running it in landscape. 
 

Here is the systemctl status after eliminating one of the execstarts:

softconsole.service - SoftConsole
   Loaded: loaded (/usr/lib/systemd/system/softconsole.service; enabled; vendor preset: enabled)
   Active: activating (start-pre) since Thu 2019-06-27 22:56:51 CDT; 1s ago
  Process: 528 ExecStart=/usr/bin/python3 /home/pi/consolestable/runconsole.py (code=exited, status=0/SUCCESS)
Cntrl PID: 560 (sleep)
   CGroup: /system.slice/softconsole.service
           └─control
             └─560 /bin/sleep 5

Jun 27 22:56:51 SoftConsoleTest systemd[1]: Starting SoftConsole...
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~


Jeff

Link to comment

That looks like it should if sampled about 1 sec after systemd decides to start things.  I just did a start on my test console while watching from another virtual window and I see pretty much the same that you see.  But then after a few more seconds the console starts.  Do you see the same status after a minute or two?  I don't claim much expertise regarding systemd - it has always seemed to work for me.  You might try just deleting the entire ExecStartPre and get rid of the delay and see what happens.  Beyond that I'm kind of stumped since there isn't much to the service definition for the console.  Here's what it all does in case it helps you:

[Unit]                                                                                <- this is just boilerplate
# Description could really be anything meaningful/distinct
Description=SoftConsole
# This should make sure the network is up
After=network.target                                                                   <- this says to start the service after the network is up

[Service]
# Script needs to be executable and first line will be '#!/usr/bin/python -u'
Type=forking                                                                            <- this is the type of the service, means the program that gets started will
                                                                                            fork another process that is the real thing and then exit
PIDFile=/home/pi/console.pid                                                             <- this says the original program will write this file with the pid of the real service 
RestartPreventExitStatus=11 12 13                                  <- these describe what to do if real service exits with these codes
RestartForceExitStatus=31 32 33 34 35

# try not to start until system time has had a chance to update
ExecStartPre=/bin/sleep 5                                          <- do this before trying to start the service
ExecStart=/home/pi/consolestable/runconsole.py                     <- the service starter program
# to test systemd stuff change to consolestable consolecur

WorkingDirectory=/home/pi
# Working dirctory gets moved to consolexxx directory by runconsole.py
# Should restart service if it is not stopped gracefully
Restart=on-failure                                                      <- if service exits with non-0 status restart (but modified by the stuff above
# Slows things down a little on restarts, maybe doesn't need to be so long
RestartSec=3                                                        <- delay before trying a restart
# Makes sure any output gets to syslog and named sensibly
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=softconsole

[Install]
WantedBy=multi-user.target
# Allows the use of journalctl -u softconsole.service to view relevant logs
Alias=softconsole.service
Link to comment

That's pretty weird.  It says it ran runconsole to success but there is a print statement in runconsole that should put an entry in the systemd log saying "Starting using directory: consolestable".  I can come very close to reproducing your situation if runconsole.py is DOS or MAC format or is empty.  All I can think of is that something has happened to that file.  The behavior is that systemd thinks it has run runconsole  successfully and is watching the resultant service which it seems to think is the sleep process since that is the last pid it knew about.  So I would play around with runconsole a bit to see if you can get it to output something (e.g., add a print statement as its very first line)

I think I am close to having a version with touch fixed up that I can give you.  Just want to make sure I understand as much as possible about your configuration.  The display is in landscape mode.  It appears as /dev/fb1 (or is it /dev/fb0).  You have a separate way into the system using a virtual terminal.  When you did get the console display to appear, which terminal did you actually run it from?  By doing a run from the virtual terminal or by doing a run from a keyboard connected to the desktop that shows on the Pimoroni screen?

Link to comment

@kck

I don't think I did anything to runconsole.py.  I just did a git pull.

I got the console to run via SSH and via VNC to the running desktop (5900).  If I execute via VNC (5901) then it doesn't start reliably.

However, now nothing happens no matter what.  When I run "sudo python -u console.py" nothing happens at all from anywhere.  One of the changes we made borked something.

Jeff

 

Link to comment

Archived

This topic is now archived and is closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...