Skip to content

Instantly share code, notes, and snippets.

View connornishijima's full-sized avatar

Lixie Labs connornishijima

View GitHub Profile
@connornishijima
connornishijima / to_string.cpp
Created April 27, 2022 14:37
Compact universal "to_string()" conversion
// Allows for a "print()" function that accepts char* to take any common variable type
// Also allows you to detect the type of any variable if that type was first defined
// in a MAKE_TYPE_INFO(type) macro
// @lixielabs 4/27/22
template <typename t_type> struct type_info { static const char * name; }; // Define type_info
template <typename t_type> const char * type_info<t_type>::name = "unknown"; // Set default state
#define TYPE_NAME(var) type_info< typeof(var) >::name // Macro to parse variable type name
#define MAKE_TYPE_INFO(type) template <> const char * type_info<type>::name = #type; // Macro to define variable type name
const byte score [] PROGMEM = {
// YOUR BYTE STREAM GOES HERE!
};
const byte voicePins[] PROGMEM = {2, 3, 4, 5, 6, 7};
byte voiceEnabled[6];
byte voiceType[6];