first commit
This commit is contained in:
commit
68cd9a35e8
5 changed files with 203 additions and 0 deletions
10
evemu.py
Normal file
10
evemu.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from evdev import UInput, ecodes as e
|
||||||
|
|
||||||
|
ui=UInput()
|
||||||
|
|
||||||
|
|
||||||
|
ui.write(e.EV_KEY, e.KEY_A, 1)
|
||||||
|
ui.write(e.EV_KEY, e.KEY_A, 0)
|
||||||
|
ui.syn()
|
||||||
|
|
||||||
|
ui.close()
|
106
fw.elf
Normal file
106
fw.elf
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
:100000000C9435000C945D000C945D000C94360249
|
||||||
|
:100010000C945D000C945D000C945D000C945D00EC
|
||||||
|
:100020000C945D000C945D000C945D000C945D00DC
|
||||||
|
:100030000C945D000C945D000C945D000C945D00CC
|
||||||
|
:100040000C9494010C945D000C9404020C94DE0159
|
||||||
|
:100050000C945D000C945D000C945D000C945D00AC
|
||||||
|
:100060000C945D000C945D00FC0211241FBECFEFC8
|
||||||
|
:10007000D8E0DEBFCDBF11E0A0E0B1E0ECE6F6E0F5
|
||||||
|
:1000800002C005900D92A231B107D9F721E0A2E19B
|
||||||
|
:10009000B1E001C01D92AB3BB207E1F710E0C5E350
|
||||||
|
:1000A000D0E004C02197FE010E942903C433D10788
|
||||||
|
:1000B000C9F70E9450020C9434030C940000CF92B4
|
||||||
|
:1000C000DF92EF92FF920F931F93CF93DF936C0118
|
||||||
|
:1000D0007A018B01C0E0D0E0CE15DF0581F0D801B8
|
||||||
|
:1000E0006D918D01D601ED91FC910190F081E02D93
|
||||||
|
:1000F000C6010995892B11F02196EECF7E01C7012B
|
||||||
|
:10010000DF91CF911F910F91FF90EF90DF90CF90F3
|
||||||
|
:100110000895089580E090E00895FC01538D448D8A
|
||||||
|
:10012000252F30E0842F90E0821B930B541710F0A2
|
||||||
|
:10013000CF96089501970895FC01918D828D9817AF
|
||||||
|
:1001400061F0828DDF01A80FB11D5D968C91928DBB
|
||||||
|
:100150009F5F9F73928F90E008958FEF9FEF0895B8
|
||||||
|
:10016000FC01918D828D981731F0828DE80FF11D81
|
||||||
|
:10017000858D90E008958FEF9FEF0895FC01918D9C
|
||||||
|
:10018000228D892F90E0805C9F4F821B91098F7395
|
||||||
|
:100190009927089585E191E00E94BE0021E0892B16
|
||||||
|
:1001A00009F420E0822F0895FC01848DDF01A80F5F
|
||||||
|
:1001B000B11DA35ABF4F2C91848D90E001968F738F
|
||||||
|
:1001C0009927848FA689B7892C93A089B1898C91AE
|
||||||
|
:1001D000837080648C93938D848D981306C00288FD
|
||||||
|
:1001E000F389E02D80818F7D80830895EF92FF92C7
|
||||||
|
:1001F0000F931F93CF93DF93EC0181E0888F9B8D4A
|
||||||
|
:100200008C8D981305C0E889F989808185FD26C009
|
||||||
|
:10021000F62E0B8D10E00F5F1F4F0F731127E02E8E
|
||||||
|
:100220008C8DE8120CC00FB607FCFACFE889F9896B
|
||||||
|
:10023000808185FFF5CFCE010E94D400F1CF8B8D58
|
||||||
|
:10024000FE01E80FF11DE35AFF4FF0829FB7F894CB
|
||||||
|
:100250000B8FEA89FB89808180620AC09FB7F8947E
|
||||||
|
:10026000EE89FF896083E889F989808183708064E1
|
||||||
|
:1002700080839FBF81E090E0DF91CF911F910F912C
|
||||||
|
:10028000FF90EF900895CF93DF93EC01888D882342
|
||||||
|
:10029000C9F0EA89FB89808185FD05C0A889B989F3
|
||||||
|
:1002A0008C9186FD0FC00FB607FCF5CF808185FFCE
|
||||||
|
:1002B000F2CFA889B9898C9185FFEDCFCE010E943C
|
||||||
|
:1002C000D400E7CFDF91CF91089580E090E0892BB3
|
||||||
|
:1002D00029F00E94CA0081110C94000008958EEF4D
|
||||||
|
:1002E0008BB988E390E0FC013197F1F729B137EF42
|
||||||
|
:1002F0003BB9FC013197F1F739B1307F22952F706E
|
||||||
|
:10030000232BE3E1F1E020832DEF2BB9DC011197E2
|
||||||
|
:10031000F1F729B122952F7021832FEF2BB9019787
|
||||||
|
:10032000F1F708950E942F031F920F920FB60F92BC
|
||||||
|
:1003300011242F933F938F939F93AF93BF938091FB
|
||||||
|
:10034000B7019091B801A091B901B091BA01309173
|
||||||
|
:10035000B60126E0230F2D3720F40296A11DB11D12
|
||||||
|
:1003600005C029E8230F0396A11DB11D2093B601F6
|
||||||
|
:100370008093B7019093B801A093B901B093BA01EB
|
||||||
|
:100380008091B2019091B301A091B401B091B501F7
|
||||||
|
:100390000196A11DB11D8093B2019093B301A0936A
|
||||||
|
:1003A000B401B093B501BF91AF919F918F913F91EF
|
||||||
|
:1003B0002F910F900FBE0F901F9018951F920F92C4
|
||||||
|
:1003C0000FB60F9211242F933F934F935F936F9328
|
||||||
|
:1003D0007F938F939F93AF93BF93EF93FF9385E1A9
|
||||||
|
:1003E00091E00E94D400FF91EF91BF91AF919F9156
|
||||||
|
:1003F0008F917F916F915F914F913F912F910F90CE
|
||||||
|
:100400000FBE0F901F9018951F920F920FB60F926C
|
||||||
|
:1004100011242F938F939F93EF93FF93E0912501E6
|
||||||
|
:10042000F09126018081E0912B01F0912C0182FD59
|
||||||
|
:1004300012C0908180912E018F5F8F7320912F01C8
|
||||||
|
:10044000821751F0E0912E01F0E0EB5EFE4F958FA8
|
||||||
|
:1004500080932E0101C08081FF91EF919F918F9138
|
||||||
|
:100460002F910F900FBE0F901F9018951F920F9213
|
||||||
|
:100470000FB60F9211248F931A990CC00DB407FE7A
|
||||||
|
:10048000FDCF809114018EBD0DB407FEFDCF80918C
|
||||||
|
:1004900013018EBD8F910F900FBE0F901F90189576
|
||||||
|
:1004A000789484B5826084BD84B5816084BD85B54F
|
||||||
|
:1004B000826085BD85B5816085BD80916E0081605B
|
||||||
|
:1004C00080936E0010928100809181008260809301
|
||||||
|
:1004D0008100809181008160809381008091800003
|
||||||
|
:1004E0008160809380008091B10084608093B1002E
|
||||||
|
:1004F0008091B00081608093B00080917A00846028
|
||||||
|
:1005000080937A0080917A00826080937A00809153
|
||||||
|
:100510007A008E7F80937A0080917A008068809341
|
||||||
|
:100520007A001092C10085E191E00E944301E091C0
|
||||||
|
:100530002701F091280180818F7E8083E09127013F
|
||||||
|
:10054000F09128018081877F8083E0912701F091DD
|
||||||
|
:10055000280180818F778083E0912701F091280125
|
||||||
|
:1005600080818F7D808380912F0180932E018BE08D
|
||||||
|
:100570008AB98FEF8BB984B1837D84B9249A85B110
|
||||||
|
:100580008E6185B910921301109214018CB58F7E83
|
||||||
|
:100590008CBD8CB580668CBD80916B00846080932F
|
||||||
|
:1005A0006B00809168008160809368000E946F01F9
|
||||||
|
:1005B0000E946F018FB7F8944091B7015091B80134
|
||||||
|
:1005C0006091B9017091BA018FBF2FB7F8948091F3
|
||||||
|
:1005D000B7019091B801A091B901B091BA012FBFB4
|
||||||
|
:1005E000841B950BA60BB70B84369105A105B105AD
|
||||||
|
:1005F00060F30E946501DCCFE5E1F1E01382128235
|
||||||
|
:1006000088EE93E0A0E0B0E084839583A683B7836F
|
||||||
|
:1006100084E091E09183808385EC90E095878487E6
|
||||||
|
:1006200084EC90E09787868780EC90E0918B808BBC
|
||||||
|
:1006300081EC90E0938B828B82EC90E0958B848BA5
|
||||||
|
:1006400086EC90E0978B868B118E128E138E148E13
|
||||||
|
:100650000895EE0FFF1F0590F491E02D099481E0BD
|
||||||
|
:0C06600090E0F8940C943403F894FFCF61
|
||||||
|
:10066C0000000000F6005F008D004301BE009C00FE
|
||||||
|
:02067C00B000CC
|
||||||
|
:00000001FF
|
4
prog_avr.sh
Executable file
4
prog_avr.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
PROG_CMD="sudo avrdude -c linuxspi -p m328p -P /dev/spidev1.0"
|
||||||
|
|
||||||
|
$PROG_CMD -U flash:w:$1
|
28
spi.py
Normal file
28
spi.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import time
|
||||||
|
import spidev
|
||||||
|
|
||||||
|
bus=1
|
||||||
|
device=0
|
||||||
|
|
||||||
|
spi=spidev.SpiDev()
|
||||||
|
|
||||||
|
spi.open(bus,device)
|
||||||
|
|
||||||
|
spi.max_speed_hz = 250000
|
||||||
|
spi.mode = 0
|
||||||
|
|
||||||
|
|
||||||
|
oldstate=0
|
||||||
|
|
||||||
|
while True:
|
||||||
|
data=spi.xfer2([0x55]*2, spi.max_speed_hz, 1000, 8)
|
||||||
|
state=data[0]<<8 + data[1]
|
||||||
|
|
||||||
|
#data.extend(spi.xfer([0x55], spi.max_speed_hz, 100))
|
||||||
|
|
||||||
|
# if state != oldstate:
|
||||||
|
print(' '.join([format(d,'08b') for d in data]))
|
||||||
|
oldstate=state
|
||||||
|
# time.sleep(1/200)
|
||||||
|
|
||||||
|
|
55
spiev.py
Normal file
55
spiev.py
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
import time
|
||||||
|
import spidev
|
||||||
|
from evdev import UInput, ecodes as e
|
||||||
|
|
||||||
|
|
||||||
|
bus=1
|
||||||
|
device=0
|
||||||
|
|
||||||
|
spi=spidev.SpiDev()
|
||||||
|
|
||||||
|
spi.open(bus,device)
|
||||||
|
|
||||||
|
spi.max_speed_hz = 250000
|
||||||
|
spi.mode = 0
|
||||||
|
|
||||||
|
ui = UInput()
|
||||||
|
|
||||||
|
oldstate=0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def check(diffs, state, button, evcode):
|
||||||
|
# print(hex(state))
|
||||||
|
if diffs & button:
|
||||||
|
ui.write(e.EV_KEY, evcode, 0 if state & button else 1)
|
||||||
|
# print("button %4x is %1d, aka %d"%( button, 1 if state & button else 0, evcode) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
data=spi.xfer2([0x55]*2, spi.max_speed_hz, 1000, 8)
|
||||||
|
state=(data[0]<<8) + data[1]
|
||||||
|
|
||||||
|
diffs = state ^ oldstate
|
||||||
|
|
||||||
|
if diffs:
|
||||||
|
print(' '.join([format(d,'08b') for d in data]))
|
||||||
|
|
||||||
|
check(diffs, state, 0x8000, e.KEY_Z) # B
|
||||||
|
check(diffs, state, 0x4000, e.KEY_A) # Y
|
||||||
|
check(diffs, state, 0x2000, e.KEY_LEFTSHIFT) # Select
|
||||||
|
check(diffs, state, 0x1000, e.KEY_ENTER) # Start
|
||||||
|
check(diffs, state, 0x0800, e.KEY_UP) # Up
|
||||||
|
check(diffs, state, 0x0400, e.KEY_DOWN) # Down
|
||||||
|
check(diffs, state, 0x0200, e.KEY_LEFT) # Left
|
||||||
|
check(diffs, state, 0x0100, e.KEY_RIGHT) # Right
|
||||||
|
check(diffs, state, 0x0080, e.KEY_X) # A
|
||||||
|
check(diffs, state, 0x0040, e.KEY_S) # X
|
||||||
|
check(diffs, state, 0x0020, e.KEY_Q) # L
|
||||||
|
check(diffs, state, 0x0010, e.KEY_W) # R
|
||||||
|
ui.syn()
|
||||||
|
|
||||||
|
oldstate=state
|
||||||
|
|
||||||
|
ui.close()
|
Loading…
Reference in a new issue