Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // --------------------------------------------------------------------------------- //
- //
- // ESP8266 Flash Serial Print v1.00b by Tomasz Majcher
- //
- // --------------------------------------------------------------------------------- //
- // --- S E R I A L S E T U P ----------------------------------------------------- //
- // --------------------------------------------------------------------------------- //
- #define SERIAL true
- #define SerialSpeed 57600
- void _p(boolean nl, const char *format, va_list args )
- {
- char buf[128];
- vsnprintf(buf, sizeof(buf), format, args);
- #if SERIAL
- Serial.print(buf);
- #endif
- }
- void _p(boolean nl,const __FlashStringHelper *format, va_list args )
- {
- char buf[128];
- #ifdef __AVR__
- vsnprintf_P(buf, sizeof(buf), (const char *)format, args);
- #else
- vsnprintf(buf, sizeof(buf), (const char *)format, args);
- #endif
- #if SERIAL
- Serial.print(buf);
- #endif
- }
- void PRINT(const char *format, ... )
- {
- va_list args;
- va_start (args, format );
- _p(1,format,args);
- va_end(args);
- }
- void PRINT(const __FlashStringHelper *format, ... )
- {
- va_list args;
- va_start(args, format );
- _p(1,format,args);
- va_end(args);
- }
- void p(const char *format, ... )
- {
- va_list args;
- va_start(args, format );
- _p(0,format,args);
- va_end(args);
- }
- void p(const __FlashStringHelper *format, ... )
- {
- va_list args;
- va_start(args, format );
- _p(0,format,args);
- va_end(args);
- }
- // --------------------------------------------------------------------------------- //
- void setup()
- {
- #if SERIAL
- Serial.begin(SerialSpeed);
- #endif
- PRINT(F("\n\n\nESP8266 Serial Print v1.00b by Tomasz Majcher")); // drukowanie napisów
- PRINT(F("\n............................................."));
- PRINT(F("\nwszystkie napisy przy wykorzystaniu funkcji "));
- PRINT(F("\nPRINT() są ładowane do pamięci FLASH, dzięki "));
- PRINT(F("\ntemu nie zajmujemy pamięci RAM moduły ESP8266"));
- PRINT(F("\n.............................................\n\n"));
- int a = 10;
- float b = 20.54;
- char bufor[20] = "abcdef";
- String str1 = "to jest napis";
- PRINT(F("\nliczba INTEGER a = %d"), a);
- PRINT(F("\nliczba FLOAT b = %0.2f"), b);
- PRINT(F("\nłańcuch CHAR = %s"), bufor);
- PRINT(F("\nnapis STRING = %s"), str1.c_str());
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment