Skip to content

Instantly share code, notes, and snippets.

@bootrino
Created February 10, 2019 20:57
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 bootrino/1af80a7363f14c5c9ad9748b41f919f1 to your computer and use it in GitHub Desktop.
Save bootrino/1af80a7363f14c5c9ad9748b41f919f1 to your computer and use it in GitHub Desktop.
example of printing binary data in Arduino
source: https://github.com/earlephilhower/ESP8266Audio/blob/2f2898c49612f1cc1351b44ffe8541def5a26b23/src/AudioGeneratorMIDI.cpp#L71
void AudioGeneratorMIDI::midi_error(const char *msg, int curpos)
{
cb.st(curpos, msg);
#if 0
int ptr;
Serial.printf("---> MIDI file error at position %04X (%d): %s\n", (uint16_t) curpos, (uint16_t) curpos, msg);
/* print some bytes surrounding the error */
ptr = curpos - 16;
if (ptr < 0) ptr = 0;
buffer.seek( buffer.data, ptr );
for (int i = 0; i < 32; i++) {
char c;
buffer.read (buffer.data, &c, 1);
Serial.printf((ptr + i) == curpos ? " [%02X] " : "%02X ", (int) c & 0xff);
}
Serial.printf("\n");
#endif
running = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment