Verified Commit 051036fe authored by Rahix's avatar Rahix
Browse files

chore(preload): Remove windows line-endings


Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent ca40b2db
import display
import leds
import utime
_rand = 123456789
def rand():
global _rand
_rand = (1103515245 * _rand + 12345) & 0xFFFFFF
return _rand
gs = 160
colors = [((i >> 2) * gs, (i >> 1 & 1) * gs, (i & 1) * gs) for i in range(1, 8)]
nick = "sample text"
try:
with open("/nickname.txt") as f:
nick = f.read()
except:
pass
while True:
with display.open() as d:
for k in range(4):
(x1, y1) = (rand() % 159, rand() % 79)
(x2, y2) = (min(x1 + rand() % 40, 159), min(y1 + rand() % 40, 79))
try:
d.rect(x1, y1, x2, y2, col=colors[rand() % len(colors)], filled=True)
except:
pass
fg = colors[rand() % len(colors)]
nx = 80 - round(len(nick) / 2 * 14)
d.print(
nick,
fg=fg,
bg=[0xFF - c for c in fg],
posx=(nx - 8) + rand() % 16,
posy=22 + rand() % 16,
)
d.update()
d.close()
leds.set(rand() % 11, colors[rand() % len(colors)])
leds.set_rocket(rand() % 3, rand() % 32)
utime.sleep_us(1) # Feed watch doge
import display
import leds
import utime
_rand = 123456789
def rand():
global _rand
_rand = (1103515245 * _rand + 12345) & 0xFFFFFF
return _rand
gs = 160
colors = [((i >> 2) * gs, (i >> 1 & 1) * gs, (i & 1) * gs) for i in range(1, 8)]
nick = "sample text"
try:
with open("/nickname.txt") as f:
nick = f.read()
except:
pass
while True:
with display.open() as d:
for k in range(4):
(x1, y1) = (rand() % 159, rand() % 79)
(x2, y2) = (min(x1 + rand() % 40, 159), min(y1 + rand() % 40, 79))
try:
d.rect(x1, y1, x2, y2, col=colors[rand() % len(colors)], filled=True)
except:
pass
fg = colors[rand() % len(colors)]
nx = 80 - round(len(nick) / 2 * 14)
d.print(
nick,
fg=fg,
bg=[0xFF - c for c in fg],
posx=(nx - 8) + rand() % 16,
posy=22 + rand() % 16,
)
d.update()
d.close()
leds.set(rand() % 11, colors[rand() % len(colors)])
leds.set_rocket(rand() % 3, rand() % 32)
utime.sleep_us(1) # Feed watch doge
import os
import display
import utime
import buttons
import light_sensor
import math
WIDTH = 160
HEIGHT = 80
disp = display.open()
light_sensor.start()
history = []
while True:
disp.clear()
value = light_sensor.get_reading()
history.insert(0, value)
if len(history) > WIDTH:
history.pop()
disp.print("%i" % value)
for i in range(0, len(history)):
# Rescale to range 0 <= value < HEIGHT-1
y = math.floor(history[i] * (HEIGHT - 2) / max(history))
disp.pixel(WIDTH - i, HEIGHT - y - 1)
disp.update()
utime.sleep(0.1)
import os
import display
import utime
import buttons
import light_sensor
import math
WIDTH = 160
HEIGHT = 80
disp = display.open()
light_sensor.start()
history = []
while True:
disp.clear()
value = light_sensor.get_reading()
history.insert(0, value)
if len(history) > WIDTH:
history.pop()
disp.print("%i" % value)
for i in range(0, len(history)):
# Rescale to range 0 <= value < HEIGHT-1
y = math.floor(history[i] * (HEIGHT - 2) / max(history))
disp.pixel(WIDTH - i, HEIGHT - y - 1)
disp.update()
utime.sleep(0.1)
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