diff --git a/CMakeLists.txt b/CMakeLists.txt index 478236cab..464535aae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,7 +253,6 @@ set(FW_SOURCES SdFatUtil.cpp SdFile.cpp SdVolume.cpp - Servo.cpp sm4.c sound.cpp speed_lookuptable.cpp diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index dd545eace..b95935223 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -358,13 +358,6 @@ your extruder heater takes 2 minutes to hit the target on heating. //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like. - //If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk - //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it. - // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile. - -// #define PROBE_SERVO_DEACTIVATION_DELAY 300 - - //If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing, //it is highly recommended you let this Z_SAFE_HOMING enabled! @@ -489,20 +482,6 @@ your extruder heater takes 2 minutes to hit the target on heating. //define BlinkM/CyzRgb Support //#define BLINKM -/*********************************************************************\ -* R/C SERVO support -* Sponsored by TrinityLabs, Reworked by codexmas -**********************************************************************/ - -// Number of servos -// -// If you select a configuration below, this will receive a default value and does not need to be set manually -// set it manually if you have more servos than extruders and wish to manually control some -// leaving it undefined or defining as 0 will disable the servo subsystem -// If unsure, leave commented / disabled -// -//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command - #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm). Used by the volumetric extrusion. // Try to maintain a minimum distance from the bed even when Z is diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index 29e955cb9..a506875c6 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -191,13 +191,6 @@ void dcode_3() #include #include "bootapp.h" -#if 0 -extern float current_temperature_pinda; -extern float axis_steps_per_mm[NUM_AXIS]; - - -#define LOG(args...) printf(args) -#endif //0 #define LOG(args...) /*! diff --git a/Firmware/Filament_sensor.cpp b/Firmware/Filament_sensor.cpp index 86c298795..c186d049e 100644 --- a/Firmware/Filament_sensor.cpp +++ b/Firmware/Filament_sensor.cpp @@ -311,22 +311,7 @@ bool IR_sensor_analog::checkVoltage(uint16_t raw) { puts_P(PSTR("fsensor v0.4 in fault range 4.6-5V - unconnected")); return false; } - /// newer IR sensor cannot normally produce 0-0.3V, this is considered a failure -#if 0 // Disabled as it has to be decided if we gonna use this or not. - if(IRsensor_Hopen_TRESHOLD <= raw && raw <= IRsensor_VMax_TRESHOLD) { - puts_P(PSTR("fsensor v0.4 in fault range 0.0-0.3V - wrong IR sensor")); - return false; - } -#endif } - /// If IR sensor is "uknown state" and filament is not loaded > 1.5V return false -#if 0 -#error "I really think this code can't be enabled anymore because we are constantly checking this voltage." - if((sensorRevision == SensorRevision::_Undef) && (raw > IRsensor_Lmax_TRESHOLD)) { - puts_P(PSTR("Unknown IR sensor version and no filament loaded detected.")); - return false; - } -#endif // otherwise the IR fsensor is considered working correctly return true; } diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 9bcd473d6..6640f08a4 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -367,9 +367,6 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_points_num, float shift_x, float shift_y); #endif //HEATBED_ANALYSIS float temp_comp_interpolation(float temperature); -#if 0 -void show_fw_version_warnings(); -#endif uint8_t check_printer_version(); #ifdef PINDA_THERMISTOR diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6e9fcc9d6..63644bf58 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -115,10 +115,6 @@ #include "Wire.h" #endif -#if NUM_SERVOS > 0 -#include "Servo.h" -#endif - #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1 #include #endif @@ -294,10 +290,6 @@ ShortTimer usb_timer; bool Stopped=false; bool processing_tcode; // Helper variable to block certain functions while T-code is being processed -#if NUM_SERVOS > 0 - Servo servos[NUM_SERVOS]; -#endif - static bool target_direction; //Insert variables if CHDK is defined @@ -487,25 +479,6 @@ void suicide() #endif } -void servo_init() -{ - #if (NUM_SERVOS >= 1) && defined(SERVO0_PIN) && (SERVO0_PIN > -1) - servos[0].attach(SERVO0_PIN); - #endif - #if (NUM_SERVOS >= 2) && defined(SERVO1_PIN) && (SERVO1_PIN > -1) - servos[1].attach(SERVO1_PIN); - #endif - #if (NUM_SERVOS >= 3) && defined(SERVO2_PIN) && (SERVO2_PIN > -1) - servos[2].attach(SERVO2_PIN); - #endif - #if (NUM_SERVOS >= 4) && defined(SERVO3_PIN) && (SERVO3_PIN > -1) - servos[3].attach(SERVO3_PIN); - #endif - #if (NUM_SERVOS >= 5) - #error "TODO: enter initalisation code for more servos" - #endif -} - bool __attribute__((noinline)) printJobOngoing() { return (IS_SD_PRINTING || usb_timer.running() || print_job_timer.isRunning()); } @@ -885,31 +858,6 @@ void factory_reset() } KEEPALIVE_STATE(IN_HANDLER); } -#if 0 -void show_fw_version_warnings() { - if (FW_DEV_VERSION == FW_VERSION_GOLD || FW_DEV_VERSION == FW_VERSION_RC) return; - switch (FW_DEV_VERSION) { - case(FW_VERSION_BETA): lcd_show_fullscreen_message_and_wait_P(MSG_FW_VERSION_BETA); break; - case(FW_VERSION_ALPHA): - case(FW_VERSION_DEVEL): - case(FW_VERSION_DEBUG): - lcd_update_enable(false); - lcd_clear(); - #if (FW_DEV_VERSION == FW_VERSION_DEVEL || FW_DEV_VERSION == FW_VERSION_ALPHA) - lcd_puts_at_P(0, 0, PSTR("Development build !!")); - #else - lcd_puts_at_P(0, 0, PSTR("Debbugging build !!!")); - #endif - lcd_puts_at_P(0, 1, PSTR("May destroy printer!")); - lcd_puts_at_P(0, 2, PSTR("FW")); lcd_puts_P(PSTR(FW_VERSION_FULL)); - lcd_puts_at_P(0, 3, PSTR("Repo: ")); lcd_puts_P(PSTR(FW_REPOSITORY)); - lcd_wait_for_click(); - break; -// default: lcd_show_fullscreen_message_and_wait_P(_i("WARNING: This is an unofficial, unsupported build. Use at your own risk!")); break;////MSG_FW_VERSION_UNKNOWN c=20 r=8 - } - lcd_update_enable(true); -} -#endif #if defined(FILAMENT_SENSOR) && defined(FSENSOR_PROBING) //! @brief try to check if firmware is on right type of printer @@ -1380,10 +1328,6 @@ void setup() setup_photpin(); -#if 0 - servo_init(); -#endif - // Reset the machine correction matrix. // It does not make sense to load the correction matrix until the machine is homed. world2machine_reset(); @@ -1532,9 +1476,6 @@ void setup() #if defined(FILAMENT_SENSOR) && defined(FSENSOR_PROBING) check_if_fw_is_on_right_printer(); #endif //defined(FILAMENT_SENSOR) && defined(FSENSOR_PROBING) -#if 0 - show_fw_version_warnings(); -#endif } switch (hw_changed) { @@ -3959,7 +3900,6 @@ extern uint8_t st_backlash_y; //!@n M226 - Wait for Pin state //!@n M240 - Trigger camera //!@n M250 - Set LCD contrast C (value 0..63) -//!@n M280 - Set/Get servo position (not active) //!@n M300 - Play tone //!@n M301 - Set hotend PID //!@n M302 - Allow cold extrude, or set minimum extrude temperature @@ -5034,66 +4974,6 @@ void process_commands() gcode_G81_M420(); } break; -#if 0 - /*! - ### G82: Single Z probe at current location - Not active G82: Single Z probe at current location - - WARNING! USE WITH CAUTION! If you'll try to probe where is no leveling pad, nasty things can happen! - In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. - */ - case 82: - SERIAL_PROTOCOLLNPGM("Finding bed "); - int l_feedmultiply = setup_for_endstop_move(); - find_bed_induction_sensor_point_z(); - clean_up_after_endstop_move(l_feedmultiply); - SERIAL_PROTOCOLPGM("Bed found at: "); - SERIAL_PROTOCOL_F(current_position[Z_AXIS], 5); - SERIAL_PROTOCOLPGM("\n"); - break; - - /*! - ### G83: Babystep in Z and store to EEPROM - Not active G83: Babystep in Z and store to EEPROM - In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. - */ - case 83: - { - int babystepz = code_seen('S') ? code_value() : 0; - int BabyPosition = code_seen('P') ? code_value() : 0; - - if (babystepz != 0) { - //FIXME Vojtech: What shall be the index of the axis Z: 3 or 4? - // Is the axis indexed starting with zero or one? - if (BabyPosition > 4) { - SERIAL_PROTOCOLLNPGM("Index out of bounds"); - }else{ - // Save it to the eeprom - babystepLoadZ = babystepz; - eeprom_update_word_notify((uint16_t*)EEPROM_BABYSTEP_Z0 + BabyPosition, babystepLoadZ); - // adjust the Z - babystepsTodoZadd(babystepLoadZ); - } - - } - - } - break; - /*! - ### G84: UNDO Babystep Z (move Z axis back) - Not active G84: UNDO Babystep Z (move Z axis back) - In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. - */ - case 84: - babystepsTodoZsubtract(babystepLoadZ); - // babystepLoadZ = 0; - break; - - /*! - ### G85: Pick best babystep - Not active G85: Pick best babystep - In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. - */ - case 85: - lcd_pick_babystep(); - break; -#endif /*! ### G86 - Disable babystep correction after home G86: Disable babystep correction after home @@ -5636,42 +5516,6 @@ void process_commands() KEEPALIVE_STATE(IN_HANDLER); break; #endif //!TMC2130 -#if 0 - case 48: // M48: scan the bed induction sensor points, print the sensor trigger coordinates to the serial line for visualization on the PC. - { - // Disable the default update procedure of the display. We will do a modal dialog. - lcd_update_enable(false); - // Let the planner use the uncorrected coordinates. - mbl.reset(); - // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. - // Wait for the motors to stop and update the current position with the absolute values. - world2machine_revert_to_uncorrected(); - // Move the print head close to the bed. - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], homing_feedrate[Z_AXIS]/40); - st_synchronize(); - // Home in the XY plane. - set_destination_to_current(); - int l_feedmultiply = setup_for_endstop_move(); - home_xy(); - int8_t verbosity_level = 0; - if (code_seen('V')) { - // Just 'V' without a number counts as V1. - char c = strchr_pointer[1]; - verbosity_level = (c == ' ' || c == '\t' || c == 0) ? 1 : code_value_short(); - } - bool success = scan_bed_induction_points(verbosity_level); - clean_up_after_endstop_move(l_feedmultiply); - // Print head up. - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], homing_feedrate[Z_AXIS]/40); - st_synchronize(); - lcd_update_enable(true); - break; - } -#endif - #ifdef ENABLE_AUTO_BED_LEVELING #ifdef Z_PROBE_REPEATABILITY_TEST @@ -7272,56 +7116,7 @@ Sigma_Exit: } break; - #if NUM_SERVOS > 0 - - /*! - ### M280 - Set/Get servo position M280: Set servo position - In Prusa Firmware this G-code is deactivated by default, must be turned on in the source code. - #### Usage - - M280 [ P | S ] - - #### Parameters - - `P` - Servo index (id) - - `S` - Target position - */ - case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds - { - int servo_index = -1; - int servo_position = 0; - if (code_seen('P')) - servo_index = code_value(); - if (code_seen('S')) { - servo_position = code_value(); - if ((servo_index >= 0) && (servo_index < NUM_SERVOS)) { -#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) - servos[servo_index].attach(0); -#endif - servos[servo_index].write(servo_position); -#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) - _delay(PROBE_SERVO_DEACTIVATION_DELAY); - servos[servo_index].detach(); -#endif - } - else { - SERIAL_ECHO_START; - SERIAL_ECHO("Servo "); - SERIAL_ECHO(servo_index); - SERIAL_ECHOLN(" out of range"); - } - } - else if (servo_index >= 0) { - SERIAL_PROTOCOL(MSG_OK); - SERIAL_PROTOCOL(" Servo "); - SERIAL_PROTOCOL(servo_index); - SERIAL_PROTOCOL(": "); - SERIAL_PROTOCOLLN(servos[servo_index].read()); - } - } - break; - #endif // NUM_SERVOS > 0 - - #if (LARGE_FLASH == true && BEEPER > 0 ) + #if (BEEPER > 0) /*! ### M300 - Play tone M300: Play beep sound In Prusa Firmware the defaults are `100Hz` and `1000ms`, so that `M300` without parameters will beep for a second. @@ -10791,94 +10586,6 @@ void save_print_file_state() { saved_printing_type = PowerPanic::PRINT_TYPE_NONE; //not sd printing nor usb printing } - -#if 0 - SERIAL_ECHOPGM("SDPOS_ATOMIC="); MYSERIAL.println(sdpos_atomic, DEC); - SERIAL_ECHOPGM("SDPOS="); MYSERIAL.println(card.get_sdpos(), DEC); - SERIAL_ECHOPGM("SDLEN_PLAN="); MYSERIAL.println(sdlen_planner, DEC); - SERIAL_ECHOPGM("SDLEN_CMDQ="); MYSERIAL.println(sdlen_cmdqueue, DEC); - SERIAL_ECHOPGM("PLANNERBLOCKS="); MYSERIAL.println(int(moves_planned()), DEC); - SERIAL_ECHOPGM("SDSAVED="); MYSERIAL.println(saved_sdpos, DEC); - //SERIAL_ECHOPGM("SDFILELEN="); MYSERIAL.println(card.fileSize(), DEC); - - - { - card.setIndex(saved_sdpos); - SERIAL_ECHOLNPGM("Content of planner buffer: "); - for (unsigned int idx = 0; idx < sdlen_planner; ++ idx) - MYSERIAL.print(char(card.get())); - SERIAL_ECHOLNPGM("Content of command buffer: "); - for (unsigned int idx = 0; idx < sdlen_cmdqueue; ++ idx) - MYSERIAL.print(char(card.get())); - SERIAL_ECHOLNPGM("End of command buffer"); - } - { - // Print the content of the planner buffer, line by line: - card.setIndex(saved_sdpos); - int8_t iline = 0; - for (unsigned char idx = block_buffer_tail; idx != block_buffer_head; idx = (idx + 1) & (BLOCK_BUFFER_SIZE - 1), ++ iline) { - SERIAL_ECHOPGM("Planner line (from file): "); - MYSERIAL.print(int(iline), DEC); - SERIAL_ECHOPGM(", length: "); - MYSERIAL.print(block_buffer[idx].sdlen, DEC); - SERIAL_ECHOPGM(", steps: ("); - MYSERIAL.print(block_buffer[idx].steps_x, DEC); - SERIAL_ECHOPGM(","); - MYSERIAL.print(block_buffer[idx].steps_y, DEC); - SERIAL_ECHOPGM(","); - MYSERIAL.print(block_buffer[idx].steps_z, DEC); - SERIAL_ECHOPGM(","); - MYSERIAL.print(block_buffer[idx].steps_e, DEC); - SERIAL_ECHOPGM("), events: "); - MYSERIAL.println(block_buffer[idx].step_event_count, DEC); - for (int len = block_buffer[idx].sdlen; len > 0; -- len) - MYSERIAL.print(char(card.get())); - } - } - { - // Print the content of the command buffer, line by line: - int8_t iline = 0; - union { - struct { - char lo; - char hi; - } lohi; - uint16_t value; - } sdlen_single; - int _bufindr = bufindr; - for (int _buflen = buflen; _buflen > 0; ++ iline) { - if (cmdbuffer[_bufindr] == CMDBUFFER_CURRENT_TYPE_SDCARD) { - sdlen_single.lohi.lo = cmdbuffer[_bufindr + 1]; - sdlen_single.lohi.hi = cmdbuffer[_bufindr + 2]; - } - SERIAL_ECHOPGM("Buffer line (from buffer): "); - MYSERIAL.print(int(iline), DEC); - SERIAL_ECHOPGM(", type: "); - MYSERIAL.print(int(cmdbuffer[_bufindr]), DEC); - SERIAL_ECHOPGM(", len: "); - MYSERIAL.println(sdlen_single.value, DEC); - // Print the content of the buffer line. - MYSERIAL.println(cmdbuffer + _bufindr + CMDHDRSIZE); - - SERIAL_ECHOPGM("Buffer line (from file): "); - MYSERIAL.println(int(iline), DEC); - for (; sdlen_single.value > 0; -- sdlen_single.value) - MYSERIAL.print(char(card.get())); - - if (-- _buflen == 0) - break; - // First skip the current command ID and iterate up to the end of the string. - for (_bufindr += CMDHDRSIZE; cmdbuffer[_bufindr] != 0; ++ _bufindr) ; - // Second, skip the end of string null character and iterate until a nonzero command ID is found. - for (++ _bufindr; _bufindr < sizeof(cmdbuffer) && cmdbuffer[_bufindr] == 0; ++ _bufindr) ; - // If the end of the buffer was empty, - if (_bufindr == sizeof(cmdbuffer)) { - // skip to the start and find the nonzero command. - for (_bufindr = 0; cmdbuffer[_bufindr] == 0; ++ _bufindr) ; - } - } - } -#endif } void restore_print_file_state() { diff --git a/Firmware/Servo.cpp b/Firmware/Servo.cpp deleted file mode 100644 index 289a2ec8a..000000000 --- a/Firmware/Servo.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* - Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - Copyright (c) 2009 Michael Margolis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - - A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method. - The servos are pulsed in the background using the value most recently written using the write() method - - Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached. - Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four. - - The methods are: - - Servo - Class for manipulating servo motors connected to Arduino pins. - - attach(pin ) - Attaches a servo motor to an i/o pin. - attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds - default min is 544, max is 2400 - - write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) - writeMicroseconds() - Sets the servo pulse width in microseconds - read() - Gets the last written servo pulse width as an angle between 0 and 180. - readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) - attached() - Returns true if there is a servo attached. - detach() - Stops an attached servos from pulsing its i/o pin. - -*/ -#include "Configuration.h" - -#ifdef NUM_SERVOS -#include -#include - -#include "Servo.h" - -#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 -#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds - - -#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 - -//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER) - -static servo_t servos[MAX_SERVOS]; // static array of servo structures -static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) - -uint8_t ServoCount = 0; // the total number of attached servos - - -// convenience macros -#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo -#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer -#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel -#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel - -#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo -#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo - -/************ static functions common to all instances ***********************/ - -static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA) -{ - if( Channel[timer] < 0 ) - *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer - else{ - if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true ) - digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated - } - - Channel[timer]++; // increment to the next channel - if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { - *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks; - if(SERVO(timer,Channel[timer]).Pin.isActive == true) // check if activated - digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high - } - else { - // finished all channels so wait for the refresh period to expire before starting over - if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) ) // allow a few ticks to ensure the next OCR1A not missed - *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL); - else - *OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed - Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel - } -} - -#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform -// Interrupt handlers for Arduino -#if defined(_useTimer1) -SIGNAL (TIMER1_COMPA_vect) -{ - handle_interrupts(_timer1, &TCNT1, &OCR1A); -} -#endif - -#if defined(_useTimer3) -SIGNAL (TIMER3_COMPA_vect) -{ - handle_interrupts(_timer3, &TCNT3, &OCR3A); -} -#endif - -#if defined(_useTimer4) -SIGNAL (TIMER4_COMPA_vect) -{ - handle_interrupts(_timer4, &TCNT4, &OCR4A); -} -#endif - -#if defined(_useTimer5) -SIGNAL (TIMER5_COMPA_vect) -{ - handle_interrupts(_timer5, &TCNT5, &OCR5A); -} -#endif - -#elif defined WIRING -// Interrupt handlers for Wiring -#if defined(_useTimer1) -void Timer1Service() -{ - handle_interrupts(_timer1, &TCNT1, &OCR1A); -} -#endif -#if defined(_useTimer3) -void Timer3Service() -{ - handle_interrupts(_timer3, &TCNT3, &OCR3A); -} -#endif -#endif - - -static void initISR(timer16_Sequence_t timer) -{ -#if defined (_useTimer1) - if(timer == _timer1) { - TCCR1A = 0; // normal counting mode - TCCR1B = _BV(CS11); // set prescaler of 8 - TCNT1 = 0; // clear the timer count -#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__) - TIFR |= _BV(OCF1A); // clear any pending interrupts; - TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt -#else - // here if not ATmega8 or ATmega128 - TIFR1 |= _BV(OCF1A); // clear any pending interrupts; - TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt -#endif -#if defined(WIRING) - timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); -#endif - } -#endif - -#if defined (_useTimer3) - if(timer == _timer3) { - TCCR3A = 0; // normal counting mode - TCCR3B = _BV(CS31); // set prescaler of 8 - TCNT3 = 0; // clear the timer count -#if defined(__AVR_ATmega128__) - TIFR |= _BV(OCF3A); // clear any pending interrupts; - ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt -#else - TIFR3 = _BV(OCF3A); // clear any pending interrupts; - TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt -#endif -#if defined(WIRING) - timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only -#endif - } -#endif - -#if defined (_useTimer4) - if(timer == _timer4) { - TCCR4A = 0; // normal counting mode - TCCR4B = _BV(CS41); // set prescaler of 8 - TCNT4 = 0; // clear the timer count - TIFR4 = _BV(OCF4A); // clear any pending interrupts; - TIMSK4 = _BV(OCIE4A) ; // enable the output compare interrupt - } -#endif - -#if defined (_useTimer5) - if(timer == _timer5) { - TCCR5A = 0; // normal counting mode - TCCR5B = _BV(CS51); // set prescaler of 8 - TCNT5 = 0; // clear the timer count - TIFR5 = _BV(OCF5A); // clear any pending interrupts; - TIMSK5 = _BV(OCIE5A) ; // enable the output compare interrupt - } -#endif -} - -static void finISR(timer16_Sequence_t timer) -{ - //disable use of the given timer -#if defined WIRING // Wiring - if(timer == _timer1) { - #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) - TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt - #else - TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt - #endif - timerDetach(TIMER1OUTCOMPAREA_INT); - } - else if(timer == _timer3) { - #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) - TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt - #else - ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt - #endif - timerDetach(TIMER3OUTCOMPAREA_INT); - } -#else - //For arduino - in future: call here to a currently undefined function to reset the timer -#endif -} - -static bool isTimerActive(timer16_Sequence_t timer) -{ - // returns true if any servo is active on this timer - for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { - if(SERVO(timer,channel).Pin.isActive == true) - return true; - } - return false; -} - - -/****************** end of static functions ******************************/ - -Servo::Servo() -{ - if( ServoCount < MAX_SERVOS) { - this->servoIndex = ServoCount++; // assign a servo index to this instance - servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009 - } - else - this->servoIndex = INVALID_SERVO ; // too many servos -} - -uint8_t Servo::attach(int pin) -{ - return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); -} - -uint8_t Servo::attach(int pin, int min, int max) -{ - if(this->servoIndex < MAX_SERVOS ) { -#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) - if (pin > 0) this->pin = pin; else pin = this->pin; -#endif - pinMode( pin, OUTPUT) ; // set servo pin to output - servos[this->servoIndex].Pin.nbr = pin; - // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 - this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS - this->max = (MAX_PULSE_WIDTH - max)/4; - // initialize the timer if it has not already been initialized - timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); - if(isTimerActive(timer) == false) - initISR(timer); - servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive - } - return this->servoIndex ; -} - -void Servo::detach() -{ - servos[this->servoIndex].Pin.isActive = false; - timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); - if(isTimerActive(timer) == false) { - finISR(timer); - } -} - -void Servo::write(int value) -{ - if(value < MIN_PULSE_WIDTH) - { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) - if(value < 0) value = 0; - if(value > 180) value = 180; - value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); - } - this->writeMicroseconds(value); -} - -void Servo::writeMicroseconds(int value) -{ - // calculate and store the values for the given channel - byte channel = this->servoIndex; - if( (channel < MAX_SERVOS) ) // ensure channel is valid - { - if( value < SERVO_MIN() ) // ensure pulse width is valid - value = SERVO_MIN(); - else if( value > SERVO_MAX() ) - value = SERVO_MAX(); - - value = value - TRIM_DURATION; - value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009 - - uint8_t oldSREG = SREG; - cli(); - servos[channel].ticks = value; - SREG = oldSREG; - } -} - -int Servo::read() // return the value as degrees -{ - return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); -} - -int Servo::readMicroseconds() -{ - unsigned int pulsewidth; - if( this->servoIndex != INVALID_SERVO ) - pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ; // 12 aug 2009 - else - pulsewidth = 0; - - return pulsewidth; -} - -bool Servo::attached() -{ - return servos[this->servoIndex].Pin.isActive ; -} - -#endif diff --git a/Firmware/Servo.h b/Firmware/Servo.h deleted file mode 100644 index 204497a4a..000000000 --- a/Firmware/Servo.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - Copyright (c) 2009 Michael Margolis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -/* - - A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method. - The servos are pulsed in the background using the value most recently written using the write() method - - Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached. - Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four. - The sequence used to seize timers is defined in timers.h - - The methods are: - - Servo - Class for manipulating servo motors connected to Arduino pins. - - attach(pin ) - Attaches a servo motor to an i/o pin. - attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds - default min is 544, max is 2400 - - write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) - writeMicroseconds() - Sets the servo pulse width in microseconds - read() - Gets the last written servo pulse width as an angle between 0 and 180. - readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) - attached() - Returns true if there is a servo attached. - detach() - Stops an attached servos from pulsing its i/o pin. - */ - -#ifndef Servo_h -#define Servo_h - -#include - -/* - * Defines for 16 bit timers used with Servo library - * - * If _useTimerX is defined then TimerX is a 16 bit timer on the current board - * timer16_Sequence_t enumerates the sequence that the timers should be allocated - * _Nbr_16timers indicates how many 16 bit timers are available. - * - */ - -// Say which 16 bit timers can be used and in what order -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define _useTimer5 -//#define _useTimer1 -#define _useTimer3 -#define _useTimer4 -//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ; -typedef enum { _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ; - -#elif defined(__AVR_ATmega32U4__) -//#define _useTimer1 -#define _useTimer3 -//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ; -typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ; - -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) -#define _useTimer3 -//#define _useTimer1 -//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ; -typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ; - -#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__) ||defined(__AVR_ATmega2561__) -#define _useTimer3 -//#define _useTimer1 -//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ; -typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ; - -#else // everything else -//#define _useTimer1 -//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ; -typedef enum { _Nbr_16timers } timer16_Sequence_t ; -#endif - -#define Servo_VERSION 2 // software version of this library - -#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo -#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo -#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached -#define REFRESH_INTERVAL 20000 // minimum time to refresh servos in microseconds - -#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer -#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) - -#define INVALID_SERVO 255 // flag indicating an invalid servo index - -typedef struct { - uint8_t nbr :6 ; // a pin number from 0 to 63 - uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false -} ServoPin_t ; - -typedef struct { - ServoPin_t Pin; - unsigned int ticks; -} servo_t; - -class Servo -{ -public: - Servo(); - uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure - uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes. - void detach(); - void write(int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds - void writeMicroseconds(int value); // Write pulse width in microseconds - int read(); // returns current pulse width as an angle between 0 and 180 degrees - int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) - bool attached(); // return true if this servo is attached, otherwise false -#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) - int pin; // store the hardware pin of the servo -#endif -private: - uint8_t servoIndex; // index into the channel data for this servo - int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH - int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH -}; - -#endif diff --git a/Firmware/lcd.cpp b/Firmware/lcd.cpp index cc89a577d..b0384b322 100644 --- a/Firmware/lcd.cpp +++ b/Firmware/lcd.cpp @@ -22,8 +22,6 @@ #define LCD_8BIT #endif -// #define VT100 - // commands #define LCD_CLEARDISPLAY 0x01 #define LCD_RETURNHOME 0x02 @@ -77,10 +75,6 @@ static uint8_t lcd_displaymode = 0; uint8_t lcd_currline; static uint8_t lcd_ddram_address; // no need for preventing ddram overflow -#ifdef VT100 -uint8_t lcd_escape[8]; -#endif - struct CustomCharacter { uint8_t colByte; uint8_t rowData[4]; @@ -95,28 +89,9 @@ static const CustomCharacter Font[] PROGMEM = { #define CUSTOM_CHARACTERS_CNT (sizeof(Font) / sizeof(Font[0])) static void lcd_display(void); - -#if 0 -static void lcd_no_display(void); -static void lcd_no_cursor(void); -static void lcd_cursor(void); -static void lcd_no_blink(void); -static void lcd_blink(void); -static void lcd_scrollDisplayLeft(void); -static void lcd_scrollDisplayRight(void); -static void lcd_leftToRight(void); -static void lcd_rightToLeft(void); -static void lcd_autoscroll(void); -static void lcd_no_autoscroll(void); -#endif - static void lcd_print_custom(uint8_t c); static void lcd_invalidate_custom_characters(); -#ifdef VT100 -void lcd_escape_write(uint8_t chr); -#endif - static void lcd_pulseEnable(void) { WRITE(LCD_PINS_ENABLE,HIGH); @@ -164,16 +139,9 @@ static void lcd_write(uint8_t value) if (value == '\n') { if (lcd_currline > 3) lcd_currline = -1; lcd_set_cursor(0, lcd_currline + 1); // LF - } - else if ((value >= 0x80) && (value < (0x80 + CUSTOM_CHARACTERS_CNT))) { + } else if ((value >= 0x80) && (value < (0x80 + CUSTOM_CHARACTERS_CNT))) { lcd_print_custom(value); - } - #ifdef VT100 - else if (lcd_escape[0] || (value == '\e')) { - lcd_escape_write(value); - } - #endif - else { + } else { lcd_send(value, HIGH); lcd_ddram_address++; // no need for preventing ddram overflow } @@ -207,10 +175,6 @@ static void lcd_begin(uint8_t clear) lcd_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; // set the entry mode lcd_command(LCD_ENTRYMODESET | lcd_displaymode); - - #ifdef VT100 - lcd_escape[0] = 0; - #endif } static int lcd_putchar(char c, FILE *) @@ -278,83 +242,6 @@ void lcd_display(void) lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); } -#if 0 -void lcd_no_display(void) -{ - lcd_displaycontrol &= ~LCD_DISPLAYON; - lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); -} -#endif - -#ifdef VT100 //required functions for VT100 -// Turns the underline cursor on/off -void lcd_no_cursor(void) -{ - lcd_displaycontrol &= ~LCD_CURSORON; - lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); -} - -void lcd_cursor(void) -{ - lcd_displaycontrol |= LCD_CURSORON; - lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); -} -#endif - -#if 0 -// Turn on and off the blinking cursor -void lcd_no_blink(void) -{ - lcd_displaycontrol &= ~LCD_BLINKON; - lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); -} - -void lcd_blink(void) -{ - lcd_displaycontrol |= LCD_BLINKON; - lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); -} - -// These commands scroll the display without changing the RAM -void lcd_scrollDisplayLeft(void) -{ - lcd_command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); -} - -void lcd_scrollDisplayRight(void) -{ - lcd_command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); -} - -// This is for text that flows Left to Right -void lcd_leftToRight(void) -{ - lcd_displaymode |= LCD_ENTRYLEFT; - lcd_command(LCD_ENTRYMODESET | lcd_displaymode); -} - -// This is for text that flows Right to Left -void lcd_rightToLeft(void) -{ - lcd_displaymode &= ~LCD_ENTRYLEFT; - lcd_command(LCD_ENTRYMODESET | lcd_displaymode); -} - -// This will 'right justify' text from the cursor -void lcd_autoscroll(void) -{ - lcd_displaymode |= LCD_ENTRYSHIFTINCREMENT; - lcd_command(LCD_ENTRYMODESET | lcd_displaymode); -} - -// This will 'left justify' text from the cursor -void lcd_no_autoscroll(void) -{ - lcd_displaymode &= ~LCD_ENTRYSHIFTINCREMENT; - lcd_command(LCD_ENTRYMODESET | lcd_displaymode); -} -#endif - /// @brief set the current LCD row /// @param row LCD row number, ranges from 0 to LCD_HEIGHT - 1 static void FORCE_INLINE lcd_set_current_row(uint8_t row) @@ -443,144 +330,6 @@ void lcd_createChar_P(uint8_t location, const CustomCharacter *char_p) lcd_command(LCD_SETDDRAMADDR | lcd_ddram_address); // no need for masking the address } -#ifdef VT100 - -//Supported VT100 escape codes: -//EraseScreen "\x1b[2J" -//CursorHome "\x1b[%d;%dH" -//CursorShow "\x1b[?25h" -//CursorHide "\x1b[?25l" -void lcd_escape_write(uint8_t chr) -{ -#define escape_cnt (lcd_escape[0]) //escape character counter -#define is_num_msk (lcd_escape[1]) //numeric character bit mask -#define chr_is_num (is_num_msk & 0x01) //current character is numeric -#define e_2_is_num (is_num_msk & 0x04) //escape char 2 is numeric -#define e_3_is_num (is_num_msk & 0x08) //... -#define e_4_is_num (is_num_msk & 0x10) -#define e_5_is_num (is_num_msk & 0x20) -#define e_6_is_num (is_num_msk & 0x40) -#define e_7_is_num (is_num_msk & 0x80) -#define e2_num (lcd_escape[2] - '0') //number from character 2 -#define e3_num (lcd_escape[3] - '0') //number from character 3 -#define e23_num (10*e2_num+e3_num) //number from characters 2 and 3 -#define e4_num (lcd_escape[4] - '0') //number from character 4 -#define e5_num (lcd_escape[5] - '0') //number from character 5 -#define e45_num (10*e4_num+e5_num) //number from characters 4 and 5 -#define e6_num (lcd_escape[6] - '0') //number from character 6 -#define e56_num (10*e5_num+e6_num) //number from characters 5 and 6 - if (escape_cnt > 1) // escape length > 1 = "\x1b[" - { - lcd_escape[escape_cnt] = chr; // store current char - if ((chr >= '0') && (chr <= '9')) // char is numeric - is_num_msk |= (1 | (1 << escape_cnt)); //set mask - else - is_num_msk &= ~1; //clear mask - } - switch (escape_cnt++) - { - case 0: - if (chr == 0x1b) return; // escape = "\x1b" - break; - case 1: - is_num_msk = 0x00; // reset 'is number' bit mask - if (chr == '[') return; // escape = "\x1b[" - break; - case 2: - switch (chr) - { - case '2': return; // escape = "\x1b[2" - case '?': return; // escape = "\x1b[?" - default: - if (chr_is_num) return; // escape = "\x1b[%1d" - } - break; - case 3: - switch (lcd_escape[2]) - { - case '?': // escape = "\x1b[?" - if (chr == '2') return; // escape = "\x1b[?2" - break; - case '2': - if (chr == 'J') // escape = "\x1b[2J" - { lcd_clear(); break; } // EraseScreen - default: - if (e_2_is_num && // escape = "\x1b[%1d" - ((chr == ';') || // escape = "\x1b[%1d;" - chr_is_num)) // escape = "\x1b[%2d" - return; - } - break; - case 4: - switch (lcd_escape[2]) - { - case '?': // "\x1b[?" - if ((lcd_escape[3] == '2') && (chr == '5')) return; // escape = "\x1b[?25" - break; - default: - if (e_2_is_num) // escape = "\x1b[%1d" - { - if ((lcd_escape[3] == ';') && chr_is_num) return; // escape = "\x1b[%1d;%1d" - else if (e_3_is_num && (chr == ';')) return; // escape = "\x1b[%2d;" - } - } - break; - case 5: - switch (lcd_escape[2]) - { - case '?': - if ((lcd_escape[3] == '2') && (lcd_escape[4] == '5')) // escape = "\x1b[?25" - switch (chr) - { - case 'h': // escape = "\x1b[?25h" - lcd_cursor(); // CursorShow - break; - case 'l': // escape = "\x1b[?25l" - lcd_no_cursor(); // CursorHide - break; - } - break; - default: - if (e_2_is_num) // escape = "\x1b[%1d" - { - if ((lcd_escape[3] == ';') && e_4_is_num) // escape = "\x1b%1d;%1dH" - { - if (chr == 'H') // escape = "\x1b%1d;%1dH" - lcd_set_cursor(e4_num, e2_num); // CursorHome - else if (chr_is_num) - return; // escape = "\x1b%1d;%2d" - } - else if (e_3_is_num && (lcd_escape[4] == ';') && chr_is_num) - return; // escape = "\x1b%2d;%1d" - } - } - break; - case 6: - if (e_2_is_num) // escape = "\x1b[%1d" - { - if ((lcd_escape[3] == ';') && e_4_is_num && e_5_is_num && (chr == 'H')) // escape = "\x1b%1d;%2dH" - lcd_set_cursor(e45_num, e2_num); // CursorHome - else if (e_3_is_num && (lcd_escape[4] == ';') && e_5_is_num) // escape = "\x1b%2d;%1d" - { - if (chr == 'H') // escape = "\x1b%2d;%1dH" - lcd_set_cursor(e5_num, e23_num); // CursorHome - else if (chr_is_num) // "\x1b%2d;%2d" - return; - } - } - break; - case 7: - if (e_2_is_num && e_3_is_num && (lcd_escape[4] == ';')) // "\x1b[%2d;" - if (e_5_is_num && e_6_is_num && (chr == 'H')) // "\x1b[%2d;%2dH" - lcd_set_cursor(e56_num, e23_num); // CursorHome - break; - } - escape_cnt = 0; // reset escape -} - -#endif //VT100 - - int lcd_putc(char c) { return fputc(c, lcdout); diff --git a/Firmware/lcd.h b/Firmware/lcd.h index bcace7b28..897195070 100644 --- a/Firmware/lcd.h +++ b/Firmware/lcd.h @@ -22,19 +22,6 @@ extern void lcd_clear(void); extern void lcd_home(void); -/*extern void lcd_no_display(void); -extern void lcd_display(void); -extern void lcd_no_blink(void); -extern void lcd_blink(void); -extern void lcd_no_cursor(void); -extern void lcd_cursor(void); -extern void lcd_scrollDisplayLeft(void); -extern void lcd_scrollDisplayRight(void); -extern void lcd_leftToRight(void); -extern void lcd_rightToLeft(void); -extern void lcd_autoscroll(void); -extern void lcd_no_autoscroll(void);*/ - extern void lcd_set_cursor(uint8_t col, uint8_t row); /// @brief Change the cursor column position while preserving the current row position @@ -70,19 +57,6 @@ extern void lcd_print(unsigned int, int = 10); extern void lcd_print(long, int = 10); extern void lcd_print(unsigned long, int = 10); -//! @brief Clear screen -#define ESC_2J "\x1b[2J" -//! @brief Show cursor -#define ESC_25h "\x1b[?25h" -//! @brief Hide cursor -#define ESC_25l "\x1b[?25l" -//! @brief Set cursor to -//! @param c column -//! @param r row -#define ESC_H(c,r) "\x1b["#r";"#c"H" - - - #define LCD_UPDATE_INTERVAL 100 #define LCD_TIMEOUT_TO_STATUS 30000ul //!< Generic timeout to status screen in ms, when no user action. #define LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z 90000ul //!< Specific timeout for lcd_babystep_z screen in ms. diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 94a3c880a..4cd866937 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -499,19 +499,6 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( } #endif // SUPPORT_VERBOSITY - #if 0 - if (result == BED_SKEW_OFFSET_DETECTION_PERFECT && fabs(a1) < bed_skew_angle_mild && fabs(a2) < bed_skew_angle_mild) { - #ifdef SUPPORT_VERBOSITY - if (verbosity_level > 0) - SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction."); - #endif // SUPPORT_VERBOSITY - // Just disable the skew correction. - vec_x[0] = MACHINE_AXIS_SCALE_X; - vec_x[1] = 0.f; - vec_y[0] = 0.f; - vec_y[1] = MACHINE_AXIS_SCALE_Y; - } - #else if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) { #ifdef SUPPORT_VERBOSITY if (verbosity_level > 0) @@ -583,7 +570,6 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( } #endif // SUPPORT_VERBOSITY } - #endif // Invert the transformation matrix made of vec_x, vec_y and cntr. { @@ -1199,8 +1185,6 @@ BedSkewOffsetDetectionResultType find_bed_induction_sensor_point_xy(int MYSERIAL.println(current_position[Z_AXIS]); } #endif //SUPPORT_VERBOSITY - //lcd_show_fullscreen_message_and_wait_P(PSTR("First hit")); - //lcd_update_enable(true); float init_x_position = current_position[X_AXIS]; float init_y_position = current_position[Y_AXIS]; @@ -3101,11 +3085,7 @@ void count_xyz_details(float (&distanceMin)[2]) { eeprom_read_block(&cntr[0], (float*)(EEPROM_BED_CALIBRATION_CENTER), 8); eeprom_read_block(&vec_x[0], (float*)(EEPROM_BED_CALIBRATION_VEC_X), 8); eeprom_read_block(&vec_y[0], (float*)(EEPROM_BED_CALIBRATION_VEC_Y), 8); -#if 0 - a2 = -1 * asin(vec_y[0] / MACHINE_AXIS_SCALE_Y); - a1 = asin(vec_x[1] / MACHINE_AXIS_SCALE_X); - angleDiff = fabs(a2 - a1); -#endif + for (uint8_t mesh_point = 0; mesh_point < 2; ++mesh_point) { float y = vec_x[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2 + 1) + cntr[1]; distanceMin[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH); diff --git a/Firmware/messages.cpp b/Firmware/messages.cpp index 5fad56c91..47ed124d9 100644 --- a/Firmware/messages.cpp +++ b/Firmware/messages.cpp @@ -372,15 +372,11 @@ extern const char MSG_NEW_FIRMWARE_AVAILABLE [] PROGMEM_I1 = ISTR("New firmware extern const char MSG_NEW_FIRMWARE_PLEASE_UPGRADE [] PROGMEM_I1 = ISTR("Please upgrade."); ////MSG_NEW_FIRMWARE_PLEASE_UPGRADE c=20 extern const char MSG_FW_MK3_DETECTED [] PROGMEM_I1 = ISTR(PRINTER_NAME " firmware detected on " PRINTER_NAME_ALTERNATE " printer"); ////MSG_FW_MK3_DETECTED c=20 r=4 //not internationalized messages -#if 0 -const char MSG_FW_VERSION_BETA[] PROGMEM_N1 = "You are using a BETA firmware version! It is in a development state! Use this version with CAUTION as it may DAMAGE the printer!"; ////MSG_FW_VERSION_BETA c=20 r=8 -#endif const char MSG_SPOOL_JOIN[] PROGMEM_N1 = "SpoolJoin"; ////MSG_SPOOL_JOIN c=13 const char MSG_FIRMWARE[] PROGMEM_N1 = "Firmware"; ////MSG_FIRMWARE c=8 const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY[] PROGMEM_N1 = "FlashAir"; ////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY c=8 const char MSG_PINDA[] PROGMEM_N1 = "PINDA"; ////MSG_PINDA c=5 const char MSG_WELCOME[] PROGMEM_N1 = WELCOME_MSG; -const char MSG_SD_WORKDIR_FAIL[] PROGMEM_N1 = "workDir open failed"; //// const char MSG_BROWNOUT_RESET[] PROGMEM_N1 = " Brown out Reset"; //// const char MSG_EXTERNAL_RESET[] PROGMEM_N1 = " External Reset"; //// const char MSG_FILE_SAVED[] PROGMEM_N1 = "Done saving file."; //// @@ -396,7 +392,6 @@ const char MSG_ZPROBE_ZOFFSET[] PROGMEM_N1 = "Z Offset"; //// #endif const char MSG_TMC_OVERTEMP[] PROGMEM_N1 = "TMC DRIVER OVERTEMP"; //// const char MSG_Enqueing[] PROGMEM_N1 = "enqueing \""; //// -const char MSG_ENDSTOPS_HIT[] PROGMEM_N1 = "endstops hit: "; //// const char MSG_SD_ERR_WRITE_TO_FILE[] PROGMEM_N1 = "error writing to file"; //// const char MSG_OK[] PROGMEM_N1 = "ok"; //// const char MSG_OK_CAPS[] PROGMEM_N1 = "OK"; //// diff --git a/Firmware/messages.h b/Firmware/messages.h index 2727b2c1b..c39669bbf 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -372,15 +372,11 @@ extern const char MSG_NEW_FIRMWARE_PLEASE_UPGRADE []; extern const char MSG_FW_MK3_DETECTED []; //not internationalized messages -#if 0 -extern const char MSG_FW_VERSION_BETA[]; -#endif extern const char MSG_SPOOL_JOIN[]; extern const char MSG_FIRMWARE[]; extern const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY[]; extern const char MSG_PINDA[]; extern const char MSG_WELCOME[]; -extern const char MSG_SD_WORKDIR_FAIL[]; extern const char MSG_BROWNOUT_RESET[]; extern const char MSG_EXTERNAL_RESET[]; extern const char MSG_FILE_SAVED[]; @@ -396,7 +392,6 @@ extern const char MSG_ZPROBE_ZOFFSET[]; #endif extern const char MSG_TMC_OVERTEMP[]; extern const char MSG_Enqueing[]; -extern const char MSG_ENDSTOPS_HIT[]; extern const char MSG_SD_ERR_WRITE_TO_FILE[]; extern const char MSG_OK[]; extern const char MSG_OK_CAPS[]; diff --git a/Firmware/pins.h b/Firmware/pins.h index 1c20a001a..d0bd1a4e7 100644 --- a/Firmware/pins.h +++ b/Firmware/pins.h @@ -3,8 +3,6 @@ #include "boards.h" -#define LARGE_FLASH true - /***************************************************************** * Rambo Pin Assignments 1.3 ******************************************************************/ diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index dc4f7e202..91e9956c6 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -761,49 +761,8 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate apply_rotation_xyz(plan_bed_level_matrix, x, y, z); #endif // ENABLE_AUTO_BED_LEVELING - // Apply the machine correction matrix. - { - #if 0 - SERIAL_ECHOPGM("Planner, current position - servos: "); - MYSERIAL.print(st_get_position_mm(X_AXIS), 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(st_get_position_mm(Y_AXIS), 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(st_get_position_mm(Z_AXIS), 5); - SERIAL_ECHOLNPGM(""); - - SERIAL_ECHOPGM("Planner, target position, initial: "); - MYSERIAL.print(x, 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(y, 5); - SERIAL_ECHOLNPGM(""); - - SERIAL_ECHOPGM("Planner, world2machine: "); - MYSERIAL.print(world2machine_rotation_and_skew[0][0], 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(world2machine_rotation_and_skew[0][1], 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(world2machine_rotation_and_skew[1][0], 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(world2machine_rotation_and_skew[1][1], 5); - SERIAL_ECHOLNPGM(""); - SERIAL_ECHOPGM("Planner, offset: "); - MYSERIAL.print(world2machine_shift[0], 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(world2machine_shift[1], 5); - SERIAL_ECHOLNPGM(""); - #endif - - world2machine(x, y); - - #if 0 - SERIAL_ECHOPGM("Planner, target position, corrected: "); - MYSERIAL.print(x, 5); - SERIAL_ECHOPGM(", "); - MYSERIAL.print(y, 5); - SERIAL_ECHOLNPGM(""); - #endif - } + // Apply the machine correction matrix. + world2machine(x, y); // The target position of the tool in absolute steps // Calculate target position in absolute steps diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 0e95d6fe4..8cd856b76 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1147,25 +1147,6 @@ FORCE_INLINE static void soft_pwm_core() #endif } else WRITE(HEATER_0_PIN,0); } -#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - -#if 0 // @@DR vypnuto pro hw pwm bedu - // tuhle prasarnu bude potreba poustet ve stanovenych intervalech, jinak nemam moc sanci zareagovat - // teoreticky by se tato cast uz vubec nemusela poustet - if ((pwm_count & ((1 << HEATER_BED_SOFT_PWM_BITS) - 1)) == 0) - { - soft_pwm_b = soft_pwm_bed >> (7 - HEATER_BED_SOFT_PWM_BITS); -# ifndef SYSTEM_TIMER_2 - // tady budu krokovat pomalou frekvenci na automatu - tohle je rizeni spinani a rozepinani - // jako ridici frekvenci mam 2khz, jako vystupni frekvenci mam 30hz - // 2kHz jsou ovsem ve slysitelnem pasmu, mozna bude potreba jit s frekvenci nahoru (a tomu taky prizpusobit ostatni veci) - // Teoreticky bych mohl stahnout OCR0B citac na 6, cimz bych se dostal nekam ke 40khz a tady potom honit PWM rychleji nebo i pomaleji - // to nicemu nevadi. Soft PWM scale by se 20x zvetsilo (no dobre, 16x), cimz by se to posunulo k puvodnimu 30Hz PWM - //if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); -# endif //SYSTEM_TIMER_2 - } -#endif -#endif #ifdef FAN_SOFT_PWM if ((pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1)) == 0) @@ -1182,14 +1163,6 @@ FORCE_INLINE static void soft_pwm_core() #endif } -#if 0 // @@DR -#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - if (soft_pwm_b < (pwm_count & ((1 << HEATER_BED_SOFT_PWM_BITS) - 1))){ - //WRITE(HEATER_BED_PIN,0); - } - //WRITE(HEATER_BED_PIN, pwm_count & 1 ); -#endif -#endif #ifdef FAN_SOFT_PWM if (soft_pwm_fan < (pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1))) WRITE(FAN_PIN,0); #endif diff --git a/Firmware/xflash.c b/Firmware/xflash.c index cc758ebf5..7b89900ea 100644 --- a/Firmware/xflash.c +++ b/Firmware/xflash.c @@ -80,16 +80,6 @@ uint8_t xflash_rd_status_reg(void) return val; } -#if 0 -void w25x20cl_wr_status_reg(uint8_t val) -{ - _CS_LOW(); - _SPI_TX(_CMD_WR_STATUS_REG); // send command 0x90 - _SPI_TX(val); // send value - _CS_HIGH(); -} -#endif - static void xflash_send_cmdaddr(uint8_t cmd, uint32_t addr) { _SPI_TX(cmd); // send command 0x03 diff --git a/Firmware/xflash.h b/Firmware/xflash.h index a75abb183..2a4fb1008 100644 --- a/Firmware/xflash.h +++ b/Firmware/xflash.h @@ -30,9 +30,6 @@ extern int8_t xflash_init(void); extern void xflash_enable_wr(void); extern void xflash_disable_wr(void); extern uint8_t xflash_rd_status_reg(void); -#if 0 -extern void w25x20cl_wr_status_reg(uint8_t val); -#endif extern void xflash_rd_data(uint32_t addr, uint8_t* data, uint16_t cnt); extern void xflash_sector_erase(uint32_t addr);