From 075ecdf1e26d43f1608baf6567e0cc676818a874 Mon Sep 17 00:00:00 2001 From: Zvonimir Rudinski Date: Tue, 28 Apr 2026 19:54:41 +0200 Subject: [PATCH] feat(display): add render method for menu items --- include/display.hpp | 2 ++ src/display.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/display.hpp b/include/display.hpp index 2dd4398..336c9f5 100644 --- a/include/display.hpp +++ b/include/display.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include "menu.hpp" /* * A helper class to facilitate drawing on a HD44780 LCD display. @@ -11,6 +12,7 @@ class Display { void begin(); void clear(); + void drawMenu(Menu& menu); LiquidCrystal_I2C& getLCD(); private: diff --git a/src/display.cpp b/src/display.cpp index 014a97c..d42b550 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -12,6 +12,21 @@ void Display::clear() { lcd.clear(); } +void Display::drawMenu(Menu &menu) { + clear(); + size_t currentItemIndex = menu.getCurrentItemIndex(); + for (size_t i = 0; i < MENU_ITEM_COUNT; i++) { + lcd.setCursor(0, i); + Item& item = menu.getItemAt(i); + + if (i == currentItemIndex) { + lcd.print("> " + item.name); + } else { + lcd.print(" " + item.name); + } + } +} + LiquidCrystal_I2C& Display::getLCD() { return lcd; }