Просмотр исходного кода

Merge pull request #629 from fdlamotte/techo_ui_tweaks

techo_ui: some tweaks
ripplebiz 11 месяцев назад
Родитель
Сommit
ed3f52775a

+ 7 - 3
examples/companion_radio/ui-new/UITask.cpp

@@ -14,6 +14,10 @@
 
 #define LONG_PRESS_MILLIS   1200
 
+#ifndef UI_RECENT_LIST_SIZE
+  #define UI_RECENT_LIST_SIZE 4
+#endif
+
 #define PRESS_LABEL "long press"
 
 #include "icons.h"
@@ -79,7 +83,7 @@ class HomeScreen : public UIScreen {
   NodePrefs* _node_prefs;
   uint8_t _page;
   bool _shutdown_init;
-  AdvertPath recent[4];
+  AdvertPath recent[UI_RECENT_LIST_SIZE];
 
   void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) {
     // Convert millivolts to percentage
@@ -156,10 +160,10 @@ public:
         display.drawTextCentered(display.width() / 2, 43, tmp);
       }
     } else if (_page == HomePage::RECENT) {
-      the_mesh.getRecentlyHeard(recent, 4);
+      the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE);
       display.setColor(DisplayDriver::GREEN);
       int y = 20;
-      for (int i = 0; i < 4; i++, y += 11) {
+      for (int i = 0; i < UI_RECENT_LIST_SIZE; i++, y += 11) {
         auto a = &recent[i];
         if (a->name[0] == 0) continue;  // empty slot
         display.setCursor(0, y);

+ 2 - 2
src/helpers/ui/GxEPDDisplay.cpp

@@ -29,8 +29,8 @@ void GxEPDDisplay::turnOn() {
   if (!_init) begin();
 #if DISP_BACKLIGHT
   digitalWrite(DISP_BACKLIGHT, HIGH);
-  _isOn = true;
 #endif
+  _isOn = true;
 }
 
 void GxEPDDisplay::turnOff() {
@@ -132,7 +132,7 @@ uint16_t GxEPDDisplay::getTextWidth(const char* str) {
   int16_t x1, y1;
   uint16_t w, h;
   display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
-  return w / SCALE_X;
+  return ceil((w + 1) / SCALE_X);
 }
 
 void GxEPDDisplay::endFrame() {

+ 1 - 0
variants/techo/platformio.ini

@@ -68,6 +68,7 @@ build_flags =
   -D BLE_DEBUG_LOGGING=1
   -D DISPLAY_CLASS=GxEPDDisplay
   -D OFFLINE_QUEUE_SIZE=256
+  -D UI_RECENT_LIST_SIZE=9
 ;  -D MESH_PACKET_LOGGING=1
 ;  -D MESH_DEBUG=1
 build_src_filter = ${LilyGo_Techo.build_src_filter}