Skip to content

Commit 8e735f7

Browse files
Silicon Labs CircuitPython Applications v1.0.0
1 parent dd7dc3c commit 8e735f7

File tree

139 files changed

+3050
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+3050
-2
lines changed

README.md

+69-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
1-
# circuitpython_applications
2-
Application examples for CircuitPython
1+
<table border="0">
2+
<tr>
3+
<td align="left" valign="middle">
4+
<h1>EFR32 CircuitPython Application Examples</h1>
5+
</td>
6+
<td align="left" valign="middle">
7+
<a href="https://www.silabs.com/wireless/bluetooth">
8+
<img src="http://pages.silabs.com/rs/634-SLU-379/images/WGX-transparent.png" title="Silicon Labs Wireless Gecko MCUs" alt="EFM32 32-bit Microcontrollers" width="250"/>
9+
</a>
10+
</td>
11+
</tr>
12+
</table>
13+
14+
# Silicon Labs CircuitPython Applications #
15+
16+
[![Version Badge](https://img.shields.io/badge/-v1.0.0-green)](https://github.com/SiliconLabs/circuitpython_applications/releases)
17+
[![CircuitPython](https://img.shields.io/badge/CircuitPython-v8.2.0+-green)](https://circuitpython.org/downloads?q=silabs)
18+
![License badge](https://img.shields.io/badge/License-Zlib-green)
19+
20+
This repository contains example projects that demonstrate various applications using CircuitPython on Silicon Labs Development Kits.
21+
All examples in this repository are considered to be EXPERIMENTAL QUALITY, which implies that the code provided in the repository has not been formally tested and is provided as-is. It is not suitable for production environments.
22+
23+
## Examples ##
24+
25+
| No | Example name | Link to example |
26+
|:--:|:-------------|:---------------:|
27+
| 1 | CircuitPython - Bluetooth - Distance Monitor (VL53L1X) | [Click Here](./cp_bluetooth_distance_monitor)|
28+
| 2 | CircuitPython - Bluetooth - Environmental Sensing (CCS811/BME280) | [Click Here](./cp_bluetooth_environmental_sensing) |
29+
| 3 | CircuitPython - Non-Wireless Display Demo (IS31FL3741) | [Click Here](./cp_non_wireless_display_demo) |
30+
| 4 | CircuitPython - RGB Display Drawing (ILI9341) | [Click Here](./cp_rgb_display_drawing_ili9341) |
31+
| 5 | CircuitPython - Temperature and Humidity Monitor with LED Matrix Display (SI2071/IS31FL3741) | [Click Here](./cp_temperature_and_humidty_monitor) |
32+
| 6 | CircuitPython - xG24 Dev Kit Sensors (ILI9341) | [Click Here](./cp_xg24_dev_kit_sensors) |
33+
34+
35+
## Get CircuitPython firmware ##
36+
37+
Official binaries for all Silicon Labs supported boards are available through
38+
[circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs). The site includes stable, unstable and
39+
continuous builds. Full release notes are available through
40+
[GitHub releases](https://github.com/adafruit/circuitpython/releases) as well.
41+
42+
43+
> **_NOTE:_** The examples in this repository require CircuitPython v8.2.0 or higher.
44+
45+
46+
## Project structure
47+
48+
* **bin**
49+
* The bin folder contains binary files required by the project. (e.g.: fonts, pictures)
50+
* **lib**
51+
* The lib folder contains precompiled libraries provided by Adafruit, this folder provides the application logic related files too. These libraries and files are required to run the project.
52+
* **src**
53+
* The src folder provides the code.py named file, this file is the entry point of the example project.
54+
55+
The files from the src and bin folders should be copied into the root of the target board's file system.
56+
57+
Libraries and other application modules should be copied from the lib folder into the lib named folder on the target board.
58+
59+
## Documentation ##
60+
61+
Getting started with [CircuitPython on EFR32 boards](doc/running_circuitpython.md).
62+
63+
For more information, visit the [Developer documentation](https://docs.silabs.com/application-examples/latest/) portal of Silicon Laboratories.
64+
65+
## Reporting Bugs/Issues and Posting Questions and Comments ##
66+
67+
To report bugs in the Application Examples projects, please create a new "Issue" in the "Issues" section of this repo. Please reference the board, project, and source files associated with the bug, and reference line numbers. If you are proposing a fix, also include information on the proposed fix. Since these examples are provided as-is, there is no guarantee that these examples will be updated to fix these issues.
68+
69+
Questions and comments related to these examples should be made by creating a new "Issue" in the "Issues" section of this repo.
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# CircuitPython - Bluetooth - Distance Monitor (VL53L1X) #
2+
3+
## Overview ##
4+
5+
This project shows a demonstration of a Bluetooth Low Energy distance monitor system using SparkFun Thing Plus Matter - MGM240P development kit and the integrated CircuitPython BLE Stack.
6+
7+
The block diagram of this application is shown in the image below:
8+
9+
![overview](docs/overview.png)
10+
11+
## Hardware Required ##
12+
13+
- [SparkFun Thing Plus Matter - MGM240P](https://www.sparkfun.com/products/20270)
14+
15+
- [SparkFun Distance Sensor Breakout - 4 Meter, VL53L1X (Qwiic)](https://www.sparkfun.com/products/14722)
16+
17+
- [OLED Display - SSD1306](https://www.sparkfun.com/products/14532)
18+
19+
## Connections Required ##
20+
21+
The sensor and OLED display can easily connected with Sparkfun Thing Plus for Matter - MGM240 development kits via Qwiic connector.
22+
23+
## Setup ##
24+
25+
To run the example you need to install **Thonny** editor and then follow the steps below:
26+
27+
To run the example you need to install **Thonny** editor and then follow the steps below:
28+
29+
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org](https://circuitpython.org/) to download the binary.
30+
31+
2. Install the necessary libraries from Adafruit CircuitPython bundle. You can download the bundle from [here](https://circuitpython.org/libraries). The libraries that used in this project and their version are list in this table below.
32+
33+
| Library | Version |
34+
|:----------------- |:------------------|
35+
| adafruit_framebuf | 1.6.1 |
36+
| adafruit_ssd1306 | 2.12.2 |
37+
| adafruit_vl53l1x | 1.1.10 |
38+
39+
3. Upload all the libraries of the lib folder to the CircuitPython device. The binary files should not be uploaded to lib folder in the device, they should have the same hierarchy as the code.py file.
40+
41+
4. Copy the content of the code.py and paste it to the code.py file on the CircuitPython device.
42+
43+
5. Run the scripts on the board.
44+
45+
46+
## How it Works ##
47+
48+
- ### Initialization ###
49+
50+
![Initialization](docs/init.png).
51+
52+
- ### Runtime operation ###
53+
54+
![Runtime operation](docs/run_time.png).
55+
56+
- ### GATT database ###
57+
58+
- [Service] Distance Monitor
59+
- [Char] Lower Threshold Value - threshold_value_lower
60+
- [R] Get lower threshold value (mm)
61+
- [W] Set lower threshold value (mm)
62+
- [Char] Upper Threshold Value - threshold_value_upper
63+
- [R] Get upper threshold value (mm)
64+
- [W] Set upper threshold value (mm)
65+
- [Char] Threshold Mode - threshold_mode
66+
- [R] Get threshold mode (0-2)
67+
- [W] Set threshold mode (0-2)
68+
- [Char] Range Mode - range_mode
69+
- [R] Get configured range mode (0-1)
70+
- [W] Set range mode (0-1)
71+
- [Char] Notification Status - notification_status
72+
- [R] Get configured notification status (0-2)
73+
- [W] Set notification status (0-2)
74+
75+
## Output ##
76+
77+
Run the **code.py** file, monitor the OLED, and try to place your hand beyond the sensor you will see the result below.
78+
79+
![result](docs/result.GIF)
Binary file not shown.
1.25 KB
Binary file not shown.
Binary file not shown.
22.1 KB
Loading
Loading
49 MB
Loading
23.3 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"""
2+
*****************************************************************************
3+
Copyright 2023 Silicon Laboratories Inc. www.silabs.com
4+
*****************************************************************************
5+
SPDX-License-Identifier: Zlib
6+
7+
The licensor of this software is Silicon Laboratories Inc.
8+
9+
This software is provided \'as-is\', without any express or implied
10+
warranty. In no event will the authors be held liable for any damages
11+
arising from the use of this software.
12+
13+
Permission is granted to anyone to use this software for any purpose,
14+
including commercial applications, and to alter it and redistribute it
15+
freely, subject to the following restrictions:
16+
17+
1. The origin of this software must not be misrepresented; you must not
18+
claim that you wrote the original software. If you use this software
19+
in a product, an acknowledgment in the product documentation would be
20+
appreciated but is not required.
21+
2. Altered source versions must be plainly marked as such, and must not be
22+
misrepresented as being the original software.
23+
3. This notice may not be removed or altered from any source distribution.
24+
25+
*****************************************************************************
26+
# EXPERIMENTAL QUALITY
27+
This code has not been formally tested and is provided as-is. It is not
28+
suitable for production environments. In addition, this code will not be
29+
maintained and there may be no bug maintenance planned for these resources.
30+
Silicon Labs may update projects from time to time.
31+
******************************************************************************
32+
"""
33+
34+
35+
class Configuration:
36+
def __init__(
37+
self,
38+
lower_threshold,
39+
upper_threshold,
40+
threshold_mode,
41+
range_mode,
42+
notification_status,
43+
) -> None:
44+
self.lower_threshold = lower_threshold
45+
self.upper_threshold = upper_threshold
46+
self.threshold_mode = threshold_mode
47+
self.range_mode = range_mode
48+
self.notification_status = notification_status
49+
50+
@staticmethod
51+
def check_change(a, b):
52+
return b if a != b else None
53+
54+
def changes(self, __value: object):
55+
changes = {
56+
"lower_threshold": self.check_change(
57+
self.lower_threshold, __value.lower_threshold
58+
),
59+
"upper_threshold": self.check_change(
60+
self.upper_threshold, __value.upper_threshold
61+
),
62+
"threshold_mode": self.check_change(
63+
self.threshold_mode, __value.threshold_mode
64+
),
65+
"range_mode": self.check_change(self.range_mode, __value.range_mode),
66+
"notification_status": self.check_change(
67+
self.notification_status, __value.notification_status
68+
),
69+
}
70+
return {k: v for k, v in changes.items() if v is not None}
71+
72+
def update(self, key: str, value) -> None:
73+
setattr(self, key, value)
74+
75+
def __eq__(self, __value: object) -> bool:
76+
return not bool(self.changes(__value))

0 commit comments

Comments
 (0)