Dear all,

I am trying to control Nvidia shutter glasses with the help of pyusb. What I
can do so far is to change the state of Green LED to Red. Here is my code
below, if someone has idea to share on the topic, I kindly ask him/her to
share:

#!/usr/bin/python
# -*- coding: utf-8 -*-
#Programmed by Kaan AKŞİT

try:
  import sys,os,usb.core,usb.util,time
except ImportError, err:
  print "couldn't load module. %s" % (err)
  sys.exit()

class shutterglass:
  def __init__(self,idv,idp):
    self.idv = idv
    self.idp = idp
    self.cap = '\x1b\x5b1;33;32m' + 'ID: '+ hex(self.idv) + ':' +
hex(self.idp) + '\x1b[0m'
    self.dev = usb.core.find(idVendor=self.idv, idProduct=self.idp)
    if self.dev is None:
      print self.cap + ' Nvidia shutter glasses \x1b\x5b1;31;40mNOT\x1b[0m
found!'
      sys.exit()
    else:
      print self.cap, 'Nvidia shutter glasses found!'
    self.dev.set_configuration()
    return
  def write(self,data):
    self.dev.write(1,data)
    print self.cap, 'Nvidia shutter glasses received the data.
\x1b\x5b1;33;32m->\x1b[0m'
    return True
  def read(self):
    try:
      data = self.dev.read(1,10)
    except usb.core.USBError:
      return None
    print self.cap, 'Data received from Nvidia shutter glasses.
\x1b\x5b1;31;40m<-\x1b[0m'
    return data

def main():
  sequence = [0x00031842,0x00180001, 0xfffff830, 0x22302824, 0x040a0805,
0x00021c01, 0x00000002,0x00021e01, 0,0x00011b01, 0x00000007,0x00031840]
  glass = shutterglass(0x0955,0x0007)
  while True:
    for i in sequence[:]:
      time.sleep(0.1)
      glass.write(hex(i))
      glass.read()
  return

if __name__ == "__main__":
  sys.exit(main())

Best regards,
Kaan
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to