Qrome / printer-monitor

OctoPrint 3D Printer Monitor using Wemos D1 Mini ESP8266
MIT License
474 stars 164 forks source link

Added Layers & Estimated time finish #136

Open victor7376 opened 3 years ago

victor7376 commented 3 years ago

Added 3 new screens:

Also for the layer progress the code switches between different size fonts if the layer size is equal or greater than 1000.

added these features into OctoprintClient & RepetierClient.

samwiseg0 commented 3 years ago

@victor7376 Any chance you could honor the 12/24hour config value for End time? Maybe even a step further if the end time is not today display date and time?

victor7376 commented 3 years ago

@samwiseg0 the screens take the information from the DisplayLayerProgress plug-in, so what ever is displayed there is shown on the screens.

samwiseg0 commented 3 years ago

@victor7376 I understand. I think ETA would be better calculated by using current time and adding seconds left. That would allow the ETA time to be formatted properly. Currently with the value you selected it is just a string value for time and is only formatted in 24hrs. I am suggesting to use remaining seconds and calculate that value.

victor7376 commented 3 years ago

When I've got my printer back up and running I'll take a look.

samwiseg0 commented 3 years ago

When I've got my printer back up and running I'll take a look.

Thank you. I have been poking at it with little success. I am very new to arruino. I have been able to make some other minor modifications but I have not been able to get this modification to work successfully.

Thank your your time. Much appreciated

victor7376 commented 3 years ago

if you want if you post what you have coded, could take a look at it.

samwiseg0 commented 3 years ago

if you want if you post what you have coded, could take a look at it.

I am mostly stuck on trying to get current time in seconds.

My thought was. If I get current time in seconds then I can add remaining seconds to it. Then format it in either date time or just time if the date is today.

Much like the example given in the issue.

finish_time = current_time + datetime.timedelta(0,currentData["progress"]["printTimeLeft"])

I was looking at TimeClient() but I am unsure if that is the correct way to go.

victor7376 commented 3 years ago

I could see what you were trying to do, but I couldnt work it out myself. I have however found out that Display Layer Progress has a feature that shows you the day of the week when a print will finish. The guy who makes the plugin is planning a new update for the clock in a future release.

In Display Layer Progress plugin change the following option to what's shown and it will give you the day of the week.

%A = Full weekday name. %H = 24 hour %M = minutes %I (capital i ) = 12 hour clock

Hope this helps.

90291828-fec93200-de80-11ea-8dd0-7cdc4c78e289

samwiseg0 commented 3 years ago

That certainly is a much easier approach. I made the changes in the plugin config and it is much more useable now. I do wish it only showed the date when it was not today. But that is a bit more minor. Thank you for pointing that out.

As a side note, another issue I came across is when the printer is paused it shows as offline.

I modified OctoPrintClient.cpp to include paused in the printing state so it does not show as offline. It's a hacky workaround but it at least still shows the data vs saying its offline. A proper screen showing the printer paused would be ideal as that is the state it is in when lets say the filament sensor is tripped or is paused for a filament change. I will keep messing with it and see if I cant add that functionality unless someone else more familiar with C++ gets to it first 😆

  String printing = (const char*)root2["state"]["flags"]["printing"];
  String paused = (const char*)root2["state"]["flags"]["paused"];
  if (printing == "true" || paused == "true") {
    printerData.isPrinting = true;
  } else {
    printerData.isPrinting = false;
  }

Thanks again for your help.

victor7376 commented 3 years ago

No problem, I do know how to make new screens, I’ll take a look tomorrow regarding pausing screen.

samwiseg0 commented 3 years ago

I was able to change the main status bar by doing the following. It now shows paused instead of the percentage.

OctoPrintClient.cpp

boolean OctoPrintClient::isPaused() {
  boolean paused = false;
  if (printerData.state == "Paused") {
    paused = true;
  }
  return paused;
}

printermonitor.ino

void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
  display->setColor(WHITE);
  display->setFont(ArialMT_Plain_16);
  String displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes();
  if (IS_24HOUR) {
    displayTime = timeClient.getHours() + ":" + timeClient.getMinutes();
  }
  display->setTextAlignment(TEXT_ALIGN_LEFT);
  display->drawString(0, 48, displayTime);

  if (!IS_24HOUR) {
    String ampm = timeClient.getAmPm();
    display->setFont(ArialMT_Plain_10);
    display->drawString(39, 54, ampm);
  }

  if (printerClient.isPaused()) {
    display->setFont(ArialMT_Plain_10);
    display->setTextAlignment(TEXT_ALIGN_LEFT);
    String paused = "Paused";
    display->drawString(64, 51, paused);
  }
  else {
    display->setFont(ArialMT_Plain_16);
    display->setTextAlignment(TEXT_ALIGN_LEFT);
    String percent = String(printerClient.getProgressCompletion()) + "%";
    display->drawString(64, 48, percent);
  }
  // Draw indicator to show next update
  int updatePos = (printerClient.getProgressCompletion().toFloat() / float(100)) * 128;
  display->drawRect(0, 41, 128, 6);
  display->drawHorizontalLine(0, 42, updatePos);
  display->drawHorizontalLine(0, 43, updatePos);
  display->drawHorizontalLine(0, 44, updatePos);
  display->drawHorizontalLine(0, 45, updatePos);

  drawRssi(display);
}
victor7376 commented 3 years ago

nice work, it has also given me an idea for something else. When a print is paused for example to change the filament a new screen appears informing the user regarding the pause.

samwiseg0 commented 3 years ago

@victor7376 I rebased off your branch and made additional changes. Hopefully @Qrome can merge your changes in so I can PR against them. Either way feel free to implement them in your fork if you wish.

The most notable changes are:

Changes: https://github.com/victor7376/printer-monitor/compare/master...samwiseg0:add_features?expand=1

Precompiled Binaries: v3.0_printermonitor.ino.d1_mini_pause_brightness.zip