aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConfuSomu2021-03-04 21:10:22 -0500
committerConfuSomu2021-03-04 21:10:22 -0500
commit250b15a5196efa4658fc637fe0c3896cb9c57c9a (patch)
tree45474645d336844fe74431a5a813b692a6b241aa
parenteb01ae68e4ffc5850b1b1182844ae4e60611fe0e (diff)
downloadpico-watch-250b15a5196efa4658fc637fe0c3896cb9c57c9a.tar
pico-watch-250b15a5196efa4658fc637fe0c3896cb9c57c9a.tar.gz
pico-watch-250b15a5196efa4658fc637fe0c3896cb9c57c9a.zip
Fix footer and header background drawing
-rw-r--r--api.cpp16
-rw-r--r--api.hpp8
2 files changed, 15 insertions, 9 deletions
diff --git a/api.cpp b/api.cpp
index 9950bf3..a79b0f3 100644
--- a/api.cpp
+++ b/api.cpp
@@ -92,7 +92,7 @@ bool Api::gui_popup_text(std::string title, std::string body){
m_send_button_press_to_app = true;
}
-bool Api::gui_footer_text(std::string text, int offset_x, int offset_row, int invert) {
+bool Api::gui_footer_text(std::string text, int offset_x, int offset_row, bool invert, bool no_bg) {
// Max chars per line for FONT_8x8 is 16 chars
// Max chars per line for FONT_6x8 is 21 chars
// Truncate longer text
@@ -106,12 +106,14 @@ bool Api::gui_footer_text(std::string text, int offset_x, int offset_row, int in
else
font = FONT_8x8;
- oledRectangle(&m_oled, 0,56, 128,64, invert, 1);
- oledDumpBuffer(&m_oled, m_ucBuffer);
+ if (!no_bg) {
+ oledRectangle(&m_oled, 0,56-offset_row*8, 127,64-offset_row*8, invert, 1);
+ oledDumpBuffer(&m_oled, m_ucBuffer);
+ }
oledWriteString(&m_oled, 0,offset_x,7-offset_row, &text[0], font, invert, 1);
}
-bool Api::gui_header_text(std::string text, int offset_x, int offset_row, int invert) {
+bool Api::gui_header_text(std::string text, int offset_x, int offset_row, bool invert, bool no_bg) {
// Max chars per line for FONT_8x8 is 16 chars
// Max chars per line for FONT_6x8 is 21 chars
// Truncate longer text
@@ -125,8 +127,10 @@ bool Api::gui_header_text(std::string text, int offset_x, int offset_row, int in
else
font = FONT_8x8;
- oledRectangle(&m_oled, 0,0, 128,8, invert, 1);
- oledDumpBuffer(&m_oled, m_ucBuffer);
+ if (!no_bg) {
+ oledRectangle(&m_oled, 0,0+offset_row*8, 127,8+offset_row*8, invert, 1);
+ oledDumpBuffer(&m_oled, m_ucBuffer);
+ }
oledWriteString(&m_oled, 0,offset_x,0+offset_row, &text[0], font, invert, 1);
}
diff --git a/api.hpp b/api.hpp
index 1ad6c6b..37a8c0c 100644
--- a/api.hpp
+++ b/api.hpp
@@ -45,15 +45,17 @@ class Api {
// \param text Text to display. Text longer than 21 will be truncated.
// \param offset_x Set a horizental offset, to allow, for example, centering the text
// \param offset_row Allow rendering the text higher. For example, one line higher when `offset_row = 1`.
- // \param invert allow inverting text and background color.
- bool gui_footer_text(std::string text, int offset_x = 0, int offset_row = 0, int invert = 0);
+ // \param invert Invert text and background color.
+ // \param no_bg Do not draw background when true.
+ bool gui_footer_text(std::string text, int offset_x = 0, int offset_row = 0, bool invert = false, bool no_bg = false);
// Display text at the top of the screen.
// The font size is automatically choosen based on the text lenght.
// \param text Text to display. Text longer than 21 will be truncated.
// \param offset_x Set a horizental offset, to allow, for example, centering the text
// \param offset_row Render text lines lower. For example, one text line lower with `offset_row = 1`.
// \param invert Invert text and background color.
- bool gui_header_text(std::string text, int offset_x = 0, int offset_row = 0, int invert = 0);
+ // \param no_bg Do not draw background when true.
+ bool gui_header_text(std::string text, int offset_x = 0, int offset_row = 0, bool invert = false, bool no_bg = false);
// Set performance mode.
// FIXME: function currently does nothing!
// An app should choose the lowest performance that can make it function. Set in init(). Only when required, higher performance should be used.