Coder Social home page Coder Social logo

slocomptech / byteconvert_arduino Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 3.0 33 KB

Library for Arduino to convert varuables to bytes and back

License: MIT License

C++ 100.00%
arduino arduino-library arduino-nano arduino-sketch conversion convert converter transmission i2c spi

byteconvert_arduino's Introduction

Byteconvert

ByteConvert

Build Status Packagist

What's about ?

Have you ever wanted to transmit int,short,long,double or any other numeric type over I2C,SPI,serial or other protocol or bus, but you converted variable to string to be able to transmit it char by char. This library enables you to convert any numeric value to bytes or other way around and you can also print array of bytes.

What you need to consider, when you are using this library

When you are using this library, you need to consider variable byte size, because if you are using different platforms, then there may be some errors, because int on platform 1 has 4 bytes and int on platform 2 may has 2 bytes.

Examples

Convert numeric variable for eg. int,short,float,double to array of bytes.

int somevar = 5;
size_t blk_size = 0;
uint8_t *block = ByteConvert::varToArray<int>(blk_size,somevar);

// Use array

delete block; // Don't forget to free memory, when you don't need array any more

Convert array of bytes to numeric variable.

uint8_t *block; // Predefined byte array with size of int
int somevar = ByteConvert::arrayToVar<int>(block);

// Use block & somevar

delete block; // Don't forget to free memory, when you don't need array any more

// Use somevar

Convert array of bytes to string of hex characters

size_t blk_size; // Predefined size of byte array
uint8_t *block; // Predefined byte array with size of int
String somevar = ByteConvert::arrayToString(blk_size,block);

// Use block & somevar

delete block; // Don't forget to free memory, when you don't need array any more

// Use somevar

Convert string of hex characters to array of bytes

String somevar = ""; // Predefined string
size_t blk_size = 0; 
uint8_t *block = ByteConvert::stringToArray(blk_size,somevar);

// Use block 

delete block; // Don't forget to free memory, when you don't need array any more

byteconvert_arduino's People

Contributors

familqasimov avatar per1234 avatar slocomptech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

byteconvert_arduino's Issues

Logo for ByteConvert

Hi sir. I'm graphic designer. I have studied your work and I think a new design will make you more visible. I would like to offer logo. I can give you all the formats of the design free. If you want a change please specify.

byte converter

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.