Like Bruce said, be careful when using successive High/Lows on adjacent pins. If they're not adjacent, maybe you could find some interesting of DT Virtual Port?

A Lookup table in codespace or EEPROM is probably the mosty efficient solution.