Skip to content

Commit a25603e

Browse files
committed
init commit, its working!
0 parents  commit a25603e

11 files changed

+419
-0
lines changed

.github/workflows/main.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Particle Compile Action Workflow
2+
# This workflow uses the Particle compile-action to compile Particle application firmware.
3+
# Make sure to set the particle-platform-name for your project.
4+
# For complete documentation, please refer to https://github.com/particle-iot/compile-action
5+
6+
name: Particle Compile
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
13+
jobs:
14+
compile:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
21+
# Particle Compile Action
22+
- name: Compile Firmware
23+
id: compile
24+
uses: particle-iot/compile-action@v1
25+
with:
26+
# Set the particle-platform-name to the platform you're targeting.
27+
# Allowed values: core, photon, p1, electron, argon, boron, xenon, esomx, bsom, b5som, tracker, trackerm, p2, msom
28+
particle-platform-name: 'p2'
29+
30+
# Optional: Upload compiled firmware as an artifact on GitHub.
31+
- name: Upload Firmware as Artifact
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: firmware-artifact
35+
path: |
36+
${{ steps.compile.outputs.firmware-path }}
37+
${{ steps.compile.outputs.target-path }}

.gitignore

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Key files
2+
*.der
3+
*.pem
4+
5+
# Ignore build results and bundles
6+
*.bin
7+
*.zip
8+
[Dd]ebug/
9+
[Dd]ebugPublic/
10+
[Rr]elease/
11+
[Rr]eleases/
12+
[Bb]in/
13+
[Oo]bj/
14+
[Ll]og/
15+
[Ll]ogs/
16+
target/*
17+
18+
# Platform-specific settings
19+
.DS_Store
20+
*.crc_block
21+
*.no_crc
22+
23+
# VisualStudioCode
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
*.code-workspace
30+
31+
# Ignore all local history of files
32+
**/.history
33+
34+
# Windows
35+
Thumbs.db
36+
*.stackdump
37+
[Dd]esktop.ini
38+
39+
# C Prerequisites
40+
*.d
41+
42+
# C Object files
43+
*.o
44+
*.ko
45+
*.obj
46+
*.elf
47+
48+
# C Linker output
49+
*.map
50+
51+
# C Debug files
52+
*.dSYM/
53+
*.su
54+
*.idb
55+
*.pdb

.vscode/launch.json

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "cortex-debug",
6+
"request": "attach",
7+
"servertype": "openocd",
8+
"name": "Particle Debugger",
9+
"cwd": "${workspaceRoot}",
10+
"rtos": "FreeRTOS",
11+
"armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
12+
"executable": "${command:particle.getDebuggerExecutable}",
13+
"serverpath": "${command:particle.getDebuggerOpenocdPath}",
14+
"preLaunchTask": "Particle: Flash application for debug (local)",
15+
"searchDir": [
16+
"${command:particle.getDebuggerSearchDir}"
17+
],
18+
"configFiles": [
19+
"${command:particle.getDebuggerConfigFiles}"
20+
],
21+
"postAttachCommands": [
22+
"${command:particle.getDebuggerPostAttachCommands}"
23+
],
24+
"particle": {
25+
"version": "1.0.1",
26+
"debugger": "particle-debugger"
27+
}
28+
},
29+
{
30+
"type": "cortex-debug",
31+
"request": "attach",
32+
"servertype": "openocd",
33+
"name": "Particle Programmer Shield",
34+
"cwd": "${workspaceRoot}",
35+
"rtos": "FreeRTOS",
36+
"armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
37+
"executable": "${command:particle.getDebuggerExecutable}",
38+
"serverpath": "${command:particle.getDebuggerOpenocdPath}",
39+
"preLaunchTask": "Particle: Flash application for debug (local)",
40+
"searchDir": [
41+
"${command:particle.getDebuggerSearchDir}"
42+
],
43+
"configFiles": [
44+
"${command:particle.getDebuggerConfigFiles}"
45+
],
46+
"postAttachCommands": [
47+
"${command:particle.getDebuggerPostAttachCommands}"
48+
],
49+
"particle": {
50+
"version": "1.0.1",
51+
"debugger": "particle-programmer-shield"
52+
}
53+
},
54+
{
55+
"type": "cortex-debug",
56+
"request": "attach",
57+
"servertype": "openocd",
58+
"name": "Generic DAPLink Compatible Debugger",
59+
"cwd": "${workspaceRoot}",
60+
"rtos": "FreeRTOS",
61+
"armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
62+
"executable": "${command:particle.getDebuggerExecutable}",
63+
"serverpath": "${command:particle.getDebuggerOpenocdPath}",
64+
"preLaunchTask": "Particle: Flash application for debug (local)",
65+
"searchDir": [
66+
"${command:particle.getDebuggerSearchDir}"
67+
],
68+
"configFiles": [
69+
"${command:particle.getDebuggerConfigFiles}"
70+
],
71+
"postAttachCommands": [
72+
"${command:particle.getDebuggerPostAttachCommands}"
73+
],
74+
"particle": {
75+
"version": "1.0.1",
76+
"debugger": "generic-cmsis-dap"
77+
}
78+
}
79+
]
80+
}

