Categories
CircuitPython Microcontroller Software Development

PyPortal Event Countdown Clock Mods III

Some big updates to the software for the modified PyPortal Event Countdown Clock. The UI was changed and several features added. It also seems to be more stable as it does not lock-up randomly. Let’s get into the changes.

  • Header and Footer status bars display information
    • Header
      • Temperature
        • Touch to change between Fahrenheit and Celsius
      • Time
        • Touch to change between 24 hour and 12 hour formats
      • Network Strength
    • Footer
      • Brightness
        • Touching the left side of the footer, dims the display backlight
        • Touching the right side of the footer, increases the brightness of the display backlight
        • Touching the middle of the footer, returns to auto brightness of the display backlight
      • Event of the number of events
  • Change the event displayed by touching the left of the display to show previous event or the right side to advance to the next event.
  • If an event has passed more than a day ago, they will be removed from the list of events and no longer displayed
  • The events do not need to be in order in the JSON file. They are sorted when they are loaded from the SD Card with the soonest event being displayed first.
Demo of the PyPortal Event Countdown Clock Mods

Noticed that the temperature was several degrees too high. This was due to the ADT7410 being too close to devices generating heat. I removed the ADT7410 and placed it on a small board and added a PH2 JST connector so it may be plugged into the I2C socket. This resulted in much more usable temperature reading.

PyPortal Event Countdown with temperature sensor moved off the PyPortal
ADT7410 Temperature Sensor moved to a separate board.

Adafruit PyPortal Titano

I just purchased an Adafruit PyPortal Titano, Product ID: 4444, to test out the software and see about allowing the software to be used on different sized screens. The Titano, has a 480×320 screen verses 320×240 of the PyPortal, Product ID: 4116.

The PyPortal Titano that I received had CircuitPython 5 installed, so the first order of business was to install CircuitPython 8. I started by going to the PyPortal CircuitPython Guide on Learn.Adafruit.

  1. Download the latest version of CircuitPython for the PyPortal Titano board by going to https://circuitpython.org/board/pyportal_titano/
  2. Download the UF2 file for CircuitPython 8.0.5
  3. Double click the reset button on the back of the Titano board and make certain the RGB LED turns green. If is is not green, try again.
  4. Copy the file to the PORTALBOOT drive that shows on your PC
    NOTE: Do not be concerned that the preinstalled demo no longer works. The library files are different for different versions.
  5. Download the CircuitPython 8 library files from https://circuitpython.org/libraries
    NOTE: This step is optional as the required libraries are in the GitHub project files
  6. Go to GitHub and download the project files from https://github.com/richteel/PyPortal_Events
  7. Delete the files on the PyPortal Titano
  8. Unzip the files and copy the files in the PyPortal folder to the PyPortal Titano
  9. The PyPortal Titano will restart and the images will change between “Connecting to the Internet” and “Failed to Connect”. The images will not take up the full screen due to the difference in resolution. (Until the code is modified.) The reason it is not connecting is we need add files to an SD Card and put that into the PyPortal Titano.
  10. Copy the files in the SD_Card folder, from GitHub, and paste them into the root of a micro SD Card.
  11. While the SD Card is still in you PC, double click on the index.html file to open the configuration utility.
  12. You may choose to load the config.json file on the card or start creating a new file from scratch by adding new events.
  13. Once you are satisfied with the events, click on the “Secrets” tab and enter your Wi-Fi settings, Timezone, and Adafruit IO Account information.
  14. Once done, click the “Save JSON File” button and save it to the SD Card as config.json.
  15. Remove the card from the PC and insert it into the PyPortal Titano.
  16. Click the reset button on the back of the PyPortal Titano.
  17. If everything was done correctly, you can anticipate that the events will be displayed on the screen
PyPortal Event Countdown running on the PyPortal Titano
The application is in the upper left corner of the screen with space to the right and bottom.

You may notice from the image of the PyPortal Titano screen, the temperature is not displayed as the PyPortal Titano does not have the ADT7410 Temperature Sensor.

The next step will be to see how to detect the screen size or make it a setting in the config.json file.

Categories
CircuitPython Software Development Web Application Development

PyPortal Event Countdown Clock Mods II

I have implemented some of the items on my to do list from last week’s post and tested out a few more ideas. I have also published version 0.1 to GitHub.

