Beispiel #1
0
def cli():
    file = sys.argv[1]
    if len(sys.argv) != 2:
        print >> sys.stderr, 'usage: writecal filename'
        sys.exit(1)

    k = passive(find(0xbeca, 0x0101), 20)
    for line in open(file).readlines():
        words = line.split()
        assert len(words) <= cal_len
        words.extend(['0'] * (cal_len - len(words)))

        key, corner, min, max = map(int, words[:4])
        points = map(int, words[4:])

        k.start_calibration_row(key, corner)
        k.set_calibration_range(min, max)
        for i, p in enumerate(points):
            k.set_calibration_point(i, p)

        print 'writing key %d corner %d (min=%d max=%d)' % (key, corner, min,
                                                            max)
        k.write_calibration_row()

    print 'committing calibration to non volatile memory'
    k.commit_calibration()
Beispiel #2
0
def cli():
    p = find(0x049f, 0x505a)

    print "measuring pot %s" % p

    k = passive(p, 1)
    k.start()
    k.set_rawkeyrate(1)

    while True:
        print "rate=%f" % get_rate(k)
Beispiel #3
0
def cli():
    kbd = passive(find(0xbeca, 0x0101), 20)

    for k in range(0, 18):
        for c in range(0, 4):
            sys.stdout.write('%d %d ' % (k, c))
            sys.stdout.flush()
            kbd.start_calibration_row(k, c)
            kbd.read_calibration_row()
            mn = kbd.get_calibration_min()
            mx = kbd.get_calibration_max()
            pts = [kbd.get_calibration_point(p) for p in range(0, 30)]
            sys.stdout.write('%d %d %s\n' % (mn, mx, ' '.join(map(str, pts))))
            sys.stdout.flush()
Beispiel #4
0
def main():
    dev = picross.find(0xbeca, 0x0101)
    kbd = micro_native.passive(dev, 500)
    kbd.wait()

    for k in range(0, 17):
        kbd.set_ledcolour(k, 0)

    if len(sys.argv) == 3:
        kbd.set_ledcolour(int(sys.argv[1]) - 1, colours[sys.argv[2]])
        print['%x' % ord(x) for x in kbd.debug()]
    else:
        for k in range(0, 17):
            for c in ("red", "green", "orange", "off"):
                kbd.set_ledcolour(k, colours[c])
                print k, c, ['%x' % ord(x) for x in kbd.debug()]
                time.sleep(0.5)
Beispiel #5
0
def cli():
    pot = picross.find(0x049f, 0x505a)
    samples = 1000

    key = 4

    print "measuring pot %s key %d samples %d" % (pot, key, samples)

    kbd = lib_alpha1.passive(pot)
    kbd.start()
    kbd.set_rawkeyrate(1)

    sensors = [key * 4 + i for i in (0, 1, 2, 3)]

    bins = [dict() for s in sensors]
    minv = [100000 for s in sensors]
    maxv = [0 for s in sensors]
    maxt = [0 for s in sensors]

    for i in xrange(samples):
        kbd.wait()

        for (i, s) in enumerate(sensors):
            value = kbd.get_rawkey(s / 4, s % 4)
            total = bins[i].get(value, 0) + 1
            maxv[i] = max(maxv[i], value)
            minv[i] = min(minv[i], value)
            maxt[i] = max(maxt[i], total)
            bins[i][value] = total

    for (i, s) in enumerate(sensors):
        print "key %d sensor %d min %d max %d range %d" % (
            s / 4, s % 4, minv[i], maxv[i], maxv[i] - minv[i])

        range = bins[i].keys()
        range.sort()

        for k in range:
            v = bins[i][k]
            r = int(60.0 * v / maxt[i])
            print '%04d %4d %s' % (k, v, ''.center(60, '*')[0:r])
Beispiel #6
0
def main():
    parser = optparse.OptionParser(usage=sys.argv[0] + ' [options]')
    parser.add_option('-f',
                      '--firmware',
                      action='store',
                      dest='firmware',
                      default='',
                      help='firmware file to load')
    parser.add_option('-S',
                      '--serial',
                      action='store',
                      dest='serial',
                      default=0,
                      help='serial number')
    parser.add_option('-v',
                      '--vid',
                      action='store',
                      dest='vendor',
                      default=0x2139,
                      help='vendor ID')
    parser.add_option('-p',
                      '--pid',
                      action='store',
                      dest='product',
                      default=0x0002,
                      help='product ID')

    (opts, args) = parser.parse_args(sys.argv)

    dev = picross.find(opts.vendor, opts.product)

    if opts.firmware:
        load_firmware(dev, opts.firmware)

    if opts.serial:
        set_serial(dev, opts.serial)
Beispiel #7
0
 def __init__(self):
     self.dev = picross.usbdevice(picross.find(0xbeca, 0x0100), 0)
     self.dev.control(0x40, 0xb1, 0, 0)
Beispiel #8
0
def cli():
    kbd = passive(find(0x049f, 0x505a), 20)
    kbd.clear_calibration()