Chest unit API plugin

This is available events that is called by engine in certain situations

Table of contents
  1. PLUGIN_mainLoop
  2. PLUGIN_timer10ms
  3. PLUGIN_timer1s
  4. PLUGIN_pressedTrigger
  5. PLUGIN_releasedTrigger
  6. PLUGIN_pressedUserButton
  7. PLUGIN_releasedUserButton
  8. PLUGIN_hitByEnemy
  9. PLUGIN_hitByTeam
  10. PLUGIN_setModulesState
  11. PLUGIN_changedGameStateToAlive
  12. PLUGIN_changedGameStateToDead
  13. PLUGIN_changedGameStateToRevival
  14. PLUGIN_changedGameStateToStarting
  15. PLUGIN_changedGameStateToEnding
  16. PLUGIN_changedRank
  17. PLUGIN_changedScore
  18. PLUGIN_processCustomMessage
  19. PLUGIN_customInit

PLUGIN_mainLoop

Part in while loop in main

void PLUGIN_mainLoop(void);

PLUGIN_timer10ms

Part in timer interrupt with periode 10 milliseconds

void PLUGIN_timer10ms(void);

PLUGIN_timer1s

Part in timer interrupt with period 1 second, by using this the time countdown is disabled (also switching between game states and drawing time at display)

void PLUGIN_timer1s(uint16_t aTimeDisplay);

Params

  • aTimeDisplay - time in seconds which should be displayed (starting countdown or game time)

PLUGIN_pressedTrigger

Part in external interrupt for trigger press

void PLUGIN_pressedTrigger(void);

PLUGIN_releasedTrigger

Part in external interrupt for trigger release

void PLUGIN_releasedTrigger(void);

PLUGIN_pressedUserButton

Part in external interrupt for user button press

void PLUGIN_pressedUserButton(void);

PLUGIN_releasedUserButton

Part in external interrupt for user button release

void PLUGIN_releasedUserButton(void);

PLUGIN_hitByEnemy

Part in while loop in main after detecting hit by enemy from slave module

void PLUGIN_hitByEnemy(uint8_t aHitCode, uint8_t aHitFlag, uint8_t aHitStrength,
		uint8_t aHitCustomInfo, uint16_t aLife, uint8_t aHealth);

Params

  • aHitCode - select table row, from which player hit was received, 0 is reserved
  • aHitFlag - specify which module was hit,

       0 reserved
       1 front_1
       2 front_2
       3 left_1
       4 left_2
       5 right_1
       6 right_2
       7 back_1
       8 back_2
       9 weapon
    
  • aHitStrength - strength of received hit (received from shot message), <0; 100>
  • aHitCustomInfo - custom info received in shot message, <0; 15>
  • aLife - actual life value
  • aHealth - actual health value

PLUGIN_hitByTeam

Part in while loop in main after detecting hit by team from slave module

void PLUGIN_hitByTeam(uint8_t aHitCode, uint8_t aHitFlag, uint8_t aHitStrength,
		uint8_t aHitCustomInfo, uint16_t aLife, uint8_t aHealth);

Params

  • aHitCode - select table row, from which player hit was received, 0 is reserved
  • aHitFlag - specify which module was hit,

       0 reserved
       1 front_1
       2 front_2
       3 left_1
       4 left_2
       5 right_1
       6 right_2
       7 back_1
       8 back_2
       9 weapon
    
  • aHitStrength - strength of received hit (received from shot message), <0; 100>
  • aHitCustomInfo - custom info received in shot message, <0; 15>
  • aLife - actual life value
  • aHealth - actual health value

PLUGIN_setModulesState

Part in while loop in main for selecting color and behavior of slave modules, triggered periodically every 20 milliseconds. Arrays contain actual values (apModulesState is send each periode to slave modules, the rest only vhen changed)

void PLUGIN_setModulesState(uint8_t aState, uint8_t aGameState,
		uint8_t aHitFlag, uint8_t aHealth, volatile uint8_t* apModulesState,
		volatile uint8_t* apModulesDim1, volatile uint8_t* apModulesDim2,
		volatile colors_t* apModulesColor1, volatile colors_t* apModulesColor2);

