From 331884f79986664a4ba9845b88bdce454ce010a3 Mon Sep 17 00:00:00 2001 From: Charles Mangin Date: Thu, 15 May 2014 14:22:44 -0400 Subject: [PATCH] added debug options for joystick shield --- .DS_Store | Bin 15364 -> 21508 bytes .../joystick_shield_debug.ino | 169 ++++++++++++++++++ .../joystick_shield_no_limit.ino | 169 ++++++++++++++++++ .../Arduino/USB_IIe_Kbd/USB_IIe_Kbd.ino | 28 +++ 4 files changed, 366 insertions(+) create mode 100644 Joystick-Shield/joystick_shield_debug/joystick_shield_debug.ino create mode 100644 Joystick-Shield/joystick_shield_no_limit/joystick_shield_no_limit.ino diff --git a/.DS_Store b/.DS_Store index f3094ed5e280aead35bd12b2d584f6dd0cb6e2a2..1d7f5394af7c70bd75a71893b78dfbf605a3447b 100644 GIT binary patch delta 1488 zcmaJ>T}&KR6h7bXQf6niW%h@kWuXjz(&84DpDwJmf)r{i#hL)W9my^YBcttA?k}U(K|EHU}C+Sz31L@ z=A8NFeBZsNW>38Xg^18Kqc#ym_)_41)5;zqmq?^|o>v+Ro4LoyokSHAdt}v6V`HNb+?1dc-5LFRN?E_op*@Drr2RO&i>@ z5m(>5JY#4Fv_w3kXSMElMl)n`3l}yPg(_;cHng`SR;o+`+zkuoVL9W*1m z=BG7oR6(#Z6sbxaF!YBtL5|xsYQ;Kn;Fz9N-LheO>cy}$n23*Q3Ae1;X^mo&G?cYJ z$}RWW&Q>uh4Uea$rZ{SYg9_X3n6yJWY`%J5+{o-td$pvA>nmaTu8z)49M&!tuPI^A z)NY=4b1s6^K%F!|he)F|@BOoMhMuFd^ctO~59t&7jJ~9==^MI4-_notGyOup(slYB z1i%3aGQ993fO1r!8nw6$jo6MT+7Uw+?nN*9a36*+ia1ngNMa6;;c+~H(-FLYSMVkl za2_AvV=Qux`EZzAo8unatj+j5_kPt7axNiXK;fDe(yLk+TGc{NVE3)H(D|QQxU$hw zfIm=Jv?__aZ?<(^Bh5attEDybmI(eu`*Lwfurwr=OM{$8ZT42`k@Ibq%%`~!Bw4U{ zF}Jl+og_QBd<3gjy%ZK@r=<}yYSJ&~S!yUQnGcq7=0(|M3C0Y^#2u2n!P14fb&DOM ztxGT}QG!y0uo)HD zf_mJJZD>Fn=lc%aiJjPuJ=n{6--kiY`!GgukTZW26VUMx49p;lS)9O0Jc+09G|qAv zFuaJ@@s^G2rU3TX`?VQw^Hl+{%f51U#wX@29eH<&82r_2as93!J=xUHk44(b6Bcvu zKMF_34Hog2=FSDW5on1vg_Y*!*j!k7q%F2RtVCO5>@RtgD<7(1+loW>{z zTN%w=R4(V`ye`$rJn~DdqwqRo@-Gp&1EZFDGaa+RkiGUUj=LOwQmrFK5|U(4=7`&%QYMS3W9kSI*Lf#_N>2p n`3-x+$qK@K9*2E1x0_GqCc_mDj&Tk-Z{#;Ar$nxq(^l6%4#{Ga delta 506 zcmZo!!Pruvz`(%3=v10w$iSchWO4v8h!)^sU|`{5U{K(msGu*Z2NYoj3NkPxGw3pe zG6XX?P8gU}0ufTg%DG!70$rA*!Tj z;}McrT~k|E4|Em~FoK*10=y6kPBu=SD5NwwRM&!;efn=8TZiS`Z@0sf4+`nQ7%G#+ zh548i7(fa)dkRM~GFfX+J|`lx`GANM<79bl-^u=B-poR$TqhTb$!^{y7RAma+%UNS z$TpU{!8ox&m63NckAkFSyoNl`Ru%?5hIEEZhLYTT7nhXMl4J&k^KvU?!0thkOF@#G z9H$`7oWFr#GNYo|=1mG$SvRi{t7QafVTE`@gBwV@BF7gnTHZ5H<~Q->0s0#hoeV(Q QU~`6vJQG;+VnGWY0GS_ng#Z8m diff --git a/Joystick-Shield/joystick_shield_debug/joystick_shield_debug.ino b/Joystick-Shield/joystick_shield_debug/joystick_shield_debug.ino new file mode 100644 index 0000000..129fb0c --- /dev/null +++ b/Joystick-Shield/joystick_shield_debug/joystick_shield_debug.ino @@ -0,0 +1,169 @@ +/* +Thanks to Dagen Brock: + +BASIC program to test joystick in Apple II emulators: + +5 DP = .10: REM Deadzone Percentage +10 XLEFT = 0:YUP = 0:XRIGHT = 279:YBOT = 159: REM Screen Bounds +15 REM Set target box coordinates +20 HALF = XRIGHT / 2:D1 = INT (HALF - (HALF * DP)):D2 = INT (HALF + (HALF * DP)) +25 HALF = YBOT / 2:D3 = INT (HALF - (HALF * DP)):D4 = INT (HALF + (HALF * DP)) +30 HGR : HCOLOR= 3 +35 REM Draw edge box +40 X1 = XLEFT:Y1 = YUP:X2 = XRIGHT:Y2 = YBOT: GOSUB 2000:X1 = X1 + 1:X2 = X2 - 1:Y1 = Y1 + 1:Y2 = Y2 - 1: GOSUB 2000 +50 P0 = PDL (0):P1 = PDL (1): GOSUB 3000 +55 PRINT P0,P1 +60 GOTO 50 +2000 HPLOT X1,Y1 TO X1,Y2: HPLOT X1,Y2 TO X2,Y2: HPLOT X2,Y2 TO X2,Y1: HPLOT X2,Y1 TO X1,Y1 +2002 RETURN +3000 X = INT (P0 * 274 / 255 + 2):Y = INT (P1 * 154 / 255 + 2) +3010 X1 = X:X2 = X + 1:Y1 = Y:Y2 = Y1 + 1: GOSUB 2000 +3020 GOSUB 4000: HCOLOR= 0: GOSUB 2000: HCOLOR= 3 +3050 RETURN +4000 HPLOT D1,D3 TO D1,D4: HPLOT D1,D4 TO D2,D4: HPLOT D2,D4 TO D2,D3: HPLOT D2,D3 TO D1,D3 +4010 RETURN : REM End Draw Target Box + + +*/ + + + + +/* Read Joystick +*/ + + + int XPin = A8; + int YPin = A7; + + int Button0Pin = 9; + int Button1Pin = 10; + +int JoystickX; +int JoystickY; + +int XMax = 0; +int YMax = 0; +int XMin = 1023; +int YMin = 1023; + + +/* + +adjust CalibrationMax up if the range on your joystick is too restricted to calibrate + +adjust down if your joystick "jumps" around a lot. 800 seems to be a pretty good spot for the sticks i've tested. + +*/ + +// int CalibrationMax = 800; // allows for weird "jumpy" joystick potentiometers. these things are 30 years old, after all. + int CalibrationMax = 9999; // no limit. + + + + + void setup() { +// Serial.begin(9600); + + pinMode(Button0Pin, INPUT); + pinMode(Button1Pin, INPUT); + + Joystick.useManualSend(true); + + } + + void loop() { + + + /* auto calibrate: + + save X, Y. + compare them to historical high/low values. + if higher/lower, reset highest/lowest variable + + highest == 1023 + lowest == 0 + midway between now == 512 + + + */ + JoystickX = 1023 - analogRead(XPin); // needs to be inverted! + JoystickY = 1023 - analogRead(YPin); + + /* auto calibrate: + + save X, Y. + compare them to historical high/low values. + if higher/lower, reset highest/lowest variable + + highest == 1023 + lowest == 0 + midway between now == 512 + + + */ + // record the maximum sensor value +// if ((JoystickX < CalibrationMax) && (JoystickX > XMax)) { + if (JoystickX > XMax) { + XMax = JoystickX; + } + + // record the minimum sensor value + if (JoystickX < XMin) { + XMin = JoystickX; + } + // record the maximum sensor value +// if ((JoystickY < CalibrationMax) && (JoystickY > YMax)) { + if (JoystickY > YMax) { + YMax = JoystickY; + } + + // record the minimum sensor value + if (JoystickY < YMin) { + YMin = JoystickY; + } + + + JoystickX = map(JoystickX, XMin, XMax, 0, 1023); + JoystickY = map(JoystickY, YMin, YMax, 0, 1023); + + + Joystick.X(JoystickX); + Joystick.Y(JoystickY); + + Joystick.button(1, digitalRead(Button0Pin)); + Joystick.button(2, digitalRead(Button1Pin)); + + Joystick.send_now(); + +/* + Serial.print(XMin); + Serial.print(" -- "); + Serial.print(JoystickX); + Serial.print(" -- "); + Serial.print(XMax); + Serial.print(" -- || -- "); + Serial.print(YMin); + Serial.print(" -- "); + Serial.print(JoystickY); + Serial.print(" -- "); + Serial.println(YMax); + delay(100); + +*/ + +/* + Serial.print(JoystickX); + Serial.print(" -- "); + Serial.print(JoystickY); + + Serial.print(" -- "); + + Serial.print(digitalRead(Button0Pin)); + Serial.print(" -- "); + Serial.print(digitalRead(Button1Pin)); + Serial.println(); + + delay(100); +*/ +} diff --git a/Joystick-Shield/joystick_shield_no_limit/joystick_shield_no_limit.ino b/Joystick-Shield/joystick_shield_no_limit/joystick_shield_no_limit.ino new file mode 100644 index 0000000..129fb0c --- /dev/null +++ b/Joystick-Shield/joystick_shield_no_limit/joystick_shield_no_limit.ino @@ -0,0 +1,169 @@ +/* +Thanks to Dagen Brock: + +BASIC program to test joystick in Apple II emulators: + +5 DP = .10: REM Deadzone Percentage +10 XLEFT = 0:YUP = 0:XRIGHT = 279:YBOT = 159: REM Screen Bounds +15 REM Set target box coordinates +20 HALF = XRIGHT / 2:D1 = INT (HALF - (HALF * DP)):D2 = INT (HALF + (HALF * DP)) +25 HALF = YBOT / 2:D3 = INT (HALF - (HALF * DP)):D4 = INT (HALF + (HALF * DP)) +30 HGR : HCOLOR= 3 +35 REM Draw edge box +40 X1 = XLEFT:Y1 = YUP:X2 = XRIGHT:Y2 = YBOT: GOSUB 2000:X1 = X1 + 1:X2 = X2 - 1:Y1 = Y1 + 1:Y2 = Y2 - 1: GOSUB 2000 +50 P0 = PDL (0):P1 = PDL (1): GOSUB 3000 +55 PRINT P0,P1 +60 GOTO 50 +2000 HPLOT X1,Y1 TO X1,Y2: HPLOT X1,Y2 TO X2,Y2: HPLOT X2,Y2 TO X2,Y1: HPLOT X2,Y1 TO X1,Y1 +2002 RETURN +3000 X = INT (P0 * 274 / 255 + 2):Y = INT (P1 * 154 / 255 + 2) +3010 X1 = X:X2 = X + 1:Y1 = Y:Y2 = Y1 + 1: GOSUB 2000 +3020 GOSUB 4000: HCOLOR= 0: GOSUB 2000: HCOLOR= 3 +3050 RETURN +4000 HPLOT D1,D3 TO D1,D4: HPLOT D1,D4 TO D2,D4: HPLOT D2,D4 TO D2,D3: HPLOT D2,D3 TO D1,D3 +4010 RETURN : REM End Draw Target Box + + +*/ + + + + +/* Read Joystick +*/ + + + int XPin = A8; + int YPin = A7; + + int Button0Pin = 9; + int Button1Pin = 10; + +int JoystickX; +int JoystickY; + +int XMax = 0; +int YMax = 0; +int XMin = 1023; +int YMin = 1023; + + +/* + +adjust CalibrationMax up if the range on your joystick is too restricted to calibrate + +adjust down if your joystick "jumps" around a lot. 800 seems to be a pretty good spot for the sticks i've tested. + +*/ + +// int CalibrationMax = 800; // allows for weird "jumpy" joystick potentiometers. these things are 30 years old, after all. + int CalibrationMax = 9999; // no limit. + + + + + void setup() { +// Serial.begin(9600); + + pinMode(Button0Pin, INPUT); + pinMode(Button1Pin, INPUT); + + Joystick.useManualSend(true); + + } + + void loop() { + + + /* auto calibrate: + + save X, Y. + compare them to historical high/low values. + if higher/lower, reset highest/lowest variable + + highest == 1023 + lowest == 0 + midway between now == 512 + + + */ + JoystickX = 1023 - analogRead(XPin); // needs to be inverted! + JoystickY = 1023 - analogRead(YPin); + + /* auto calibrate: + + save X, Y. + compare them to historical high/low values. + if higher/lower, reset highest/lowest variable + + highest == 1023 + lowest == 0 + midway between now == 512 + + + */ + // record the maximum sensor value +// if ((JoystickX < CalibrationMax) && (JoystickX > XMax)) { + if (JoystickX > XMax) { + XMax = JoystickX; + } + + // record the minimum sensor value + if (JoystickX < XMin) { + XMin = JoystickX; + } + // record the maximum sensor value +// if ((JoystickY < CalibrationMax) && (JoystickY > YMax)) { + if (JoystickY > YMax) { + YMax = JoystickY; + } + + // record the minimum sensor value + if (JoystickY < YMin) { + YMin = JoystickY; + } + + + JoystickX = map(JoystickX, XMin, XMax, 0, 1023); + JoystickY = map(JoystickY, YMin, YMax, 0, 1023); + + + Joystick.X(JoystickX); + Joystick.Y(JoystickY); + + Joystick.button(1, digitalRead(Button0Pin)); + Joystick.button(2, digitalRead(Button1Pin)); + + Joystick.send_now(); + +/* + Serial.print(XMin); + Serial.print(" -- "); + Serial.print(JoystickX); + Serial.print(" -- "); + Serial.print(XMax); + Serial.print(" -- || -- "); + Serial.print(YMin); + Serial.print(" -- "); + Serial.print(JoystickY); + Serial.print(" -- "); + Serial.println(YMax); + delay(100); + +*/ + +/* + Serial.print(JoystickX); + Serial.print(" -- "); + Serial.print(JoystickY); + + Serial.print(" -- "); + + Serial.print(digitalRead(Button0Pin)); + Serial.print(" -- "); + Serial.print(digitalRead(Button1Pin)); + Serial.println(); + + delay(100); +*/ +} diff --git a/USB_IIe_Kbd/Arduino/USB_IIe_Kbd/USB_IIe_Kbd.ino b/USB_IIe_Kbd/Arduino/USB_IIe_Kbd/USB_IIe_Kbd.ino index 8d02a32..06ce7c6 100644 --- a/USB_IIe_Kbd/Arduino/USB_IIe_Kbd/USB_IIe_Kbd.ino +++ b/USB_IIe_Kbd/Arduino/USB_IIe_Kbd/USB_IIe_Kbd.ino @@ -158,6 +158,9 @@ CTL = AVR A1 / 15 const int COLUMNS = 8; const int ROWS = 10; + +// QWERTY + int KEYS_ARRAY[ROWS][COLUMNS] = { { 0x29, 0x2B, 0x04, 0x1D, 0x54, 0x27, 0x55, 0x29 }, @@ -181,6 +184,31 @@ int KEYS_ARRAY[ROWS][COLUMNS] = { }; +// Add QWERTZ, AZERTY? + +/*int KEYS_ARRAY[ROWS][COLUMNS] = { +{ 0x29, 0x2B, 0x04, 0x1D, 0x54, 0x27, 0x55, 0x29 }, + +{ 0x1E, 0x14, 0x07, 0x1B, 0x51, 0x52, 0x50, 0x4F }, + +{ 0x1F, 0x1a, 0x16, 0x06, 0x62, 0x5C, 0x60, 0x26 }, + +{ 0x20, 0x08, 0x0B, 0x19, 0x59, 0x5D, 0x61, 0x56 }, + +{ 0x21, 0x15, 0x09, 0x05, 0x5A, 0x5E, 0x63, 0x58 }, + +{ 0x23, 0x1C, 0x0A, 0x11, 0x5B, 0x5F, 0x57, 0x85 }, + +{ 0x22, 0x17, 0x0D, 0x10, 0x31, 0x35, 0x28, 0x2A }, + +{ 0x24, 0x18, 0x0E, 0x36, 0x2E, 0x13, 0x52, 0x51 }, + +{ 0x25, 0x0C, 0x33, 0x37, 0x27, 0x2F, 0x2C, 0x50 }, + +{ 0x26, 0x12, 0x0F, 0x38, 0x2D, 0x30, 0x34, 0x4F } +}; +*/ + /*