#include <stdio.h>
#include <cstdlib>
+#include "mbed.h"
+
using std::string;
uint16_t get_checksum(const string &to_check)
}
// Separate command from arguments
-string get_arguments( string possible_command )
+string get_arguments( const string& possible_command )
{
size_t beginning = possible_command.find_first_of(" ");
if( beginning == string::npos ) {
}
// Convert a path indication ( absolute or relative ) into a path ( absolute )
-// TODO: Combine with plan9 absolute_path, current_path as argument?
string absolute_from_relative( string path )
{
string cwd = THEKERNEL->current_path;
{
vector<string> l= split(str, ',');
vector<float> r;
- for(auto& s : l) {
+ for(auto& s : l){
float x = strtof(s.c_str(), nullptr);
r.push_back(x);
}
return r;
}
+vector<uint32_t> parse_number_list(const char *str, uint8_t radix)
+{
+ vector<string> l= split(str, ',');
+ vector<uint32_t> r;
+ for(auto& s : l){
+ uint32_t x = strtol(s.c_str(), nullptr, radix);
+ r.push_back(x);
+ }
+ return r;
+}
+
int append_parameters(char *buf, std::vector<std::pair<char,float>> params, size_t bufsize)
{
size_t n= 0;
}
return n;
}
+
+string wcs2gcode(int wcs) {
+ string str= "G5";
+ str.append(1, std::min(wcs, 5) + '4');
+ if(wcs >= 6) {
+ str.append(".").append(1, '1' + (wcs - 6));
+ }
+ return str;
+}
+
+void safe_delay_ms(uint32_t delay)
+{
+ safe_delay_us(delay*1000);
+}
+
+void safe_delay_us(uint32_t dus)
+{
+ uint32_t start = us_ticker_read();
+ while ((us_ticker_read() - start) < dus) {
+ THEKERNEL->call_event(ON_IDLE);
+ }
+}