Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 578c58d

Browse files
Merge pull request #6 from alfran/development
Fixes, updates
2 parents 71cb774 + eb1d553 commit 578c58d

File tree

8 files changed

+423
-550
lines changed

8 files changed

+423
-550
lines changed

cores/arduino/Print.cpp

100755100644
Lines changed: 190 additions & 248 deletions
Large diffs are not rendered by default.

cores/arduino/Print.h

100755100644
Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,60 +25,61 @@
2525

2626
#include <types.h>
2727
#include "WString.h"
28+
#include "Printable.h"
2829

29-
enum {
30-
Byte = 0,
31-
BIN = 2,
32-
OCT = 8,
33-
DEC = 10,
34-
HEX = 16
35-
};
36-
37-
class Print {
38-
public:
39-
virtual size_t write(uint8 ch) = 0;
40-
virtual size_t write(const char *str);
41-
virtual size_t write(const void *buf, uint32 len);
30+
#define DEC 10
31+
#define HEX 16
32+
#define OCT 8
33+
#define BIN 2
4234

43-
size_t print(const String &);
44-
size_t print(char);
45-
size_t print(const char[]);
46-
size_t print(uint8, int=DEC);
47-
size_t print(int, int=DEC);
48-
size_t print(unsigned int, int=DEC);
49-
size_t print(long, int=DEC);
50-
size_t print(unsigned long, int=DEC);
51-
size_t print(long long, int=DEC);
52-
size_t print(unsigned long long, int=DEC);
53-
size_t print(double, int=2);
54-
size_t println(void);
55-
size_t println(const String &s);
56-
size_t println(char);
57-
size_t println(const char[]);
58-
size_t println(uint8, int=DEC);
59-
size_t println(int, int=DEC);
60-
size_t println(unsigned int, int=DEC);
61-
size_t println(long, int=DEC);
62-
size_t println(unsigned long, int=DEC);
63-
size_t println(long long, int=DEC);
64-
size_t println(unsigned long long, int=DEC);
65-
size_t println(double, int=2);
66-
#ifdef SUPPORTS_PRINTF
67-
// Roger Clark. Work in progress to add printf support
68-
int printf(const char * format, ...);
69-
#endif
35+
class Print
36+
{
37+
private:
38+
int write_error;
39+
size_t printNumber(unsigned long, uint8_t);
40+
size_t printFloat(double, uint8_t);
41+
protected:
42+
void setWriteError(int err = 1) { write_error = err; }
43+
public:
7044
Print() : write_error(0) {}
71-
45+
7246
int getWriteError() { return write_error; }
7347
void clearWriteError() { setWriteError(0); }
48+
49+
virtual size_t write(uint8_t) = 0;
50+
size_t write(const char *str) {
51+
if (str == NULL) return 0;
52+
return write((const uint8_t *)str, strlen(str));
53+
}
54+
virtual size_t write(const uint8_t *buffer, size_t size);
55+
size_t write(const char *buffer, size_t size) {
56+
return write((const uint8_t *)buffer, size);
57+
}
58+
59+
size_t print(const __FlashStringHelper *);
60+
size_t print(const String &);
61+
size_t print(const char[]);
62+
size_t print(char);
63+
size_t print(unsigned char, int = DEC);
64+
size_t print(int, int = DEC);
65+
size_t print(unsigned int, int = DEC);
66+
size_t print(long, int = DEC);
67+
size_t print(unsigned long, int = DEC);
68+
size_t print(double, int = 2);
69+
size_t print(const Printable&);
7470

75-
protected:
76-
void setWriteError(int err = 1) { write_error = err; }
77-
78-
private:
79-
int write_error;
80-
size_t printNumber(unsigned long long, uint8);
81-
size_t printFloat(double, uint8);
71+
size_t println(const __FlashStringHelper *);
72+
size_t println(const String &s);
73+
size_t println(const char[]);
74+
size_t println(char);
75+
size_t println(unsigned char, int = DEC);
76+
size_t println(int, int = DEC);
77+
size_t println(unsigned int, int = DEC);
78+
size_t println(long, int = DEC);
79+
size_t println(unsigned long, int = DEC);
80+
size_t println(double, int = 2);
81+
size_t println(const Printable&);
82+
size_t println(void);
8283
};
8384

8485
#endif

cores/arduino/Tone.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
5252
if (duration > 0 ) toggle_count = 2 * frequency * duration / 1000;
5353
else toggle_count = -1;
5454
timer.setPrescaleFactor(CYCLES_PER_MICROSECOND); // microseconds
55-
timer.setOverflow(1000000/frequency/4);
55+
timer.setOverflow(1000000/frequency/16);
5656
timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE);
5757
timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update
5858
timer.toneAttachInterrupt(TIMER_CH1, handler_tone);

cores/arduino/boards.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
#include "memory.h"
5151
#include "gpio.h"
5252
#include "timer.h"
53-
5453
#include "wiring_types.h"
54+
#include "variant.h"
5555

5656
/* Set of all possible pin names; not all boards have all these (note
5757
* that we use the Dx convention since all of the Maple's pins are
@@ -134,8 +134,6 @@ bool boardUsesPin(uint8 pin);
134134
* (...RBT6) on it. Maple Rev6 (as of March 2011) DOES NOT EXIST.
135135
*/
136136

137-
#include "otto.h"
138-
139137
/*
140138
* TODO turn this into a warning so people can:
141139
*

variants/otto/otto.h

Lines changed: 0 additions & 246 deletions
This file was deleted.

0 commit comments

Comments
 (0)