Choosing your layers is one of the more important parts of creating a project since it's easy to accidentally choose layers that end up duplicating some of the functions. This guide is intended to help clarify your understanding of the layout so you can make the best choices for your needs.

The FunHouse library, like the other Portal-based libraries is split up into layers. Layers allow you to use certain portions of the library to save on memory.

The PyPortal library, which is what inspired the other Portal-type libraries was originally written as a single layer. This had the advantage of making it really simple to write and use for specific types of projects. It has now been split into layers like the other Portal-style libraries.

We'll go over the layers that are specific to the FunHouse library.

Mixing and Matching Layers

Which of the layers you choose to use for your project depends on the amount of customization and memory management you would like in your project. The higher level up you go in the library layer hierarchy, the more automatic functions you will have available to you, but it also takes away your ability to customize things and uses more memory.

In general, at a minimum, you will likely want at least the Graphics layers and optionally either the Network or Peripheral layers. However, by using the top level layer, you will have access to everything.

Graphics Layers

You can use the graphics layer if you wanted to have some convenient graphics functions, such as easily drawing a background or displaying a QR code.

Network Layers

On the network functionality side of things, if you just wanted to initialize the network, you could use the WiFi layer, but if you wanted more of the network functions as well, you would use the network layer.

Peripherals Layer

To use the on-board peripheral functionality, such as if you just wanted to initialize the buttons, DotStars, Capacitive Touch Pads, Slider, and audio, then you could use the Peripherals layer.

Top Layer

If you wanted everything along with some great functionality that ties all the legs of the hierarchy together, then you would want the very top layer, which is the FunHouse layer. This layer was intended to be similar to the MagTag or MatrixPortal library's top layer, but with some notable differences, which we'll cover in this guide.

Remember that if you go with this layer, you should not need to also import any of the lower layers.

Importing your layers

Top Layer

To import the top level layer only, you would simply just import it like this:

from adafruit_funhouse import FunHouse

If you would like access to the Network and Graphics layers, they are available as objects named network and graphics. For instance, if you instantiated the top layer as funhouse, then you would access the Network layer with funhouse.network, the Graphics layer with funhouse.graphics, and the Peripherals layer with funhouse.peripherals.

funhouse = FunHouse()
network = funhouse.network
graphics = funhouse.graphics
peripherals = funhouse.peripherals

Sub-Layers

To only import sub-layers such as the Graphics, Network, and Peripherals layers, you would import it like this:

from adafruit_funhouse.graphics import Graphics
from adafruit_funhouse.network import Network
from adafruit_funhouse.peripherals import Peripherals

After they're imported, you would just instantiate each of the classes separately.

This guide was first published on Apr 26, 2021. It was last updated on 2021-05-01 13:46:09 -0400.

This page (Choosing Your Layers) was last updated on Dec 01, 2021.

Text editor powered by tinymce.