backlight.cpp 763 B

123456789101112131415161718192021222324252627282930313233
  1. //backlight.cpp
  2. #include "backlight.h"
  3. #include <avr/eeprom.h>
  4. #include <Arduino.h>
  5. #include "eeprom.h"
  6. #include "Marlin.h"
  7. #include "pins.h"
  8. #include "fastio.h"
  9. // #include "Timer.h"
  10. // #include "Configuration.h"
  11. int16_t backlightLevel = 0;
  12. int16_t backlightLevel_old = 0;
  13. // uint16_t backlightCounter = 0;
  14. void backlight_update()
  15. {
  16. if (backlightLevel != backlightLevel_old) //update level
  17. {
  18. analogWrite(LCD_BL_PIN, backlightLevel);
  19. backlightLevel_old = backlightLevel;
  20. eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL, backlightLevel);
  21. }
  22. }
  23. void backlight_init()
  24. {
  25. SET_OUTPUT(LCD_BL_PIN);
  26. WRITE(LCD_BL_PIN,0);
  27. backlightLevel = eeprom_read_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL);
  28. backlight_update();
  29. }