u8g2_config_displays.pl 1022 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/perl -w
  2. my (@i2c_displays, @spi_displays);
  3. # scan provided header file for CONFIG_U8G2_I2C and CONFIG_U8G2_SPI entries
  4. while (<STDIN>) {
  5. if (/^\s*#\s*define\s+CONFIG_U8G2_I2C_([^_]+)_(\S+)\s+1/) {
  6. push(@i2c_displays, lc($1)."_i2c_".lc($2));
  7. }
  8. if (/^\s*#\s*define\s+CONFIG_U8G2_SPI_(\S+)\s+1/) {
  9. push(@spi_displays, lc($1));
  10. }
  11. }
  12. if (@i2c_displays > 0 || @spi_displays > 0) {
  13. print << 'HEADER';
  14. #ifndef _U8G2_DISPLAYS_H
  15. #define _U8G2_DISPLAYS_H
  16. #define U8G2_DISPLAY_TABLE_ENTRY(function, binding)
  17. HEADER
  18. print("#define U8G2_DISPLAY_TABLE_I2C \\\n");
  19. foreach my $display (@i2c_displays) {
  20. print(" U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_${display}_f, $display) \\\n");
  21. }
  22. print("\n");
  23. print("#define U8G2_DISPLAY_TABLE_SPI \\\n");
  24. foreach my $display (@spi_displays) {
  25. print(" U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_${display}_f, $display) \\\n");
  26. }
  27. print("\n");
  28. print << 'FOOTER';
  29. #endif /* _U8G2_DISPLAYS_H */
  30. FOOTER
  31. }