Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pr/ion098/8
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Jan 4, 2025
2 parents 40e0b19 + abad04b commit 7a4e919
Show file tree
Hide file tree
Showing 39 changed files with 1,051 additions and 807 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# automatically format code using clang-format when a pull request is merged or manually triggered
name: format-code

on:
pull_request:
types: [closed] # on merge pull request
workflow_dispatch: # allows manual triggering

permissions:
contents: write

jobs:
format:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Format code # Outputs the correctly formatted code
uses: DoozyX/[email protected]
with:
source: './src/hardware ./include/hardware'
extensions: 'hpp,cpp'
clangFormatVersion: 18
inplace: true # Same as `clang-format -i`

# Commits the correctly formatted files to the repository
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Action
author_email: [email protected]
message: Automated code formatting
push: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/depot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Populate Depot json

on:
# runs when this repository's releases are modified
release:
# allows for manual dispatching of the workflow
workflow_dispatch:

jobs:
populate:
runs-on: ubuntu-latest
permissions:
# permits reading of releases and writing to the depot branch
contents: write
steps:
# where to find gh action and what version to use
- uses: LemLib/[email protected]
with:
# gives the github action the permissions specified above
token: ${{ github.token }}
# target repo for depots
repo: LemLib/hardware
# where to read releases from (can be omitted if repo is also the repo from which to read releases from, but it doesn't sem to be working at the moment)
source-repo: LemLib/hardware
# makes the json output human readable
readable-json: true
90 changes: 90 additions & 0 deletions .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Add Template to Pull Request
on:
workflow_run:
workflows: ['PROS Build Template']
types: [completed]
jobs:
pr_comment:
# if Build Template was successful and ran on a branch that is currently the head in a pull request
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest

permissions:
pull-requests: write

