#include "libs/nuts_bolts.h"
#include "libs/SlowTicker.h"
#include "libs/Adc.h"
-#include "libs/Digipot.h"
#include "libs/Pauser.h"
#include "libs/StreamOutputPool.h"
#include <mri.h>
add_module( this->slow_ticker = new SlowTicker());
this->step_ticker = new StepTicker();
this->adc = new Adc();
- this->digipot = new Digipot();
// LPC17xx-specific
NVIC_SetPriorityGrouping(0);
#include "libs/StreamOutputPool.h"
#include "libs/StepTicker.h"
#include "libs/Adc.h"
-#include "libs/Digipot.h"
#include "libs/Pauser.h"
#include "modules/communication/SerialConsole.h"
#include "modules/communication/GcodeDispatch.h"
SlowTicker* slow_ticker;
StepTicker* step_ticker;
Adc* adc;
- Digipot* digipot;
private:
std::array<std::vector<Module*>, NUMBER_OF_DEFINED_EVENTS> hooks; // When a module asks to be called for a specific event ( a hook ), this is where that request is remembered
}
void Laser::on_module_loaded() {
- if( !this->kernel->config->value( laser_module_enable_checksum )->by_default(false)->as_bool() ){ return; }
+ if( !this->kernel->config->value( laser_module_enable_checksum )->by_default(false)->as_bool() ){
+ // as not needed free up resource
+ delete this;
+ return;
+ }
this->laser_pin = new mbed::PwmOut(p21);
this->laser_pin->period_us(20);
#include <string>
using namespace std;
-CurrentControl::CurrentControl(){}
+CurrentControl::CurrentControl(){
+ digipot= NULL;
+}
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(false)->as_bool() ){
+ // as this module is not needed free up the resource
+ delete this;
+ return;
+ }
+
+ // allocate digipot, if already allocated delete it first
+ delete digipot;
+ digipot = new Digipot();
// Get configuration
this->alpha_current = this->kernel->config->value(alpha_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->kernel->digipot->set_current(2, this->gamma_current);
- this->kernel->digipot->set_current(3, this->delta_current);
+ this->digipot->set_current(0, this->alpha_current);
+ this->digipot->set_current(1, this->beta_current );
+ this->digipot->set_current(2, this->gamma_current);
+ this->digipot->set_current(3, this->delta_current);
this->register_for_event(ON_GCODE_RECEIVED);
}
for (i = 0; i < 4; i++)
{
if (gcode->has_letter(alpha[i]))
- this->kernel->digipot->set_current(i, gcode->get_value(alpha[i]));
- gcode->stream->printf("%c:%3.1fA%c", alpha[i], this->kernel->digipot->get_current(i), (i == 3)?'\n':' ');
+ this->digipot->set_current(i, gcode->get_value(alpha[i]));
+ gcode->stream->printf("%c:%3.1fA%c", alpha[i], this->digipot->get_current(i), (i == 3)?'\n':' ');
}
}
}