I want to provide a few details on version 0.1 of the code and what is being worked for version 1.0. The two releases are very different with 1.0 being the one that I recommend you use once it is available.

Version 0.1 does automatically change the backlight brightness but it is not too dramatic therefore not very useful in my opinion. I’m disappointed by the way that turned out but plan to address it in version 1.0 with automatic and manual setting of the backlight.

Version 0.1 also freezes randomly, however I think it is a memory issue. I plan to address this by calling the CircuitPython garbage collection and/or implementing a watchdog timer. Not certain at the moment, which direction I will take but suspect that I will implement both.

Version 0.1 will also load all events, even those in the past so it is not very useful. Version 1.0 will address this by not loading past events.

The next version, 1.0, will have a different screen layout. As stated above, I wanted a way to manually control the backlighting so I have added icons at the bottom of the screen with touch target areas for increasing, decreasing, and automatic setting of the screen backlight. In order to add this as an option, I have created a 20 pixel high footer on the screen for the icons and to display brightness information. I may also display when the time is being updated as the touch interface is non-responsive during an update as it is a blocking call.

A 20 pixel header will also be included to display the time, the current event of the number of events, and a network strength indicator. The header and footer take away 40 pixels from the screen height but I think it will be worth it.

Hopefully I will finish this new version shortly and will have it available on GitHub. As you may have guessed, I will be on vacation/holiday for two weeks in about two weeks so there will not be any posts while I am away, unless it is about the vacation and I have stable enough internet to make some posts.

Categories
Desktop Application Development Raspberry Pi Software Development

Soft Latching Power Switch Revisited

This week, I have some updates revolving around the Soft Latching Power Switch, that I last wrote about eight years ago. I finally returned to the project and now have it working as I intended. I also have made some changes to the Dual Volt Amp Meter‘s Desktop software. I believe I may now have a stable usable version. Lastly, I’ve gotten started with Flux.ai and plan on using it to replace my old version of Eagle.

Soft Latching Power Switch

Soft Latching Switch on the bench
Soft Latching Switch on the bench connected to a Raspberry Pi Zero

I resolved a few items that I encountered previously when I attempted to use the Soft Latching Power Switch designed by Mosaic Industries to control an Adafruit 1000C. I was able to reliably control the PowerBoost 1000C using the Soft Latching circuit, one I removed R13 from the PowerBoost and placed a 200K ohm resistor between the enable and ground. R13 pulls up the enable pin to Vs so that the PowerBoost is always on, unless the enable pin is connected to ground. In my case, I wanted the opposite behavior. I wanted the PowerBoost to always be off unless the enable pin is connected to Vs.

The Soft Latching Power Switch designed by Mosaic Industries is intended to switch the 5V going into the Raspberry Pi but I wanted to use it differently by having it control turn off, or disable, the PowerBoost 1000C boost circuit. Below is a diagram showing the circuit used in this design.

Complete Circuit Diagram
Complete Circuit Diagram with the Soft Latching Circuit, Powerboost 1000C, and Raspberry Pi

The Soft Latching Power Switch is connected so that the input voltage is the Vs output of the Adafruit 1000C. The Vs output is USB voltage if USB Power is applied. If USB Power is not applied, Vs is the battery voltage. The output of the Soft Latching Power Switch output is connected to the enable pin of the Adafruit 1000C. The final connection of the Soft Latching Power Switch is the control pin, which is connected to GPIO22 (pin 15) of the Raspberry Pi.

The Adfruit PowerBoost 1000C is modified by removing the 200K ohm pull-up resistor, R13. An external 200K ohm resistor is connected between the enable pin and ground. A capacitor, around 0.01uF is placed in parallel with the resistor to prevent the PowerBoost from turning on the first time power is applied from either USB or battery. The value of the capacitor used is not critical. The first capacitor I grabbed was 0.01uF and it worked. The purpose of the capacitor is to make it look like a short from the enable pin to ground when power is first applied. If you find that it still starts from the on state rather than off state, you may need to use a higher value capacitor to provide more time for the capacitor to charge up and appear as a short to ground.

Once the circuit is put together and connected, you will need to load some scripts on the Raspberry Pi to allow the switch to shutdown the Raspberry Pi when the switch is pressed and for the Raspberry Pi to turn off the power when it shuts down. The scripts are available in the Pi-Power-Button project on GitHub.

