# Pi thinks unicorn hat is a phat

**URL:** <https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682>\
**Category:** Support\
**Created:** [July 17, 2016, 5:05pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682 "2016-07-17T17:05:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pi2003](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/pi2003/32/1613_2.png) [@pi2003](https://forums.pimoroni.com/u/pi2003)\
**Post date:** [July 17, 2016, 5:05pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/1 "2016-07-17T17:05:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RogueM](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/roguem/32/311_2.png) [@RogueM](https://forums.pimoroni.com/u/RogueM)\
**Post date:** [July 17, 2016, 6:24pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/2 "2016-07-17T18:24:10Z")

</div>

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

```
unicornhat.set_layout(unicornhat.HAT)

```

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

---

<div class="post-metadata">

**Author:** ![pi2003](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/pi2003/32/1613_2.png) [@pi2003](https://forums.pimoroni.com/u/pi2003)\
**Post date:** [July 17, 2016, 6:27pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/3 "2016-07-17T18:27:11Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![RogueM](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/roguem/32/311_2.png) [@RogueM](https://forums.pimoroni.com/u/RogueM)\
**Post date:** [July 17, 2016, 6:33pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/4 "2016-07-17T18:33:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pi2003](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/pi2003/32/1613_2.png) [@pi2003](https://forums.pimoroni.com/u/pi2003)\
**Post date:** [July 17, 2016, 6:34pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/5 "2016-07-17T18:34:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pi2003](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/pi2003/32/1613_2.png) [@pi2003](https://forums.pimoroni.com/u/pi2003)\
**Post date:** [July 17, 2016, 6:39pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/6 "2016-07-17T18:39:58Z")

</div>

works now

Thanks a lot

will

---

<div class="post-metadata">

**Author:** ![RogueM](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/roguem/32/311_2.png) [@RogueM](https://forums.pimoroni.com/u/RogueM)\
**Post date:** [July 17, 2016, 6:43pm UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/7 "2016-07-17T18:43:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [July 18, 2016, 10:32am UTC](https://forums.pimoroni.com/t/pi-thinks-unicorn-hat-is-a-phat/2682/8 "2016-07-18T10:32:57Z")

</div>

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! )
