Skip to content

shokoban/thinkgearLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThinkgearLib for Mindwave

This code is for get data from Mindwave that is machine made by NeuroSky.

なんか適当に作った

Requirements

linux

  • libbluetooth-dev

CMakeLists.txt

For Linux.

cmake_minimum_required(VERSION 3.10)

project(thinkgearLib)

set(CMAKE_C_STANDARD 11)

file(GLOB_RECURSE THINKGEAR_LIB
        thinkgearLib/*.c
        thinkgearLib/utils/*.c
        thinkgearLib/core/*.c
        thinkgearLib/core/win/*.c
        thinkgearLib/core/linux/*.c
)
add_executable(thinkgearLib main.c ${THINKGEAR_LIB})
target_link_libraries(thinkgearLib bluetooth)

For windows.

cmake_minimum_required(VERSION 3.10)

project(thinkgearLib)

set(CMAKE_C_STANDARD 11)

file(GLOB_RECURSE THINKGEAR_LIB
        thinkgearLib/*.c
        thinkgearLib/utils/*.c
        thinkgearLib/core/*.c
        thinkgearLib/core/win/*.c
        thinkgearLib/core/linux/*.c
)
add_executable(thinkgearLib main.c ${THINKGEAR_LIB})
# target_link_libraries(thinkgearLib bluetooth)

main.c

#include <stdio.h>
#include <time.h>

#ifdef _WIN32
#include <Windows.h>
#endif
#include "thinkgearLib/thinkgear.h"

int main(int argc, char **argv)
{
    // difine socket and port
#ifdef _WIN32
    handle_t sckt;
    char *port = "com3";
#elif __GNUC__
    int sckt;
    char *port = "C4:64:E3:E8:CF:DD";
#endif

    printf("Connecting to Neurosky device.\n");
    // connect to the device
    tg_packet_t packet;
    if ((tg_connect(&sckt, port)) == TG_CANNOT_CONNECT)
    {
        // if the connection fails, print the error
        printf("Error:  Could NOT Connect to Neurosky device. (code: 0x%x)\n", TG_CANNOT_CONNECT);
        return 1;
    }
    printf("Connected to Neurosky device.\n");

    // get the data for 30 seconds
    time_t start = time(NULL);
    while (time(NULL) - start < 30)
    {
        // Packet acquisition
        // Raw data is acquired every 1/512 of a second.
        // Other data is acquired every second.
        tg_get_packet(sckt, &packet);

        // Print data
        if (packet.flag.raw_wave != 0)
        {
            printf("********** raw wave **********\n");
            tg_show_raw_wave(packet);
            printf("******************************\n");
        }
        // poor signal and other data
        if (packet.flag.poor != 0)
        {
            printf("************ data ************\n");
            tg_show_poor(packet);
            tg_show_esense(packet);
            tg_show_asic_data(packet);
            printf("******************************\n");
        }
    }

    // disconnect from the device
    tg_disconnect(sckt);
    printf("Disconnected from Neurosky device.\n");

    return 0;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors