#include "modules/tools/laser/Laser.h"
#include "modules/tools/extruder/Extruder.h"
#include "modules/tools/temperaturecontrol/TemperatureControlPool.h"
+#include "modules/tools/switch/SwitchPool.h"
#include "modules/robot/Player.h"
#include "modules/utils/simpleshell/SimpleShell.h"
#include "modules/utils/configurator/Configurator.h"
kernel->add_module( new Configurator() );
kernel->add_module( new CurrentControl() );
kernel->add_module( new TemperatureControlPool() );
+ kernel->add_module( new SwitchPool() );
kernel->add_module( new PauseButton() );
//kernel->add_module( &cdcmsc );
--- /dev/null
+/*
+ This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
+ Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "libs/Module.h"
+#include "libs/Kernel.h"
+#include <math.h>
+#include "Switch.h"
+#include "libs/Pin.h"
+
+Switch::Switch(){}
+
+Switch::Switch(uint16_t name){
+ this->name_checksum = name;
+}
+
+void Switch::on_module_loaded(){
+ this->register_for_event(ON_GCODE_EXECUTE);
+
+ // Settings
+ this->on_config_reload(this);
+
+}
+
+
+// Get config
+void Switch::on_config_reload(void* argument){
+ this->on_m_code = this->kernel->config->value(switch_checksum, this->name_checksum, on_m_code_checksum )->required()->as_number();
+ this->off_m_code = this->kernel->config->value(switch_checksum, this->name_checksum, off_m_code_checksum )->required()->as_number();
+ this->output_pin = this->kernel->config->value(switch_checksum, this->name_checksum, output_pin_checksum )->required()->as_pin()->as_output();
+ this->output_pin->set( this->kernel->config->value(switch_checksum, this->name_checksum, startup_state_checksum )->by_default(0)->as_number() );
+}
+
+// Turn pin on and off
+void Switch::on_gcode_execute(void* argument){
+ Gcode* gcode = static_cast<Gcode*>(argument);
+ if( gcode->has_letter('M' )){
+ int code = gcode->get_value('M');
+ if( code == this->on_m_code ){
+ // Turn pin on
+ this->output_pin->set(1);
+ }
+ if( code == this->off_m_code ){
+ // Turn pin off
+ this->output_pin->set(0);
+ }
+ }
+}
+
+
+
+
--- /dev/null
+/*
+ this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl).
+ smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version.
+ smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details.
+ you should have received a copy of the gnu general public license along with smoothie. if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SWITCH_H
+#define SWITCH_H
+
+#include "libs/Pin.h"
+#include <math.h>
+
+#define switch_checksum 15508
+#define on_m_code_checksum 29094
+#define off_m_code_checksum 14853
+#define output_pin_checksum 18779
+#define startup_state_checksum 37528
+
+class Switch : public Module {
+ public:
+ Switch();
+ Switch(uint16_t name);
+
+ void on_module_loaded();
+ void on_config_reload(void* argument);
+ void on_gcode_execute(void* argument);
+
+ uint16_t name_checksum;
+ uint16_t on_m_code;
+ uint16_t off_m_code;
+ Pin* output_pin;
+};
+
+#endif
--- /dev/null
+/*
+ This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
+ Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "libs/Module.h"
+#include "libs/Kernel.h"
+#include <math.h>
+using namespace std;
+#include <vector>
+#include "SwitchPool.h"
+#include "Switch.h"
+
+SwitchPool::SwitchPool(){}
+
+void SwitchPool::on_module_loaded(){
+
+ vector<uint16_t> modules;
+ this->kernel->config->get_module_list( &modules, switch_checksum );
+
+ for( int i = 0; i < modules.size(); i++ ){
+ // If module is enabled
+ if( this->kernel->config->value(switch_checksum, modules[i], enable_checksum )->as_bool() == true ){
+ Switch* controller = new Switch(modules[i]);
+ this->kernel->add_module(controller);
+ this->controllers.push_back( controller );
+ }
+ }
+
+}
+
+
+
+
+
--- /dev/null
+/*
+ this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl).
+ smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version.
+ smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details.
+ you should have received a copy of the gnu general public license along with smoothie. if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SWITCHPOOL_H
+#define SWITCHPOOL_H
+
+#include "Switch.h"
+#include <math.h>
+using namespace std;
+#include <vector>
+
+#define switch_checksum 15508
+#define enable_checksum 29545
+
+class SwitchPool : public Module {
+ public:
+ SwitchPool();
+
+ void on_module_loaded();
+
+ vector<Switch*> controllers;
+};
+
+
+
+#endif