steps:
- uses: actions/github-script@v6
with:
# This snippet is public-domain, taken from
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
script: |
async function upsertComment(owner, repo, issue_number, purpose,old_body, body) {
const {data: comments} = await github.rest.issues.listComments(
{owner, repo, issue_number});
const marker = `\r\n<!-- DO NOT REMOVE!! -->\r\n<!-- bot: ${purpose} -->\r\n`;
const old_marker = new RegExp(marker.replace("\r\n", "\r?\n")).exec(old_body)?.[0] ?? marker;
body = old_body.split(old_marker)[0] + marker + body;
await github.request('PATCH /repos/{owner}/{repo}/pulls/{pull_number}', {
owner: owner,
repo: repo,
pull_number: issue_number,
body: body,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
}
const {owner, repo} = context.repo;
const run_id = ${{github.event.workflow_run.id}};
const pull_head_sha = '${{github.event.workflow_run.head_sha}}';
/** @type {{old_body: string}} */
const {issue_number, old_body} = await (async () => {
const pulls = await github.rest.pulls.list({owner, repo});
for await (const {data} of github.paginate.iterator(pulls)) {
for (const pull of data) {
if (pull.head.sha === pull_head_sha) {
return {issue_number: pull.number, old_body: pull.body};
}
}
}
return {};
})();
if (issue_number) {
core.info(`Using pull request ${issue_number}`);
} else {
return core.error(`No matching pull request found`);
}
let old_sha = /\<\!-- commit-sha: (?<sha>[a-z0-9]+) --\>/i.exec(old_body)?.groups?.sha
if (old_sha != undefined && pull_head_sha == old_sha) return core.error("Comment is already up-to-date!")
const artifacts = await github.paginate(
github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id});
if (!artifacts.length) {
return core.error(`No artifacts found, perhaps Build Template was skipped`);
}
const template = artifacts[0];
let body = `<!-- commit-sha: ${pull_head_sha} -->\n`;
body +=`## Download the template for this pull request: \n\n`;
body += `> [!NOTE]
> This is auto generated from [\`${{ github.workflow }}\`](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\n`;
body += `- via manual download: [${template.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${template.id}.zip)\n`;
body += `- via PROS Integrated Terminal: \n \`\`\`
curl -o ${template.name}.zip https://nightly.link/${owner}/${repo}/actions/artifacts/${template.id}.zip;
pros c fetch ${template.name}.zip;
pros c apply ${template.name};
rm ${template.name}.zip;
\`\`\``;
core.info(`Review thread message body: \n${body}`);
await upsertComment(owner, repo, issue_number,
"nightly-link", old_body, body);
26 changes: 26 additions & 0 deletions .github/workflows/pros-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PROS Build Template

on:
push:
branches: "**"
pull_request:
branches: "**"

workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run LemLib/pros-build
id: test
uses: LemLib/[email protected]

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.test.outputs.name }}
path: ${{ github.workspace }}/template/*
20 changes: 20 additions & 0 deletions .github/workflows/test-clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: test-clang-format

on:
push:
branches:
- '*'
pull_request:


jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: DoozyX/[email protected]
with:
source: './src/hardware ./include/hardware'
extensions: 'hpp,cpp'
clangFormatVersion: 18
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ IS_LIBRARY:=1
# Be sure that your header files are in the include directory inside of a folder with the
# same name as what you set LIBNAME to below.
LIBNAME:=hardware
VERSION:=0.1.0
VERSION:=0.3.1
# EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c
# this line excludes opcontrol.c and similar files
EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/main,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext)))

# files that get distributed to every user (beyond your source archive) - add
# whatever files you want here. This line is configured to add all header files
# that are in the directory include/LIBNAME
TEMPLATE_FILES=$(INCDIR)/$(LIBNAME)/encoder/*.hpp $(INCDIR)/$(LIBNAME)/IMU/*.hpp $(INCDIR)/$(LIBNAME)/motors/*.hpp
TEMPLATE_FILES=$(INCDIR)/$(LIBNAME)/Encoder/*.hpp $(INCDIR)/$(LIBNAME)/IMU/*.hpp $(INCDIR)/$(LIBNAME)/Motor/*.hpp

.DEFAULT_GOAL=quick

Expand Down
76 changes: 52 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,67 @@ This PROS template aims to simplify interactions with devices, and implement a c

## Features

- [X] **[Unitized](https://github.com/LemLib/units)**
- [X] **Uncompromising error handling**
- [X] [Unitized](https://github.com/LemLib/units)
- [X] Advanced Error Handling
- [ ] Device disconnect/reconnect callbacks
- [ ] Compile-time Port Checks

- [X] **Motor Class**
- [X] Changing encoder units don't affect reported angle
- [X] Current limit
- [X] Differentiate 11W and 5.5W motors
- [X] -1.0 to +1.0 power levels, adjusts automatically to motor type
- [X] Type Safe enums
- [ ] Micro-disconnect detection
- [X] **Motor**
- [X] Changing encoder units don't affect reported angle
- [X] Current limit
- [X] Differentiate 11W and 5.5W motors
- [X] -1.0 to +1.0 power levels, adjusts automatically to motor type
- [X] Type Safe enums
- [ ] Micro-disconnect detection

- [ ] **Motor Groups**
- [X] Motor disconnects/reconnects don't affect measured angle
- [X] Removing motors doesn't affect the measured angle
- [X] Automatic per-motor gear ratio calculations
- [ ] Micro-disconnect detection
- [X] Motor disconnects/reconnects don't affect measured angle
- [X] Removing motors doesn't affect the measured angle
- [X] Automatic per-motor gear ratio calculations
- [ ] Micro-disconnect detection

- [ ] **Abstract Distance Sensor**
- [ ] Generic interface for any distance sensor
- [ ] Support for all VEX distance sensors
- [ ] V5 Distance Sensor
- [ ] V5 Optical Sensor
- [ ] ADI Ultrasonic Sensor

- [ ] **Abstract Color Sensor**
- [ ] Generic interface for any color sensor
- [ ] Support for all VEX color sensors
- [ ] V5 Optical Sensor

- [X] **Abstract Encoders**
- [X] Generic interface for any encoder
- [X] Support for all VEX encoders
- [X] All custom encoders
- [X] Motors / Motor Groups
- [X] V5 Rotation Sensor
- [X] Optical Shaft encoder
- [X] Generic interface for any encoder
- [X] Support for all VEX encoders
- [X] Motors / Motor Groups
- [X] V5 Rotation Sensor
- [X] Optical Shaft encoder
- [ ] ADI Potentiometer V1
- [ ] ADI Potentiometer V2

- [X] **Abstract Gyro**
- [X] Generic interface for any gyro
- [X] Support for VEX gyros, as well as any custom gyros for use in VEX AI or VEX U
- [X] All custom gyros
- [X] V5 Inertial Sensor
- [X] Generic interface for any gyro
- [X] Gyro Scaling
- [ ] Support for all VEX gyros
- [X] V5 Inertial Sensor
- [ ] V5 GPS Sensor
- [ ] ADI analog gyro

- [ ] **Abstract Accelerometer**
- [ ] Generic interface for any accelerometer
- [ ] Support for all VEX accelerometers
- [ ] V5 Inertial Sensor
- [ ] V5 GPS Sensor
- [ ] ADI Accelerometer

- [ ] **Abstract IMU**
- [ ] Generic interface for any IMU
- [ ] Support for all VEX IMUs
- [ ] V5 Inertial Sensor
- [ ] V5 GPS Sensor

## Who Should Use This?

Anyone who uses PROS. This API is simpler, safer, and more powerful than that of PROS. Library developers should use this in order to support custom sensors which may be used by VURC and VAIRC teams.
Anyone who uses PROS. This API is simpler, safer, and more powerful than that of PROS. Library developers should use this in order to support custom sensors which may be used by VURC and VAIRC teams.
Binary file modified firmware/libpros.a
Binary file not shown.
Binary file added firmware/units.a
Binary file not shown.
Loading

0 comments on commit 7a4e919

Please sign in to comment.