init repo

This commit is contained in:
RomanRom2 committed 2025-01-28 19:17:01 +03:00
commit 90e6151613
3260 files changed
+3745062

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -0,0 +1,20 @@
:020000040000FA
:100000001124669A26E030E408C000000197E9F761
:100010008DB183278DB9215019F081E091E7F6CF9A
:1000200080911F138B3E69F48FEF80931F138DE92E
:1000300093E084BF909300108091021081FDFCCF6B
:1000400006C082E080930110E0E0F1E0099580ECC9
:1000500080930608A09123110A2E000CBB0BBC5FF5
:100060002CE530E00E9476007E5F8F4F9F4F2AE0A4
:1000700095958795779567952A95D1F760930808A8
:10008000709309088091E20581608093E205049AEB
:10009000E0E0F2E42DE933E040E41EC08091040882
:1000A00087FFFCCF80910008E11552E4F50711F4B9
:1000B000882391F0809302088193CF018F7799274D
:1000C000892B51F424BF309300108091021080FDE1
:1000D000FCCF8DB184278DB9CF0190548115904C00
:1000E000E8F288ED91E084BF909341000E947D008A
:1000F000B7FF0895821B930B0895A29FB001B39F91
:10010000C001A39F700D811D1124911DB29F700D20
:08011000811D1124911D0895C9
:00000001FF
@@ -0,0 +1,422 @@
_runtimePath_ "../../runtime"
_runtimeStart_ &h7FFF
_codeRomType_ ROMv2
const sysArg0 = &h24
const sysArg7 = &h2B
'payload protocol: <isLast>, <length>, <payload 0...62>
'filename packet: <type>, <length>, <name>, <0> : <type> = 1:file or 2:dir
const MAX_FILES = 100
const PAYLOAD_SIZE = 63
const PROTOCOL_SIZE = 1 + 1 + PAYLOAD_SIZE
const PACKET_SIZE = 1 + 1 + 12 + 1
const CmdSDList = 1
const CmdSDExec = 2
const CmdSDOpen = 3
const CmdSDClose = 4
const CmdSDBegin = 5
const CmdSDInit = 6
const EntryFile = 1
const EntryDir = 2
const EntryError = 3
def execAddr, commsAddr, commsSize, commsRetn, browserIdx, browserY, cursorY, cursOldY, isLast, length, runStrAddr, execRtn, waitRtn
runName$ = ""
execName$ = ""
pathName$ = ""
dim commsCmd%(PACKET_SIZE-1) = 0
dim buffer%(PROTOCOL_SIZE-1) = 0
dim browser%(MAX_FILES-1, PACKET_SIZE-1)
gosub findLoader
restart:
gosub initialise
gosub initSDComms
gosub beginSDCard
gosub openSDCard
repeat
gosub listSDCard
gosub loadDir
gosub fillBrowser
until &(isLast)
gosub closeSDCard
gosub printBrowser
f = 0
kk = 255
repeat
wait
gosub handleInput
if &(execRtn) then goto &restart
inc f
forever
end
findLoader:
romType = get("ROM_TYPE")
if romType &= &h20 'ROMv2
execAddr = &hE23E
elseif romType &= &h28 'ROMv3
execAddr = &hB4A8
elseif romType &= &h38 'ROMv4
execAddr = &hAD5A
elseif romType &>= &h40 'ROMv5 or higher
repeat
'create name string
execAddr = get("ROM_READ_DIR", execAddr)
if (execAddr)
poke @execName$, 6
for j=sysArg0 &to sysArg7
poke @execName$ + j - (sysArg0 - 1), peek(j)
next j
if execName$ = "Loader" then return
endif
until execAddr &= 0
print "Loader not found!"
end
endif
return
sendCommsCmd:
asm
LDWI SYS_SendSerial1_v3_80
STW giga_sysFn
LDW _commsAddr
STW giga_sysArg0
LDI 1
STW giga_sysArg2
LD _commsSize
LSLW
LSLW
LSLW
STW giga_sysArg3
SYS 80
STW _commsRetn
endasm
return
'simplified version of Loader, removes checksum, destination address, copying of buffer
'to destination address and visuals
loadDir:
asm
LDW _NextByteIn_32
STW giga_sysFn
loadD0: LDWI _buffer_array
STW giga_sysArg0 'buffer
LDI 207
ST giga_sysArg3 'scanline 207
SYS 32 'isLast, (0 or 1)
LDWI _buffer_array
PEEK
XORI 255
BEQ _loadD0 'loop while idle
LDI 219
ST giga_sysArg3 'scanline 219
SYS 32 'length, (6 bits : 0..62)
LDI 235
ST giga_sysArg3 'scanline 235
SYS 32 'payload 0
LDI 251
ST giga_sysArg3 'scanline 251
SYS 32 'payload 1
LDI 2
ST giga_sysArg3 'scanline 2
loadD1: SYS 32 'payload 2-61
LD giga_sysArg3
ADDI 4
ST giga_sysArg3
XORI 242 'scanline end is 238
BNE _loadD1
LDI 185
ST giga_sysArg3 'scanline 185
SYS 32 'payload 62
endasm
isLast = peek(@buffer)
length = peek(@buffer + 1) AND 63
return
fillBrowser:
bIdx = 2
if length &= 0 then return
if browserIdx &&= MAX_FILES then return
repeat
cIdx = 0
repeat
char = peek(@buffer + bIdx)
poke addr(browser(browserIdx, cIdx)), char
inc bIdx
inc cIdx
until char &&= 0
inc browserIdx
if browserIdx &&= MAX_FILES then return
until (bIdx - 2) &= length
return
printBrowser:
startY = max(min(browserY, browserIdx-15), 0)
endY = min(browserY+14, browserIdx-1)
for i=startY to endY
strAddr = addr(browser(i, 0)) + 1
strLen = peek(strAddr)
isFile = peek(strAddr - 1)
if (i-browserY) &= cursorY
if isFile &&= 1
set FGBG_COLOUR, &h203F
else
set FGBG_COLOUR, &h202A
endif
runStrAddr = strAddr
else
if isFile &= 1
set FGBG_COLOUR, &h3F20
else
set FGBG_COLOUR, &h2A20
endif
endif
at 2, (i-browserY) LSL 3
print string$(strAddr);spc$(12 - strLen);
next i
return
updateBrowser:
startY = max(min(browserY, browserIdx-15), 0)
prevY = startY + cursOldY
prevAddr = addr(browser(prevY, 0)) + 1
prevLen = peek(prevAddr)
isFile = peek(prevAddr - 1)
if isFile &&= 1
set FGBG_COLOUR, &h3F20
else
set FGBG_COLOUR, &h2A20
endif
at 2, (prevY - startY) LSL 3
print string$(prevAddr);spc$(12 - prevLen);
cursOldY = cursorY
currY = startY + cursorY
currAddr = addr(browser(currY, 0)) + 1
currLen = peek(currAddr)
isFile = peek(currAddr - 1)
if isFile &= 1
set FGBG_COLOUR, &h203F
else
set FGBG_COLOUR, &h202A
endif
at 2, (currY - startY) LSL 3
print string$(currAddr);spc$(12 - currLen);
runStrAddr = currAddr
return
getRomType:
romType = get("ROM_TYPE")
NextByteIn_32 = &h0b18 'Default to SYS_ReceiveSerial1
if romType &&= &h20 then NextByteIn_32 = &h0BB1 'ROMv2
if romType &&= &h28 then NextByteIn_32 = &h0BDF 'ROMv3
if romType &&= &h38 then NextByteIn_32 = &h8A31 'ROMv4
if romType &&= &h40 then NextByteIn_32 = &h5907 'ROMv5a
if romType &&= &hf0 then NextByteIn_32 = &h1300 'SDCARD
if romType &&= &hf8 'DEVROM
if execAddr.hi &&= &h5A then NextByteIn_32 = &h5907 '(DEVROM v5a+, initial)
if execAddr.hi &&= &h5C then NextByteIn_32 = &h5B07 '(DEVROM v5a+, last before SYS_ReceiveSerial1)
endif
return
openSDCard:
poke @commsCmd, CmdSDOpen
len = peek(@pathName$)
commsSize = 1 + len + 1
if len &> 0
for i=1 &to len + 1
poke @commsCmd + i, peek(@pathName$ + i)
next i
else
poke @commsCmd + 1, 0
endif
gosub sendCommsCmd
'SDCard open can take a variable amount of time
gosub waitSDCard
pathName$ = ""
return
execApp:
gosub initSDComms
poke @commsCmd, CmdSDExec
runName$ = string$(runStrAddr)
len = peek(@runName$)
for i=1 &to len + 1
poke @commsCmd + i, peek(@runName$ + i)
next i
set FGBG_COLOUR, &h0F20 : cls INIT : cls
commsSize = 1 + len + 1
gosub sendCommsCmd
exec execAddr
return
'repeat delay and auto repeat
handleInput:
k = get("SERIAL_RAW")
if k &&<> kk
f = 0
kk = k
gosub k
endif
if f &> 20
if ((f LSR 1) AND 1)
gosub k
endif
endif
return
'button A
127: gosub execOrList
return
'enter
10: gosub execOrList
return
'right
254: browserY = browserY + 15
browserY = max(min(browserY, browserIdx-15), 0)
gosub printBrowser
return
'left
253: browserY = browserY - 15
browserY = max(browserY, 0)
gosub printBrowser
return
'down
251: inc cursorY
if cursorY &&> min(browserIdx - 1, 14) then cursorY = 0
gosub updateBrowser
return
'up
247: dec cursorY
if cursorY &< 0 then cursorY = min(browserIdx - 1, 14)
gosub updateBrowser
return
'execute files, list directories
execOrList:
entry = peek(runStrAddr - 1)
if entry &&= EntryDir
execRtn = 1
pathName$ = string$(runStrAddr)
endif
if entry &&= EntryFile
execRtn = 0
gosub execApp
endif
if entry &= EntryError
execRtn = 2
pathName$ = ""
endif
return
waitSDCard:
asm
LDW _NextByteIn_32
STW giga_sysFn
waitSD: LDI _waitRtn
STW giga_sysArg0 'waitRtn address
LDI 207
ST giga_sysArg3 'scanline 207
SYS 32 'waitRtn result, (0:ready)
LD _waitRtn
BNE _waitSD 'loop while busy
endasm
wait 2
return
'this command is used to break BabelFish out of it's game controller loop and start checking comms
initSDComms:
commsSize = 1
poke @commsCmd, CmdSDInit
gosub sendCommsCmd
wait
return
listSDCard:
commsSize = 1
poke @commsCmd, CmdSDList
gosub sendCommsCmd
return
closeSDCard:
commsSize = 1
poke @commsCmd, CmdSDClose
gosub sendCommsCmd
return
beginSDCard:
commsSize = 1
poke @commsCmd, CmdSDBegin
gosub sendCommsCmd
'SDCard begin can take a variable amount of time
gosub waitSDCard
return
initialise:
init vars @commsSize
gosub getRomType
commsAddr = @commsCmd
mode 2 : set FGBG_COLOUR, &h3F20 : cls INIT : cls
return
@@ -0,0 +1 @@
0x02, 0x00, 0xfa, 0x59, 0x20, 0x2b, 0x82, 0x11, 0xcf, 0x62, 0xcf, 0x18, 0x11, 0x20, 0x0f, 0x2b, 0xa2, 0x59, 0x01, 0x2b, 0xaa, 0x59, 0x00, 0x2b, 0xa6, 0x11, 0xbd, 0x61, 0xcf, 0x18, 0x11, 0xa9, 0x61, 0x2b, 0xcc, 0x11, 0xfe, 0x7c, 0x2b, 0x84, 0x11, 0xa0, 0x7d, 0x2b, 0x86, 0x11, 0xd5, 0x61, 0xcf, 0x18, 0x11, 0xfe, 0x7c, 0x2b, 0x84, 0x11, 0xa0, 0x7b, 0x2b, 0x86, 0x11, 0xd5, 0x61, 0xcf, 0x18, 0x11, 0xfe, 0x7c, 0x2b, 0x84, 0x11, 0xa0, 0x7a, 0x2b, 0x86, 0x11, 0xd5, 0x61, 0xcf, 0x18, 0x11, 0xa6, 0x02, 0xcf, 0x18, 0x11, 0xd5, 0x11, 0xcf, 0x18, 0x11, 0xcd, 0x10, 0xcf, 0x18, 0x11, 0xbb, 0x11, 0xcf, 0x18, 0x11, 0xcd, 0x09, 0xcf, 0x18, 0x11, 0xe7, 0x10, 0xcf, 0x18, 0x11, 0x96, 0x03, 0xcf, 0x18, 0x11, 0xe8, 0x03, 0xcf, 0x18, 0x21, 0x40, 0x35, 0x3f, 0x64, 0x11, 0xa6, 0x11, 0xcf, 0x18, 0x11, 0x58, 0x04, 0xcf, 0x18, 0x59, 0x00, 0x2b, 0x4a, 0x59, 0xff, 0x2b, 0x4c, 0x11, 0xc9, 0x61, 0xcf, 0x18, 0x11, 0xb7, 0x0c, 0xcf, 0x18, 0x21, 0x46, 0x35, 0x3f, 0x9b, 0x90, 0x50, 0x93, 0x4a, 0x11, 0x8c, 0x02, 0xcf, 0x18, 0xb4, 0x80, 0x75, 0x1a, 0x21, 0x82, 0xfc, 0x2b, 0x4e, 0x21, 0x4e, 0x8c, 0x20, 0x35, 0x3f, 0xb7, 0x11, 0xc3, 0x02, 0xcf, 0x18, 0x11, 0x3e, 0xe2, 0x2b, 0x30, 0x11, 0x79, 0x03, 0xcf, 0x18, 0x21, 0x4e, 0x8c, 0x28, 0x35, 0x3f, 0xcd, 0x11, 0xd9, 0x02, 0xcf, 0x18, 0x11, 0xa8, 0xb4, 0x2b, 0x30, 0x11, 0x79, 0x03, 0xcf, 0x18, 0x21, 0x4e, 0x8c, 0x38, 0x35, 0x3f, 0xe3, 0x11, 0xef, 0x02, 0xcf, 0x18, 0x11, 0x5a, 0xad, 0x2b, 0x30, 0x11, 0x79, 0x03, 0xcf, 0x18, 0x21, 0x4e, 0xe6, 0x40, 0xec, 0xfe, 0x11, 0x00, 0x03, 0xcf, 0x18, 0x03, 0x00, 0xf6, 0xee, 0xfe, 0x35, 0x53, 0x08, 0x11, 0x79, 0x03, 0xcf, 0x18, 0x21, 0x30, 0x2b, 0x82, 0x11, 0xa0, 0x61, 0xcf, 0x18, 0x2b, 0x30, 0x21, 0x30, 0x35, 0x72, 0x1d, 0x11, 0x5e, 0x03, 0xcf, 0x18, 0x11, 0xa0, 0x7b, 0x2b, 0x82, 0x59, 0x06, 0xf0, 0x82, 0x59, 0x24, 0x2b, 0x50, 0x11, 0xa0, 0x7b, 0x99, 0x50, 0xe6, 0x23, 0x2b, 0xe8, 0x21, 0x50, 0xad, 0xf0, 0xe8, 0x93, 0x50, 0x1a, 0x50, 0xe6, 0x2b, 0x35, 0x56, 0x2a, 0x11, 0xa0, 0x7b, 0x2b, 0x84, 0x11, 0xa6, 0x7c, 0x2b, 0x94, 0x11, 0xc5, 0x66, 0xcf, 0x18, 0x82, 0x01, 0x35, 0x72, 0x5a, 0x11, 0x5e, 0x03, 0xcf, 0x18, 0x63, 0xff, 0x21, 0x30, 0x35, 0x3f, 0x66, 0x11, 0x0a, 0x03, 0xcf, 0x18, 0x11, 0xb1, 0x69, 0x2b, 0x82, 0x11, 0xe6, 0x62, 0xcf, 0x18, 0x11, 0xa2, 0x67, 0xcf, 0x18, 0xb4, 0x80, 0x63, 0xff, 0x75, 0x11, 0x06, 0x0b, 0x2b, 0x22, 0x21, 0x32, 0x2b, 0x24, 0x59, 0x01, 0x2b, 0x26, 0x1a, 0x34, 0xe9, 0xe9, 0xe9, 0x2b, 0x27, 0xb4, 0xe6, 0x2b, 0x36, 0x63, 0xff, 0x75, 0x21, 0x70, 0x2b, 0x22, 0x11, 0xae, 0x7c, 0x2b, 0x24, 0x59, 0xcf, 0x5e, 0x27, 0xb4, 0xfe, 0x11, 0xae, 0x7c, 0xad, 0x8c, 0xff, 0x35, 0x3f, 0x99, 0x59, 0xdb, 0x5e, 0x27, 0xb4, 0xfe, 0x59, 0xeb, 0x5e, 0x27, 0xb4, 0xfe, 0x59, 0xfb, 0x5e, 0x27, 0xb4, 0xfe, 0x59, 0x02, 0x5e, 0x27, 0xb4, 0xfe, 0x1a, 0x27, 0xe3, 0x04, 0x5e, 0x27, 0x8c, 0xf2, 0x35, 0x72, 0xc3, 0x59, 0xb9, 0x5e, 0x27, 0xb4, 0xfe, 0x11, 0xae, 0x7c, 0xad, 0x2b, 0x40, 0x11, 0xaf, 0x7c, 0xad, 0x82, 0x3f, 0x2b, 0x42, 0x63, 0xff, 0x75, 0x59, 0x02, 0x2b, 0x52, 0x21, 0x42, 0xec, 0xfe, 0x11, 0x00, 0x04, 0xcf, 0x18, 0x04, 0x00, 0xfa, 0xee, 0xfe, 0x35, 0x3f, 0x08, 0x11, 0x0c, 0x04, 0xcf, 0x18, 0x63, 0xff, 0x21, 0x38, 0x8c, 0x64, 0x35, 0x72, 0x13, 0x63, 0xff, 0x59, 0x00, 0x2b, 0x54, 0x11, 0xae, 0x7c, 0x99, 0x52, 0xad, 0x2b, 0x56, 0x21, 0x38, 0x2b, 0x96, 0x21, 0x54, 0x2b, 0x98, 0x11, 0x38, 0x06, 0xcf, 0xcc, 0x2b, 0xea, 0x21, 0x56, 0xf0, 0xea, 0x93, 0x52, 0x93, 0x54, 0x21, 0x56, 0x35, 0x72, 0x17, 0x93, 0x38, 0x21, 0x38, 0x8c, 0x64, 0x35, 0x72, 0x46, 0x63, 0xff, 0x21, 0x52, 0xe6, 0x02, 0xfc, 0x42, 0x35, 0x3f, 0x54, 0x11, 0x15, 0x04, 0xcf, 0x18, 0x63, 0xff, 0x75, 0x21, 0x38, 0xe6, 0x0f, 0x2b, 0xe8, 0x21, 0x3a, 0x2b, 0x82, 0x21, 0xe8, 0x2b, 0x84, 0x11, 0xa1, 0x64, 0xcf, 0x18, 0x2b, 0x82, 0x59, 0x00, 0x2b, 0x84, 0x11, 0xe2, 0x61, 0xcf, 0x18, 0x2b, 0x58, 0x21, 0x3a, 0xe3, 0x0e, 0x2b, 0xe8, 0x21, 0x38, 0xe6, 0x01, 0x2b, 0xea, 0x21, 0xe8, 0x2b, 0x82, 0x21, 0xea, 0x2b, 0x84, 0x11, 0xa1, 0x64, 0xcf, 0x18, 0x2b, 0x5a, 0x21, 0x58, 0x2b, 0x5c, 0x21, 0x5a, 0x2b, 0xb0, 0x59, 0x01, 0x2b, 0xb2, 0x21, 0x5c, 0x2b, 0x96, 0x59, 0x00, 0x2b, 0x98, 0x11, 0x38, 0x06, 0xcf, 0xcc, 0xe3, 0x01, 0x2b, 0x5e, 0x21, 0x5e, 0xad, 0x2b, 0x60, 0x21, 0x5e, 0xe6, 0x01, 0xad, 0x2b, 0x62, 0x21, 0x5c, 0xb8, 0x3a, 0xfc, 0x3c, 0x35, 0x3f, 0xc9, 0x11, 0xe7, 0x04, 0xcf, 0x18, 0x21, 0x62, 0x8c, 0x01, 0x35, 0x72, 0xd7, 0x11, 0x3f, 0x20, 0x2b, 0xa2, 0x90, 0xdc, 0x11, 0x2a, 0x20, 0x2b, 0xa2, 0x21, 0x5e, 0x2b, 0x44, 0x11, 0x11, 0x05, 0xcf, 0x18, 0x21, 0x62, 0x8c, 0x01, 0x35, 0x3f, 0xf1, 0x11, 0x0c, 0x05, 0xcf, 0x18, 0xec, 0xfe, 0x11, 0x00, 0x05, 0xcf, 0x18, 0x05, 0x00, 0xf8, 0xee, 0xfe, 0x11, 0x20, 0x3f, 0x2b, 0xa2, 0x11, 0x11, 0x05, 0xcf, 0x18, 0x11, 0x20, 0x2a, 0x2b, 0xa2, 0x59, 0x02, 0x5e, 0xa4, 0x21, 0x5c, 0xb8, 0x3a, 0xe9, 0xe9, 0xe9, 0x5e, 0xa5, 0x11, 0xa0, 0x66, 0xcf, 0x18, 0x21, 0x5e, 0x2b, 0x82, 0x11, 0xe6, 0x62, 0xcf, 0x18, 0x59, 0x0c, 0xb8, 0x60, 0x5e, 0x84, 0x11, 0xae, 0x64, 0xcf, 0x18, 0x21, 0x5c, 0x99, 0xb2, 0x2b, 0x5c, 0xb8, 0xb0, 0x35, 0x4d, 0x45, 0x11, 0xa0, 0x04, 0xcf, 0x18, 0x63, 0xff, 0x75, 0x21, 0Line truncated
@@ -0,0 +1,710 @@
/*
* PS/2 keyboard handling for Babelfish talking to Gigatron
* Complete rewrite of PS2Keyboard for game controller mapping
* and keymap compression to reduce footprint
*
* References:
*
* https://www.avrfreaks.net/sites/default/files/PS2%20Keyboard.pdf
* The PS/2 Mouse/Keyboard Protocol
*
* http://www.quadibloc.com/comp/scan.htm
* Scan Codes Demytified
*
* https://retired.beyondlogic.org/keyboard/keybrd.htm
* Interfacing the AT keyboard
*
* https://web.archive.org/web/20180101224739/http://www.computer-engineering.org/ps2keyboard/scancodes2.html
* Keyboard Scan Codes: Set 2
*
* https://github.com/PaulStoffregen/PS2Keyboard
* PS/2 Keyboard Library for Arduino
*
* https://github.com/techpaul/PS2KeyAdvanced
* Arduino PS2 Keyboard FULL keyboard protocol support and full keys to integer coding
*
* https://github.com/techpaul/PS2KeyMap/
* Arduino PS2 keyboard International Keyboard mapping from PS2KeyAdvanced and return as UTF-8
*
* https://www.terena.org/activities/multiling/ml-mua/test/kbd-all.html
* This page provides information about layouts of different national
* keyboard their mapping to used Character Sets and UCS
*
* https://github.com/ilpianista/itlinux-win-keyboard
* An Italian keyboard layout for Windows, customized with shortcuts from Linux systems
*/
// TODO
// [Basic features]
// XXX Test keymap for DE
// XXX Test keymap for FR
// XXX Test keymap for GB
// XXX Test keymap for ES
// XXX Issue: Sometimes keyboard starts injecting break codes
// when pressing [buttonA] + arrow keys, making it impossible
// to set the time in Mandelbrot??
// XXX (Left)Alt for buttonB?
//
// [Advanced features, for consideration]
// XXX Caps-Lock and setting LEDs
// XXX Do something with NumLock?
// XXX Key combination to reset keyboard?
// XXX Allow Gigatron to control the keyboard lights
// XXX Let keyboard lights run in a pattern (bad idea :-)
#define PS2_ENTER '\n'
#define PS2_TAB 9
#define PS2_BACKSPACE 127
#define PS2_ESC 27
#define PS2_F1 (0xc0 + 1)
#define PS2_F2 (0xc0 + 2)
#define PS2_F3 (0xc0 + 3)
#define PS2_F4 (0xc0 + 4)
#define PS2_F5 (0xc0 + 5)
#define PS2_F6 (0xc0 + 6)
#define PS2_F7 (0xc0 + 7)
#define PS2_F8 (0xc0 + 8)
#define PS2_F9 (0xc0 + 9)
#define PS2_F10 (0xc0 + 10)
#define PS2_F11 (0xc0 + 11)
#define PS2_F12 (0xc0 + 12)
#define CTRLALTDEL (255 ^ buttonStart)
/*
* Keyboard layout mapping
*/
const char keymapNames[][3] = {
"US", "GB", "DE", "FR", "IT", "ES",
};
const byte nrKeymaps = arrayLen(keymapNames);
int getKeymapIndex(void)
{
byte index = EEPROM.read(offsetof(struct EEPROMlayout, keymapIndex));
return (index >= nrKeymaps) ? 0 : index; // Also handle invalid values
}
const char *getKeymapName()
{
return getKeymapName(getKeymapIndex());
}
const char *getKeymapName(byte index)
{
return (index > arrayLen(keymapNames)) ? 0 : keymapNames[index];
}
enum {
US = 1 << 0,
GB = 1 << 1,
DE = 1 << 2,
FR = 1 << 3,
IT = 1 << 4,
ES = 1 << 5,
NOMOD = 0 << nrKeymaps,
SHIFT = 1 << nrKeymaps,
ALTGR = 2 << nrKeymaps,
EVERY = 3 << nrKeymaps,
};
typedef struct {
byte flags; // Change from byte to word if we add more keymaps
byte code;
byte ascii; // XXX Remove this if we add flags. Value can be inferred by lookup()
} keyTuple_t;
// Keymaps courtesy of
// Arduino PS2Keyboard library (US,DE,FR)
// https://playground.arduino.cc/Main/PS2Keyboard
// and
// Teensy PS2Keyboard library (GB,IT,ES)
// http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
//
// 229 * 3 bytes = 687 bytes for holding 6 keyboard layouts
// To save space this table excludes codes that aren't in US-ASCII
// because these aren't in the Gigatron font either (yet).
// So accented letters and such are all absent. This is needed
// to make it all fit in the ATtiny85 configuration.
const PROGMEM keyTuple_t keymaps[] = {
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0d, 9 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x5a, 10 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x76, 27 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x29, 32 },
{ +US+GB+DE +IT+ES +SHIFT, 0x16, 33 }, // '!'
{ +FR +NOMOD, 0x4a, 33 },
{ +GB+DE +IT+ES +SHIFT, 0x1e, 34 }, // '"'
{ +FR +NOMOD, 0x26, 34 },
{ +US +SHIFT, 0x52, 34 },
{ +US +SHIFT, 0x26, 35 }, // '#'
{ +FR +ES +ALTGR, 0x26, 35 },
{ +IT +ALTGR, 0x52, 35 },
{ +GB+DE +NOMOD, 0x5d, 35 },
{ +DE+FR +ALTGR, 0x5d, 35 },
{ +US+GB+DE +IT+ES +SHIFT, 0x25, 36 }, // '$'
{ +FR +NOMOD, 0x5b, 36 },
{ +US+GB+DE +IT+ES +SHIFT, 0x2e, 37 }, // '%'
{ +FR +SHIFT, 0x52, 37 },
{ +FR +NOMOD, 0x16, 38 }, // '&'
{ +DE +IT+ES +SHIFT, 0x36, 38 },
{ +US+GB +SHIFT, 0x3d, 38 },
{ +FR +NOMOD, 0x25, 39 }, // '''
{ +IT+ES +NOMOD, 0x4e, 39 },
{ +US+GB +NOMOD, 0x52, 39 },
{ +DE +NOMOD, 0x55, 39 },
{ +DE +SHIFT, 0x5d, 39 },
{ +FR +NOMOD, 0x2e, 40 }, // '('
{ +DE +IT+ES +SHIFT, 0x3e, 40 },
{ +US+GB +SHIFT, 0x46, 40 },
{ +US+GB +SHIFT, 0x45, 41 }, // ')'
{ +DE +IT+ES +SHIFT, 0x46, 41 },
{ +FR +NOMOD, 0x4e, 41 },
{ +US+GB +SHIFT, 0x3e, 42 }, // '*'
{ +DE +IT+ES +SHIFT, 0x5b, 42 },
{ +FR +NOMOD, 0x5d, 42 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7c, 42 },
{ +US+GB +FR +SHIFT, 0x55, 43 }, // '+'
{ +DE +IT+ES +NOMOD, 0x5b, 43 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x79, 43 },
{ +FR +NOMOD, 0x3a, 44 }, // ','
{ +US+GB+DE +IT+ES +NOMOD, 0x41, 44 },
{ +FR +NOMOD, 0x36, 45 }, // '-'
{ +DE +IT+ES +NOMOD, 0x4a, 45 },
{ +US+GB +NOMOD, 0x4e, 45 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7b, 45 },
{ +FR +SHIFT, 0x41, 46 }, // '.'
{ +US+GB+DE +IT+ES +NOMOD, 0x49, 46 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x71, 46 },
{ +DE +IT+ES +SHIFT, 0x3d, 47 }, // '/'
{ +FR +SHIFT, 0x49, 47 },
{ +US+GB +NOMOD, 0x4a, 47 },
{ +US+GB+DE +IT+ES +NOMOD, 0x45, 48 }, // '0'
{ +FR +SHIFT, 0x45, 48 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x70, 48 },
{ +US+GB+DE +IT+ES +NOMOD, 0x16, 49 }, // '1'
{ +FR +SHIFT, 0x16, 49 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x69, 49 },
{ +US+GB+DE +IT+ES +NOMOD, 0x1e, 50 }, // '2'
{ +FR +SHIFT, 0x1e, 50 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x72, 50 },
{ +US+GB+DE +IT+ES +NOMOD, 0x26, 51 }, // '3'
{ +FR +SHIFT, 0x26, 51 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7a, 51 },
{ +US+GB+DE +IT+ES +NOMOD, 0x25, 52 }, // '4'
{ +FR +SHIFT, 0x25, 52 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x6b, 52 },
{ +US+GB+DE +IT+ES +NOMOD, 0x2e, 53 }, // '5'
{ +FR +SHIFT, 0x2e, 53 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x73, 53 },
{ +US+GB+DE +IT+ES +NOMOD, 0x36, 54 }, // '6'
{ +FR +SHIFT, 0x36, 54 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x74, 54 },
{ +US+GB+DE +IT+ES +NOMOD, 0x3d, 55 }, // '7'
{ +FR +SHIFT, 0x3d, 55 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x6c, 55 },
{ +US+GB+DE +IT+ES +NOMOD, 0x3e, 56 }, // '8'
{ +FR +SHIFT, 0x3e, 56 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x75, 56 },
{ +US+GB+DE +IT+ES +NOMOD, 0x46, 57 }, // '9'
{ +FR +SHIFT, 0x46, 57 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7d, 57 },
{ +FR +NOMOD, 0x49, 58 }, // ':'
{ +DE +IT+ES +SHIFT, 0x49, 58 },
{ +US+GB +SHIFT, 0x4c, 58 },
{ +FR +NOMOD, 0x41, 59 }, // ';'
{ +DE +IT+ES +SHIFT, 0x41, 59 },
{ +US+GB +NOMOD, 0x4c, 59 },
{ +US+GB +SHIFT, 0x41, 60 }, // '<'
{ +DE+FR+IT+ES +NOMOD, 0x61, 60 },
{ +DE +IT+ES +SHIFT, 0x45, 61 }, // '='
{ +US+GB +FR +NOMOD, 0x55, 61 },
{ +US+GB +SHIFT, 0x49, 62 }, // '>'
{ +DE+FR+IT+ES +SHIFT, 0x61, 62 },
{ +FR +SHIFT, 0x3a, 63 }, // '?'
{ +US+GB +SHIFT, 0x4a, 63 },
{ +DE +IT+ES +SHIFT, 0x4e, 63 },
{ +DE+FR +ALTGR, 0x15, 64 }, // '@'
{ +US +SHIFT, 0x1e, 64 },
{ +ES +ALTGR, 0x1e, 64 },
{ +FR +ALTGR, 0x45, 64 },
{ +IT +ALTGR, 0x4c, 64 },
{ +GB +SHIFT, 0x52, 64 },
{ +FR +SHIFT, 0x15, 65 }, // 'A'
{ +US+GB+DE +IT+ES +SHIFT, 0x1c, 65 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x32, 66 }, // 'B'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x21, 67 }, // 'C'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x23, 68 }, // 'D'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x24, 69 }, // 'E'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2b, 70 }, // 'F'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x34, 71 }, // 'G'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x33, 72 }, // 'H'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x43, 73 }, // 'I'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x3b, 74 }, // 'J'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x42, 75 }, // 'K'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x4b, 76 }, // 'L'
{ +US+GB+DE +IT+ES +SHIFT, 0x3a, 77 }, // 'M'
{ +FR +SHIFT, 0x4c, 77 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x31, 78 }, // 'N'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x44, 79 }, // 'O'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x4d, 80 }, // 'P'
{ +US+GB+DE +IT+ES +SHIFT, 0x15, 81 }, // 'Q'
{ +FR +SHIFT, 0x1c, 81 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2d, 82 }, // 'R'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x1b, 83 }, // 'S'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2c, 84 }, // 'T'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x3c, 85 }, // 'U'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2a, 86 }, // 'V'
{ +FR +SHIFT, 0x1a, 87 }, // 'W'
{ +US+GB+DE +IT+ES +SHIFT, 0x1d, 87 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x22, 88 }, // 'X'
{ +DE +SHIFT, 0x1a, 89 }, // 'Y'
{ +US+GB +FR+IT+ES +SHIFT, 0x35, 89 },
{ +US+GB +IT+ES +SHIFT, 0x1a, 90 }, // 'Z'
{ +FR +SHIFT, 0x1d, 90 },
{ +DE +SHIFT, 0x35, 90 },
{ +FR +ALTGR, 0x2e, 91 }, // '['
{ +DE +IT +ALTGR, 0x3e, 91 },
{ +US+GB +NOMOD, 0x54, 91 },
{ +IT+ES +ALTGR, 0x54, 91 },
{ +IT +NOMOD, 0x0e, 92 }, // '\'
{ +ES +ALTGR, 0x0e, 92 },
{ +FR +ALTGR, 0x3e, 92 },
{ +DE +ALTGR, 0x4e, 92 },
{ +US +NOMOD, 0x5d, 92 },
{ +GB +NOMOD, 0x61, 92 },
{ +DE +IT +ALTGR, 0x46, 93 }, // ']'
{ +FR +ALTGR, 0x4e, 93 },
{ +US+GB +NOMOD, 0x5b, 93 },
{ +IT+ES +ALTGR, 0x5b, 93 },
{ +DE +NOMOD, 0x0e, 94 }, // '^'
{ +US+GB +SHIFT, 0x36, 94 },
{ +FR +ALTGR, 0x46, 94 },
{ +FR +NOMOD, 0x54, 94 },
{ +ES +SHIFT, 0x54, 94 },
{ +IT +SHIFT, 0x55, 94 },
{ +FR +NOMOD, 0x3e, 95 }, // '_'
{ +DE +IT+ES +SHIFT, 0x4a, 95 },
{ +US+GB +SHIFT, 0x4e, 95 },
{ +US+GB +NOMOD, 0x0e, 96 }, // '`'
{ +FR +ALTGR, 0x3d, 96 },
{ +IT +ALTGR, 0x4e, 96 },
{ +ES +NOMOD, 0x54, 96 },
{ +DE +SHIFT, 0x55, 96 },
{ +FR +NOMOD, 0x15, 97 }, // 'a'
{ +US+GB+DE +IT+ES +NOMOD, 0x1c, 97 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x32, 98 }, // 'b'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x21, 99 }, // 'c'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x23, 100 }, // 'd'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x24, 101 }, // 'e'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2b, 102 }, // 'f'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x34, 103 }, // 'g'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x33, 104 }, // 'h'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x43, 105 }, // 'i'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x3b, 106 }, // 'j'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x42, 107 }, // 'k'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x4b, 108 }, // 'l'
{ +US+GB+DE +IT+ES +NOMOD, 0x3a, 109 }, // 'm'
{ +FR +NOMOD, 0x4c, 109 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x31, 110 }, // 'n'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x44, 111 }, // 'o'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x4d, 112 }, // 'p'
{ +US+GB+DE +IT+ES +NOMOD, 0x15, 113 }, // 'q'
{ +FR +NOMOD, 0x1c, 113 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2d, 114 }, // 'r'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x1b, 115 }, // 's'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2c, 116 }, // 't'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x3c, 117 }, // 'u'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2a, 118 }, // 'v'
{ +FR +NOMOD, 0x1a, 119 }, // 'w'
{ +US+GB+DE +IT+ES +NOMOD, 0x1d, 119 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x22, 120 }, // 'x'
{ +DE +NOMOD, 0x1a, 121 }, // 'y'
{ +US+GB +FR+IT+ES +NOMOD, 0x35, 121 },
{ +US+GB +IT+ES +NOMOD, 0x1a, 122 }, // 'z'
{ +FR +NOMOD, 0x1d, 122 },
{ +DE +NOMOD, 0x35, 122 },
{ +FR +ALTGR, 0x25, 123 }, // '{'
{ +DE +IT +ALTGR, 0x3d, 123 },
{ +ES +ALTGR, 0x52, 123 },
{ +US+GB +SHIFT, 0x54, 123 },
{ +IT +SHIFT, 0x0e, 124 }, // '|'
{ +ES +ALTGR, 0x16, 124 },
{ +FR +ALTGR, 0x36, 124 },
{ +US +SHIFT, 0x5d, 124 },
{ +GB +SHIFT, 0x61, 124 },
{ +DE+FR +ES +ALTGR, 0x61, 124 },
{ +DE +IT +ALTGR, 0x45, 125 }, // '}'
{ +FR +ALTGR, 0x56, 125 },
{ +US+GB +SHIFT, 0x5b, 125 },
{ +ES +ALTGR, 0x5d, 125 },
{ +US +SHIFT, 0x0e, 126 }, // '~'
{ +FR +ALTGR, 0x1e, 126 },
{ +ES +ALTGR, 0x25, 126 },
{ +IT +ALTGR, 0x55, 126 },
{ +DE +ALTGR, 0x5b, 126 },
{ +GB +SHIFT, 0x5d, 126 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x66, 127 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x05, 193 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x06, 194 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x04, 195 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0c, 196 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x03, 197 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0b, 198 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x83, 199 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0a, 200 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x01, 201 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x09, 202 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x78, 203 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x07, 204 },
};
/*
* Find ASCII code corresponding to key code and active modifiers
* for the current keymap
*/
static inline byte lookup(byte mods, word code)
{
byte keymapFlag = 1 << getKeymapIndex();
for (int i=0; i<arrayLen(keymaps); i++) {
const keyTuple_t *t = &keymaps[i];
byte f = pgm_read_byte(&t->flags);
if (~f & keymapFlag)
continue; // Different keymap
if ((f & EVERY) != EVERY && (f & EVERY) != mods)
continue; // Different modifiers
byte c = pgm_read_byte(&t->code);
if (c != code)
continue; // Different scan code
return pgm_read_byte(&t->ascii);
}
return 0;
}
/*
* Output state
*/
enum {
// bit 0:7 Equivalent game controller buttons (positive)
// buttonRight .. buttonA
// bit 8:13 State of modifier keys
leftShiftFlag = 1<<8,
rightShiftFlag = 1<<9,
leftCtrlFlag = 1<<10,
rightCtrlFlag = 1<<11,
altFlag = 1<<12,
altGrFlag = 1<<13,
shiftFlags = leftShiftFlag | rightShiftFlag,
ctrlFlags = leftCtrlFlag | rightCtrlFlag,
altFlags = altFlag | altGrFlag,
// bit 14:15 Protocol state
breakFlag = 1<<14, // Release of physical key
extendedFlag = 1<<15, // Extended PS/2 keyboard codes
};
#define nextPs2()\
flags &= ~(breakFlag | extendedFlag)
static word flags = 0; // Modifier keys and button state
static byte ascii = 0; // Current ASCII key press
static word lastChange, hold; // Babelfish controls the hold time for keys
// XXX Put variables in a class for better scoping
/*
* PS/2 sequences
*/
static int bitBuffer;
static byte _n;
static word lastClock;
/*
* Input buffering
*/
static volatile byte ps2Buffer[15+1];
static volatile byte head = 0, tail = 0;
#if defined(ARDUINO_attiny)
// attachInterrupt() doesn't work on the ATtiny85
static byte keyboardClockBit;
ISR(PCINT0_vect)
{
if (~PINB & keyboardClockBit) // FALLING edge of PS/2 clock
ps2interrupt();
}
#endif
void keyboard_setup()
{
// Initialize the pins
pinMode(keyboardDataPin, INPUT_PULLUP);
allowPs2();
#if defined(ARDUINO_attiny)
keyboardClockBit = digitalPinToBitMask(keyboardClockPin);
GIMSK |= 1<<PCIE; // Pin change interrupt enable
PCMSK |= keyboardClockBit; // ... for keyboard clock
#else
attachInterrupt(
digitalPinToInterrupt(keyboardClockPin),
ps2interrupt, FALLING);
#endif
}
// Handle one bit from PS/2 keyboard for the next byte
// bit 0 : start bit (0)
// bit 1..8 : data bits 0..7 (lowest bit first)
// bit 9 : parity (odd)
// bit 10 : stop bit (1)
void ps2interrupt()
{
byte nextBit = digitalRead(keyboardDataPin);
word now = (word) millis(); // millis() stops when interrupts are disabled,
// but that is ok, because we will reset n
// after every vPulse (through allowPs2())
// At least 10 kHz required for PS/2, self-reset after time out
if (now - lastClock > 5 || _n >= 11) {
bitBuffer = 1; // Clear bits and setup for odd parity
_n = 0;
}
lastClock = now;
bitBuffer |= nextBit << _n;
bitBuffer ^= nextBit; // Track parity in bit 0
if (_n == 10) {
ps2Buffer[head] = (bitBuffer >> 1) & 255;
byte nextHead = (head + 1) % sizeof ps2Buffer;
if (nextHead != tail // Buffer not (almost) full
&& (bitBuffer & 1)) // Parity check, with bonus check of start/stop bits
head = nextHead;
}
_n++;
}
// Ready to receive
void allowPs2()
{
pinMode(keyboardClockPin, INPUT_PULLUP);
_n = 11; // Consider previous bits lost
}
// Pull clock line LOW to signal that we're not ready to receive
void forbidPs2()
{
digitalWrite(keyboardClockPin, LOW);
pinMode(keyboardClockPin, OUTPUT);
}
// Read next byte from incoming PS/2 buffer, or 0 when empty
static byte readPs2Buffer()
{
byte value = 0;
if (head != tail) {
value = ps2Buffer[tail];
tail = (tail + 1) % sizeof ps2Buffer;
}
return value;
}
byte keyboard_getState()
{
word now = (word) millis(); // Note: without interrupts millis() stops counting
for (;;) {
word value = readPs2Buffer();
if (value == 0) { // Buffer is empty
if (now - lastChange > hold) // Auto-release keys after `hold' milliseconds
ascii = 0;
if (now - lastChange > 1000) // Hold `buttons' a bit longer than the repeat delay. This
flags &= ~255; // is merely a safeguard against missing the break event
// and then ending up with a stuck virtual button press.
break;
}
switch (value) {
// The BREAK or EXTENDED bytes are part of a longer sequence
// Here we don't mind the order they appear in
case 0xe0: flags |= extendedFlag; continue;
case 0xf0: flags |= breakFlag; continue;
case 0xaa: // BAT ok
#define oddParity(x) ((1 ^ x ^ (x>>1) ^ (x>>2) ^ (x>>3) ^ (x>>4) ^ (x>>5) ^ (x>>6) ^ (x>>7)) & 1)
#define code(x) ((1 << 10) | (oddParity(x) << 9) | ((x) << 1))
keyboard_send(code(0xf4)); // Enable (fixes Walter's PERIBOARD-409)
continue;
}
if (flags & extendedFlag)
value |= 0xe0 << 8; // Simplify our switch statements
// Recognize modifier keys
word modifier = 0;
switch (value) {
case 0x11: modifier = altFlag; break;
case 0x12: modifier = leftShiftFlag; break;
case 0x14: modifier = leftCtrlFlag; break;
case 0x59: modifier = rightShiftFlag; break;
case 0xe011: modifier = altGrFlag; break;
case 0xe014: modifier = rightCtrlFlag; break;
}
// Case 1: Handle modifier keys
if (modifier) {
if (flags & breakFlag)
flags &= ~modifier; // Modifier key released
else
flags |= modifier; // Modifier key pressed
nextPs2(); // Reset PS/2 sequence
continue; // Back to reading from buffer
}
// Recognize character and control keys and map them to ASCII
// or game controller buttons
// Always return an updated state to the caller from this point on,
// even if there are still bytes waiting in the buffer.
byte button = 0;
byte newAscii = 0;
switch (value) {
// Extended codes in "Set 2"
case 0xe075: button = buttonUp; break; // [UpArrow]
case 0xe06b: button = buttonLeft; break; // [LeftArrow]
case 0xe072: button = buttonDown; break; // [DownArrow]
case 0xe074: button = buttonRight; break; // [RightArrow]
case 0x66: // [BackSpace]
case 0xe071: if ((flags & ctrlFlags) // [Delete]
&& (flags & altFlags))
newAscii = CTRLALTDEL; // [Ctrl-Alt-Del] becomes [Start]
else
button = buttonA; break; // ASCII DEL is 127 is ~buttonA
case 0xe069: button = buttonA; break; // [End]
case 0xe070: // [Insert]
case 0xe06c: button = buttonB; break; // [Home]
case 0xe07a: button = buttonSelect; break; // [PageDown]
case 0xe07d: button = buttonStart; break; // [PageUp]
case 0xe04a: newAscii = '/'; break; // [/] on numeric island
case 0xe05a: newAscii = '\n'; break; // [Enter] on numeric island
default:
// Apply keyboard mapping to ASCII
if ((flags & altGrFlag) ||
((flags & ctrlFlags) && (flags & altFlag))) // Ctrl+Alt is AltGr
newAscii = lookup(ALTGR, value);
else if (flags & shiftFlags)
newAscii = lookup(SHIFT, value);
else
newAscii = lookup(NOMOD, value);
// Handle control key combinations
if (flags & ctrlFlags)
switch (newAscii) {
case '?': newAscii = 127; break; // Traditional mapping of Ctrl-? to DEL
case ' ': button = 255; break; // Make it send a 0 byte
default:
byte f = fnKey(newAscii);
if (f) {
if (flags & altFlags)
// Ctrl-Alt-Fxx changes the keymap
EEPROM.write(offsetof(struct EEPROMlayout, keymapIndex), f-1);
else
// Ctrl+Fxx are BabelFish commands
newAscii ^= 64;
} else
// Make control codes (what the key is for...)
newAscii &= 31;
}
}
// Consolidate the `flags' and `ascii' states
if (button) { // Case 2: Simulated game controller buttons
lastChange = now;
if (flags & breakFlag)
flags &= ~button; // Button released
else
flags |= button; // Button pressed
ascii = 0;
} else { // Case 3: ASCII keys
if (newAscii != ascii)
lastChange = now;
if (~flags & breakFlag) // Ignore ASCII release events (use 'hold' instead)
ascii = newAscii; // ASCII pressed
hold = 35; // Hold for 3 frames (less than the repeat rate)
if (ascii == CTRLALTDEL) // At least 2 seconds for the [Start] signal
hold = max(500 + now - lastChange, 2500); // No accidental Easter Egg trigger (8b guy)
flags &= ~255;
}
nextPs2(); // Reset PS/2 sequence
break; // Always return, leave anything in buffer behind
}
// Return the newly determined state to caller
return ascii ? ascii : (255 & ~flags);
}
// Return 0 if not a function key, or its ordinal otherwise
byte fnKey(byte key)
{
return (PS2_F1 <= key && key <= PS2_F12) ? (key & 15) : 0;
}
// 'code' must include start, data, parity and stop bits
void keyboard_send(word code)
{
// 1. Bring the Clock line low for at least 100 microseconds
forbidPs2();
delayMicroseconds(100);
// 2. Bring the data line low
digitalWrite(keyboardDataPin, 0);
pinMode(keyboardDataPin, OUTPUT);
// 3. Release the Clock line
allowPs2();
// Pull-up resistor will bring clock line up first
do {
// 6. Wait for the device to bring Clock high
while (digitalRead(keyboardClockPin) == 0)
;
// 4. 7. Wait for the device to bring the Clock line low
// MvK: Falling edge transfers the data
while (digitalRead(keyboardClockPin) != 0)
;
// 5. Set/reset the Data line to send the next data bit
code >>= 1;
if (code & 1)
pinMode(keyboardDataPin, INPUT_PULLUP); // To send 1
else {
digitalWrite(keyboardDataPin, 0);
pinMode(keyboardDataPin, OUTPUT); // To send 0
}
// 8. Repeat steps 5-7 for the other seven data bits and the parity bit
// 9. Release the Data line
} while (code > 1);
pinMode(keyboardDataPin, INPUT_PULLUP);
// 10. Wait for the device to bring Data low
while (digitalRead(keyboardDataPin) != 0)
;
// 11. Wait for the device to bring Clock low
while (digitalRead(keyboardClockPin) != 0)
;
// 12. Wait for the device to release Data and Clock
while (digitalRead(keyboardClockPin) == 0 || digitalRead(keyboardDataPin) == 0)
;
}
@@ -0,0 +1,97 @@
// Generated by tinyfont.py
0x0000, // ' '
0x03a0, // '!'
0x6018, // '"'
0x7d5f, // '#'
0x2bf4, // '$'
0x4889, // '%'
0x2aab, // '&'
0x0300, // "'"
0x01d1, // '('
0x45c0, // ')'
0x288a, // '*'
0x11c4, // '+'
0x0440, // ','
0x1084, // '-'
0x0020, // '.'
0x0888, // '/'
0x3e3e, // '0'
0x27e1, // '1'
0x4ea9, // '2'
0x56aa, // '3'
0x709f, // '4'
0x76b2, // '5'
0x3eb7, // '6'
0x4e98, // '7'
0x7ebf, // '8'
0x76be, // '9'
0x0140, // ':'
0x0540, // ';'
0x1151, // '<'
0x294a, // '='
0x4544, // '>'
0x42b8, // '?'
0x3a3d, // '@'
0x3e8f, // 'A'
0x7eaa, // 'B'
0x3a31, // 'C'
0x7e2e, // 'D'
0x7eb1, // 'E'
0x7e90, // 'F'
0x3e37, // 'G'
0x7c9f, // 'H'
0x47f1, // 'I'
0x0a3e, // 'J'
0x7c9b, // 'K'
0x7c21, // 'L'
0x7d9f, // 'M'
0x7ddf, // 'N'
0x7e3f, // 'O'
0x7e4c, // 'P'
0x3a6f, // 'Q'
0x7ecd, // 'R'
0x26b2, // 'S'
0x43f0, // 'T'
0x7c3f, // 'U'
0x783e, // 'V'
0x7cdf, // 'W'
0x6c9b, // 'X'
0x70fc, // 'Y'
0x4eb9, // 'Z'
0x03f1, // '['
0x2082, // '\\'
0x47e0, // ']'
0x2208, // '^'
0x0421, // '_'
0x4100, // '`'
0x1d2f, // 'a'
0x7d26, // 'b'
0x1929, // 'c'
0x193f, // 'd'
0x196d, // 'e'
0x11f4, // 'f'
-0x4d42, // 'g'
0x7d07, // 'h'
0x16e1, // 'i'
-0x76d2, // 'j'
0x7c8b, // 'k'
0x47e1, // 'l'
0x3dcf, // 'm'
0x3d07, // 'n'
0x1926, // 'o'
-0x01b4, // 'p'
-0x4da1, // 'q'
0x3c88, // 'r'
0x15ea, // 's'
0x23e9, // 't'
0x382f, // 'u'
0x386e, // 'v'
0x3cef, // 'w'
0x24c9, // 'x'
-0x1f42, // 'y'
0x256d, // 'z'
0x13f1, // '{'
0x03e0, // '|'
0x47e4, // '}'
0x2310, // '~'
0x7fff, // '\x7f'
@@ -0,0 +1,97 @@
#-----------------------------------------------------------------------
#
# tinyfont.py -- a very small font
#
#-----------------------------------------------------------------------
#
# Description:
#
# The tiny font is an 3x5 pixel monospaced font where each character
# is placed in a box of 4x6 pixels. At the native 160x120 Gigatron
# resolution we can display 40x20 characters.
#
# The encoding has 3x5 bits for the pixels and 1 shift bit to indicate
# an overall shift down for characters g, j, p, q and y. The lowercase
# j needs special handling. This scheme gives 2 bytes per character,
# for a total of 192 bytes.
#
# References:
#
# http://vt100.tarunz.org
# VT100 Terminal for Pilot (Brian J. Swetland)
#
# https://robey.lag.net/2010/01/23/tiny-monospace-font.html
# A very tiny, monospace, bitmap font (Robey Pointer)
#
# https://fonts2u.com/small-5x3-regular.font
# Small 5X3 regular (soxhead2000)
#
# https://github.com/olikraus/u8g2
# U8glib library for monochrome displays, version 2
#
# History:
#
# 2018-08-01 (marcelk) Initial version inspired by open source examples
# 2018-08-xx (marcelk) Update of @corz
#
#-----------------------------------------------------------------------
def convert(font):
for c in range(96):
i, j = c % 16, c / 16
word, shift = 0, 0
for y in range(6):
for x in range(3):
p = ((j * 6 + y) * 16 + i) * 4 + x + 1
if font[p] == '@':
if y == 5 and shift == 0:
shift, word = 1, word << 1
word |= 1 << (5*(3-x) - y - 1 + shift)
if shift == 0:
print ' 0x%04x,' % word,
else:
print '-0x%04x,' % (0x8000 - word),
print '// %s' % repr(chr(32+c))
tinyfont =\
'......@..@.@.@.@..@@.@....@...@....@.@..........................'\
'......@..@.@.@@@.@@....@.@.@..@...@...@..@.@..@................@'\
'......@......@.@..@@..@...@.......@...@...@..@@@.....@@@......@.'\
'.............@@@.@@..@...@.@......@...@..@.@..@...@..........@..'\
'......@......@.@..@....@..@@.......@.@...........@........@.....'\
'................................................................'\
'..@@..@..@@..@@..@.@.@@@..@@.@@@.@@@.@@@...........@.....@...@@@'\
'.@.@.@@....@...@.@.@.@...@.....@.@.@.@.@..@...@...@..@@@..@....@'\
'.@.@..@...@..@@..@@@.@@..@@@..@..@@@.@@@.........@.........@..@.'\
'.@.@..@..@.....@...@...@.@.@.@...@.@...@..@...@...@..@@@..@.....'\
'.@@..@@@.@@@.@@....@.@@..@@@.@...@@@.@@......@.....@.....@....@.'\
'................................................................'\
'..@@..@..@@...@@.@@..@@@.@@@..@@.@.@.@@@..@@.@.@.@...@.@.@.@.@@@'\
'.@.@.@.@.@.@.@...@.@.@...@...@...@.@..@....@.@.@.@...@@@.@@@.@.@'\
'.@.@.@@@.@@..@...@.@.@@..@@..@.@.@@@..@....@.@@..@...@@@.@@@.@.@'\
'.@...@.@.@.@.@...@.@.@...@...@.@.@.@..@..@.@.@.@.@...@.@.@@@.@.@'\
'..@@.@.@.@@...@@.@@..@@@.@...@@@.@.@.@@@..@..@.@.@@@.@.@.@.@.@@@'\
'................................................................'\
'.@@...@..@@...@@.@@@.@.@.@.@.@.@.@.@.@.@.@@@..@@.....@@...@.....'\
'.@.@.@.@.@.@.@....@..@.@.@.@.@.@.@.@.@.@...@..@..@....@..@.@....'\
'.@.@.@.@.@@@..@...@..@.@.@.@.@@@..@..@@@..@...@...@...@.........'\
'.@@..@@@.@@....@..@..@.@.@.@.@@@.@.@..@..@....@....@..@.........'\
'.@....@@.@.@.@@...@..@@@..@..@.@.@.@..@..@@@..@@.....@@......@@@'\
'................................................................'\
'.@.......@.........@.......@.....@....@....O.@...@@.............'\
'..@...@@.@@...@@..@@..@@..@...@@.@@..........@.@..@..@@@.@@...@.'\
'.....@.@.@.@.@...@.@.@.@.@@@.@.@.@.@.@@...@@.@@...@..@@@.@.@.@.@'\
'.....@.@.@.@.@...@.@.@@...@..@@@.@.@..@....@.@.@..@..@@@.@.@.@.@'\
'.....@@@.@@...@@..@@..@@..@....@.@.@.@@@.@.@.@.@.@@@.@.@.@.@..@.'\
'..............................@.......... @.....................'\
'..................@...........................@@..@..@@...@@.@@@'\
'.@@...@@.@.@..@@.@@@.@.@.@.@.@.@.@.@.@.@.@@@..@...@...@..@@..@@@'\
'.@.@.@.@.@@..@@...@..@.@.@.@.@@@..@..@.@...@.@@...@...@@.....@@@'\
'.@.@.@.@.@....@@..@..@.@.@@@.@@@..@...@@..@...@...@...@......@@@'\
'.@@...@@.@...@@...@@..@@..@..@@@.@.@...@.@@@..@@..@..@@......@@@'\
'.@.....@..............................@.........................'
print '// Generated by tinyfont.py'
convert(tinyfont)
@@ -0,0 +1,9 @@
# Source from 2022-08-16:
## ROM
https://www.dropbox.com/sh/sw0etxvv6z54c0n/AABPUZrywJBoGGucP0vf1NEsa?dl=0
## NO_ROM
https://www.dropbox.com/sh/d8v284j9j41bby3/AAB0HwuKrlWOsKBrOrrxWuCUa?dl=0
Added Arduino Nano Every to BabelFish.
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,20 @@
:020000040000FA
:100000001124669A26E030E408C000000197E9F761
:100010008DB183278DB9215019F081E091E7F6CF9A
:1000200080911F138B3E69F48FEF80931F138DE92E
:1000300093E084BF909300108091021081FDFCCF6B
:1000400006C082E080930110E0E0F1E0099580ECC9
:1000500080930608A09123110A2E000CBB0BBC5FF5
:100060002CE530E00E9476007E5F8F4F9F4F2AE0A4
:1000700095958795779567952A95D1F760930808A8
:10008000709309088091E20581608093E205049AEB
:10009000E0E0F2E42DE933E040E41EC08091040882
:1000A00087FFFCCF80910008E11552E4F50711F4B9
:1000B000882391F0809302088193CF018F7799274D
:1000C000892B51F424BF309300108091021080FDE1
:1000D000FCCF8DB184278DB9CF0190548115904C00
:1000E000E8F288ED91E084BF909341000E947D008A
:1000F000B7FF0895821B930B0895A29FB001B39F91
:10010000C001A39F700D811D1124911DB29F700D20
:08011000811D1124911D0895C9
:00000001FF
@@ -0,0 +1,10 @@
// Annotated hexdump for Blinky.gt1
0x7f, 0x00, 0x0b, // Segment 7f00: 11 bytes
0x11, 0x50, 0x44, // 7f00 LDWI $4450 ; Load address of center of screen
0x2b, 0x30, // 7f03 STW 'p' ; Store in variable 'p' (at $0030)
0xf0, 0x30, // 7f05 POKE 'p' ; Write low byte of accumulator there
0xe3, 0x01, // 7f07 ADDI 1 ; Increment accumulator
0x90, 0x03, // 7f09 BRA $7f05 ; Loop forever
0x00, // No more segments
0x7f, 0x00 // Start address
@@ -0,0 +1,425 @@
_runtimePath_ "../../runtime"
_runtimeStart_ &h7FFF
_codeRomType_ ROMv5a
const sysArg0 = &h24
const sysArg7 = &h2B
'payload protocol: <isLast>, <length>, <payload 0...62>
'filename packet: <type>, <length>, <name>, <0> : <type> = 1:file or 2:dir
const MAX_FILES = 100
const PAYLOAD_SIZE = 63
const PROTOCOL_SIZE = 1 + 1 + PAYLOAD_SIZE
const PACKET_SIZE = 1 + 1 + 12 + 1
const CmdSDList = 1
const CmdSDExec = 2
const CmdSDOpen = 3
const CmdSDClose = 4
const CmdSDBegin = 5
const CmdSDInit = 6
const EntryFile = 1
const EntryDir = 2
const EntryError = 3
def execAddr, commsAddr, commsSize, commsRetn, browserIdx, browserY, cursorY, cursOldY, isLast, length, runStrAddr, execRtn, waitRtn
runName$ = ""
execName$ = ""
pathName$ = ""
dim commsCmd%(PACKET_SIZE-1) = 0
dim buffer%(PROTOCOL_SIZE-1) = 0
dim browser%(MAX_FILES-1, PACKET_SIZE-1)
gosub findLoader
restart:
gosub initialise
gosub initSDComms
gosub beginSDCard
gosub openSDCard
repeat
gosub listSDCard
gosub loadDir
gosub fillBrowser
until &(isLast)
gosub closeSDCard
gosub printBrowser
f = 0
kk = 255
repeat
wait
gosub handleInput
if &(execRtn) then goto &restart
inc f
forever
end
findLoader:
romType = get("ROM_TYPE")
if romType &&= &h20 'ROMv2
execAddr = &hE23E
elseif romType &&= &h28 'ROMv3
execAddr = &hB4A8
elseif romType &&= &h38 'ROMv4
execAddr = &hAD5A
elseif romType &>= &h40 'ROMv5 or higher
repeat
'create name string
execAddr = get("ROM_READ_DIR", execAddr)
if (execAddr)
poke @execName$, 6
for j=sysArg0 &to sysArg7
poke @execName$ + j - (sysArg0 - 1), peek(j)
next j
if execName$ = "Loader" then return
endif
until execAddr &= 0
print "Loader not found!"
end
endif
return
sendCommsCmd:
asm
LDWI SYS_SendSerial1_v3_80
STW giga_sysFn
LDW _commsAddr
STW giga_sysArg0
LDI 1
STW giga_sysArg2
LD _commsSize
LSLW
LSLW
LSLW
STW giga_sysArg3
SYS 80
STW _commsRetn
endasm
return
'simplified version of Loader, removes checksum, destination address, copying of buffer
'to destination address and visuals
loadDir:
asm
LDW _NextByteIn_32
STW giga_sysFn
loadD0: LDWI _buffer_array
STW giga_sysArg0 'buffer
LDI 207
ST giga_sysArg3 'scanline 207
SYS 32 'isLast, (0 or 1)
LDWI _buffer_array
PEEK
XORI 255
BEQ _loadD0 'loop while idle
LDI 219
ST giga_sysArg3 'scanline 219
SYS 32 'length, (6 bits : 0..62)
LDI 235
ST giga_sysArg3 'scanline 235
SYS 32 'payload 0
LDI 251
ST giga_sysArg3 'scanline 251
SYS 32 'payload 1
LDI 2
ST giga_sysArg3 'scanline 2
loadD1: SYS 32 'payload 2-61
LD giga_sysArg3
ADDI 4
ST giga_sysArg3
XORI 242 'scanline end is 238
BNE _loadD1
LDI 185
ST giga_sysArg3 'scanline 185
SYS 32 'payload 62
endasm
isLast = peek(@buffer)
length = peek(@buffer + 1) AND 63
return
fillBrowser:
bIdx = 2
if length &&= 0 then return
if browserIdx &&= MAX_FILES then return
repeat
cIdx = 0
repeat
char = peek(@buffer + bIdx)
poke addr(browser(browserIdx, cIdx)), char
inc bIdx
inc cIdx
until char &&= 0
inc browserIdx
if browserIdx &&= MAX_FILES then return
until (bIdx - 2) &&= length
return
printBrowser:
startY = max(min(browserY, browserIdx-15), 0)
endY = min(browserY+14, browserIdx-1)
for i=startY &to endY
strAddr = addr(browser(i, 0)) + 1
strLen = peek(strAddr)
isFile = peek(strAddr - 1)
if (i-browserY) &&= cursorY
if isFile &&= 1
set FGBG_COLOUR, &h203F
else
set FGBG_COLOUR, &h202A
endif
runStrAddr = strAddr
else
if isFile &&= 1
set FGBG_COLOUR, &h3F20
else
set FGBG_COLOUR, &h2A20
endif
endif
at 2, (i-browserY) LSL 3
print string$(strAddr);spc$(12 - strLen);
next i
return
updateBrowser:
startY = max(min(browserY, browserIdx-15), 0)
prevY = startY + cursOldY
prevAddr = addr(browser(prevY, 0)) + 1
prevLen = peek(prevAddr)
isFile = peek(prevAddr - 1)
if isFile &&= 1
set FGBG_COLOUR, &h3F20
else
set FGBG_COLOUR, &h2A20
endif
at 2, (prevY - startY) LSL 3
print string$(prevAddr);spc$(12 - prevLen);
cursOldY = cursorY
currY = startY + cursorY
currAddr = addr(browser(currY, 0)) + 1
currLen = peek(currAddr)
isFile = peek(currAddr - 1)
if isFile &&= 1
set FGBG_COLOUR, &h203F
else
set FGBG_COLOUR, &h202A
endif
at 2, (currY - startY) LSL 3
print string$(currAddr);spc$(12 - currLen);
runStrAddr = currAddr
return
getRomType:
'defaults to ROMv1
NextByteIn_32 = &h02E9
romType = get("ROM_TYPE")
if romType &&= &h20 'ROMv2
NextByteIn_32 = &h0BB1
elseif romType &&= &h28 'ROMv3
NextByteIn_32 = &h0BDF
elseif romType &&= &h38 'ROMv4
NextByteIn_32 = &h8A31
elseif romType &&= &h40 'ROMv5a
NextByteIn_32 = &h5907
elseif romType &&= &hF0 'SDCARD
NextByteIn_32 = &h1300
elseif romType &&= &hF8 'DEVROM
NextByteIn_32 = &h5907
endif
return
openSDCard:
poke @commsCmd, CmdSDOpen
len = peek(@pathName$)
if len &> 0
for i=1 &to len + 1
poke @commsCmd + i, peek(@pathName$ + i)
next i
else
poke @commsCmd + 1, 0
endif
commsSize = 1 + len + 1
gosub sendCommsCmd
'SDCard open can take a variable amount of time
gosub waitSDCard
pathName$ = ""
return
execApp:
gosub initSDComms
poke @commsCmd, CmdSDExec
runName$ = string$(runStrAddr)
len = peek(@runName$)
for i=1 &to len + 1
poke @commsCmd + i, peek(@runName$ + i)
next i
set FGBG_COLOUR, &h0F20 : cls INIT : cls
commsSize = 1 + len + 1
gosub sendCommsCmd
exec execAddr
return
'repeat delay and auto repeat
handleInput:
k = get("SERIAL_RAW")
if k &&<> kk
f = 0
kk = k
gosub k
endif
if f &> 20
if ((f LSR 1) AND 1)
gosub k
endif
endif
return
'button A
127: gosub execOrList
return
'enter
10: gosub execOrList
return
'right
254: browserY = browserY + 15
browserY = max(min(browserY, browserIdx-15), 0)
gosub printBrowser
return
'left
253: browserY = browserY - 15
browserY = max(browserY, 0)
gosub printBrowser
return
'down
251: inc cursorY
if cursorY &&> min(browserIdx - 1, 14) then cursorY = 0
gosub updateBrowser
return
'up
247: dec cursorY
if cursorY &&< 0 then cursorY = min(browserIdx - 1, 14)
gosub updateBrowser
return
'execute files, list directories
execOrList:
entry = peek(runStrAddr - 1)
if entry &&= EntryFile
execRtn = 0
gosub execApp
elseif entry &= EntryDir
execRtn = 1
pathName$ = string$(runStrAddr)
elseif entry &&= EntryError
execRtn = 2
pathName$ = ""
endif
return
waitSDCard:
asm
LDW _NextByteIn_32
STW giga_sysFn
waitSD: LDI _waitRtn
STW giga_sysArg0 'waitRtn address
LDI 207
ST giga_sysArg3 'scanline 207
SYS 32 'waitRtn result, (0:ready)
LD _waitRtn
BNE _waitSD 'loop while busy
endasm
wait 2
return
'this command is used to break BabelFish out of it's game controller loop and start checking comms
initSDComms:
commsSize = 1
poke @commsCmd, CmdSDInit
gosub sendCommsCmd
wait
return
listSDCard:
commsSize = 1
poke @commsCmd, CmdSDList
gosub sendCommsCmd
return
closeSDCard:
commsSize = 1
poke @commsCmd, CmdSDClose
gosub sendCommsCmd
return
beginSDCard:
commsSize = 1
poke @commsCmd, CmdSDBegin
gosub sendCommsCmd
'SDCard begin can take a variable amount of time
gosub waitSDCard
return
initialise:
init vars @commsSize
gosub getRomType
commsAddr = @commsCmd
mode 2 : set FGBG_COLOUR, &h3F20 : cls INIT : cls
return
@@ -0,0 +1 @@
0x02, 0x00, 0xfa, 0x59, 0x40, 0x2b, 0x82, 0x11, 0xe8, 0x62, 0xcf, 0x18, 0x11, 0x20, 0x0f, 0x2b, 0xa2, 0x59, 0x01, 0x2b, 0xaa, 0x59, 0x00, 0x2b, 0xa6, 0x85, 0xa0, 0x62, 0x11, 0xfe, 0x7c, 0x2b, 0x84, 0x11, 0xa0, 0x7d, 0x85, 0xd2, 0x61, 0x11, 0xfe, 0x7c, 0x2b, 0x84, 0x11, 0xa0, 0x7b, 0x85, 0xd2, 0x61, 0x11, 0xfe, 0x7c, 0x2b, 0x84, 0x11, 0xa0, 0x7a, 0x85, 0xd2, 0x61, 0x85, 0x79, 0x02, 0x85, 0xd9, 0x0d, 0x85, 0xe2, 0x0c, 0x85, 0xc3, 0x0d, 0x85, 0xdd, 0x05, 0x85, 0xf8, 0x0c, 0x85, 0x3a, 0x03, 0x85, 0x8c, 0x03, 0x21, 0x40, 0x35, 0x3f, 0x47, 0x85, 0xb0, 0x0d, 0x85, 0xe0, 0x03, 0x59, 0x00, 0x2b, 0x4a, 0x59, 0xff, 0x2b, 0x4c, 0x85, 0xb7, 0x61, 0x85, 0xc2, 0x09, 0x21, 0x46, 0x35, 0x3f, 0x70, 0x90, 0x3b, 0x93, 0x4a, 0x85, 0x65, 0x02, 0xb4, 0x80, 0x75, 0x1a, 0x21, 0x82, 0xfc, 0x2b, 0x4e, 0x21, 0x4e, 0x8c, 0x20, 0x35, 0x72, 0x8d, 0x11, 0x3e, 0xe2, 0x2b, 0x30, 0x85, 0x1d, 0x03, 0x21, 0x4e, 0x8c, 0x28, 0x35, 0x72, 0x9c, 0x11, 0xa8, 0xb4, 0x2b, 0x30, 0x85, 0x1d, 0x03, 0x21, 0x4e, 0x8c, 0x38, 0x35, 0x72, 0xab, 0x11, 0x5a, 0xad, 0x2b, 0x30, 0x85, 0x1d, 0x03, 0x21, 0x4e, 0xe6, 0x40, 0x35, 0x53, 0xb5, 0x85, 0x1d, 0x03, 0x21, 0x30, 0x2b, 0x82, 0x85, 0xbf, 0x61, 0x2b, 0x30, 0x21, 0x30, 0x35, 0x72, 0xc6, 0x85, 0x0a, 0x03, 0x11, 0xa0, 0x7b, 0x2b, 0x82, 0x59, 0x06, 0xf0, 0x82, 0x59, 0x24, 0x2b, 0x50, 0x11, 0xa0, 0x7b, 0x99, 0x50, 0xe6, 0x23, 0x2b, 0xe8, 0x21, 0x50, 0xad, 0xf0, 0xe8, 0x93, 0x50, 0x1a, 0x50, 0xe6, 0x2b, 0x35, 0x56, 0xd3, 0x11, 0xa0, 0x7b, 0x2b, 0x84, 0x11, 0xa6, 0x7c, 0x85, 0xc3, 0x66, 0x85, 0x00, 0x03, 0x03, 0x00, 0xfa, 0x82, 0x01, 0x35, 0x72, 0x06, 0x85, 0x0a, 0x03, 0x63, 0xff, 0x21, 0x30, 0x35, 0x3f, 0x10, 0x85, 0xb7, 0x02, 0x11, 0xb1, 0x69, 0x85, 0xd1, 0x62, 0x85, 0xaa, 0x67, 0xb4, 0x80, 0x63, 0xff, 0x75, 0x11, 0x06, 0x0b, 0x2b, 0x22, 0x21, 0x32, 0x2b, 0x24, 0x59, 0x01, 0x2b, 0x26, 0x1a, 0x34, 0xe9, 0xe9, 0xe9, 0x2b, 0x27, 0xb4, 0xe6, 0x2b, 0x36, 0x63, 0xff, 0x75, 0x21, 0x70, 0x2b, 0x22, 0x11, 0xae, 0x7c, 0x2b, 0x24, 0x59, 0xcf, 0x5e, 0x27, 0xb4, 0xfe, 0x11, 0xae, 0x7c, 0xad, 0x8c, 0xff, 0x35, 0x3f, 0x3d, 0x59, 0xdb, 0x5e, 0x27, 0xb4, 0xfe, 0x59, 0xeb, 0x5e, 0x27, 0xb4, 0xfe, 0x59, 0xfb, 0x5e, 0x27, 0xb4, 0xfe, 0x59, 0x02, 0x5e, 0x27, 0xb4, 0xfe, 0x1a, 0x27, 0xe3, 0x04, 0x5e, 0x27, 0x8c, 0xf2, 0x35, 0x72, 0x67, 0x59, 0xb9, 0x5e, 0x27, 0xb4, 0xfe, 0x11, 0xae, 0x7c, 0xad, 0x2b, 0x40, 0x11, 0xaf, 0x7c, 0xad, 0x82, 0x3f, 0x2b, 0x42, 0x63, 0xff, 0x75, 0x59, 0x02, 0x2b, 0x52, 0x21, 0x42, 0x35, 0x72, 0x96, 0x63, 0xff, 0x21, 0x38, 0x8c, 0x64, 0x35, 0x72, 0x9f, 0x63, 0xff, 0x59, 0x00, 0x2b, 0x54, 0x11, 0xae, 0x7c, 0x99, 0x52, 0xad, 0x2b, 0x56, 0x21, 0x38, 0x2b, 0x96, 0x21, 0x54, 0x2b, 0x98, 0x11, 0x38, 0x06, 0x85, 0xa1, 0x68, 0x2b, 0xea, 0x21, 0x56, 0xf0, 0xea, 0x93, 0x52, 0x93, 0x54, 0x21, 0x56, 0x35, 0x72, 0xa3, 0x93, 0x38, 0x21, 0x38, 0x8c, 0x64, 0x35, 0x72, 0xd3, 0x63, 0xff, 0x21, 0x52, 0xe6, 0x02, 0xfc, 0x42, 0x35, 0x72, 0x9f, 0x63, 0xff, 0x75, 0x21, 0x38, 0xe6, 0x0f, 0x2b, 0xe8, 0x21, 0x3a, 0x2b, 0x82, 0x21, 0xe8, 0x85, 0xac, 0x62, 0x2b, 0x82, 0x59, 0x00, 0x85, 0xf0, 0x61, 0x85, 0x00, 0x04, 0x04, 0x00, 0xfa, 0x2b, 0x58, 0x21, 0x3a, 0xe3, 0x0e, 0x2b, 0xe8, 0x21, 0x38, 0xe6, 0x01, 0x2b, 0xea, 0x21, 0xe8, 0x2b, 0x82, 0x21, 0xea, 0x85, 0xac, 0x62, 0x2b, 0x5a, 0x21, 0x58, 0x2b, 0x5c, 0x21, 0x5a, 0x2b, 0xb0, 0x59, 0x01, 0x2b, 0xb2, 0x21, 0x5c, 0x2b, 0x96, 0x59, 0x00, 0x2b, 0x98, 0x11, 0x38, 0x06, 0x85, 0xa1, 0x68, 0xe3, 0x01, 0x2b, 0x5e, 0x21, 0x5e, 0xad, 0x2b, 0x60, 0x21, 0x5e, 0xe6, 0x01, 0xad, 0x2b, 0x62, 0x21, 0x5c, 0xb8, 0x3a, 0xfc, 0x3c, 0x35, 0x72, 0x65, 0x21, 0x62, 0x8c, 0x01, 0x35, 0x72, 0x59, 0x11, 0x3f, 0x20, 0x2b, 0xa2, 0x85, 0x60, 0x04, 0x11, 0x2a, 0x20, 0x2b, 0xa2, 0x21, 0x5e, 0x2b, 0x44, 0x85, 0x7b, 0x04, 0x21, 0x62, 0x8c, 0x01, 0x35, 0x72, 0x74, 0x11, 0x20, 0x3f, 0x2b, 0xa2, 0x85, 0x7b, 0x04, 0x11, 0x20, 0x2a, 0x2b, 0xa2, 0x59, 0x02, 0x5e, 0xa4, 0x21, 0x5c, 0xb8, 0x3a, 0xe9, 0xe9, 0xe9, 0x5e, 0xa5, 0x85, 0xa8, 0x64, 0x21, 0x5e, 0x85, 0xd1, 0x62, 0x59, 0x0c, 0xb8, 0x60, 0x85, 0xe4, 0x63, 0x21, 0x5c, 0x99, 0xb2, 0x2b, 0x5c, 0xb8, 0xb0, 0x35, 0x56, 0x23, 0x63, 0xff, 0x75, 0x21, 0x38, 0xe6, 0x0f, 0x2b, 0xe8, 0x21, 0x3a, 0x2b, 0x82, 0x21, 0xe8, 0x85, 0xac, 0x62, 0x2b, 0x82, 0x59, 0x00, 0x85, 0xf0, 0x61, 0x2b, 0x58, 0x21, 0x58, 0x99, 0x3e, 0x2b, 0x64, 0x21, 0x64, 0x2b, 0x96, 0x59, 0x00, 0x2b, 0x98, 0x11, 0x38, 0x06, 0x85, 0xa1, 0x68, 0xe3, 0x01, 0x2b, 0x66, 0x21, 0x66, 0xad, 0x2b, 0x68, 0x21, 0x66, 0xe6, 0x01, 0xad, 0x2b, 0x62, 0x21, 0x62, 0x8c, 0x01, 0x35, 0x72, 0xee, 0x11, 0x20, 0x3f, 0x2b, 0xa2, 0x85, 0xf5, 0x04, 0x11, 0x20, 0x2a, 0x2b, 0xa2, 0x59, 0x02, 0x85, 0x00, 0x05, 0x05, 0x00, 0xfe, 0x5e, 0xa4, 0x21, 0x64, 0xb8, 0x58, 0xe9, 0xe9, 0xe9, 0x5e, 0xa5, 0x85, 0xa8, 0x64, 0x21, 0x66, 0x85, 0xd1, 0x62, 0x59, 0x0c, 0xb8, 0x68, 0x85, 0xe4, 0x63, 0x21, 0x3c, 0x2b, 0x3e, 0x21, 0x58, 0x99, 0x3c, 0x2b, 0x6a, 0x21, 0x6a, 0x2b, 0x96, 0x59, 0x00, 0x2b, 0x98, 0x11, 0x38, 0x06, 0x85, 0xa1, 0x68, 0xe3, 0x01, 0x2b, 0x6c, 0x21, 0x6c, 0xad, 0x2b, 0x6e, 0x21, 0x6c, 0xe6, 0x01, 0xad, 0x2b, 0x62, 0x21, 0x62, 0x8c, 0x01, 0x35, 0Line truncated
@@ -0,0 +1,710 @@
/*
* PS/2 keyboard handling for Babelfish talking to Gigatron
* Complete rewrite of PS2Keyboard for game controller mapping
* and keymap compression to reduce footprint
*
* References:
*
* https://www.avrfreaks.net/sites/default/files/PS2%20Keyboard.pdf
* The PS/2 Mouse/Keyboard Protocol
*
* http://www.quadibloc.com/comp/scan.htm
* Scan Codes Demytified
*
* https://retired.beyondlogic.org/keyboard/keybrd.htm
* Interfacing the AT keyboard
*
* https://web.archive.org/web/20180101224739/http://www.computer-engineering.org/ps2keyboard/scancodes2.html
* Keyboard Scan Codes: Set 2
*
* https://github.com/PaulStoffregen/PS2Keyboard
* PS/2 Keyboard Library for Arduino
*
* https://github.com/techpaul/PS2KeyAdvanced
* Arduino PS2 Keyboard FULL keyboard protocol support and full keys to integer coding
*
* https://github.com/techpaul/PS2KeyMap/
* Arduino PS2 keyboard International Keyboard mapping from PS2KeyAdvanced and return as UTF-8
*
* https://www.terena.org/activities/multiling/ml-mua/test/kbd-all.html
* This page provides information about layouts of different national
* keyboard their mapping to used Character Sets and UCS
*
* https://github.com/ilpianista/itlinux-win-keyboard
* An Italian keyboard layout for Windows, customized with shortcuts from Linux systems
*/
// TODO
// [Basic features]
// XXX Test keymap for DE
// XXX Test keymap for FR
// XXX Test keymap for GB
// XXX Test keymap for ES
// XXX Issue: Sometimes keyboard starts injecting break codes
// when pressing [buttonA] + arrow keys, making it impossible
// to set the time in Mandelbrot??
// XXX (Left)Alt for buttonB?
//
// [Advanced features, for consideration]
// XXX Caps-Lock and setting LEDs
// XXX Do something with NumLock?
// XXX Key combination to reset keyboard?
// XXX Allow Gigatron to control the keyboard lights
// XXX Let keyboard lights run in a pattern (bad idea :-)
#define PS2_ENTER '\n'
#define PS2_TAB 9
#define PS2_BACKSPACE 127
#define PS2_ESC 27
#define PS2_F1 (0xc0 + 1)
#define PS2_F2 (0xc0 + 2)
#define PS2_F3 (0xc0 + 3)
#define PS2_F4 (0xc0 + 4)
#define PS2_F5 (0xc0 + 5)
#define PS2_F6 (0xc0 + 6)
#define PS2_F7 (0xc0 + 7)
#define PS2_F8 (0xc0 + 8)
#define PS2_F9 (0xc0 + 9)
#define PS2_F10 (0xc0 + 10)
#define PS2_F11 (0xc0 + 11)
#define PS2_F12 (0xc0 + 12)
#define CTRLALTDEL (255 ^ buttonStart)
/*
* Keyboard layout mapping
*/
const char keymapNames[][3] = {
"US", "GB", "DE", "FR", "IT", "ES",
};
const byte nrKeymaps = arrayLen(keymapNames);
int getKeymapIndex(void)
{
byte index = EEPROM.read(offsetof(struct EEPROMlayout, keymapIndex));
return (index >= nrKeymaps) ? 0 : index; // Also handle invalid values
}
const char *getKeymapName()
{
return getKeymapName(getKeymapIndex());
}
const char *getKeymapName(byte index)
{
return (index > arrayLen(keymapNames)) ? 0 : keymapNames[index];
}
enum {
US = 1 << 0,
GB = 1 << 1,
DE = 1 << 2,
FR = 1 << 3,
IT = 1 << 4,
ES = 1 << 5,
NOMOD = 0 << nrKeymaps,
SHIFT = 1 << nrKeymaps,
ALTGR = 2 << nrKeymaps,
EVERY = 3 << nrKeymaps,
};
typedef struct {
byte flags; // Change from byte to word if we add more keymaps
byte code;
byte ascii; // XXX Remove this if we add flags. Value can be inferred by lookup()
} keyTuple_t;
// Keymaps courtesy of
// Arduino PS2Keyboard library (US,DE,FR)
// https://playground.arduino.cc/Main/PS2Keyboard
// and
// Teensy PS2Keyboard library (GB,IT,ES)
// http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
//
// 229 * 3 bytes = 687 bytes for holding 6 keyboard layouts
// To save space this table excludes codes that aren't in US-ASCII
// because these aren't in the Gigatron font either (yet).
// So accented letters and such are all absent. This is needed
// to make it all fit in the ATtiny85 configuration.
const PROGMEM keyTuple_t keymaps[] = {
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0d, 9 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x5a, 10 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x76, 27 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x29, 32 },
{ +US+GB+DE +IT+ES +SHIFT, 0x16, 33 }, // '!'
{ +FR +NOMOD, 0x4a, 33 },
{ +GB+DE +IT+ES +SHIFT, 0x1e, 34 }, // '"'
{ +FR +NOMOD, 0x26, 34 },
{ +US +SHIFT, 0x52, 34 },
{ +US +SHIFT, 0x26, 35 }, // '#'
{ +FR +ES +ALTGR, 0x26, 35 },
{ +IT +ALTGR, 0x52, 35 },
{ +GB+DE +NOMOD, 0x5d, 35 },
{ +DE+FR +ALTGR, 0x5d, 35 },
{ +US+GB+DE +IT+ES +SHIFT, 0x25, 36 }, // '$'
{ +FR +NOMOD, 0x5b, 36 },
{ +US+GB+DE +IT+ES +SHIFT, 0x2e, 37 }, // '%'
{ +FR +SHIFT, 0x52, 37 },
{ +FR +NOMOD, 0x16, 38 }, // '&'
{ +DE +IT+ES +SHIFT, 0x36, 38 },
{ +US+GB +SHIFT, 0x3d, 38 },
{ +FR +NOMOD, 0x25, 39 }, // '''
{ +IT+ES +NOMOD, 0x4e, 39 },
{ +US+GB +NOMOD, 0x52, 39 },
{ +DE +NOMOD, 0x55, 39 },
{ +DE +SHIFT, 0x5d, 39 },
{ +FR +NOMOD, 0x2e, 40 }, // '('
{ +DE +IT+ES +SHIFT, 0x3e, 40 },
{ +US+GB +SHIFT, 0x46, 40 },
{ +US+GB +SHIFT, 0x45, 41 }, // ')'
{ +DE +IT+ES +SHIFT, 0x46, 41 },
{ +FR +NOMOD, 0x4e, 41 },
{ +US+GB +SHIFT, 0x3e, 42 }, // '*'
{ +DE +IT+ES +SHIFT, 0x5b, 42 },
{ +FR +NOMOD, 0x5d, 42 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7c, 42 },
{ +US+GB +FR +SHIFT, 0x55, 43 }, // '+'
{ +DE +IT+ES +NOMOD, 0x5b, 43 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x79, 43 },
{ +FR +NOMOD, 0x3a, 44 }, // ','
{ +US+GB+DE +IT+ES +NOMOD, 0x41, 44 },
{ +FR +NOMOD, 0x36, 45 }, // '-'
{ +DE +IT+ES +NOMOD, 0x4a, 45 },
{ +US+GB +NOMOD, 0x4e, 45 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7b, 45 },
{ +FR +SHIFT, 0x41, 46 }, // '.'
{ +US+GB+DE +IT+ES +NOMOD, 0x49, 46 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x71, 46 },
{ +DE +IT+ES +SHIFT, 0x3d, 47 }, // '/'
{ +FR +SHIFT, 0x49, 47 },
{ +US+GB +NOMOD, 0x4a, 47 },
{ +US+GB+DE +IT+ES +NOMOD, 0x45, 48 }, // '0'
{ +FR +SHIFT, 0x45, 48 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x70, 48 },
{ +US+GB+DE +IT+ES +NOMOD, 0x16, 49 }, // '1'
{ +FR +SHIFT, 0x16, 49 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x69, 49 },
{ +US+GB+DE +IT+ES +NOMOD, 0x1e, 50 }, // '2'
{ +FR +SHIFT, 0x1e, 50 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x72, 50 },
{ +US+GB+DE +IT+ES +NOMOD, 0x26, 51 }, // '3'
{ +FR +SHIFT, 0x26, 51 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7a, 51 },
{ +US+GB+DE +IT+ES +NOMOD, 0x25, 52 }, // '4'
{ +FR +SHIFT, 0x25, 52 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x6b, 52 },
{ +US+GB+DE +IT+ES +NOMOD, 0x2e, 53 }, // '5'
{ +FR +SHIFT, 0x2e, 53 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x73, 53 },
{ +US+GB+DE +IT+ES +NOMOD, 0x36, 54 }, // '6'
{ +FR +SHIFT, 0x36, 54 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x74, 54 },
{ +US+GB+DE +IT+ES +NOMOD, 0x3d, 55 }, // '7'
{ +FR +SHIFT, 0x3d, 55 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x6c, 55 },
{ +US+GB+DE +IT+ES +NOMOD, 0x3e, 56 }, // '8'
{ +FR +SHIFT, 0x3e, 56 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x75, 56 },
{ +US+GB+DE +IT+ES +NOMOD, 0x46, 57 }, // '9'
{ +FR +SHIFT, 0x46, 57 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x7d, 57 },
{ +FR +NOMOD, 0x49, 58 }, // ':'
{ +DE +IT+ES +SHIFT, 0x49, 58 },
{ +US+GB +SHIFT, 0x4c, 58 },
{ +FR +NOMOD, 0x41, 59 }, // ';'
{ +DE +IT+ES +SHIFT, 0x41, 59 },
{ +US+GB +NOMOD, 0x4c, 59 },
{ +US+GB +SHIFT, 0x41, 60 }, // '<'
{ +DE+FR+IT+ES +NOMOD, 0x61, 60 },
{ +DE +IT+ES +SHIFT, 0x45, 61 }, // '='
{ +US+GB +FR +NOMOD, 0x55, 61 },
{ +US+GB +SHIFT, 0x49, 62 }, // '>'
{ +DE+FR+IT+ES +SHIFT, 0x61, 62 },
{ +FR +SHIFT, 0x3a, 63 }, // '?'
{ +US+GB +SHIFT, 0x4a, 63 },
{ +DE +IT+ES +SHIFT, 0x4e, 63 },
{ +DE+FR +ALTGR, 0x15, 64 }, // '@'
{ +US +SHIFT, 0x1e, 64 },
{ +ES +ALTGR, 0x1e, 64 },
{ +FR +ALTGR, 0x45, 64 },
{ +IT +ALTGR, 0x4c, 64 },
{ +GB +SHIFT, 0x52, 64 },
{ +FR +SHIFT, 0x15, 65 }, // 'A'
{ +US+GB+DE +IT+ES +SHIFT, 0x1c, 65 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x32, 66 }, // 'B'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x21, 67 }, // 'C'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x23, 68 }, // 'D'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x24, 69 }, // 'E'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2b, 70 }, // 'F'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x34, 71 }, // 'G'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x33, 72 }, // 'H'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x43, 73 }, // 'I'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x3b, 74 }, // 'J'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x42, 75 }, // 'K'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x4b, 76 }, // 'L'
{ +US+GB+DE +IT+ES +SHIFT, 0x3a, 77 }, // 'M'
{ +FR +SHIFT, 0x4c, 77 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x31, 78 }, // 'N'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x44, 79 }, // 'O'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x4d, 80 }, // 'P'
{ +US+GB+DE +IT+ES +SHIFT, 0x15, 81 }, // 'Q'
{ +FR +SHIFT, 0x1c, 81 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2d, 82 }, // 'R'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x1b, 83 }, // 'S'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2c, 84 }, // 'T'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x3c, 85 }, // 'U'
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x2a, 86 }, // 'V'
{ +FR +SHIFT, 0x1a, 87 }, // 'W'
{ +US+GB+DE +IT+ES +SHIFT, 0x1d, 87 },
{ +US+GB+DE+FR+IT+ES +SHIFT, 0x22, 88 }, // 'X'
{ +DE +SHIFT, 0x1a, 89 }, // 'Y'
{ +US+GB +FR+IT+ES +SHIFT, 0x35, 89 },
{ +US+GB +IT+ES +SHIFT, 0x1a, 90 }, // 'Z'
{ +FR +SHIFT, 0x1d, 90 },
{ +DE +SHIFT, 0x35, 90 },
{ +FR +ALTGR, 0x2e, 91 }, // '['
{ +DE +IT +ALTGR, 0x3e, 91 },
{ +US+GB +NOMOD, 0x54, 91 },
{ +IT+ES +ALTGR, 0x54, 91 },
{ +IT +NOMOD, 0x0e, 92 }, // '\'
{ +ES +ALTGR, 0x0e, 92 },
{ +FR +ALTGR, 0x3e, 92 },
{ +DE +ALTGR, 0x4e, 92 },
{ +US +NOMOD, 0x5d, 92 },
{ +GB +NOMOD, 0x61, 92 },
{ +DE +IT +ALTGR, 0x46, 93 }, // ']'
{ +FR +ALTGR, 0x4e, 93 },
{ +US+GB +NOMOD, 0x5b, 93 },
{ +IT+ES +ALTGR, 0x5b, 93 },
{ +DE +NOMOD, 0x0e, 94 }, // '^'
{ +US+GB +SHIFT, 0x36, 94 },
{ +FR +ALTGR, 0x46, 94 },
{ +FR +NOMOD, 0x54, 94 },
{ +ES +SHIFT, 0x54, 94 },
{ +IT +SHIFT, 0x55, 94 },
{ +FR +NOMOD, 0x3e, 95 }, // '_'
{ +DE +IT+ES +SHIFT, 0x4a, 95 },
{ +US+GB +SHIFT, 0x4e, 95 },
{ +US+GB +NOMOD, 0x0e, 96 }, // '`'
{ +FR +ALTGR, 0x3d, 96 },
{ +IT +ALTGR, 0x4e, 96 },
{ +ES +NOMOD, 0x54, 96 },
{ +DE +SHIFT, 0x55, 96 },
{ +FR +NOMOD, 0x15, 97 }, // 'a'
{ +US+GB+DE +IT+ES +NOMOD, 0x1c, 97 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x32, 98 }, // 'b'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x21, 99 }, // 'c'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x23, 100 }, // 'd'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x24, 101 }, // 'e'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2b, 102 }, // 'f'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x34, 103 }, // 'g'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x33, 104 }, // 'h'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x43, 105 }, // 'i'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x3b, 106 }, // 'j'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x42, 107 }, // 'k'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x4b, 108 }, // 'l'
{ +US+GB+DE +IT+ES +NOMOD, 0x3a, 109 }, // 'm'
{ +FR +NOMOD, 0x4c, 109 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x31, 110 }, // 'n'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x44, 111 }, // 'o'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x4d, 112 }, // 'p'
{ +US+GB+DE +IT+ES +NOMOD, 0x15, 113 }, // 'q'
{ +FR +NOMOD, 0x1c, 113 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2d, 114 }, // 'r'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x1b, 115 }, // 's'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2c, 116 }, // 't'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x3c, 117 }, // 'u'
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x2a, 118 }, // 'v'
{ +FR +NOMOD, 0x1a, 119 }, // 'w'
{ +US+GB+DE +IT+ES +NOMOD, 0x1d, 119 },
{ +US+GB+DE+FR+IT+ES +NOMOD, 0x22, 120 }, // 'x'
{ +DE +NOMOD, 0x1a, 121 }, // 'y'
{ +US+GB +FR+IT+ES +NOMOD, 0x35, 121 },
{ +US+GB +IT+ES +NOMOD, 0x1a, 122 }, // 'z'
{ +FR +NOMOD, 0x1d, 122 },
{ +DE +NOMOD, 0x35, 122 },
{ +FR +ALTGR, 0x25, 123 }, // '{'
{ +DE +IT +ALTGR, 0x3d, 123 },
{ +ES +ALTGR, 0x52, 123 },
{ +US+GB +SHIFT, 0x54, 123 },
{ +IT +SHIFT, 0x0e, 124 }, // '|'
{ +ES +ALTGR, 0x16, 124 },
{ +FR +ALTGR, 0x36, 124 },
{ +US +SHIFT, 0x5d, 124 },
{ +GB +SHIFT, 0x61, 124 },
{ +DE+FR +ES +ALTGR, 0x61, 124 },
{ +DE +IT +ALTGR, 0x45, 125 }, // '}'
{ +FR +ALTGR, 0x56, 125 },
{ +US+GB +SHIFT, 0x5b, 125 },
{ +ES +ALTGR, 0x5d, 125 },
{ +US +SHIFT, 0x0e, 126 }, // '~'
{ +FR +ALTGR, 0x1e, 126 },
{ +ES +ALTGR, 0x25, 126 },
{ +IT +ALTGR, 0x55, 126 },
{ +DE +ALTGR, 0x5b, 126 },
{ +GB +SHIFT, 0x5d, 126 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x66, 127 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x05, 193 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x06, 194 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x04, 195 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0c, 196 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x03, 197 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0b, 198 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x83, 199 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x0a, 200 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x01, 201 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x09, 202 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x78, 203 },
{ +US+GB+DE+FR+IT+ES +EVERY, 0x07, 204 },
};
/*
* Find ASCII code corresponding to key code and active modifiers
* for the current keymap
*/
static inline byte lookup(byte mods, word code)
{
byte keymapFlag = 1 << getKeymapIndex();
for (int i=0; i<arrayLen(keymaps); i++) {
const keyTuple_t *t = &keymaps[i];
byte f = pgm_read_byte(&t->flags);
if (~f & keymapFlag)
continue; // Different keymap
if ((f & EVERY) != EVERY && (f & EVERY) != mods)
continue; // Different modifiers
byte c = pgm_read_byte(&t->code);
if (c != code)
continue; // Different scan code
return pgm_read_byte(&t->ascii);
}
return 0;
}
/*
* Output state
*/
enum {
// bit 0:7 Equivalent game controller buttons (positive)
// buttonRight .. buttonA
// bit 8:13 State of modifier keys
leftShiftFlag = 1<<8,
rightShiftFlag = 1<<9,
leftCtrlFlag = 1<<10,
rightCtrlFlag = 1<<11,
altFlag = 1<<12,
altGrFlag = 1<<13,
shiftFlags = leftShiftFlag | rightShiftFlag,
ctrlFlags = leftCtrlFlag | rightCtrlFlag,
altFlags = altFlag | altGrFlag,
// bit 14:15 Protocol state
breakFlag = 1<<14, // Release of physical key
extendedFlag = 1<<15, // Extended PS/2 keyboard codes
};
#define nextPs2()\
flags &= ~(breakFlag | extendedFlag)
static word flags = 0; // Modifier keys and button state
static byte ascii = 0; // Current ASCII key press
static word lastChange, hold; // Babelfish controls the hold time for keys
// XXX Put variables in a class for better scoping
/*
* PS/2 sequences
*/
static int bitBuffer;
static byte _n;
static word lastClock;
/*
* Input buffering
*/
static volatile byte ps2Buffer[15+1];
static volatile byte head = 0, tail = 0;
#if defined(ARDUINO_attiny)
// attachInterrupt() doesn't work on the ATtiny85
static byte keyboardClockBit;
ISR(PCINT0_vect)
{
if (~PINB & keyboardClockBit) // FALLING edge of PS/2 clock
ps2interrupt();
}
#endif
void keyboard_setup()
{
// Initialize the pins
pinMode(keyboardDataPin, INPUT_PULLUP);
allowPs2();
#if defined(ARDUINO_attiny)
keyboardClockBit = digitalPinToBitMask(keyboardClockPin);
GIMSK |= 1<<PCIE; // Pin change interrupt enable
PCMSK |= keyboardClockBit; // ... for keyboard clock
#else
attachInterrupt(
digitalPinToInterrupt(keyboardClockPin),
ps2interrupt, FALLING);
#endif
}
// Handle one bit from PS/2 keyboard for the next byte
// bit 0 : start bit (0)
// bit 1..8 : data bits 0..7 (lowest bit first)
// bit 9 : parity (odd)
// bit 10 : stop bit (1)
void ps2interrupt()
{
byte nextBit = digitalRead(keyboardDataPin);
word now = (word) millis(); // millis() stops when interrupts are disabled,
// but that is ok, because we will reset n
// after every vPulse (through allowPs2())
// At least 10 kHz required for PS/2, self-reset after time out
if (now - lastClock > 5 || _n >= 11) {
bitBuffer = 1; // Clear bits and setup for odd parity
_n = 0;
}
lastClock = now;
bitBuffer |= nextBit << _n;
bitBuffer ^= nextBit; // Track parity in bit 0
if (_n == 10) {
ps2Buffer[head] = (bitBuffer >> 1) & 255;
byte nextHead = (head + 1) % sizeof ps2Buffer;
if (nextHead != tail // Buffer not (almost) full
&& (bitBuffer & 1)) // Parity check, with bonus check of start/stop bits
head = nextHead;
}
_n++;
}
// Ready to receive
void allowPs2()
{
pinMode(keyboardClockPin, INPUT_PULLUP);
_n = 11; // Consider previous bits lost
}
// Pull clock line LOW to signal that we're not ready to receive
void forbidPs2()
{
digitalWrite(keyboardClockPin, LOW);
pinMode(keyboardClockPin, OUTPUT);
}
// Read next byte from incoming PS/2 buffer, or 0 when empty
static byte readPs2Buffer()
{
byte value = 0;
if (head != tail) {
value = ps2Buffer[tail];
tail = (tail + 1) % sizeof ps2Buffer;
}
return value;
}
byte keyboard_getState()
{
word now = (word) millis(); // Note: without interrupts millis() stops counting
for (;;) {
word value = readPs2Buffer();
if (value == 0) { // Buffer is empty
if (now - lastChange > hold) // Auto-release keys after `hold' milliseconds
ascii = 0;
if (now - lastChange > 1000) // Hold `buttons' a bit longer than the repeat delay. This
flags &= ~255; // is merely a safeguard against missing the break event
// and then ending up with a stuck virtual button press.
break;
}
switch (value) {
// The BREAK or EXTENDED bytes are part of a longer sequence
// Here we don't mind the order they appear in
case 0xe0: flags |= extendedFlag; continue;
case 0xf0: flags |= breakFlag; continue;
case 0xaa: // BAT ok
#define oddParity(x) ((1 ^ x ^ (x>>1) ^ (x>>2) ^ (x>>3) ^ (x>>4) ^ (x>>5) ^ (x>>6) ^ (x>>7)) & 1)
#define code(x) ((1 << 10) | (oddParity(x) << 9) | ((x) << 1))
keyboard_send(code(0xf4)); // Enable (fixes Walter's PERIBOARD-409)
continue;
}
if (flags & extendedFlag)
value |= 0xe0 << 8; // Simplify our switch statements
// Recognize modifier keys
word modifier = 0;
switch (value) {
case 0x11: modifier = altFlag; break;
case 0x12: modifier = leftShiftFlag; break;
case 0x14: modifier = leftCtrlFlag; break;
case 0x59: modifier = rightShiftFlag; break;
case 0xe011: modifier = altGrFlag; break;
case 0xe014: modifier = rightCtrlFlag; break;
}
// Case 1: Handle modifier keys
if (modifier) {
if (flags & breakFlag)
flags &= ~modifier; // Modifier key released
else
flags |= modifier; // Modifier key pressed
nextPs2(); // Reset PS/2 sequence
continue; // Back to reading from buffer
}
// Recognize character and control keys and map them to ASCII
// or game controller buttons
// Always return an updated state to the caller from this point on,
// even if there are still bytes waiting in the buffer.
byte button = 0;
byte newAscii = 0;
switch (value) {
// Extended codes in "Set 2"
case 0xe075: button = buttonUp; break; // [UpArrow]
case 0xe06b: button = buttonLeft; break; // [LeftArrow]
case 0xe072: button = buttonDown; break; // [DownArrow]
case 0xe074: button = buttonRight; break; // [RightArrow]
case 0x66: // [BackSpace]
case 0xe071: if ((flags & ctrlFlags) // [Delete]
&& (flags & altFlags))
newAscii = CTRLALTDEL; // [Ctrl-Alt-Del] becomes [Start]
else
button = buttonA; break; // ASCII DEL is 127 is ~buttonA
case 0xe069: button = buttonA; break; // [End]
case 0xe070: // [Insert]
case 0xe06c: button = buttonB; break; // [Home]
case 0xe07a: button = buttonSelect; break; // [PageDown]
case 0xe07d: button = buttonStart; break; // [PageUp]
case 0xe04a: newAscii = '/'; break; // [/] on numeric island
case 0xe05a: newAscii = '\n'; break; // [Enter] on numeric island
default:
// Apply keyboard mapping to ASCII
if ((flags & altGrFlag) ||
((flags & ctrlFlags) && (flags & altFlag))) // Ctrl+Alt is AltGr
newAscii = lookup(ALTGR, value);
else if (flags & shiftFlags)
newAscii = lookup(SHIFT, value);
else
newAscii = lookup(NOMOD, value);
// Handle control key combinations
if (flags & ctrlFlags)
switch (newAscii) {
case '?': newAscii = 127; break; // Traditional mapping of Ctrl-? to DEL
case ' ': button = 255; break; // Make it send a 0 byte
default:
byte f = fnKey(newAscii);
if (f) {
if (flags & altFlags)
// Ctrl-Alt-Fxx changes the keymap
EEPROM.write(offsetof(struct EEPROMlayout, keymapIndex), f-1);
else
// Ctrl+Fxx are BabelFish commands
newAscii ^= 64;
} else
// Make control codes (what the key is for...)
newAscii &= 31;
}
}
// Consolidate the `flags' and `ascii' states
if (button) { // Case 2: Simulated game controller buttons
lastChange = now;
if (flags & breakFlag)
flags &= ~button; // Button released
else
flags |= button; // Button pressed
ascii = 0;
} else { // Case 3: ASCII keys
if (newAscii != ascii)
lastChange = now;
if (~flags & breakFlag) // Ignore ASCII release events (use 'hold' instead)
ascii = newAscii; // ASCII pressed
hold = 35; // Hold for 3 frames (less than the repeat rate)
if (ascii == CTRLALTDEL) // At least 2 seconds for the [Start] signal
hold = max(500 + now - lastChange, 2500); // No accidental Easter Egg trigger (8b guy)
flags &= ~255;
}
nextPs2(); // Reset PS/2 sequence
break; // Always return, leave anything in buffer behind
}
// Return the newly determined state to caller
return ascii ? ascii : (255 & ~flags);
}
// Return 0 if not a function key, or its ordinal otherwise
byte fnKey(byte key)
{
return (PS2_F1 <= key && key <= PS2_F12) ? (key & 15) : 0;
}
// 'code' must include start, data, parity and stop bits
void keyboard_send(word code)
{
// 1. Bring the Clock line low for at least 100 microseconds
forbidPs2();
delayMicroseconds(100);
// 2. Bring the data line low
digitalWrite(keyboardDataPin, 0);
pinMode(keyboardDataPin, OUTPUT);
// 3. Release the Clock line
allowPs2();
// Pull-up resistor will bring clock line up first
do {
// 6. Wait for the device to bring Clock high
while (digitalRead(keyboardClockPin) == 0)
;
// 4. 7. Wait for the device to bring the Clock line low
// MvK: Falling edge transfers the data
while (digitalRead(keyboardClockPin) != 0)
;
// 5. Set/reset the Data line to send the next data bit
code >>= 1;
if (code & 1)
pinMode(keyboardDataPin, INPUT_PULLUP); // To send 1
else {
digitalWrite(keyboardDataPin, 0);
pinMode(keyboardDataPin, OUTPUT); // To send 0
}
// 8. Repeat steps 5-7 for the other seven data bits and the parity bit
// 9. Release the Data line
} while (code > 1);
pinMode(keyboardDataPin, INPUT_PULLUP);
// 10. Wait for the device to bring Data low
while (digitalRead(keyboardDataPin) != 0)
;
// 11. Wait for the device to bring Clock low
while (digitalRead(keyboardClockPin) != 0)
;
// 12. Wait for the device to release Data and Clock
while (digitalRead(keyboardClockPin) == 0 || digitalRead(keyboardDataPin) == 0)
;
}
@@ -0,0 +1,26 @@
0x06, 0x00, 0x00, // 256 bytes at $0600
0xcd, 0x4a, 0x2b, 0x30, 0xe6, 0x52, 0x35, 0x53, 0x10, 0xe3, 0x32,
0x2b, 0x32, 0x11, 0x00, 0x07, 0x90, 0x15, 0x2b, 0x32, 0x11, 0x00,
0x08, 0x2b, 0x34, 0x21, 0x32, 0xe9, 0xe9, 0x99, 0x32, 0x99, 0x34,
0x2b, 0x34, 0x59, 0x20, 0x5e, 0x24, 0x59, 0x0f, 0x5e, 0x25, 0x21,
0x36, 0x2b, 0x28, 0x11, 0xe1, 0x04, 0x2b, 0x22, 0x59, 0xfb, 0x2b,
0x32, 0x21, 0x34, 0x7f, 0x00, 0x93, 0x34, 0x5e, 0x26, 0xb4, 0xcb,
0x93, 0x28, 0x93, 0x32, 0x21, 0x32, 0x35, 0x72, 0x36, 0xff, 0x2b,
0x38, 0x11, 0x00, 0x78, 0x2b, 0x36, 0xcd, 0x9f, 0x59, 0x00, 0x5e,
0x36, 0x11, 0x00, 0x08, 0x99, 0x36, 0x35, 0x53, 0x62, 0x11, 0x00,
0x08, 0x2b, 0x36, 0x21, 0x36, 0x2b, 0x28, 0x59, 0x20, 0x5e, 0x24,
0x5e, 0x25, 0x11, 0xe1, 0x04, 0x2b, 0x22, 0xb4, 0xcb, 0x93, 0x28,
0x1a, 0x28, 0x8c, 0xa0, 0x35, 0x72, 0x73, 0x11, 0xee, 0x01, 0x2b,
0x3a, 0x21, 0x3a, 0xad, 0xe6, 0x78, 0x35, 0x53, 0x8f, 0x8c, 0x80,
0x90, 0x91, 0x8c, 0x08, 0xf0, 0x3a, 0x21, 0x3a, 0xe6, 0x02, 0x2b,
0x3a, 0x8c, 0xfe, 0x35, 0x72, 0x83, 0xff, 0x2b, 0x3c, 0xcf, 0x18,
0x59, 0x7f, 0xcf, 0x38, 0x1a, 0x0f, 0x2b, 0x3e, 0x1a, 0x0f, 0x2b,
0x30, 0xfc, 0x3e, 0x35, 0x72, 0xb8, 0x21, 0x30, 0x90, 0xa9, 0x21,
0x30, 0x8c, 0x0a, 0x35, 0x72, 0xc7, 0x59, 0x20, 0xcf, 0x38, 0xcf,
0x3c, 0x90, 0xa3, 0x21, 0x30, 0x8c, 0x7f, 0x35, 0x72, 0xdf, 0x59,
0x20, 0xcf, 0x38, 0x1a, 0x36, 0xe6, 0x06, 0x35, 0x53, 0xdb, 0x59,
0x00, 0x5e, 0x36, 0x90, 0xa3, 0x21, 0x30, 0xe6, 0x20, 0x35, 0x50,
0xa3, 0xe6, 0x5f, 0x35, 0x53, 0xa3, 0x21, 0x30, 0xcf, 0x38, 0x1a,
0x36, 0xe3, 0x06, 0x5e, 0x36, 0xe6, 0x9b, 0x35, 0x50, 0xfc, 0xcf,
0x3c, 0x90, 0xa3,
0x00, 0x06, 0x00 // Start at $0600
@@ -0,0 +1,596 @@
// Converted from Apps/WozMon.gt1 by Makefile
0x02,
0x00,
0xe2,
0xcd,
0x0a,
0x2a,
0x2a,
0x20,
0x57,
0x6f,
0x7a,
0x4d,
0x6f,
0x6e,
0x00,
0x2b,
0x30,
0x11,
0xdf,
0x01,
0xf6,
0x2b,
0x32,
0xcd,
0x60,
0xe6,
0x52,
0x35,
0x53,
0x22,
0xe3,
0x32,
0x2b,
0x34,
0x11,
0x00,
0x07,
0x90,
0x27,
0x2b,
0x34,
0x11,
0x00,
0x08,
0x2b,
0x36,
0x21,
0x34,
0xe9,
0xe9,
0x99,
0x34,
0x99,
0x36,
0x2b,
0x36,
0x11,
0xe1,
0x04,
0x2b,
0x22,
0x21,
0x2a,
0x2b,
0x24,
0x21,
0x32,
0x2b,
0x28,
0xec,
0xfe,
0xe3,
0x06,
0x2b,
0x32,
0x59,
0x05,
0x2b,
0x34,
0x21,
0x36,
0x7f,
0x00,
0x5e,
0x26,
0xb4,
0xcb,
0x93,
0x36,
0x93,
0x28,
0x21,
0x34,
0xe6,
0x01,
0x35,
0x4d,
0x48,
0xee,
0xfe,
0xff,
0x2b,
0x38,
0xcd,
0xad,
0x1a,
0x32,
0x35,
0x3f,
0xac,
0x11,
0xe1,
0x04,
0x2b,
0x22,
0x11,
0x00,
0x08,
0x5e,
0x32,
0x99,
0x32,
0x35,
0x53,
0x7b,
0x11,
0x00,
0x08,
0x2b,
0x32,
0x2b,
0x28,
0x5e,
0x26,
0xb4,
0xcb,
0x93,
0x28,
0x1a,
0x28,
0x8c,
0xa0,
0x35,
0x72,
0x81,
0x11,
0xee,
0x01,
0x2b,
0x34,
0x21,
0x34,
0xad,
0xe6,
0x78,
0x35,
0x53,
0x9d,
0x8c,
0x80,
0x90,
0x9f,
0x8c,
0x08,
0xf0,
0x34,
0x21,
0x34,
0xe6,
0x02,
0x2b,
0x34,
0x8c,
0xfe,
0x35,
0x72,
0x91,
0xff,
0x2b,
0x3a,
0xcd,
0xd9,
0x75,
0x2b,
0x30,
0x11,
0x52,
0x06,
0x2b,
0x22,
0x21,
0x30,
0xb4,
0xf5,
0xe6,
0x0a,
0x35,
0x50,
0xc4,
0xe3,
0x07,
0xe3,
0x3a,
0xcf,
0x38,
0x21,
0x30,
0x82,
0x0f,
0xe6,
0x0a,
0x35,
0x50,
0xd3,
0xe3,
0x07,
0xe3,
0x3a,
0xcf,
0x38,
0x63,
0xff,
0x2b,
0x3c,
0x11,
0x00,
0x03,
0xcf,
0x18,
0x03,
0x00,
0xf3,
0xcd,
0xd3,
0x75,
0x59,
0x80,
0x2b,
0x3e,
0xcf,
0x3a,
0x93,
0x3e,
0x21,
0x3e,
0xad,
0x35,
0x3f,
0xd1,
0xe6,
0x2e,
0x35,
0x50,
0x07,
0x35,
0x72,
0x1d,
0x59,
0x01,
0x2b,
0x40,
0x90,
0x07,
0xe6,
0x0c,
0x35,
0x72,
0x28,
0xe6,
0x01,
0x2b,
0x40,
0x90,
0x07,
0xe6,
0x18,
0x35,
0x72,
0x31,
0xcf,
0x42,
0x90,
0x07,
0x59,
0x00,
0x2b,
0x30,
0x2b,
0x44,
0xe9,
0xe9,
0xe9,
0xe9,
0x2b,
0x34,
0x21,
0x3e,
0xad,
0x93,
0x3e,
0xe6,
0x30,
0x35,
0x50,
0x68,
0xe6,
0x0a,
0x35,
0x53,
0x54,
0x2b,
0x30,
0xe3,
0x0a,
0x99,
0x34,
0x90,
0x35,
0xe6,
0x06,
0x82,
0x1f,
0x35,
0x56,
0x68,
0xe6,
0x07,
0x35,
0x53,
0x68,
0x2b,
0x30,
0xe3,
0x10,
0x99,
0x34,
0x90,
0x35,
0x21,
0x30,
0x35,
0x3f,
0xcd,
0x21,
0x3e,
0xe6,
0x02,
0x2b,
0x3e,
0x21,
0x40,
0x35,
0x53,
0x84,
0x21,
0x44,
0xf0,
0x46,
0x21,
0x46,
0xe3,
0x01,
0x2b,
0x46,
0x90,
0x07,
0x35,
0x72,
0x91,
0xcf,
0x3a,
0x21,
0x44,
0x2b,
0x46,
0xe6,
0x01,
0x2b,
0x42,
0x21,
0x42,
0xb8,
0x44,
0x35,
0x53,
0xc7,
0x21,
0x42,
0xe3,
0x01,
0x2b,
0x42,
0x82,
0x07,
0x35,
0x72,
0xa5,
0xcf,
0x3a,
0x1a,
0x32,
0x35,
0x72,
0xba,
0x59,
0x02,
0x5e,
0x32,
0x1a,
0x43,
0xcf,
0x3c,
0x1a,
0x42,
0xcf,
0x3c,
0x59,
0x3a,
0xcf,
0x38,
0x21,
0x32,
0xe3,
0x04,
0x2b,
0x32,
0x21,
0x42,
0xad,
0xcf,
0x3c,
0x90,
0x91,
0x59,
0x00,
0x2b,
0x40,
0x90,
0x07,
0x59,
0x5c,
0xcf,
0x38,
0x63,
0xff,
0x2b,
0x48,
0x93,
0x32,
0x11,
0x20,
0x0f,
0x2b,
0x2a,
0x5e,
0x24,
0xcf,
0x3a,
0x59,
0x2a,
0xcf,
0x38,
0x21,
0x30,
0xad,
0x93,
0x30,
0x35,
0x72,
0xe2,
0x11,
0x00,
0x04,
0xcf,
0x18,
0x04,
0x00,
0x72,
0x59,
0x81,
0x2b,
0x3e,
0xcf,
0x3a,
0x59,
0x7f,
0x5e,
0x2b,
0xcf,
0x38,
0x2b,
0x32,
0x1a,
0x0f,
0x2b,
0x30,
0x1a,
0x0f,
0xf0,
0x3e,
0xfc,
0x30,
0x35,
0x72,
0x1e,
0x21,
0x3e,
0xad,
0x90,
0x0e,
0x21,
0x3e,
0xad,
0x8c,
0x0a,
0x35,
0x3f,
0x60,
0x8c,
0x75,
0x35,
0x72,
0x42,
0x59,
0x20,
0xcf,
0x38,
0x2b,
0x32,
0x1a,
0x32,
0xe6,
0x06,
0x35,
0x50,
0x40,
0x5e,
0x32,
0x21,
0x3e,
0xe6,
0x01,
0x2b,
0x3e,
0x90,
0x04,
0xe6,
0x60,
0x35,
0x53,
0x04,
0x1a,
0x32,
0x8c,
0x96,
0x35,
0x72,
0x57,
0x59,
0x5c,
0xcf,
0x38,
0x11,
0x00,
0x04,
0xcf,
0x18,
0x21,
0x3e,
0xad,
0xcf,
0x38,
0x93,
0x3e,
0x90,
0x04,
0xf0,
0x3e,
0x2b,
0x40,
0x59,
0x20,
0xcf,
0x38,
0x59,
0x0f,
0x5e,
0x2b,
0xcf,
0x48,
0x90,
0xfe,
0x00,
0x02,
0x00,
@@ -0,0 +1,97 @@
// Generated by tinyfont.py
0x0000, // ' '
0x03a0, // '!'
0x6018, // '"'
0x7d5f, // '#'
0x2bf4, // '$'
0x4889, // '%'
0x2aab, // '&'
0x0300, // "'"
0x01d1, // '('
0x45c0, // ')'
0x288a, // '*'
0x11c4, // '+'
0x0440, // ','
0x1084, // '-'
0x0020, // '.'
0x0888, // '/'
0x3e3e, // '0'
0x27e1, // '1'
0x4ea9, // '2'
0x56aa, // '3'
0x709f, // '4'
0x76b2, // '5'
0x3eb7, // '6'
0x4e98, // '7'
0x7ebf, // '8'
0x76be, // '9'
0x0140, // ':'
0x0540, // ';'
0x1151, // '<'
0x294a, // '='
0x4544, // '>'
0x42b8, // '?'
0x3a3d, // '@'
0x3e8f, // 'A'
0x7eaa, // 'B'
0x3a31, // 'C'
0x7e2e, // 'D'
0x7eb1, // 'E'
0x7e90, // 'F'
0x3e37, // 'G'
0x7c9f, // 'H'
0x47f1, // 'I'
0x0a3e, // 'J'
0x7c9b, // 'K'
0x7c21, // 'L'
0x7d9f, // 'M'
0x7ddf, // 'N'
0x7e3f, // 'O'
0x7e4c, // 'P'
0x3a6f, // 'Q'
0x7ecd, // 'R'
0x26b2, // 'S'
0x43f0, // 'T'
0x7c3f, // 'U'
0x783e, // 'V'
0x7cdf, // 'W'
0x6c9b, // 'X'
0x70fc, // 'Y'
0x4eb9, // 'Z'
0x03f1, // '['
0x2082, // '\\'
0x47e0, // ']'
0x2208, // '^'
0x0421, // '_'
0x4100, // '`'
0x1d2f, // 'a'
0x7d26, // 'b'
0x1929, // 'c'
0x193f, // 'd'
0x196d, // 'e'
0x11f4, // 'f'
-0x4d42, // 'g'
0x7d07, // 'h'
0x16e1, // 'i'
-0x76d2, // 'j'
0x7c8b, // 'k'
0x47e1, // 'l'
0x3dcf, // 'm'
0x3d07, // 'n'
0x1926, // 'o'
-0x01b4, // 'p'
-0x4da1, // 'q'
0x3c88, // 'r'
0x15ea, // 's'
0x23e9, // 't'
0x382f, // 'u'
0x386e, // 'v'
0x3cef, // 'w'
0x24c9, // 'x'
-0x1f42, // 'y'
0x256d, // 'z'
0x13f1, // '{'
0x03e0, // '|'
0x47e4, // '}'
0x2310, // '~'
0x7fff, // '\x7f'
@@ -0,0 +1,97 @@
#-----------------------------------------------------------------------
#
# tinyfont.py -- a very small font
#
#-----------------------------------------------------------------------
#
# Description:
#
# The tiny font is an 3x5 pixel monospaced font where each character
# is placed in a box of 4x6 pixels. At the native 160x120 Gigatron
# resolution we can display 40x20 characters.
#
# The encoding has 3x5 bits for the pixels and 1 shift bit to indicate
# an overall shift down for characters g, j, p, q and y. The lowercase
# j needs special handling. This scheme gives 2 bytes per character,
# for a total of 192 bytes.
#
# References:
#
# http://vt100.tarunz.org
# VT100 Terminal for Pilot (Brian J. Swetland)
#
# https://robey.lag.net/2010/01/23/tiny-monospace-font.html
# A very tiny, monospace, bitmap font (Robey Pointer)
#
# https://fonts2u.com/small-5x3-regular.font
# Small 5X3 regular (soxhead2000)
#
# https://github.com/olikraus/u8g2
# U8glib library for monochrome displays, version 2
#
# History:
#
# 2018-08-01 (marcelk) Initial version inspired by open source examples
# 2018-08-xx (marcelk) Update of @corz
#
#-----------------------------------------------------------------------
def convert(font):
for c in range(96):
i, j = c % 16, c / 16
word, shift = 0, 0
for y in range(6):
for x in range(3):
p = ((j * 6 + y) * 16 + i) * 4 + x + 1
if font[p] == '@':
if y == 5 and shift == 0:
shift, word = 1, word << 1
word |= 1 << (5*(3-x) - y - 1 + shift)
if shift == 0:
print ' 0x%04x,' % word,
else:
print '-0x%04x,' % (0x8000 - word),
print '// %s' % repr(chr(32+c))
tinyfont =\
'......@..@.@.@.@..@@.@....@...@....@.@..........................'\
'......@..@.@.@@@.@@....@.@.@..@...@...@..@.@..@................@'\
'......@......@.@..@@..@...@.......@...@...@..@@@.....@@@......@.'\
'.............@@@.@@..@...@.@......@...@..@.@..@...@..........@..'\
'......@......@.@..@....@..@@.......@.@...........@........@.....'\
'................................................................'\
'..@@..@..@@..@@..@.@.@@@..@@.@@@.@@@.@@@...........@.....@...@@@'\
'.@.@.@@....@...@.@.@.@...@.....@.@.@.@.@..@...@...@..@@@..@....@'\
'.@.@..@...@..@@..@@@.@@..@@@..@..@@@.@@@.........@.........@..@.'\
'.@.@..@..@.....@...@...@.@.@.@...@.@...@..@...@...@..@@@..@.....'\
'.@@..@@@.@@@.@@....@.@@..@@@.@...@@@.@@......@.....@.....@....@.'\
'................................................................'\
'..@@..@..@@...@@.@@..@@@.@@@..@@.@.@.@@@..@@.@.@.@...@.@.@.@.@@@'\
'.@.@.@.@.@.@.@...@.@.@...@...@...@.@..@....@.@.@.@...@@@.@@@.@.@'\
'.@.@.@@@.@@..@...@.@.@@..@@..@.@.@@@..@....@.@@..@...@@@.@@@.@.@'\
'.@...@.@.@.@.@...@.@.@...@...@.@.@.@..@..@.@.@.@.@...@.@.@@@.@.@'\
'..@@.@.@.@@...@@.@@..@@@.@...@@@.@.@.@@@..@..@.@.@@@.@.@.@.@.@@@'\
'................................................................'\
'.@@...@..@@...@@.@@@.@.@.@.@.@.@.@.@.@.@.@@@..@@.....@@...@.....'\
'.@.@.@.@.@.@.@....@..@.@.@.@.@.@.@.@.@.@...@..@..@....@..@.@....'\
'.@.@.@.@.@@@..@...@..@.@.@.@.@@@..@..@@@..@...@...@...@.........'\
'.@@..@@@.@@....@..@..@.@.@.@.@@@.@.@..@..@....@....@..@.........'\
'.@....@@.@.@.@@...@..@@@..@..@.@.@.@..@..@@@..@@.....@@......@@@'\
'................................................................'\
'.@.......@.........@.......@.....@....@....O.@...@@.............'\
'..@...@@.@@...@@..@@..@@..@...@@.@@..........@.@..@..@@@.@@...@.'\
'.....@.@.@.@.@...@.@.@.@.@@@.@.@.@.@.@@...@@.@@...@..@@@.@.@.@.@'\
'.....@.@.@.@.@...@.@.@@...@..@@@.@.@..@....@.@.@..@..@@@.@.@.@.@'\
'.....@@@.@@...@@..@@..@@..@....@.@.@.@@@.@.@.@.@.@@@.@.@.@.@..@.'\
'..............................@.......... @.....................'\
'..................@...........................@@..@..@@...@@.@@@'\
'.@@...@@.@.@..@@.@@@.@.@.@.@.@.@.@.@.@.@.@@@..@...@...@..@@..@@@'\
'.@.@.@.@.@@..@@...@..@.@.@.@.@@@..@..@.@...@.@@...@...@@.....@@@'\
'.@.@.@.@.@....@@..@..@.@.@@@.@@@..@...@@..@...@...@...@......@@@'\
'.@@...@@.@...@@...@@..@@..@..@@@.@.@...@.@@@..@@..@..@@......@@@'\
'.@.....@..............................@.........................'
print '// Generated by tinyfont.py'
convert(tinyfont)
+11
View File
@@ -0,0 +1,11 @@
# Pluggy Reloaded
A new variant with the Arduino Nano Every with the new ATmega4809 CPU.
- 48KB Flash
- 6KB RAM
- 256B EEPROM
The reason it is at the moment better to get than the Pro Micro and in addition still more favorably (Reichelt approx. 10€)
I have also provided an I2C EEPROM, but have not made any software for it yet. I inserted and tested the board with the Arduino Nano Every 4809 in the existing software.
![PluggyReloadedEvery](picture/PluggyReloadedEvery.jpg)
@@ -0,0 +1,207 @@
<!--This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA) with Design Exception 1.0-->
<eagle version="7.1.0">
<drawing>
<settings>
<setting alwaysvectorfont="no"/>
<setting verticaltext="up"/>
</settings>
<grid distance="0.1" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.01" altunitdist="inch" altunit="inch"/>
<layers>
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>
<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>
<layer number="19" name="Unrouted" color="6" fill="1" visible="yes" active="yes"/>
<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="yes"/>
<layer number="21" name="tPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="22" name="bPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="23" name="tOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="26" name="bNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="28" name="bValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="29" name="tStop" color="7" fill="3" visible="yes" active="yes"/>
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="yes"/>
<layer number="31" name="tCream" color="7" fill="4" visible="yes" active="yes"/>
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="yes"/>
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="yes"/>
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="yes"/>
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="yes"/>
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="yes"/>
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="yes"/>
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="yes"/>
<layer number="39" name="tKeepout" color="4" fill="11" visible="yes" active="yes"/>
<layer number="40" name="bKeepout" color="1" fill="11" visible="yes" active="yes"/>
<layer number="41" name="tRestrict" color="4" fill="10" visible="yes" active="yes"/>
<layer number="42" name="bRestrict" color="1" fill="10" visible="yes" active="yes"/>
<layer number="43" name="vRestrict" color="2" fill="10" visible="yes" active="yes"/>
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="yes"/>
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="yes"/>
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="yes"/>
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="yes"/>
<layer number="48" name="Document" color="7" fill="1" visible="yes" active="yes"/>
<layer number="49" name="Reference" color="7" fill="1" visible="yes" active="yes"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="90" name="Modules" color="5" fill="1" visible="yes" active="yes"/>
<layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"/>
<layer number="92" name="Busses" color="1" fill="1" visible="yes" active="yes"/>
<layer number="93" name="Pins" color="2" fill="1" visible="yes" active="yes"/>
<layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"/>
<layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"/>
<layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"/>
<layer number="97" name="Info" color="7" fill="1" visible="yes" active="yes"/>
<layer number="98" name="Guide" color="6" fill="1" visible="yes" active="yes"/>
</layers>
<library>
<packages>
<package name="MODULE_ABX00028">
<wire x1="-21.59" y1="-8.89" x2="21.59" y2="-8.89" width="0.127" layer="21"/>
<wire x1="21.59" y1="-8.89" x2="21.59" y2="8.89" width="0.127" layer="21"/>
<wire x1="21.59" y1="8.89" x2="-21.59" y2="8.89" width="0.127" layer="21"/>
<wire x1="-21.59" y1="8.89" x2="-21.59" y2="-8.89" width="0.127" layer="21"/>
<wire x1="-21.59" y1="-8.89" x2="21.59" y2="-8.89" width="0.127" layer="51"/>
<wire x1="21.59" y1="-8.89" x2="21.59" y2="8.89" width="0.127" layer="51"/>
<wire x1="21.59" y1="8.89" x2="-21.59" y2="8.89" width="0.127" layer="51"/>
<wire x1="-21.84" y1="-9.14" x2="21.84" y2="-9.14" width="0.05" layer="39"/>
<wire x1="21.84" y1="-9.14" x2="21.84" y2="9.14" width="0.05" layer="39"/>
<wire x1="21.84" y1="9.14" x2="-21.84" y2="9.14" width="0.05" layer="39"/>
<wire x1="-21.84" y1="9.14" x2="-21.84" y2="-9.14" width="0.05" layer="39"/>
<circle x="-17.78" y="-9.5" radius="0.1" width="0.2" layer="21"/>
<circle x="-17.78" y="-9.5" radius="0.1" width="0.2" layer="51"/>
<wire x1="-21.59" y1="8.89" x2="-21.59" y2="-8.89" width="0.127" layer="51"/>
<text x="-21.5" y="10" size="1.27" layer="25">&gt;NAME</text>
<text x="-21.5" y="-10" size="1.27" layer="27" align="top-left">&gt;VALUE</text>
<pad name="1" x="-17.78" y="-7.62" drill="1.016" shape="square"/>
<pad name="2" x="-15.24" y="-7.62" drill="1.016"/>
<pad name="3" x="-12.7" y="-7.62" drill="1.016"/>
<pad name="4" x="-10.16" y="-7.62" drill="1.016"/>
<pad name="5" x="-7.62" y="-7.62" drill="1.016"/>
<pad name="6" x="-5.08" y="-7.62" drill="1.016"/>
<pad name="7" x="-2.54" y="-7.62" drill="1.016"/>
<pad name="8" x="0" y="-7.62" drill="1.016"/>
<pad name="9" x="2.54" y="-7.62" drill="1.016"/>
<pad name="10" x="5.08" y="-7.62" drill="1.016"/>
<pad name="11" x="7.62" y="-7.62" drill="1.016"/>
<pad name="12" x="10.16" y="-7.62" drill="1.016"/>
<pad name="13" x="12.7" y="-7.62" drill="1.016"/>
<pad name="14" x="15.24" y="-7.62" drill="1.016"/>
<pad name="15" x="17.78" y="-7.62" drill="1.016"/>
<pad name="16" x="17.78" y="7.62" drill="1.016" rot="R180"/>
<pad name="17" x="15.24" y="7.62" drill="1.016" rot="R180"/>
<pad name="18" x="12.7" y="7.62" drill="1.016" rot="R180"/>
<pad name="19" x="10.16" y="7.62" drill="1.016" rot="R180"/>
<pad name="20" x="7.62" y="7.62" drill="1.016" rot="R180"/>
<pad name="21" x="5.08" y="7.62" drill="1.016" rot="R180"/>
<pad name="22" x="2.54" y="7.62" drill="1.016" rot="R180"/>
<pad name="23" x="0" y="7.62" drill="1.016" rot="R180"/>
<pad name="24" x="-2.54" y="7.62" drill="1.016" rot="R180"/>
<pad name="25" x="-5.08" y="7.62" drill="1.016" rot="R180"/>
<pad name="26" x="-7.62" y="7.62" drill="1.016" rot="R180"/>
<pad name="27" x="-10.16" y="7.62" drill="1.016" rot="R180"/>
<pad name="28" x="-12.7" y="7.62" drill="1.016" rot="R180"/>
<pad name="29" x="-15.24" y="7.62" drill="1.016" rot="R180"/>
<pad name="30" x="-17.78" y="7.62" drill="1.016" rot="R180"/>
<hole x="-20.32" y="-7.62" drill="1.651"/>
<hole x="-20.32" y="7.62" drill="1.651"/>
<hole x="20.32" y="7.62" drill="1.651"/>
<hole x="20.32" y="-7.62" drill="1.651"/>
</package>
</packages>
<symbols>
<symbol name="ABX00028">
<wire x1="-15.24" y1="-27.94" x2="-15.24" y2="25.4" width="0.254" layer="94"/>
<wire x1="-15.24" y1="25.4" x2="15.24" y2="25.4" width="0.254" layer="94"/>
<wire x1="15.24" y1="25.4" x2="15.24" y2="-27.94" width="0.254" layer="94"/>
<wire x1="15.24" y1="-27.94" x2="-15.24" y2="-27.94" width="0.254" layer="94"/>
<text x="-15.24" y="26.289" size="1.778" layer="95">&gt;NAME</text>
<text x="-15.24" y="-30.48" size="1.778" layer="96">&gt;VALUE</text>
<pin name="D13" x="20.32" y="-20.32" length="middle" rot="R180"/>
<pin name="+3V3" x="20.32" y="20.32" length="middle" direction="pwr" rot="R180"/>
<pin name="AREF" x="-20.32" y="7.62" length="middle"/>
<pin name="A0/DAC0" x="-20.32" y="2.54" length="middle"/>
<pin name="+5V" x="20.32" y="17.78" length="middle" direction="pwr" rot="R180"/>
<pin name="!RESET" x="-20.32" y="12.7" length="middle" direction="in"/>
<pin name="GND" x="20.32" y="-25.4" length="middle" direction="pwr" rot="R180"/>
<pin name="VIN" x="20.32" y="22.86" length="middle" direction="pwr" rot="R180"/>
<pin name="A1" x="-20.32" y="0" length="middle"/>
<pin name="A2" x="-20.32" y="-2.54" length="middle"/>
<pin name="A3" x="-20.32" y="-5.08" length="middle"/>
<pin name="A4/SDA" x="-20.32" y="-7.62" length="middle"/>
<pin name="A5/SCL" x="-20.32" y="-10.16" length="middle"/>
<pin name="A6" x="-20.32" y="-12.7" length="middle"/>
<pin name="A7" x="-20.32" y="-15.24" length="middle"/>
<pin name="TX" x="-20.32" y="-22.86" length="middle"/>
<pin name="RX" x="-20.32" y="-20.32" length="middle"/>
<pin name="D2" x="20.32" y="-10.16" length="middle" rot="R180"/>
<pin name="D3/PWM" x="20.32" y="12.7" length="middle" rot="R180"/>
<pin name="D4" x="20.32" y="-12.7" length="middle" rot="R180"/>
<pin name="D5/PWM" x="20.32" y="10.16" length="middle" rot="R180"/>
<pin name="D6/PWM" x="20.32" y="7.62" length="middle" rot="R180"/>
<pin name="D8" x="20.32" y="-17.78" length="middle" rot="R180"/>
<pin name="D7" x="20.32" y="-15.24" length="middle" rot="R180"/>
<pin name="D9/PWM" x="20.32" y="5.08" length="middle" rot="R180"/>
<pin name="D10/PWM" x="20.32" y="2.54" length="middle" rot="R180"/>
<pin name="D11/MOSI" x="20.32" y="-2.54" length="middle" rot="R180"/>
<pin name="D12/MISO" x="20.32" y="-5.08" length="middle" rot="R180"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="ABX00028" prefix="U">
<description>ATmega4809 Arduino Nano Every AVR AVR MCU 8-Bit Embedded Evaluation Board &lt;a href="https://pricing.snapeda.com/parts/Arduino%20Nano%20Every/Arduino/view-part?ref=eda"&gt;Check availability&lt;/a&gt;</description>
<gates>
<gate name="G$1" symbol="ABX00028" x="0" y="0"/>
</gates>
<devices>
<device name="" package="MODULE_ABX00028">
<connects>
<connect gate="G$1" pin="!RESET" pad="13 18"/>
<connect gate="G$1" pin="+3V3" pad="2"/>
<connect gate="G$1" pin="+5V" pad="12"/>
<connect gate="G$1" pin="A0/DAC0" pad="4"/>
<connect gate="G$1" pin="A1" pad="5"/>
<connect gate="G$1" pin="A2" pad="6"/>
<connect gate="G$1" pin="A3" pad="7"/>
<connect gate="G$1" pin="A4/SDA" pad="8"/>
<connect gate="G$1" pin="A5/SCL" pad="9"/>
<connect gate="G$1" pin="A6" pad="10"/>
<connect gate="G$1" pin="A7" pad="11"/>
<connect gate="G$1" pin="AREF" pad="3"/>
<connect gate="G$1" pin="D10/PWM" pad="28"/>
<connect gate="G$1" pin="D11/MOSI" pad="29"/>
<connect gate="G$1" pin="D12/MISO" pad="30"/>
<connect gate="G$1" pin="D13" pad="1"/>
<connect gate="G$1" pin="D2" pad="20"/>
<connect gate="G$1" pin="D3/PWM" pad="21"/>
<connect gate="G$1" pin="D4" pad="22"/>
<connect gate="G$1" pin="D5/PWM" pad="23"/>
<connect gate="G$1" pin="D6/PWM" pad="24"/>
<connect gate="G$1" pin="D7" pad="25"/>
<connect gate="G$1" pin="D8" pad="26"/>
<connect gate="G$1" pin="D9/PWM" pad="27"/>
<connect gate="G$1" pin="GND" pad="14 19"/>
<connect gate="G$1" pin="RX" pad="17"/>
<connect gate="G$1" pin="TX" pad="16"/>
<connect gate="G$1" pin="VIN" pad="15"/>
</connects>
<technologies>
<technology name="">
<attribute name="Availability" value="In Stock"/>
<attribute name="Price" value="None"/>
<attribute name="MP" value="Arduino Nano Every"/>
<attribute name="Package" value="None"/>
<attribute name="Description" value="
Arduino’s 5V compatible board in the smallest available form factor: 45x18mm!
"/>
<attribute name="Purchase-URL" value="https://pricing.snapeda.com/search/part/Arduino Nano Every/?ref=eda"/>
<attribute name="MF" value="Arduino"/>
</technology>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
</drawing>
</eagle>
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE eagle SYSTEM "eagle.dtd">
<eagle version="9.6.2">
<drawing>
<settings>
<setting alwaysvectorfont="no"/>
<setting verticaltext="up"/>
</settings>
<grid distance="50" unitdist="mil" unit="mm" style="lines" multiple="1" display="yes" altdistance="5" altunitdist="mil" altunit="mil"/>
<layers>
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>
<layer number="2" name="Route2" color="16" fill="1" visible="no" active="yes"/>
<layer number="3" name="Route3" color="17" fill="1" visible="no" active="yes"/>
<layer number="4" name="Route4" color="18" fill="1" visible="no" active="yes"/>
<layer number="5" name="Route5" color="19" fill="1" visible="no" active="yes"/>
<layer number="6" name="Route6" color="25" fill="1" visible="no" active="yes"/>
<layer number="7" name="Route7" color="26" fill="1" visible="no" active="yes"/>
<layer number="8" name="Route8" color="27" fill="1" visible="no" active="yes"/>
<layer number="9" name="Route9" color="28" fill="1" visible="no" active="yes"/>
<layer number="10" name="Route10" color="29" fill="1" visible="no" active="yes"/>
<layer number="11" name="Route11" color="30" fill="1" visible="no" active="yes"/>
<layer number="12" name="Route12" color="20" fill="1" visible="no" active="yes"/>
<layer number="13" name="Route13" color="21" fill="1" visible="no" active="yes"/>
<layer number="14" name="Route14" color="22" fill="1" visible="no" active="yes"/>
<layer number="15" name="Route15" color="23" fill="1" visible="no" active="yes"/>
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>
<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>
<layer number="19" name="Unrouted" color="6" fill="1" visible="yes" active="yes"/>
<layer number="20" name="Dimension" color="24" fill="1" visible="yes" active="yes"/>
<layer number="21" name="tPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="22" name="bPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="23" name="tOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="26" name="bNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="28" name="bValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="29" name="tStop" color="7" fill="3" visible="no" active="yes"/>
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="yes"/>
<layer number="31" name="tCream" color="7" fill="4" visible="no" active="yes"/>
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="yes"/>
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="yes"/>
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="yes"/>
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="yes"/>
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="yes"/>
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="yes"/>
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="yes"/>
<layer number="39" name="tKeepout" color="4" fill="11" visible="yes" active="yes"/>
<layer number="40" name="bKeepout" color="1" fill="11" visible="yes" active="yes"/>
<layer number="41" name="tRestrict" color="4" fill="10" visible="yes" active="yes"/>
<layer number="42" name="bRestrict" color="1" fill="10" visible="yes" active="yes"/>
<layer number="43" name="vRestrict" color="2" fill="10" visible="yes" active="yes"/>
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="yes"/>
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="yes"/>
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="yes"/>
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="yes"/>
<layer number="48" name="Document" color="7" fill="1" visible="yes" active="yes"/>
<layer number="49" name="Reference" color="7" fill="1" visible="yes" active="yes"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="88" name="SimResults" color="9" fill="1" visible="yes" active="yes"/>
<layer number="89" name="SimProbes" color="9" fill="1" visible="yes" active="yes"/>
<layer number="90" name="Modules" color="5" fill="1" visible="yes" active="yes"/>
<layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"/>
<layer number="92" name="Busses" color="1" fill="1" visible="yes" active="yes"/>
<layer number="93" name="Pins" color="2" fill="1" visible="yes" active="yes"/>
<layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"/>
<layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"/>
<layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"/>
<layer number="97" name="Info" color="7" fill="1" visible="yes" active="yes"/>
<layer number="98" name="Guide" color="6" fill="1" visible="yes" active="yes"/>
</layers>
<library>
<packages>
<package name="BREAKOUT_SD">
<pad name="P$1" x="5.08" y="40.005" drill="1" shape="long" rot="R90"/>
<pad name="P$2" x="7.62" y="40.005" drill="1" shape="long" rot="R90"/>
<pad name="P$3" x="10.16" y="40.005" drill="1" shape="long" rot="R90"/>
<pad name="P$4" x="12.7" y="40.005" drill="1" shape="long" rot="R90"/>
<pad name="P$5" x="15.24" y="40.005" drill="1" shape="long" rot="R90"/>
<pad name="P$6" x="17.78" y="40.005" drill="1" shape="long" rot="R90"/>
<wire x1="22.86" y1="0" x2="22.86" y2="43.18" width="0.127" layer="21"/>
<wire x1="22.86" y1="43.18" x2="0" y2="43.18" width="0.127" layer="21"/>
<wire x1="0" y1="43.18" x2="0" y2="0" width="0.127" layer="21"/>
<wire x1="0" y1="0" x2="2.54" y2="0" width="0.127" layer="21"/>
<wire x1="22.86" y1="0" x2="20.32" y2="0" width="0.127" layer="21"/>
<wire x1="3.81" y1="1.27" x2="19.05" y2="1.27" width="0.127" layer="21"/>
<wire x1="2.54" y1="0" x2="3.81" y2="1.27" width="0.127" layer="21"/>
<wire x1="20.32" y1="0" x2="19.05" y2="1.27" width="0.127" layer="21"/>
<wire x1="3.81" y1="1.27" x2="3.81" y2="15.24" width="0.127" layer="21"/>
<wire x1="3.81" y1="15.24" x2="19.05" y2="15.24" width="0.127" layer="21"/>
<wire x1="19.05" y1="15.24" x2="19.05" y2="1.27" width="0.127" layer="21"/>
<text x="5.715" y="35.814" size="1.27" layer="21" rot="R90">CS</text>
<text x="8.255" y="34.544" size="1.27" layer="21" rot="R90">SCK</text>
<text x="10.795" y="33.782" size="1.27" layer="21" rot="R90">MOSI</text>
<text x="13.335" y="33.782" size="1.27" layer="21" rot="R90">MISO</text>
<text x="15.875" y="34.544" size="1.27" layer="21" rot="R90">VCC</text>
<text x="18.415" y="34.29" size="1.27" layer="21" rot="R90">GND</text>
<text x="4.445" y="16.51" size="1.27" layer="21">SD Card Breakout</text>
</package>
</packages>
<symbols>
<symbol name="BREAKOUT_SD">
<pin name="CS" x="2.54" y="20.32" length="middle" rot="R270"/>
<pin name="SCK" x="7.62" y="20.32" length="middle" rot="R270"/>
<pin name="MOSI" x="12.7" y="20.32" length="middle" rot="R270"/>
<pin name="MISO" x="17.78" y="20.32" length="middle" rot="R270"/>
<pin name="VCC" x="22.86" y="20.32" length="middle" rot="R270"/>
<pin name="GND" x="27.94" y="20.32" length="middle" rot="R270"/>
<wire x1="0" y1="22.86" x2="30.48" y2="22.86" width="0.254" layer="94"/>
<wire x1="30.48" y1="22.86" x2="30.48" y2="0" width="0.254" layer="94"/>
<wire x1="30.48" y1="0" x2="0" y2="0" width="0.254" layer="94"/>
<wire x1="0" y1="0" x2="0" y2="22.86" width="0.254" layer="94"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="BREAKOUT_SD">
<gates>
<gate name="G$1" symbol="BREAKOUT_SD" x="-53.34" y="-2.54"/>
</gates>
<devices>
<device name="" package="BREAKOUT_SD">
<connects>
<connect gate="G$1" pin="CS" pad="P$1"/>
<connect gate="G$1" pin="GND" pad="P$6"/>
<connect gate="G$1" pin="MISO" pad="P$4"/>
<connect gate="G$1" pin="MOSI" pad="P$3"/>
<connect gate="G$1" pin="SCK" pad="P$2"/>
<connect gate="G$1" pin="VCC" pad="P$5"/>
</connects>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
</drawing>
</eagle>
File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB