Browse Source

Nextion cleanup

Scott Lahteine 4 years ago
parent
commit
51a61c5431
1 changed files with 14 additions and 7 deletions
  1. 14
    7
      Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp

+ 14
- 7
Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp View File

@@ -46,13 +46,7 @@ char NextionTFT::selectedfile[MAX_PATH_LEN];
46 46
 char NextionTFT::nextion_command[MAX_CMND_LEN];
47 47
 uint8_t NextionTFT::command_len;
48 48
 
49
-bool last_homed = 0, last_homedX = 0, last_homedY = 0, last_homedZ = 0;
50
-float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999, last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999;
51
-float last_get_axis_position_mmX = 999, last_get_axis_position_mmY = 999, last_get_axis_position_mmZ = 999;
52
-float last_extruder_advance_K = 999;
53
-uint8_t last_active_extruder = 99, last_fan_speed = 99, last_print_speed = 99, last_flow_speed = 99, last_progress = 99;
54
-uint8_t last_printer_state = 99, last_IDEX_Mode = 99;
55
-uint32_t layer = 0, last_layer = 99;
49
+uint32_t layer = 0;
56 50
 
57 51
 NextionTFT nextion;
58 52
 
@@ -601,6 +595,9 @@ void NextionTFT::PanelAction(uint8_t req) {
601 595
 void NextionTFT::UpdateOnChange() {
602 596
   const millis_t ms = millis();
603 597
   static millis_t next_event_ms = 0;
598
+  static float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999,
599
+               last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999;
600
+
604 601
   // tmppage Temperature
605 602
   if (!WITHIN(last_degHotend0 - getActualTemp_celsius(E0), -0.2, 0.2) || !WITHIN(last_degTargetHotend0 - getTargetTemp_celsius(E0), -0.5, 0.5)) {
606 603
     SEND_TEMP("tmppage.t0", ui8tostr3rj(getActualTemp_celsius(E0)), " / ", ui8tostr3rj(getTargetTemp_celsius(E0)));
@@ -621,24 +618,28 @@ void NextionTFT::UpdateOnChange() {
621 618
   }
622 619
 
623 620
   // tmppage Tool
621
+  static uint8_t last_active_extruder = 99;
624 622
   if (last_active_extruder != getActiveTool()) {
625 623
     SEND_VALasTXT("tmppage.tool", getActiveTool());
626 624
     last_active_extruder = getActiveTool();
627 625
   }
628 626
 
629 627
   // tmppage Fan Speed
628
+  static uint8_t last_fan_speed = 99;
630 629
   if (last_fan_speed != getActualFan_percent(FAN0)) {
631 630
     SEND_VALasTXT("tmppage.fan", ui8tostr3rj(getActualFan_percent(FAN0)));
632 631
     last_fan_speed = getActualFan_percent(FAN0);
633 632
   }
634 633
 
635 634
   // tmppage Print Speed
635
+  static uint8_t last_print_speed = 99;
636 636
   if (last_print_speed != getFeedrate_percent()) {
637 637
     SEND_VALasTXT("tmppage.speed", ui8tostr3rj(getFeedrate_percent()));
638 638
     last_print_speed = getFeedrate_percent();
639 639
   }
640 640
 
641 641
   // tmppage Flow
642
+  static uint8_t last_flow_speed = 99;
642 643
   if (last_flow_speed != getFlowPercentage(getActiveTool())) {
643 644
     SEND_VALasTXT("tmppage.flow", getFlowPercentage(getActiveTool()));
644 645
     last_flow_speed = getFlowPercentage(getActiveTool());
@@ -661,6 +662,7 @@ void NextionTFT::UpdateOnChange() {
661 662
       SEND_VALasTXT("tmppage.elapsed", elapsed_str);
662 663
     }
663 664
 
665
+    static uint8_t last_progress = 99;
664 666
     if (last_progress != getProgress_percent()) {
665 667
       SEND_VALasTXT("tmppage.progress", ui8tostr3rj(getProgress_percent()));
666 668
       last_progress = getProgress_percent();
@@ -678,6 +680,8 @@ void NextionTFT::UpdateOnChange() {
678 680
   }
679 681
 
680 682
   // tmppage Axis
683
+  static float last_get_axis_position_mmX = 999, last_get_axis_position_mmY = 999, last_get_axis_position_mmZ = 999;
684
+
681 685
   if (!WITHIN(last_get_axis_position_mmX - getAxisPosition_mm(X), -0.1, 0.1)) {
682 686
     if (ELAPSED(ms, next_event_ms)) {
683 687
       next_event_ms = ms + 30;
@@ -700,6 +704,8 @@ void NextionTFT::UpdateOnChange() {
700 704
   }
701 705
 
702 706
   // tmppage homed
707
+  static bool last_homed = false, last_homedX = false, last_homedY = false, last_homedZ = false;
708
+
703 709
   if (last_homed != isPositionKnown()) {
704 710
     SEND_VAL("tmppage.homed", isPositionKnown());
705 711
     last_homed = isPositionKnown();
@@ -718,6 +724,7 @@ void NextionTFT::UpdateOnChange() {
718 724
   }
719 725
 
720 726
   // tmppage IDEX Mode
727
+  static uint8_t last_IDEX_Mode = 99;
721 728
   #if ENABLED(DUAL_X_CARRIAGE)
722 729
     if (last_IDEX_Mode != getIDEX_Mode()) {
723 730
       SEND_VAL("tmppage.idexmode", getIDEX_Mode());

Loading…
Cancel
Save