SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
StreamArduinoAdapter.hpp
Go to the documentation of this file.
1
30#pragma once
31
32#ifdef ARDUINO
33#include <Arduino.h>
34#include <stdarg.h>
35
36class ArduinoStreamPrinter
37{
38private:
39 Stream &stream;
40
41public:
42 ArduinoStreamPrinter(Stream& s) : stream(s) {}
43
44 int operator()(const char* format, ...) const
45 {
46 char buffer[256];
47 va_list args;
48 va_start(args, format);
49 int len = vsnprintf(buffer, sizeof(buffer), format, args);
50 va_end(args);
51
52 if (len > 0) {
53 stream.print(buffer);
54 }
55 return len;
56 }
57};
58
59#endif