Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
developers-guide [2017/04/27 10:21]
72.168.144.31 Fix code block syntax
developers-guide [2019/02/02 11:16]
wolfmanjm [When to read configuration]
Line 10: Line 10:
  
 When coding a smoothie module, you probably want the user to be able to configure it. When coding a smoothie module, you probably want the user to be able to configure it.
-In smoothie configuration is stored in a configuration file, it is read at startup time ( when your module is being loaded ), and anytime the configuration is reloaded ( for example when the config file is changed )+In smoothie configuration is stored in a configuration file, it is read at startup time ( when your module is being loaded ).
  
-If you want your config values to be read only upon module loading, but not when the config is reloaded, ​read your config values from the //​on_module_loaded//​ callback of your module:​ [[https://​github.com/​arthurwolf/​Smoothie/​blob/​bee725fcd5dce2162f643dd747fb95c1cc9f4242/​src/​modules/​utils/​pausebutton/​PauseButton.cpp#​L16|example]].+If you want your config values to be read only upon module loading read your config values from the //​on_module_loaded//​ callback of your module:​ [[https://​github.com/​arthurwolf/​Smoothie/​blob/​bee725fcd5dce2162f643dd747fb95c1cc9f4242/​src/​modules/​utils/​pausebutton/​PauseButton.cpp#​L16|example]].
  
-However this is not recommended. You probably want your configuration to be also read when the system says the configuration has been updated. ​ 
-What you want to do then is add a //​on_config_reload//​ handler to your module. 
-That handler is called for all modules, when Smoothie wants the configuration reloaded. 
-And of course you also want to call that callback from //​on_module_loaded//​ 
- 
-<code cpp> 
-void MyModule::​on_module_loaded() { 
-    // Settings 
-    this->​on_config_reload(this);​ 
-} 
- 
-// Get config 
-void MyModule::​on_config_reload(void* argument){ 
- // read configuration values 
-} 
-</​code>​ 
  
 === Checksums === Checksums