GithubHelp home page GithubHelp logo

datatransfer's Introduction

Data Transfer library

Meant to efficiently store and send data. It essentially "sits on top of" the RadioHead library that interfaces with the rf69 LoRA radio and allows me to very easily specify bits to turn on/off. In total, I think I can send all the controller data for my quadruped with 4 bytes... which should be SUPERRR fast! I may consider making this a standalone class(this is currently only useful for those using the same radio as me) but we shall see.

How To Use?

First, you need to instantiate an RH_RF69 radio object. The arguments specify SPI pins, and can be modified in Config.h RH_RF69 rf69(RFM69_CS, RFM69_INT);

This needs to be passed to a 'Transfer object as such: Transfer dataBuffer(&rf69, BUFFER_SIZE, key);

BUFFER _SIZE is the size of the buffer array to be sent across devices, in bytes (can be modified in Config.h) key is a 16 byte array for data encryption

Functions

init() Initializes the dataBuffer and performs radio setup. This includes a manual reset of the radio via an interrupt pin on G0; this pin can be changed in Config.h

write(BIT_OR_BYTE bitOrByte, int index, int value) Allows you to write data to the local Transfer object

Where: bitOrByte specifies whether data is written to a bit or a byte in the buffer; choose between 'BIT' or 'BYTE index is the bit or byte you want to modify

  • If you wish to modify a BIT, index allows you to select the number bit you wish to change. Indexes larger than 8 will shift to the next byte, and the bit's index in the byte is determined by index % 8, counting from right to left and starting from 0 in each byte.
  • If you wish to modify a BYTE, then you may select the index in the buffer to modify, starting with 0, obviously. value is required only for bytes; this is simply the value you want to write the selected byte.

read(BIT_OR_BYTE bitOrByte, int index) Allows you to read data in the local Transfer object

Where: bitOrByte specifies whether data is written to a bit or a byte in the buffer; choose between BIT or BYTE index is the bit or byte you want to read

  • If you wish to read a BIT, index allows you to select the number bit you wish to read. Indexes larger than 8 will shift to the next byte, and the bit's index in the byte is determined by index % 8, counting from right to left and starting from 0 in each byte.
  • If you wish to read a BYTE, then you may select the index in the buffer to read, starting with 0, obviously.

This is recommended to be used after a call to receive(), which handles the reception of a buffer sent fro manother device.

send(bool resetBuffer) Sends a local buffer to a different device. Defaults to resetting the local buffer, but this can be overwritten by specifying false in the argument.

Note that this will wait for the buffer to be sent, which may cause issues

receive() Receives a buffer from a different device. Returns true if successful, false if not.

Common use:

For transmitting data, it makes sense to use write() and send. Send will reset the local buffer to 0 for future calls to write().

For receiving data, it makes sense to use receive(), and upon a return of true, to 'read() relevant data.

datatransfer's People

Contributors

seanboe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.