Sep-11-2017, 02:10 PM
function for write to chronodot
Edit
Delete post
Report this post
Quote
Mon Sep 11, 2017 12:34 pm
Hi! all
1: Is there a way to simplify the "write_chronodot(s,m,h)", like using a list [ ] instead ?
2: Is there a way to write like in VB, all in one line :
sec=1 : min=2 : hour=3 : write_chronodot(sec,min,hour)
Here's what I have that run OK :
1= 1
2= 2
3= 3
11= 2 # one sec more = OK
12= 2
13= 3
sec= 2 # one sec more = OK
min= 2
hour= 3
Thanks
Edit
Delete post
Report this post
Quote
Mon Sep 11, 2017 12:34 pm
Hi! all
1: Is there a way to simplify the "write_chronodot(s,m,h)", like using a list [ ] instead ?
2: Is there a way to write like in VB, all in one line :
sec=1 : min=2 : hour=3 : write_chronodot(sec,min,hour)
Here's what I have that run OK :
def write_chronodot(s,m,h): data=[s,m,h] i2c_bus.write_i2c_block_data(0x68,0x00,data) # write 3 chronodot registers (sec-min-hour) print ("1= ",data[0]) print ("2= ",data[1]) print ("3= ",data[2]) return def read_chronodot(): chronodot=i2c_bus.read_i2c_block_data(0x68,0x00,3) print ("11= ",chronodot[0]) print ("12= ",chronodot[1]) print ("13= ",chronodot[2]) return chronodot sec=1 min=2 hour=3 write_chronodot(sec,min,hour) # to set time time.sleep(1) # Wait for the chronodot to change the "sec" register a=read_chronodot() print (" sec= ",a[0]) # To verify the time print (" min= ",a[1]) print ("hour= ",a[2])give:
1= 1
2= 2
3= 3
11= 2 # one sec more = OK
12= 2
13= 3
sec= 2 # one sec more = OK
min= 2
hour= 3
Thanks