From fc7c91fa204385a1049be5b0cfde1dbcd0b248b8 Mon Sep 17 00:00:00 2001 From: peterhinch Date: Sun, 16 Apr 2023 18:24:33 +0100 Subject: [PATCH] Minor changes to README and demo code format. --- README.md | 48 ++++++------ gui/demos/audio.py | 3 +- gui/demos/epaper.py | 151 ++++++++++++++++++++++++----------- gui/demos/screens.py | 3 +- gui/demos/various.py | 183 +++++++++++++++++++++++++++++-------------- 5 files changed, 258 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index fc058a1..1f4ec0d 100644 --- a/README.md +++ b/README.md @@ -1003,7 +1003,7 @@ constructor and is closed by issuing the `close()` static method. ## 6.1 Label widget ```python -from gui.widgets import Label +from gui.widgets import Label # File: label.py ``` ![Image](./images/label.JPG) @@ -1089,7 +1089,7 @@ Screen.change(BaseScreen) ### 6.1.1 Grid widget ```python -from gui.widgets import Grid +from gui.widgets import Grid # File: grid.py ``` ![Image](./images/grid.JPG) @@ -1152,7 +1152,7 @@ See the example [calendar.py](https://github.com/peterhinch/micropython-micro-gu ## 6.2 LED widget ```python -from gui.widgets import LED +from gui.widgets import LED # File: led.py ``` ![Image](./images/led.JPG) @@ -1191,7 +1191,7 @@ controlled with `led(True)` or `led(False)`. ## 6.3 Checkbox widget ```python -from gui.widgets import Checkbox +from gui.widgets import Checkbox # File: checkbox.py ``` ![Image](./images/checkbox.JPG) This provides for Boolean data entry and display. In the `True` state the @@ -1233,7 +1233,7 @@ Methods: ```python from gui.core.colors import * # Colors and shapes -from gui.widgets import Button +from gui.widgets import Button # File: buttons.py ``` ![Image](./images/pushbuttons.JPG) @@ -1310,7 +1310,7 @@ Optional keyword only arguments: ```python from gui.core.colors import * # Colors and shapes -from gui.widgets import Button, ButtonList +from gui.widgets import Button, ButtonList # File: buttons.py ``` A `ButtonList` groups a number of buttons together to implement a button which @@ -1369,7 +1369,7 @@ for t in table: # Buttons overlay each other at same location ```python from gui.core.colors import * # Colors and shapes -from gui.widgets import Button, RadioButtons +from gui.widgets import Button, RadioButtons # File: buttons.py ``` ![Image](./images/radiobuttons.JPG) @@ -1416,7 +1416,7 @@ for t in table: ## 6.7 Listbox widget ```python -from gui.widgets import Listbox +from gui.widgets import Listbox # File: listbox.py ``` ![Image](./images/listbox.JPG) @@ -1525,7 +1525,7 @@ Screen.change(BaseScreen) ## 6.8 Dropdown widget ```python -from gui.widgets import Dropdown +from gui.widgets import Dropdown # File: dropdown.py ``` ![Image](./images/dd_closed.JPG) @@ -1640,7 +1640,7 @@ Screen.change(BaseScreen) ## 6.9 DialogBox class ```python -from gui.widgets import DialogBox +from gui.widgets import DialogBox # File: dialog.py ``` ![Image](./images/dialog.JPG) @@ -1694,7 +1694,7 @@ in `gui/demos/screens.py`. ## 6.10 Textbox widget ```python -from gui.widgets import Textbox +from gui.widgets import Textbox # File: textbox.py ``` ![Image](./images/textbox.JPG) @@ -1763,7 +1763,7 @@ the oldest (topmost) being discarded as required. This `passive` widget displays a single floating point value on a vertical linear scale. Optionally it can support data dependent callbacks. ```python -from gui.widgets import Meter +from gui.widgets import Meter # File: meter.py ``` ![Image](./images/meter.JPG) The two styles of `meter`, both showing a value of 0.65. This `passive` widget @@ -1855,7 +1855,7 @@ behaves similarly for data values between 0.9 and 1.0. ### 6.11.1 Region class ```python -from gui.widgets import Region +from gui.widgets import Region # File: region.py ``` Instantiating a `Region` associates it with a supporting widget (currently only a `Meter`). Constructor positional args are as follows: @@ -1915,7 +1915,7 @@ callbacks to run as appropriate. ## 6.12 Slider and HorizSlider widgets ```python -from gui.widgets import Slider, HorizSlider +from gui.widgets import Slider, HorizSlider # File: sliders.py ``` ![Image](./images/sliders.JPG) @@ -1995,7 +1995,7 @@ around sliders to display all legends. ## 6.13 Scale widget ```python -from gui.widgets import Scale +from gui.widgets import Scale # File: scale.py ``` ![Image](./images/scale.JPG) @@ -2132,7 +2132,7 @@ precision. Each visible division on the control represents 10 integer units. ## 6.14 ScaleLog widget ```python -from gui.widgets import ScaleLog +from gui.widgets import ScaleLog # File: scale_log.py ``` ![Image](./images/log_scale.JPG) @@ -2272,7 +2272,7 @@ def tickcb(f, c): ## 6.15 Dial widget ```python -from gui.widgets import Dial, Pointer +from gui.widgets import Dial, Pointer # File: dial.py ``` ![Image](./images/dial.JPG) ![Image](./images/dial1.JPG) @@ -2388,7 +2388,7 @@ Screen.change(BaseScreen) ## 6.16 Knob widget ```python -from gui.widgets import Knob +from gui.widgets import Knob # File: knob.py ``` ![Image](./images/knob.JPG) @@ -2446,7 +2446,7 @@ value changes. This enables dynamic color change. ## 6.17 Adjuster widget ```python -from gui.widgets import Adjuster +from gui.widgets import Adjuster, FloatAdj # File: adjuster.py ``` ![Image](./images/adjusters.jpg) ![Image](./images/adj_vector.jpg) @@ -2512,7 +2512,7 @@ basis. See code comments for further details. ## 6.18 Menu class ```python -from gui.widgets import Menu +from gui.widgets import Menu # File: menu.py ``` ![Image](./images/menu.JPG) @@ -2620,7 +2620,7 @@ different callback if the application required it. ## 6.19 BitMap Widget ```python -from gui.widgets import BitMap +from gui.widgets import BitMap # File: bitmap.py ``` ![Image](./images/bitmap.JPG) @@ -2662,7 +2662,7 @@ See `gui/demos/bitmap.py` for a usage example. ## 6.20 QRMap Widget ```python -from gui.widgets import QRMap +from gui.widgets import QRMap # File: qrcode.py ``` ![Image](./images/qrcode.JPG) @@ -3079,6 +3079,10 @@ async def full_refresh(): ssd.set_partial() ``` +The driver for the supported display uses 1-bit color mapping: this means that +greying-out has no visible effect. Greyed-out controls cannot accept the focus +and are therefore disabled but appearance is unchanged. + ###### [Contents](./README.md#0-contents) # Appendix 1 Application design diff --git a/gui/demos/audio.py b/gui/demos/audio.py index 7bca29a..9441abf 100644 --- a/gui/demos/audio.py +++ b/gui/demos/audio.py @@ -43,8 +43,7 @@ audio_out = I2S(I2S_ID, **config) # ======= GUI ======= -from gui.widgets.label import Label -from gui.widgets import Button, CloseButton, HorizSlider, Listbox +from gui.widgets import Button, CloseButton, HorizSlider, Listbox, Label from gui.core.writer import CWriter # Font for CWriter diff --git a/gui/demos/epaper.py b/gui/demos/epaper.py index 17002c1..99fe6e7 100644 --- a/gui/demos/epaper.py +++ b/gui/demos/epaper.py @@ -15,8 +15,21 @@ import gui.fonts.arial10 as arial10 # Font for CWriter import gui.fonts.freesans20 as large from gui.core.colors import * + # Widgets -from gui.widgets import Label, Dial, Pointer, Meter, Scale, Button, ButtonList, RadioButtons, CloseButton, Checkbox, LED +from gui.widgets import ( + Label, + Dial, + Pointer, + Meter, + Scale, + Button, + ButtonList, + RadioButtons, + CloseButton, + Checkbox, + LED, +) from gui.widgets.graph import CartesianGraph, Curve from math import sin, pi @@ -25,6 +38,7 @@ import uasyncio as asyncio import utime import gc + async def full_refresh(): Screen.rfsh_done.clear() # Enable completion flag await Screen.rfsh_done.wait() # Wait for a refresh to end @@ -40,8 +54,8 @@ class FooScreen(Screen): # A ButtonList with two entries table_buttonset = ( - {'fgcolor' : RED, 'text' : 'Disable', 'args' : (buttons, True)}, - {'fgcolor' : GREEN, 'text' : 'Enable', 'args' : (buttons, False)}, + {"fgcolor": RED, "text": "Disable", "args": (buttons, True)}, + {"fgcolor": GREEN, "text": "Enable", "args": (buttons, False)}, ) def tickcb(f, c): @@ -52,80 +66,115 @@ class FooScreen(Screen): return c def bcb(b): - print('Button pressed', b) + print("Button pressed", b) super().__init__() self.rb0 = None self.bs0 = None wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False) wri_large = CWriter(ssd, large, GREEN, BLACK, verbose=False) - lbltim = Label(wri, 65, 100, 'this is a test', bdcolor=RED) + lbltim = Label(wri, 65, 100, "this is a test", bdcolor=RED) - m0 = Meter(wri, 10, 240, divisions = 4, ptcolor=YELLOW, height=80, width=15, - label='Meter', style=Meter.BAR, legends=('0.0', '0.5', '1.0')) + m0 = Meter( + wri, + 10, + 240, + divisions=4, + ptcolor=YELLOW, + height=80, + width=15, + label="Meter", + style=Meter.BAR, + legends=("0.0", "0.5", "1.0"), + ) # Instantiate displayable objects. bgcolor forces complete redraw. - dial = Dial(wri, 2, 2, height = 75, ticks = 12, bgcolor=BLACK, bdcolor=None, label=120) # Border in fg color - scale = Scale(wri, 2, 100, width = 124, tickcb = tickcb, - pointercolor=RED, fontcolor=YELLOW, bdcolor=CYAN) + dial = Dial( + wri, 2, 2, height=75, ticks=12, bgcolor=BLACK, bdcolor=None, label=120 + ) # Border in fg color + scale = Scale( + wri, 2, 100, width=124, tickcb=tickcb, pointercolor=RED, fontcolor=YELLOW, bdcolor=CYAN + ) row = 105 col = 2 - Label(wri, row, col, 'Normal buttons') + Label(wri, row, col, "Normal buttons") # Four Button instances row = 120 ht = 30 - for i, s in enumerate(('a', 'b', 'c', 'd')): - col= 2 + i * (ht + 5) - buttons.append(Button(wri, row, col, height=ht, callback=bcb, text=s, litcolor=RED, shape=CIRCLE, bgcolor=DARKGREEN)) + for i, s in enumerate(("a", "b", "c", "d")): + col = 2 + i * (ht + 5) + buttons.append( + Button( + wri, + row, + col, + height=ht, + callback=bcb, + text=s, + litcolor=RED, + shape=CIRCLE, + bgcolor=DARKGREEN, + ) + ) # ButtonList self.bs = ButtonList(self.callback) self.bs0 = None - col+= 50 - Label(wri, row - 15, col, 'ButtonList') - for t in table_buttonset: # Buttons overlay each other at same location - button = self.bs.add_button(wri, row, col, shape=RECTANGLE, textcolor=BLUE, height=30, **t) - if self.bs0 is None: # Save for reset button callback + col += 50 + Label(wri, row - 15, col, "ButtonList") + for t in table_buttonset: # Buttons overlay each other at same location + button = self.bs.add_button( + wri, row, col, shape=RECTANGLE, textcolor=BLUE, height=30, **t + ) + if self.bs0 is None: # Save for reset button callback self.bs0 = button # Reset button - col+= 60 - btn = Button(wri, row, col, height=30, callback=self.rstcb, text='reset', litcolor=RED, fgcolor=GREEN, bgcolor=DARKGREEN) + col += 60 + btn = Button( + wri, + row, + col, + height=30, + callback=self.rstcb, + text="reset", + litcolor=RED, + fgcolor=GREEN, + bgcolor=DARKGREEN, + ) col = btn.mcol + 15 # Checkbox - Label(wri, row - 15, col, 'Checkbox and LED') + Label(wri, row - 15, col, "Checkbox and LED") Checkbox(wri, row, col, callback=self.cbcb) - col+= 40 + col += 40 self.led = LED(wri, row, col, color=YELLOW, bdcolor=GREEN) row = self.bs0.mrow + 5 col = 20 ht = 75 wd = 200 - self.graph = CartesianGraph(wri, row, col, height = ht, width = wd, bdcolor=False) - Label(wri, row + ht + 5, col - 10, '-2.0') - Label(wri, row + ht + 5, col - 8 + int(wd//2), '0.0') - lbl = Label(wri, row + ht + 5, col - 10 + wd, '2.0') + self.graph = CartesianGraph(wri, row, col, height=ht, width=wd, bdcolor=False) + Label(wri, row + ht + 5, col - 10, "-2.0") + Label(wri, row + ht + 5, col - 8 + int(wd // 2), "0.0") + lbl = Label(wri, row + ht + 5, col - 10 + wd, "2.0") Label(wri_large, lbl.mrow + 5, col, "y = sinc(x)") - CloseButton(wri, bgcolor=BLACK) asyncio.create_task(run(dial, lbltim, m0, scale)) - def callback(self, button, buttons, val): buttons[2].greyed_out(val) def rstcb(self, button): - print('Reset button: init ButtonList, do full refresh.') + print("Reset button: init ButtonList, do full refresh.") self.bs.value(self.bs0) asyncio.create_task(full_refresh()) def cbcb(self, cb): self.led.value(cb.value()) gc.collect() - print('Free RAM:', gc.mem_free()) + print("Free RAM:", gc.mem_free()) def after_open(self): def populate(): @@ -140,30 +189,41 @@ class FooScreen(Screen): async def run(dial, lbltim, m0, scale): - days = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', - 'Sunday') - months = ('Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', - 'Aug', 'Sept', 'Oct', 'Nov', 'Dec') - uv = lambda phi : cmath.rect(1, phi) # Return a unit vector of phase phi + days = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday") + months = ( + "Jan", + "Feb", + "March", + "April", + "May", + "June", + "July", + "Aug", + "Sept", + "Oct", + "Nov", + "Dec", + ) + uv = lambda phi: cmath.rect(1, phi) # Return a unit vector of phase phi pi = cmath.pi hrs = Pointer(dial) mins = Pointer(dial) secs = Pointer(dial) - hstart = 0 + 0.7j # Pointer lengths and position at top + hstart = 0 + 0.7j # Pointer lengths and position at top mstart = 0 + 0.92j - sstart = 0 + 0.92j + sstart = 0 + 0.92j cv = -1.0 # Scale dv = 0.005 while True: t = utime.localtime() - hrs.value(hstart * uv(-t[3]*pi/6 - t[4]*pi/360), YELLOW) - mins.value(mstart * uv(-t[4] * pi/30), YELLOW) - secs.value(sstart * uv(-t[5] * pi/30), RED) - lbltim.value('{:02d}.{:02d}.{:02d}'.format(t[3], t[4], t[5])) - dial.text('{} {} {} {}'.format(days[t[6]], t[2], months[t[1] - 1], t[0])) - m0.value(t[5]/60) + hrs.value(hstart * uv(-t[3] * pi / 6 - t[4] * pi / 360), YELLOW) + mins.value(mstart * uv(-t[4] * pi / 30), YELLOW) + secs.value(sstart * uv(-t[5] * pi / 30), RED) + lbltim.value("{:02d}.{:02d}.{:02d}".format(t[3], t[4], t[5])) + dial.text("{} {} {} {}".format(days[t[6]], t[2], months[t[1] - 1], t[0])) + m0.value(t[5] / 60) scale.value(cv) await asyncio.sleep_ms(200) cv += dv @@ -173,9 +233,10 @@ async def run(dial, lbltim, m0, scale): def test(): - print('Testing micro-gui...') + print("Testing micro-gui...") Screen.change(FooScreen) print("End") ssd.sleep() # Tidy shutdown of EPD + test() diff --git a/gui/demos/screens.py b/gui/demos/screens.py index 3d4a4a2..adb4020 100644 --- a/gui/demos/screens.py +++ b/gui/demos/screens.py @@ -7,8 +7,7 @@ import hardware_setup # Create a display instance from gui.core.ugui import Screen, Window, ssd -from gui.widgets.label import Label -from gui.widgets import Button, RadioButtons, CloseButton, Listbox, Dropdown, DialogBox +from gui.widgets import Button, RadioButtons, CloseButton, Listbox, Dropdown, DialogBox, Label from gui.core.writer import CWriter # Font for CWriter diff --git a/gui/demos/various.py b/gui/demos/various.py index 4271857..550ee9b 100644 --- a/gui/demos/various.py +++ b/gui/demos/various.py @@ -11,14 +11,21 @@ from gui.core.ugui import Screen, ssd from gui.core.writer import CWriter import gui.fonts.arial10 as arial10 # Font for CWriter from gui.core.colors import * + # Widgets -from gui.widgets.label import Label -from gui.widgets.dial import Dial, Pointer -from gui.widgets.meter import Meter -from gui.widgets.scale import Scale -from gui.widgets.buttons import Button, ButtonList, RadioButtons, CloseButton -from gui.widgets.checkbox import Checkbox -from gui.widgets.led import LED +from gui.widgets import ( + Label, + Dial, + Pointer, + Meter, + Scale, + Button, + ButtonList, + RadioButtons, + CloseButton, + Checkbox, + LED, +) import cmath import uasyncio as asyncio @@ -32,15 +39,15 @@ class FooScreen(Screen): # A ButtonList with two entries table_buttonset = ( - {'fgcolor' : RED, 'text' : 'Disable', 'args' : (buttons, True)}, - {'fgcolor' : GREEN, 'text' : 'Enable', 'args' : (buttons, False)}, + {"fgcolor": RED, "text": "Disable", "args": (buttons, True)}, + {"fgcolor": GREEN, "text": "Enable", "args": (buttons, False)}, ) table_radiobuttons = ( - {'text' : '1', 'args' : ('1',)}, - {'text' : '2', 'args' : ('2',)}, - {'text' : '3', 'args' : ('3',)}, - {'text' : '4', 'args' : ('4',)}, + {"text": "1", "args": ("1",)}, + {"text": "2", "args": ("2",)}, + {"text": "3", "args": ("3",)}, + {"text": "4", "args": ("4",)}, ) def tickcb(f, c): @@ -51,109 +58,166 @@ class FooScreen(Screen): return c def bcb(b): - print('Button pressed', b) + print("Button pressed", b) super().__init__() self.rb0 = None self.bs0 = None wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False) - lbltim = Label(wri, 65, 100, 'this is a test', bdcolor=RED) + lbltim = Label(wri, 65, 100, "this is a test", bdcolor=RED) - m0 = Meter(wri, 10, 240, divisions = 4, ptcolor=YELLOW, height=80, width=15, - label='Meter example', style=Meter.BAR, legends=('0.0', '0.5', '1.0')) + m0 = Meter( + wri, + 10, + 240, + divisions=4, + ptcolor=YELLOW, + height=80, + width=15, + label="Meter example", + style=Meter.BAR, + legends=("0.0", "0.5", "1.0"), + ) # Instantiate displayable objects. bgcolor forces complete redraw. - dial = Dial(wri, 2, 2, height = 75, ticks = 12, bgcolor=BLACK, bdcolor=None, label=120) # Border in fg color - scale = Scale(wri, 2, 100, width = 124, tickcb = tickcb, - pointercolor=RED, fontcolor=YELLOW, bdcolor=CYAN) + dial = Dial( + wri, 2, 2, height=75, ticks=12, bgcolor=BLACK, bdcolor=None, label=120 + ) # Border in fg color + scale = Scale( + wri, 2, 100, width=124, tickcb=tickcb, pointercolor=RED, fontcolor=YELLOW, bdcolor=CYAN + ) row = 105 col = 2 - Label(wri, row, col, 'Normal buttons') + Label(wri, row, col, "Normal buttons") # Four Button instances row = 120 ht = 30 - for i, s in enumerate(('a', 'b', 'c', 'd')): - col= 2 + i * (ht + 5) - buttons.append(Button(wri, row, col, height=ht, callback=bcb, text=s, litcolor=RED, shape=CIRCLE, bgcolor=DARKGREEN)) + for i, s in enumerate(("a", "b", "c", "d")): + col = 2 + i * (ht + 5) + buttons.append( + Button( + wri, + row, + col, + height=ht, + callback=bcb, + text=s, + litcolor=RED, + shape=CIRCLE, + bgcolor=DARKGREEN, + ) + ) # ButtonList self.bs = ButtonList(self.callback) self.bs0 = None - col+= 50 - Label(wri, row - 15, col, 'ButtonList') - for t in table_buttonset: # Buttons overlay each other at same location - button = self.bs.add_button(wri, row, col, shape=RECTANGLE, textcolor=BLUE, height=30, **t) - if self.bs0 is None: # Save for reset button callback + col += 50 + Label(wri, row - 15, col, "ButtonList") + for t in table_buttonset: # Buttons overlay each other at same location + button = self.bs.add_button( + wri, row, col, shape=RECTANGLE, textcolor=BLUE, height=30, **t + ) + if self.bs0 is None: # Save for reset button callback self.bs0 = button # Reset button - col+= 60 - btn = Button(wri, row, col, height=30, callback=self.rstcb, text='reset', litcolor=RED, fgcolor=GREEN, bgcolor=DARKGREEN) + col += 60 + btn = Button( + wri, + row, + col, + height=30, + callback=self.rstcb, + text="reset", + litcolor=RED, + fgcolor=GREEN, + bgcolor=DARKGREEN, + ) col = 2 row = 170 - Label(wri, row, col, 'Radio buttons') + Label(wri, row, col, "Radio buttons") # Radio buttons row = 185 - self.rb = RadioButtons(BLUE, self.rbcb) # color of selected button + self.rb = RadioButtons(BLUE, self.rbcb) # color of selected button self.rb0 = None for t in table_radiobuttons: - button = self.rb.add_button(wri, row, col, textcolor = WHITE, - fgcolor = BLUE, bgcolor = DARKBLUE, shape=CIRCLE, height = 30, **t) - if self.rb0 is None: # Save for reset button callback + button = self.rb.add_button( + wri, + row, + col, + textcolor=WHITE, + fgcolor=BLUE, + bgcolor=DARKBLUE, + shape=CIRCLE, + height=30, + **t + ) + if self.rb0 is None: # Save for reset button callback self.rb0 = button - col+= 35 + col += 35 # Checkbox - col+= 35 - Label(wri, row - 15, col, 'Checkbox and LED') + col += 35 + Label(wri, row - 15, col, "Checkbox and LED") Checkbox(wri, row, col, callback=self.cbcb) - col+= 40 + col += 40 self.led = LED(wri, row, col, color=YELLOW, bdcolor=GREEN) CloseButton(wri) asyncio.create_task(run(dial, lbltim, m0, scale)) - def callback(self, button, buttons, val): buttons[2].greyed_out(val) def rbcb(self, button, val): - print('RadioButtons callback', val) + print("RadioButtons callback", val) def rstcb(self, button): - print('Reset button: init ButtonList and RadioButtons') + print("Reset button: init ButtonList and RadioButtons") self.bs.value(self.bs0) self.rb.value(self.rb0) def cbcb(self, cb): self.led.value(cb.value()) gc.collect() - print('Free RAM:', gc.mem_free()) + print("Free RAM:", gc.mem_free()) + async def run(dial, lbltim, m0, scale): - days = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', - 'Sunday') - months = ('Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', - 'Aug', 'Sept', 'Oct', 'Nov', 'Dec') - uv = lambda phi : cmath.rect(1, phi) # Return a unit vector of phase phi + days = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday") + months = ( + "Jan", + "Feb", + "March", + "April", + "May", + "June", + "July", + "Aug", + "Sept", + "Oct", + "Nov", + "Dec", + ) + uv = lambda phi: cmath.rect(1, phi) # Return a unit vector of phase phi pi = cmath.pi hrs = Pointer(dial) mins = Pointer(dial) secs = Pointer(dial) - hstart = 0 + 0.7j # Pointer lengths and position at top + hstart = 0 + 0.7j # Pointer lengths and position at top mstart = 0 + 0.92j - sstart = 0 + 0.92j + sstart = 0 + 0.92j cv = -1.0 # Scale dv = 0.005 while True: t = utime.localtime() - hrs.value(hstart * uv(-t[3]*pi/6 - t[4]*pi/360), YELLOW) - mins.value(mstart * uv(-t[4] * pi/30), YELLOW) - secs.value(sstart * uv(-t[5] * pi/30), RED) - lbltim.value('{:02d}.{:02d}.{:02d}'.format(t[3], t[4], t[5])) - dial.text('{} {} {} {}'.format(days[t[6]], t[2], months[t[1] - 1], t[0])) - m0.value(t[5]/60) + hrs.value(hstart * uv(-t[3] * pi / 6 - t[4] * pi / 360), YELLOW) + mins.value(mstart * uv(-t[4] * pi / 30), YELLOW) + secs.value(sstart * uv(-t[5] * pi / 30), RED) + lbltim.value("{:02d}.{:02d}.{:02d}".format(t[3], t[4], t[5])) + dial.text("{} {} {} {}".format(days[t[6]], t[2], months[t[1] - 1], t[0])) + m0.value(t[5] / 60) scale.value(cv) await asyncio.sleep_ms(200) cv += dv @@ -164,9 +228,10 @@ async def run(dial, lbltim, m0, scale): def test(): if ssd.height < 240 or ssd.width < 320: - print(' This test requires a display of at least 320x240 pixels.') + print(" This test requires a display of at least 320x240 pixels.") else: - print('Testing micro-gui...') + print("Testing micro-gui...") Screen.change(FooScreen) + test()