Pi thinks unicorn hat is a phat

just updated my unicornhat libary and ran the new detect program and it says my height isn’t = to my width which it isn’t and now all the examples run as a phat format

Thanks for the heads up, we’ll look into it ASAP. Remember that you can override the detection and enforce the HAT layout with:


a bit of a pain I know, but may help in the interim.

the weird thing is however that when in shell I run the function that tells you the dimensions of the display it says (8,8)

I just had a look and the process uses device-tree detection to see if a HAT is present. This will only work if you booted the Pi with the HAT already fitted… I’m willing to bet it’s your problem.

great. That’s slightly annoying but will try that and be back.

works now

Thanks a lot


great, remember you can always enforce the layout in your code if you tend to swap HATs on the fly.

This is the result of the autodetect feature I merged in recently. Unfortunately like all other HAT-eeprom features it needs the HAT placed on the Pi before booting in order to work- as @RogueM mentions.

Defaulting to pHAT may be a little problematic, but in reality it’s the only way auto-detect can work since the pHAT has no EEPROM to explicitly detect. It’s a trade-off and a temporary discomfort for existing Unicorn HAT users, but it’s easy enough to simply specify whether you have the HAT or the pHAT in code. :D

Arguably your Pi should always be turned off before swapping out HATs, but we all know nobody pays attention to that rule ;) ( I sure don’t! )