The FunHouse library was built upon the existing Portal-style libraries, taking a lot from the MagTag library due to the similar processor, the ESP32-S2. Like most of the other Portal libraries, it was designed with a layered approach to allow maximum use of code with minimum maintenance. This was achieved by splitting the library up into a base library and the main library which piggyback's on top of the base library. The base library was named PortalBase which is split up into 3 components. The main base, the GraphicsBase, and the NetworkBase. In the diagram, you can see these components represented in blue.

Here is the way it is logically laid out with dependencies. The FunHouse library is comprised of the top layer, the Peripherals, Network, and Graphics layers in the diagram.

There are three main branches of dependencies related to Network Functionality, Graphics functionality, and Peripherals. The FunHouse library ties them both together and allows easier coding, but at the cost of more memory usage and less control. We'll go through each of the classes starting from the bottom and working our way up the diagram starting with the Network branch.

Network Branch

The network branch contains all of the functionality related to connecting to the internet and retrieving data. You will want to use this branch if your project need to retrieve any data that is not stored on the device itself.

WiFi Module

The WiFi module is now part of PortalBase and is responsible for initializing the hardware libraries and controlling the status DotStar colors. The main purpose of this library is to abstract away from the specific WiFi implementation so that PortalBase can be used both with boards with an external WiFi controller and boards with a built-in controller. This layer really was never intended to be used directly, but you would want to use this library if you only wanted to handle the automatic initialization of hardware and connection to WiFi and didn't need any other functionality.

Network Module

The network module has many convenience functions for making network calls. It handles a lot of things from automatically establishing the connection to getting the time from the internet, to getting data at certain URLs. This is one of the largest of the modules as there is a lot of functionality packed into this. This is built on top of NetworkBase and initializes the WiFi module and anything else specific to the FunHouse board.

Graphics Branch

This branch is a lot lighter than the Network Branch because so much of the functionality is built into CircuitPython and displayio.

Graphics Module

Most of the functionality is part of GraphicsBase. This module contains some convenience functions such as setting the background to a color or image and displaying a QR code.

Peripherals Branch

This branch is kind of a catch-all of specific board hardware. For the FunHouse library, this includes the onboard DotStar LEDs, buttons, Capacitive Touchpads, Slider, PIR Sensor, Environmental Sensors and audio. This library automatically initializes the hardware to make it easier to use it in your scripts.

This library also initializes the Temperature, Humidity, and Pressure sensors. To do this, I2C is also automatically initialized and to use I2C with other sensors, you can access it through the i2c object in peripherals branch.

FunHouse Module

The FunHouse module is top level module and will handle initializing everything below it. Using this module is very similar to using the MagTag library. The main differences are the peripherals library is different and the display is doesn't need to be refreshed. 

Another new feature is the MQTT functionality. This may eventually be moved to PortalBase if it is popular and it doesn't cause the PortalBase library to become too large.

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

This page (FunHouse Library Overview) was last updated on May 08, 2021.

Text editor powered by tinymce.