Merge branch 'main' into bundlefly-11
This commit is contained in:
commit
2fe21340ae
70 changed files with 53 additions and 135 deletions
|
|
@ -160,8 +160,7 @@ def startScan(radio, send_ad, send_advertising,
|
|||
if endscan_cb is not None and endscan_cb(addr_text, adv_ss.address, adv_ss):
|
||||
complete = True
|
||||
break
|
||||
else:
|
||||
continue
|
||||
continue
|
||||
|
||||
# Must be a match if this is reached
|
||||
matching_ads += 1
|
||||
|
|
@ -226,7 +225,7 @@ def startScan(radio, send_ad, send_advertising,
|
|||
return (complete, matching_ads, awaiting_allrx, awaiting_allacks)
|
||||
|
||||
|
||||
def broadcastAndReceive(radio,
|
||||
def broadcastAndReceive(radio, # pylint: disable=dangerous-default-value
|
||||
send_ad,
|
||||
*receive_ads_types,
|
||||
scan_time=DEF_SEND_TIME_S,
|
||||
|
|
@ -130,7 +130,7 @@ class RPSDisplay():
|
|||
def loadSprites(filename, transparent=0):
|
||||
"""Load horizontal sprite sheet if running with a display
|
||||
"""
|
||||
import adafruit_imageload
|
||||
import adafruit_imageload # pylint: disable=import-outside-toplevel
|
||||
s_bit, s_pal = adafruit_imageload.load(filename,
|
||||
bitmap=displayio.Bitmap,
|
||||
palette=displayio.Palette)
|
||||
|
|
@ -37,3 +37,7 @@ tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
|
|||
group = displayio.Group()
|
||||
group.append(tile_grid)
|
||||
display.show(group)
|
||||
|
||||
# Loop forever so you can enjoy your image
|
||||
while True:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -64,3 +64,7 @@ tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
|
|||
group = displayio.Group()
|
||||
group.append(tile_grid)
|
||||
display.show(group)
|
||||
|
||||
# Loop forever so you can enjoy your image
|
||||
while True:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@ text_area.y = 20
|
|||
|
||||
# Show it
|
||||
display.show(text_area)
|
||||
|
||||
# Loop forever so you can enjoy your text
|
||||
while True:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -62,3 +62,7 @@ tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
|
|||
group = displayio.Group()
|
||||
group.append(tile_grid)
|
||||
display.show(group)
|
||||
|
||||
# Loop forever so you can enjoy your image
|
||||
while True:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -30,3 +30,7 @@ bitmap[80, 50] = 1
|
|||
for x in range(150, 170):
|
||||
for y in range(100, 110):
|
||||
bitmap[x, y] = 1
|
||||
|
||||
# Loop forever so you can enjoy your image
|
||||
while True:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@ text_area.y = 80
|
|||
|
||||
# Show it
|
||||
display.show(text_area)
|
||||
|
||||
# Loop forever so you can enjoy your image
|
||||
while True:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -64,3 +64,7 @@ sprite.y = 70
|
|||
|
||||
# Add the Group to the Display
|
||||
display.show(group)
|
||||
|
||||
# Loop forever so you can enjoy your image
|
||||
while True:
|
||||
pass
|
||||
|
|
|
|||
27
PyLeap_NeoPixel_demo/code.py
Normal file → Executable file
27
PyLeap_NeoPixel_demo/code.py
Normal file → Executable file
|
|
@ -3,10 +3,27 @@ import board
|
|||
import neopixel
|
||||
|
||||
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.2, auto_write=False)
|
||||
rainbow_cycle_demo = 1
|
||||
|
||||
def colorwheel(pos):
|
||||
if pos < 0 or pos > 255:
|
||||
return (0, 0, 0)
|
||||
if pos < 85:
|
||||
return (255 - pos * 3, pos * 3, 0)
|
||||
if pos < 170:
|
||||
pos -= 85
|
||||
return (0, 255 - pos * 3, pos * 3)
|
||||
pos -= 170
|
||||
return (pos * 3, 0, 255 - pos * 3)
|
||||
|
||||
def rainbow_cycle(wait):
|
||||
for j in range(255):
|
||||
for i in range(10):
|
||||
rc_index = (i * 256 // 10) + j * 5
|
||||
pixels[i] = colorwheel(rc_index & 255)
|
||||
pixels.show()
|
||||
time.sleep(wait)
|
||||
|
||||
while True:
|
||||
for j in range(255):
|
||||
for i in range(len(pixels)):
|
||||
rc_index = (i * 256 // len(pixels)) + j
|
||||
pixels[i] = neopixel._pixelbuf.wheel(rc_index)
|
||||
pixels.show()
|
||||
if rainbow_cycle_demo:
|
||||
rainbow_cycle(0.05)
|
||||
|
|
|
|||
|
|
@ -1,126 +0,0 @@
|
|||
"""
|
||||
GFX Helper for pyportal_azure_iot_temperature.py
|
||||
"""
|
||||
import board
|
||||
import displayio
|
||||
from adafruit_display_text.label import Label
|
||||
from adafruit_bitmap_font import bitmap_font
|
||||
|
||||
# the current working directory (where this file is)
|
||||
cwd = ("/" + __file__).rsplit("/", 1)[0]
|
||||
|
||||
# Fonts within /fonts folder
|
||||
info_font = cwd + "/fonts/Nunito-Black-17.bdf"
|
||||
temperature_font = cwd + "/fonts/Nunito-Light-75.bdf"
|
||||
|
||||
|
||||
class Azure_GFX(displayio.Group):
|
||||
def __init__(self, celsius=False):
|
||||
"""Creates an Azure_GFX object.
|
||||
:param bool celsius: Temperature displayed as F or C
|
||||
"""
|
||||
# root displayio group
|
||||
root_group = displayio.Group()
|
||||
board.DISPLAY.show(root_group)
|
||||
super().__init__()
|
||||
|
||||
self._celsius = celsius
|
||||
|
||||
# create background icon group
|
||||
self._icon_group = displayio.Group()
|
||||
self.append(self._icon_group)
|
||||
board.DISPLAY.show(self._icon_group)
|
||||
# create text object group
|
||||
self._text_group = displayio.Group()
|
||||
self.append(self._text_group)
|
||||
|
||||
self._icon_sprite = None
|
||||
self._icon_file = None
|
||||
self._cwd = cwd
|
||||
self.set_icon(self._cwd + "/images/azure_splash.bmp")
|
||||
|
||||
print("Loading Fonts...")
|
||||
glyphs = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.:/ "
|
||||
self.info_font = bitmap_font.load_font(info_font)
|
||||
self.info_font.load_glyphs(glyphs)
|
||||
|
||||
self.c_font = bitmap_font.load_font(temperature_font)
|
||||
self.c_font.load_glyphs(glyphs)
|
||||
self.c_font.load_glyphs(("°",)) # extra glyph for temperature font
|
||||
|
||||
print("setting up labels...")
|
||||
self.title_text = Label(self.info_font, text="Azure IoT Temperature Logger")
|
||||
self.title_text.x = 55
|
||||
self.title_text.y = 15
|
||||
self._text_group.append(self.title_text)
|
||||
|
||||
self.temp_text = Label(self.c_font)
|
||||
self.temp_text.x = 25
|
||||
self.temp_text.y = 110
|
||||
self._text_group.append(self.temp_text)
|
||||
|
||||
self.azure_status_text = Label(self.info_font)
|
||||
self.azure_status_text.x = 100
|
||||
self.azure_status_text.y = 220
|
||||
self._text_group.append(self.azure_status_text)
|
||||
|
||||
board.DISPLAY.show(self._text_group)
|
||||
|
||||
def display_azure_status(self, status_text):
|
||||
"""Displays the current Azure IoT status.
|
||||
:param str status_text: Description of Azure IoT status
|
||||
"""
|
||||
self.azure_status_text.text = status_text
|
||||
|
||||
def display_temp(self, adt_data):
|
||||
"""Displays the data from the ADT7410 on the.
|
||||
:param float adt_data: Value from the ADT7410
|
||||
"""
|
||||
if not self._celsius:
|
||||
adt_data = (adt_data * 9 / 5) + 32
|
||||
print("Temperature: %0.2f°F" % adt_data)
|
||||
if adt_data >= 212:
|
||||
self.temp_text.color = 0xFD2EE
|
||||
elif adt_data <= 32:
|
||||
self.temp_text.color = 0xFF0000
|
||||
self.temp_text.text = "%0.2f°F" % adt_data
|
||||
else:
|
||||
print("Temperature: %0.2f°C" % adt_data)
|
||||
if adt_data <= 0:
|
||||
self.temp_text.color = 0xFD2EE
|
||||
elif adt_data >= 100:
|
||||
self.temp_text.color = 0xFF0000
|
||||
self.temp_text.text = "%0.2f°C" % adt_data
|
||||
|
||||
def set_icon(self, filename):
|
||||
"""Sets the background image to a bitmap file.
|
||||
|
||||
:param filename: The filename of the chosen icon
|
||||
"""
|
||||
print("Set icon to ", filename)
|
||||
if self._icon_group:
|
||||
self._icon_group.pop()
|
||||
|
||||
if not filename:
|
||||
return # we're done, no icon desired
|
||||
|
||||
# CircuitPython 6 & 7 compatible
|
||||
if self._icon_file:
|
||||
self._icon_file.close()
|
||||
self._icon_file = open(filename, "rb")
|
||||
icon = displayio.OnDiskBitmap(self._icon_file)
|
||||
self._icon_sprite = displayio.TileGrid(
|
||||
icon, pixel_shader=getattr(icon, "pixel_shader", displayio.ColorConverter())
|
||||
)
|
||||
|
||||
# CircuitPython 7 compatible
|
||||
# # Remove self._icon_file - it is no longer used
|
||||
# icon = displayio.OnDiskBitmap(filename)
|
||||
# self._icon_sprite = displayio.TileGrid(icon, pixel_shader=icon.pixel_shader)
|
||||
|
||||
self._icon_group.append(self._icon_sprite)
|
||||
try:
|
||||
board.DISPLAY.refresh(target_frames_per_second=60)
|
||||
except AttributeError:
|
||||
board.DISPLAY.refresh_soon()
|
||||
board.DISPLAY.wait_for_frame()
|
||||
Loading…
Reference in a new issue