You are on page 1of 3

/**********

Pseudocode for button


This service file is responsible for debouncing the button and
creating button events
***********/

Include the following files:


ES_Configure.h
ES_Framework.h
Gameplay.h
Projectile.h
DotStarService.h
ButtonDB.h

Define the following variables:


Ms25 as 25ms timer value

Initialize the following module-level variables:


ButtonState_t CurrentState
Uint8_t LastButtonState
Uint8_t myPriority

/**********
Function: InitButtonDB
Type: Bool
Parameter: uint8_t Priority
Returns: boolean stating whether initialization was a success
(true) or failure (false)
***********/
InitEnemyShip
* Set priority
* Set current state to init
* Set button to input, turn on pullup resistor
* Post initial transition event

/**********
Function: PostButtonDB
Type: Bool
Parameter: ES_Event_t variable ThisEvent
Returns: boolean stating whether post to service was a success
(true) or failure (false)
***********/
PostEnemyShip
- return call to ES_PostToService with parameters
MyPriority and ThisEvent

/**********
Function: RunButtonDB
Type: ES_Event_t
Parameter: ES_Event_t variable ThisEvent
Returns: ES_Event_t variable that states if there are errors or
not
***********/
RunButtonDB
* Switch statement with current state
* InitButtonState
* If initEvent set last state to current val,
* set current state to waiting
* Waiting
* Rising edge event
* Set state to rising edge
* Set timer
* Falling edge event
* Set timer
* Set state to falling edge
* Rising Edge
* Falling edge event
* Stop timer
* Set current state to waiting
* Timeout
* Set currentState to waiting
* Falling Edge
* risingEdge event
* Stop timer
* Current state is waiting
* Timeout
* Post button event to projectile, gameplay and dotstar
* Set state to waiting

/**********
Function: CheckButton
Type: ES_Event_t
Parameter: void
Returns: bool
***********/
//event checker to see if button changed
Check button
* Set default return val to false
* If the button state is not equal to the last button state
* Set return val to true
* Update lastButton state
* If the button is down
* Post falling edge event
* If the button is up
* Post rising edge event

You might also like