Skip to content

Commit

Permalink
Merge pull request #1 from karelv/main
Browse files Browse the repository at this point in the history
improve onboarding for other driver(sensor) contributors
  • Loading branch information
karelv authored Nov 18, 2023
2 parents 83c6b82 + f945a9a commit 4067044
Show file tree
Hide file tree
Showing 64 changed files with 7,511 additions and 4,239 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]


# on:
# # Runs on pushes targeting the default branch
# push:
# branches: ["main"]

# # Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:


jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pip-tools twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
cd i2c-stick-py
python -m build
twine upload dist/*
33 changes: 19 additions & 14 deletions .github/workflows/site-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
tags:
- "V[0-9]+.[0-9]+.[0-9]+"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
contents: write
pages: write
id-token: write

Expand All @@ -28,20 +30,23 @@ jobs:
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Install pandoc
run: sudo apt-get install -y pandoc
- name: Install cssnano
run: sudo npm install cssnano-cli --global
- name: Install terser
run: sudo npm install terser --global
- name: Install python dependencies
run: sudo pip install -r web-interface/requirements.txt
- name: Install arduino-cli
- name: Install python requirements for web-interface
run: pip install -r web-interface/requirements.txt
- name: Install python requirements for i2c-stick-arduino
run: pip install -r i2c-stick-arduino/requirements.txt
- name: Build all distribution
run: doit dist
- name: Kitchen
run: |
mkdir -p ~/.local/bin
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh
- name: Build distribution
run: make
cp -vrf dist i2c-stick-${{ github.ref_name }}
zip -r i2c-stick-${{ github.ref_name }}.zip i2c-stick-${{ github.ref_name }}
- name: Publish to release tag
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
readme.md
i2c-stick-${{ github.ref_name }}.zip
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ web-interface/*.html
!web-interface/assets/**/*.min.js
!web-interface/assets/**/*.min.css
web-interface/melexis-bulma.css
.idea
venv
.doit.db*
__pycache__
81 changes: 65 additions & 16 deletions doc/03_serial_interface_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Check communication with MCU and return "Melexis Inspired Engineering".

Send: `mlx` + `LF`

Receive:
- `mlx:MELEXIS I2C STICK` + `LF`
- `mlx:=================` + `LF`
- `mlx:` + `LF`
- `mlx:Melexis Inspired Engineering` + `LF`
- `mlx:` + `LF`
- `mlx:hit '?' for help` + `LF`
Receive:
- `mlx:MELEXIS I2C STICK` + `LF`
- `mlx:=================` + `LF`
- `mlx:` + `LF`
- `mlx:Melexis Inspired Engineering` + `LF`
- `mlx:` + `LF`
- `mlx:hit '?' for help` + `LF`

### `fv` - Firmware Version Command

Expand Down Expand Up @@ -82,7 +82,7 @@ Send: READ: `i2c:` + `sa` + `:R:` + `<#bytes to read>:<STATUS>` + `LF`

Receive example: `i2c:3A:R:FF:OK` + `LF`

Meaning:
Meaning:
Send: read from slave address 3A(hex, 7 bit), 1 byte.
Receive: First byte is FF hex.

Expand Down Expand Up @@ -120,6 +120,55 @@ Meaning: read at register address 3004h from slave address 3A(hex, 7 bit), 2 byt

The first byte is 0x5A, the 2nd is 0x69.

### `ch` - get Configure Host command

Get the configuration of the host:
- the format of the communication
- the I2C frequency
- which drivers there are provided by the firmware
- The slave address assosiations with the drivers

Send: `ch` + `LF`

Receive: `ch:<configuration>=<value>[(<description>)]` + `LF`

Receive example:
```
ch:FORMAT=0(DEC)
ch:I2C_FREQ=0(100kHz)
ch:SA_DRV=5A,01,MLX90614
ch:SA_DRV=3E,01,MLX90614
ch:SA_DRV=33,02,MLX90640
ch:SA_DRV=33,03,MLX90641
ch:SA_DRV=3A,04,MLX90632
ch:DRV=01,MLX90614
ch:DRV=02,MLX90640
ch:DRV=03,MLX90641
ch:DRV=04,MLX90632
```

### `+ch` - set Configure Host command

Set the configuration of the host:
- the format of the communication
- the I2C frequency
- which drivers there are provided by the firmware
- The slave address assosiations with the drivers

Send: `+ch:<configuration>=<value>|<description>` + `LF`

Receive: `+ch:<status> [<where the configuration is stored>]` + `LF`

Send example:
```
+ch:FORMAT=DEC
```

Receive example:
```
+ch:OK [host-register]
```

### `scan` - Scan I2C bus command

Scan the I2C bus and look at which slave address returns an
Expand Down Expand Up @@ -299,10 +348,10 @@ Meaning: The sensor at slave address 3A has new data.
Read the memory content of the selected sensor.

Format: `mr::<address>` + `LF`
or
Format: `mr:` + `sa` + `:<address>` + `LF`
or
Format: `mr:` + `sa` + `:<address>,<address_count>` + `LF`
or
Format: `mr:` + `sa` + `:<address>` + `LF`
or
Format: `mr:` + `sa` + `:<address>,<address_count>` + `LF`

Note: `<address>` and `<address_count>` are in hex format with 4 characters (always)

Expand All @@ -318,10 +367,10 @@ receive: `mr:3A:2400,10,01,0003,DATA,EF4A,3480` + `LF`
Write the memory content of the selected sensor.

Format: `mw::<address>,<data>` + `LF`
or
Format: `mr:` + `sa` + `:<address>,<data>` + `LF`
or
Format: `mr:` + `sa` + `:<address>,<data>,<data+1>,..` + `LF`
or
Format: `mr:` + `sa` + `:<address>,<data>` + `LF`
or
Format: `mr:` + `sa` + `:<address>,<data>,<data+1>,..` + `LF`

Note: `<address>` and `<data>` are in hex format with 4 characters (always)

Expand Down
96 changes: 96 additions & 0 deletions dodo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import sys
import subprocess
from glob import glob

DOIT_CONFIG = {'action_string_formatting': 'both',
'default_tasks': ['dist', 'cleaner'],
}
PIP_USER = " --user "
if sys.prefix != sys.base_prefix: # check if we are in a virtual environment
PIP_USER = ""

try:
import doit
except (Exception,) as e:
print("Installing the doit python package.")
t = subprocess.check_output('pip install {} doit'.format(PIP_USER), text=True, shell=True, stderr=subprocess.STDOUT)
print(t)
print("\n\nPlease run this script again")
print("Note: instead of 'python dodo.py', now you can use 'doit'")
print("Note: use 'doit list' for a list of commands.")
exit(0)

import shutil
import os

THIS_DIR = os.path.dirname(os.path.abspath(__file__))


def remove(path):
""" param <path> could either be relative or absolute. """
for p in glob(path):
if os.path.isfile(p) or os.path.islink(p):
os.remove(p) # remove the file
elif os.path.isdir(p):
shutil.rmtree(p) # remove dir and all contains
else:
raise ValueError("path {} is not a file or dir.".format(p))


def show_cmd(task):
msg = task.name
if task.verbosity >= 2:
for action in task.actions:
msg += "\n - " + str(action)
return msg


def task_cleaner():
""" Clean the entire repository for a git commit & be ready to re-compile the entire project!"""

def do_clean():
patterns = ["dist",
]
for pattern in patterns:
try:
print(f"cleaner: {pattern}")
remove(pattern)
except Exception as err:
print(str(err))

return {
"actions": None,
"clean": [(do_clean, ),
"cd i2c-stick-arduino && doit clean",
"cd web-interface && doit clean",
],
'title': show_cmd,
}


def task_pip():
"""Install required python packages using pip"""
for rqt_file in ['web-interface/requirements.txt', 'i2c-stick-arduino/requirements.txt']:
yield {
'name': rqt_file,
'actions': ["pip install {} -r {}".format(PIP_USER, rqt_file)],
'file_dep': [rqt_file],
'title': show_cmd,
}


def task_dist():
return {
'actions': ["cd i2c-stick-arduino && doit dist",
"cd web-interface && doit dist",
],
'verbosity': 2,
'title': show_cmd,
'uptodate': [False],
}


if __name__ == '__main__':
import doit

doit.run(globals())
9 changes: 8 additions & 1 deletion i2c-stick-arduino/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
*.bak
*.bak
.doit.db*
__pycache__
package
driver_cmd.h
driver_cmd.cpp
firmware_list.md
tools
23 changes: 0 additions & 23 deletions i2c-stick-arduino/Makefile

This file was deleted.

Loading

0 comments on commit 4067044

Please sign in to comment.