Found a way to make the menu accessible
Still trying to figure out how to add my python project and have it run from here😊
So far added a clock and uptime, gps is next😊
Found a way to make the menu accessible
Still trying to figure out how to add my python project and have it run from here😊
So far added a clock and uptime, gps is next😊
Nice work, if you figure things out, would love to know what ya done so I can look at my GPS code to integrate it
@Luis nice work! Do you have a GitHub repo we can take a look at for this? Our team have done a bit of work on running projects from the OLED, might be worth speaking to @pi-topMIKE and seeing how you can get involved with the development - would be great to get this feature out!
I was just going to ask if you had a github repo going… I was looking into this a couple weeks ago but have had other things come up/working on other projects atm. Can’t wait to see this feature added!
@CAProjects: Thanks . My integration attempt of the gps has failed so far, I am getting a thread lock error. It think its due to the fact that the menu is running and then the miniscreen is called out again. Will try again, if you want I can post the exact error message here if you want to give it a try. Thanks
How did ya get the menu edits done? Would love to look at it this weekend
@luis what did you do to get the uptime to display also what was the code for it?
As for the projects I could get this
In Meny.py I changed line 214 and put an absolute path to /home/pi/Desktop/MyProjects and made a sub folder called GPS
The uptime widget is in /usr/lib/pt-sys-oled/components if I am not mistaken. Will need to check once I am back on the device to confirm the path.
I went with a totally different build on another SD card and for some strange reason the menu system is stuck at the battery level and PT log outputs the buttons that I am pressing but does not change the menu…
What I did previously was to copy the entire pt-sys-oled on the desktop. Issued the kill command for pt-sys-oled and then played with my custom menu so that if I break something after a reboot I would always have the working menu😁. But now with this new build it doesn’t like it. I see that the pi-top team have fixed the animation going into a continuous loop but miniscreen now is no longer called OLED as i had it in my first build.
@Luis I was playing with it on the newer builds (3 weeks ago’ish) and I also couldnt get other widgets working. @pi-topMIKE is working on redesigning the menu system so 3rd party support for widgets and menu items becomes a thing. I mean, they already have a script widget but hasnt been fixed with the recent implementations, at least, that’s what I discovered.
Ok I think I got a handle on what is needed to add menu items
I added Disk and Memory to the system menu and after looking at some sys info items I think I can add GPS to it, but its completely different than my original codes. its just a modification of the WiFi menu item for the time being its a start though
@CAProjects, excellent job, that gps icons looks fantastic. Have managed to fix mine as well. If anyone is interested I can post my updates to the code.
I added the additional widgets next to settings.
@CAProjects: Where is the gps icon stored? Or is it drawn pixel by pixel from the code itself?
the image and gif location is /usr/share/pt-sys-oled/images
after copying with terminal and using sudo you need to sudo chmod 666 filename.extension
replacing filename with the filename and extension with what ever the image file extension is
@Luis the GPS image, well Gif i made myself
Thanks a lot for sharing this. From you previous post you mentioned that the GPS code you created will have to be redone completely. Is this because the code needs to follow the same template code? I noticed there is a template in usr/lib/pt-sys-oled.
There is a certain structure it has to follow
@pi-topMIKE @Luis @Supernovali I FINALLY DONE IT!!!
got GPS info running in the system menu sooooooo much starting and stopping pt-sys-oled.service and soooooooo much looking at the code wondering what I got wrong and why the service restarts itself when selecting the GPS page. BUT i finally got it working and it does update every second which is nice
The only information that is being displayed is from RMC NMEA sentence, Lat Lon and speed
1 thing with it is that it takes a second or 2 to change to the GPS, but only happens once, i dont know why, it just does, but going back to it after its perfectly fine
https://www.youtube.com/watch?v=YxkZOCtfCP8
WHAT I DONE
I started modifying a copy of the WiFi Widget then scrapped it gave me the information to write my code
Step 0: Edit Menu.py to add an extra menu item
Step 1: config my GPS unit to ONLY show RMC NMEA data
uart.write(b'$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*35\r\n')
Step 2: Config my GPS unit to a 1hz refresh
uart.write(b'$PMTK220,1000*1F\r\n')
Step 3: Install pynmea2 as sudo
Step 4: Get some sort of NMEA displaying on the screen as in my previous post
Step 5: get pynmea formatting
Step 6: get Lat, Lon, Speed displayed in the correct display format
Step 7: import common values to position the text
THE CODE
And here is the code i wrote to make all this happen ( no fancy icons or that just text) enjoy the mess
import serial, io, pynmea2
from components.widgets.common.functions import draw_text
from components.widgets.common.base_widgets import BaseSnapshot
from components.widgets.common.values import (
default_margin_x,
common_first_line_y,
common_second_line_y,
common_third_line_y,
)
class Hotspot(BaseSnapshot):
def __init__(self, width, height, mode, interval, **data):
super(Hotspot, self).__init__(width, height, interval, self.render)
self.uart = serial.Serial('/dev/ttyS0', 9600, timeout=5.0)
self.uart_read = io.TextIOWrapper(io.BufferedRWPair(self.uart, self.uart))
self.interval = 1
self.nmea_dict = {
'latitude' : "",
'longitude' : "",
'speed' : ""}
def render(self, draw, width, height):
line = self.uart_read.readline()
msg = pynmea2.parse(line)
if msg.sentence_type == 'RMC':
pole = 'N' if float(msg.latitude) > 0 else 'S'
lat = f"***{pole} %02dm %04.2fs" % (msg.latitude_minutes, msg.latitude_seconds)
draw_text(draw, xy=(default_margin_x,common_first_line_y), text=str(lat))
pole = 'E' if float(msg.longitude) > 0 else 'W'
lon = str(abs(int('%02d' % (msg.longitude)))).zfill(3)
lon = f"***{pole} %02dm %04.2fs" % (msg.longitude_minutes, msg.longitude_seconds)
draw_text(draw, xy=(default_margin_x,common_second_line_y), text=str(lon))
speed = f'{round((float(msg.spd_over_grnd) * 1.150779448),1)} MPH'
draw_text(draw, xy=(default_margin_x,common_third_line_y), text=str(speed))
BASE STARTING POINT
this is all i took from the WiFi widget to start my code
from components.widgets.common.functions import draw_text
from components.widgets.common.base_widgets import BaseSnapshot
from components.widgets.common.values import (
default_margin_x,
common_first_line_y,
common_second_line_y,
common_third_line_y,
)
class Hotspot(BaseSnapshot):
def __init__(self, width, height, mode, interval, **data):
super(Hotspot, self).__init__(width, height, interval, self.render)
def render(self, draw, width, height):
draw_text(draw, xy=(default_margin_x,common_first_line_y), text='Hello pi-top[4]')
Conclusion
I look forward to an easier way to add to the system menu, any 3rd party modules, install them wiht sudo pip3, whats next with the system menu for me? NOTHING, was really frustating to code, any little error will cause the menu to fail starting (no reboot required, just disable service, stop it enable it and start it). VSCode cannot be started via sudo so saving every time requires typing in password.
Its done, a proof of concept that works
@CAProjects: Brilliant! Well done and again thanks for your hardwork and sharing this with us. I will definitely be adding this to my sub-menu😊. Will also try to have the logo for the gps you created, it’s simply to nice to leave it out.
With regards to the pt-sys-oled service, I feel your pain😂
Did you implement the other widgets that were there (disk, uptime, clock, etc)?
Have a great weekend,
Luis
Awe yeah!!! I love it. I’m going to start tinkering a bit here and there too. So much going on right now I havent been sleeping good but I’ll probably get to it tomorrow and play with it too
No I did not as I did not focus on them.
I am thinking of doing a proper knowledge base up on what functions you can import and how to use them and how to make widgets so that we have some documentation on how to do it all.
@Luis the disk, uptime, etc does need an overhaul to the design as they are rather basic so when i know more I may also look into doing that too.
I for got tp mention that another annoyance i had was that i could not use VSCode with Remote SSH when working all this out, and that is because i could not save the work due to needing to enter a password all the time so everything had to be done on the pi-top itself
@CAProjects nice one!!
For the VSCode issue, can you just use:
sudo chmod -R 777 /path/to/directory
to give full access to edits? Probably safer to store them in the home directory and copy them over using sudo when done though…