Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean-up and add fixed welcome jingle #80

Open
wants to merge 10 commits into
base: DEV
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ Temporary Items

# TonUINO
/tools/*.pyc

# Eclipse IDE
.project
42 changes: 42 additions & 0 deletions Logging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef LOGGING_H
#define LOGGING_H

#include <SoftwareSerial.h>

/*
* Global serial device.
*/
SoftwareSerial mySoftwareSerial(2, 3); // RX, TX

/**
* Global serial device.
*/
void log_buffer(byte * buffer, byte bufferSize);

/**
* Logging macros.
*/
#if defined(DEBUG_VERBOSE)
# define DEBUG_VERBOSE_PRINTLN(x) Serial.println(x)
# define DEBUG_VERBOSE_PRINT(x) Serial.print(x)
# define DEBUG_PRINTLN(x) Serial.println(x)
# define DEBUG_PRINT(x) Serial.print(x)
# define DEBUG_PRINTI(x, b) Serial.print(x, b)
# define DEBUG_PRINTB(b, l) log_buffer(b, l)
#elif defined(DEBUG)
# define DEBUG_VERBOSE_PRINTLN(x)
# define DEBUG_VERBOSE_PRINT(x)
# define DEBUG_PRINTLN(x) Serial.println(x)
# define DEBUG_PRINT(x) Serial.print(x)
# define DEBUG_PRINTI(x, b) Serial.print(x, b)
# define DEBUG_PRINTB(b, l) log_buffer(b, l)
#else
# define DEBUG_VERBOSE_PRINTLN(x)
# define DEBUG_VERBOSE_PRINT(x)
# define DEBUG_PRINTLN(x)
# define DEBUG_PRINT(x)
# define DEBUG_PRINTI(x, b)
# define DEBUG_PRINTB(b, l)
#endif

#endif
11 changes: 11 additions & 0 deletions Logging.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "Logging.h"

/*
* Helper routine to dump a byte array as hex values to serial.
*/
void log_buffer(byte * buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);
}
}
Loading