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_d4)
|
||||
add_subdirectory(debug_imu)
|
||||
add_subdirectory(debug_mcu)
|
||||
|
||||
add_subdirectory(mcu_firmware)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(xrealAirDebugD3 C)
|
||||
project(xrealAirDebugIMU C)
|
||||
|
||||
set(CMAKE_C_STANDARD 17)
|
||||
|
||||
add_executable(
|
||||
xrealAirDebugD3
|
||||
xrealAirDebugIMU
|
||||
src/debug.c
|
||||
)
|
||||
|
||||
target_include_directories(xrealAirDebugD3
|
||||
target_include_directories(xrealAirDebugIMU
|
||||
BEFORE PUBLIC ${XREAL_AIR_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(xrealAirDebugD3
|
||||
target_link_libraries(xrealAirDebugIMU
|
||||
${XREAL_AIR_LIBRARY}
|
||||
)
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// 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
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,23 +22,23 @@
|
|||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#include "device3.h"
|
||||
#include "device_imu.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void test3(uint64_t timestamp,
|
||||
device3_event_type event,
|
||||
const device3_ahrs_type* ahrs) {
|
||||
device3_quat_type orientation;
|
||||
device3_euler_type euler;
|
||||
void test(uint64_t timestamp,
|
||||
device_imu_event_type event,
|
||||
const device_imu_ahrs_type* ahrs) {
|
||||
device_imu_quat_type orientation;
|
||||
device_imu_euler_type euler;
|
||||
|
||||
switch (event) {
|
||||
case DEVICE3_EVENT_INIT:
|
||||
case DEVICE_IMU_EVENT_INIT:
|
||||
printf("Initialized\n");
|
||||
break;
|
||||
case DEVICE3_EVENT_UPDATE:
|
||||
orientation = device3_get_orientation(ahrs);
|
||||
euler = device3_get_euler(orientation);
|
||||
case DEVICE_IMU_EVENT_UPDATE:
|
||||
orientation = device_imu_get_orientation(ahrs);
|
||||
euler = device_imu_get_euler(orientation);
|
||||
printf("Roll: %.2f; Pitch: %.2f; Yaw: %.2f\n", euler.roll, euler.pitch, euler.yaw);
|
||||
break;
|
||||
default:
|
||||
|
@ -47,13 +47,13 @@ void test3(uint64_t timestamp,
|
|||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
device3_type dev3;
|
||||
if (DEVICE3_ERROR_NO_ERROR != device3_open(&dev3, test3)) {
|
||||
device_imu_type dev;
|
||||
if (DEVICE_IMU_ERROR_NO_ERROR != device_imu_open(&dev, test)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
device3_clear(&dev3);
|
||||
while (DEVICE3_ERROR_NO_ERROR == device3_read(&dev3, -1));
|
||||
device3_close(&dev3);
|
||||
device_imu_clear(&dev);
|
||||
while (DEVICE_IMU_ERROR_NO_ERROR == device_imu_read(&dev, -1));
|
||||
device_imu_close(&dev);
|
||||
return 0;
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(xrealAirDebugD4 C)
|
||||
project(xrealAirDebugMCU C)
|
||||
|
||||
set(CMAKE_C_STANDARD 17)
|
||||
|
||||
add_executable(
|
||||
xrealAirDebugD4
|
||||
xrealAirDebugMCU
|
||||
src/debug.c
|
||||
)
|
||||
|
||||
target_include_directories(xrealAirDebugD4
|
||||
target_include_directories(xrealAirDebugMCU
|
||||
BEFORE PUBLIC ${XREAL_AIR_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(xrealAirDebugD4
|
||||
target_link_libraries(xrealAirDebugMCU
|
||||
${XREAL_AIR_LIBRARY}
|
||||
)
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// 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
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,22 +22,22 @@
|
|||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#include "device4.h"
|
||||
#include "device_mcu.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void test4(uint64_t timestamp,
|
||||
device4_event_type event,
|
||||
void test(uint64_t timestamp,
|
||||
device_mcu_event_type event,
|
||||
uint8_t brightness,
|
||||
const char* msg) {
|
||||
switch (event) {
|
||||
case DEVICE4_EVENT_MESSAGE:
|
||||
case DEVICE_MCU_EVENT_MESSAGE:
|
||||
printf("Message: `%s`\n", msg);
|
||||
break;
|
||||
case DEVICE4_EVENT_BRIGHTNESS_UP:
|
||||
case DEVICE_MCU_EVENT_BRIGHTNESS_UP:
|
||||
printf("Increase Brightness: %u\n", brightness);
|
||||
break;
|
||||
case DEVICE4_EVENT_BRIGHTNESS_DOWN:
|
||||
case DEVICE_MCU_EVENT_BRIGHTNESS_DOWN:
|
||||
printf("Decrease Brightness: %u\n", brightness);
|
||||
break;
|
||||
default:
|
||||
|
@ -46,13 +46,13 @@ void test4(uint64_t timestamp,
|
|||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
device4_type dev4;
|
||||
if (DEVICE4_ERROR_NO_ERROR != device4_open(&dev4, test4)) {
|
||||
device_mcu_type dev;
|
||||
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev, test)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
device4_clear(&dev4);
|
||||
while (DEVICE4_ERROR_NO_ERROR == device4_read(&dev4, -1));
|
||||
device4_close(&dev4);
|
||||
device_mcu_clear(&dev);
|
||||
while (DEVICE_MCU_ERROR_NO_ERROR == device_mcu_read(&dev, -1));
|
||||
device_mcu_close(&dev);
|
||||
return 0;
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#include "device4.h"
|
||||
#include "device_mcu.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -67,13 +67,13 @@ int main(int argc, const char** argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
device4_type dev4;
|
||||
if (DEVICE4_ERROR_NO_ERROR != device4_open(&dev4, NULL)) {
|
||||
device_mcu_type dev;
|
||||
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev, NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
device4_clear(&dev4);
|
||||
device4_update_mcu_firmware(&dev4, path);
|
||||
device4_close(&dev4);
|
||||
device_mcu_clear(&dev);
|
||||
device_mcu_update_firmware(&dev, path);
|
||||
device_mcu_close(&dev);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// 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
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// 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
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -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_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);
|
||||
|
||||
|
|
|
@ -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
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
@ -10,7 +35,18 @@
|
|||
|
||||
#define NUM_SUPPORTED_PRODUCTS 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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_mcu_interface_id(uint16_t product_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// 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
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -517,7 +517,7 @@ device_mcu_error_type device_mcu_update_display_mode(device_mcu_type* device) {
|
|||
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) {
|
||||
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
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
@ -8,8 +34,6 @@
|
|||
#include <cstdint>
|
||||
#endif
|
||||
|
||||
#include "hid_ids.h"
|
||||
|
||||
const uint16_t xreal_vendor_id = 0x3318;
|
||||
const uint16_t xreal_product_ids[NUM_SUPPORTED_PRODUCTS] = {
|
||||
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
|
||||
};
|
||||
|
||||
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++) {
|
||||
if (xreal_product_ids[i] == product_id) {
|
||||
return xreal_imu_interface_ids[i];
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool is_xreal_product_id(uint16_t product_id) {
|
||||
return xreal_product_index(product_id) >= 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
for (int i = 0; i < NUM_SUPPORTED_PRODUCTS; i++) {
|
||||
if (xreal_product_ids[i] == product_id) {
|
||||
return xreal_mcu_interface_ids[i];
|
||||
}
|
||||
}
|
||||
const int index = xreal_product_index(product_id);
|
||||
|
||||
if (index >= 0) {
|
||||
return xreal_mcu_interface_ids[index];
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
28
src/driver.c
28
src/driver.c
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// 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
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
void test3(uint64_t timestamp,
|
||||
void test_imu(uint64_t timestamp,
|
||||
device_imu_event_type event,
|
||||
const device_imu_ahrs_type* ahrs) {
|
||||
static device_imu_quat_type old;
|
||||
|
@ -74,7 +74,7 @@ void test3(uint64_t timestamp,
|
|||
old = q;
|
||||
}
|
||||
|
||||
void test4(uint64_t timestamp,
|
||||
void test_mcu(uint64_t timestamp,
|
||||
device_mcu_event_type event,
|
||||
uint8_t brightness,
|
||||
const char* msg) {
|
||||
|
@ -102,28 +102,28 @@ int main(int argc, const char** argv) {
|
|||
}
|
||||
|
||||
if (pid == 0) {
|
||||
device_imu_type dev3;
|
||||
if (DEVICE_IMU_ERROR_NO_ERROR != device_imu_open(&dev3, test3)) {
|
||||
device_imu_type dev_imu;
|
||||
if (DEVICE_IMU_ERROR_NO_ERROR != device_imu_open(&dev_imu, test_imu)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
device_imu_clear(&dev3);
|
||||
device_imu_calibrate(&dev3, 1000, true, true, false);
|
||||
while (DEVICE_IMU_ERROR_NO_ERROR == device_imu_read(&dev3, -1));
|
||||
device_imu_close(&dev3);
|
||||
device_imu_clear(&dev_imu);
|
||||
device_imu_calibrate(&dev_imu, 1000, true, true, false);
|
||||
while (DEVICE_IMU_ERROR_NO_ERROR == device_imu_read(&dev_imu, -1));
|
||||
device_imu_close(&dev_imu);
|
||||
return 0;
|
||||
} else {
|
||||
int status = 0;
|
||||
|
||||
device_mcu_type dev4;
|
||||
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev4, test4)) {
|
||||
device_mcu_type dev_mcu;
|
||||
if (DEVICE_MCU_ERROR_NO_ERROR != device_mcu_open(&dev_mcu, test_mcu)) {
|
||||
status = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
device_mcu_clear(&dev4);
|
||||
while (DEVICE_MCU_ERROR_NO_ERROR == device_mcu_read(&dev4, -1));
|
||||
device_mcu_close(&dev4);
|
||||
device_mcu_clear(&dev_mcu);
|
||||
while (DEVICE_MCU_ERROR_NO_ERROR == device_mcu_read(&dev_mcu, -1));
|
||||
device_mcu_close(&dev_mcu);
|
||||
|
||||
exit:
|
||||
if (pid != waitpid(pid, &status, 0)) {
|
||||
|
|
Reference in a new issue