upload
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <avr/io.h>
  2. #include "backlight.h"
  3. uint8_t led_counter = 0;
  4. uint8_t led_level = 0;
  5. void bl_set()
  6. {
  7. led_counter++;
  8. if (led_counter > 7) {
  9. led_counter = 0;
  10. }
  11. if (led_counter < led_level) {
  12. // output high
  13. DDRB |= (1<<2);
  14. PORTB |= (1<<2);
  15. } else {
  16. // Hi-Z
  17. DDRB &= ~(1<<2);
  18. PORTB &= ~(1<<2);
  19. }
  20. }
  21. void backlight_init_ports()
  22. {
  23. DDRB &= ~(1<<2);
  24. PORTB &= ~(1<<2);
  25. backlight_init();
  26. }
  27. void backlight_set(uint8_t level)
  28. {
  29. led_level = level;
  30. }