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.

M355.cpp 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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 "../../gcode.h"
  23. #include "../../../inc/MarlinConfig.h"
  24. #if HAS_CASE_LIGHT
  25. #include "../../../feature/caselight.h"
  26. /**
  27. * M355: Turn case light on/off and set brightness
  28. *
  29. * P<byte> Set case light brightness (PWM pin required - ignored otherwise)
  30. *
  31. * S<bool> Set case light on/off
  32. *
  33. * When S turns on the light on a PWM pin then the current brightness level is used/restored
  34. *
  35. * M355 P200 S0 turns off the light & sets the brightness level
  36. * M355 S1 turns on the light with a brightness of 200 (assuming a PWM pin)
  37. */
  38. void GcodeSuite::M355() {
  39. uint8_t args = 0;
  40. if (parser.seenval('P')) {
  41. ++args, case_light_brightness = parser.value_byte();
  42. case_light_arg_flag = false;
  43. }
  44. if (parser.seenval('S')) {
  45. ++args, case_light_on = parser.value_bool();
  46. case_light_arg_flag = true;
  47. }
  48. if (args) update_case_light();
  49. // always report case light status
  50. SERIAL_ECHO_START();
  51. if (!case_light_on) {
  52. SERIAL_ECHOLNPGM("Case light: off");
  53. }
  54. else {
  55. if (!PWM_PIN(CASE_LIGHT_PIN)) SERIAL_ECHOLNPGM("Case light: on");
  56. else SERIAL_ECHOLNPAIR("Case light: ", case_light_brightness);
  57. }
  58. }
  59. #endif // HAS_CASE_LIGHT