From 8af5afd00d1cba9211e4fe9be1df44a14b7973a1 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 16 May 2020 16:57:06 +0200 Subject: [PATCH] Add writeBytes function to allow writing multiple bytes --- i2c.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/i2c.hpp b/i2c.hpp index 0b48f40..7e9dc4f 100644 --- a/i2c.hpp +++ b/i2c.hpp @@ -25,6 +25,17 @@ struct I2c { return Driver::write(data); } + template + static bool writeBytes(const uint8_t *buffer) + { + for (size_t i = 0; i < Bytes; ++i) { + if (!write(buffer[i])) + return false; + } + + return true; + } + template static uint8_t read() {