Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NuTool - ClockConfigure] [NuTool - PinConfigure] Easier way to copy register C code into project #3

Open
jaydcarlson opened this issue Feb 7, 2022 · 1 comment

Comments

@jaydcarlson
Copy link

jaydcarlson commented Feb 7, 2022

Rather than using the "Generate Code" feature, ClockConfigure and PinConfigure should have a button to allow the user to copy the register init code, as plaintext C code, to the clipboard so that they can paste it into their project.

Right now, it's rather clunky to use and integrate these tools into a project. Both ClockConfigure and PinConfigure have a "Generate Code" feature that will create a series of directories and separate MyProject.c source files that both contain a void SYS_Init() method with the generated registers. However, these files obviously can't be used unmodified, since the method names are identical, thus the user has to manually combine the code in these methods into their own project tree.

It seems like it would make more sense to just copy the contents of these generated SYS_Init() methods directly to the clipboard so the user can paste it into their own project.

@jaydcarlson
Copy link
Author

jaydcarlson commented Feb 7, 2022

I was able to hack at the minified js code for ClockConfigure to get what I want. I just implemented oncopy in the window.onload() method and manually ran the code generator functions (these are minified names):

    window.onload = function () {
        document.body.oncopy = function(e) {
            td_no_header();
            dd();
            window.clipboardData.setData ("Text", O);
            e.preventDefault();
        }
        Id();
    };

(I made a copy of the td() function that doesn't add in all the stuff before the registers)

That way, whenever I type "Ctrl-C" on my keyboard, I get the generated code on my clipboard I can paste into my project.

Similarly, I was able to hack at the PinConfigure tool to do the same thing a bit more easily:

    window.onload = function () {

        var ctrlDown = false,
        ctrlKey = 17,
        cmdKey = 91,
        cKey = 67;

        document.onkeydown = function(e) {
            if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = true;

            if(e.keyCode == cKey) {
                NUTOOL_PIN.getDataUsedToCreateText();
                window.clipboardData.setData ("Text", ea);
                alert("Init code copied to clipboard");
                e.preventDefault();
            }
        };
        
        document.onkeyup = function(e) {
            if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = false;
        }
        
        Kc();
    };

(for some reason, oncopy wasn't working, so I just listen for keys and react to "Ctrl-C" or "Cmd-C")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant