GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SloCompTech/ByteConvert_arduino: Library for Arduino to convert varuables to bytes and back

BranchesTags
Open more actions menu

Latest commit

 

History

24 Commits
24 Commits

Folders and files

NameName
Last commit message
Last commit date
examples/SimpleTest
examples/SimpleTest
 
 
extras/graphics
extras/graphics
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
keywords.txt
keywords.txt
 
 
library.properties
library.properties
 
 

Repository files navigation

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

About

Library for Arduino to convert varuables to bytes and back

Topics

arduinoarduino-libraryarduino-nanoarduino-sketchconversionconvertconverteri2cspitransmission

Resources

Readme
MIT license
Activity

Stars

13 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.