Browse Source

add pc displays to ui

Thomas Buck 4 months ago
parent
commit
f587c66e75
3 changed files with 22 additions and 2 deletions
  1. 1
    0
      include/ui.h
  2. 8
    0
      src/mqtt.cpp
  3. 13
    2
      src/ui.cpp

+ 1
- 0
include/ui.h View File

32
     bool light_box;
32
     bool light_box;
33
     enum bathroom_light_states bathroom_lights;
33
     enum bathroom_light_states bathroom_lights;
34
     bool light_sink;
34
     bool light_sink;
35
+    bool pc_displays;
35
 };
36
 };
36
 
37
 
37
 extern struct ui_status ui_status;
38
 extern struct ui_status ui_status;

+ 8
- 0
src/mqtt.cpp View File

178
         ui_status.light_sink = state ? true : false;
178
         ui_status.light_sink = state ? true : false;
179
         prev_status.light_sink = ui_status.light_sink;
179
         prev_status.light_sink = ui_status.light_sink;
180
         ui_progress(UI_UPDATE);
180
         ui_progress(UI_UPDATE);
181
+    } else if (ts == "livingroom/displays/cmnd/POWER") {
182
+        ui_status.pc_displays = state ? true : false;
183
+        prev_status.pc_displays = ui_status.pc_displays;
184
+        ui_progress(UI_UPDATE);
181
     }
185
     }
182
 #endif // FEATURE_UI
186
 #endif // FEATURE_UI
183
 
187
 
252
         mqtt.subscribe("livingroom/amp/cmnd/POWER");
256
         mqtt.subscribe("livingroom/amp/cmnd/POWER");
253
         mqtt.subscribe("bathroom/force_light");
257
         mqtt.subscribe("bathroom/force_light");
254
         mqtt.subscribe("livingroom/light_sink/cmnd/POWER");
258
         mqtt.subscribe("livingroom/light_sink/cmnd/POWER");
259
+        mqtt.subscribe("livingroom/displays/cmnd/POWER");
255
 #endif // FEATURE_UI
260
 #endif // FEATURE_UI
256
     }
261
     }
257
 }
262
 }
329
     if (curr_status.light_sink != prev_status.light_sink) {
334
     if (curr_status.light_sink != prev_status.light_sink) {
330
         mqttPublish("livingroom/light_sink/cmnd/POWER", curr_status.light_sink ? "on" : "off", true);
335
         mqttPublish("livingroom/light_sink/cmnd/POWER", curr_status.light_sink ? "on" : "off", true);
331
     }
336
     }
337
+    if (curr_status.pc_displays != prev_status.pc_displays) {
338
+        mqttPublish("livingroom/displays/cmnd/POWER", curr_status.pc_displays ? "on" : "off", true);
339
+    }
332
 
340
 
333
     prev_status = curr_status;
341
     prev_status = curr_status;
334
 }
342
 }

+ 13
- 2
src/ui.cpp View File

154
     // 5
154
     // 5
155
     bool on = ui_status.light_corner || ui_status.light_sink || ui_status.light_workspace
155
     bool on = ui_status.light_corner || ui_status.light_sink || ui_status.light_workspace
156
             || ui_status.light_amp || ui_status.light_bench || ui_status.light_box
156
             || ui_status.light_amp || ui_status.light_bench || ui_status.light_box
157
-            || ui_status.light_kitchen || ui_status.light_pc;
157
+            || ui_status.light_kitchen || ui_status.light_pc || ui_status.pc_displays;
158
     draw_button(on ? "All Lights Off" : "Wake Up Lights",
158
     draw_button(on ? "All Lights Off" : "Wake Up Lights",
159
                 BTNS_OFF_X + BTN_W / 2 + BTN_W + BTN_GAP,
159
                 BTNS_OFF_X + BTN_W / 2 + BTN_W + BTN_GAP,
160
                 BTNS_OFF_Y + BTN_H / 2 + BTN_H + BTN_GAP,
160
                 BTNS_OFF_Y + BTN_H / 2 + BTN_H + BTN_GAP,
206
                 BTNS_OFF_Y + BTN_H / 2 + BTN_H + BTN_GAP,
206
                 BTNS_OFF_Y + BTN_H / 2 + BTN_H + BTN_GAP,
207
                 ui_status.bathroom_lights == BATH_LIGHT_BIG ? TFT_GREEN : TFT_RED);
207
                 ui_status.bathroom_lights == BATH_LIGHT_BIG ? TFT_GREEN : TFT_RED);
208
 
208
 
209
+    // 3
210
+    // TODO own page?
211
+    draw_button("PC Displays",
212
+                BTNS_OFF_X + BTN_W / 2,
213
+                BTNS_OFF_Y + BTN_H / 2 + (BTN_H + BTN_GAP) * 2,
214
+                ui_status.pc_displays ? TFT_GREEN : TFT_RED);
215
+
209
     // 4
216
     // 4
210
     draw_button("Bath Lights Off",
217
     draw_button("Bath Lights Off",
211
                 BTNS_OFF_X + BTN_W / 2 + BTN_W + BTN_GAP,
218
                 BTNS_OFF_X + BTN_W / 2 + BTN_W + BTN_GAP,
585
                 INVERT_BOOL(ui_status.light_sink);
592
                 INVERT_BOOL(ui_status.light_sink);
586
             } else if (ui_page == UI_LIVINGROOM2) {
593
             } else if (ui_page == UI_LIVINGROOM2) {
587
                 INVERT_BOOL(ui_status.light_kitchen);
594
                 INVERT_BOOL(ui_status.light_kitchen);
595
+            } else if (ui_page == UI_BATHROOM) {
596
+                INVERT_BOOL(ui_status.pc_displays);
588
             }
597
             }
589
             writeMQTT_UI();
598
             writeMQTT_UI();
590
         } else if ((p.x >= BTNS_OFF_X + BTN_W + BTN_GAP) && (p.x <= BTNS_OFF_X + BTN_W + BTN_GAP + BTN_W) && (p.y >= BTNS_OFF_Y) && (p.y <= BTNS_OFF_Y + BTN_H)) {
599
         } else if ((p.x >= BTNS_OFF_X + BTN_W + BTN_GAP) && (p.x <= BTNS_OFF_X + BTN_W + BTN_GAP + BTN_W) && (p.y >= BTNS_OFF_Y) && (p.y <= BTNS_OFF_Y + BTN_H)) {
602
             if (ui_page == UI_LIVINGROOM1) {
611
             if (ui_page == UI_LIVINGROOM1) {
603
                 bool on = ui_status.light_corner || ui_status.light_sink || ui_status.light_workspace
612
                 bool on = ui_status.light_corner || ui_status.light_sink || ui_status.light_workspace
604
                         || ui_status.light_amp || ui_status.light_bench || ui_status.light_box
613
                         || ui_status.light_amp || ui_status.light_bench || ui_status.light_box
605
-                        || ui_status.light_kitchen || ui_status.light_pc;
614
+                        || ui_status.light_kitchen || ui_status.light_pc || ui_status.pc_displays;
606
                 if (on) {
615
                 if (on) {
607
                     ui_status.light_amp = false;
616
                     ui_status.light_amp = false;
608
                     ui_status.light_kitchen = false;
617
                     ui_status.light_kitchen = false;
612
                     ui_status.light_corner = false;
621
                     ui_status.light_corner = false;
613
                     ui_status.light_box = false;
622
                     ui_status.light_box = false;
614
                     ui_status.light_sink = false;
623
                     ui_status.light_sink = false;
624
+                    ui_status.pc_displays = false;
615
                 } else {
625
                 } else {
616
                     ui_status.light_corner = true;
626
                     ui_status.light_corner = true;
617
                     ui_status.light_sink = true;
627
                     ui_status.light_sink = true;
628
+                    ui_status.pc_displays = true;
618
                 }
629
                 }
619
             } else if (ui_page == UI_LIVINGROOM2) {
630
             } else if (ui_page == UI_LIVINGROOM2) {
620
                 INVERT_BOOL(ui_status.light_box);
631
                 INVERT_BOOL(ui_status.light_box);

Loading…
Cancel
Save