mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-17 01:13:30 +00:00
JIRA: [STUDIO-13609] Change-Id: I591de7033360b9570600006cfbce2148a8d031d5 (cherry picked from commit e9c774be8f4c89b8dafa14ef56913612fb68bd0c)
64 lines
1.8 KiB
C++
64 lines
1.8 KiB
C++
#include <nlohmann/json.hpp>
|
|
#include "DevLamp.h"
|
|
|
|
// TODO: remove this include
|
|
#include "slic3r/GUI/DeviceManager.hpp"
|
|
|
|
using namespace nlohmann;
|
|
|
|
namespace Slic3r
|
|
{
|
|
|
|
|
|
static std::string _light_effect_str(DevLamp::LIGHT_EFFECT effect)
|
|
{
|
|
switch (effect)
|
|
{
|
|
case Slic3r::DevLamp::LIGHT_EFFECT_ON:
|
|
return "on";
|
|
case Slic3r::DevLamp::LIGHT_EFFECT_OFF:
|
|
return "off";
|
|
case Slic3r::DevLamp::LIGHT_EFFECT_FLASHING:
|
|
return "flashing";
|
|
default:
|
|
return "unknown";
|
|
}
|
|
return "unknown";
|
|
}
|
|
|
|
void DevLamp::CtrlSetChamberLight(LIGHT_EFFECT effect)
|
|
{
|
|
// copied from others, TODO CHECK
|
|
command_set_chamber_light(effect);
|
|
command_set_chamber_light2(effect);
|
|
}
|
|
|
|
int DevLamp::command_set_chamber_light(LIGHT_EFFECT effect, int on_time, int off_time, int loops, int interval)
|
|
{
|
|
json j;
|
|
j["system"]["command"] = "ledctrl";
|
|
j["system"]["led_node"] = "chamber_light";
|
|
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
|
j["system"]["led_mode"] = _light_effect_str(effect);
|
|
j["system"]["led_on_time"] = on_time;
|
|
j["system"]["led_off_time"] = off_time;
|
|
j["system"]["loop_times"] = loops;
|
|
j["system"]["interval_time"] = interval;
|
|
return m_owner->publish_json(j);
|
|
}
|
|
|
|
int DevLamp::command_set_chamber_light2(LIGHT_EFFECT effect, int on_time, int off_time, int loops, int interval)
|
|
{
|
|
json j;
|
|
j["system"]["command"] = "ledctrl";
|
|
j["system"]["led_node"] = "chamber_light2";
|
|
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
|
j["system"]["led_mode"] = _light_effect_str(effect);
|
|
j["system"]["led_on_time"] = on_time;
|
|
j["system"]["led_off_time"] = off_time;
|
|
j["system"]["loop_times"] = loops;
|
|
j["system"]["interval_time"] = interval;
|
|
return m_owner->publish_json(j);
|
|
}
|
|
|
|
} |