Merge pull request #316 from spees/master

Minor fixes to the UI to prevent overlap
This commit is contained in:
evilsocket 2019-10-18 09:43:59 +02:00 committed by GitHub
commit e992834b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 10 deletions

View File

@ -74,6 +74,8 @@ main:
netmask: 24
interval: 1 # check every x minutes for device
share_internet: false
memtemp: # Display memory usage and cpu temperature on screen
enabled: false
# monitor interface to use
iface: mon0
# command to run to bring the mon interface up in case it's not up already

View File

@ -491,5 +491,5 @@ def on_ui_update(ui):
def on_ui_setup(ui):
ui.add_element('bluetooth', LabeledValue(color=BLACK, label='BT', value='-', position=(ui.width() / 2 - 30, 0),
ui.add_element('bluetooth', LabeledValue(color=BLACK, label='BT', value='-', position=(ui.width() / 2 - 15, 0),
label_font=fonts.Bold, text_font=fonts.Medium))

View File

@ -2,8 +2,19 @@
#
# totalmem usedmem freemem cputemp
#
###############################################################
#
# Updated 18-10-2019 by spees <speeskonijn@gmail.com>
# - Changed the place where the data was displayed on screen
# - Made the data a bit more compact and easier to read
# - removed the label so we wont waste screen space
# - Updated version to 1.0.1
#
###############################################################
__author__ = 'https://github.com/xenDE'
__version__ = '1.0.0'
__version__ = '1.0.1'
__name__ = 'memtemp'
__license__ = 'GPL3'
__description__ = 'A plugin that will add a memory and temperature indicator'
@ -21,9 +32,9 @@ class MEMTEMP:
# set the minimum seconds before refresh the values
refresh_wait = 30
refresh_ts_last = time.time() - refresh_wait
def __init__(self):
# only import when the module is loaded and enabled
import os
@ -31,9 +42,9 @@ class MEMTEMP:
def get_temp(self):
try:
temp = os.popen('/opt/vc/bin/vcgencmd measure_temp').readlines()[0].split('=')[1].replace("\n", '').replace("'","")
return 'cpu:' + temp
return 't:' + temp
except:
return 'cpu:0.0C'
return 't:-'
# cpu:37.4C
def get_mem_info(self):
@ -42,9 +53,9 @@ class MEMTEMP:
# total, used, free = map(int, os.popen('free -t -m').readlines()[-1].split()[1:])
# without Swap, only real memory:
total, used, free = map(int, os.popen('free -t -m').readlines()[-3].split()[1:4])
return "tm:"+str(total)+" um:"+str(used)+" fm:"+str(free)
return "\nT:"+str(total)+"M U:"+str(used)+"M\nF:"+str(free)+"M"
except:
return "tm:0 um:0 fm:0"
return "\nT:- U:-\nF:- "
# tm:532 um:82 fm:353
@ -57,7 +68,7 @@ def on_loaded():
def on_ui_setup(ui):
ui.add_element('memtemp', LabeledValue(color=BLACK, label='SYS', value='tm:0 um:0 fm:0 0.0C', position=(0, ui.height()-28),
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='\nT:- U:-\nF:- -', position=(ui.width() / 2 + 17, ui.height() / 2),
label_font=fonts.Bold, text_font=fonts.Medium))
@ -66,3 +77,4 @@ def on_ui_update(ui):
ui.set('memtemp', "%s %s" % (memtemp.get_mem_info(), memtemp.get_temp()))
memtemp.refresh_ts_last = time.time()

View File

@ -16,7 +16,7 @@ class Inky(DisplayImpl):
self._layout['face'] = (0, 37)
self._layout['name'] = (5, 18)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (25, 0)
self._layout['aps'] = (30, 0)
self._layout['uptime'] = (147, 0)
self._layout['line1'] = [0, 12, 212, 12]
self._layout['line2'] = [0, 92, 212, 92]