Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
**
Fish Service:
Timers:
N/A
Module Vars:
static variable of type FishState_t CurrentState
static integer fishX that stores fish x-position on OLED screen
static integer fishY that stores fish y-position on OLED screen
static integer fishOrient that stores fish orientation on OLED screen
static integer finalHookX that stores hook x-position on OLED screen
static integer finalHookY that stores hook y-position on OLED screen
Module Functions:
getNewFish: A module function that generates a new fish
isFishCaught: A module function that checks if fish is caught
getFishHookPos: A setter function that updates the final hook position
Event Checkers:
N/A
***********************************************************************************
**
Pseudo-code for the Fish Service module:
InitFishFSM
Takes a priority number, returns True
Set current state to ES_Init;
post the initial transition event;
PostFishFSM
Takes in an event ThisEvent and returns a call to ES_PostToService
RunFishFSM
Takes in an event ThisEvent and returns ES_NO_EVENT
Based on the state of the CurrentState variable choose one of the following
blocks of code:
CurrentState is InitFishState
CurrentState is FishWandering:
CurrentState is FishLooking:
Store the value of newHookX within Joyhook Service into finalHookX within
this service
Store the value of newHookY into finalHookY, decrement by 8 pixels to account
for hook length
on the OLED screen, so that when throwing hook, we will be aiming for the
hook tip, instead of the hook bottom
Seed the random number generator with current time from ES_Timer_GetTime() to
ensure
randomness of number generation
Randomly generate a value for fishX between 45 to 88 to allow for buffer
region enough to
place hooks towards any random fish
Randomly generate a value for fishY between 25 to 50 to allow for buffer
region enough to
place hooks towards any random fish
Randomly generate a value for fishOrient between 0 and 1 denoting fish
fishing left or right
Print new fish location and orientation to console
***********************************************************************************
**