Mercurial > code > home > repos > light9
comparison light8/io.py @ 83:ae2ed47a5321
io can now return to being dummy (untested)
io can now return to being dummy (untested)
fixed a wrong method name in SerialPots too
author | drewp |
---|---|
date | Fri, 12 Jul 2002 10:59:43 +0000 |
parents | 70bd142d72c2 |
children | 0459cecf8145 |
comparison
equal
deleted
inserted
replaced
82:65e77dc74ad8 | 83:ae2ed47a5321 |
---|---|
10 print "IO: %s is going live" % self.__name__ | 10 print "IO: %s is going live" % self.__name__ |
11 self.dummy=0 | 11 self.dummy=0 |
12 # you'd override with additional startup stuff here, | 12 # you'd override with additional startup stuff here, |
13 # perhaps even loading a module and saving it to a class | 13 # perhaps even loading a module and saving it to a class |
14 # attr so the subclass-specific functions can use it | 14 # attr so the subclass-specific functions can use it |
15 | |
16 def godummy(self): | |
17 print "IO: %s is going dummy" % self.__name__ | |
18 self.dummy=1 | |
19 # you might override this to close ports, etc | |
15 | 20 |
16 def isdummy(self): | 21 def isdummy(self): |
17 return self.dummy | 22 return self.dummy |
18 | 23 |
19 def __repr__(self): | 24 def __repr__(self): |
56 def __init__(self): | 61 def __init__(self): |
57 # no init here- call getport() to actually initialize | 62 # no init here- call getport() to actually initialize |
58 self.dummy=1 | 63 self.dummy=1 |
59 self.__name__='SerialPots' # i thought this was automatic! | 64 self.__name__='SerialPots' # i thought this was automatic! |
60 | 65 |
61 def startup(self): | 66 def golive(self): |
62 """ | 67 """ |
63 ls -l /dev/i2c-0 | 68 ls -l /dev/i2c-0 |
64 crw-rw-rw- 1 root root 89, 0 Jul 11 12:27 /dev/i2c-0 | 69 crw-rw-rw- 1 root root 89, 0 Jul 11 12:27 /dev/i2c-0 |
65 """ | 70 """ |
66 import serport | 71 import serport |
71 # this is for a chip with A0,A1,A2 lines all low: | 76 # this is for a chip with A0,A1,A2 lines all low: |
72 port = 72 | 77 port = 72 |
73 | 78 |
74 ioctl(self.f,I2C_SLAVE,port) | 79 ioctl(self.f,I2C_SLAVE,port) |
75 self.dummy=0 | 80 self.dummy=0 |
81 | |
82 def godummy(self): | |
83 BaseIO.godummy(self) | |
84 self.f.close() | |
76 | 85 |
77 def getlevels(self): | 86 def getlevels(self): |
78 if self.dummy: | 87 if self.dummy: |
79 return (0,0,0,0) | 88 return (0,0,0,0) |
80 else: | 89 else: |