Jump to content

Soft Keypadlinc-like Console from Raspberry Pi


kck

Recommended Posts

I'm in the process of checking out a beta version with configurable touch parameters - just want to make sure it's not DOA.   Once I get that done I can have you redo the install if you are willing.  In principle, this version allows specifying shifts, flips, and scaling for the input position values so we should be able to get them to align with the screen.  Of course, I can really test that here without a screen that has those issues but I have tried it on my screens and it will create offsets (which make my screens misalign as expected).  Installing that beta will also guarantee a clean baseline again.  Probably this will take me another hour or so to validate.

Kevin

Link to comment

OK - think I have something worth trying.  Best would be to build a clean pi.

1. Make sure you get the new pisetup from github

2. This pisetup will ask if you want to download the beta also - answer Y

3. Answer N to the auto run of the console

4. It will ask if you want to install a screen.  Answer N since I am assuming you will already have your screen on and working

5. It will ask for the type of the screen - answer pimoroni4 - this value is used in a lookup in a new file in the beta directory called screendefinitions.  It must match an entry in that file and the rest of the line in that file has parameters.  By the way, at the moment I am assuming that the Hyperpixel won't dim.  It probably does but since I'm not sure how best to not try it for now.

6. After everything completes, edit the (root owned) file versionselector in the pi home dir to say beta instead of stable

7. Try doing a sudo systemclt start softconsole and cross your fingers :-)  At the least we may get some more info on adjustments.  By the way, there is another file in the beta directory called touch definitions.  It has the shift values etc. so if we are close but off a bit, you can tune things by editing it.

Link to comment

@kck,

So, completed all of the directions.  Using the systemctl it shows as started but nothing happens.  Here is the log:

