M5Unit-RS485 0.0.1 git rev:d5ba212
Loading...
Searching...
No Matches
unit_SP485_stream.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_RS485_UNIT_SP485_STREAM_HPP
11#define M5_UNIT_RS485_UNIT_SP485_STREAM_HPP
12
13#if defined(ARDUINO)
14#include "unit_SP485.hpp"
15#include <Stream.h>
16
17namespace m5 {
18namespace unit {
19
27class UnitSP485Stream final : public Stream {
28public:
33 explicit UnitSP485Stream(UnitSP485& unit) : _unit(unit)
34 {
35 }
36
41 int available() override
42 {
43 return _unit.available();
44 }
49 int read() override
50 {
51 return _unit.read();
52 }
57 int peek() override
58 {
59 return _unit.peek();
60 }
66 size_t write(uint8_t b) override
67 {
68 return _unit.write(b);
69 }
76 size_t write(const uint8_t* buffer, size_t size) override
77 {
78 return _unit.write(buffer, size);
79 }
83 void flush() override
84 {
85 _unit.flush();
86 }
87
92 int availableForWrite()
93 {
94 return _unit.availableForWrite();
95 }
96
97 using Print::write;
98
99private:
100 UnitSP485& _unit;
101};
102
103} // namespace unit
104} // namespace m5
105#endif
106#endif
Top level namespace of M5stack.
Unit-related namespace.
SP485 unit for M5UnitUnified.