-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from senseshift/develop
Release 0.7.0-rc.3
- Loading branch information
Showing
135 changed files
with
5,378 additions
and
6,266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,36 @@ | ||
Checks: 'bugprone-*,clang-analyzer-*,google-*,hicpp-*,misc-*,modernize-*,performance-*,portability-*,readability-*' | ||
--- | ||
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,-modernize-use-trailing-return-type' | ||
WarningsAsErrors: true | ||
HeaderFilterRegex: '' | ||
AnalyzeTemporaryDtors: false | ||
FormatStyle: google | ||
CheckOptions: | ||
- key: cert-dcl16-c.NewSuffixes | ||
value: 'L;LL;LU;LLU' | ||
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField | ||
value: '0' | ||
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors | ||
value: '1' | ||
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic | ||
value: '1' | ||
- key: google-readability-braces-around-statements.ShortStatementLines | ||
value: '1' | ||
- key: google-readability-function-size.StatementThreshold | ||
value: '800' | ||
- key: google-readability-namespace-comments.ShortNamespaceLines | ||
value: '10' | ||
- key: google-readability-namespace-comments.SpacesBeforeComments | ||
value: '2' | ||
- key: modernize-loop-convert.MaxCopySize | ||
value: '16' | ||
- key: modernize-loop-convert.MinConfidence | ||
value: reasonable | ||
- key: modernize-loop-convert.NamingStyle | ||
value: CamelCase | ||
- key: modernize-pass-by-value.IncludeStyle | ||
value: llvm | ||
- key: modernize-replace-auto-ptr.IncludeStyle | ||
value: llvm | ||
- key: modernize-use-nullptr.NullMacros | ||
value: 'NULL' | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// no real downside on these | ||
unusedFunction | ||
unusedPrivateFunction | ||
|
||
*:.pio/* | ||
*:*/libdeps/* | ||
*:*/generated/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: "Setup PlatformIO" | ||
description: "Setup PlatformIO for building and checking firmware" | ||
|
||
inputs: | ||
cache: | ||
required: false | ||
description: "Specify things to cache. Supported values are: 'pip', 'cache', 'packages', 'platforms', 'build_cache', 'build_dir'." | ||
default: 'pip cache' | ||
cache_dir: | ||
description: https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/directory/cache_dir.html | ||
required: false | ||
default: '~/.platformio/.cache' | ||
packages_dir: | ||
description: https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/directory/packages_dir.html | ||
required: false | ||
default: '~/.platformio/packages' | ||
platforms_dir: | ||
description: https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/directory/platforms_dir.html | ||
required: false | ||
default: '~/.platformio/platforms' | ||
build_cache_dir: | ||
description: https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/directory/build_cache_dir.html | ||
required: false | ||
build_dir: | ||
description: https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/directory/build_dir.html | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Prepare | ||
shell: bash | ||
run: | | ||
touch ./requirements.txt | ||
${{ inputs.cache_dir && format('echo "PLATFORMIO_CACHE_DIR={0}" >> $GITHUB_ENV', inputs.cache_dir) || '' }} | ||
${{ inputs.packages_dir && format('echo "PLATFORMIO_PACKAGES_DIR={0}" >> $GITHUB_ENV', inputs.packages_dir) || '' }} | ||
${{ inputs.platforms_dir && format('echo "PLATFORMIO_PLATFORMS_DIR={0}" >> $GITHUB_ENV', inputs.platforms_dir) || '' }} | ||
${{ inputs.build_cache_dir && format('echo "PLATFORMIO_BUILD_CACHE_DIR={0}" >> $GITHUB_ENV', inputs.build_cache_dir) || '' }} | ||
${{ inputs.build_dir && format('echo "PLATFORMIO_BUILD_DIR={0}" >> $GITHUB_ENV', inputs.build_dir) || '' }} | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
cache: ${{ contains(inputs.cache, 'pip') && 'pip' || '' }} | ||
|
||
- name: Cache PlatformIO | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
${{ contains(inputs.cache, 'cache') && inputs.cache_dir || '' }} | ||
${{ contains(inputs.cache, 'packages') && inputs.packages_dir || '' }} | ||
${{ contains(inputs.cache, 'platforms') && inputs.platforms_dir || '' }} | ||
${{ contains(inputs.cache, 'build_cache') && inputs.build_cache_dir || '' }} | ||
${{ contains(inputs.cache, 'build_dir') && inputs.build_dir || '' }} | ||
key: setup-platformio-${{ runner.os }}-pio-${{ hashFiles('**/*.ini') }} | ||
restore-keys: | | ||
setup-platformio-${{ runner.os }}-pio- | ||
- name: Install PlatformIO | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade platformio | ||
pio upgrade --dev | ||
pio pkg update --global |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import json | ||
import pandas as pd | ||
import argparse | ||
|
||
|
||
# Function to load JSON data from files | ||
def load_json(filename): | ||
with open(filename, 'r') as f: | ||
return json.load(f) | ||
|
||
|
||
# Function to compare values and create formatted strings | ||
def compare_values(base, current, key): | ||
if key not in base and key not in current: | ||
return None | ||
if key not in base: | ||
return f"🆕 {current[key]}" | ||
if key not in current: | ||
return f"❌" | ||
|
||
base_value = base[key] | ||
current_value = current[key] | ||
|
||
if base_value == current_value: | ||
return f"🆗 {base_value}" | ||
|
||
change = current_value - base_value | ||
sign = "+" if change > 0 else "-" | ||
symbol = "⚠️" if change > 0 else "⬇️" | ||
|
||
# round to 2 decimal places | ||
change = round(abs(change), 2) | ||
return f"{symbol} {current_value} <sub>{sign}{change}</sub>" | ||
|
||
|
||
# Function to generate Markdown table | ||
def generate_markdown_table(base_data, current_data): | ||
table_data = [] | ||
|
||
all_keys = set(base_data.keys()).union(set(current_data.keys())) | ||
all_keys = sorted(all_keys) | ||
|
||
for key in all_keys: | ||
base_ram = base_data.get(key, {}).get("ram", {}) | ||
current_ram = current_data.get(key, {}).get("ram", {}) | ||
|
||
base_flash = base_data.get(key, {}).get("flash", {}) | ||
current_flash = current_data.get(key, {}).get("flash", {}) | ||
|
||
row = [ | ||
key.replace("-usage", ""), | ||
compare_values(base_ram, current_ram, "percentage"), | ||
compare_values(base_ram, current_ram, "used"), | ||
compare_values(base_flash, current_flash, "percentage"), | ||
compare_values(base_flash, current_flash, "used") | ||
] | ||
table_data.append(row) | ||
|
||
df = pd.DataFrame(table_data, columns=["Variant", "RAM, %", "RAM, bytes", "Flash, %", "Flash, bytes"]) | ||
|
||
return df.to_markdown(index=False) | ||
|
||
|
||
# Main function to handle CLI arguments and execute the script | ||
def main(): | ||
parser = argparse.ArgumentParser(description='Compare JSON files and generate a markdown table.') | ||
parser.add_argument('base', type=str, help='Path to the base JSON file') | ||
parser.add_argument('current', type=str, help='Path to the current JSON file') | ||
parser.add_argument('--output', type=str, help='Path to the output markdown file') | ||
args = parser.parse_args() | ||
|
||
base_data = load_json(args.base) | ||
current_data = load_json(args.current) | ||
|
||
markdown_table = generate_markdown_table(base_data, current_data) | ||
|
||
if args.output: | ||
with open(args.output, 'w') as f: | ||
f.write(markdown_table) | ||
print(f"Markdown table generated and saved to {args.output}") | ||
else: | ||
print(markdown_table) | ||
|
||
|
||
# usage: python compare-memory-usage.py base.json current.json --output table.md | ||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import os | ||
import sys | ||
import re | ||
import argparse | ||
|
||
|
||
def github_debug(message): | ||
""" | ||
Print a debug message in GitHub Actions format. | ||
Args: | ||
message (str): The debug message. | ||
""" | ||
print(f"::debug::{message}") | ||
|
||
|
||
def strip_flags(flags): | ||
return [flag[2:] if flag.startswith('-D') and flag != '-D' else flag for flag in flags if flag != '-D'] | ||
|
||
|
||
def store_firmware_name(target): | ||
print(f"firmware={target}") | ||
if os.getenv('GITHUB_ACTIONS'): | ||
with open(os.getenv('GITHUB_OUTPUT'), 'a') as github_output: | ||
github_output.write(f"firmware={target}\n") | ||
else: | ||
print("::error::Not in GitHub Actions") | ||
|
||
|
||
def get_bhaptics_name(target, flags): | ||
""" | ||
Get bHaptics name based on target and flags. | ||
Args: | ||
target (str): The target name. | ||
flags (list): List of flags. | ||
""" | ||
github_debug(f"Getting bHaptics name for {target}") | ||
github_debug(f"Flags are {flags}") | ||
|
||
if "SS_USE_NIMBLE=true" in flags: | ||
github_debug("Nimble is enabled, appending +nimble to the target") | ||
target += "+nimble" | ||
|
||
if "SS_BATTERY_ENABLED=true" in flags: | ||
github_debug("Battery is enabled, appending +battery to the target") | ||
target += "+battery" | ||
|
||
store_firmware_name(target) | ||
|
||
|
||
def handle_calibration_flag(target, flag, prefix): | ||
""" | ||
Handle calibration flags. | ||
Args: | ||
target (str): The target name. | ||
flag (str): The flag name. | ||
prefix (str): The prefix for the calibration. | ||
""" | ||
if "MinMaxCalibrator" in flag: | ||
target += f"+{prefix}_minmax" | ||
elif "FixedCenterPointDeviationCalibrator" in flag: | ||
target += f"+{prefix}_fcpd" | ||
elif "CenterPointDeviationCalibrator" in flag: | ||
target += f"+{prefix}_cpd" | ||
|
||
return target | ||
|
||
|
||
def handle_opengloves_comm_flag(target, flag): | ||
""" | ||
Handle OpenGloves communication flags. | ||
Args: | ||
target (str): The target name. | ||
flag (str): The flag name. | ||
""" | ||
if "OPENGLOVES_COMM_SERIAL" in flag: | ||
github_debug("Serial is enabled, appending +serial to the target") | ||
target += "+serial" | ||
elif "OPENGLOVES_COMM_BTSERIAL" in flag: | ||
github_debug("Bluetooth Serial is enabled, appending +bluetooth to the target") | ||
target += "+bluetooth" | ||
elif "OPENGLOVES_COMM_BLESERIAL" in flag: | ||
github_debug("BLE Serial is enabled, appending +ble to the target") | ||
target += "+ble" | ||
|
||
return target | ||
|
||
|
||
def get_opengloves_name(target, flags): | ||
""" | ||
Get OpenGloves name based on target and flags. | ||
Args: | ||
target (str): The target name. | ||
flags (list): List of flags. | ||
""" | ||
github_debug(f"Getting OpenGloves name for {target}") | ||
github_debug(f"Flags are {flags}") | ||
|
||
for flag in flags: | ||
if "OPENGLOVES_COMMUNICATION" in flag: | ||
target = handle_opengloves_comm_flag(target, flag) | ||
if "CALIBRATION_CURL" in flag: | ||
target = handle_calibration_flag(target, flag, "curl_calib") | ||
if "CALIBRATION_SPLAY" in flag: | ||
target = handle_calibration_flag(target, flag, "splay_calib") | ||
|
||
store_firmware_name(target) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Get firmware name based on target and flags.') | ||
parser.add_argument('target', type=str, help='The target name') | ||
parser.add_argument('flags', type=str, help='List of flags', default='') | ||
args = parser.parse_args() | ||
|
||
target = args.target | ||
flags = strip_flags(args.flags.split(' ')) | ||
|
||
github_debug(f"Target is {target}") | ||
|
||
if re.match(r'^(bhaptics)', target): | ||
get_bhaptics_name(target, flags) | ||
elif re.match(r'^(opengloves|lucidgloves|indexer)', target): | ||
get_opengloves_name(target, flags) | ||
else: | ||
print(f"::error::Unknown target {target}") | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.