Skip to content
Closed
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
31 changes: 0 additions & 31 deletions include/vdml/port.h

This file was deleted.

99 changes: 0 additions & 99 deletions include/vdml/registry.h

This file was deleted.

58 changes: 58 additions & 0 deletions include/vdml/registry.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef VDML_REGISTRY_HPP
#define VDML_REGISTRY_HPP

#include "v5_apitypes.h"
#include "vdml/vdml.hpp"

#include <cstdint>
#include <optional>

namespace zest {
namespace vdml {
enum class DeviceType {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enum should have a comment explaining that these values are based on VEXos (since they seem rather arbitrary right now)

NONE = 0,
MOTOR = 2,
ROTATION = 4,
IMU = 6,
DISTANCE = 7,
RADIO = 8,
VISION = 11,
ADI = 12,
OPTICAL = 16,
GPS = 20,
AI_VISION = 29,
SERIAL = 129,
UNDEFINED = 255
};

struct DeviceInfo {
DeviceType type;
uint32_t data;
};

static std::array<std::optional<DeviceInfo>, MAX_DEVICE_PORTS> device_registry;
static V5_DeviceType registry_types[MAX_DEVICE_PORTS];

void initialize_registry();

void update_registry();
std::optional<DeviceInfo> set_device(uint8_t port, DeviceType type);
std::optional<DeviceInfo> get_device(uint8_t port);
bool validate_device(uint8_t port, DeviceType expected);
} // namespace vdml
} // namespace zest

// STUBS SO OLD VDML CODE COMPILES

typedef struct {
pros::c::v5_device_e_t device_type;
V5_DeviceT device_info;
uint8_t pad[128]; // 16 bytes in adi_data_s_t times 8 ADI Ports = 128
} v5_smart_device_s_t;

void registry_update_types();
v5_smart_device_s_t* registry_get_device(uint8_t port);
v5_smart_device_s_t* registry_get_device_internal(uint8_t port);
int32_t registry_validate_binding(uint8_t port, pros::c::v5_device_e_t expected_t);

#endif
Loading