Example #1
0
def dow_dump(dev):
    """Dumps the entire Day-of-Week Clock memory."""
    usbtiny.dump(
        0x0,
        dev.control_in(3, 0, 0, 7) + dev.control_in(3, 0x7, 0, 7) +
        dev.control_in(3, 0xE, 0, 6))
    dev.control_in(3, 0x10, 0, 2)  # move address pointer away from 0x0:0x7
Example #2
0
def dow_set_time(dev, new_time):
    """Sets the current time of the Day-of-Week Clock to new_time."""
    year = max(new_time.year - 2000, 0)

    raw_time = chr(((new_time.microsecond / 100000) << 4) +
                   ((new_time.microsecond / 10000) % 10))
    raw_time = raw_time + chr(((new_time.second / 10) << 4) +
                              (new_time.second % 10))
    raw_time = raw_time + chr(((new_time.minute / 10) << 4) +
                              (new_time.minute % 10))
    raw_time = raw_time + chr(((new_time.hour / 10) << 4) +
                              (new_time.hour % 10) + 0x80 +
                              ((year / 100) * 0x40))
    raw_time = raw_time + chr(new_time.isoweekday())
    raw_time = raw_time + chr(((new_time.day / 10) << 4) + (new_time.day % 10))
    raw_time = raw_time + chr(((new_time.month / 10) << 4) +
                              (new_time.month % 10))
    raw_time = raw_time + chr((((year % 100) / 10) << 4) + year % 10)
    usbtiny.dump(0, raw_time)
    dev.control_out(2, 0, 0, raw_time)
Example #3
0
    t               - perform USB echo test
    c               - clear IR data
    r               - read current IR data
    i <byte> ...    - send instruction bytes to LCD
    d <byte> ...    - send data bytes to LCD
    s <string> ...  - send strings to LCD"""

dev = usbtiny.USBtiny(vendor, product)

cmd = '?'
if len(sys.argv) > 1:
	cmd = sys.argv[1]
arg = sys.argv[2:]
if cmd == 'r':
	data = dev.control_in(IGORPLUG_READ, 0, 0, 3 + 36)
	usbtiny.dump(0, data)
elif cmd == 'c':
	dev.control_in(IGORPLUG_CLEAR, 0, 0, 0)
elif cmd == 't':
	dev.echo_test()
elif cmd == 'i':
	s = ''.join([chr(int(x,16)) for x in arg])
	dev.control_out(LCD_INSTR, 0, 0, s)
elif cmd == 'd':
	s = ''.join([chr(int(x,16)) for x in arg])
	dev.control_out(LCD_DATA, 0, 0, s)
elif cmd == 's':
	dev.control_out(LCD_DATA, 0, 0, ' '.join(arg))
else:
	print >> sys.stderr, usage
	sys.exit(1)
Example #4
0
                else:
                    dev.control_in(USBTINY_CLR, 0, 0x38, 0)
                led = pd3
            time.sleep(0.02)
    except:
        pass
    finally:
        dev.control_in(USBTINY_POWERUP, 20, 0, 0)
        time.sleep(0.2)
        dev.control_in(USBTINY_POWERDOWN, 0, 0, 0)
elif cmd == 'C':
    r = dev.control_in(USBTINY_SPI, addr + (byte << 8), c3 + (c4 << 8), 4)
    if len(r) == 4:
        print("%02x %02x %02x %02x" % tuple([ord(i) for i in r]))
    else:
        print("No power")
elif cmd == 'P':
    dev.control_in(USBTINY_POLL_BYTES, addr + (byte << 8), 0, 0)
elif cmd == 'f':
    r = dev.control_in(USBTINY_FLASH_READ, 0, addr, byte)
    usbtiny.dump(addr, r)
elif cmd == 'e':
    r = dev.control_in(USBTINY_EEPROM_READ, 0, addr, byte)
    usbtiny.dump(addr, r)
elif cmd == 'F':
    buf = chr(c3)
    dev.control_out(USBTINY_FLASH_WRITE, byte, addr, buf)
elif cmd == 'E':
    buf = chr(c3)
    dev.control_out(USBTINY_EEPROM_WRITE, byte, addr, buf)
				else:
					dev.control_in(USBTINY_CLR, 0, 0x38, 0)
				led = pd3
			time.sleep(0.02)
	except:
		pass
	finally:
		dev.control_in(USBTINY_POWERUP, 20, 0, 0)
		time.sleep(0.2)
		dev.control_in(USBTINY_POWERDOWN, 0, 0, 0)
elif cmd == 'C':
	r = dev.control_in(USBTINY_SPI, addr + (byte << 8), c3 + (c4 << 8), 4)
	if len(r) == 4:
		print "%02x %02x %02x %02x" % tuple([ord(i) for i in r])
	else:
		print "No power"
elif cmd == 'P':
	dev.control_in(USBTINY_POLL_BYTES, addr + (byte << 8), 0, 0)
elif cmd == 'f':
	r = dev.control_in(USBTINY_FLASH_READ, 0, addr, byte)
	usbtiny.dump(addr, r)
elif cmd == 'e':
	r = dev.control_in(USBTINY_EEPROM_READ, 0, addr, byte)
	usbtiny.dump(addr, r)
elif cmd == 'F':
	buf = chr(c3)
	dev.control_out(USBTINY_FLASH_WRITE, byte, addr, buf)
elif cmd == 'E':
	buf = chr(c3)
	dev.control_out(USBTINY_EEPROM_WRITE, byte, addr, buf)