Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Looking at the file structure of a project like this can feel intimidating. This
- `include/rtos` headers for the scheduler (FreeRTOS)
- `include/system` headers for low-level system functionality
- `include/system/dev` headers for serial I/O and file management
- `include/system/user_functions` a horrifying mess that should be destroyed

- `scripts` contains scripts used for building ZestCode and projects that use ZestCode

Expand Down
2 changes: 0 additions & 2 deletions include/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
#include <unistd.h>
#endif /* __cplusplus */

#include "pros/misc.h"
#include "pros/rtos.h"

#ifdef __cplusplus
#include "pros/misc.hpp"
#include "pros/rtos.hpp"
#endif

Expand Down
86 changes: 86 additions & 0 deletions include/pros/competition.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#pragma once

#include <functional>

namespace zest::competition {
/**
* @brief the competition mode (disabled, driver control, autonomous)
*
*/
enum class Mode {
Disabled,
DriverControl,
Autonomous,
};

/**
* @brief the competition system being used
*
*/
enum class System {
FieldControl,
CompetitionSwitch,
None,
};

/**
* @brief Get the competition mode (disabled, driver control, autonomous)
*
* @return Status
*/
Mode get_mode();

/**
* @brief Get the system type being used (field control, competition switch, or none)
*
* @return System
*/
System get_system();

/**
* @brief Whether field control or a competition switch is connected
*
* @return true
* @return false
*/
bool is_connected();

/**
* @brief register the callable that will be called when the autonomous period starts.
*
* The callable is called whenever the competition state changes to autonomous. The task that runs
* it is killed as soon as the competition state changes to driver control or disabled.
*
* @param callable
*/
void register_autonomous(std::function<void()> callable);

/**
* @brief register the callable that will be called when the driver control period starts.
*
* The callable is called whenever the competition state changes to autonomous. The task that runs
* it is killed as soon as the competition state changes to driver control or disabled.
*
* @param callable
*/
void register_driver_control(std::function<void()> callable);

/**
* @brief register the callable that will be called when the disabled period starts.
*
* The callable is called whenever the competition state changes to autonomous. The task that
* runs it is killed as soon as the competition state changes to driver control or disabled.
*
* @param callable
*/
void register_disabled(std::function<void()> callable);

/**
* @brief initialize the competition control task
*
* TODO: figure out how to hide this from the user
*
* This function is called after `int main` is called.
*/
void initialize();
} // namespace zest::competition
Loading
Loading