2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
11 #include "libs/Kernel.h"
12 #include "libs/utils.h"
16 #define config_get_checksum 46310
17 #define config_set_checksum 55538
18 #define config_load_checksum 3143
24 this->default_set
= false;
27 ConfigValue
* required(){
28 if( this->found
== true ){
31 error("could not find config setting with checksum %u, please see http://smoothieware.org/configuring-smoothie\r\n", this->check_sum
);
36 if( this->found
== false && this->default_set
== true ){
37 return this->default_double
;
39 double result
= atof(remove_non_number(value
).c_str());
40 if( result
== 0.0 && this->value
.find_first_not_of("0.") != string::npos
){
41 error("config setting '%s' with value '%s' is not a valid number, please see http://smoothieware.org/configuring-smoothie\r\n", this->key
.c_str(), this->value
.c_str() );
48 if( this->found
== false && this->default_set
== true ){
49 return this->default_double
;
51 if( this->value
.find_first_of("t1") != string::npos
){
60 ConfigValue
* by_default(double value
){
61 this->default_set
= true;
62 this->default_double
= value
;
66 bool has_characters( string mask
){
67 if( this->value
.find_first_of(mask
) != string::npos
){ return true; }else{ return false; }
71 return this->has_characters(string("!"));
79 double default_double
;
83 class Config
: public Module
{
87 void on_module_loaded();
88 void on_console_line_received( void* argument
);
89 void config_get_command( string parameters
);
90 void config_set_command( string parameters
);
91 void config_load_command(string parameters
);
92 void set_string( uint16_t check_sum
, string value
);
93 ConfigValue
* value(uint16_t check_sum
);
94 bool has_characters(uint16_t check_sum
, string str
);
95 string
get_config_file();
96 bool has_config_file();
97 void try_config_file(string candidate
);
99 string config_file
; // Path to the config file
100 bool config_file_found
; // Wether or not the config file's location is known