Emma
Diverse decks of slide mainly about Django
By Leila Verhaegen and Emma Delescolle
Emma
cofounder of LevIT
Maintener of DRF-Schema-Adapter
Maintener of Ember-cli-crudities
Leila
cofounder of LevIT
young Python and EmberJs developer
who love playing with electronic and micro-bits
pcf8523_light.py
RTC read/write
clock.py
the main clock management module
utils.py
binary to decimal converters
pcf8523_light.py
def read(self, reg_def, debug=False):
if not self.i2c.try_lock():
return [None]
rv = bytearray(1)
self.i2c.writeto(self.address, bytes([reg_def[0]]), stop=False)
self.i2c.readfrom_into(self.address, rv)
self.i2c.unlock()
return [rv[0] & reg_def[1]]
def write(self, reg_def, value, debug=False):
buf = bytearray(2)
buf[0] = reg_def[0]
buf[1] = value
if not self.i2c.try_lock():
return False
self.i2c.writeto(self.address, buf)
self.i2c.unlock()
return True
...
if num == 0:
pixels[pos*8 + 0] = color
pixels[pos*8 + 1] = color
pixels[pos*8 + 2] = color
pixels[pos*8 + 4] = color
pixels[pos*8 + 5] = color
pixels[pos*8 + 6] = color
elif num == 1:
pixels[pos*8 + 2] = color
pixels[pos*8 + 6] = color
...
def days_in_month(year, month):
if month in (1, 3, 5, 7, 8, 10, 12):
return 31
elif month != 2:
return 30
elif is_leap(year):
return 29
return 28
def is_leap(year):
if year % 4 != 0:
return False
if year % 100 != 0:
return True
return year % 400 == 0
if mode == 0:
show_number(current.tm_hour // 10, pos=0)
show_number(current.tm_hour % 10, pos=1)
show_number(current.tm_min // 10, pos=2)
show_number(current.tm_min % 10, pos=3)
if btn_h.value is False:
rtc.datetime = time.struct_time((current.tm_year, current.tm_mon, current.tm_mday,
(current.tm_hour + 1) % 24, current.tm_min,
0,0,9,-1))
time.sleep(.1)
elif btn_m.value is False:
rtc.datetime = time.struct_time((current.tm_year, current.tm_mon, current.tm_mday,
current.tm_hour, (current.tm_min + 1) % 60,
0,0,9,-1))
time.sleep(.1)
@LeilaVerhaegen
@EmmaDelescolle
@levit_SCS
leila20
nanuxbe
https://levit.be
https://blog.levit.be
levit_scs
By Emma
pyconUK 2018 talk