From 8b992966b21666587a1119cd510bbb6cad3d5c82 Mon Sep 17 00:00:00 2001 From: chrisruk Date: Mon, 3 Aug 2020 14:36:12 +0100 Subject: [PATCH 1/2] Show memory as GB --- gpiozero/pins/data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gpiozero/pins/data.py b/gpiozero/pins/data.py index 3b85d20b..66da0171 100644 --- a/gpiozero/pins/data.py +++ b/gpiozero/pins/data.py @@ -1304,10 +1304,12 @@ def __format__(self, format_spec): }) return self.board.format(style=style, **kw) elif content == 'specs': + specs = self._asdict() + specs['memory'] /= 1024 return dedent("""\ {style:bold}Revision {style:reset}: {revision} {style:bold}SoC {style:reset}: {soc} - {style:bold}RAM {style:reset}: {memory}Mb + {style:bold}RAM {style:reset}: {memory}GB {style:bold}Storage {style:reset}: {storage} {style:bold}USB ports {style:reset}: {usb} {style:yellow}(excluding power){style:reset} {style:bold}Ethernet ports {style:reset}: {ethernet} @@ -1315,7 +1317,7 @@ def __format__(self, format_spec): {style:bold}Bluetooth {style:reset}: {bluetooth} {style:bold}Camera ports (CSI) {style:reset}: {csi} {style:bold}Display ports (DSI){style:reset}: {dsi}""" - ).format(style=style, **self._asdict()) + ).format(style=style, **specs) elif content == 'headers': return '\n\n'.join( dedent("""\ From 340355e861a15782b4588de627db9e07f35b4a60 Mon Sep 17 00:00:00 2001 From: chrisruk Date: Thu, 1 Oct 2020 12:25:35 +0100 Subject: [PATCH 2/2] use MB for memory sizes less than 1GB --- gpiozero/pins/data.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gpiozero/pins/data.py b/gpiozero/pins/data.py index 66da0171..3ecc7e7b 100644 --- a/gpiozero/pins/data.py +++ b/gpiozero/pins/data.py @@ -1305,11 +1305,15 @@ def __format__(self, format_spec): return self.board.format(style=style, **kw) elif content == 'specs': specs = self._asdict() - specs['memory'] /= 1024 + if specs['memory'] < 1024: + specs['memory_unit'] = "MB" + else: + specs['memory'] /= 1024 + specs['memory_unit'] = "GB" return dedent("""\ {style:bold}Revision {style:reset}: {revision} {style:bold}SoC {style:reset}: {soc} - {style:bold}RAM {style:reset}: {memory}GB + {style:bold}RAM {style:reset}: {memory}{memory_unit} {style:bold}Storage {style:reset}: {storage} {style:bold}USB ports {style:reset}: {usb} {style:yellow}(excluding power){style:reset} {style:bold}Ethernet ports {style:reset}: {ethernet}