upload
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

backlight.c 529B

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. }