esp32_BNO08x/include/BNO08xTestHelper.hpp

96 lines
2.2 KiB
C++
Raw Normal View History

2024-11-14 21:29:46 +00:00
#pragma once
#include "stdio.h"
#include "BNO08x.hpp"
class BNO08xTestHelper
{
private:
inline static BNO08x* test_imu = nullptr;
inline static bno08x_config_t imu_cfg;
2024-11-14 22:04:01 +00:00
static const constexpr char* TAG = "BNO08xTestHelper";
2024-11-14 21:29:46 +00:00
public:
2024-11-14 22:04:01 +00:00
static void print_test_start_banner(const char* TEST_TAG)
2024-11-14 21:29:46 +00:00
{
printf("------------------------BEGIN TEST: %s------------------------\n\r", TEST_TAG);
}
2024-11-14 22:04:01 +00:00
static void print_test_end_banner(const char* TEST_TAG)
2024-11-14 21:29:46 +00:00
{
printf("------------------------END TEST: %s------------------------\n\r", TEST_TAG);
}
2024-11-14 22:04:01 +00:00
static void print_test_msg(const char* TEST_TAG, const char* msg)
2024-11-14 21:29:46 +00:00
{
printf("%s: %s: %s\n\r", TAG, TEST_TAG, msg);
}
static void set_test_imu_cfg(bno08x_config_t cfg)
{
imu_cfg = cfg;
}
static void create_test_imu()
{
2024-11-14 22:04:01 +00:00
if (test_imu != nullptr)
2024-11-14 21:29:46 +00:00
destroy_test_imu();
2024-11-14 22:04:01 +00:00
2024-11-14 21:29:46 +00:00
test_imu = new BNO08x();
}
static void destroy_test_imu()
{
if (test_imu != nullptr)
{
delete test_imu;
test_imu = nullptr;
}
}
static BNO08x* get_test_imu()
{
return test_imu;
}
2024-11-14 22:04:01 +00:00
static esp_err_t call_init_config_args()
{
if (test_imu == nullptr)
return ESP_FAIL;
return test_imu->init_config_args();
}
static esp_err_t call_init_gpio()
{
if (test_imu == nullptr)
return ESP_FAIL;
return test_imu->init_gpio();
}
static esp_err_t call_init_hint_isr()
{
if (test_imu == nullptr)
return ESP_FAIL;
return test_imu->init_hint_isr();
}
static esp_err_t call_init_spi()
{
if (test_imu == nullptr)
return ESP_FAIL;
return test_imu->init_spi();
}
static esp_err_t call_launch_tasks()
{
if (test_imu == nullptr)
return ESP_FAIL;
return test_imu->launch_tasks();
}
2024-11-14 21:29:46 +00:00
};