Commit 3e924664 authored by schneider's avatar schneider

fix(pycardium): Use standard Python module names

parent 99dfb411
import leds
import math
import utime
import time
def col_cor(colors, brightness=1, gamma=1):
......@@ -90,6 +90,6 @@ def kitt(
halo(output)
leds.set_all(output)
utime.sleep_ms(delay)
time.sleep_ms(delay)
leds.clear()
#this script reads a BMP file and displays it as POV. For optimal results use a BMP that is 11 pixels wide.
import leds,utime
import leds
#default filename. Depending on how you want to run this, change it
FILENAME = "Smiley.bmp"
#Determines the Frame Rate, currently not used.
......
......@@ -79,7 +79,7 @@ flags["poly"] = [
[0, 0, 0],
[0, 0, 0],
]
import leds, display, math, utime, ledfx
import leds, display, math, time, ledfx
def expand(colors, cutoff=12):
......@@ -169,7 +169,7 @@ def demo(s_delay=2):
print(i)
show_leds(flag=i)
show_display(flag=i)
utime.sleep_ms(s_delay * 1000)
time.sleep_ms(s_delay * 1000)
leds.clear()
with display.open() as disp:
disp.clear().update()
......
......@@ -2,7 +2,7 @@ import buttons
import color
import display
import sys
import utime
import time
TIMEOUT = 0x100
""":py:func:`~simple_menu.button_events` timeout marker."""
......@@ -46,11 +46,11 @@ def button_events(timeout=None):
if timeout is not None:
timeout = int(timeout * 1000)
next_tick = utime.time_ms() + timeout
next_tick = time.time_ms() + timeout
while True:
if timeout is not None:
current_time = utime.time_ms()
current_time = time.time_ms()
if current_time >= next_tick:
next_tick += timeout
yield TIMEOUT
......@@ -191,7 +191,7 @@ class Menu:
self.entries = entries
self.idx = 0
self.select_time = utime.time_ms()
self.select_time = time.time_ms()
self.disp = display.open()
self.button_scroll_up = (
buttons.TOP_RIGHT if self.right_buttons_scroll else buttons.BOTTOM_LEFT
......@@ -236,7 +236,7 @@ class Menu:
if offset == 20 and len(string) >= 10:
# Slowly scroll entry to the side
time_offset = (utime.time_ms() - self.select_time) // int(
time_offset = (time.time_ms() - self.select_time) // int(
self.scroll_speed * 1000
)
time_offset = time_offset % (len(string) - 7) - 1
......@@ -306,7 +306,7 @@ class Menu:
for ev in button_events(timeout):
if ev == buttons.BOTTOM_RIGHT:
self.select_time = utime.time_ms()
self.select_time = time.time_ms()
self.draw_menu(-8)
self.idx = (self.idx + 1) % len(self.entries)
try:
......@@ -317,7 +317,7 @@ class Menu:
print("Exception during menu.on_scroll():")
sys.print_exception(e)
elif ev == self.button_scroll_up:
self.select_time = utime.time_ms()
self.select_time = time.time_ms()
self.draw_menu(8)
self.idx = (self.idx + len(self.entries) - 1) % len(self.entries)
try:
......@@ -328,10 +328,10 @@ class Menu:
print("Exception during menu.on_scroll():")
sys.print_exception(e)
elif ev == self.button_select:
t0 = utime.time()
t0 = time.time()
long_press = False
while buttons.read(buttons.TOP_RIGHT) > 0:
if utime.time() - t0 > 1:
if time.time() - t0 > 1:
long_press = True
break
......@@ -340,19 +340,19 @@ class Menu:
self.on_long_select(self.entries[self.idx], self.idx)
else:
self.on_select(self.entries[self.idx], self.idx)
self.select_time = utime.time_ms()
self.select_time = time.time_ms()
except _ExitMenuException:
raise
except Exception as e:
print("Menu crashed!")
sys.print_exception(e)
self.error("Menu", "crashed")
utime.sleep(1.0)
time.sleep(1.0)
self.draw_menu()
if self.timeout is not None and (
utime.time_ms() - self.select_time
time.time_ms() - self.select_time
) > int(self.timeout * 1000):
self.on_timeout()
except _ExitMenuException:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment