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

Development #6

Merged
merged 3 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
438 changes: 190 additions & 248 deletions cores/arduino/Print.cpp
100755 → 100644

Large diffs are not rendered by default.

97 changes: 49 additions & 48 deletions cores/arduino/Print.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,60 +25,61 @@

#include <types.h>
#include "WString.h"
#include "Printable.h"

enum {
Byte = 0,
BIN = 2,
OCT = 8,
DEC = 10,
HEX = 16
};

class Print {
public:
virtual size_t write(uint8 ch) = 0;
virtual size_t write(const char *str);
virtual size_t write(const void *buf, uint32 len);
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2

size_t print(const String &);
size_t print(char);
size_t print(const char[]);
size_t print(uint8, int=DEC);
size_t print(int, int=DEC);
size_t print(unsigned int, int=DEC);
size_t print(long, int=DEC);
size_t print(unsigned long, int=DEC);
size_t print(long long, int=DEC);
size_t print(unsigned long long, int=DEC);
size_t print(double, int=2);
size_t println(void);
size_t println(const String &s);
size_t println(char);
size_t println(const char[]);
size_t println(uint8, int=DEC);
size_t println(int, int=DEC);
size_t println(unsigned int, int=DEC);
size_t println(long, int=DEC);
size_t println(unsigned long, int=DEC);
size_t println(long long, int=DEC);
size_t println(unsigned long long, int=DEC);
size_t println(double, int=2);
#ifdef SUPPORTS_PRINTF
// Roger Clark. Work in progress to add printf support
int printf(const char * format, ...);
#endif
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}

int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }

virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}

size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);

protected:
void setWriteError(int err = 1) { write_error = err; }

private:
int write_error;
size_t printNumber(unsigned long long, uint8);
size_t printFloat(double, uint8);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
};

#endif
2 changes: 1 addition & 1 deletion cores/arduino/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
if (duration > 0 ) toggle_count = 2 * frequency * duration / 1000;
else toggle_count = -1;
timer.setPrescaleFactor(CYCLES_PER_MICROSECOND); // microseconds
timer.setOverflow(1000000/frequency/4);
timer.setOverflow(1000000/frequency/16);
timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE);
timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update
timer.toneAttachInterrupt(TIMER_CH1, handler_tone);
Expand Down
4 changes: 1 addition & 3 deletions cores/arduino/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
#include "memory.h"
#include "gpio.h"
#include "timer.h"

#include "wiring_types.h"
#include "variant.h"

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

#include "otto.h"

/*
* TODO turn this into a warning so people can:
*
Expand Down
246 changes: 0 additions & 246 deletions variants/otto/otto.h

This file was deleted.

Loading