Skip to content

Instantly share code, notes, and snippets.

@colesnicov
Created January 12, 2020 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colesnicov/6321ee1ac9770407761692dd8c21a272 to your computer and use it in GitHub Desktop.
Save colesnicov/6321ee1ac9770407761692dd8c21a272 to your computer and use it in GitHub Desktop.
With these functions, any data can be cleaned from the PGM space.
/**
* @licence WTFPL
*
*/
#pragma once
#include "avr/pgmspace.h"
template<typename T> void PROGMEM_readAnything(const T * source, T& dest)
{
memcpy_P(&dest, source, sizeof(T));
}
template<typename T> T PROGMEM_getAnything(const T * source)
{
static T temp;
memcpy_P(&temp, source, sizeof(T));
return temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment