/pycon_pybadge_2020

Initial code for Microsoft's PyBadge at PyCon 2020

Primary LanguagePythonMIT LicenseMIT

Microsoft PyBadge at PyCon 2020

Adafruit PyBadges will be given away at the Microsoft booth at PyCon 2020 to attendees who stop by and complete hands-on labs.

This repository contains the initial code loaded on the badges.

To learn more about the badge and Microsoft at PyCon, please visit https://aka.ms/pycon2020.

💜 Written by Nina Zakharenko (@nnja) with support from Luciana Abud (@luabud).

For more CircuitPython projects, stay in touch:

In Action

Getting Started

This code is meant to run on an Adafruit PyBadge LC, a compact dev board featuring an ATSAMD51 processor, a color TFT screen with dimmable backlight, a wide assortment of buttons, and one NeoPixel LED.

It's written in CircuitPython, a variant of Python that can be used to program microcontrollers (Originally forked from MicroPython).

To program the board, plug it into your computer with a micro USB cable that supports data transfer. If you got your PyBadge from the Microsoft booth, use the USB cable from the kit. Once you plug your board in, it should show up at a CIRCUITPY drive.

To change the behavior of the board, modify the code in code.py. Once it's saved, the latest code will run on the device automatically.

The Badge

Turn on the badge by sliding the switch at the top of the board to the "on" position.

Assembly & Charging

If you got your kit from the Microsoft booth, plug in the battery, then attach the battery with the included piece of double sided tape.

Is your badge not working, even though the battery is plugged in? It may need a charge!

To charge the battery, make sure the battery is plugged in, then plug in a micro USB cable. If everything is plugged in correctly, a yellow charge light on the back of the board will turn on.

Navigation

To get started from the main screen, press the "start" button on the upper right corner of the badge.

This will take you to the main menu.

Main Menu

From the main menu, you can choose from the following options.

Press "a" to select, and "b" to go back.

Name Badge

Show your name, so everyone knows what to call you!

Name

Update the NAME constant at the top of the file with your own name.

Colors

Pass in the list of colors to the NAME_BADGE_COLORS constant at the top of the file. Colors can be hex values like 0xFF00FF or a tuple of RGB values, like (255, 0, 255).

Check util.py for color options.

Press the "left" and "right" buttons to switch between background colors.

LED

To turn the LED on, press the "up" button. To turn the LED off, press the "down" button. To make the LED off by default, change the value of led_on to False in the NameBadge class.

The brightness of the LED can be changed with the LED_BRIGHTNESS constant. The brightness value can be adjusted from 0.0 which is completely off, to 1.0 which is very bright.

Social Battery Status

Ever feel overwhelmed by large social gatherings and conferences? Now you can wear your social status on your badge!

The social statuses were originally created for this project.

To switch your social status between Full, Low, and Empty, press the "left" and "right' buttons.

To turn the LED on, press the "up" button. To turn the LED off, press the "down" button. To make the LED off by default, change the value of led_on to False in the SocialBattery class.

Learn More

By default, this will show a QR code that leads to https://aka.ms/pycon2020, where you can learn more about Microsoft and this project.

To change the QR code to your own site, change the URL constant at the top of the file.

Main Screen

Return to the main menu.

Menu Items

Adding Menu Items

To add menu items, create a new class that inherits from DefaultMenuItemState. Then, pass in your new class when instantiating the MainMenu, and add it to the state_manager by adding it to the list of states passed into the call to state_manager.add().

Changing Menu Labels

To change the label of a menu item, update the label property on its class.

Easter Egg

There's a surprise easter egg hidden in the code. Can you find it? 🥚📎✨

CircuitPython and Libraries

CircuitPython

This code targets CircuitPython version 5.0.0-beta.5. If you notice bugs or other issues with continued development, follow these instructions to upgrade your board to the latest version.

Libraries

This code depends on the PyBadger library. Version 2.0.0 is included in the lib folder.

You may want to upgrade to the latest version. To upgrade your libraries, download the latest version for CircuitPython 5. Then, replace all the libraries in the lib folder from this bundle.

You may also want to read the documentation, or view the source on GitHub.

Editing the Code

I used VS Code (an awesome IDE with Python support) using the Witch Hazel theme for the development of this code. Follow these instructions for connecting to the serial port in the VS Code terminal to view printed output for Mac/Linux, and Windows.

For programming hardware without an IDE Mu is a very simple text editor targeted for beginners.

Contributions

This repository is meant to contain a snapshot of the code loaded on the badges at PyCon 2020. Minor fixes and version upgrades will be pushed, but new features will likely not be accepted.

If you made awesome modifications or added new features, please open an issue with a summary, a screenshot, and a link to your repository. Selected screenshots may be listed in a gallery in the future.

License & Attributions

The code is published by Nina Zakharenko, and available under the MIT License.

Attributions

Background images are provided for customizing your badge in images/backgrounds.

Images:

Fonts used: