pi-top utilities

Discuss development specific to the Pi version of ADFFS
Post Reply
JonAbbott
Posts: 1739
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

pi-top utilities

Post by JonAbbott » Wed Jan 18, 2017 1:13 pm

A battery indicator for the pi-top, which indicates the percentage of charge and powered status:
pi-topUtils1.png
pi-topUtils1.png (17.19 KiB) Viewed 762 times
Hover the mouse over the icon for time information:
pi-topUtils2.png
pi-topUtils2.png (13.16 KiB) Viewed 762 times
It also includes HID and USB keyboard drivers, which add the following features:
  • Volume controls work
  • Brightness controls work
  • left pi-top+SHIFT+| is |
  • left pi-top+Left Arrow is Home
  • left pi-top+Right Arrow is End/Copy
  • left pi-top+Up Arrow is Page Up
  • left pi-top+Down Arrow is Page Down
  • left pi-top+DEL is Pause/Break
  • right pi-top is the middle mouse button
  • P-key / F-key behaviour is swapped by default, removing the requirement to hold Fn for the function keys (set in !Run)
  • Dims the screen when there's no keyboard/mouse activity (timeout is set in !Run)
  • Powers down the screen when the DPMS screen saver blanks the screen
  • Powers down if left on the Wimp shutdown screen (4 sec by default, timeout can be set or disabled in !Run), pressing a key or the Restart button cancels the power down
  • Can set the brightness to a default level when loaded (set in !Run)
By default the P-keys and F-keys are swapped, the behaviour can be toggled by pressing the key next to DEL (this may be removed once finalized).
pi-topUtils.zip
v1.02
(7.81 KiB) Downloaded 107 times
source_code.zip
pitopUtils Module source code
(7.06 KiB) Downloaded 48 times
Configuring a pi-top for gaming

If you're going to be using your pi-top for gaming, you'll also want to create a custom 50hz video mode so games such as Pac-mania have silky smooth scrolling.

Edit !Boot.Loader.CONFIG/TXT and add the following, remembering to comment out any previous video mode settings:

Code: Select all

# Custom 1360x768 50Hz
hdmi_cvt=1360 768 50 3 0 0 0
hdmi_group=2
hdmi_mode=87

Vanfanel
Posts: 373
Joined: Mon Sep 16, 2013 12:01 am

Re: pi-top utilities

Post by Vanfanel » Fri Jan 20, 2017 1:58 pm

Wow! Just when I was wondering about getting a pi-top! This is great, Jon! Thanks a lot for this.

JonAbbott
Posts: 1739
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: pi-top utilities

Post by JonAbbott » Sun Jan 22, 2017 10:41 am

Be aware that the volume keys cause the keyboard to stop responding and turning on NumLock prevents the F-keys from working. By default the brightness is at ~50% so it's a bit dark. Oh...and the keyboard and trackpad are :evil:, so you'll probably want an external mouse and keyboard if you want to use it beyond gaming. There's also no speakers, I'm using headphones, but you might want the official pi-top speaker which is not too expensive but they sting you on postage. Finally, you'll want a WiFi to CAT5 dongle if you want to connect it to WiFi, I've got mine inside the case but I'm not sure if there's enough room to also fit a speaker.

I've written the SPI code to adjust the screen brightness, but I'm not going to release this until I've also implemented a replacement USB keyboard driver with extended HID support to handle the volume keys, the brightness keys will then work as expected. I'll also add the ability to swap the F-keys/Fn+F-keys around so you don't have to hold Fn to use F-keys, which I find particularly irritating!

I'll resolve the NumLock issue if possible - I've not looked at the USB data yet to see what it's doing, hopefully it's just sending invalid key codes that need translating.

A few other features I intend to add are to make it power down if left on the Wimp "Restart" prompt and dim the screen if left idle.

I really should buy an official pi-top speaker and add support for that as well, it was on my Christmas list, but Santa seems to have skipped our house this year :cry:

JonAbbott
Posts: 1739
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: pi-top utilities

Post by JonAbbott » Mon Jan 23, 2017 11:23 pm

JonAbbott wrote:I'll resolve the NumLock issue if possible - I've not looked at the USB data yet to see what it's doing, hopefully it's just sending invalid key codes that need translating.
This can't be resolved without reprogramming the keyboard (I need to track down the keyboard manufacturer). With NumLock on, it forces the Fn key on so F8/F9/F10 always return the volume keys and aren't modified if Fn is subsequently held.

I've coded the USB/HID drivers, so the volume and brightness keys now work. I need to add a timed shutdown and finish coding the ability to swap the F/P keys around so you don't have to hold Fn for the F-keys, before I make it available.

Additional modifiers I've implemented are:
  • left pi-top+SHIFT+| now produces | instead of ¦
  • left pi-top+Left Arrow is Home
  • left pi-top+Right Arrow is End/Copy
  • left pi-top+Up Arrow is Page Up
  • left pi-top+Down Arrow is Page Down
  • right pi-top is the middle mouse button
I'm not sure what to do with the three rogue keys up the top right, which I'll describe as: Folder, Command Prompt and Num Lock

JonAbbott
Posts: 1739
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: pi-top utilities

Post by JonAbbott » Wed Jan 25, 2017 10:12 am

There's a near feature complete test version in the OP, I've implemented everything I'd planned with the exception of screen dimming and support for the pi-top speaker.

Altering the brightness is flacky as hell, you have to bash the SPI interface repeatedly until it finally accepts data. A side effect of this is that you can't be 100% certain that the brightness it's telling you it's currently at, is actually correct. The pi-top board also has a bug in its firmware, where it doesn't reset the state of some of the status bits after power on. So it can for example report the lid is closed, when it's actually open.

The only solution I can think of for these issues is to set the brightness to a known level, so I may add a *command for this at some point.

JonAbbott
Posts: 1739
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: pi-top utilities

Post by JonAbbott » Wed Jan 25, 2017 10:37 pm

It's now feature complete. The screen is now dimmed when there's no key/mouse activity and it powers the screen off when the DPMS screen saver blanks the screen.

JonAbbott
Posts: 1739
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: pi-top utilities

Post by JonAbbott » Fri Jan 27, 2017 12:43 pm

I've added a few additional settings to set the brightness to a default level when loaded and set or disable the power down timeout.

JonAbbott
Posts: 1739
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: pi-top utilities

Post by JonAbbott » Fri Feb 10, 2017 12:13 am

I purchased a pi-top speaker, so will add support for it at some point. For future compatibility I'll probably use the Linux script to configure it and just write a script interpreter.

What to do about volume control though? RISCOS' volume control is pretty pointless as it relies on software scaling; you can't change the volume in most games for example as they don't use the scaling tables. I'll probably switch the volume buttons to control the amp in the pi-top speaker if it's present.

Post Reply