How to use raw Windows C API - TalonRing/Talon-DevKit GitHub Wiki

Reference TalonSDK.dll in your project

  • x86 - Assets/TalonSDK/Plugins/x86/TalonSDK.dll
  • x86_64 - Assets/TalonSDK/Plugins/x86_64/TalonSDK.dll

Add TalonSDK.h to your project

#pragma once


#ifdef TALON_EXPORTS
#define TALON_API __declspec(dllexport)   
#else  
#define TALON_API __declspec(dllimport)   
#endif  

extern "C"
{
	typedef void(*TalonCallback)(const char * event, const char* deviceId);

	TALON_API void talon_init(TalonCallback callback, uint8_t config, uint8_t period);

	TALON_API void talon_destroy();
	
	TALON_API void talon_scan();

	TALON_API void talon_connect(const char* deviceId);

	TALON_API void talon_config(const char* deviceId, uint8_t config);

	TALON_API float* talon_orientation(const char* deviceId);

	TALON_API float* talon_accel(const char* deviceId);

	TALON_API float* talon_gyro(const char* deviceId);

	TALON_API float* talon_mag(const char* deviceId);

	TALON_API bool talon_button(const char* deviceId, int btn);

	TALON_API bool talon_tapped(const char* deviceId);

	TALON_API bool talon_recentered(const char* deviceId);

	TALON_API int talon_battery(const char* deviceId);
}

APIs

talon_init

Create a TalonSDK instance

  • config
    Initial configuration for Talon Ring
         *  bit 0:   sensor switch      - 0: off, 1: on
         *  bit 1:   sensor raw data    - 0: disable, 1: enable raw sensor data
         *  bit 2:   low power mode     - 0: off, 1: on
         *  bit 3:   sleep mode         - 0: disable, 1: enable 60s
         *  bit 4:   ring mode          - 0: fist, 1: palm
         *  bit 5:   handedness         - 0: right, 1: left
         *  bit 6-7: n.a
  • period Sensor update period
         * range: 1 – 50hz
         * default: 20hz

talon_destroy

Destroy current instance

talon_scan

Scan nearby TalonRing devices

talon_connect

Connect TalonRing by device ID.

talon_config

Dynamic update TalonRing config

talon_orientation

Get TalonRing orientation

talon_accel

Get TalonRing accelerometer

talon_gyro

Get TalonRing gyroscope

talon_mag

Get TalonRing magnetometer

talon_button

Get TalonRing button state

talon_tapped

Check if TalonRing tapped

talon_recentered

Check if TalonRing recentered

talon_battery

Get TalonRing battery level

TalonCallback

  • event
    • "onDiscovered"
    • "onConnected"
    • "onDisconnected"
  • deviceId
    • TalonRing deviceId

Examples

#include "stdafx.h"
#include <string>
#include "TalonSDK.h"

void callback(const char* event, const char* deviceId)
{
    if (strcmp(event, "onDiscovered") == 0)
    {
        talon_connect(deviceId);
    }
}

int main()
{
    talon_init(callback, 0x01, 20);

    talon_scan();
 
    getchar();

    talon_destroy();

    return 0;
}

For more about how to use the APIs, please check out C# code for reference

⚠️ **GitHub.com Fallback** ⚠️