Advertisement
Guest User

display.py

a guest
Jun 24th, 2013
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import subprocess
  4.  
  5. class MyDisplay:
  6.  
  7.     def __init__( self ):
  8.         self.value = 0
  9.  
  10.         self.proc = subprocess.Popen(
  11.  
  12.             ["./display_ctl"],
  13.             stdout = subprocess.PIPE,
  14.             stdin = subprocess.PIPE
  15.         )
  16.  
  17.     def __del__(self):
  18.         self.proc.terminate()
  19.  
  20.     def set_value( self, val ):
  21.         self.value = val
  22.         self.proc.stdin.write( str(val) + '\n')
  23.         print 'Set value', val
  24.  
  25.     def get_value( self ):
  26.         return self.value
  27.  
  28.  
  29.  
  30. if __name__=="__main__":
  31.  
  32.     dev = MyDisplay()
  33.     dev.set_value( 15 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement