kopia lustrzana https://github.com/peterhinch/micropython-nano-gui
Color tests pass, prior to splitting out widgets.
rodzic
21945241ac
commit
5ec4948f91
|
@ -9,7 +9,7 @@
|
||||||
# border: False no border None use bgcolor, int: treat as color
|
# border: False no border None use bgcolor, int: treat as color
|
||||||
|
|
||||||
import cmath
|
import cmath
|
||||||
from ngui.core.writer import Writer
|
from gui.core.writer import Writer
|
||||||
import framebuf
|
import framebuf
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
# Adafruit 1.5" 128*128 OLED display: https://www.adafruit.com/product/1431
|
# Adafruit 1.5" 128*128 OLED display: https://www.adafruit.com/product/1431
|
||||||
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
||||||
|
|
||||||
# The MIT License (MIT)
|
|
||||||
|
|
||||||
# Released under the MIT License (MIT). See LICENSE.
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
# Copyright (c) 2018-2020 Peter Hinch
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
|
|
||||||
|
@ -17,40 +15,19 @@
|
||||||
# X6 CLK
|
# X6 CLK
|
||||||
# X8 DATA
|
# X8 DATA
|
||||||
|
|
||||||
height = 96 # 1.27 inch 96*128 (rows*cols) display
|
|
||||||
# height = 128 # 1.5 inch 128*128 display
|
|
||||||
|
|
||||||
# Demo of initialisation procedure designed to minimise risk of memory fail
|
|
||||||
# when instantiating the frame buffer. The aim is to do this as early as
|
|
||||||
# possible before importing other modules.
|
|
||||||
|
|
||||||
import machine
|
|
||||||
import gc
|
|
||||||
from drivers.ssd1351 import SSD1351 as SSD
|
|
||||||
|
|
||||||
# Initialise hardware
|
# Initialise hardware
|
||||||
pdc = machine.Pin('X1', machine.Pin.OUT_PP, value=0)
|
from ssd1351_setup import ssd, height # Create a display instance
|
||||||
pcs = machine.Pin('X2', machine.Pin.OUT_PP, value=1)
|
from gui.core.nanogui import Dial, Pointer, refresh, Label
|
||||||
prst = machine.Pin('X3', machine.Pin.OUT_PP, value=1)
|
|
||||||
spi = machine.SPI(1)
|
|
||||||
gc.collect() # Precaution before instantiating framebuf
|
|
||||||
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|
|
||||||
from nanogui import Dial, Pointer, refresh, Label
|
|
||||||
refresh(ssd) # Initialise and clear display.
|
refresh(ssd) # Initialise and clear display.
|
||||||
|
|
||||||
# Now import other modules
|
# Now import other modules
|
||||||
import cmath
|
import cmath
|
||||||
import utime
|
import utime
|
||||||
from ngui.core.writer import CWriter
|
from gui.core.writer import CWriter
|
||||||
|
|
||||||
# Font for CWriter
|
# Font for CWriter
|
||||||
import arial10
|
import gui.fonts.arial10 as arial10
|
||||||
|
from gui.core.colors import *
|
||||||
GREEN = SSD.rgb(0, 255, 0)
|
|
||||||
RED = SSD.rgb(255, 0, 0)
|
|
||||||
BLUE = SSD.rgb(0, 0, 255)
|
|
||||||
YELLOW = SSD.rgb(255, 255, 0)
|
|
||||||
BLACK = 0
|
|
||||||
|
|
||||||
def aclock():
|
def aclock():
|
||||||
uv = lambda phi : cmath.rect(1, phi) # Return a unit vector of phase phi
|
uv = lambda phi : cmath.rect(1, phi) # Return a unit vector of phase phi
|
||||||
|
|
|
@ -2,27 +2,8 @@
|
||||||
# Adafruit 1.5" 128*128 OLED display: https://www.adafruit.com/product/1431
|
# Adafruit 1.5" 128*128 OLED display: https://www.adafruit.com/product/1431
|
||||||
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
||||||
|
|
||||||
# The MIT License (MIT)
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
# Copyright (c) 2018 Peter Hinch
|
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
# THE SOFTWARE.
|
|
||||||
|
|
||||||
# WIRING
|
# WIRING
|
||||||
# Pyb SSD
|
# Pyb SSD
|
||||||
|
@ -34,40 +15,25 @@
|
||||||
# X6 CLK
|
# X6 CLK
|
||||||
# X8 DATA
|
# X8 DATA
|
||||||
|
|
||||||
height = 96 # 1.27 inch 96*128 (rows*cols) display
|
|
||||||
# height = 128 # 1.5 inch 128*128 display
|
|
||||||
|
|
||||||
# Demo of initialisation procedure designed to minimise risk of memory fail
|
# Demo of initialisation procedure designed to minimise risk of memory fail
|
||||||
# when instantiating the frame buffer. The aim is to do this as early as
|
# when instantiating the frame buffer. The aim is to do this as early as
|
||||||
# possible before importing other modules.
|
# possible before importing other modules.
|
||||||
|
|
||||||
import machine
|
|
||||||
import gc
|
import gc
|
||||||
from ssd1351 import SSD1351 as SSD
|
|
||||||
|
|
||||||
# Initialise hardware
|
# Initialise hardware
|
||||||
pdc = machine.Pin('X1', machine.Pin.OUT_PP, value=0)
|
from ssd1351_setup import ssd # Create a display instance
|
||||||
pcs = machine.Pin('X2', machine.Pin.OUT_PP, value=1)
|
|
||||||
prst = machine.Pin('X3', machine.Pin.OUT_PP, value=1)
|
from gui.core.nanogui import Dial, Pointer, refresh
|
||||||
spi = machine.SPI(1)
|
|
||||||
gc.collect() # Precaution befor instantiating framebuf
|
|
||||||
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|
|
||||||
from nanogui import Dial, Pointer, refresh
|
|
||||||
refresh(ssd) # Initialise and clear display.
|
refresh(ssd) # Initialise and clear display.
|
||||||
|
|
||||||
# Now import other modules
|
# Now import other modules
|
||||||
|
|
||||||
import utime
|
import utime
|
||||||
import pyb
|
import pyb
|
||||||
from writer import CWriter
|
from gui.core.writer import CWriter
|
||||||
import arial10 # Font
|
import gui.fonts.arial10 as arial10
|
||||||
|
from gui.core.colors import *
|
||||||
GREEN = SSD.rgb(0, 255, 0)
|
|
||||||
RED = SSD.rgb(255, 0, 0)
|
|
||||||
BLUE = SSD.rgb(0, 0, 255)
|
|
||||||
YELLOW = SSD.rgb(255, 255, 0)
|
|
||||||
BLACK = 0
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print('alevel test is running.')
|
print('alevel test is running.')
|
||||||
|
|
|
@ -6,49 +6,21 @@
|
||||||
# Copyright (c) 2020 Peter Hinch
|
# Copyright (c) 2020 Peter Hinch
|
||||||
# Released under the MIT License (MIT) - see LICENSE file
|
# Released under the MIT License (MIT) - see LICENSE file
|
||||||
|
|
||||||
# WIRING (Adafruit pin nos and names)
|
|
||||||
# Pyb SSD
|
|
||||||
# 3v3 Vin (10)
|
|
||||||
# Gnd Gnd (11)
|
|
||||||
# X1 DC (3 DC)
|
|
||||||
# X2 CS (5 OC OLEDCS)
|
|
||||||
# X3 Rst (4 R RESET)
|
|
||||||
# X6 CLK (2 CL SCK)
|
|
||||||
# X8 DATA (1 SI MOSI)
|
|
||||||
|
|
||||||
height = 96 # 1.27 inch 96*128 (rows*cols) display
|
|
||||||
# height = 128 # 1.5 inch 128*128 display
|
|
||||||
|
|
||||||
import machine
|
|
||||||
import gc
|
|
||||||
from ssd1351 import SSD1351 as SSD
|
|
||||||
|
|
||||||
# Initialise hardware and framebuf before importing modules
|
# Initialise hardware and framebuf before importing modules
|
||||||
#pdc = machine.Pin('X1', machine.Pin.OUT_PP, value=0)
|
from ssd1351_setup import ssd # Create a display instance
|
||||||
#pcs = machine.Pin('X2', machine.Pin.OUT_PP, value=1)
|
|
||||||
#prst = machine.Pin('X3', machine.Pin.OUT_PP, value=1)
|
|
||||||
#spi = machine.SPI(1)
|
|
||||||
pdc = machine.Pin('Y1', machine.Pin.OUT_PP, value=0)
|
|
||||||
pcs = machine.Pin('Y2', machine.Pin.OUT_PP, value=1)
|
|
||||||
prst = machine.Pin('Y3', machine.Pin.OUT_PP, value=1)
|
|
||||||
spi = machine.SPI(2)
|
|
||||||
gc.collect() # Precaution befor instantiating framebuf
|
|
||||||
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|
|
||||||
|
|
||||||
import uasyncio as asyncio
|
import uasyncio as asyncio
|
||||||
import pyb
|
import pyb
|
||||||
import uos
|
import uos
|
||||||
from writer import CWriter
|
from gui.core.writer import CWriter
|
||||||
from nanogui import LED, Meter, refresh
|
from gui.core.nanogui import LED, Meter, refresh
|
||||||
refresh(ssd)
|
refresh(ssd)
|
||||||
|
|
||||||
# Fonts
|
# Fonts
|
||||||
import arial10, freesans20
|
import gui.fonts.arial10 as arial10
|
||||||
|
import gui.fonts.freesans20 as freesans20
|
||||||
|
|
||||||
GREEN = SSD.rgb(0, 255, 0)
|
from gui.core.colors import *
|
||||||
RED = SSD.rgb(255, 0, 0)
|
|
||||||
YELLOW = SSD.rgb(255, 255, 0)
|
|
||||||
BLACK = 0
|
|
||||||
|
|
||||||
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, arial10, GREEN, BLACK, verbose=False)
|
wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False)
|
||||||
|
|
|
@ -6,49 +6,21 @@
|
||||||
# Copyright (c) 2020 Peter Hinch
|
# Copyright (c) 2020 Peter Hinch
|
||||||
# Released under the MIT License (MIT) - see LICENSE file
|
# Released under the MIT License (MIT) - see LICENSE file
|
||||||
|
|
||||||
# WIRING (Adafruit pin nos and names)
|
|
||||||
# Pyb SSD
|
|
||||||
# 3v3 Vin (10)
|
|
||||||
# Gnd Gnd (11)
|
|
||||||
# X1 DC (3 DC)
|
|
||||||
# X2 CS (5 OC OLEDCS)
|
|
||||||
# X3 Rst (4 R RESET)
|
|
||||||
# X6 CLK (2 CL SCK)
|
|
||||||
# X8 DATA (1 SI MOSI)
|
|
||||||
|
|
||||||
height = 96 # 1.27 inch 96*128 (rows*cols) display
|
|
||||||
# height = 128 # 1.5 inch 128*128 display
|
|
||||||
|
|
||||||
import machine
|
|
||||||
import gc
|
|
||||||
from ssd1351 import SSD1351 as SSD
|
|
||||||
|
|
||||||
# Initialise hardware and framebuf before importing modules
|
# Initialise hardware and framebuf before importing modules
|
||||||
#pdc = machine.Pin('X1', machine.Pin.OUT_PP, value=0)
|
from ssd1351_setup import ssd # Create a display instance
|
||||||
#pcs = machine.Pin('X2', machine.Pin.OUT_PP, value=1)
|
|
||||||
#prst = machine.Pin('X3', machine.Pin.OUT_PP, value=1)
|
|
||||||
#spi = machine.SPI(1)
|
|
||||||
pdc = machine.Pin('Y1', machine.Pin.OUT_PP, value=0)
|
|
||||||
pcs = machine.Pin('Y2', machine.Pin.OUT_PP, value=1)
|
|
||||||
prst = machine.Pin('Y3', machine.Pin.OUT_PP, value=1)
|
|
||||||
spi = machine.SPI(2)
|
|
||||||
gc.collect() # Precaution befor instantiating framebuf
|
|
||||||
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|
|
||||||
|
|
||||||
import uasyncio as asyncio
|
import uasyncio as asyncio
|
||||||
import pyb
|
import pyb
|
||||||
import uos
|
import uos
|
||||||
from writer import CWriter
|
from gui.core.writer import CWriter
|
||||||
from nanogui import LED, Meter, refresh
|
from gui.core.nanogui import LED, Meter, refresh
|
||||||
refresh(ssd)
|
refresh(ssd)
|
||||||
|
|
||||||
# Fonts
|
# Fonts
|
||||||
import arial10, freesans20
|
import gui.fonts.arial10 as arial10
|
||||||
|
import gui.fonts.freesans20 as freesans20
|
||||||
|
|
||||||
GREEN = SSD.rgb(0, 255, 0)
|
from gui.core.colors import *
|
||||||
RED = SSD.rgb(255, 0, 0)
|
|
||||||
YELLOW = SSD.rgb(255, 255, 0)
|
|
||||||
BLACK = 0
|
|
||||||
|
|
||||||
color = lambda v : RED if v > 0.7 else YELLOW if v > 0.5 else GREEN
|
color = lambda v : RED if v > 0.7 else YELLOW if v > 0.5 else GREEN
|
||||||
txt = lambda v : 'ovr' if v > 0.7 else 'high' if v > 0.5 else 'ok'
|
txt = lambda v : 'ovr' if v > 0.7 else 'high' if v > 0.5 else 'ok'
|
||||||
|
|
|
@ -3,57 +3,23 @@
|
||||||
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
||||||
# For wiring details see drivers/ADAFRUIT.md in this repo.
|
# For wiring details see drivers/ADAFRUIT.md in this repo.
|
||||||
|
|
||||||
# The MIT License (MIT)
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
|
|
||||||
# Copyright (c) 2018 Peter Hinch
|
from ssd1351_setup import ssd # Create a display instance
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
# THE SOFTWARE.
|
|
||||||
|
|
||||||
height = 96 # 1.27 inch 96*128 (rows*cols) display
|
|
||||||
# height = 128 # 1.5 inch 128*128 display
|
|
||||||
|
|
||||||
import machine
|
|
||||||
import gc
|
|
||||||
from ssd1351 import SSD1351 as SSD
|
|
||||||
|
|
||||||
# Initialise hardware and framebuf before importing modules
|
|
||||||
pdc = machine.Pin('X1', machine.Pin.OUT_PP, value=0)
|
|
||||||
pcs = machine.Pin('X2', machine.Pin.OUT_PP, value=1)
|
|
||||||
prst = machine.Pin('X3', machine.Pin.OUT_PP, value=1)
|
|
||||||
spi = machine.SPI(1)
|
|
||||||
gc.collect() # Precaution befor instantiating framebuf
|
|
||||||
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|
|
||||||
|
|
||||||
import cmath
|
import cmath
|
||||||
import utime
|
import utime
|
||||||
import uos
|
import uos
|
||||||
from writer import Writer, CWriter
|
from gui.core.writer import Writer, CWriter
|
||||||
from nanogui import Label, Meter, LED, Dial, Pointer, refresh
|
from gui.core.nanogui import Label, Meter, LED, Dial, Pointer, refresh
|
||||||
|
|
||||||
# Fonts
|
# Fonts
|
||||||
import arial10, freesans20
|
import gui.fonts.arial10 as arial10
|
||||||
|
import gui.fonts.freesans20 as freesans20
|
||||||
|
|
||||||
|
from gui.core.colors import *
|
||||||
|
|
||||||
GREEN = SSD.rgb(0, 255, 0)
|
|
||||||
RED = SSD.rgb(255, 0, 0)
|
|
||||||
BLUE = SSD.rgb(0, 0, 255)
|
|
||||||
YELLOW = SSD.rgb(255, 255, 0)
|
|
||||||
BLACK = 0
|
|
||||||
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, arial10, GREEN, BLACK, verbose=False)
|
wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False)
|
||||||
wri.set_clip(True, True, False)
|
wri.set_clip(True, True, False)
|
||||||
|
|
|
@ -2,51 +2,20 @@
|
||||||
# https://www.adafruit.com/product/684
|
# https://www.adafruit.com/product/684
|
||||||
# For wiring details see drivers/ADAFRUIT.md in this repo.
|
# For wiring details see drivers/ADAFRUIT.md in this repo.
|
||||||
|
|
||||||
# The MIT License (MIT)
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
|
|
||||||
# Copyright (c) 2018 Peter Hinch
|
from ssd1351_setup import ssd # Create a display instance
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
from gui.core.nanogui import Label, Meter, LED, refresh
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
# THE SOFTWARE.
|
|
||||||
|
|
||||||
import machine
|
|
||||||
import gc
|
|
||||||
from ssd1331 import SSD1331 as SSD
|
|
||||||
pdc = machine.Pin('X1', machine.Pin.OUT_PP, value=0)
|
|
||||||
pcs = machine.Pin('X2', machine.Pin.OUT_PP, value=1)
|
|
||||||
prst = machine.Pin('X3', machine.Pin.OUT_PP, value=1)
|
|
||||||
spi = machine.SPI(1)
|
|
||||||
gc.collect()
|
|
||||||
ssd = SSD(spi, pcs, pdc, prst) # Create a display instance
|
|
||||||
|
|
||||||
from nanogui import Label, Meter, LED, refresh
|
|
||||||
refresh(ssd)
|
refresh(ssd)
|
||||||
# Fonts
|
# Fonts
|
||||||
import arial10
|
import gui.fonts.arial10 as arial10
|
||||||
from writer import Writer, CWriter
|
|
||||||
|
from gui.core.writer import Writer, CWriter
|
||||||
import utime
|
import utime
|
||||||
import uos
|
import uos
|
||||||
|
from gui.core.colors import *
|
||||||
GREEN = SSD.rgb(0, 255, 0)
|
|
||||||
RED = SSD.rgb(255, 0, 0)
|
|
||||||
BLUE = SSD.rgb(0, 0, 255)
|
|
||||||
YELLOW = SSD.rgb(255, 255, 0)
|
|
||||||
BLACK = 0
|
|
||||||
|
|
||||||
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, arial10, GREEN, BLACK, verbose=False)
|
wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False)
|
||||||
|
|
|
@ -3,27 +3,8 @@
|
||||||
# Adafruit 1.5" 128*128 OLED display: https://www.adafruit.com/product/1431
|
# Adafruit 1.5" 128*128 OLED display: https://www.adafruit.com/product/1431
|
||||||
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
# Adafruit 1.27" 128*96 display https://www.adafruit.com/product/1673
|
||||||
|
|
||||||
# The MIT License (MIT)
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
# Copyright (c) 2018 Peter Hinch
|
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
# THE SOFTWARE.
|
|
||||||
|
|
||||||
# WIRING (Adafruit pin nos and names)
|
# WIRING (Adafruit pin nos and names)
|
||||||
# Pyb SSD
|
# Pyb SSD
|
||||||
|
@ -38,37 +19,22 @@
|
||||||
height = 96 # 1.27 inch 96*128 (rows*cols) display
|
height = 96 # 1.27 inch 96*128 (rows*cols) display
|
||||||
# height = 128 # 1.5 inch 128*128 display
|
# height = 128 # 1.5 inch 128*128 display
|
||||||
|
|
||||||
import machine
|
from ssd1351_setup import ssd # Create a display instance
|
||||||
import gc
|
|
||||||
from ssd1351 import SSD1351 as SSD
|
|
||||||
|
|
||||||
# Initialise hardware and framebuf before importing modules
|
|
||||||
pdc = machine.Pin('X1', machine.Pin.OUT_PP, value=0)
|
|
||||||
pcs = machine.Pin('X2', machine.Pin.OUT_PP, value=1)
|
|
||||||
prst = machine.Pin('X3', machine.Pin.OUT_PP, value=1)
|
|
||||||
spi = machine.SPI(1)
|
|
||||||
gc.collect() # Precaution befor instantiating framebuf
|
|
||||||
ssd = SSD(spi, pcs, pdc, prst, height) # Create a display instance
|
|
||||||
|
|
||||||
import cmath
|
import cmath
|
||||||
import math
|
import math
|
||||||
import utime
|
import utime
|
||||||
import uos
|
import uos
|
||||||
from writer import Writer, CWriter
|
from gui.core.writer import Writer, CWriter
|
||||||
from fplot import PolarGraph, PolarCurve, CartesianGraph, Curve, TSequence
|
from gui.core.fplot import PolarGraph, PolarCurve, CartesianGraph, Curve, TSequence
|
||||||
from nanogui import Label, refresh
|
from gui.core.nanogui import Label, refresh
|
||||||
refresh(ssd)
|
refresh(ssd)
|
||||||
|
|
||||||
# Fonts
|
# Fonts
|
||||||
import arial10, freesans20
|
import gui.fonts.arial10 as arial10
|
||||||
|
import gui.fonts.freesans20 as freesans20
|
||||||
|
|
||||||
GREEN = SSD.rgb(0, 255, 0)
|
from gui.core.colors import *
|
||||||
RED = SSD.rgb(255, 0, 0)
|
|
||||||
BLUE = SSD.rgb(0, 0, 255)
|
|
||||||
YELLOW = SSD.rgb(255, 255, 0)
|
|
||||||
WHITE = SSD.rgb(255, 255, 255)
|
|
||||||
BLACK = 0
|
|
||||||
LIGHTGREEN = SSD.rgb(0, 100, 0)
|
|
||||||
|
|
||||||
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, arial10, GREEN, BLACK, verbose=False)
|
wri = CWriter(ssd, arial10, GREEN, BLACK, verbose=False)
|
||||||
|
|
|
@ -1,27 +1,7 @@
|
||||||
# mono_test.py Demo program for nano_gui on an SSD1306 OLED display.
|
# mono_test.py Demo program for nano_gui on an SSD1306 OLED display.
|
||||||
|
|
||||||
# The MIT License (MIT)
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
#
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
# Copyright (c) 2018 Peter Hinch
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
# THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
# https://learn.adafruit.com/monochrome-oled-breakouts/wiring-128x32-spi-oled-display
|
# https://learn.adafruit.com/monochrome-oled-breakouts/wiring-128x32-spi-oled-display
|
||||||
# https://www.proto-pic.co.uk/monochrome-128x32-oled-graphic-display.html
|
# https://www.proto-pic.co.uk/monochrome-128x32-oled-graphic-display.html
|
||||||
|
@ -31,14 +11,13 @@
|
||||||
import utime
|
import utime
|
||||||
import uos
|
import uos
|
||||||
from ssd1306_setup import WIDTH, HEIGHT, setup
|
from ssd1306_setup import WIDTH, HEIGHT, setup
|
||||||
from writer import Writer, CWriter
|
from gui.core.writer import Writer, CWriter
|
||||||
from nanogui import Label, Meter, refresh
|
from gui.core.nanogui import Label, Meter, refresh
|
||||||
|
|
||||||
# Fonts
|
# Fonts
|
||||||
import courier20 as fixed
|
import gui.fonts.arial10 as arial10
|
||||||
import font6 as small
|
import gui.courier20 as fixed
|
||||||
import arial10
|
import gui.fonts.font6 as small
|
||||||
|
|
||||||
|
|
||||||
def fields(use_spi=False, soft=True):
|
def fields(use_spi=False, soft=True):
|
||||||
ssd = setup(use_spi, soft) # Create a display instance
|
ssd = setup(use_spi, soft) # Create a display instance
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
# ssd1306_setup.py Demo pogram for rendering arbitrary fonts to an SSD1306 OLED display.
|
||||||
|
# Device initialisation
|
||||||
|
|
||||||
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
|
|
||||||
|
|
||||||
|
# https://learn.adafruit.com/monochrome-oled-breakouts/wiring-128x32-spi-oled-display
|
||||||
|
# https://www.proto-pic.co.uk/monochrome-128x32-oled-graphic-display.html
|
||||||
|
|
||||||
|
import machine
|
||||||
|
from drivers.ssd1306.ssd1306 import SSD1306_SPI, SSD1306_I2C
|
||||||
|
|
||||||
|
WIDTH = const(128)
|
||||||
|
HEIGHT = const(64)
|
||||||
|
|
||||||
|
def setup(use_spi=False, soft=True):
|
||||||
|
if use_spi:
|
||||||
|
# Pyb SSD
|
||||||
|
# 3v3 Vin
|
||||||
|
# Gnd Gnd
|
||||||
|
# X1 DC
|
||||||
|
# X2 CS
|
||||||
|
# X3 Rst
|
||||||
|
# X6 CLK
|
||||||
|
# X8 DATA
|
||||||
|
pdc = machine.Pin('Y1', machine.Pin.OUT_PP)
|
||||||
|
pcs = machine.Pin('Y2', machine.Pin.OUT_PP)
|
||||||
|
prst = machine.Pin('Y3', machine.Pin.OUT_PP)
|
||||||
|
if soft:
|
||||||
|
spi = machine.SPI(sck=machine.Pin('Y6'), mosi=machine.Pin('Y8'), miso=machine.Pin('Y7'))
|
||||||
|
else:
|
||||||
|
spi = machine.SPI(2)
|
||||||
|
ssd = SSD1306_SPI(WIDTH, HEIGHT, spi, pdc, prst, pcs)
|
||||||
|
else: # I2C
|
||||||
|
# Pyb SSD
|
||||||
|
# 3v3 Vin
|
||||||
|
# Gnd Gnd
|
||||||
|
# Y9 CLK
|
||||||
|
# Y10 DATA
|
||||||
|
if soft:
|
||||||
|
pscl = machine.Pin('Y9', machine.Pin.OPEN_DRAIN)
|
||||||
|
psda = machine.Pin('Y10', machine.Pin.OPEN_DRAIN)
|
||||||
|
i2c = machine.I2C(scl=pscl, sda=psda)
|
||||||
|
else:
|
||||||
|
i2c = machine.I2C(2)
|
||||||
|
ssd = SSD1306_I2C(WIDTH, HEIGHT, i2c)
|
||||||
|
return ssd
|
Ładowanie…
Reference in New Issue