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

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