.vscode/settings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extensions.ignoreRecommendations": true,
3+
"C_Cpp.default.configurationProvider": "particle.particle-vscode-core",
4+
"files.associations": {
5+
"*.ino": "cpp"
6+
},
7+
"particle.targetDevice": "smokey_tester_2",
8+
"particle.firmwareVersion": "4.2.0",
9+
"particle.targetPlatform": "boron"
10+
}

.vscode/tasks.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: clang build active file",
6+
"command": "/usr/bin/clang",
7+
"args": [
8+
"-fcolor-diagnostics",
9+
"-fansi-escape-codes",
10+
"-g",
11+
"${file}",
12+
"-o",
13+
"${fileDirname}/${fileBasenameNoExtension}"
14+
],
15+
"options": {
16+
"cwd": "${fileDirname}"
17+
},
18+
"problemMatcher": [
19+
"$gcc"
20+
],
21+
"group": {
22+
"kind": "build",
23+
"isDefault": true
24+
},
25+
"detail": "Task generated by Debugger."
26+
}
27+
],
28+
"version": "2.0.0"
29+
}

README.md

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# helga-node
2+
3+
This firmware project was created using [Particle Developer Tools](https://www.particle.io/developer-tools/) and is compatible with all [Particle Devices](https://www.particle.io/devices/).
4+
5+
Feel free to replace this README.md file with your own content, or keep it for reference.
6+
7+
## Table of Contents
8+
- [Introduction](#introduction)
9+
- [Prerequisites To Use This Template](#prerequisites-to-use-this-repository)
10+
- [Getting Started](#getting-started)
11+
- [Particle Firmware At A Glance](#particle-firmware-at-a-glance)
12+
- [Logging](#logging)
13+
- [Setup and Loop](#setup-and-loop)
14+
- [Delays and Timing](#delays-and-timing)
15+
- [Testing and Debugging](#testing-and-debugging)
16+
- [GitHub Actions (CI/CD)](#github-actions-cicd)
17+
- [OTA](#ota)
18+
- [Support and Feedback](#support-and-feedback)
19+
- [Version](#version)
20+
21+
## Introduction
22+
23+
For an in-depth understanding of this project template, please refer to our [documentation](https://docs.particle.io/firmware/best-practices/firmware-template/).
24+
25+
## Prerequisites To Use This Repository
26+
27+
To use this software/firmware on a device, you'll need:
28+
29+
- A [Particle Device](https://www.particle.io/devices/).
30+
- Windows/Mac/Linux for building the software and flashing it to a device.
31+
- [Particle Development Tools](https://docs.particle.io/getting-started/developer-tools/developer-tools/) installed and set up on your computer.
32+
- Optionally, a nice cup of tea (and perhaps a biscuit).
33+
34+
## Getting Started
35+
36+
1. While not essential, we recommend running the [device setup process](https://setup.particle.io/) on your Particle device first. This ensures your device's firmware is up-to-date and you have a solid baseline to start from.
37+
38+
2. If you haven't already, open this project in Visual Studio Code (File -> Open Folder). Then [compile and flash](https://docs.particle.io/getting-started/developer-tools/workbench/#cloud-build-and-flash) your device. Ensure your device's USB port is connected to your computer.
39+
40+
3. Verify the device's operation by monitoring its logging output:
41+
- In Visual Studio Code with the Particle Plugin, open the [command palette](https://docs.particle.io/getting-started/developer-tools/workbench/#particle-commands) and choose "Particle: Serial Monitor".
42+
- Or, using the Particle CLI, execute:
43+
```
44+
particle serial monitor --follow
45+
```
46+
47+
4. Uncomment the code at the bottom of the cpp file in your src directory to publish to the Particle Cloud! Login to console.particle.io to view your devices events in real time.
48+
49+
5. Customize this project! For firmware details, see [Particle firmware](https://docs.particle.io/reference/device-os/api/introduction/getting-started/). For information on the project's directory structure, visit [this link](https://docs.particle.io/firmware/best-practices/firmware-template/#project-overview).
50+
51+
## Particle Firmware At A Glance
52+
53+
### Logging
54+
55+
The firmware includes a [logging library](https://docs.particle.io/reference/device-os/api/logging/logger-class/). You can display messages at different levels and filter them:
56+
57+
```
58+
Log.trace("This is trace message");
59+
Log.info("This is info message");
60+
Log.warn("This is warn message");
61+
Log.error("This is error message");
62+
```
63+
64+
### Setup and Loop
65+
66+
Particle projects originate from the Wiring/Processing framework, which is based on C++. Typically, one-time setup functions are placed in `setup()`, and the main application runs from the `loop()` function.
67+
68+
For advanced scenarios, explore our [threading support](https://docs.particle.io/firmware/software-design/threading-explainer/).
69+
70+
### Delays and Timing
71+
72+
By default, the setup() and loop() functions are blocking whilst they run, meaning that if you put in a delay, your entire application will wait for that delay to finish before anything else can run.
73+
74+
For techniques that allow you to run multiple tasks in parallel without creating threads, checkout the code example [here](https://docs.particle.io/firmware/best-practices/firmware-template/).
75+
76+
(Note: Although using `delay()` isn't recommended for best practices, it's acceptable for testing.)
77+
78+
### Testing and Debugging
79+
80+
For firmware testing and debugging guidance, check [this documentation](https://docs.particle.io/troubleshooting/guides/build-tools-troubleshooting/debugging-firmware-builds/).
81+
82+
### GitHub Actions (CI/CD)
83+
84+
This project provides a YAML file for GitHub, automating firmware compilation whenever changes are pushed. More details on [Particle GitHub Actions](https://docs.particle.io/firmware/best-practices/github-actions/) are available.
85+
86+
### OTA
87+
88+
To learn how to utilize Particle's OTA service for device updates, consult [this documentation](https://docs.particle.io/getting-started/cloud/ota-updates/).
89+
90+
Test OTA with the 'Particle: Cloud Flash' command in Visual Studio Code or the CLI command 'particle flash'!
91+
92+
This firmware supports binary assets in OTA packages, allowing the inclusion of audio, images, configurations, and external microcontroller firmware. More details are [here](https://docs.particle.io/reference/device-os/api/asset-ota/asset-ota/).
93+
94+
## Support and Feedback
95+
96+
For support or feedback on this template or any Particle products, please join our [community](https://community.particle.io)!
97+
98+
## Version
99+
100+
Template version 1.0.2

project.properties

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name=helga-node
2+
#assetOtaDir=assets
3+

src/BatteryLevel.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "BatteryLevel.h"
2+
3+
FuelGauge fuel;
4+
5+
BatteryLevel::BatteryLevel()
6+
{
7+
// Initialization can be handled here if needed
8+
}
9+
10+
float BatteryLevel::getBatteryVoltage()
11+
{
12+
return fuel.getVCell(); // Returns the voltage of the LiPo cell
13+
}
14+
15+
float BatteryLevel::getBatteryCharge()
16+
{
17+
return fuel.getSoC(); // Returns the State of Charge of the LiPo battery as a percentage
18+
}

src/BatteryLevel.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef BATTERY_LEVEL_H
2+
#define BATTERY_LEVEL_H
3+
4+
#include "Particle.h"
5+
6+
class BatteryLevel
7+
{
8+
public:
9+
BatteryLevel();
10+
float getBatteryVoltage();
11+
float getBatteryCharge();
12+
};
13+
14+
#endif

src/build.mk

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
INCLUDE_DIRS += $(SOURCE_PATH)/$(USRSRC) # add user sources to include path
2+
# add C and CPP files - if USRSRC is not empty, then add a slash
3+
CPPSRC += $(call target_files,$(USRSRC_SLASH),*.cpp)
4+
CSRC += $(call target_files,$(USRSRC_SLASH),*.c)
5+
6+
# Remove certain libraries based on device OS version
7+
# ---------------------------------------------
8+
ifeq ($(shell test $(VERSION) -ge 5000; echo $$?),0)
9+
$(info $$MODULE_LIBSV2 is [${MODULE_LIBSV2}])
10+
MODULE_LIBSV2_FILTERED:=$(filter-out $(SOURCE_PATH)lib/memfault,$(MODULE_LIBSV2))
11+
MODULE_LIBSV2=$(MODULE_LIBSV2_FILTERED)
12+
$(info $$MODULE_LIBSV2 is [${MODULE_LIBSV2}])
13+
endif

0 commit comments

Comments
 (0)