Commit 30a885c8 authored by schneider's avatar schneider
Browse files

chore(g-watch): remove trailing spaces

parent 05ba8877
......@@ -7,7 +7,7 @@ import bhi160
import utime
import power
import light_sensor
disp = display.open()
sensor = 0
sensors = [{"sensor": bhi160.BHI160Orientation(sample_rate=8), "name": "Orientation"}]
......@@ -153,23 +153,23 @@ with display.open() as disp:
timeout=7000 #time in ms how long clock will be displayed
clock_off=clock_on+timeout #time in ms when clock is turned off
fade_time=0 #fade out counter
leds.dim_top(2)
leds_on=0
p_leds_on=0
while True:
millis=utime.monotonic_ms()
lt = utime.localtime()
dow = lt[6]
#---------------------------------------- read brightness sensor
bri=light_sensor.get_reading()
bri=light_sensor.get_reading()
bri=int(fade_time*100/1000 * bri/200) # calculate display brightness in percent (bri)
if (bri>100):
if (bri>100):
bri=100
if (bri<0):
bri=0
......@@ -180,7 +180,7 @@ with display.open() as disp:
#---------------------------------------- read buttons
pressed = buttons.read(buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT)
p_leds_on=leds_on
if pressed & buttons.BOTTOM_LEFT != 0:
leds_on=0
disp.clear()
......@@ -189,7 +189,7 @@ with display.open() as disp:
disp.backlight(brightness=50)
utime.sleep_ms(500)
disp.backlight(brightness=0)
for led in range(led_count):
for led in range(led_count):
leds.prep_hsv(led, [0,0,0])
disp.update()
......@@ -201,10 +201,10 @@ with display.open() as disp:
disp.backlight(brightness=50)
utime.sleep_ms(500)
disp.backlight(brightness=0)
#---------------------------------------- read orientation sensor
samples = sensors[sensor]["sensor"].read()
if len(samples) > 0: #get orientation sensor samples
......@@ -215,37 +215,37 @@ with display.open() as disp:
yd=abs(yn-yo)
yd=yd%180
yd=yd*22 #multiply rotation with amplifier
if abs(sample.z)>50: #if arm is hanging:
yd=0 #do not regard wrist rotation
ydl=ydl*.9
ydl=ydl*.9
ydl=(yd+ydl*9)/10 #low pass filter wrist rotation
if ydl>100: #check rottion against threshold and limit value
if ydl>100: #check rottion against threshold and limit value
ydl=100
if clock_on+timeout<millis:
clock_on=millis
clock_off = timeout+clock_on
#.................................... display rotation bargraph on leds // full bar == hitting threshold
if (leds_on==1):
hour = lt[3]
hue=360-(hour/24*360)
for led in range(led_count):
for led in range(led_count):
if(led<int(ydl/100*12)-1) or millis<clock_off-1500-((10-led)*15)+300:
leds.prep_hsv(10-led, [hue,100,ledbri])#led=0
else:
leds.prep_hsv(10-led, [0,0,0])
#---------------------------------------- display clock
disp.clear()
if clock_off>=millis:
if clock_off>=millis:
#.................................... time
lt = utime.localtime()
......@@ -262,20 +262,20 @@ with display.open() as disp:
if fade_time<0:
fade_time=0
if fade_time>1000:
fade_time=1000
disp.backlight(brightness=bri)
render7segment() #render time in 7-segment digiclock style
disp.print('{:02d}-{:02d}-{} {}'.format(day, month, year, DOW[dow]), posx=10, posy=67, font=2) # display date
#.................................... power
pwr=math.sqrt(power.read_battery_voltage())
#disp.print("%f" % power.read_battery_voltage(), posx=25, posy=58, font=2) # display battery voltage
full=2.0
empty=math.sqrt(3.4)
......@@ -286,10 +286,10 @@ with display.open() as disp:
if pwrpercent<0:
pwrpercent=0
if pwrpercent>100:
pwrpercent=100
disp.rect(8, 60, 153, 63, col=[100,100,100]) # draw battery bar
c=[255,0,0] #red=empty
......@@ -297,18 +297,18 @@ with display.open() as disp:
c=[255,255,0] #yellow=emptyish
if pwrpercent>25:
c=[0,255,0] #green=ok
disp.rect(8, 60, int(pwrpercent*1.43+8), 63, col=c) # draw charge bar in battery bar
#---------------------------------------- do not display clock
leds.update()
disp.update()
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