chunkysteveo / OctoPrintAPI

Library for use with Arduino compatible micro controllers (web enabled) to access the Octoprint API on Raspberry Pi's running the Octoprint 3D printer web server by the brilliant Gina Häußge, aka @foosel.
GNU General Public License v2.0
42 stars 24 forks source link

New feature : octoPrintSetTemperatures() #30

Open fmatray opened 4 years ago

fmatray commented 4 years ago

Hello, What do you think about adding a feature et set all temperatures at once. This can be useful to quickly set all to 0°C and cool down tools and bed.

bool octoPrintSetTemperatures(uint16_t tool0, uint16_t tool1, uint16_t bed);

chunkysteveo commented 4 years ago

I love the idea! I would have that function as the main function, and pass simple ones to it, like octoPrintCoolDown() ?

What could also use that function is getting the temperature presets set in the settings:

"profiles": [ { "bed": 100, "chamber": null, "extruder": 230, "name": "ABS" }, { "bed": 65, "chamber": null, "extruder": 210, "name": "PLA" }, { "bed": 85, "chamber": 0, "extruder": 235, "name": "PETG" } ],

Something that would take the profile name, e.g. octoPrintSetTemperatureProfile(PETG), and that could get the profiles from settings... and apply the temperatures to your functions?

I see the profile temperatures have "chamber" in there too - is that new to the API and Octoprint?

There's some homework for you!! :)

fmatray commented 4 years ago

Love it !! We can do something like : bool octoPrintSetTemperatures(uint16_t tool0 = 0, uint16_t tool1 = 0, uint16_t bed = 0); bool octoPrintCoolDown() { return octoPrintSetTemperatures() }

For the profile definition :

define ABS 1

define PLA 2

define PETG 3

struct profile_s { unit_8_t profile_id, uint16_t tool0; uint16_t tool1; uint16_t bed; uint16_t chamber; } profiles[] = { { ABS, 230, 0, 100, 0}, { PLA, 210, 0, 65, 0}, { PETG, 235, 0, 85, 0}, {0, 0, 0, 0} }

I never noticed you can manage a chamber with Octoprint :-) We only print PLA.

chunkysteveo commented 4 years ago

You can retrieve the profiles saved on Octoprint in the settings API endpoint. Would be nice to retrieve those profiles available. But I guess there's not much usefulness out of getting the settings from octoprint, and using the settings to send back to octoprint? Ignore me.

fmatray commented 4 years ago

Hello, I looked into the REST API documentation but I can't find temperatures profiles. Do you have any idea how to retrieve the information ?

chunkysteveo commented 4 years ago

Yeah. They are buried deep in the settings endpoint. /api/settings you'd need to drill down the json object to get to them. Search for 'profiles' when you get all the settings back. It's a big json return, so may be too big to bring back? Try it in a browser to see the full json object.

fmatray commented 4 years ago

It's a HUGE JSON and dependents on plugins configuration. With mine, I get 19k characters, really TOO much for an arduino.

I tried to request just a part (temperature) but looks like it's impossible.

chunkysteveo commented 4 years ago

Yeah, I looked into Arduino JSON targeting just a part of a JSON object in a stream before moving it into memory. Couldn't get it to work either (getting the colour I think of the installation!). There is a streaming JSON library which does allow you to do that, but it's just not worth it right now!

Let's park the profiles for now, and just make our own locally that you can use your new setTemp functions for?

fmatray commented 4 years ago

I agree, too complicate for the usage.

Do you code the profile part ?

chunkysteveo commented 4 years ago

No, not touched anything on this yet. Too busy with work.