Merge branch 'main' into nrealAirLinuxDriver-main
Signed-off-by: Jacki <jacki@thejackimonster.de>
This commit is contained in:
commit
3225fcc575
13 changed files with 164 additions and 92 deletions
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
add_subdirectory(debug_d3)
|
add_subdirectory(debug_imu)
|
||||||
add_subdirectory(debug_d4)
|
add_subdirectory(debug_mcu)
|
||||||
|
|
||||||
add_subdirectory(mcu_firmware)
|
add_subdirectory(mcu_firmware)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(xrealAirDebugD3 C)
|
project(xrealAirDebugIMU C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 17)
|
set(CMAKE_C_STANDARD 17)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
xrealAirDebugD3
|
xrealAirDebugIMU
|
||||||
src/debug.c
|
src/debug.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(xrealAirDebugD3
|
target_include_directories(xrealAirDebugIMU
|
||||||
BEFORE PUBLIC ${XREAL_AIR_INCLUDE_DIR}
|
BEFORE PUBLIC ${XREAL_AIR_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(xrealAirDebugD3
|
target_link_libraries(xrealAirDebugIMU
|
||||||
${XREAL_AIR_LIBRARY}
|
${XREAL_AIR_LIBRARY}
|
||||||
)
|
)
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Created by thejackimonster on 05.04.23.
|
// Created by thejackimonster on 05.04.23.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,23 +22,23 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "device3.h"
|
#include "device_imu.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void test3(uint64_t timestamp,
|
void test(uint64_t timestamp,
|
||||||
device3_event_type event,
|
device_imu_event_type event,
|
||||||
const device3_ahrs_type* ahrs) {
|
const device_imu_ahrs_type* ahrs) {
|
||||||
device3_quat_type orientation;
|
device_imu_quat_type orientation;
|
||||||
device3_euler_type euler;
|
device_imu_euler_type euler;
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEVICE3_EVENT_INIT:
|
case DEVICE_IMU_EVENT_INIT:
|
||||||
printf("Initialized\n");
|
printf("Initialized\n");
|
||||||
break;
|
break;
|
||||||
case DEVICE3_EVENT_UPDATE:
|
case DEVICE_IMU_EVENT_UPDATE:
|
||||||
orientation = device3_get_orientation(ahrs);
|
orientation = device_imu_get_orientation(ahrs);
|
||||||
euler = device3_get_euler(orientation);
|
euler = device_imu_get_euler(orientation);
|
||||||
printf("Roll: %.2f; Pitch: %.2f; Yaw: %.2f\n", euler.roll, euler.pitch, euler.yaw);
|
printf("Roll: %.2f; Pitch: %.2f; Yaw: %.2f\n", euler.roll, euler.pitch, euler.yaw);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -47,13 +47,13 @@ void test3(uint64_t timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char** argv) {
|
int main(int argc, const char** argv) {
|
||||||
device3_type dev3;
|
device_imu_type dev;
|
||||||
if (DEVICE3_ERROR_NO_ERROR != device3_open(&dev3, test3)) {
|
if (DEVICE_IMU_ERROR_NO_ERROR != device_imu_open(&dev, test)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
device3_clear(&dev3);
|
device_imu_clear(&dev);
|
||||||
while (DEVICE3_ERROR_NO_ERROR == device3_read(&dev3, -1));
|
while (DEVICE_IMU_ERROR_NO_ERROR == device_imu_read(&dev, -1));
|
||||||
device3_close(&dev3);
|
device_imu_close(&dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(xrealAirDebugD4 C)
|
project(xrealAirDebugMCU C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 17)
|
set(CMAKE_C_STANDARD 17)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
xrealAirDebugD4
|
xrealAirDebugMCU
|
||||||
src/debug.c
|
src/debug.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(xrealAirDebugD4
|
target_include_directories(xrealAirDebugMCU
|
||||||
BEFORE PUBLIC ${XREAL_AIR_INCLUDE_DIR}
|
BEFORE PUBLIC ${XREAL_AIR_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(xrealAirDebugD4
|
target_link_libraries(xrealAirDebugMCU
|
||||||
${XREAL_AIR_LIBRARY}
|
${XREAL_AIR_LIBRARY}
|
||||||
)
|
)
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Created by thejackimonster on 05.04.23.
|
// Created by thejackimonster on 05.04.23.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -22,22 +22,22 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "device4.h"
|
#include "device_mcu.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void test4(uint64_t timestamp,
|
void test(uint64_t timestamp,
|
||||||
device4_event_type event,
|
device_mcu_event_type event,
|
||||||
uint8_t brightness,
|
uint8_t brightness,
|
||||||
const char* msg) {
|
const char* msg) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEVICE4_EVENT_MESSAGE:
|
case DEVICE_MCU_EVENT_MESSAGE:
|
||||||
printf("Message: `%s`\n", msg);
|
printf("Message: `%s`\n", msg);
|
||||||
break;
|
break;
|
||||||
case DEVICE4_EVENT_BRIGHTNESS_UP:
|
case DEVICE_MCU_EVENT_BRIGHTNESS_UP:
|
||||||
printf("Increase Brightness: %u\n", brightness);
|
printf("Increase Brightness: %u\n", brightness);
|
||||||
break;
|
break;
|
||||||
case DEVICE4_EVENT_BRIGHTNESS_DOWN:
|
case DEVICE_MCU_EVENT_BRIGHTNESS_DOWN:
|
||||||
printf("Decrease Brightness: %u\n", brightness);
|
printf("Decrease Brightness: %u\n", brightness);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -46,13 +46,13 @@ void test4(uint64_t timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char** argv) {
|
int main(int argc, const char** argv) {
|
||||||
device4_type dev4;
|
device_mcu_type dev;
|
||||||
if (DEVICE4_ERROR_NO_ERROR != device4_open(&dev4, test4)) {
|
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev, test)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
device4_clear(&dev4);
|
device_mcu_clear(&dev);
|
||||||
while (DEVICE4_ERROR_NO_ERROR == device4_read(&dev4, -1));
|
while (DEVICE_MCU_ERROR_NO_ERROR == device_mcu_read(&dev, -1));
|
||||||
device4_close(&dev4);
|
device_mcu_close(&dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -22,7 +22,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "device4.h"
|
#include "device_mcu.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -67,13 +67,13 @@ int main(int argc, const char** argv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
device4_type dev4;
|
device_mcu_type dev;
|
||||||
if (DEVICE4_ERROR_NO_ERROR != device4_open(&dev4, NULL)) {
|
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev, NULL)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
device4_clear(&dev4);
|
device_mcu_clear(&dev);
|
||||||
device4_update_mcu_firmware(&dev4, path);
|
device_mcu_update_firmware(&dev, path);
|
||||||
device4_close(&dev4);
|
device_mcu_close(&dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// Created by thejackimonster on 30.03.23.
|
// Created by thejackimonster on 30.03.23.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// Created by thejackimonster on 29.03.23.
|
// Created by thejackimonster on 29.03.23.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -135,12 +135,12 @@ struct __attribute__((__packed__)) device_mcu_packet_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum device_mcu_event_t {
|
enum device_mcu_event_t {
|
||||||
DEVICE_MCU_EVENT_UNKNOWN = 0,
|
DEVICE_MCU_EVENT_UNKNOWN = 0,
|
||||||
DEVICE_MCU_EVENT_SCREEN_ON = 1,
|
DEVICE_MCU_EVENT_SCREEN_ON = 1,
|
||||||
DEVICE_MCU_EVENT_SCREEN_OFF = 2,
|
DEVICE_MCU_EVENT_SCREEN_OFF = 2,
|
||||||
DEVICE_MCU_EVENT_BRIGHTNESS_UP = 3,
|
DEVICE_MCU_EVENT_BRIGHTNESS_UP = 3,
|
||||||
DEVICE_MCU_EVENT_BRIGHTNESS_DOWN = 4,
|
DEVICE_MCU_EVENT_BRIGHTNESS_DOWN = 4,
|
||||||
DEVICE_MCU_EVENT_MESSAGE = 5,
|
DEVICE_MCU_EVENT_MESSAGE = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum device_mcu_error_t device_mcu_error_type;
|
typedef enum device_mcu_error_t device_mcu_error_type;
|
||||||
|
@ -183,7 +183,7 @@ device_mcu_error_type device_mcu_poll_display_mode(device_mcu_type* device);
|
||||||
|
|
||||||
device_mcu_error_type device_mcu_update_display_mode(device_mcu_type* device);
|
device_mcu_error_type device_mcu_update_display_mode(device_mcu_type* device);
|
||||||
|
|
||||||
device_mcu_error_type device_mcu_update_mcu_firmware(device_mcu_type* device, const char* path);
|
device_mcu_error_type device_mcu_update_firmware(device_mcu_type* device, const char* path);
|
||||||
|
|
||||||
device_mcu_error_type device_mcu_close(device_mcu_type* device);
|
device_mcu_error_type device_mcu_close(device_mcu_type* device);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
//
|
||||||
|
// Created by wheaney on 20.11.23.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,7 +35,18 @@
|
||||||
|
|
||||||
#define NUM_SUPPORTED_PRODUCTS 4
|
#define NUM_SUPPORTED_PRODUCTS 4
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
extern const uint16_t xreal_vendor_id;
|
extern const uint16_t xreal_vendor_id;
|
||||||
extern const uint16_t xreal_product_ids[NUM_SUPPORTED_PRODUCTS];
|
extern const uint16_t xreal_product_ids [NUM_SUPPORTED_PRODUCTS];
|
||||||
|
|
||||||
|
bool is_xreal_product_id(uint16_t product_id);
|
||||||
|
|
||||||
int xreal_imu_interface_id(uint16_t product_id);
|
int xreal_imu_interface_id(uint16_t product_id);
|
||||||
int xreal_mcu_interface_id(uint16_t product_id);
|
int xreal_mcu_interface_id(uint16_t product_id);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Created by thejackimonster on 21.04.23.
|
// Created by thejackimonster on 21.04.23.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -100,5 +100,3 @@ uint32_t crc32_checksum(const uint8_t* buf, uint32_t len) {
|
||||||
|
|
||||||
return ~CRC32_data;
|
return ~CRC32_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -517,7 +517,7 @@ device_mcu_error_type device_mcu_update_display_mode(device_mcu_type* device) {
|
||||||
return DEVICE_MCU_ERROR_NO_ERROR;
|
return DEVICE_MCU_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_mcu_error_type device_mcu_update_mcu_firmware(device_mcu_type* device, const char* path) {
|
device_mcu_error_type device_mcu_update_firmware(device_mcu_type* device, const char* path) {
|
||||||
if (!device) {
|
if (!device) {
|
||||||
device_mcu_error("No device");
|
device_mcu_error("No device");
|
||||||
return DEVICE_MCU_ERROR_NO_DEVICE;
|
return DEVICE_MCU_ERROR_NO_DEVICE;
|
||||||
|
|
|
@ -1,3 +1,29 @@
|
||||||
|
//
|
||||||
|
// Created by wheaney on 12.11.23.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "hid_ids.h"
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,8 +34,6 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hid_ids.h"
|
|
||||||
|
|
||||||
const uint16_t xreal_vendor_id = 0x3318;
|
const uint16_t xreal_vendor_id = 0x3318;
|
||||||
const uint16_t xreal_product_ids[NUM_SUPPORTED_PRODUCTS] = {
|
const uint16_t xreal_product_ids[NUM_SUPPORTED_PRODUCTS] = {
|
||||||
0x0424, // XREAL Air
|
0x0424, // XREAL Air
|
||||||
|
@ -32,22 +56,36 @@ const int xreal_mcu_interface_ids[NUM_SUPPORTED_PRODUCTS] = {
|
||||||
-1 // TODO - XREAL Air 2 Ultra MCU support via interface 0
|
-1 // TODO - XREAL Air 2 Ultra MCU support via interface 0
|
||||||
};
|
};
|
||||||
|
|
||||||
int xreal_imu_interface_id(uint16_t product_id) {
|
static int xreal_product_index(uint16_t product_id) {
|
||||||
for (int i = 0; i < NUM_SUPPORTED_PRODUCTS; i++) {
|
for (int i = 0; i < NUM_SUPPORTED_PRODUCTS; i++) {
|
||||||
if (xreal_product_ids[i] == product_id) {
|
if (xreal_product_ids[i] == product_id) {
|
||||||
return xreal_imu_interface_ids[i];
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xreal_mcu_interface_id(uint16_t product_id) {
|
bool is_xreal_product_id(uint16_t product_id) {
|
||||||
for (int i = 0; i < NUM_SUPPORTED_PRODUCTS; i++) {
|
return xreal_product_index(product_id) >= 0;
|
||||||
if (xreal_product_ids[i] == product_id) {
|
}
|
||||||
return xreal_mcu_interface_ids[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
int xreal_imu_interface_id(uint16_t product_id) {
|
||||||
}
|
const int index = xreal_product_index(product_id);
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
return xreal_imu_interface_ids[index];
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int xreal_mcu_interface_id(uint16_t product_id) {
|
||||||
|
const int index = xreal_product_index(product_id);
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
return xreal_mcu_interface_ids[index];
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
38
src/driver.c
38
src/driver.c
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Created by thejackimonster on 29.03.23.
|
// Created by thejackimonster on 29.03.23.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2023 thejackimonster. All rights reserved.
|
// Copyright (c) 2023-2024 thejackimonster. All rights reserved.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -31,9 +31,9 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
void test3(uint64_t timestamp,
|
void test_imu(uint64_t timestamp,
|
||||||
device_imu_event_type event,
|
device_imu_event_type event,
|
||||||
const device_imu_ahrs_type* ahrs) {
|
const device_imu_ahrs_type* ahrs) {
|
||||||
static device_imu_quat_type old;
|
static device_imu_quat_type old;
|
||||||
static float dmax = -1.0f;
|
static float dmax = -1.0f;
|
||||||
|
|
||||||
|
@ -74,10 +74,10 @@ void test3(uint64_t timestamp,
|
||||||
old = q;
|
old = q;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test4(uint64_t timestamp,
|
void test_mcu(uint64_t timestamp,
|
||||||
device_mcu_event_type event,
|
device_mcu_event_type event,
|
||||||
uint8_t brightness,
|
uint8_t brightness,
|
||||||
const char* msg) {
|
const char* msg) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEVICE_MCU_EVENT_MESSAGE:
|
case DEVICE_MCU_EVENT_MESSAGE:
|
||||||
printf("Message: `%s`\n", msg);
|
printf("Message: `%s`\n", msg);
|
||||||
|
@ -102,28 +102,28 @@ int main(int argc, const char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
device_imu_type dev3;
|
device_imu_type dev_imu;
|
||||||
if (DEVICE_IMU_ERROR_NO_ERROR != device_imu_open(&dev3, test3)) {
|
if (DEVICE_IMU_ERROR_NO_ERROR != device_imu_open(&dev_imu, test_imu)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_imu_clear(&dev3);
|
device_imu_clear(&dev_imu);
|
||||||
device_imu_calibrate(&dev3, 1000, true, true, false);
|
device_imu_calibrate(&dev_imu, 1000, true, true, false);
|
||||||
while (DEVICE_IMU_ERROR_NO_ERROR == device_imu_read(&dev3, -1));
|
while (DEVICE_IMU_ERROR_NO_ERROR == device_imu_read(&dev_imu, -1));
|
||||||
device_imu_close(&dev3);
|
device_imu_close(&dev_imu);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
device_mcu_type dev4;
|
device_mcu_type dev_mcu;
|
||||||
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev4, test4)) {
|
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev_mcu, test_mcu)) {
|
||||||
status = 1;
|
status = 1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_mcu_clear(&dev4);
|
device_mcu_clear(&dev_mcu);
|
||||||
while (DEVICE_MCU_ERROR_NO_ERROR == device_mcu_read(&dev4, -1));
|
while (DEVICE_MCU_ERROR_NO_ERROR == device_mcu_read(&dev_mcu, -1));
|
||||||
device_mcu_close(&dev4);
|
device_mcu_close(&dev_mcu);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (pid != waitpid(pid, &status, 0)) {
|
if (pid != waitpid(pid, &status, 0)) {
|
||||||
|
|
Reference in a new issue