nodemcu-firmware/tools/u8g2_config_displays.pl

41 lines
926 B
Perl
Raw Normal View History

2017-05-26 21:39:29 +02:00
#!/usr/bin/perl -w
my (@i2c_displays, @spi_displays);
# scan provided header file for CONFIG_U8G2_I2C and CONFIG_U8G2_SPI entries
while (<STDIN>) {
if (/^\s*#\s*define\s+CONFIG_U8G2_I2C_([^_]+)_(\S+)\s+1/) {
push(@i2c_displays, lc($1)."_i2c_".lc($2));
}
if (/^\s*#\s*define\s+CONFIG_U8G2_SPI_(\S+)\s+1/) {
push(@spi_displays, lc($1));
}
}
2017-06-13 19:03:25 +02:00
print << 'HEADER';
2017-05-26 21:39:29 +02:00
#ifndef _U8G2_DISPLAYS_H
#define _U8G2_DISPLAYS_H
#define U8G2_DISPLAY_TABLE_ENTRY(function, binding)
HEADER
2017-06-13 19:03:25 +02:00
print("#define U8G2_DISPLAY_TABLE_I2C \\\n");
foreach my $display (@i2c_displays) {
print(" U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_${display}_f, $display) \\\n");
}
print("\n");
2017-05-26 21:39:29 +02:00
2017-06-13 19:03:25 +02:00
print("#define U8G2_DISPLAY_TABLE_SPI \\\n");
foreach my $display (@spi_displays) {
print(" U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_${display}_f, $display) \\\n");
}
print("\n");
2017-05-26 21:39:29 +02:00
2017-06-13 19:03:25 +02:00
print << 'FOOTER';
2017-05-26 21:39:29 +02:00
#endif /* _U8G2_DISPLAYS_H */
FOOTER