| 
						
						
							
								
							
						
						
					 | 
					@ -3,6 +3,8 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include <functional> | 
					 | 
					 | 
					#include <functional> | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include <iostream> | 
					 | 
					 | 
					#include <iostream> | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include <fstream> | 
					 | 
					 | 
					#include <fstream> | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					#include <memory> | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					#include <cmath> | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					namespace simon { | 
					 | 
					 | 
					namespace simon { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  namespace stepper { | 
					 | 
					 | 
					  namespace stepper { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -16,7 +18,8 @@ namespace simon { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      extract_settings(j_set, axis); | 
					 | 
					 | 
					      extract_settings(j_set, axis); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      m_thread = std::thread(std::bind(&a4988::c_allegro_4988::run, &(*m_ptr_a4988))); | 
					 | 
					 | 
					      m_thread = std::thread(std::bind(&a4988::c_allegro_4988::run, &(*m_ptr_a4988))); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      m_ptr_a4988->post_move(32768, true, 100); | 
					 | 
					 | 
					      rotate(180); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      rotate(-180); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      m_ptr_a4988->kill(); | 
					 | 
					 | 
					      m_ptr_a4988->kill(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      m_thread.join(); | 
					 | 
					 | 
					      m_thread.join(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -41,7 +44,8 @@ namespace simon { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            m_stepper = { | 
					 | 
					 | 
					            m_stepper = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					               // TODO: Do more sanitizing before retrieving this data
 | 
					 | 
					 | 
					               // TODO: Do more sanitizing before retrieving this data
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              .gear_reduction = j_axis_conf["stepper"]["gear_reduction"], | 
					 | 
					 | 
					              .gear_reduction = j_axis_conf["stepper"]["gear_reduction"], | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					              .steps_per_revolution = j_axis_conf["stepper"]["steps_per_revolution"] | 
					 | 
					 | 
					              .steps_per_revolution = j_axis_conf["stepper"]["steps_per_revolution"], | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              .clockwise = j_axis_conf["stepper"]["clockwise"] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            }; | 
					 | 
					 | 
					            }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            break; | 
					 | 
					 | 
					            break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          } | 
					 | 
					 | 
					          } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -66,5 +70,17 @@ namespace simon { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      return jstring; | 
					 | 
					 | 
					      return jstring; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    float c_stepper::rotate(const float& degrees) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      auto steps_360 =  m_stepper.gear_reduction | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                      * m_stepper.steps_per_revolution | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                      * static_cast<float>(m_ptr_a4988->get_microsteps()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      auto steps = static_cast<unsigned>((std::abs(degrees)/360.0f) * steps_360); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      bool direction = (degrees < 0) ? !m_stepper.clockwise : m_stepper.clockwise; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      std::cout << "dir >" << direction << std::endl; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      m_ptr_a4988->post_move(steps, direction, 100); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      return steps; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					
  |