main.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _MAIN_H_
  2. #define _MAIN_H_
  3. // #define REVISION_A
  4. #define REVISION_B
  5. // Calculate the byte offset of a field in a structure of type type.
  6. #define FIELD_OFFSET(type, field) ((uint32_t)(uint32_t*)&(((type *)0)->field))
  7. // Calculate the size of a field in a structure of type type
  8. #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  9. // Calculate the size from field1 to field2 (inclusive)
  10. #define FIELD_SIZE_THROUGH(type, field1, field2) \
  11. (FIELD_OFFSET(type, field2) + FIELD_SIZE(type, field2) - FIELD_OFFSET(type, field1))
  12. #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
  13. #define I2C_MAX_BUFFER 20
  14. #define NUM_TUBES 4
  15. #define NUM_DIGITS 10
  16. #define REFRESH_RATE_US 1000
  17. #define DOT_MIN 256
  18. #define DOT_MAX 640
  19. #define DOT_FADE_DURATION_US 1000000
  20. #define DIGIT_MIN PCA9685_Min_Brightness
  21. #define DIGIT_MAX PCA9685_Max_Brightness
  22. #define DIGIT_FADE_DURATION_US 1000000
  23. #define DIGIT_RNG_FADE_DURATION_US 200000
  24. #define DIGIT_RNG_FADE_ITERATIONS 20
  25. #define DIGIT_RNG_REFRESH_INTERVAL 60
  26. #define DIGIT_RNG_REFRESH_VARIANCE 30
  27. #define REFRESH_SEQUENTIAL
  28. // #define REFRESH_RANDOM
  29. void I2C_Write(int DeviceAddress, char RegAddress, char *Data, int Length);
  30. void I2C_Read(int DeviceAddress, char RegAddress, char *Data, int Length);
  31. #endif