main.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _MAIN_H_
  2. #define _MAIN_H_
  3. // Calculate the byte offset of a field in a structure of type type.
  4. #define FIELD_OFFSET(type, field) ((uint32_t)(uint32_t*)&(((type *)0)->field))
  5. // Calculate the size of a field in a structure of type type
  6. #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  7. // Calculate the size from field1 to field2 (inclusive)
  8. #define FIELD_SIZE_THROUGH(type, field1, field2) \
  9. (FIELD_OFFSET(type, field2) + FIELD_SIZE(type, field2) - FIELD_OFFSET(type, field1))
  10. #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
  11. #define NUM_TUBES 4
  12. #define MAX_FADE_DIGITS 2
  13. #define I2C_MAX_BUFFER 20
  14. #define REFRESH_RATE_US 1000
  15. #define DOT_MIN PCA9685_Min_Brightness
  16. #define DOT_MAX PCA9685_Max_Brightness
  17. #define DOT_FADE_DURATION_US 900000
  18. #define DOT_FADE_TICK (DOT_FADE_DURATION_US / REFRESH_RATE_US)
  19. #define DOT_FADE_STEP ((DOT_MAX + DOT_FADE_TICK - 1) / DOT_FADE_TICK)
  20. #define DIGIT_MIN PCA9685_Min_Brightness
  21. #define DIGIT_MAX PCA9685_Max_Brightness
  22. #define DIGIT_FADE_DURATION_US 1000000
  23. // #define DIGIT_FADE_TICK (DOT_FADE_DURATION_US / REFRESH_RATE_US)
  24. // #define DIGIT_FADE_STEP ((DOT_MAX + DIGIT_FADE_TICK - 1) / DIGIT_FADE_TICK)
  25. #define DIGIT_RNG_REFRESH_RATE_S 30
  26. #define DIGIT_RNG_REFRESH_ITER 20
  27. void I2C_Write(int DeviceAddress, char RegAddress, char *Data, int Length);
  28. void I2C_Read(int DeviceAddress, char RegAddress, char *Data, int Length);
  29. #endif