My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

filwidth.cpp 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../inc/MarlinConfig.h"
  23. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  24. #include "filwidth.h"
  25. FilamentWidthSensor filwidth;
  26. bool FilamentWidthSensor::enabled; // = false; // (M405-M406) Filament Width Sensor ON/OFF.
  27. uint32_t FilamentWidthSensor::accum; // = 0 // ADC accumulator
  28. uint16_t FilamentWidthSensor::raw; // = 0 // Measured filament diameter - one extruder only
  29. float FilamentWidthSensor::nominal_mm = DEFAULT_NOMINAL_FILAMENT_DIA, // (M104) Nominal filament width
  30. FilamentWidthSensor::measured_mm = DEFAULT_MEASURED_FILAMENT_DIA, // Measured filament diameter
  31. FilamentWidthSensor::e_count = 0,
  32. FilamentWidthSensor::delay_dist = 0;
  33. uint8_t FilamentWidthSensor::meas_delay_cm = MEASUREMENT_DELAY_CM; // Distance delay setting
  34. int8_t FilamentWidthSensor::ratios[MAX_MEASUREMENT_DELAY + 1], // Ring buffer to delay measurement. (Extruder factor minus 100)
  35. FilamentWidthSensor::index_r, // Indexes into ring buffer
  36. FilamentWidthSensor::index_w;
  37. void FilamentWidthSensor::init() {
  38. const int8_t ratio = sample_to_size_ratio();
  39. LOOP_L_N(i, COUNT(ratios)) ratios[i] = ratio;
  40. index_r = index_w = 0;
  41. }
  42. #endif // FILAMENT_WIDTH_SENSOR