pi@SoftConsoleTest:~ $ systemctl status softconsole
● softconsole.service - SoftConsole
   Loaded: loaded (/usr/lib/systemd/system/softconsole.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-06-28 21:36:40 CDT; 10s ago
  Process: 1277 ExecStart=/home/pi/consolestable/runconsole.py (code=exited, status=0/SUCCESS)
  Process: 1274 ExecStartPre=/bin/sleep 5 (code=exited, status=0/SUCCESS)
 Main PID: 1278 (python3)
   CGroup: /system.slice/softconsole.service
           └─1278 python3 console.py

Jun 28 21:36:34 SoftConsoleTest systemd[1]: Starting SoftConsole...
Jun 28 21:36:40 SoftConsoleTest softconsole[1277]: Starting using directory: consolebeta
Jun 28 21:36:40 SoftConsoleTest systemd[1]: Started SoftConsole.

This is the error when I sudo python -u console.py in the beta directory:

06-28-19 21:31:44 Console ( 1093) starting in /home/pi/consolebeta
{'28c': ['/dev/fb1', 'fbcon', 'PWM'], 'pimoroni4': ['/dev/fb0/fbcon/None'], '35r': ['/dev/fb1', 'fbcon', 'PWM'], 'Name ': [' Device Path ', ' Driver ', ' DimType'], '28r': ['/dev/fb1', 'fbcon', 'PWM'], 'pi7': ['/dev/fb0', 'fbcon', 'Pi7']}
Traceback (most recent call last):
  File "console.py", line 148, in <module>
    utilities.InitializeEnvironment()
  File "/home/pi/consolebeta/utilities.py", line 100, in InitializeEnvironment
    hw.initOS(scrntyp)
  File "/home/pi/consolebeta/hw.py", line 104, in initOS
    if screendefs[screentype][1] != 'XWin':
IndexError: list index out of range
06-28-19 21:31:44 Exiting with history trace (0)
1108(1561775505.9202983): Logger loop ended

Link to comment

Silly typo causing that - sorry.  Edit the screendefinitions file.  The line that defines pimoroni4 has slant characters instead of vertical bar characters between the last 2 parameters.  It should look like this: 

pimoroni4|/dev/fb0|fbcon|None
Link to comment

@kck,

FYI there are spelling errors in line 124 of touchhandler.py.  Should read 'Goodix Capacitive TouchScreen'

It erred again, looks like the spelling in the touchhandler.py is used elsewhere and is incorrect.  I'm not sure where that spelling error is, but here is the log:

pi@SoftConsoleTest:~/consolebeta $ sudo python -u console.py
06-28-19 21:56:30 Console ( 1866) starting in /home/pi/consolebeta
{'28r': ['/dev/fb1', 'fbcon', 'PWM'], '35r': ['/dev/fb1', 'fbcon', 'PWM'], 'pi7': ['/dev/fb0', 'fbcon', 'Pi7'], 'Name ': [' Device Path ', ' Driver ', ' DimType'], 'pimoroni4': ['/dev/fb0', 'fbcon', 'None'], '28c': ['/dev/fb1', 'fbcon', 'PWM']}
Screen: pimoroni4  Device: /dev/fb0 Driver: fbcon Dim: None
{'generic ft5x06 (11)': ['True', '0', '0', '0', '0', '1.0', '1.0'], 'FT5406 memory based driver': ['True', '0', '0', '0', '0', '1.0', '1.0'], 'stmpe-ts': ['False', '0', '0', '0', '0', '1.0', '1.0'], 'Goodix Capactivie Touchscreen': ['True', '-324', '303', '0', '0', '1.0', '1.0'], 'ControllerName': ['cap(True/False)', 'shiftx', 'shifty', 'flipx', 'flipy', 'scalex', 'scaley'], 'EP0110M09': ['True', '0', '0', '0', '0', '1.0', '1.0']}
Traceback (most recent call last):
  File "console.py", line 148, in <module>
    utilities.InitializeEnvironment()
  File "/home/pi/consolebeta/utilities.py", line 107, in InitializeEnvironment
    ts = Touchscreen()
  File "/home/pi/consolebeta/touchhandler.py", line 151, in __init__
    self._f_device = io.open(self._touch_device(), 'rb', self.EVENT_SIZE)
  File "/home/pi/consolebeta/touchhandler.py", line 305, in _touch_device
    raise RuntimeError('Unable to locate touchscreen device')
RuntimeError: Unable to locate touchscreen device
06-28-19 21:56:30 Exiting with history trace (0)
1879(1561776991.5578496): Logger loop ended

Link to comment

Darn capitals.  The error is in the touchdefinitions file.  The instance in touchhandler isn't used any more - I should delete that but hadn't spent much time cleaning up old stuff.

Link to comment
Just now, kck said:

Darn capitals.  The error is in the touchdefinitions file.  The instance in touchhandler isn't used any more - I should delete that but hadn't spent much time cleaning up old stuff.

When I fixed the location in touchhandler.py I got the error in the spot is posted above.

Link to comment
7 minutes ago, kck said:

You need to fix the typo in touchdefinitions - the capital is missing there and that is what is being looked at.

Also, capacitive was misspelled.  However, the console runs and makes the test button.  And it turns stuff off.  But the touch is off by quite a bit now.  Worse than prior.  The bottom 1/3 is shifted up.  And everything is shifted right a little bit.

But progress!  Thank you so much. 

Jeff

Actually it appears the vertical is squished into the top 1/2 maybe

 

Link to comment

Progress!  You can try to get the touch aligned by playing with the values in touchdefinitions.  The values for shiftx and shifty get added to the values that the hardware returns (the ones you ran the test for) and changing them should let you align the value that gets returned to the screen higher level code.  That code expects (0,0) in the upper left going to the max screen pixels in the lower right (480, 800)  Actually, looking closer at the values it is odd.  Your horizontal (across the landscape) is 800 pixels but the touch values seem to go from 324 to 790 which is only about 470 so it would seem that in addition to subtracting the 324ish value the scaling should be set to 800/470, i.e. about 1.7.  The vertical seems to go from -297 to 467 or about 765.  So it would need to be scaled by 480/765.  What bothers me (and made me not notice this when I looked at your results) is that 765 is ~800 and 470 is ~480 so it looks like the results are somehow rotated but that makes no sense since you were clearly getting values by touching the actual screen in its used orientation.  By the way, it doesn't look like you need a flip - that handles case on some screens where the pixel values go in one direction and the touch values in the opposite one.  That might happen here is you rotated the screen 180 degrees from its current orientation and the screen driver hardware got told about that.  By the way - I assume that when you installed the screen driver there was some way to tell it that you were in landscape?  Otherwise the pixel addressing wouldn't be working.

Link to comment

FYI - there is a long thread ( https://forums.pimoroni.com/t/hyperpixel-4-touch-screen-dimensions-are-swapped/8198/38 ) on the Pimoroni forums about this reversal of touch and pixel dimensions.  Not having the screen I can't follow it all but it seems a) this is a known issue and b) there *may* be some other drivers or firmware updates that fix it.  But in the meantime it sounds like scaling a la my previous post is the solution.

Link to comment

Well setting the scaling should fix the scrunching I think.  But I've never actually used that code.  What I should do is figure out how to create a screen mode that would help do all this but this is the first display that I've seen have this problem since I moved from the now-dead pygame touch handling to this native event based stuff.

Link to comment

Applying the scaling seems to have nailed it.  It's close enough for governement work.

I'll give you a break but then I have many more ?'s about configurations and possibilities.


Oh and it auto starts now.

Thanks again!  If I ever overnight in PDX I'll buy you a beer. or 12, whatever.

Jeff

Link to comment

Hey I'm just an old retired software guy who finds some of this fun (and some frustrating).  After climbing the corporate ladder to wind up far away from the bits I find it nice to remember why I got excited about computers nearly 50 years ago.  Enjoy!  (By the way, best bet on configurations it to look at my examples - they are all setups that run somewhere around my place.  I think the usage notes are pretty complete too.

Kevin

Link to comment

Kevin,

Ok, you broached it.  Here are 3 use cases I wonder if are currently possible:

1.  A Keypad that opens a screen. that isn't in a chain.  Button turns on/off Fan-Medium scene.  Doube tap = go to fan speed selection screen

2.  A burron that increments a variable +1 each press.  That variable tells the therrmostats to temporaily drop the ac by 2 degrees.  vaiable decrements each hour (in ISY). and the button on SC reflects the current hours left

3.  Seasonal screens / buttons.  I have 2 keypad buttons that turn on holiday lights.  Only needed 1 Dec - 1 Jan.

What do you think?

Also, can you use the same ISY device in multiple places?  I tried and it erred out but my formatting was probably off.  Also, during the console load it report it fails loading some scene components, namely Hue bridge items.  What is the implication to the console?  WIll i be able use these scenes?

One more thing since we took out dimming, the screen never goes blank (powersave, or whatever).  Should it still go blank at some point?

Jeff

PS - Setting the dimming mode to PWM doesn't err out but it also doesn't dim the screen. 

Link to comment

1. Actually since you have the beta there is a facility that I haven't put in the general release yet (will be in the next one) motivated by a request up the thread, to support "GOTO" keys.  This is a key that takes you directly to another screen you have defined that doesn't use the nav keys at the bottom.  I don't currently support 2 completely different actions for single and double tap on the same key (I'll put it on the idea list) but you could have 2 keys on a screen one of which turns on/off the Fan-Medium scene and one next to it that does a GOTO a fan selection screen.  That's at least close.  GOTO isn't in the usage notes yet but there is an example of it I've been using for test in the "TreeTest" screen in the config-rpi-dev7.txt file in the examples.

2. Close - look at the SETVAR key.  You can have each press move to a new value that is in a list so it isn't unlimited but you could have the list be 1, 2, 3, 4, 5 or even make the differences separate values.  You can also change the key appearance to you'd visually know you were in override if the value wasn't 0.  The label on the key can include the current variable value and is updated whenever that is changed either from a press of the key or from the ISY.  I think that should be very close to what you want.  See the garage.cfg file for a short example.  Also the notes do cover this decently.

3. Don't think this one is there.  There is a provision to set values based on time but that doesn't change the screens.  -> idea list

4. You should have no problem accessing the same device from keys on different screens if that is the question.

5. Are you using v5 on your ISY with nodeserver?  I'm still on v4.  But I still think any device that acts like a switch should work.  Worst case for now is that you could have the key trigger an ISY program to do the work.  I am hoping to move to v5 if I get the time sometime this summer at which point I can fix any issues that.

6. Blanking is the extreme form of dimming (brightness = 0).  So with dimming off there is no blanking.  However it was my intent once we got you running to figure out dimming (even if it is only 0 or 1) for you.  If you can poke around your screen documentation to figure out how to dim it, or if it won't dim then blank it, I should be able to pretty easily put that in.  Right now the code supports 2 dimming methods (you can see their code in hw.py).  PWM uses the pulse width modulation of the Pi to adjust the light intensity using pin 18.  Pi7 uses a built in Linux pseudo device provided by the driver to set the intensity.  Given that your screen uses all the connection pins on the Pi I would expect a variant of the first might work, perhaps with a different pin.

Kevin

Link to comment

Hi Kevin

Back again. I received the Pi 7" screen and set it up on the Pi. However after running pisetup.sh  and rebooting the display is upside down. 

Turned the screen over and continued watching the console install and it hung up with In red: missing parent : button D front door. Fatal console error  - fix config file 'none type' 

object has no attribute children.

console was up 3 sec

console exiting - Ecode 13

During setup I answered the terminal type pi7 

It asked if power button was on top. I answered yes the first time and no the second but made no difference on screen orientation.

Also to answer the question for switch name I gave it one of my switches 'Test Switch' on my ISY.

Thanks again for any help

Gary

UPDATE: You can pretty much disregard all the above. Just getting a message now that no console config found

Link to comment

@garybixler

Don't know what you're doing if the screen doesn't rotate.  That's straight Raspbian function.  If you don't say Y to flip then the screen will appear in landscape oriented so that the power plug of the attached Pi points down. If you say flip then all that happens is that the directive lcd_rotate=2 gets added to the OS /boot/config.txt file which makes the screen appear in landscape with the power plug pointed up.  Nothing to do with the console code at all - 1 line in the install script.

As for the minimal example.  You should have a file config.txt in your Console directory that describes the 1 screen it creates and you should have an auth.cfg file in Console/cfg that has your credentials.  That hasn't been touched in my code in a long time and I just checked and it seems to work fine.

No console config found means that in  ~pi/Console it found no config.txt file nor a file of the form config-<nodename>.txt - If the console can't find either then you get a red screen that says no config file found and an exit.

Link to comment

Hi 

I realized later that it depends on how I answered the question about the power plug being on top or not. Didn't know what the reference was to. But after re-imaging the CD many many times I pretty much have given up on this ever working for me. After my last reloads with the new script once with using the bata version and once without, it ended up with a blank screen with a blinking courser at the top left after rebooting to continue the console setup. Pi was locked up at that point. I ddi sometimes get the errors I previously mentioned and sometimes I can see the console running from the cpu usage but no console display just the pi screen. I am at version 5.0.15a on the ISY if that may have something to do with the problem.

This is a really great idea. 

Thanks for all your help.

Gary

 

 

 

 

Link to comment

I don't think the ISY version in general should have any impact.  Couple of questions: are you running stretch or buster Raspbian?  If you do a ls /dev/fb* what do you see?  If you do a systemctl status softconsole what do you see?  Do a journalctl -u softconsole - go to the end (End key) and look backwards at the messages - what are they.  In particular you should see a "Starting SoftConsole message from systemd.  What follows that?  Just so you know, I have 2 systems (one I develop on) that are Pi3B+ with the foundation 7"display on them.  Just today for reference I imaged one with Raspbian, having copied over the pisetup.sh and network supplicant files, remotely logged in to the system over ssh, sudo'd and went to /boot and ran pisetup.  After answering the question, the system goes through a reboot, installs the console, and does another reboot.  For my purposes, I had not set the console to automatically run at boot so I remotely logged in (either via ssh or via VNC) did a sudo systemctl start softconsole.  This takes about 5-10 seconds after  the Pi screen turns blue and I see the console log start rolling by until eventually the home screen appears.  For reference I do not have a keyboard attached to the Pi nor do I use tha Pi screen as a desktop.  I shouldn't matter if you did but I wanted you to understand everything possible about my flow.  You are using a stock screen that I use on a standard pi so this should really all work.  Where I expect confusion is in building config files which is why I have that ability to build a minimalist one for you so you can at least verify that things come up.  There is likely something that you are doing that is different from what I just described.  If you can think of what it might be I may be able to diagnose what is happening.   By the way, it sounded like earlier you may have gotten the red screen error about no config file.  If you did, that was the console running which proves it could see and use the screen at least at that point, though why you had no config file I don't understand.  As I mentioned above, verify that in Console directory you have a fairly short config.txt file and that in Console/cfglib you have an auth.cfg file that look like it have the correct stuff for your ISY (address, user name, password).  I hate seeing folks frustrated, especially if it might be because of some error or confusion I created so I would like to help at least get a sign of life.  By the way, if you are on Raspberry Stretch then you should stick to the stable release.  The beta works fine for me but it has fewer miles on it.  Let me know any other way I can help.

 

Kevin

Link to comment

My setup pocedure (stretch)
1. Image a CD and copy the pisetup to that image.
2. Install the CD into the Pi and let it go through its startup config and let it do its updates.
3. Enable ssh and VNC from the pi screen. (No keyboard or mouse used this time)
4. nano the pisetup.sh to change from DOS file.
5. from ssh sudo /boot/pisetup.sh
6. Answer questions.
    A. ----------------------------------------------------------
----------------------------------------------------------
This is the system setup script
Mon Jul  1 09:21:44 EDT 2019
----------------------------------------------------------
----------------------------------------------------------

----------------------------------------------------------
----------------------------------------------------------
Connect WiFI if needed
Mon Jul  1 09:21:44 EDT 2019
----------------------------------------------------------
----------------------------------------------------------
Press Enter to continue
       B. Geographic area: US
        C. Time Zone: Eastern
       D. Enter new password:  
       E. What name for this system?  PiConsole
        F. Install VNC on standard port (Y/N/alt port number)? y
       G. Is this the developer personal system (Y/N) (bit risky to say Y if it not)? n
       H. Download current beta as well as stable? n  Is this the developer personal system (Y/N) (bit risky to say Y if it not)? n
       I. Autostart Console (Y/N)? This time I answered n
       J. Install known screen? y
       K. What type screen? pi7
       L. Flip 7 inch......at top? n
      M. Auto reboot ......setup? y
      N. Set up example system? y
      O. Name to use for the ISY hub? ISY (used default here)
      P. Url to isy: entered ip address with port 5010
     Q. ISY username, password? entered    
     R. Example switch to use (ISY name): Not sure what this is asking for. I entered a switch name that is setup on my ISY (GarageDoor) I have also use a unique name                       like (PiSwitch).
     S. OK? y
     T. Proceed? y
     
7. Rebooted
8. Pi screen came up blank with blinking curser at top left. Can't get to Pi screen. If i try to stop or start the console i just get this:

Failed to stop softconsole.service: Unit softconsole.service not loaded


Files to look at:
ls /dev/fb*   (/dev/fb0)
systemctl status softconsole  (Unit softconsole.service could not be found.)
journalctl -u softconsole  (-- No entries --)

This time it did not seem to configure the console at all. Sometimes it does. Sometime it will bypass ISY questions  after a clean install. Results seem to vary dramatically. No consistent problem.

Hope this can bring some insight.

Thanks 

Gary

Link to comment

After doing a ls I get this:

pi@PiConsole:~ $ ls
adafruit-pitft.sh         ConsoleMinEx  Downloads          Music
adafruit-pitft-touch-cal  Desktop       earlyprep.log      Pictures
Consoleauth               di.log        getsetupinfo.py    Public
consoleinstallleftovers   Documents     installconsole.sh  Templates
CONSOLEINSTALLRUNNING     doinstall.sh  MagPi              Videos
 

Interesting that console install is running but pi is just showing a blank screen with the blinking courser.

Link to comment

Archived

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


  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

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