1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-10-13 23:48:28 +03:00

Merged upstream arduino branch

This commit is contained in:
Cristian Maglie
2012-10-18 15:50:09 +02:00
364 changed files with 153088 additions and 102 deletions

View File

@@ -221,6 +221,8 @@ size_t Print::printFloat(double number, uint8_t digits)
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)

View File

@@ -29,6 +29,7 @@ Version Modified By Date Comments
09/11/25 Fixed timer0 from being excluded
0006 D Mellis 09/12/29 Replaced objects with functions
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
*************************************************/
#include <avr/interrupt.h>
@@ -85,10 +86,10 @@ volatile uint8_t timer5_pin_mask;
#endif
// MLS: This does not make sense, the 3 options are the same
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
@@ -96,13 +97,23 @@ static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 25
#elif defined(__AVR_ATmega8__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
#elif defined(__AVR_ATmega32U4__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER3
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 3 /*, 1 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
#else
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
// Leave timer 0 to last.
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
@@ -480,8 +491,7 @@ void noTone(uint8_t _pin)
digitalWrite(_pin, 0);
}
#if 0
#if !defined(__AVR_ATmega8__)
#ifdef USE_TIMER0
ISR(TIMER0_COMPA_vect)
{
if (timer0_toggle_count != 0)
@@ -501,6 +511,7 @@ ISR(TIMER0_COMPA_vect)
#endif
#ifdef USE_TIMER1
ISR(TIMER1_COMPA_vect)
{
if (timer1_toggle_count != 0)
@@ -520,6 +531,7 @@ ISR(TIMER1_COMPA_vect)
#endif
#ifdef USE_TIMER2
ISR(TIMER2_COMPA_vect)
{
@@ -541,12 +553,10 @@ ISR(TIMER2_COMPA_vect)
// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop
}
}
#endif
//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#if 0
#ifdef USE_TIMER3
ISR(TIMER3_COMPA_vect)
{
if (timer3_toggle_count != 0)
@@ -563,7 +573,10 @@ ISR(TIMER3_COMPA_vect)
*timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop
}
}
#endif
#ifdef USE_TIMER4
ISR(TIMER4_COMPA_vect)
{
if (timer4_toggle_count != 0)
@@ -580,7 +593,10 @@ ISR(TIMER4_COMPA_vect)
*timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop
}
}
#endif
#ifdef USE_TIMER5
ISR(TIMER5_COMPA_vect)
{
if (timer5_toggle_count != 0)
@@ -597,5 +613,4 @@ ISR(TIMER5_COMPA_vect)
*timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop
}
}
#endif

View File

@@ -227,7 +227,7 @@ size_t Serial_::write(const uint8_t *buffer, size_t size)
int r = USBD_Send(CDC_TX, buffer, size);
if (r > 0)
{
{
return r;
} else
{

View File

@@ -34,7 +34,7 @@
// -std=c++0x
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal)))
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
// An inherited class for holding the result of a concatenation. These
// result objects are assumed to be writable by subsequent concatenations.

View File

@@ -1,12 +1,12 @@
/*
Cosm sensor client with Strings
Pachube sensor client with Strings
This sketch connects an analog sensor to Cosm (http://www.cosm.com)
This sketch connects an analog sensor to Pachube (http://www.pachube.com)
using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
the Adafruit Ethernet shield, either one will work, as long as it's got
a Wiznet Ethernet module on board.
This example has been updated to use version 2.0 of the Cosm.com API.
This example has been updated to use version 2.0 of the pachube.com API.
To make it work, create a feed with two datastreams, and give them the IDs
sensor1 and sensor2. Or change the code below to match your feed.
@@ -20,8 +20,10 @@
created 15 March 2010
modified 9 Apr 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra
modified 8 September 2012
by Scott Fitzgerald
http://arduino.cc/en/Tutorial/CosmClientString
http://arduino.cc/en/Tutorial/PachubeClientString
This code is in the public domain.
*/
@@ -30,7 +32,7 @@
#include <Ethernet.h>
/#define APIKEY "YOUR API KEY GOES HERE" // replace your Cosm api key here
#define APIKEY "YOUR API KEY GOES HERE" // replace your Pachube api key here
#define FEEDID 00000 // replace your feed ID
#define USERAGENT "My Project" // user agent is the project name
@@ -49,12 +51,12 @@ EthernetClient client;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(216,52,233,121); // numeric IP for api.cosm.com
//char server[] = "api.cosm.com"; // name address for Cosm API
IPAddress server(216,52,233,121); // numeric IP for api.pachube.com
//char server[] = "api.pachube.com"; // name address for pachube API
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; //delay between updates to Cosm.com
const unsigned long postingInterval = 10*1000; //delay between updates to pachube.com
void setup() {
// Open serial communications and wait for port to open:
@@ -83,7 +85,7 @@ void loop() {
dataString += sensorReading;
// you can append multiple readings to this String if your
// Cosm feed is set up to handle multiple values:
// pachube feed is set up to handle multiple values:
int otherSensorReading = analogRead(A1);
dataString += "\nsensor2,";
dataString += otherSensorReading;
@@ -123,8 +125,8 @@ void sendData(String thisData) {
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.cosm.com");
client.print("X-CosmApiKey: ");
client.println("Host: api.pachube.com");
client.print("X-pachubeApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);