This setup provides the following functionality:

  • Button press to turn on
  • Button press to signal to the device to shutdown
  • Long button press to force power off
  • Turn off power when the Raspberry Pi shuts down

Next Steps

  • Clean up the code now that it is working as expected
  • Possibly have one script file to handle shutdown and listening for button press
  • Design another circuit to allow similar functionality from a keyboard similar to the functionality on the HP 95lx and Psion 5 PDAs

Dual Volt Amp Meter

Made some changes on the desktop application for the Dual Volt Amp Meter project that I wrote about a few weeks ago.

I was having some issues with the software after it was running for a few hours. I would get random errors related to an index being out of bounds and could not figure out how that was possible when I am in a for loop that has the lower bound being zero and the upper bound being one less than the count of items in the list. I neglected to connect the dots that I was manipulating the list in another thread to limit the number of items in the list. The error would crop up if the timing was just right that the check on the array bounds occurred on the main thread, then the code then removed the item on the other thread. The next line in my main thread then referenced the item that was just removed, then the application would crash.

I believe I have now resolved all of those issues, so the code should be stable now. It has been running for a couple of hours so far without any issues.

Below is a capture from the application showing the button on the Soft Latching Power Switch being pressed and turning on the PowerBoost 1000C and in turn, the Raspberry Pi.

Graph from from the Dual Voltage Amp Meter
Graph from from the Dual Voltage Amp Meter showing the Soft Latching Power Switch being turned on.

Flux.ai

I discovered Flux.ai by watching a hackster.io video, where Alex Glow interviewed the Flux.ai team. I have since started working with Flux.ai and intend to create the Soft Latching Power Switch publicly in Flux.ai so others may use in their designs.

I really like what the Flux.ai has put together but it feels like there is much work to do to make it a product that may be used by the community. I plan to work more with Flux.ai and provide feedback to the team on design changes that may help users come up to speed quickly.

The only Schematic and PCB Layout tool that I have used successfully was Eagle. Once Eagle was acquired by Autodesk and moved to online subscription based licensing, I stopped updating Eagle. I’m still using Eagle 7.7.0 and would like to move on to something else. I have looked at KiCad and have it installed but have not made the commitment to start using it. Part of the reason is I have several components that I built in Eagle. I would need to start over in KiCad.

Another reason I have not moved to KiCad but am willing to move to Flux.ai, has to do with the parts libraries when sharing a project. I have received or pulled KiCad designs and have had to reach out to the authors to get some missing libraries. (The same is an issue with sharing Eagle designs.) Flux.ai solves this problem as libraries are online and may be shared with the community.

In addition to public parts, Flux.ai has the ability to create pull completed circuits with PCB layouts in other designs. This is great as one may design a power supply or other circuit and pull it in and reuse it in multiple projects. I have attempted something similar in Eagle but there are always issues with it and it seems you are always reinventing the wheel. Flux.ai eliminates redundant work and speeds up the design process.

Another advantage of Flux.ai is they have brought change management into the tool. You may see all the revisions made to a part or circuit, stay on an older version, or update to the latest change. This allows someone to update their public design to fix an issue and someone else who has used the design, may pull the latest fix into their design. It also allows someone to fork someone else’s design, improve upon it, then submit a pull request so the original designer can pull the change and everyone may benefit.

As you can tell, I’m very hopeful that Flux.ai will succeed and the Open Source community will embrace what Flux.ai is attempting to do with their hardware design platform. Give it a try. I hope to see the community help Flux.ai grow.

You may see what I’m up to on the platform by going to https://www.flux.ai/richteel. So far, I’ve put together one part for the IRF7319. I did so by forking another user’s part for the IRF7317.

Categories
Software Development Web Application Development

Physical File Folder Tabs – HTML Solution to Print Folder Tabs

Today, I needed to print some physical folder tabs. I wanted to challenge myself a bit to see if it were possible to build an HTML application that could do the job. Ideally, I wanted to load an Excel file and use the contents of a worksheet to create the labels. I was able to find some example code that uses some AJAX libraries from CloudFlare to parse the Excel file. With that and a few other bits of code samples, I was able to build a robust local page for creating physical folder tabs that may be printed and cut to help keep my filing tidy.

The code is available on GitHub at https://github.com/richteel/FileFolderTabs.