mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-01-01 12:20:47 -07:00
FIX: incorrect display of AMS humidity
JIRA: [STUDIO-13742] Change-Id: I25c26282c48faa05ab07dbb0cdbf5147bf475ccd (cherry picked from commit 971afb8365c955c2562bb5c2d7a8effdc2b625ce)
This commit is contained in:
parent
b9601f666a
commit
bdf413fb58
6 changed files with 52 additions and 39 deletions
|
|
@ -432,10 +432,9 @@ void DevFilaSystemParser::ParseV1_0(const json& jj, MachineObject* obj, DevFilaS
|
|||
|
||||
if (it->contains("humidity"))
|
||||
{
|
||||
std::string humidity = (*it)["humidity"].get<std::string>();
|
||||
|
||||
try
|
||||
{
|
||||
std::string humidity = (*it)["humidity"].get<std::string>();
|
||||
curr_ams->m_humidity_level = atoi(humidity.c_str());
|
||||
}
|
||||
catch (...)
|
||||
|
|
@ -446,40 +445,15 @@ void DevFilaSystemParser::ParseV1_0(const json& jj, MachineObject* obj, DevFilaS
|
|||
|
||||
if (it->contains("humidity_raw"))
|
||||
{
|
||||
std::string humidity_raw = (*it)["humidity_raw"].get<std::string>();
|
||||
|
||||
try
|
||||
{
|
||||
std::string humidity_raw = (*it)["humidity_raw"].get<std::string>();
|
||||
curr_ams->m_humidity_percent = atoi(humidity_raw.c_str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (curr_ams->GetHumidityPercent() != -1)
|
||||
{
|
||||
if (curr_ams->GetHumidityPercent() < 20)
|
||||
{
|
||||
curr_ams->m_humidity_level = 5;
|
||||
}
|
||||
else if (curr_ams->GetHumidityPercent() < 40)
|
||||
{
|
||||
curr_ams->m_humidity_level = 4;
|
||||
}
|
||||
else if (curr_ams->GetHumidityPercent() < 60)
|
||||
{
|
||||
curr_ams->m_humidity_level = 3;
|
||||
}
|
||||
else if (curr_ams->GetHumidityPercent() < 80)
|
||||
{
|
||||
curr_ams->m_humidity_level = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr_ams->m_humidity_level = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -131,8 +131,8 @@ private:
|
|||
|
||||
// temperature and humidity
|
||||
float m_current_temperature = INVALID_AMS_TEMPERATURE; // the temperature
|
||||
int m_humidity_level = 5;
|
||||
int m_humidity_percent = -1; // the percentage, -1 means invalid. eg. 100 means 100%
|
||||
int m_humidity_level = 5; // AmsType::AMS
|
||||
int m_humidity_percent = -1; // N3F N3S, the percentage, -1 means invalid. eg. 100 means 100%
|
||||
int m_left_dry_time = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct uiAmsHumidityInfo
|
|||
{
|
||||
std::string ams_id;
|
||||
AMSModel ams_type;
|
||||
int humidity_level = -1;
|
||||
int humidity_display_idx = -1;
|
||||
int humidity_percent = -1;
|
||||
float current_temperature;
|
||||
int left_dry_time = -1;
|
||||
|
|
@ -38,7 +38,7 @@ public:
|
|||
~uiAmsPercentHumidityDryPopup() = default;
|
||||
|
||||
public:
|
||||
void Update(uiAmsHumidityInfo *info) { m_ams_id = info->ams_id; Update(info->humidity_level, info->humidity_percent, info->left_dry_time, info->current_temperature); };
|
||||
void Update(uiAmsHumidityInfo *info) { m_ams_id = info->ams_id; Update(info->humidity_display_idx, info->humidity_percent, info->left_dry_time, info->current_temperature); };
|
||||
|
||||
std::string get_owner_ams_id() const { return m_ams_id; }
|
||||
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
wxPoint popup_pos(img_pos.x - m_Humidity_tip_popup.GetSize().GetWidth() + FromDIP(150), img_pos.y - FromDIP(80));
|
||||
m_Humidity_tip_popup.Position(popup_pos, wxSize(0, 0));
|
||||
|
||||
int humidity_value = info->humidity_level;
|
||||
int humidity_value = info->humidity_display_idx;
|
||||
if (humidity_value > 0 && humidity_value <= 5) { m_Humidity_tip_popup.set_humidity_level(humidity_value); }
|
||||
m_Humidity_tip_popup.Popup();
|
||||
}
|
||||
|
|
@ -1001,7 +1001,7 @@ void AMSControl::UpdateAms(const std::string &series_name,
|
|||
{
|
||||
uiAmsHumidityInfo humidity_info;
|
||||
humidity_info.ams_id = the_info.ams_id;
|
||||
humidity_info.humidity_level = the_info.ams_humidity;
|
||||
humidity_info.humidity_display_idx = the_info.get_humidity_display_idx();
|
||||
humidity_info.humidity_percent = the_info.humidity_raw;
|
||||
humidity_info.left_dry_time = the_info.left_dray_time;
|
||||
humidity_info.current_temperature = the_info.current_temperature;
|
||||
|
|
|
|||
|
|
@ -197,6 +197,43 @@ Caninfo AMSinfo::get_caninfo(const std::string& can_id, bool& found) const
|
|||
return Caninfo();
|
||||
};
|
||||
|
||||
int AMSinfo::get_humidity_display_idx() const
|
||||
{
|
||||
if (ams_type == AMSModel::GENERIC_AMS)
|
||||
{
|
||||
if (ams_humidity > 0 && ams_humidity < 6)
|
||||
{
|
||||
return ams_humidity;
|
||||
}
|
||||
}
|
||||
else if (ams_type == AMSModel::N3F_AMS || ams_type == AMSModel::N3S_AMS)
|
||||
{
|
||||
if (humidity_raw < 20)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
else if (humidity_raw < 40)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
else if (humidity_raw < 60)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
else if (humidity_raw < 80)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
assert(false && "Invalid AMS type for humidity display");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Description:AMSExtText
|
||||
**************************************************/
|
||||
|
|
@ -2822,7 +2859,7 @@ AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wx
|
|||
uiAmsHumidityInfo *info = new uiAmsHumidityInfo;
|
||||
info->ams_id = m_amsinfo.ams_id;
|
||||
info->ams_type = m_amsinfo.ams_type;
|
||||
info->humidity_level = m_amsinfo.ams_humidity;
|
||||
info->humidity_display_idx = m_amsinfo.get_humidity_display_idx();
|
||||
info->humidity_percent = m_amsinfo.humidity_raw;
|
||||
info->left_dry_time = m_amsinfo.left_dray_time;
|
||||
info->current_temperature = m_amsinfo.current_temperature;
|
||||
|
|
@ -2916,9 +2953,9 @@ void AMSHumidity::doRender(wxDC& dc)
|
|||
{
|
||||
ScalableBitmap hum_img;
|
||||
if (!wxGetApp().dark_mode()) {
|
||||
hum_img = ams_humidity_imgs[m_amsinfo.ams_humidity - 1];
|
||||
hum_img = ams_humidity_imgs[m_amsinfo.get_humidity_display_idx() - 1];
|
||||
} else {
|
||||
hum_img = ams_humidity_dark_imgs[m_amsinfo.ams_humidity - 1];
|
||||
hum_img = ams_humidity_dark_imgs[m_amsinfo.get_humidity_display_idx() - 1];
|
||||
}
|
||||
|
||||
pot = wxPoint((size.x - hum_img.GetBmpWidth()) / 2, ((size.y - hum_img.GetBmpSize().y) / 2));
|
||||
|
|
@ -2930,9 +2967,9 @@ void AMSHumidity::doRender(wxDC& dc)
|
|||
// hum image
|
||||
ScalableBitmap hum_img;
|
||||
if (!wxGetApp().dark_mode()) {
|
||||
hum_img = ams_humidity_no_num_imgs[m_amsinfo.ams_humidity - 1];
|
||||
hum_img = ams_humidity_no_num_imgs[m_amsinfo.get_humidity_display_idx() - 1];
|
||||
} else {
|
||||
hum_img = ams_humidity_no_num_dark_imgs[m_amsinfo.ams_humidity - 1];
|
||||
hum_img = ams_humidity_no_num_dark_imgs[m_amsinfo.get_humidity_display_idx() - 1];
|
||||
}
|
||||
|
||||
pot = wxPoint(FromDIP(5), ((size.y - hum_img.GetBmpSize().y) / 2));
|
||||
|
|
|
|||
|
|
@ -262,6 +262,8 @@ public:
|
|||
|
||||
bool support_drying() const { return (ams_type == AMSModel::N3S_AMS) || (ams_type == AMSModel::N3F_AMS); };
|
||||
Caninfo get_caninfo(const std::string& can_id, bool& found) const;
|
||||
|
||||
int get_humidity_display_idx() const;
|
||||
};
|
||||
|
||||
/*************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue