8 // Whether or not a Gcode has a letter
9 bool Gcode::has_letter( char letter
){
10 //return ( this->command->find( letter ) != string::npos );
11 for (size_t i
=0; i
< this->command
.length(); i
++){
12 if( this->command
.at(i
) == letter
){
19 // Retrieve the value for a given letter
20 //double Gcode::get_value_old( char letter ){
21 // size_t start = this->command.find(letter);
22 // size_t end = this->command.find_first_not_of("1234567890.-", start+1);
23 // if( end == string::npos ){ end = this->command.length()+1; }
24 // string extracted = this->command.substr( start+1, end-start-1 );
25 // double value = atof(extracted.c_str());
30 // Retrieve the value for a given letter
31 // We don't use the high-level methods of std::string because they call malloc and it's very bad to do that inside of interrupts
32 double Gcode::get_value( char letter
){
34 for (size_t i
=0; i
<= this->command
.length()-1; i
++){
35 if( letter
== this->command
.at(i
) ){
36 size_t beginning
= i
+1;
38 for(size_t j
=beginning
; j
<= this->command
.length(); j
++){
40 if( j
== this->command
.length() ){ c
= ';'; }else{ c
= this->command
.at(j
); }
41 if( c
!= '.' && c
!= '-' && ( c
< '0' || c
> '9' ) ){
42 buffer
[j
-beginning
] = '\0';
46 buffer
[j
-beginning
] = c
;