1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Merge remote-tracking branch 'remotes/esp8266/esp8266' into esp8266

This commit is contained in:
Markus Sattler 2015-07-15 13:58:30 +02:00
commit 0f25c46b94
4 changed files with 39 additions and 18 deletions

View File

@ -213,8 +213,8 @@ Libraries that don't rely on low-level access to AVR registers should work well.
- [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)). - [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)).
- [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library.git) - [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library.git)
- [DHT11](https://github.com/adafruit/DHT-sensor-library) - Download latest v1.1.0 library and no changes are necessary. Older versions should initialize DHT as follows: ```DHT dht(DHTPIN, DHTTYPE, 15);``` - [DHT11](https://github.com/adafruit/DHT-sensor-library) - Download latest v1.1.0 library and no changes are necessary. Older versions should initialize DHT as follows: ```DHT dht(DHTPIN, DHTTYPE, 15);```
- [NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) - Adafruit's NeoPixel libray, now with support for the ESP8266 (use version 1.0.2 or higher from Arduino's library manager). - [NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) - Adafruit's NeoPixel library, now with support for the ESP8266 (use version 1.0.2 or higher from Arduino's library manager).
- [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with esp8266. - [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with esp8266. Use the "NeoPixelAnimator" branch for esp8266 to get HSL color support and more.
- [PubSubClient](https://github.com/Imroy/pubsubclient) MQTT library by @Imroy. - [PubSubClient](https://github.com/Imroy/pubsubclient) MQTT library by @Imroy.
- [RTC](https://github.com/Makuna/Rtc) - Arduino Library for Ds1307 & Ds3231 compatible with esp8266. - [RTC](https://github.com/Makuna/Rtc) - Arduino Library for Ds1307 & Ds3231 compatible with esp8266.
- [Souliss, Smart Home](https://github.com/souliss/souliss) - Framework for Smart Home based on Arduino, Android and openHAB. - [Souliss, Smart Home](https://github.com/souliss/souliss) - Framework for Smart Home based on Arduino, Android and openHAB.

View File

@ -162,14 +162,22 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
strcpy(s, "ovf"); strcpy(s, "ovf");
return s; return s;
} }
char* out = s; char* out = s;
int signInt_Part = 1;
// Handle negative numbers // Handle negative numbers
if (number < 0.0) { if (number < 0.0) {
*out = '-'; signInt_Part = -1;
++out;
number = -number; number = -number;
} }
// calc left over digits
if (prec > 0)
{
width -= (prec + 1);
}
// Round correctly so that print(1.999, 2) prints as "2.00" // Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5; double rounding = 0.5;
for (uint8_t i = 0; i < prec; ++i) for (uint8_t i = 0; i < prec; ++i)
@ -180,18 +188,19 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
// Extract the integer part of the number and print it // Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number; unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part; double remainder = number - (double)int_part;
out += sprintf(out, "%ld", int_part); out += sprintf(out, "%*ld", width, int_part * signInt_Part);
// Print the decimal point, but only if there are digits beyond // Print the decimal point, but only if there are digits beyond
if (prec > 0) { if (prec > 0) {
*out = '.'; *out = '.';
++out; ++out;
}
for (unsigned char decShift = prec; decShift > 0; decShift--) { for (unsigned char decShift = prec; decShift > 0; decShift--) {
remainder *= 10.0; remainder *= 10.0;
} }
sprintf(out, "%0*d", prec, (int)remainder); sprintf(out, "%0*d", prec, (int)remainder);
}
return s; return s;
} }

View File

@ -135,6 +135,17 @@ int printf_P(const char* formatP, ...) {
return ret; return ret;
} }
int sprintf_P(char* str, const char* formatP, ...) {
int ret;
va_list arglist;
va_start(arglist, formatP);
ret = vsnprintf_P(str, SIZE_IRRELEVANT, formatP, arglist);
va_end(arglist);
return ret;
}
int snprintf_P(char* str, size_t strSize, const char* formatP, ...) { int snprintf_P(char* str, size_t strSize, const char* formatP, ...) {
int ret; int ret;
va_list arglist; va_list arglist;

View File

@ -50,6 +50,7 @@ size_t strnlen_P(const char *s, size_t size);
#define strlen_P(strP) strnlen_P((strP), SIZE_IRRELEVANT) #define strlen_P(strP) strnlen_P((strP), SIZE_IRRELEVANT)
int printf_P(const char *formatP, ...) __attribute__ ((format (printf, 1, 2))); int printf_P(const char *formatP, ...) __attribute__ ((format (printf, 1, 2)));
int sprintf_P(char *str, const char *formatP, ...) __attribute__((format(printf, 2, 3)));
int snprintf_P(char *str, size_t strSize, const char *formatP, ...) __attribute__((format(printf, 3, 4))); int snprintf_P(char *str, size_t strSize, const char *formatP, ...) __attribute__((format(printf, 3, 4)));
int vsnprintf_P(char *str, size_t strSize, const char *formatP, va_list ap) __attribute__ ((format (printf, 3, 0))); int vsnprintf_P(char *str, size_t strSize, const char *formatP, va_list ap) __attribute__ ((format (printf, 3, 0)));