infrared_controller.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <stdbool.h>
  3. #include "game_state.h" // For LaserTagTeam enum
  4. typedef struct InfraredController InfraredController;
  5. /**
  6. * Allocate and initialize an InfraredController.
  7. * @return Pointer to the newly allocated InfraredController.
  8. */
  9. InfraredController* infrared_controller_alloc();
  10. /**
  11. * Free an InfraredController and its resources.
  12. * @param controller Pointer to the InfraredController to free.
  13. */
  14. void infrared_controller_free(InfraredController* controller);
  15. /**
  16. * Set the team for the InfraredController.
  17. * @param controller Pointer to the InfraredController.
  18. * @param team The team to set (TeamRed or TeamBlue).
  19. */
  20. void infrared_controller_set_team(InfraredController* controller, LaserTagTeam team);
  21. /**
  22. * Send an infrared signal corresponding to the controller's team.
  23. * @param controller Pointer to the InfraredController.
  24. */
  25. void infrared_controller_send(InfraredController* controller);
  26. /**
  27. * Check if a hit has been received from the opposite team.
  28. * @param controller Pointer to the InfraredController.
  29. * @return true if a hit was received, false otherwise.
  30. */
  31. bool infrared_controller_receive(InfraredController* controller);
  32. // IR command definitions
  33. #define IR_COMMAND_RED_TEAM 0xA1
  34. #define IR_COMMAND_BLUE_TEAM 0xB2