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…
@CAProjects: I think a knowledge base would be fantastic, this would definitely help a lot, especially for people like me who are not very versed in programming😂. I did come across this, which gives out some details:
https://pi-top-pi-top-python-sdk.readthedocs-hosted.com/en/stable/api_pitop_device.html
Don’t know if you seen it before.
Yeah, the uptime, disk are pretty basic but they do the work😂. Would be nice if we can get a widget working for vcgencmd measure_temp and vcgencmd get_config arm_freq to output the info on the miniscreen. For me at least these would be very useful since I am running the RPI overclocked.
measure_temp and get_config arm_freq is actually easy I have the code for that as I made a system temp script for cooling testing
CPU Temperature
str(round(float(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1000,2))+'°C'
CPU Clock Speed
str(int(int(str(os.popen('vcgencmd measure_clock arm').readline().strip('frequency(48)=')).strip())/1000000))+' MHz'
Both are 1 liners that gets the values and strips everything and formats it in 1 go. That’s my old way of doing it, would do it as an fstring now
This is what got me tinkering with the oled in the first place. I was planning on adjusting the looks of the CPU monitor and add temp and speed to it. Just been so busy with everything else, I havent return to it yet.
@Supernovali: If you get this running please let us know. I am also curious about the temp and speed displays widget😉. Thanks
Wowww🤗, yess pleaseee😂. Can I also keep disk usage, clock, etc and use this also?
this is a seperate widget so you can add it as a new one, still working out some kinks tho
Will the GPS code work in the same way? That would be awesome to have all these extra widgets at a push of a button. An sftp start/stop widget would also be something really nice.
Thanks again for everything
GPS code was done, its at the top of this thread. Was how i cracked making a widget
https://forum.pi-top.com/t/pi-top-4-menu-tweaks/614/16?u=caprojects
Sorry forgot about the post, thanks for reminding me. Can’t wait to play with this later today😁
Here is what is the finished code for CPU load, speed and temp
No fancy animation or graphics yet, working on working that out
If the CPU speed is less than 1000 it will show the speed in MHz and if its >= 1000 then it will show in GHz
import psutil
from gpiozero import CPUTemperature
from components.widgets.common.base_widgets import BaseSnapshot
from components.widgets.common.functions import get_image_file_path, draw_text
from components.widgets.common.image_component import ImageComponent
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.interval = 1.5
self.cpu = CPUTemperature()
def render(self, draw, width, height):
cpuSpeed = round(float(psutil.cpu_freq(percpu=False).current))
cpuTemp = round(self.cpu.temperature,2)
cpuLoad = psutil.cpu_percent(percpu=False, interval=1)
cSpeed = f'{cpuSpeed} MHz' if cpuSpeed < 1000 else f'{cpuSpeed/1000} GHz'
draw_text(draw, xy=(default_margin_x,common_first_line_y), text=f'Load : {cpuLoad}%')
draw_text(draw, xy=(default_margin_x,common_second_line_y), text=f'Speed: {cSpeed}')
draw_text(draw, xy=(default_margin_x,common_third_line_y), text=f'Temp : {cpuTemp}°C')
Well I have done it again this time i have got animating widget image added with icons
https://www.youtube.com/watch?v=0YbDhvnn4ZQ
How i done it was take the WiFi code and just take out everything i do not need and added the system monitor stuff in its place
This is the gif used for all the images,
- Save it this gif to the pi-top and rename it to cpu_info.gif (assuming you put it on Desktop)
- add it to
/usr/share/pt-sys-oled/images/sys_info
viasudo cp /home/pi/Desktop/cpu_info.gif /usr/share/pt-sys-oled/images/sys_info/cpi_info.gif
- then chmod the file
sudo chmod 644 /usr/share/pt-sys-oled/images/sys_info/cpu_info.gif
Do not forget to add a menu item for it
Here is the updated code for the animation
/usr/lib/pt-sys-oled/components/widgets/sys_info/cpu_info.py
import psutil
from gpiozero import CPUTemperature
from components.widgets.common.base_widgets import BaseSnapshot
from components.widgets.common.functions import get_image_file_path, draw_text
from components.widgets.common.image_component import ImageComponent
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.cpu = CPUTemperature()
self.width = width
self.height = height
self.mode = mode
self.gif = ImageComponent(
device_mode=self.mode,
width=self.width,
height=self.height,
image_path=get_image_file_path("sys_info/cpu_info.gif"),
loop=False,
playback_speed=2.0,
)
self.cpuSpeed = ''
self.cpuTemp = ''
self.cpuLoad = ''
self.cSpeed = ''
self.initialised = False
self.default_interval = interval
def reset(self):
self.gif = ImageComponent(
device_mode=self.mode,
width=self.width,
height=self.height,
image_path=get_image_file_path("sys_info/cpu_info.gif"),
loop=False,
playback_speed=2.0,
)
self.cpuSpeed = ''
self.cpuTemp = ''
self.cpuLoad = ''
self.cSpeed = ''
self.initialised = False
self.interval = self.default_interval
def set_data_members(self):
self.cpuSpeed = round(float(psutil.cpu_freq(percpu=False).current))
self.cpuTemp = round(self.cpu.temperature,2)
self.cpuLoad = psutil.cpu_percent(percpu=False)
self.cSpeed = f'{self.cpuSpeed} MHz' if self.cpuSpeed < 1000 else f'{self.cpuSpeed/1000} GHz'
self.initialised = True
def render(self, draw, width, height):
first_frame = not self.initialised
# Determine initial connection state
if first_frame:
self.set_data_members()
# Determine connection state
if not self.gif.is_animating():
self.set_data_members()
# Determine animation speed
# TODO: fix frame speed in GIF
# self.interval = self.gif.frame_duration
if first_frame:
self.interval = 0.5
else:
if self.gif.is_animating():
self.interval = 0.025
else:
self.interval = self.default_interval
# Draw to OLED
self.gif.render(draw)
if self.initialised and not self.gif.is_animating():
self.interval = 1
if self.gif.finished:
draw_text(draw, xy=(default_margin_x,common_first_line_y), text=f'{self.cpuLoad}%')
draw_text(draw, xy=(default_margin_x,common_second_line_y), text=f'{self.cSpeed}')
draw_text(draw, xy=(default_margin_x,common_third_line_y), text=f'{self.cpuTemp}°C')
elif self.gif.hold_first_frame:
draw.ellipse((69, 21) + (83, 35), 0, 0)
draw.ellipse((70, 22) + (82, 34), 1, 0)
draw.line((73, 25) + (78, 30), "black", 2)
draw.line((74, 30) + (79, 25), "black", 2)
@CAProjects wowwwww, I lovee it, looks so nice. Can’t wait to try it out. Well done and thanks so much for sharing this with us. The menu system is beginning to look so much nicer and packed with new features🎉
Noice! I’ve got a lot to do right now but on my weekend when I have less going on, I might start creating some modifications to the project launcher
@CAProjects: Thanks for making dreams come true🍻
It beautiful to watch it in reality, love the graphics👏
Hay @Luis Luis, I am trying to do the same thing, adding an extra widgets to the main manu, I unblocked projects code in Manu.py, also change title and templet code in project folder, but its not working, the OLED stoped functioning complitly, although when I again block the project code in Many.py, it starts working, can you please tell me what am I missing. It would be great help.
Thank You