Params

  • aState - actial global state of chest, allowed values in plugin are

       2 state_prepared - chest initialized for game, waiting to start
       3 state_game - chest in game
       4 state_ending - after game ended
    
  • aGameState - actual state of game

       0 game_state_ending - the end of game
       1 game_state_alive - ingame playing
       2 game_state_dead - after hit by another player, death
       3 game_state_starting - game is starting, after state changed from prepared to game
       4 game_state_revival - change from dead to alive
       5 game_state_none - before game
    
  • aHitFlag - specify which module was hit,

       0 no hit received
       1 front_1
       2 front_2
       3 left_1
       4 left_2
       5 right_1
       6 right_2
       7 back_1
       8 back_2
       9 weapon
    
  • aHealth - actual health value
  • apModulesState - pointer to array[NUM_OF_SLAVES] with state for each slave module, bits structure 0b000VBBAA

       V - vibration flag, 1 means activate vibration for short time periode
       BB - state of led2 circuit
       AA - state of led1 circuit
       0 turn off
       1 basic color (color 1)
       2 special color (color 2)
       3 stroboscope - activate white blink
    
  • apModulesDim1 - pointer to array[NUM_OF_SLAVES] with dim value of led1 circuit for each slave module, <0; 100>, 0 - leds not lighting, 100 - full brightness
  • apModulesDim2 - pointer to array[NUM_OF_SLAVES] with dim value of led2 circuit for each slave module, <0; 100>, 0 - leds not lighting, 100 - full brightness
  • apModulesColor1 - pointer to array[NUM_OF_SLAVES] with basic color (color 1) structure (red, green, blue; each 8 bit) for each slave module
  • apModulesColor2 - pointer to array[NUM_OF_SLAVES] with special color (color 2) structure (red, green, blue; each 8 bit) for each slave module

PLUGIN_changedGameStateToAlive

Part in while loop in main triggered by game_state change to Alive (normal playing state)

void PLUGIN_changedGameStateToAlive(uint8_t aGameStateLast);

Params

  • aGameStateLast - last game state

PLUGIN_changedGameStateToDead

Part in while loop in main triggered by game_state change to Death (basically after loosing life)

void PLUGIN_changedGameStateToDead(uint8_t aGameStateLast);

Params

  • aGameStateLast - last game state

PLUGIN_changedGameStateToRevival

Part in while loop in main triggered by game_state change to Revival (after death)

void PLUGIN_changedGameStateToRevival(uint8_t aGameStateLast);

Params

  • aGameStateLast - last game state

PLUGIN_changedGameStateToStarting

Part in while loop in main triggered by game_state change to Starting (part before actual game)

void PLUGIN_changedGameStateToStarting(uint8_t aGameStateLast);

Params

  • aGameStateLast - last game state

PLUGIN_changedGameStateToEnding

Part in while loop in main triggered by game_state change to Ending (game time is zero)

void PLUGIN_changedGameStateToEnding(uint8_t aGameStateLast);

Params

  • aGameStateLast - last game state

PLUGIN_changedRank

Part in while loop in main triggered by receive message with new rank

void PLUGIN_changedRank(uint8_t aRank, uint8_t aRankLast);

Params

  • aRank - new received rank
  • aRankLast - last rank value

PLUGIN_changedScore

Part in while loop in main triggered by receive message with new score

void PLUGIN_changedScore(int32_t aScore, int32_t aScoreLast);

Params

  • aScore - new received score
  • aScoreLast - last score value

PLUGIN_processCustomMessage

Part in data_process (main loop) for processing custom message

void PLUGIN_processCustomMessage(uint8_t* apData, uint16_t aLength,
		uint8_t aDevice);

Params

  • apData - pointer to array with data bytes
  • aLength - length of valid bytes in apData array
  • aDevice - chest (player) code, which send the message, equal to row in table, 0 means coordinator (main app)

PLUGIN_customInit

Part of PLUGIN_init, for users part of initialization, for example global vars for timers (length_death,…)

void PLUGIN_customInit(volatile colors_t* apModulesColor1,
		volatile colors_t* apModulesColor2, volatile uint8_t* apModulesDim1,
		volatile uint8_t* apModulesDim2, uint8_t* apModulesVibrationStrength,
		volatile uint8_t* apModulesState);

Params

  • apModulesColor1 - pointer to array[NUM_OF_SLAVES] with basic color (color 1) structure (red, green, blue; each 8 bit) for each slave module
  • apModulesColor2 - pointer to array[NUM_OF_SLAVES] with special color (color 2) structure (red, green, blue; each 8 bit) for each slave module
  • apModulesDim1 - pointer to array[NUM_OF_SLAVES] with dim value of led1 circuit for each slave module, <0; 100>, 0 - leds not lighting, 100 - full brightness
  • apModulesDim2 - pointer to array[NUM_OF_SLAVES] with dim value of led2 circuit for each slave module, <0; 100>, 0 - leds not lighting, 100 - full brightness
  • apModulesVibrationStrength - pointer to array[NUM_OF_SLAVES] with vibration strength value of for each slave module, <0; 255>, 0 - vibration switched off, 255 - maximum vibration strength
  • apModulesState - pointer to array[NUM_OF_SLAVES] with state for each slave module, bits structure 0b000VBBAA

       V - vibration flag, 1 means activate vibration for short time periode
       BB - state of led2 circuit
       AA - state of led1 circuit
       0 turn off
       1 basic color (color 1)
       2 special color (color 2)
       3 stroboscope - activate white blink