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

Loading…
Cancel
Save