Update README.md

pull/34/head
Bfics 2022-08-07 19:07:03 +02:00 zatwierdzone przez GitHub
rodzic 741051ea6e
commit fd67af7a48
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 40 dodań i 39 usunięć

Wyświetl plik

@ -69,7 +69,7 @@ display.
3.6 [Scale class](./README.md#36-scale-class) Linear display with wide dynamic range. 3.6 [Scale class](./README.md#36-scale-class) Linear display with wide dynamic range.
3.7 [Class Textbox](./README.md#37-class-textbox) Scrolling text display. 3.7 [Class Textbox](./README.md#37-class-textbox) Scrolling text display.
4. [ESP8266](./README.md#4-esp8266) This can work. Contains information on 4. [ESP8266](./README.md#4-esp8266) This can work. Contains information on
minimising the RAM and flash footprints of the GUI. minimizing the RAM and flash footprints of the GUI.
5. [Old firmware](./README.md#5-old-firmware) For users of color displays who can't run current firmware. 5. [Old firmware](./README.md#5-old-firmware) For users of color displays who can't run current firmware.
#### [Supported displays](./DISPLAYS.md) #### [Supported displays](./DISPLAYS.md)
@ -123,10 +123,10 @@ for fast text rendering.
## 1.2 Description ## 1.2 Description
Widgets are intended for the display of data from physical devices such as Widgets are intended for the display of data from physical devices such as
sensors. They are drawn using graphics primitives rather than icons to minimise sensors. They are drawn using graphics primitives rather than icons to minimize
RAM usage. It also enables them to be effciently rendered at arbitrary scale by RAM usage. It also enables them to be efficiently rendered at arbitrary scale by
hosts with restricted processing power. The approach also enables widgets to hosts with restricted processing power. The approach also enables widgets to
maximise information in ways that are difficult with icons, in particular using maximize information in ways that are difficult with icons, in particular using
dynamic color changes in conjunction with moving elements. dynamic color changes in conjunction with moving elements.
Copying the contents of the frame buffer to the display is relatively slow. The Copying the contents of the frame buffer to the display is relatively slow. The
@ -353,7 +353,7 @@ that pixels up to the edges of the display can be accessed.
from color_setup import ssd # Create a display instance from color_setup import ssd # Create a display instance
from gui.core.colors import RED, BLUE, GREEN from gui.core.colors import RED, BLUE, GREEN
from gui.core.nanogui import refresh from gui.core.nanogui import refresh
refresh(ssd, True) # Initialise and clear display. refresh(ssd, True) # Initialize and clear display.
# Uncomment for ePaper displays # Uncomment for ePaper displays
# ssd.wait_until_ready() # ssd.wait_until_ready()
ssd.fill(0) ssd.fill(0)
@ -384,7 +384,7 @@ Text components of widgets are rendered using the `Writer` (monochrome) or
## 3.1 Application Initialisation ## 3.1 Application Initialisation
The GUI is initialised by issuing: The GUI is initialized by issuing:
```python ```python
from color_setup import ssd from color_setup import ssd
``` ```
@ -395,7 +395,7 @@ A typical application then imports `nanogui` modules and clears the display:
from gui.core.nanogui import refresh from gui.core.nanogui import refresh
from gui.widgets.label import Label # Import any widgets you plan to use from gui.widgets.label import Label # Import any widgets you plan to use
from gui.widgets.dial import Dial, Pointer from gui.widgets.dial import Dial, Pointer
refresh(ssd, True) # Initialise and clear display. refresh(ssd, True) # Initialize and clear display.
``` ```
Initialisation of text display follows. For each font a `CWriter` instance Initialisation of text display follows. For each font a `CWriter` instance
is created (for monochrome displays a `Writer` is used): is created (for monochrome displays a `Writer` is used):
@ -428,7 +428,7 @@ In such cases colors may be created and assigned to variables as follows:
from color_setup import SSD from color_setup import SSD
PALE_YELLOW = SSD.rgb(150, 150, 0) PALE_YELLOW = SSD.rgb(150, 150, 0)
``` ```
The GUI also provides drivers with 4-bit color to minimise RAM use. Colors are The GUI also provides drivers with 4-bit color to minimize RAM use. Colors are
assigned to a lookup table having 16 entries. The frame buffer stores 4-bit assigned to a lookup table having 16 entries. The frame buffer stores 4-bit
color values, which are converted to the correct color depth for the hardware color values, which are converted to the correct color depth for the hardware
when the display is refreshed. when the display is refreshed.
@ -444,7 +444,7 @@ then sets `PALE_YELLOW` to 12. Any color number in range `0 <= n <= 15` may be
used (implying that predefined colors may be reassigned). It is recommended used (implying that predefined colors may be reassigned). It is recommended
that `BLACK` (0) and `WHITE` (15) are not changed. If code is to be ported that `BLACK` (0) and `WHITE` (15) are not changed. If code is to be ported
between 4-bit and other drivers, use `create_color()` for all custom colors: between 4-bit and other drivers, use `create_color()` for all custom colors:
it will produce appropriate behaviour. See the `vari_fields` function in the it will produce appropriate behavior. See the `vari_fields` function in the
demo `color15.py` for an example. demo `color15.py` for an example.
### 3.1.2 Monochrome displays ### 3.1.2 Monochrome displays
@ -458,7 +458,7 @@ ePaper units where the foreground is white.
At the bit level `1` represents the foreground. This is white on an emitting At the bit level `1` represents the foreground. This is white on an emitting
display such as an OLED. On a Sharp display it indicates reflection. On an display such as an OLED. On a Sharp display it indicates reflection. On an
ePaper display it represents black. Given that `1` is the foreground color, ePaper display it represents black. Given that `1` is the foreground color,
explicitly specifying `BLACK` on an ePaper will produce `0` as black has (very) explicitly specifying `BLACK` on a ePaper will produce `0` as black has (very)
low saturation. In this context the resultant physically white background low saturation. In this context the resultant physically white background
color may come as a surprise. color may come as a surprise.
@ -488,19 +488,19 @@ Constructor args:
4. `text` If a string is passed it is displayed: typically used for static 4. `text` If a string is passed it is displayed: typically used for static
text. If an integer is passed it is interpreted as the maximum text length text. If an integer is passed it is interpreted as the maximum text length
in pixels; typically obtained from `writer.stringlen('-99.99')`. Nothing is in pixels; typically obtained from `writer.stringlen('-99.99')`. Nothing is
dsplayed until `.value()` is called. Intended for dynamic text fields. displayed until `.value()` is called. Intended for dynamic text fields.
5. `invert=False` Display in inverted or normal style. 5. `invert=False` Display in inverted or normal style.
6. `fgcolor=None` Optionally override the `Writer` colors. 6. `fgcolor=None` Optionally overrides the `Writer` colors.
7. `bgcolor=None` 7. `bgcolor=None`
8. `bdcolor=False` If `False` no border is displayed. If `None` a border is 8. `bdcolor=False` If `False` no border is displayed. If `None` a border is
shown in the `Writer` forgeround color. If a color is passed, it is used. shown in the `Writer` foreground color. If a color is passed, it is used.
The constructor displays the string at the required location. The constructor displays the string at the required location.
Methods: Methods:
1. `value` Redraws the label. This takes the following args: 1. `value` Redraws the label. This takes the following args:
* `text=None` The text to display. If `None` displays last value. * `text=None` The text to display. If `None` displays the last value.
* ` invert=False` If true, show inverse text. * ` invert=False` If true, show the inverse text.
* `fgcolor=None` Foreground color: if `None` the `Writer` default is used. * `fgcolor=None` Foreground color: if `None` the `Writer` default is used.
* `bgcolor=None` Background color, as per foreground. * `bgcolor=None` Background color, as per foreground.
* `bdcolor=None` Border color. As per above except that if `False` is * `bdcolor=None` Border color. As per above except that if `False` is
@ -520,7 +520,7 @@ from gui.core.colors import *
from gui.widgets.label import Label from gui.widgets.label import Label
import gui.fonts.freesans20 as freesans20 import gui.fonts.freesans20 as freesans20
refresh(ssd) # Initialise and clear display. refresh(ssd) # Initialize and clear display.
CWriter.set_textpos(ssd, 0, 0) # In case previous tests have altered it CWriter.set_textpos(ssd, 0, 0) # In case previous tests have altered it
wri = CWriter(ssd, freesans20, GREEN, BLACK, verbose=False) wri = CWriter(ssd, freesans20, GREEN, BLACK, verbose=False)
wri.set_clip(True, True, False) wri.set_clip(True, True, False)
@ -549,9 +549,9 @@ Keyword only args:
5. `width=10` Width. 5. `width=10` Width.
6. `fgcolor=None` Foreground color: if `None` the `Writer` default is used. 6. `fgcolor=None` Foreground color: if `None` the `Writer` default is used.
7. `bgcolor=None` Background color, as per foreground. 7. `bgcolor=None` Background color, as per foreground.
8. `ptcolor=None` Color of meter pointer or bar. Default is foreground color. 8. `ptcolor=None` Color of meter pointer or bar. Default is the foreground color.
9. `bdcolor=False` If `False` no border is displayed. If `None` a border is 9. `bdcolor=False` If `False` no border is displayed. If `None` a border is
shown in the `Writer` forgeround color. If a color is passed, it is used. shown in the `Writer` foreground color. If a color is passed, it is used.
10. `divisions=5` No. of graduations to show. 10. `divisions=5` No. of graduations to show.
11. `label=None` A text string will cause a `Label` to be drawn below the 11. `label=None` A text string will cause a `Label` to be drawn below the
meter. An integer will create a `Label` of that width for later use. meter. An integer will create a `Label` of that width for later use.
@ -572,8 +572,8 @@ Methods:
`None` causes no change. `None` causes no change.
Returns the current value. Returns the current value.
2. `text` Updates the label if present (otherwise throws a `ValueError`). Args: 2. `text` Updates the label if present (otherwise throws a `ValueError`). Args:
* `text=None` The text to display. If `None` displays last value. * `text=None` The text to display. If `None` displays the last value.
* ` invert=False` If true, show inverse text. * ` invert=False` If true, show the inverse text.
* `fgcolor=None` Foreground color: if `None` the `Writer` default is used. * `fgcolor=None` Foreground color: if `None` the `Writer` default is used.
* `bgcolor=None` Background color, as per foreground. * `bgcolor=None` Background color, as per foreground.
* `bdcolor=None` Border color. As per above except that if `False` is * `bdcolor=None` Border color. As per above except that if `False` is
@ -597,7 +597,7 @@ Keyword only args:
5. `fgcolor=None` Foreground color: if `None` the `Writer` default is used. 5. `fgcolor=None` Foreground color: if `None` the `Writer` default is used.
6. `bgcolor=None` Background color, as per foreground. 6. `bgcolor=None` Background color, as per foreground.
7. `bdcolor=False` If `False` no border is displayed. If `None` a border is 7. `bdcolor=False` If `False` no border is displayed. If `None` a border is
shown in the `Writer` forgeround color. If a color is passed, it is used. shown in the `Writer` foreground color. If a color is passed, it is used.
8. `label=None` A text string will cause a `Label` to be drawn below the 8. `label=None` A text string will cause a `Label` to be drawn below the
LED. An integer will create a `Label` of that width for later use. LED. An integer will create a `Label` of that width for later use.
@ -605,8 +605,8 @@ Methods:
1. `color` arg `c=None` Change the LED color to `c`. If `c` is `None` the LED 1. `color` arg `c=None` Change the LED color to `c`. If `c` is `None` the LED
is turned off (rendered in the background color). is turned off (rendered in the background color).
2. `text` Updates the label if present (otherwise throws a `ValueError`). Args: 2. `text` Updates the label if present (otherwise throws a `ValueError`). Args:
* `text=None` The text to display. If `None` displays last value. * `text=None` The text to display. If `None` displays the last value.
* ` invert=False` If true, show inverse text. * ` invert=False` If true, show the inverse text.
* `fgcolor=None` Foreground color: if `None` the `Writer` default is used. * `fgcolor=None` Foreground color: if `None` the `Writer` default is used.
* `bgcolor=None` Background color, as per foreground. * `bgcolor=None` Background color, as per foreground.
* `bdcolor=None` Border color. As per above except that if `False` is * `bdcolor=None` Border color. As per above except that if `False` is
@ -646,13 +646,13 @@ Keyword only args:
5. `fgcolor=None` Foreground color: if `None` the `Writer` default is used. 5. `fgcolor=None` Foreground color: if `None` the `Writer` default is used.
6. `bgcolor=None` Background color, as per foreground. 6. `bgcolor=None` Background color, as per foreground.
7. `bdcolor=False` If `False` no border is displayed. If `None` a border is 7. `bdcolor=False` If `False` no border is displayed. If `None` a border is
shown in the `Writer` forgeround color. If a color is passed, it is used. shown in the `Writer` foreground color. If a color is passed, it is used.
8. `ticks=4` No. of gradutions to show. 8. `ticks=4` No. of gradutions to show.
9. `label=None` A text string will cause a `Label` to be drawn below the 9. `label=None` A text string will cause a `Label` to be drawn below the
meter. An integer will create a `Label` of that width for later use. meter. An integer will create a `Label` of that width for later use.
10. `style=Dial.CLOCK` Pointers are drawn from the centre of the circle as per 10. `style=Dial.CLOCK` Pointers are drawn from the center of the circle as per
the hands of a clock. `Dial.COMPASS` causes pointers to be drawn as arrows the hands of a clock. `Dial.COMPASS` causes pointers to be drawn as arrows
centred on the control's centre. Arrow tail chevrons are suppressed for very centered on the control's center. Arrow tail chevrons are suppressed for very
short pointers. short pointers.
11. `pip=None` Draws a central dot. A color may be passed, otherwise the 11. `pip=None` Draws a central dot. A color may be passed, otherwise the
foreground color will be used. If `False` is passed, no pip will be drawn. The foreground color will be used. If `False` is passed, no pip will be drawn. The
@ -664,7 +664,7 @@ constructor.
### Pointer class ### Pointer class
Constructor arg: Constructor arg:
1. `dial` The `Dial` instance on which it is to be dsplayed. 1. `dial` The `Dial` instance on which it is to be displayed.
Methods: Methods:
1. `value` Args: 1. `value` Args:
@ -675,8 +675,8 @@ Methods:
of the parent `Dial`. Otherwise the passed color is used. of the parent `Dial`. Otherwise the passed color is used.
Returns the current value. Returns the current value.
2. `text` Updates the label if present (otherwise throws a `ValueError`). Args: 2. `text` Updates the label if present (otherwise throws a `ValueError`). Args:
* `text=None` The text to display. If `None` displays last value. * `text=None` The text to display. If `None` displays the last value.
* ` invert=False` If true, show inverse text. * ` invert=False` If true, show the inverse text.
* `fgcolor=None` Foreground color: if `None` the `Writer` default is used. * `fgcolor=None` Foreground color: if `None` the `Writer` default is used.
* `bgcolor=None` Background color, as per foreground. * `bgcolor=None` Background color, as per foreground.
* `bdcolor=None` Border color. As per above except that if `False` is * `bdcolor=None` Border color. As per above except that if `False` is
@ -706,7 +706,7 @@ def clock(ssd, wri):
## 3.6 Scale class ## 3.6 Scale class
This displays floating point data having a wide dynamic range. It is modelled This displays floating point data having a wide dynamic range. It is modeled
on old radios where a large scale scrolls past a small window having a fixed on old radios where a large scale scrolls past a small window having a fixed
pointer. This enables a scale with (say) 200 graduations (ticks) to readily be pointer. This enables a scale with (say) 200 graduations (ticks) to readily be
visible on a small display, with sufficient resolution to enable the user to visible on a small display, with sufficient resolution to enable the user to
@ -798,7 +798,7 @@ precision. Each visible division on the control represents 10 integer units.
Displays multiple lines of text in a field of fixed dimensions. Text may be Displays multiple lines of text in a field of fixed dimensions. Text may be
clipped to the width of the control or may be word-wrapped. If the number of clipped to the width of the control or may be word-wrapped. If the number of
lines of text exceeds the height available, scrolling will occur. Access to lines of text exceed the height available, scrolling will occur. Access to
text that has scrolled out of view may be achieved by calling a method. The text that has scrolled out of view may be achieved by calling a method. The
widget supports fixed and variable pitch fonts. widget supports fixed and variable pitch fonts.
```python ```python
@ -880,7 +880,7 @@ directory matched that of the source. This was the structure of my frozen
directory before I added the 4 bit driver: directory before I added the 4 bit driver:
![Image](images/esp8266_tree.JPG) ![Image](images/esp8266_tree.JPG)
I erased flash, built and installed the new firmware. Finally I copied I erased the flash, built and installed the new firmware. Finally I copied
`setup_examples/esp8266_setup.py` to `/pyboard/color_setup.py`. This could have `setup_examples/esp8266_setup.py` to `/pyboard/color_setup.py`. This could have
been frozen but I wanted to be able to change pins if required. been frozen but I wanted to be able to change pins if required.
@ -902,3 +902,4 @@ to `gui/core/writer.py`. This uses Python code to render text if the firmware
or driver are unable to support fast rendering. or driver are unable to support fast rendering.
###### [Contents](./README.md#contents) ###### [Contents](./README.md#contents)