Archim config

On the 414 firmware, I was able to enable the controller fan so my fan turns on with the steppers until a preset amount of time after the steppers disable. I defined it to pin 6 so I could use one of the handy mosfet plugs, and because I was thinking about using a larger fan than I ended up using.
Anyway, fast forward to 425, and something is broken. The IDE starts yelling at me about not being able to set a variable to a nonconstant outside the…method? loop? I forget exactly now, just hoping somebody else has seen it and knows.
Pretty sure we aren’t messing with the features/fan folder for CNC, so I tried pasting in the folder from the old firmware, same problem. So, I think it must be in one of the config files, but those things are SO heavy with variables that I think I’d have to spend a few hours reading through them just to know where to start.
Anybody got ideas off the top of their head? Should I go get the entire actual error verbatim? I know a little about Java and object oriented programming, so I’m not entirely lost reading the code, I just don’t know how the workflow goes for compiling a program so I’m not sure where the start line is.

If you paste the first few errors, I can try to tell you what it is saying. The config files aren’t actually that long, especially if you just ignore everything to do with the extruders. IIRC, the fan stuff is in the adv one, and it is just a few params.

1 Like

In file included from sketch/src/MarlinCore.cpp:173:0:
sketch/src/feature/controllerfan.h:61:67: error: non-constant in-class initialization invalid for static member ‘ControllerFan::settings’
static const controllerFan_settings_t constexpr &settings = controllerFan_defaults;
sketch/src/feature/controllerfan.h:61:67: error: (an out of class initialization is required)
sketch/src/feature/controllerfan.h:61:67: error: ‘ControllerFan::settings’ cannot be initialized by a non-constant expression when being declared
exit status 1
Error compiling for board Archim.

Thanks. Let me know what you make of that. Firmware compiled, then I uncommented
“define use_controller_fan” and set the controller_fan_pin to 6 (from -1).
Worked ok on the older firmware.

#define CONTROLLER_FAN_PIN 6 // Set a custom pin for the controller fan
//#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered
#define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.)
#define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled
#define CONTROLLERFAN_SPEED_IDLE 0 // (0-255) Idle speed, used when motors are disabled
#define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors
//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu

I’m not at my computer, but this error is something that you should not be able to break with a config file. I suspect there isn’t a test case that covers the settings you changed, and this code (which is normally not compiled) broke in one of the updates.

static member variables are created before any objects are, and this one is initialized from something the compiler can’t determine to be constant. If needs to be set later, outside the class definition, if it is going to be set by something that isn’t only knowable at runtime.

But more specifically, I don’t see how this could be your fault. To fix it, I would go through the git history, or try to determine the intent of setting that static variable. It is probably an easy fix. Not sure when I will get a chance to look at it though. Maybe make a Marlin issue for it?

1 Like

Cool, thanks. I was pretty sure it wasn’t my fault because it worked ok in 414. I’ll see what I can dig up.