{"id":13743762,"url":"https://github.com/OpenBCI/OpenBCI_Cyton_Library","last_synced_at":"2025-05-09T01:31:49.885Z","repository":{"id":43026257,"uuid":"44399860","full_name":"OpenBCI/OpenBCI_Cyton_Library","owner":"OpenBCI","description":"Repository for OpenBCI Cyton Arduino Libraries","archived":false,"fork":false,"pushed_at":"2024-10-09T19:05:23.000Z","size":5686,"stargazers_count":89,"open_issues_count":23,"forks_count":89,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-15T14:35:51.718Z","etag":null,"topics":["cyton","firmware","library","openbci"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenBCI.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-16T17:16:31.000Z","updated_at":"2024-11-14T08:13:23.000Z","dependencies_parsed_at":"2022-09-10T16:00:32.482Z","dependency_job_id":null,"html_url":"https://github.com/OpenBCI/OpenBCI_Cyton_Library","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenBCI%2FOpenBCI_Cyton_Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenBCI%2FOpenBCI_Cyton_Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenBCI%2FOpenBCI_Cyton_Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenBCI%2FOpenBCI_Cyton_Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenBCI","download_url":"https://codeload.github.com/OpenBCI/OpenBCI_Cyton_Library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253174364,"owners_count":21865852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cyton","firmware","library","openbci"],"created_at":"2024-08-03T05:00:56.628Z","updated_at":"2025-05-09T01:31:45.365Z","avatar_url":"https://github.com/OpenBCI.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"[![Stories in Ready](https://badge.waffle.io/OpenBCI/OpenBCI_32bit_Library.png?label=ready\u0026title=Ready)](https://waffle.io/OpenBCI/OpenBCI_32bit_Library)\n# OpenBCI 32bit Library\n\nThe official library for the OpenBCI 32bit Board.\n\n## Table of Contents:\n\n1. [Minimums](#minimums)\n2. [Installing](#installing)\n3. [Upgrading](#upgrading)\n4. [Downgrading](#downgrading)\n3. [General Overview](#generalOverview)\n  1. [Includes](#includes)\n  2. [setup()](#setup)\n  3. [loop()](#loop)\n4. [System Overview](#systemOverview)\n5. [Reference Guide](#referenceGuide)\n  1. [Functions](#functions)\n  2. [Enums](#enums)\n\n## \u003ca name=\"minimums\"\u003e\u003c/a\u003e Minimums:\n\nYou just opened your OpenBCI (congrats!) and want to get started programming the firmware right now?! Ok, ok do the following minimums!\n1. Install the dongle drivers [from FTDI](http://www.ftdichip.com/FTDrivers.htm) for your operating system.\n2. Download the latest Arduino IDE software from the [Arduino site](www.arduino.cc)\n3. Follow the 2nd installation method \"Manual install by copying ZIP file\" to install the latest chipKIT-core hardware files from the [chipKIT-core wiki](http://chipkit.net/wiki/index.php?title=ChipKIT_core)\n\n## \u003ca name=\"installing\"\u003e\u003c/a\u003e Installing:\n\n1. Download this repository zip or clone this repo (we clone directly into the `libraries` folder for development)\n2. Download [OpenBCI_32bit_SD](https://github.com/OpenBCI/OpenBCI_32bit_SD)\n3. Move both of the folders into your `libraries` folder (please make a folder in Arduino named libraries if you don't have one)\n  * Mac OSX: User/Documents/Arduino/libraries\n  * Windows: /My Documents/Arduino/libraries\n4. Restart Arduino IDE\n5. Open `DefaultBoard.ino` for a full featured example.\n6. Hack and make awesome stuff!\n\n## \u003ca name=\"upgrading\"\u003e\u003c/a\u003e Upgrading:\n\nCheckout the [upgrade guide](./UPGRADE_GUIDE.md)!\n\n## \u003ca name=\"downgrading\"\u003e\u003c/a\u003e Downgrading:\n\nHave a bunch of custom firmware based on the original firmware? Have no fear for previous releases are [here](https://github.com/OpenBCI/OpenBCI_32bit_Library/releases) and [here for the radios if needed](https://github.com/OpenBCI/OpenBCI_Radios/releases).\n\n## \u003ca name=\"generalOverview\"\u003e\u003c/a\u003e General Overview:\n\nYour needs dictate what you need to include! This saves a ton of precious memory space!\n\n### \u003ca name=\"includes\"\u003e\u003c/a\u003e Includes:\n\n#### Default OpenBCI with SD Card Functionality\n\nIn order to use the SD card write functionality, you must not only include the file `SD_Card_Stuff.ino` located in examples/DefaultBoard, you must include the following:\n\nHeaders:\n```Arduino\n#include \u003cOBCI32_SD.h\u003e\n#include \u003cDSPI.h\u003e\n#include \u003cEEPROM.h\u003e\n#include \u003cOpenBCI_32bit_Library.h\u003e\n#include \u003cOpenBCI_32bit_Library_Definitions.h\u003e\n```\n\nVariables used by `SD_Card_Stuff.ino`:\n```Arduino\nboolean addAccelToSD = false;\nboolean addAuxToSD = false;\nboolean SDfileOpen = false;\n```\n\n#### Bare OpenBCI Board with no SD card\n\nHeaders:\n```Arduino\n#include \u003cDSPI.h\u003e\n#include \u003cOpenBCI_32bit_Library.h\u003e\n#include \u003cOpenBCI_32bit_Library_Definitions.h\u003e\n```\n\nYou do not need to declare any variables...\n\n### \u003ca name=\"setup\"\u003e\u003c/a\u003e setup():\n\n#### Accel (default)\n```Arduino\nvoid setup() {\n  board.begin(); // Bring up the OpenBCI Board\n  // The board will use accel data by default\n}\n```\n\n#### Aux\n```Arduino\nvoid setup() {\n  board.begin(); // Bring up the OpenBCI Board\n  board.useAccel(false); // Notify the board we want to use aux data, this effects `::sendChannelData()`\n}\n```\n\n### \u003ca name=\"loop\"\u003e\u003c/a\u003e loop():\n\nWe will start with the basics here, and work our way up... The loop function can be thought of as the meat and core executor of the OpenBCI_32bit_Library functionality. Keep in mind the main purpose of this library is to stream data from the ADS1299 to the computer, that's our focus, everything takes a back seat to that.\n\nA bare board, not using the SD, accel, or aux data must have the following:\n```Arduino\nvoid loop() {\n  board.loop();\n  if (board.streaming) {\n    if (board.channelDataAvailable) {\n      // Read from the ADS(s), store data, set channelDataAvailable flag to false\n      board.updateChannelData();\n\n      board.sendChannelData();\n    }\n  }\n\n  // Check the serial port for new data\n  if (board.hasDataSerial0()) {\n    // Read one char and process it\n    board.processChar(board.getCharSerial0());\n  }\n}\n```\nThe first `if` statement is only `true` if a `b` command is ran through the `processChar` function. The next `if` statement exploits a `volatile` interrupt driven `boolean` called `channelDataAvailable`. This interrupt driven system is new as of firmware version 2.0.0 a discussion of it can be [found here](https://github.com/OpenBCI/OpenBCI_32bit_Library/issues/22). If the ADS1299 has signaled to the Board new data is ready, the function `updateChannelData()` is executed. This function will grab new data from the Board's ADS1299 (and from the daisy's ADS1299) and store that data to the arrays: `lastBoardDataRaw`, `boardChannelDataRaw`, `meanBoardDataRaw`, `lastDaisyDataRaw`, `daisyChannelDataRaw`, `meanDaisyDataRaw`, which can be accessed to drive filters or whatever your heart desires.\n\n\n## \u003ca name=\"systemOverview\"\u003e\u003c/a\u003e System Overview:\n\n### Sending Channel Data\nIn the OpenBCI system, and with most wireless systems, we are restricted by the rate at which we can send data.\n\nIf you send a packet from the Pic32 to the Device RFduino and you start it with `0x41`, write 31 bytes, and follow with `0xCX` (where `X` can be `0-F` hex) then the packet will immediately be sent from the Device radio. This is counter to how if you want to send a message longer than 31 bytes (takes over two packets to transmit from Device radio to Host radio (Board to Dongle)) then you simply write the message, and that message will be sent in a multipacket format that allows it to be reassembled on the Dongle. This reassembling of data is critical to over the air programming.\n\n# \u003ca name=\"referenceGuide\"\u003e\u003c/a\u003e Reference Guide:\n\n## \u003ca name=\"functions\"\u003e\u003c/a\u003e Functions:\n\n### accelHasNewData()\n\nReads a status register to see if there is new accelerometer data.\n\n**_Returns_** {boolean}\n\n`true` if the accelerometer has new data.\n\n### accelUpdateAxisData()\n\nReads from the accelerometer to get new X, Y, and Z data. Updates the global array `axisData`.\n\n### begin()\n\nThe function the OpenBCI board will call in `setup()`.\n\n### beginDebug()\n\nThe function the OpenBCI board will call in setup. Turns sniff mode on and allows you to tap into the serial port that is broken out on the OpenBCI 32bit board.\n\nYou must alter `Board_Defs.h` file located:\n\nOn Mac:    \n`/Users/username/Documents/Arduino/hardware/chipkit-core/pic32/variants/openbci/Board_Defs.h`\nOn Windows:\n\n`C:\\Users\\username\\Documents\\Arduino\\hardware\\chipkit-core\\pic32\\variants\\openbci\\Board_Defs.h`\n\nSpecifically lines `311` and `313`, change `7` and `10` to `11` and `12` for `_SER1_TX_PIN` and `_SER1_RX_PIN` respectively. Check out this sweet gif if you are a visual person http://g.recordit.co/3jH01sMD6Y.gif\n\nYou will need to reflash your board! But now you can connect to pins `11` (`TX`) and `12` (`RX`) via any 3V3 serial to USB driver. Remember to use 3V3, 115200 baud, and have a common ground!\n\n### hasDataSerial0()\n\nCalled in every `loop()` and checks `Serial0`.\n\n**_Returns_** {boolean}\n\n`true` if there is data ready to be read.\n\n### hasDataSerial1()\n\nCalled in every `loop()` and checks `Serial1`.\n\n**_Returns_** {boolean}\n\n`true` if there is data ready to be read.\n\n### processChar(character)\n\nProcess one char at a time from serial port. This is the main command processor for the OpenBCI system. Considered mission critical for normal operation.\n\n**_character_** {char}\n\nThe character to process.\n\n**_Returns_** {boolean}\n\n`true` if the command was recognized, `false` if not.\n\n### getCharSerial0()\n\nIf `hasDataSerial0()` is `true` then this function is called. Reads from `Serial0` first and foremost, which comes from the RFduino. If no data is available then returns a `0x00` which is NOT a command that the system will recognize as a safe guard.\n\n**_Returns_** {char}\n\nThe character from the serial port.\n\n### getCharSerial1()\n\nIf `hasDataSerial1()` is `true` then this function is called. Reads from `Serial1` which comes from the external serial port. If no data is available then returns a `0x00` which is NOT a command that the system will recognize as a safe guard.\n\n**_Returns_** {char}\n\nThe character from the serial port.\n\n### sendChannelData()\n\nWrites channel data, aux data, and footer to serial port or over wifi. Based on global variables `useAux` and `useAccel` Must keep for portability.\n\nIf `curAccelMode` is ACCEL_MODE_OFF then  then sends data from `auxData` array and sets the contents of `auxData` to `0` after send. `board.useAccel(false)`\nIf `curAccelMode` is ACCEL_MODE_ON then  then sends data from `axisData` array and sets the contents of `axisData` to `0` after send. `board.useAccel(true)`\n\n### updateChannelData()\n\nCalled when the board ADS1299 has new data available. If there is a daisy module attached, that data is also fetched here.\n\n## \u003ca name=\"enums\"\u003e\u003c/a\u003e ENUMS:\n\n### BOARD_MODE\n\nBoard mode changes the hardware pins.\n\n#### BOARD_MODE_DEFAULT\n\n`0` - Board will operate leave all pins in default mode.\n\n#### BOARD_MODE_DEBUG\n\n`1` - Board will output serial debug data out of the external serial port.\n\n#### BOARD_MODE_ANALOG\n\n`2` - Board will read from `A6` (`D11`), `A7` (`D12`), and `A8` (`D13`). `A8` is only is use when there is no wifi present. The analog to digital converter is 10bits and the data will be in .  \n\n|Pin|Aux Bytes|Notes|\n|----|----|----|\n|`A6`|0:1|`D11`|\n|`A7`|2:3|`D12`|\n|`A8`|4:5|`D13` - If wifi not present|\n\n#### BOARD_MODE_DIGITAL\n\n`3` - Board will read from `D11`, `D12`, `D13` (if wifi not present), `D17`, and `D18` (if wifi not present).\n\n|Pin|Aux Byte|Notes|\n|----|----|----|\n|`D11`|0||\n|`D11`|1||\n|`D13`|2|If wifi not present|\n|`D17`|3||\n|`D18`|4|If wifi not present|\n\n### PACKET_TYPE\n\n#### PACKET_TYPE_ACCEL\n\n`0` - End of standard stream packet.\n\n#### PACKET_TYPE_RAW_AUX\n\n`1` - End of stream packet with raw packet.\n\n#### PACKET_TYPE_USER_DEFINED\n\n`2` - End of stream packet, user defined.\n\n#### PACKET_TYPE_ACCEL_TIME_SET\n\n`3` - End of time sync up with accelerometer stream packet.\n\n#### PACKET_TYPE_ACCEL_TIME_SYNC\n\n`4` - End of time synced stream packet.\n\n#### PACKET_TYPE_RAW_AUX_TIME_SET\n\n`5` - End of time sync up stream packet.\n\n#### PACKET_TYPE_RAW_AUX_TIME_SYNC\n\n`6` - End of time synced stream packet.\n\n### SAMPLE_RATE\n\n#### SAMPLE_RATE_16000\n\n`0` - Sample rate 16000Hz\n\n#### SAMPLE_RATE_8000\n\n`1` - Sample rate 8000Hz\n\n#### SAMPLE_RATE_4000\n\n`2` - Sample rate 4000Hz\n\n#### SAMPLE_RATE_2000\n\n`3` - Sample rate 2000Hz\n\n#### SAMPLE_RATE_1000\n\n`4` - Sample rate 1000Hz\n\n#### SAMPLE_RATE_500\n\n`5` - Sample rate 500Hz\n\n#### SAMPLE_RATE_250\n\n`6` - Sample rate 250Hz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOpenBCI%2FOpenBCI_Cyton_Library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOpenBCI%2FOpenBCI_Cyton_Library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOpenBCI%2FOpenBCI_Cyton_Library/lists"}