08 March 2025

Team 21 Progress Review

Our controller was designed around the game Webfishing, and was designed around the concept of being a wearable bucket hat! Being synonymous with fishing, the bucket hat is also an accessory that you can unlock for your character within the game. Our design uses the accelerometer of the Circuit Playground Express to track the direction that your head is tilted, and maps that to your characters movement. We are using an external microphone detecting sudden loud sound inputs in order to cast your characters fishing line, with a sustained sound leading to a further cast. We will also be accessing a photoresistor through the top of our hat, that you can cover with your hand in order to toggle open and closed the in-game menu.

 

Create float variables accelX and accelY

Create long variable startMillis

Create integer variables xMouse and yMouse and set them to 0

Create integer variables peakToPeak, singalMin, signalMax, and sample

Create integer variables currentRotA, lastRotA, and mouseGo

Create boolean variable menuActive and set it to false

 

Do the following if the switch is on:

//setup x and y axis data

Assign variable accelX to the value of the Circuit Playground’s motionX

Assign variable accelY to the value of the Circuit Playground’s motionY

 

//sets x and y movement to control either wasd keys or mouse x and y

If menuActive is false:

Map accelX from the range (-10,11) to (-1,2)

Map accelY from the range (-10,11) to (-1,2)

//translate x axis to a and d keys

If the value of accelX is between -1 and 1, release the A and D keys

Otherwise, if the value of accelX is greater than or equal to 1, press the D key

Otherwise, if the value of accelX is less than or equal to 1, press the A key

//translate y axis to w and s keys

If the value of accelY is between -1 and 1, release the W and S keys

Otherwise, if the value of accelY is greater than or equal to 1, press the W key

Otherwise, if the value of accelY is less than or equal to 1, press the S key

Otherwise:

Map accelX from the range (-10,11) to (-100, 101)

Map accelY from the range (-10,11) to (-100, 101)

Move the mouse’s x and y positions by accelX and accelY respectively

 

//setup sound data

Set startMillis to the current value of the function millis

Set peakToPeak and signalMax to 0

Set signalMin to 1024

 

//interpret sound data for 50 milliseconds

While the current value of the millis function minus startMillis is less than 50:

Set sample to the analog value of the amp’s output

If sample is greater than signalMax, set singalMax to sample

Otherwise if sample is less than signalMin, set singalMin to sample

Set peakToPeak as the difference between signalMax and signalMin

 

//use sound data output to control left mouse button

If peakToPeak is greater than or equal to .5, press the left mouse button

Otherwise, release the left mouse button

              

//use rotary encoder output to move cursor and press right mouse button

Set currentRotA to the output value of the rotary encoder’s output A

If currentRotA is not equal to lastRotA AND currentRotA’s value is 1:

//turn counterclockwise, move mouse left

If the output of the rotary encoder’s output B is not equal to currentRotA:

Set mouseGo to -40

//turn clockwise, move mouse right

If the output of the rotary encoder’s output B is not equal to currentRotA:

Set mouseGo to 40

Press the right mouse button

Move the mouse’s x axis by mouseGo

Release the right mouse button

 

//use light sensor to toggle menu control scheme

If the light sensor’s output is less than 300:

menuActive toggles its value

Click tab key

 

Otherwise:

Release all keys on the keyboard and the mouse

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.