I have been working on a program meant to make archery, and similar ranged sports more accessible to the visually impaired community. Unfortunately, I feel that I have progressed with development as far as AppGameKit will permit; and am abandoning the project for the time being.
The program works as intended, in a very rudimentary sense. The archer / marksman will tap the screen to acquire the coordinates of a selected target, and then the android device will provide haptic feedback to assist with aiming.
However, in it's current version the program only does so in a vague manner; providing only a rough area in which the target is located, rather than an exact and precise position.
I am hoping that future versions of the application will be better suited to precision based applications, accurate within a millimeter of the designated target.
For those interested, the code in its current iteration can be found below.
Main.AGC
// Project: ArcherSee
// Created: 20-05-20
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "ArcherSee" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
// set global variables
Global returnHome
Global aquireTarget
Global targetAquired
Global aquirePositionX
Global aquirePositionY
Global aquirePositionZ
Global alignPositionX
Global alignPositionY
Global alignPositionZ
Global aquireAngleX
Global aquireAngleY
Global aquireAngleZ
Global alignAngleX
Global alignAngleY
Global alignAngleZ
// initalize voiceover service
TextToSpeechSetup()
// specify media directory
SetFolder( "/media" )
// load sound profile
targetAquired = LoadSound( "sTargeted.wav" )
//define color scheme/theme
SetPrintColor(234, 255, 0) //blaze yellow
SetPrintSize(50)
// define required permissions
permission$="Camera"
if (CheckPermission(permission$)<=0)
RequestPermission(permission$)
while(CheckPermission(permission$)=1)
Sync()
endwhile
endif
//initalize camera feed
SetImmersiveMode(1) //documentation said from 4.4 up
img=1
cam=0
SetDeviceCameraToImage(cam,img) //cam input goto image, image for id will created
spr=CreateSprite(img )//image output into a sprite
setspritesize(spr,GetVirtualWidth(),GetVirtualHeight()) //full size
function returnHome()
print("Tap to select target")
speak("Tap to select target")
sync()
if GetPointerPressed()=1
sync()
aquireTarget()
endif
endfunction
// define common functions
function aquireTarget() // target aquisition
aquirePositionX=GetRawAccelX()
aquirePositionY=GetRawAccelY()
aquirePositionZ=GetRawAccelZ()
aquireAngleX=GetRawGyroVelocityX()
aquireAngleY=GetRawGyroVelocityY()
aquireAngleZ=GetRawGyroVelocityZ()
targetAquired=1
sync()
hudBallistics()
endfunction aquirePositionX, aquirePositionY, aquirePositionZ, aquireAngleX, aquireAngleY, aquireAngleZ, targetAquired
do
returnHome()
function hudBallistics() // ballistic HUD | user interface information
if targetAquired=1 //ensure does not trigger by mistake
repeat // similar to "do" operation, however will not lock program
alignPositionX=GetRawAccelX()
alignPositionY=GetRawAccelY()
alignPositionZ=GetRawAccelZ()
alignAngleX=GetRawGyroVelocityX()
alignAngleY=GetRawGyroVelocityY()
alignAngleZ=GetRawGyroVelocityZ()
print("Targeted: " +str(aquirePositionX) +"Targeting: " +str(alignPositionX))
print("Distance: " +str(aquirePositionY) +"Current Distance: " +str(alignPositionY))
print("Elevation: " +str(aquirePositionZ) +"Current Elevation: " +str(alignPositionZ))
sync()
if aquirePositionX=alignPositionX +aquirePositionY=alignPositionY +aquirePositionZ=alignPositionZ +aquireAngleX=alignAngleX +aquireAngleY=alignAngleY +aquireAngleZ=alignAngleZ
VibrateDevice(0.25)
sync()
endif
until GetPointerPressed()=1
elseif GetPointerPressed()=1
sync()
aquireTarget()
endif
endfunction
loop
end
unused.AGC
// File: unused.agc
// Created: 20-07-11
Global returnHome
Global reaquireTarget
Global toggleSettingsButton
Global toggleReaquireButton
Global toggleVibrateButton
Global toggleHudButton
Global toggleVoiceoverButton
Global toggleAudioButton
Global toggleReturnHomeButton
Global toggleHud
Global toggleAudio
Global toggleVoiceover
Global toggleVibrate
Global toggleExitButton
// define button functions
AddVirtualButton (2, 250, 580, 180)
toggleSettingsButton=2
SetVirtualButtonText (toggleSettingsButton, "Settings")
if GetVirtualButtonPressed(toggleSettingsButton)
speak("Settings")
endif
if GetVirtualButtonPressed(toggleSettingsButton)+1
settingsScreen()
sync()
endif
aquireAngleX, aquireAngleY, aquireAngleZ
getAngleX=GetRawGyroVelocityX()
getAngleY=GetRawGyroVelocityY()
getAngleZ=GetRawGyroVelocityZ()
print("Aquired Angle X: " +str(aquireAngleX) +"Rotation Angle X: " +str(alignAngleX))
print("Aquired Angle Y: " +str(aquireAngleY) +"Rotation Angle Y: " +str(alignAngleY))
print("Aquired Angle Z: " +str(aquireAngleZ) +"Rotation Angle Z: " +str(alignAngleZ))
+getAngleX=alignAngleX +getAngleY=alignAngleY +getAngleZ=alignAngleZ
if toggleVoiceover=1
speak("Tap to reselect target")
elseif toggleVoiceover=0
print("Tap to reselect target")
endif
//vibrate device function
if aquirePositionX=alignPositionX +aquirePositionY=alignPositionY +aquirePositionZ=alignPositionZ +toggleAudio=1
PlaySound(targetAquired)
sync()
elseif aquirePositionX=alignPositionX +aquirePositionY=alignPositionY +aquirePositionZ=alignPositionZ +toggleAudio=0 +toggleVibrate=1
VibrateDevice(0.5)
endif
sync()
// create user interface | usable buttons
toggleExitButton=2
AddVirtualButton (toggleExitButton, 250, 140, 180)
SetVirtualButtonText (toggleExitButton, "Exit")
if GetVirtualButtonPressed(toggleExitButton)
speak("Exit")
endif
if GetVirtualButtonPressed(toggleExitButton)=1
DeleteVirtualButton(1)
exit
sync()
endif
function returnHome()
do
print("Tap to select target")
if GetPointerPressed()
aquireTarget()
sync()
endif
loop
endfunction
//Provide user preference options
function settingsScreen()
ClearScreen()
AddVirtualButton (3, 210, 300, 180)
toggleVibrateButton=3
SetVirtualButtonText (toggleVibrateButton, "Vibration on")
if GetVirtualButtonPressed (toggleVibrateButton)
speak ("Toggle Vibration")
endif
if GetVirtualButtonPressed (toggleVibrateButton)=1
toggleVibrate=0
SetVirtualButtonText (toggleVibrateButton, "Vibration off")
speak ("Vibration off")
elseif toggleVibrate=0
toggleVibrate=1
SetVirtualButtonText (toggleVibrateButton, "Vibration on")
speak ("Vibration on")
sync()
endif
AddVirtualButton (4, 225, 350, 180)
toggleHudButton=4
SetVirtualButtonText (toggleHudButton, "Hud on")
if GetVirtualButtonPressed (toggleHudButton)
speak ("Toggle Heads Up Display")
endif
if GetVirtualButtonPressed (toggleHudButton)=1
toggleHud=0
SetVirtualButtonText (toggleHudButton, "Hud off")
speak("Heads up display off")
elseif toggleHud=0
toggleHud=1
SetVirtualButtonText (toggleHudButton, "Hud on")
speak("Heads up display on")
sync()
endif
AddVirtualButton (5, 250, 400, 180)
toggleVoiceoverButton=5
SetVirtualButtonText (toggleVoiceoverButton, "Voiceover on")
if GetVirtualButtonPressed (toggleVoiceoverButton)
speak ("Toggle Voiceover Service")
endif
if GetVirtualButtonPressed (toggleVoiceoverButton)+1
SetVirtualButtonText (toggleVoiceoverButton, "Voiceover off")
speak("Voiceover Service off")
toggleVoiceover=0
StopSpeaking()
elseif toggleVoiceover=0
toggleVoiceover=1
TextToSpeechSetup()
SetVirtualButtonText (toggleVoiceover, "Voiceover on")
speak("Voiceover Service on")
sync()
endif
AddVirtualButton (6, 280, 450, 180)
toggleAudioButton=6
SetVirtualButtonText (toggleAudioButton, "Audio on")
if GetVirtualButtonPressed (toggleAudioButton)=1
speak ("Toggle Audio events")
endif
if GetVirtualButtonPressed (toggleAudioButton)=1
SetVirtualButtonText (toggleAudioButton, "Audio off")
speak("Audio events off")
toggleAudio=0
elseif toggleAudio=0
toggleAudio=1
SetVirtualButtonText (toggleAudioButton, "Audio on")
speak("Audio events on")
endif
sync()
AddVirtualButton (7, 300, 475, 180)
toggleReturnHomeButton=7
SetVirtualButtonText (toggleReturnHomeButton, "Home")
if GetVirtualButtonPressed (toggleReturnHomeButton)
speak ("Return to home screen")
endif
if GetVirtualButtonPressed (toggleReturnHomeButton)+1
returnHome()
sync()
endif
endfunction
AddVirtualButton (8, 225, 400, 180)
toggleReaquireButton=8
SetVirtualButtonText (toggleReaquireButton, "Re-aquire Target")
if GetVirtualButtonPressed(toggleReaquireButton)
speak("Re aquire target")
endif
if GetVirtualButtonPressed(toggleReaquireButton)+1
reaquireTarget=1
aquireTarget()
sync()
endif