Pin* from_string(std::string value){
LPC_GPIO_TypeDef* gpios[5] ={LPC_GPIO0,LPC_GPIO1,LPC_GPIO2,LPC_GPIO3,LPC_GPIO4};
- this->port = gpios[ atoi(value.substr(0,1).c_str()) ];
+ this->port_number = atoi(value.substr(0,1).c_str());
+ this->port = gpios[this->port_number];
this->inverting = ( value.find_first_of("!")!=string::npos ? true : false );
this->pin = atoi( value.substr(2, value.size()-2-(this->inverting?1:0)).c_str() );
return this;
return this;
}
+ inline Pin* as_open_drain(){
+ if( this->port_number == 0 ){ LPC_PINCON->PINMODE_OD0 |= (1<<this->pin); }
+ if( this->port_number == 1 ){ LPC_PINCON->PINMODE_OD1 |= (1<<this->pin); }
+ if( this->port_number == 2 ){ LPC_PINCON->PINMODE_OD2 |= (1<<this->pin); }
+ if( this->port_number == 3 ){ LPC_PINCON->PINMODE_OD3 |= (1<<this->pin); }
+ if( this->port_number == 4 ){ LPC_PINCON->PINMODE_OD4 |= (1<<this->pin); }
+ return this;
+ }
+
inline bool get(){
if( this->inverting ){
return ~(( this->port->FIOPIN >> this->pin ) & 1);
bool inverting;
LPC_GPIO_TypeDef* port;
+ char port_number;
char pin;
};
this->alpha_dir_pin = this->kernel->config->value(alpha_dir_pin_checksum )->by_default("1.18" )->as_pin()->as_output();
this->beta_dir_pin = this->kernel->config->value(beta_dir_pin_checksum )->by_default("1.20" )->as_pin()->as_output();
this->gamma_dir_pin = this->kernel->config->value(gamma_dir_pin_checksum )->by_default("1.19" )->as_pin()->as_output();
+ this->alpha_en_pin = this->kernel->config->value(alpha_en_pin_checksum )->by_default("0.4" )->as_pin()->as_output()->as_open_drain();
+ this->beta_en_pin = this->kernel->config->value(beta_en_pin_checksum )->by_default("0.10" )->as_pin()->as_output()->as_open_drain();
+ this->gamma_en_pin = this->kernel->config->value(gamma_en_pin_checksum )->by_default("0.19" )->as_pin()->as_output()->as_open_drain();
+
+
+ // TODO : This is supposed to be done by gcodes
+ this->alpha_en_pin->set(0);
+ this->beta_en_pin->set(0);
+ this->gamma_en_pin->set(0);
+
// Set the Timer interval for Match Register 1,
this->kernel->step_ticker->set_reset_delay( this->microseconds_per_step_pulse / 1000000 );
#define alpha_dir_pin_checksum 55887
#define beta_dir_pin_checksum 28644
#define gamma_dir_pin_checksum 46412
+#define alpha_en_pin_checksum 35042
+#define beta_en_pin_checksum 34680
+#define gamma_en_pin_checksum 26335
+
class Stepper : public Module {
public:
Pin* alpha_dir_pin;
Pin* beta_dir_pin;
Pin* gamma_dir_pin;
+ Pin* alpha_en_pin;
+ Pin* beta_en_pin;
+ Pin* gamma_en_pin;
unsigned short step_bits[3];
int counter_increment;
bool paused;
CurrentControl::CurrentControl(){}
void CurrentControl::on_module_loaded(){
- //if( !this->kernel->config->value( currentcontrol_module_enable_checksum )->by_default(false)->as_bool() ){ return; }
+ if( !this->kernel->config->value( currentcontrol_module_enable_checksum )->by_default(true)->as_bool() ){ return; }
// Get configuration
- this->alpha_current = this->kernel->config->value(alpha_current_checksum )->by_default(0)->as_number();
- this->beta_current = this->kernel->config->value(beta_current_checksum )->by_default(0.1)->as_number();
- this->gamma_current = this->kernel->config->value(gamma_current_checksum )->by_default(1.9)->as_number();
- this->delta_current = this->kernel->config->value(delta_current_checksum )->by_default(2)->as_number();
+ this->alpha_current = this->kernel->config->value(alpha_current_checksum )->by_default(0.8)->as_number();
+ this->beta_current = this->kernel->config->value(beta_current_checksum )->by_default(0.8)->as_number();
+ this->gamma_current = this->kernel->config->value(gamma_current_checksum )->by_default(0.8)->as_number();
+ this->delta_current = this->kernel->config->value(delta_current_checksum )->by_default(0.8)->as_number();
this->kernel->digipot->set_current(0, this->alpha_current);
this->kernel->digipot->set_current(1, this->beta_current );
this->register_for_event(ON_PLAY);
this->register_for_event(ON_PAUSE);
- this->button = this->kernel->config->value( pause_button_pin_checksum )->by_default("0.0")->as_pin()->as_input();
- this->led = this->kernel->config->value( pause_led_pin_checksum )->by_default("0.1")->as_pin()->as_output();
+ this->button = this->kernel->config->value( pause_button_pin_checksum )->by_default("2.12")->as_pin()->as_input();
+ this->led = this->kernel->config->value( pause_led_pin_checksum )->by_default("4.28")->as_pin()->as_output();
this->kernel->slow_ticker->attach( 100, this, &PauseButton::button_tick );
}