everything

main
Brett 2025-04-11 19:49:20 -04:00
parent 19d656e49f
commit b3c44050da
1 changed files with 25 additions and 76 deletions

View File

@ -36,77 +36,24 @@ blt::gfx::first_person_camera camera;
std::array<char, 100> buffer; std::array<char, 100> buffer;
size_t last_time_ran = 0; size_t last_time_ran = 0;
struct parker_json_t struct everything_t
{ {
float motorTargetAngle; float motorTargetAngle = 0;
float position; float distance_reading = 0;
float position = 0;
struct anglePID_t blt::vec3f anglePID;
{ blt::vec3f posPID;
float setpoint; blt::vec3f ypr;
float input; blt::vec3f euler;
float output; blt::vec3f gravity;
} anglePID; blt::vec4f q;
blt::vec3f aa;
struct ypr_t blt::vec3f gy;
{ blt::vec3f aaReal;
float yaw; blt::vec3f aaWorld;
float pitch;
float roll;
} ypr;
struct euler_t
{
float psi;
float theta;
float phi;
} euler;
struct gravity_t
{
float x;
float y;
float z;
} gravity;
struct q_t
{
float x;
float y;
float z;
float w;
} q;
struct aa_t
{
float x;
float y;
float z;
} aa;
struct gy_t
{
float x;
float y;
float z;
} gy;
struct aaReal_t
{
float x;
float y;
float z;
} aaReal;
struct aaWorld_t
{
float x;
float y;
float z;
} aaWorld;
}; };
blt::vec2 current_position;
void check_for_request() void check_for_request()
{ {
@ -114,10 +61,16 @@ void check_for_request()
if (cur_time - last_time_ran > 250) if (cur_time - last_time_ran > 250)
{ {
last_time_ran = cur_time; last_time_ran = cur_time;
const std::string_view fuck_you{buffer.data()}; const std::string_view bad_code{buffer.data()};
std::string parker_hates_this{fuck_you}; const std::string this_is_terrible{bad_code};
auto cstr = parker_hates_this.c_str(); const auto result = blt::requests::send_get_request("http://" + this_is_terrible + "/get_stuff_bin");
parker_json_t data{}; if (result.size() != sizeof(everything_t))
{
BLT_WARN("Size of string from ESP32 ({}) doesn't match the size of the struct ({})", result.size(), sizeof(everything_t));
return;
}
everything_t data;
std::memcpy(&data, result.data(), sizeof(everything_t));
} }
} }
@ -125,8 +78,6 @@ void init(const blt::gfx::window_data&)
{ {
using namespace blt::gfx; using namespace blt::gfx;
BLT_TRACE("{}", blt::requests::send_get_request("https://tpgc.me/"));
global_matrices.create_internals(); global_matrices.create_internals();
resources.load_resources(); resources.load_resources();
renderer_2d.create(); renderer_2d.create();
@ -140,8 +91,6 @@ void update(const blt::gfx::window_data& data)
camera.update_view(global_matrices); camera.update_view(global_matrices);
global_matrices.update(); global_matrices.update();
ImGui::SetNextWindowSize(ImVec2(300, static_cast<float>(data.height))); ImGui::SetNextWindowSize(ImVec2(300, static_cast<float>(data.height)));
ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowPos(ImVec2(0, 0));
if (ImGui::Begin("Settings", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize)) if (ImGui::Begin("Settings", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize))