Cloning / Modifying and existing plugin

First, some background. I've installed some external cooling fans on my printer. These are 12v fans commonly found in PCs. I have added a hat to my Raspberry Pi to control these fans including variable speed. I want the speed of these fans to mirror the speed of the part cooling fans on the tool head, i.e. follow "M106 Sn" and "M107".

I have installed the "GCode System Commands" plugin, defined some "OCTO" commands, and can successfully control the speed of the fans through the GCode. The last step is modifying the GCode to insert the appropriate OCTO commands whenever there is an "M106 Sn" or "M107" command.

The plugins "CommandSplitter" and "Fan Speed Control" are almost exactly what I need. Since I'm a NOOB when it comes to writing plugins, I'd like to start with these and modify one of them for my needs. I believe AGPLv3 allows me to do this but I need some help with how to do this :slight_smile:

First, after I install one of these plugins can I then modify its source code on my system? Where would I find the sources? After modifying them, how do I tell OctoPrint to "compile" or "build" it? How do I "debug" in this environment?

The plugin tutorial from the docs should answer your questions. Instead of creating a new plugin just clone an existing git repository.

To create your own version of it, go to the repository you want to clone (e.g. from your post https://github.com/ntoff/OctoPrint-FanSpeedSlider ) and up the top right you'll see the button that says "Fork", click it and it'll create a copy on your own account.

From there you'll clone that to your local computer (I'm assuming a raspberry pi running octopi)

make a directory (or don't, it's just neater if you do) called "github" in your home directory

mkdir ~/github

You could just git clone straight into your home directory, it's just neater to keep all the projects in one folder.

Then you'd

cd ~/github

and

git clone https://github.com/b-morgan/OctoPrint-FanSpeedSlider

assuming you followed the docs and installed cookie cutter http://docs.octoprint.org/en/master/plugins/gettingstarted.html#growing-up-how-to-make-it-distributable

you can (I think, it's been a while since I used a pi for much of anything)

source ~/oprint/bin/activate

cd ~/github/OctoPrint-FanSpeedSlider

octoprint dev plugin:install

Then restart octoprint, either with the system menu or sudo service octoprint restart

Then you can edit your files with whichever editor suits you best. Messing with the .py files usually requires octoprint to be restarted but not the plugin to be reinstalled.

1 Like

I think I'd make that a...

git clone --depth=1 https://github.com/b-morgan/OctoPrint-FanSpeedSlider

Since you won't be contributing to the original author's code and you're not interested in their history. Further, you could even...

rmdir -r .git      # Just nuke the entire hidden folder/database
git init           # and start a new one

To just start things fresh, then later create your own (new) github repository appropriately-named.

@b-morgan Im attempting to do something similar to control the fans on my hotend with the rp rather than the printer's mainboard because im using the third power output on my RAMPS board to control a second hotend. You seem to have made much more progress than I have, is there any chance I could get a copy of the code you have edited so far?