diff --git a/src/menu.cpp b/src/menu.cpp index 4fb6272..2a4253f 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -45,14 +45,12 @@ std::string Menu::FilterMenuText(int position) { } void Menu::CreateMenuItem(std::string text, int position, bool highlighted) { - char* cstr = &text[0]; text.insert(text.end(), MAX_CHAR_LENGTH-text.size(), ' '); - patch->display.SetCursor(MENU_X[position-1], MENU_Y[position-1]); if (highlighted) { DrawSolidRect(*patch, 0, MENU_Y[2], SSD1309_WIDTH, MENU_Y[2]+17, true); - patch->display.WriteString(cstr, Font_11x18, !highlighted); + WriteString(*patch, MENU_X[position-1], MENU_Y[position-1], Font_11x18, text, !highlighted); } else { - patch->display.WriteString(cstr, Font_7x10, !highlighted); + WriteString(*patch, MENU_X[position-1], MENU_Y[position-1], Font_7x10, text, !highlighted); } } diff --git a/src/menu.h b/src/menu.h index af51a07..8e3b94c 100644 --- a/src/menu.h +++ b/src/menu.h @@ -1,5 +1,8 @@ #pragma once +#ifndef CASCADE_MENU_H_ +#define CASCADE_MENU_H_ + #include "daisy_patch.h" #include "util.h" @@ -21,3 +24,5 @@ class Menu { void UpdateMenuPosition(); std::string SelectedName(); }; + +#endif // CASCADE_MENU_H_ diff --git a/src/util.cpp b/src/util.cpp index a47c8d2..db1cda2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -11,8 +11,20 @@ void DrawSolidRect(DaisyPatch patch, } } -void WriteString(DaisyPatch patch, int x, int y, FontDef font, std::string text) { +void WriteString(DaisyPatch patch, + int x, + int y, + FontDef font, + std::string text, + bool on) { patch.display.SetCursor(x, y); - char* cstr = &text[0]; - patch.display.WriteString(cstr, font, true); + patch.display.WriteString(&text[0], font, on); +} + +void WriteString(DaisyPatch patch, + int x, + int y, + FontDef font, + std::string text) { + WriteString(patch, x, y, font, text, true); } diff --git a/src/util.h b/src/util.h index fb1eb28..f5c720b 100644 --- a/src/util.h +++ b/src/util.h @@ -16,6 +16,13 @@ void DrawSolidRect(DaisyPatch, uint8_t, bool); +void WriteString(DaisyPatch, + int, + int, + FontDef, + std::string, + bool); + void WriteString(DaisyPatch, int, int,