mmap and bit wise twiddling - Raspberry Pi

Thomas Heller theller at ctypes.org
Wed May 2 16:07:33 EDT 2012


Am 02.05.2012 22:05, schrieb Thomas Heller:
> class GPIO(BitVector):
>     def __init__(self, address, value=0xFF, nbits=8):
>         self.address = address
>         super(GPIO, self).__init__(value, nbits)
>     def _get_value(self):
>         "read an 8-bit value from the hardware as 8-bit integer"
>         ...
>     def _set_value(self, v):
>         "write the 8-bit value 'v' to the hardware"
>         ...

Sorry, forgot to create the property; so please add this
to the class definition:

     _value = property(_get_value, _set_value)


Thomas



More information about the Python-list mailing list