-
Notifications
You must be signed in to change notification settings - Fork 5
/
Logger.cpp
44 lines (37 loc) · 958 Bytes
/
Logger.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/***********************************************
HAYESDUINO PROJECT - COPYRIGHT 2013, PAYTON BYRD
Project homepage: http://hayesduino.codeplex.com
License: http://hayesduino.codeplex.com/license
***********************************************/
#include "Arduino.h"
#include "Logger.h"
#ifdef UBRR1H
#define __MEGA__
#define POWER_LED 29
#else
#define __UNO__
#endif
int Logger::available(void) { if(Serial) return Serial.available(); return 0; }
int Logger::peek(void) { if(Serial) return Serial.peek(); return 0; }
int Logger::read(void) { if(Serial) return Serial.read(); return 0; }
void Logger::flush(void) { if(Serial) Serial.flush(); }
size_t Logger::write(uint8_t var)
{
#ifdef POWER_LED
digitalWrite(POWER_LED, LOW);
#endif
if(Serial)
{
#ifdef POWER_LED
//delay(50);
digitalWrite(POWER_LED, HIGH);
#endif
return Serial.write(var);
}
#ifdef POWER_LED
//delay(50);
digitalWrite(POWER_LED, HIGH);
#endif
return 0;
}
Logger lggr;