From 356b3ebbe95473b06ffa86e42ff01346c2b43718 Mon Sep 17 00:00:00 2001 From: RedHawk Date: Wed, 10 May 2023 13:12:13 +0300 Subject: [PATCH] LiquidCrystal.cpp: [#35] LCD now wraps text. --- source/shoh/src/peripherals/LiquidCrystal.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/shoh/src/peripherals/LiquidCrystal.cpp b/source/shoh/src/peripherals/LiquidCrystal.cpp index 3a7988b..ac49f8d 100644 --- a/source/shoh/src/peripherals/LiquidCrystal.cpp +++ b/source/shoh/src/peripherals/LiquidCrystal.cpp @@ -195,15 +195,17 @@ void LiquidCrystal::home() void LiquidCrystal::print(std::string const &s) { - print(s.c_str()); + print(s.c_str()); } void LiquidCrystal::print(const char *s) { - while(*s) { - write(*s); - ++s; - } + for (uint8_t i = 0; *s != '\0' && i <= 1; i++) { + for (size_t q = 0; *s != '\0' && q < 16; q++, s++) { + this->setCursor(q, i); + this->write(*s); + } + } } void LiquidCrystal::setCursor(uint8_t col, uint8_t row)