This is what I have done so far.
1) I setup 2 files Simple.H and Simple.ccp
a) Simple.h contains ( I think this file is not needed.)
void userdefinedmacro(uint8_t index);
b) Simple.ccp contains
#ifdef` CPUMAPTEST1
void userdefinedmacro(uint8_t index)
{
switch (index) {
#ifdef MACROBUTTON0_PIN
case CONTROLPININDEXMACRO0:
inputBuffer.push(“$H\r”); // home machine
break;
}
}
#endif
2) In my CPU MAP I added
#include “Simple.h”
#define MACROBUTTON0PIN GPIONUM_22
I am not able to compile it. I am surely doing something wrong.
评论 (4)
#2 – mac7988 于 2019-11-08
> Follow the atari_1020 as an example.
>
> In cpu_map.h you should include your simple.h (keep it all lower case to match most other files) inside your cpu map.
>
> In simple.h, place all your #define statement first. Then wrap all your function prototypes like this at the bottom.
>
> “c++“
> #ifndef simple_h
> #define simple_h
>
> #endif
>
>
> in simple.cpp, include grbl.h at the top. Surround all your functions with the #ifdef of your cpu map. so it only uses them for your machine.
>
> Paste your compile error if you still have trouble.
Thank you, I will try it when I get home. Thank you.
#3 – mac7988 于 2019-11-09
Hi Bart,
Thank you for the info. Silly mistake but got it working following your suggestions.
I did notice if you press the macro to run a Gcode from the sd card it will run the code but from that point forward hitting a cycle start will also run that macro( even after a power cycle) not a problem for me, In fact it’s good for a headless machine.
Also serial monitor shows invalid gcode error if you press feedhold. which is nothing in the code just weird.
Did I mention your work here is amazing. I will do my best to support other users from my learning as well.
Cheers!
#4 – bdring 于 2019-11-09
Glad to hear it. The compiler is very picky and does not behave exactly the same as some other c compilers.
closing….
#1 – bdring 于 2019-11-08
Follow the atari_1020 as an example.
In cpu_map.h you should include your simple.h (keep it all lower case to match most other files) inside your cpu map.
In simple.h, place all your #define statement first. Then wrap all your function prototypes like this at the bottom.
“
C++#ifndef simple_h
#define simple_h
#endif
“
in simple.cpp, include grbl.h at the top. Surround all your functions with the #ifdef of your cpu map. so it only uses them for your machine.
Paste your compile error if you still have trouble.