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.

led_matrix.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright 2013,2014 Kai Ryu <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef LED_MATRIX_H
  15. #define LED_MATRIX_H
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #if (LED_MATRIX_COLS <= 8)
  19. typedef uint8_t led_matrix_row_t;
  20. #elif (LED_MATRIX_COLS <= 16)
  21. typedef uint16_t led_matrix_row_t;
  22. #elif (LED_MATRIX_COLS <= 32)
  23. typedef uint32_t led_matrix_row_t;
  24. #else
  25. #error "LED_MATRIX_COLS: invalid value"
  26. #endif
  27. typedef struct {
  28. union {
  29. int8_t delta;
  30. struct {
  31. bool direction:1;
  32. };
  33. };
  34. uint8_t value;
  35. } led_matrix_element_t;
  36. #ifdef LED_MATRIX_ENABLE
  37. void led_matrix_init(void);
  38. void led_matrix_enable(void);
  39. void led_matrix_disable(void);
  40. void led_matrix_init_cols(void);
  41. led_matrix_row_t led_matrix_make_cols(uint8_t row, uint8_t pwm);
  42. void led_matrix_set_value(uint8_t row, uint8_t col, uint8_t value);
  43. void led_matrix_set_delta(uint8_t row, uint8_t col, int8_t delta);
  44. extern void led_matrix_write_cols(led_matrix_row_t cols);
  45. extern void led_matrix_unselect_rows(void);
  46. extern void led_matrix_select_row(uint8_t row);
  47. #else
  48. #define led_matrix_init()
  49. #define led_matrix_enable()
  50. #define led_matrix_disable()
  51. #define led_matrix_init_cols()
  52. #define led_matrix_write_cols()
  53. #define led_matrix_unselect_rows()
  54. #define led_matrix_select_row()
  55. #endif
  56. #endif