diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7179d62..c2f460e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,18 +3,24 @@ # that can be found in the LICENSE file. # References: -# https://developer.github.com/webhooks/event-payloads/ -# https://github.com/actions/cache # https://github.com/actions/checkout # https://github.com/actions/setup-go # https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#using-the-github_token-in-a-workflow # https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions/ # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +# https://docs.github.com/en/rest/commits/comments#create-a-commit-comment +# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request +# https://docs.github.com/en/actions/learn-github-actions/contexts on: [push, pull_request] name: Run tests jobs: - test_all: + # Runs go test both with code coverage sent to codecov, race detector and + # benchmarks. At the end do a quick check to ensure the tests to not leave + # files in the tree. + test: + name: "test: go${{matrix.gover}}.x/${{matrix.os}}" + runs-on: "${{matrix.os}}" continue-on-error: true defaults: run: @@ -24,18 +30,89 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] # Do not forget to bump every 6 months! - gover: ["1.17"] - runs-on: "${{matrix.os}}" - name: "go${{matrix.gover}}.x on ${{matrix.os}}" + gover: ["1.19"] + env: + PYTHONDONTWRITEBYTECODE: x steps: + - name: Turn off git core.autocrlf + if: matrix.os == 'windows-latest' + run: git config --global core.autocrlf false + - uses: actions/checkout@v3 + with: + fetch-depth: 2 - uses: actions/setup-go@v3 with: go-version: "~${{matrix.gover}}.0" + cache: true + - name: 'go install necessary tools' + if: always() + run: | + go install github.com/maruel/pat/cmd/ba@latest + - name: 'Check: go test -cover' + if: always() + run: go test -timeout=120s -covermode=count -coverprofile coverage.txt -bench=. -benchtime=1x ./... + # Don't send code coverage if anything failed to reduce spam. + - uses: codecov/codecov-action@v2 + - name: 'Cleanup' + if: always() + run: rm coverage.txt + - name: 'Check: go test -race' + run: go test -timeout=120s -race -bench=. -benchtime=1x ./... + - name: 'Check: benchmark 📈' + run: ba -against HEAD~1 + - name: 'Check: go test -short (CGO_ENABLED=0)' + env: + CGO_ENABLED: 0 + run: go test -timeout=120s -short -bench=. -benchtime=1x ./... + - name: 'Check: go test -short (32 bits)' + if: matrix.os != 'macos-latest' + env: + GOARCH: 386 + run: go test -timeout=120s -short -bench=. -benchtime=1x ./... + - name: "Check: tree is clean" + if: always() + run: | + # Nothing should have changed in the tree up to that point and no + # unsuspected file was created. + TOUCHED=$(git status --porcelain --ignored) + if ! test -z "$TOUCHED"; then + echo "Oops, something touched these files, please cleanup:" + echo "$TOUCHED" + git diff + false + fi - # Checkout and print debugging information. + + # Run linters. This workflow can be merged with the test_all one if desired + # to cut on runtime, at the cost of latency. I dislike waiting for results + # so I prefer to run them in parallel. + lint: + name: "lint: go${{matrix.gover}}.x/${{matrix.os}}" + runs-on: "${{matrix.os}}" + continue-on-error: true + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + # You may want to run only on linux to save on cost. Projects with + # OS-specific code benefits from explicitly linting on macOS and + # Windows. + os: [ubuntu-latest, macos-latest, windows-latest] + # Do not forget to bump every 6 months! + gover: ["1.19"] + env: + PYTHONDONTWRITEBYTECODE: x + steps: - name: Turn off git core.autocrlf + if: matrix.os == 'windows-latest' run: git config --global core.autocrlf false - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: "~${{matrix.gover}}.0" + cache: true - name: "Debug" run: | echo HOME = $HOME @@ -44,31 +121,23 @@ jobs: echo "" echo $ ls -l $HOME/go/bin ls -la $HOME/go/bin - - - name: 'Cache: ~/go' - uses: actions/cache@v2 - with: - path: ~/go - key: "${{runner.os}}-gopkg-${{hashFiles('go.sum', '.github/workflows/*.yml')}}" - - # Fetch the tools before checking out, so they don't modify go.mod/go.sum. - name: 'go install necessary tools' + if: always() run: | - go install -v github.com/gordonklaus/ineffassign@latest - go install -v github.com/securego/gosec/cmd/gosec@latest - go install -v golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest - go install -v honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/gordonklaus/ineffassign@latest + go install github.com/securego/gosec/v2/cmd/gosec@latest + go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest + go install honnef.co/go/tools/cmd/staticcheck@latest - name: 'go install necessary tools (ubuntu)' if: always() && matrix.os == 'ubuntu-latest' run: | - go install -v github.com/client9/misspell/cmd/misspell@latest - go install -v github.com/google/addlicense@latest - - # Now run proper checks. + go install github.com/client9/misspell/cmd/misspell@latest + go install github.com/google/addlicense@latest - name: 'Check: go vet' if: always() - run: go vet ./... + run: go vet -unsafeptr=false ./... - name: 'Check: go vet shadow; shadowed variables' + if: always() run: | SHADOW_TOOL="$(which shadow)" if [ -f "${SHADOW_TOOL}.exe" ]; then @@ -80,19 +149,23 @@ jobs: run: ineffassign ./... - name: 'Check: staticcheck' if: always() + # SA1019: Foo is deprecated run: staticcheck -checks inherit,-SA1019 ./... - - name: 'Check: gosec (only G104)' - run: gosec -include=G104 -fmt=golint -quiet ./... - + - name: 'Check: gosec' + if: always() + run: gosec -fmt=golint -quiet ./... # The following checks are not dependent on the OS or go build tags. Only # run them on ubuntu-latest since it's the fastest one. - name: 'Check: no executable was committed (ubuntu)' if: always() && matrix.os == 'ubuntu-latest' run: | - if find . -path '*.sh' -prune -o -path ./.git -prune -o -type f -executable -print | grep -e . ; then - echo 'Do not commit executables beside shell scripts' + if find . -path ./.git -prune -o -type f -executable -print | grep -e . ; then + echo 'Do not commit executables' false fi + - name: 'Check: addlicense; all sources have a license header (ubuntu)' + if: always() && matrix.os == 'ubuntu-latest' + run: addlicense -check . - name: 'Check: gofmt; code is well formatted (ubuntu)' if: always() && matrix.os == 'ubuntu-latest' run: | @@ -104,67 +177,54 @@ jobs: echo "- ${FILE}" >> _gofmt.txt done cat _gofmt.txt - echo "## ⚠ gofmt Failed" >> _comments.txt - echo "" >> _comments.txt - cat _gofmt.txt >> _comments.txt - echo "" >> _comments.txt + echo "## ⚠ gofmt Failed" >> ../_comments.txt + echo "" >> ../_comments.txt + cat _gofmt.txt >> ../_comments.txt + echo "" >> ../_comments.txt false fi - - name: 'Check: addlicense; all sources have a license header (ubuntu)' - if: always() && matrix.os == 'ubuntu-latest' - run: addlicense -check . - name: "Check: misspelling; code doesn't contain misspelling (ubuntu)" if: always() && matrix.os == 'ubuntu-latest' run: | ERR=$(misspell .) if ! test -z "$ERR"; then echo "$ERR" - echo "## ⚠ misspell Failed" >> _comments.txt - echo "" >> _comments.txt - echo "$ERR" >> _comments.txt - echo "" >> _comments.txt + echo "## ⚠ misspell Failed" >> ../_comments.txt + echo "" >> ../_comments.txt + echo "$ERR" >> ../_comments.txt + echo "" >> ../_comments.txt false fi - - # Run tests last since it's potentially the slowest step. - - name: 'Check: go test -cover' - run: go test -timeout=40s -covermode=count -coverprofile coverage.txt ./... - # Don't send code coverage if anything failed to reduce spam. - - uses: codecov/codecov-action@v2 - - name: 'Cleanup' - run: rm coverage.txt - # Don't run go test -race if anything failed, to speed up the results. - - name: 'Check: go test -race' - run: go test -timeout=60s -race ./... - - name: 'Check: go test -bench .' - run: go test -timeout=40s -bench . -benchtime=100ms -cpu=1 ./... - - name: 'Check: CGO_ENABLED=0 go test -short' - run: CGO_ENABLED=0 go test -timeout=40s -short ./... - - - name: "Check: tree is clean" + - name: 'Send comments' + if: failure() run: | - # Nothing should have changed in the tree up to that point and no - # unsuspected file was created. - TOUCHED=$(git status --porcelain --ignored) - if ! test -z "$TOUCHED"; then - echo "Oops, something touched these files, please cleanup:" - echo "$TOUCHED" - git diff - false + if [ -f ../_comments.txt ]; then + URL="${{github.event.issue.pull_request.url}}" + if test -z "$URL"; then + URL="${{github.api_url}}/repos/${{github.repository}}/commits/${{github.sha}}/comments" + fi + echo "Sending $(cat ../_comments.txt|wc -l) lines of comments to ${URL}" + curl -sS --request POST \ + --header "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" \ + --header "Content-Type: application/json" \ + --data "$(cat ../_comments.txt | jq -R --slurp '{body: .}')" \ + "${URL}" > /dev/null + rm ../_comments.txt fi - - name: "Check: go generate doesn't modify files" + if: always() run: | go generate ./... - # Also test for untracked files. + # Also test for untracked files. go generate should not generate ignored + # files either. TOUCHED=$(git status --porcelain --ignored) if ! test -z "$TOUCHED"; then echo "go generate created these files, please fix:" echo "$TOUCHED" false fi - - name: "Check: go mod tidy doesn't modify files" + if: always() run: | go mod tidy TOUCHED=$(git status --porcelain --ignored) @@ -173,7 +233,6 @@ jobs: git diff false fi - - name: 'Test on periph.io/x/cmd' # Force an upgrade to test cmd with tip of tree devices. run: | @@ -184,32 +243,60 @@ jobs: go get -t ./... go test -short ./... - - name: 'Send comments' - if: failure() && github.event_name == 'pull_request' - run: | - if [ -f _comments.txt ]; then - URL=$(cat ${GITHUB_EVENT_PATH} | jq -r .pull_request.comments_url) - echo "Sending $(cat _comments.txt|wc -l) lines of comments to ${URL}" - PAYLOAD=$(echo '{}' | jq --arg body "$(cat _comments.txt)" '.body = $body') - curl -sS --request POST \ - --header "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" \ - --header "Content-Type: application/json" \ - --data "${PAYLOAD}" "${URL}" > /dev/null - fi - test_short: + # Ensure tests pass on oldest supported Go version. + old: + name: "test: go${{matrix.gover}}/${{matrix.os}}" + runs-on: "${{matrix.os}}" continue-on-error: true + defaults: + run: + shell: bash strategy: fail-fast: false matrix: os: [ubuntu-latest] - gover: ['1.14.15'] - runs-on: "${{matrix.os}}" - name: "go${{matrix.gover}} on ${{matrix.os}} (quick)" + # https://github.com/golang/go/issues/55078 + # golang.org/x/sys/unix broke on Go versions before 1.17. Not worth + # fixing. + gover: ['1.17.13'] + env: + PYTHONDONTWRITEBYTECODE: x steps: - - uses: actions/setup-go@v2 + - name: Turn off git core.autocrlf + if: matrix.os == 'windows-latest' + run: git config --global core.autocrlf false + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 with: - go-version: "${{matrix.gover}}" - - uses: actions/checkout@v2 + go-version: "=${{matrix.gover}}" - name: 'Check: go test' - run: go test -timeout=40s ./... + run: go test -timeout=120s -bench=. -benchtime=1x ./... + + + codeql: + name: "codeql: go${{matrix.gover}}.x/${{matrix.os}}" + runs-on: "${{matrix.os}}" + continue-on-error: true + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + # Do not forget to bump every 6 months! + gover: ["1.19"] + permissions: + security-events: write + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: "~${{matrix.gover}}.0" + cache: true + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: go + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/ads1x15/doc.go b/ads1x15/doc.go index 79c9d79..3a8a1ee 100644 --- a/ads1x15/doc.go +++ b/ads1x15/doc.go @@ -5,7 +5,7 @@ // Package ads1x15 controls ADS1015/ADS1115 Analog-Digital Converters (ADC) via // I²C interface. // -// Datasheet +// # Datasheet // // ADS1015: http://www.ti.com/product/ADS1015 // diff --git a/apa102/doc.go b/apa102/doc.go index 3b95c06..5bababb 100644 --- a/apa102/doc.go +++ b/apa102/doc.go @@ -11,11 +11,11 @@ // This driver handles color intensity and temperature correction and uses the // full near 8000:1 dynamic range as supported by the device. // -// More details +// # More details // // See https://periph.io/device/apa102/ for more details about the device. // -// Datasheet +// # Datasheet // // https://cpldcpu.files.wordpress.com/2014/08/apa-102c-super-led-specifications-2014-en.pdf package apa102 diff --git a/as7262/as7262.go b/as7262/as7262.go index ae23403..c6e6053 100644 --- a/as7262/as7262.go +++ b/as7262/as7262.go @@ -85,17 +85,17 @@ func (s Spectrum) String() string { // Band has two types of measurement of relative spectral flux density. // -// Value +// # Value // // Value are the calibrated readings. The accuracy of the channel counts/μW/cm2 // is ±12%. // -// Counts +// # Counts // // Counts are the raw readings, there are approximately 45 counts/μW/cm2 with a // gain of 16 (Gx16). // -// Wavelength +// # Wavelength // // Wavelength is the nominal center of a band, with a ±40nm bandwidth around the // center. Wavelengths for the as7262 are: 450nm, 500nm, 550nm, 570nm, 600nm and @@ -114,13 +114,13 @@ func (b Band) String() string { // Sense preforms a reading of relative spectral radiance of all the sensor // bands. // -// Led Drive Current +// # Led Drive Current // // The AS7262 provides a current-limited integrated led drive circuit. Valid // limits for the drive current are 0mA, 12.5mA, 25mA, 50mA and 100mA. If non // valid values are given the next lowest valid value is used. // -// Resolution +// # Resolution // // For best resolution it is recommended that for a specific led drive // current that the senseTime or gain is increased until at least one of the diff --git a/as7262/doc.go b/as7262/doc.go index eca7be0..749fa50 100644 --- a/as7262/doc.go +++ b/as7262/doc.go @@ -6,7 +6,7 @@ // interface. The as7262 features 6 spectral channels spaced at 450, 500, 550, // 570, 600, 650 nm and includes 2 integrated LED drivers. // -// Datasheet +// # Datasheet // // https://ams.com/documents/20143/36005/AS7262_DS000486_2-00.pdf package as7262 diff --git a/bh1750/doc.go b/bh1750/doc.go index 0596638..27f7938 100644 --- a/bh1750/doc.go +++ b/bh1750/doc.go @@ -4,7 +4,7 @@ // Package bh1750 controls a ROHM BH1750 ambient light sensor, over an i2c bus. // -// Datasheet +// # Datasheet // // http://cpre.kmutnb.ac.th/esl/learning/bh1750-light-sensor/bh1750fvi-e_datasheet.pdf package bh1750 diff --git a/bitbang/i2c.go b/bitbang/i2c.go index 0d19ba4..22e7166 100644 --- a/bitbang/i2c.go +++ b/bitbang/i2c.go @@ -30,9 +30,9 @@ const SkipAddr uint16 = 0xFFFF // during ACK. // // It has two special features: -// - Special address SkipAddr can be used to skip the address from being -// communicated -// - An arbitrary speed can be used +// - Special address SkipAddr can be used to skip the address from being +// communicated +// - An arbitrary speed can be used func New(clk gpio.PinIO, data gpio.PinIO, f physic.Frequency) (*I2C, error) { // Spec calls to idle at high. Page 8, section 3.1.1. // Set SCL as pull-up. diff --git a/bmxx80/doc.go b/bmxx80/doc.go index d1300bf..42c5865 100644 --- a/bmxx80/doc.go +++ b/bmxx80/doc.go @@ -5,11 +5,11 @@ // Package bmxx80 controls a Bosch BMP180/BME280/BMP280 device over I²C, or SPI // for the BMx280. // -// More details +// # More details // // See https://periph.io/device/bmxx80/ for more details about the device. // -// Datasheets +// # Datasheets // // The URLs tend to rot, visit https://www.bosch-sensortec.com if they become // invalid. @@ -28,7 +28,7 @@ // // https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf // -// Notes on the BMP180 datasheet +// # Notes on the BMP180 datasheet // // The results of the calculations in the algorithm on page 15 are partly // wrong. It looks like the original authors used non-integer calculations and diff --git a/cap1xxx/cap1xxx.go b/cap1xxx/cap1xxx.go index 7c893d3..309fa8d 100644 --- a/cap1xxx/cap1xxx.go +++ b/cap1xxx/cap1xxx.go @@ -9,7 +9,7 @@ // The cap1xxx devices are a 3/5/6/8/14 channel capacitive touch sensor with // 2/3/6/8/11 LED drivers. // -// Datasheet +// # Datasheet // // 3 sensors, 3 LEDs: // http://ww1.microchip.com/downloads/en/DeviceDoc/CAP1133.pdf diff --git a/ccs811/ccs811.go b/ccs811/ccs811.go index 09140b6..d2ffcf2 100644 --- a/ccs811/ccs811.go +++ b/ccs811/ccs811.go @@ -294,16 +294,17 @@ func (d *Dev) SetBaseline(baseline []byte) error { // Sensing resistor's current is between 0-63uA, and voltage 0-1.65V. // // Status represents sensor's status register. -// 1001 0110 -// ||||||||| -// ||||||| \- 1 = There is an error. -// |||||| \- Reserved. -// ||||| \- Reserved. -// |||| \- 1 = Data ready. -// ||| \- 1 = Valid application firmware loaded. -// || \- Reserved. -// | \- Reserved. -// \- 0 = Firmware in boot mode, 1 Firmware in application mode. +// +// 1001 0110 +// ||||||||| +// ||||||| \- 1 = There is an error. +// |||||| \- Reserved. +// ||||| \- Reserved. +// |||| \- 1 = Data ready. +// ||| \- 1 = Valid application firmware loaded. +// || \- Reserved. +// | \- Reserved. +// \- 0 = Firmware in boot mode, 1 Firmware in application mode. // // Error represents error state of the sensor if available, otherwise is nil. type SensorValues struct { diff --git a/ccs811/doc.go b/ccs811/doc.go index 8c3da87..69199df 100644 --- a/ccs811/doc.go +++ b/ccs811/doc.go @@ -5,11 +5,11 @@ // Package ccs811 controls CCS811 Volatile Organic Compounds sensor via // I²C interface. // -// Product page +// # Product page // // https://ams.com/ccs811 // -// Datasheet +// # Datasheet // // https://ams.com/documents/20143/36005/CCS811_DS000459_7-00.pdf package ccs811 diff --git a/ds18b20/doc.go b/ds18b20/doc.go index 514b10d..4304894 100644 --- a/ds18b20/doc.go +++ b/ds18b20/doc.go @@ -14,11 +14,11 @@ // The DS18B20/DS18S20 alarm functionality and reading/writing the 2 alarm // bytes in the EEPROM are not supported. // -// More details +// # More details // // See https://periph.io/device/ds18b20/ for more details about the device. // -// Datasheets +// # Datasheets // // https://datasheets.maximintegrated.com/en/ds/DS18B20-PAR.pdf // diff --git a/ds248x/doc.go b/ds248x/doc.go index 002a968..a756276 100644 --- a/ds248x/doc.go +++ b/ds248x/doc.go @@ -5,11 +5,11 @@ // Package ds248x controls a Maxim DS2483 or DS2482-100 1-wire interface chip // over I²C. // -// More details +// # More details // // See https://periph.io/device/ds248x/ for more details about the device. // -// Datasheets +// # Datasheets // // https://www.maximintegrated.com/en/products/digital/one-wire/DS2483.html // diff --git a/epd/doc.go b/epd/doc.go index e56e622..069e3e3 100644 --- a/epd/doc.go +++ b/epd/doc.go @@ -4,9 +4,9 @@ // Package epd controls Waveshare e-paper series displays. // -// More details +// # More details // -// Datasheets +// # Datasheets // // https://www.waveshare.com/w/upload/e/e6/2.13inch_e-Paper_Datasheet.pdf // diff --git a/go.mod b/go.mod index e2752cd..36cd2b8 100644 --- a/go.mod +++ b/go.mod @@ -4,14 +4,19 @@ module periph.io/x/devices/v3 -go 1.14 +go 1.17 require ( - github.com/google/go-cmp v0.5.6 + github.com/google/go-cmp v0.5.9 github.com/maruel/ansi256 v1.0.2 - github.com/mattn/go-colorable v0.1.12 - golang.org/x/image v0.0.0-20211028202545-6944b10bf410 - golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect - periph.io/x/conn/v3 v3.6.10 - periph.io/x/host/v3 v3.7.2 + github.com/mattn/go-colorable v0.1.13 + golang.org/x/image v0.1.0 + periph.io/x/conn/v3 v3.7.0 + periph.io/x/host/v3 v3.8.0 +) + +require ( + github.com/jonboulle/clockwork v0.3.0 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect + golang.org/x/sys v0.1.0 // indirect ) diff --git a/go.sum b/go.sum index bd3956d..ec7dd4a 100644 --- a/go.sum +++ b/go.sum @@ -1,25 +1,44 @@ -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= +github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/maruel/ansi256 v1.0.2 h1:AE5gYrrZ5vQaFTTwy5vxva8Bak7p7wID3Uqu3t1j3No= github.com/maruel/ansi256 v1.0.2/go.mod h1:x7uow2KFkUgjdzvYHyfZuMEOTGKvCYLyVUHIVg1vYic= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ= -golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/image v0.1.0 h1:r8Oj8ZA2Xy12/b5KZYj3tuv7NG/fBz3TwQVvpJ9l8Rk= +golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -periph.io/x/conn/v3 v3.6.10 h1:gwU4ssmZkq1D/uz8hU91i/COo2c9DrRaS4PJZBbCd+c= -periph.io/x/conn/v3 v3.6.10/go.mod h1:UqWNaPMosWmNCwtufoTSTTYhB2wXWsMRAJyo1PlxO4Q= -periph.io/x/d2xx v0.0.4/go.mod h1:38Euaaj+s6l0faIRHh32a+PrjXvxFTFkPBEQI0TKg34= -periph.io/x/host/v3 v3.7.2 h1:rCAUxkzy2xrzh18HP2AoVwTL/fEKqmcJ1icsZQGM58Q= -periph.io/x/host/v3 v3.7.2/go.mod h1:nHMlzkPwmnHyP9Tn0I8FV+e0N3K7TjFXLZkIWzAicog= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA= +periph.io/x/conn/v3 v3.7.0/go.mod h1:ypY7UVxgDbP9PJGwFSVelRRagxyXYfttVh7hJZUHEhg= +periph.io/x/d2xx v0.1.0/go.mod h1:OflHQcWZ4LDP/2opGYbdXSP/yvWSnHVFO90KRoyobWY= +periph.io/x/host/v3 v3.8.0 h1:T5ojZ2wvnZHGPS4h95N2ZpcCyHnsvH3YRZ1UUUiv5CQ= +periph.io/x/host/v3 v3.8.0/go.mod h1:rzOLH+2g9bhc6pWZrkCrmytD4igwQ2vxFw6Wn6ZOlLY= diff --git a/hd44780/hd44780.go b/hd44780/hd44780.go index a9cde28..e3e046a 100644 --- a/hd44780/hd44780.go +++ b/hd44780/hd44780.go @@ -4,7 +4,7 @@ // Package hd44780 controls the Hitachi LCD display chipset HD-44780 // -// Datasheet +// # Datasheet // // https://www.sparkfun.com/datasheets/LCD/HD44780.pdf package hd44780 @@ -33,6 +33,7 @@ type Dev struct { } // New creates and initializes the LCD device +// // data - references to data pins // rs - rs pin // e - strobe pin @@ -88,6 +89,7 @@ func (r *Dev) Halt() error { } // SetCursor positions the cursor +// // line - screen line, 0-based // column - column, 0-based func (r *Dev) SetCursor(line uint8, column uint8) error { @@ -95,6 +97,7 @@ func (r *Dev) SetCursor(line uint8, column uint8) error { } // Print the data string +// // data string to display func (r *Dev) Print(data string) error { for _, v := range []byte(data) { @@ -106,6 +109,7 @@ func (r *Dev) Print(data string) error { } // WriteChar writes a single byte (character) at the cursor position. +// // data - character code func (r *Dev) WriteChar(data uint8) error { if err := r.sendData(); err != nil { diff --git a/ht16k33/doc.go b/ht16k33/doc.go index 88a11ca..2bf5aa4 100644 --- a/ht16k33/doc.go +++ b/ht16k33/doc.go @@ -4,13 +4,13 @@ // Package ht16k33 implements interfacing code to Holtek HT16K33 Alphanumeric 16x8 LED driver. // -// More Details +// # More Details // -// Datasheets +// # Datasheets // // http://www.holtek.com/documents/10179/116711/HT16K33v120.pdf // -// Product Page +// # Product Page // // http://www.holtek.com/productdetail/-/vg/HT16K33 package ht16k33 diff --git a/hx711/hx711.go b/hx711/hx711.go index 8bf35f4..0aa814b 100644 --- a/hx711/hx711.go +++ b/hx711/hx711.go @@ -5,7 +5,7 @@ // Package hx711 implements an interface to the 24-bits HX711 analog to digital // converter. // -// Datasheet +// # Datasheet // // http://www.aviaic.com/Download/hx711F_EN.pdf.pdf package hx711 diff --git a/ina219/doc.go b/ina219/doc.go index ea93c07..6d51267 100644 --- a/ina219/doc.go +++ b/ina219/doc.go @@ -5,13 +5,13 @@ // Package ina219 controls a Texas Instruments ina219 high side current, // voltage and power monitor IC over an i2c bus. // -// Calibration +// # Calibration // // Calibration is recommended for accurate current and power measurements. // Voltage measurements do not require sensor calibration. To calibrate, measure // the actual value of the shunt resistor. // -// Datasheet +// # Datasheet // // http://www.ti.com/lit/ds/symlink/ina219.pdf package ina219 diff --git a/ina219/ina219.go b/ina219/ina219.go index 15eee46..0226ba1 100644 --- a/ina219/ina219.go +++ b/ina219/ina219.go @@ -17,7 +17,7 @@ import ( // Opts holds the configuration options. // -// Slave Address +// # Slave Address // // Depending which pins the A1, A0 pins are connected to will change the slave // address. Default configuration is address 0x40 (both pins to GND). For a full diff --git a/inky/doc.go b/inky/doc.go index ac841c4..e41cf5d 100644 --- a/inky/doc.go +++ b/inky/doc.go @@ -4,7 +4,7 @@ // Package inky drives an Inky pHAT, pHAT v2 or wHAT E ink display. // -// Datasheet +// # Datasheet // // Inky lacks a true datasheet, so the code here is derived from the reference // implementation by Pimoroni: diff --git a/lepton/cci/cci.go b/lepton/cci/cci.go index 1034be4..538caac 100644 --- a/lepton/cci/cci.go +++ b/lepton/cci/cci.go @@ -148,7 +148,6 @@ func New(i i2c.Bus) (*Dev, error) { // Dev is the Lepton specific Command and Control Interface (CCI). // -// // Dev can safely accessed concurrently via multiple goroutines. // // This interface is accessed via I²C and provides access to view and modify diff --git a/lepton/cci/doc.go b/lepton/cci/doc.go index 10818cc..8b9cc07 100644 --- a/lepton/cci/doc.go +++ b/lepton/cci/doc.go @@ -8,7 +8,7 @@ // This protocol controls and queries the camera but is not used to read the // images. // -// Datasheet +// # Datasheet // // https://www.flir.com/globalassets/imported-assets/document/flir-lepton-software-interface-description-document.pdf package cci diff --git a/lepton/doc.go b/lepton/doc.go index a99ec80..6207828 100644 --- a/lepton/doc.go +++ b/lepton/doc.go @@ -4,11 +4,11 @@ // Package lepton drives a FLIR Lepton Infra Red (IR) camera. // -// More details +// # More details // // See https://periph.io/device/lepton/ for more details about the device. // -// Datasheet +// # Datasheet // // https://www.flir.com/globalassets/imported-assets/document/lepton-engineering-datasheet---with-radiometry.pdf package lepton diff --git a/lirc/doc.go b/lirc/doc.go index d4b3b9b..920cc81 100644 --- a/lirc/doc.go +++ b/lirc/doc.go @@ -5,7 +5,7 @@ // Package lirc implements InfraRed receiver support through native linux app // lirc. // -// More details +// # More details // // See https://periph.io/device/ir/ for more details about the driver, as it // requires host configuration. diff --git a/mcp23xxx/doc.go b/mcp23xxx/doc.go index 4a831a0..88a8405 100644 --- a/mcp23xxx/doc.go +++ b/mcp23xxx/doc.go @@ -4,7 +4,7 @@ // Package mcp23xxx provides driver for the MCP23 family of IO extenders // -// Datasheet +// # Datasheet // // https://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf package mcp23xxx diff --git a/mcp9808/doc.go b/mcp9808/doc.go index 6e89d6e..60346d4 100644 --- a/mcp9808/doc.go +++ b/mcp9808/doc.go @@ -4,7 +4,7 @@ // Package mcp9808 controls a Microchip MCP9808 digital I²C temperature sensor. // -// Features +// # Features // // -40°C and +125°C Operating Range. // @@ -12,7 +12,7 @@ // // User-Programmable Temperature Alerts. // -// Datasheet +// # Datasheet // // http://ww1.microchip.com/downloads/en/DeviceDoc/25095A.pdf package mcp9808 diff --git a/mcp9808/mcp9808.go b/mcp9808/mcp9808.go index 076504a..63b0419 100644 --- a/mcp9808/mcp9808.go +++ b/mcp9808/mcp9808.go @@ -18,7 +18,7 @@ import ( // Opts holds the configuration options. // -// Slave Address +// # Slave Address // // Depending which pins the A0, A1 and A2 pins are connected to will change the // slave address. Default configuration is address 0x18 (Ax pins to GND). For a diff --git a/mfrc522/blockaccess.go b/mfrc522/blockaccess.go index 417ed5e..b41be56 100644 --- a/mfrc522/blockaccess.go +++ b/mfrc522/blockaccess.go @@ -4,7 +4,7 @@ // Package mfrc522 controls a Mifare RFID card reader. // -// Datasheet +// # Datasheet // // https://www.nxp.com/docs/en/data-sheet/MFRC522.pdf package mfrc522 @@ -33,25 +33,25 @@ const ( // Every trail sector has the options for controlling the access to the trailing sector bits. // For example : // -// KeyA_R[Key]_W[Key]_BITS_R[Key]_W[Key]_KeyB_R[Key]_W[Key] +// KeyA_R[Key]_W[Key]_BITS_R[Key]_W[Key]_KeyB_R[Key]_W[Key] // -// - KeyA -// - could be Read by providing [Key] ( where [Key] could be KeyA or KeyB ) -// - could be Written by Providing [Key] ( where [Key] is KeyA or KeyB ) -// - access bits for the sector data (see above) -// - could be Read by providing [Key] ( where [Key] could be KeyA or KeyB ) -// - could be Written by Providing [Key] ( where [Key] is KeyA or KeyB ) -// - KeyB -// - could be Read by providing [Key] ( where [Key] could be KeyA or KeyB ) -// - could be Written by Providing [Key] ( where [Key] is KeyA or KeyB ) +// - KeyA +// - could be Read by providing [Key] ( where [Key] could be KeyA or KeyB ) +// - could be Written by Providing [Key] ( where [Key] is KeyA or KeyB ) +// - access bits for the sector data (see above) +// - could be Read by providing [Key] ( where [Key] could be KeyA or KeyB ) +// - could be Written by Providing [Key] ( where [Key] is KeyA or KeyB ) +// - KeyB +// - could be Read by providing [Key] ( where [Key] could be KeyA or KeyB ) +// - could be Written by Providing [Key] ( where [Key] is KeyA or KeyB ) // -// example: +// example: // -// KeyA_RN_WA_BITS_RA_WA_KeyB_RA_WA means -// - KeyA could not be read but could be overwriten if KeyA is provided -// - Access bits could be read and overwritten if KeyA is provided during the card authentication -// - KeyB could be read and overriten if KeyA is provided during the card authentication -// more on the matter: https://www.nxp.com/docs/en/data-sheet/MF1S50YYX_V1.pdf +// KeyA_RN_WA_BITS_RA_WA_KeyB_RA_WA means +// - KeyA could not be read but could be overwriten if KeyA is provided +// - Access bits could be read and overwritten if KeyA is provided during the card authentication +// - KeyB could be read and overriten if KeyA is provided during the card authentication +// more on the matter: https://www.nxp.com/docs/en/data-sheet/MF1S50YYX_V1.pdf const ( KeyA_RN_WA_BITS_RA_WN_KeyB_RA_WA SectorTrailerAccess = 0x0 KeyA_RN_WN_BITS_RA_WN_KeyB_RA_WN SectorTrailerAccess = 0x02 diff --git a/mfrc522/commands/low_level.go b/mfrc522/commands/low_level.go index 9908658..ae8a7cd 100644 --- a/mfrc522/commands/low_level.go +++ b/mfrc522/commands/low_level.go @@ -35,9 +35,9 @@ type AuthStatus byte // NewLowLevelSPI creates and initializes the RFID card reader attached to SPI. // -// spiPort - the SPI device to use. -// resetPin - reset GPIO pin. -// irqPin - irq GPIO pin. +// spiPort - the SPI device to use. +// resetPin - reset GPIO pin. +// irqPin - irq GPIO pin. func NewLowLevelSPI(spiPort spi.Port, resetPin gpio.PinOut, irqPin gpio.PinIn) (*LowLevel, error) { if resetPin == nil { return nil, wrapf("reset pin is not set") @@ -233,11 +233,11 @@ func (r *LowLevel) ClearInterrupt() { // Auth authenticate the card fof the sector/block using the provided data. // -// mode - the authentication mode. -// sector - the sector to authenticate on. -// block - the block within sector to authenticate. -// sectorKey - the key to be used for accessing the sector data. -// serial - the serial of the card. +// mode - the authentication mode. +// sector - the sector to authenticate on. +// block - the block within sector to authenticate. +// sectorKey - the key to be used for accessing the sector data. +// serial - the serial of the card. func (r *LowLevel) Auth(mode byte, blockAddress byte, sectorKey [6]byte, serial []byte) (AuthStatus, error) { buffer := make([]byte, 2) buffer[0] = mode @@ -256,8 +256,8 @@ func (r *LowLevel) Auth(mode byte, blockAddress byte, sectorKey [6]byte, serial // CardWrite the low-level interface to write some raw commands to the card. // -// command - the command register -// data - the data to write out to the card using the authenticated sector. +// command - the command register +// data - the data to write out to the card using the authenticated sector. func (r *LowLevel) CardWrite(command byte, data []byte) ([]byte, int, error) { var backData []byte backLength := -1 diff --git a/mfrc522/mfrc522.go b/mfrc522/mfrc522.go index 1edd3e0..98835a2 100644 --- a/mfrc522/mfrc522.go +++ b/mfrc522/mfrc522.go @@ -4,7 +4,7 @@ // Package mfrc522 controls a Mifare RFID card reader. // -// Datasheet +// # Datasheet // // https://www.nxp.com/docs/en/data-sheet/MFRC522.pdf package mfrc522 @@ -80,10 +80,10 @@ func noop() {} // NewSPI creates and initializes the RFID card reader attached to SPI. // -// spiPort the SPI device to use. -// resetPin reset GPIO pin. -// irqPin irq GPIO pin. -// configs configuration options +// spiPort the SPI device to use. +// resetPin reset GPIO pin. +// irqPin irq GPIO pin. +// configs configuration options func NewSPI(spiPort spi.Port, resetPin gpio.PinOut, irqPin gpio.PinIn, configs ...configF) (*Dev, error) { cfg := &config{ defaultTimeout: 30 * time.Second, @@ -128,7 +128,7 @@ func (r *Dev) Halt() error { // SetAntennaGain configures antenna signal strength. // -// gain signal strength from 0 to 7. +// gain signal strength from 0 to 7. func (r *Dev) SetAntennaGain(gain int) error { r.beforeCall() defer r.afterCall() @@ -141,7 +141,7 @@ func (r *Dev) SetAntennaGain(gain int) error { // ReadUID reads the 4-byte or 7-byte card UID with IRQ event timeout. // -// timeout the operation timeout +// timeout the operation timeout func (r *Dev) ReadUID(timeout time.Duration) (uid []byte, err error) { r.beforeCall() defer func() { @@ -155,11 +155,11 @@ func (r *Dev) ReadUID(timeout time.Duration) (uid []byte, err error) { // ReadCard reads the card sector/block with IRQ event timeout. // -// timeout the operation timeout -// auth the authentication mode. -// sector the sector to authenticate on. -// block the block within sector to authenticate. -// key the key to be used for accessing the sector data. +// timeout the operation timeout +// auth the authentication mode. +// sector the sector to authenticate on. +// block the block within sector to authenticate. +// key the key to be used for accessing the sector data. func (r *Dev) ReadCard(timeout time.Duration, auth byte, sector int, block int, key Key) (data []byte, err error) { r.beforeCall() defer func() { @@ -185,10 +185,10 @@ func (r *Dev) ReadCard(timeout time.Duration, auth byte, sector int, block int, // ReadAuth reads the card authentication data with IRQ event timeout. // -// timeout the operation timeout -// auth authentication type -// sector the sector to authenticate on. -// key the key to be used for accessing the sector data. +// timeout the operation timeout +// auth authentication type +// sector the sector to authenticate on. +// key the key to be used for accessing the sector data. func (r *Dev) ReadAuth(timeout time.Duration, auth byte, sector int, key Key) (data []byte, err error) { r.beforeCall() defer func() { @@ -215,12 +215,12 @@ func (r *Dev) ReadAuth(timeout time.Duration, auth byte, sector int, key Key) (d // WriteCard writes the data into the card block with IRQ event timeout. // -// timeout the operation timeout -// auth the authentiction mode. -// sector the sector on the card to write to. -// block the block within the sector to write into. -// data 16 bytes if data to write -// key the key used to authenticate the card - depends on the used auth method. +// timeout the operation timeout +// auth the authentiction mode. +// sector the sector on the card to write to. +// block the block within the sector to write into. +// data 16 bytes if data to write +// key the key used to authenticate the card - depends on the used auth method. func (r *Dev) WriteCard(timeout time.Duration, auth byte, sector int, block int, data [16]byte, key Key) (err error) { r.beforeCall() defer func() { @@ -247,13 +247,13 @@ func (r *Dev) WriteCard(timeout time.Duration, auth byte, sector int, block int, // WriteSectorTrail writes the sector trail with sector access bits with IRQ event timeout. // -// timeout operation timeout -// auth authentication mode. -// sector sector to set authentication. -// keyA the key used for AuthA authentication scheme. -// keyB the key used for AuthB authentication scheme. -// access the block access structure. -// key the current key used to authenticate the provided sector. +// timeout operation timeout +// auth authentication mode. +// sector sector to set authentication. +// keyA the key used for AuthA authentication scheme. +// keyB the key used for AuthB authentication scheme. +// access the block access structure. +// key the current key used to authenticate the provided sector. func (r *Dev) WriteSectorTrail(timeout time.Duration, auth byte, sector int, keyA Key, keyB Key, access *BlocksAccess, key Key) (err error) { r.beforeCall() defer func() { @@ -390,8 +390,8 @@ func (r *Dev) selectTag(serial []byte) (byte, error) { // readBlock reads the block from the card. // -// sector - card sector to read from -// block - the block within the sector (0-3 tor Mifare 4K) +// sector - card sector to read from +// block - the block within the sector (0-3 tor Mifare 4K) func (r *Dev) readBlock(sector int, block int) ([]byte, error) { return r.read(calcBlockAddress(sector, block%3)) } @@ -469,8 +469,8 @@ func (r *Dev) write(blockAddr byte, data []byte) error { // preAccess calculates CRC of the block address to be accessed and sends it to the device for verification. // -// blockAddr - the block address to access. -// cmd - command code to perform on the given block, +// blockAddr - the block address to access. +// cmd - command code to perform on the given block, func (r *Dev) preAccess(blockAddr byte, cmd byte) ([]byte, int, error) { send := make([]byte, 4) send[0] = cmd @@ -487,7 +487,7 @@ func (r *Dev) preAccess(blockAddr byte, cmd byte) ([]byte, int, error) { // read reads the block // -// blockAddr the address to read from the card. +// blockAddr the address to read from the card. func (r *Dev) read(blockAddr byte) ([]byte, error) { data, _, err := r.preAccess(blockAddr, commands.PICC_READ) if err != nil { diff --git a/mfrc522/mfrc522_test.go b/mfrc522/mfrc522_test.go index 16f441a..262541a 100644 --- a/mfrc522/mfrc522_test.go +++ b/mfrc522/mfrc522_test.go @@ -21,7 +21,8 @@ func fromBitString(t *testing.T, s string) (res byte) { } /* - C1 C2 C3 + C1 C2 C3 + 3 : 1 0 0 2 : 0 0 1 1 : 1 0 1 @@ -77,13 +78,13 @@ func TestBitCalc(t *testing.T) { } /* - C1 C2 C3 + C1 C2 C3 + 3 : 0 0 1 2 : 0 0 0 1 : 0 0 0 0 : 0 0 0 - 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 diff --git a/mpu9250/mpu9250.go b/mpu9250/mpu9250.go index 360789e..9699e16 100644 --- a/mpu9250/mpu9250.go +++ b/mpu9250/mpu9250.go @@ -4,7 +4,7 @@ // Package mpu9250 MPU-9250 is a 9-axis MotionTracking device that combines a 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer and a Digital Motion Processor™ (DMP) // -// Datasheet +// # Datasheet // // https://www.invensense.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf // https://www.invensense.com/wp-content/uploads/2015/02/MPU-9250-Register-Map.pdf @@ -390,16 +390,16 @@ func (m *MPU9250) SelfTest() (*SelfTestResult, error) { // improved stability. The clock source can be selected according to the // following table: // -// CLK_SEL | Clock Source -// --------+-------------------------------------- -// 0 | Internal oscillator -// 1 | PLL with X Gyro reference -// 2 | PLL with Y Gyro reference -// 3 | PLL with Z Gyro reference -// 4 | PLL with external 32.768kHz reference -// 5 | PLL with external 19.2MHz reference -// 6 | Reserved -// 7 | Stops the clock and keeps the timing generator in reset +// CLK_SEL | Clock Source +// --------+-------------------------------------- +// 0 | Internal oscillator +// 1 | PLL with X Gyro reference +// 2 | PLL with Y Gyro reference +// 3 | PLL with Z Gyro reference +// 4 | PLL with external 32.768kHz reference +// 5 | PLL with external 19.2MHz reference +// 6 | Reserved +// 7 | Stops the clock and keeps the timing generator in reset func (m *MPU9250) SetClockSource(src byte) error { if src > 7 { return wrapf("clock should be in range 0 .. 7") @@ -412,10 +412,10 @@ func (m *MPU9250) SetClockSource(src byte) error { // The FS_SEL parameter allows setting the full-scale range of the gyro sensors, // as described in the table below. // -// 0 = +/- 250 degrees/sec -// 1 = +/- 500 degrees/sec -// 2 = +/- 1000 degrees/sec -// 3 = +/- 2000 degrees/sec +// 0 = +/- 250 degrees/sec +// 1 = +/- 500 degrees/sec +// 2 = +/- 1000 degrees/sec +// 3 = +/- 2000 degrees/sec func (m *MPU9250) SetGyroRange(rangeVal byte) error { if rangeVal > 3 { return wrapf("accepted values are in the range 0 .. 3") @@ -434,10 +434,10 @@ func (m *MPU9250) GetGyroRange() (byte, error) { // The FS_SEL parameter allows setting the full-scale range of the accelerometer // sensors, as described in the table below. // -// 0 = +/- 2g -// 1 = +/- 4g -// 2 = +/- 8g -// 3 = +/- 16g +// 0 = +/- 2g +// 1 = +/- 4g +// 2 = +/- 8g +// 3 = +/- 16g func (m *MPU9250) SetAccelRange(rangeVal byte) error { if (rangeVal >> 3) > 3 { return wrapf("accepted values are in the range 0 .. 3") @@ -642,24 +642,24 @@ func (m *MPU9250) GetMasterClockSpeed() (byte, error) { // MPU-60X0 internal 8MHz clock. It sets the I2C master clock speed according to // the following table: // -// I2C_MST_CLK | I2C Master Clock Speed | 8MHz Clock Divider -// ------------+------------------------+------------------- -// 0 | 348kHz | 23 -// 1 | 333kHz | 24 -// 2 | 320kHz | 25 -// 3 | 308kHz | 26 -// 4 | 296kHz | 27 -// 5 | 286kHz | 28 -// 6 | 276kHz | 29 -// 7 | 267kHz | 30 -// 8 | 258kHz | 31 -// 9 | 500kHz | 16 -// 10 | 471kHz | 17 -// 11 | 444kHz | 18 -// 12 | 421kHz | 19 -// 13 | 400kHz | 20 -// 14 | 381kHz | 21 -// 15 | 364kHz | 22 +// I2C_MST_CLK | I2C Master Clock Speed | 8MHz Clock Divider +// ------------+------------------------+------------------- +// 0 | 348kHz | 23 +// 1 | 333kHz | 24 +// 2 | 320kHz | 25 +// 3 | 308kHz | 26 +// 4 | 296kHz | 27 +// 5 | 286kHz | 28 +// 6 | 276kHz | 29 +// 7 | 267kHz | 30 +// 8 | 258kHz | 31 +// 9 | 500kHz | 16 +// 10 | 471kHz | 17 +// 11 | 444kHz | 18 +// 12 | 421kHz | 19 +// 13 | 400kHz | 20 +// 14 | 381kHz | 21 +// 15 | 364kHz | 22 func (m *MPU9250) SetMasterClockSpeed(speed byte) error { // TODO: Use physic.Frequency. if speed > 15 { @@ -948,7 +948,7 @@ func (m *MPU9250) GetSlave4MasterDelay() (byte, error) { // Rate. When a slave's access rate is decreased relative to the Sample Rate, // the slave is accessed every: // -// 1 / (1 + I2C_MST_DLY) samples +// 1 / (1 + I2C_MST_DLY) samples // // This base Sample Rate in turn is determined by SMPLRT_DIV (register 25) and // DLPF_CFG (register 26). Whether a slave's access rate is reduced relative to @@ -1556,12 +1556,12 @@ func (m *MPU9250) SetAccelerationOffsetX(offset uint16) error { // (Register 28). For each full scale setting, the accelerometers' sensitivity // per LSB in ACCEL_xOUT is shown in the table below: // -// AFS_SEL | Full Scale Range | LSB Sensitivity -// --------+------------------+---------------- -// 0 | +/- 2g | 8192 LSB/mg -// 1 | +/- 4g | 4096 LSB/mg -// 2 | +/- 8g | 2048 LSB/mg -// 3 | +/- 16g | 1024 LSB/mg +// AFS_SEL | Full Scale Range | LSB Sensitivity +// --------+------------------+---------------- +// 0 | +/- 2g | 8192 LSB/mg +// 1 | +/- 4g | 4096 LSB/mg +// 2 | +/- 8g | 2048 LSB/mg +// 3 | +/- 16g | 1024 LSB/mg func (m *MPU9250) GetAcceleration() (*AccelerometerData, error) { x, err := m.GetAccelerationX() if err != nil { @@ -1677,12 +1677,12 @@ func (m *MPU9250) GetRotationZ() (int16, error) { // (Register 27). For each full scale setting, the gyroscopes' sensitivity per // LSB in GYRO_xOUT is shown in the table below: // -// FS_SEL | Full Scale Range | LSB Sensitivity -// -------+--------------------+---------------- -// 0 | +/- 250 degrees/s | 131 LSB/deg/s -// 1 | +/- 500 degrees/s | 65.5 LSB/deg/s -// 2 | +/- 1000 degrees/s | 32.8 LSB/deg/s -// 3 | +/- 2000 degrees/s | 16.4 LSB/deg/s +// FS_SEL | Full Scale Range | LSB Sensitivity +// -------+--------------------+---------------- +// 0 | +/- 250 degrees/s | 131 LSB/deg/s +// 1 | +/- 500 degrees/s | 65.5 LSB/deg/s +// 2 | +/- 1000 degrees/s | 32.8 LSB/deg/s +// 3 | +/- 2000 degrees/s | 16.4 LSB/deg/s func (m *MPU9250) GetRotation() (*RotationData, error) { x, err := m.GetRotationX() if err != nil { diff --git a/nrzled/doc.go b/nrzled/doc.go index 53d3f1f..ce5298b 100644 --- a/nrzled/doc.go +++ b/nrzled/doc.go @@ -18,14 +18,14 @@ // You may also need to increase your SPI buffer size to 12*num_pixels+3, or just max it out // with `spidev.bufsize=65536`. That should allopw you to buffer over 5400 Neopixels. // -// Datasheet +// # Datasheet // // This directory contains datasheets for ws2812, ws2812b, ucs190x and various // sk6812. // // https://github.com/cpldcpu/light_ws2812/tree/master/Datasheets // -// UCS1903 datasheet +// # UCS1903 datasheet // // http://www.bestlightingbuy.com/pdf/UCS1903%20datasheet.pdf // diff --git a/pca9548/doc.go b/pca9548/doc.go index 5ef3049..0e7df1c 100644 --- a/pca9548/doc.go +++ b/pca9548/doc.go @@ -6,14 +6,12 @@ // from multiple vendors. The main features of this multiplexer is that its has // 8 channels and is capable of voltage level translation. // -// -// Adjusting the Bus CLK +// # Adjusting the Bus CLK // // The bus clock is slaved to the master bus clock, different clock for each // port is currently not supported. The Maximum clock for this device is 400kHz. // -// -// Datasheet +// # Datasheet // // https://www.nxp.com/docs/en/data-sheet/PCA9548A.pdf package pca9548 diff --git a/pca9685/doc.go b/pca9685/doc.go index 5962a4b..cd30b2c 100644 --- a/pca9685/doc.go +++ b/pca9685/doc.go @@ -4,9 +4,9 @@ // Package pca9685 includes utilities to controls pca9685 module and servo motors. // -// More details +// # More details // -// Datasheet +// # Datasheet // // https://www.nxp.com/docs/en/data-sheet/PCA9685.pdf // diff --git a/piblaster/piblaster.go b/piblaster/piblaster.go index fb87f39..2b9e8e3 100644 --- a/piblaster/piblaster.go +++ b/piblaster/piblaster.go @@ -10,7 +10,7 @@ // TODO(maruel): "dtoverlay=pwm" or "dtoverlay=pwm-2chan" works without having // to install anything, albeit with less pins supported. // -// Warning +// # Warning // // piblaster doesn't report what pins is controls so it is easy to misuse this // library. @@ -56,7 +56,7 @@ var piblasterHandle io.WriteCloser func openPiblaster() error { if piblasterHandle == nil { - f, err := os.OpenFile("/dev/pi-blaster", os.O_WRONLY|os.O_APPEND, 0644) + f, err := os.OpenFile("/dev/pi-blaster", os.O_WRONLY|os.O_APPEND, 0600) if err != nil { return err } diff --git a/rainbowhat/doc.go b/rainbowhat/doc.go index 2789cd8..77c62d8 100644 --- a/rainbowhat/doc.go +++ b/rainbowhat/doc.go @@ -20,9 +20,9 @@ // // Servo header (PWM) // -// More details +// # More details // -// Product Page +// # Product Page // // https://shop.pimoroni.com/products/rainbow-hat-for-android-things package rainbowhat diff --git a/sn3218/doc.go b/sn3218/doc.go index 0dd99bb..e4d671f 100644 --- a/sn3218/doc.go +++ b/sn3218/doc.go @@ -4,7 +4,7 @@ // Package sn3218 controls a SN3218 LED driver with 18 LEDs over an i2c bus. // -// Datasheet +// # Datasheet // // http://www.si-en.com/uploadpdf/s2011517171720.pdf package sn3218 diff --git a/ssd1306/doc.go b/ssd1306/doc.go index ead20c5..968a621 100644 --- a/ssd1306/doc.go +++ b/ssd1306/doc.go @@ -18,11 +18,11 @@ // High. When set to Low (Ground), it enables the reset circuitry. It can be // used externally to this driver, if used, the driver must be reinstantiated. // -// More details +// # More details // // See https://periph.io/device/ssd1306/ for more details about the device. // -// Datasheets +// # Datasheets // // Product page: // http://www.solomon-systech.com/en/product/display-ic/oled-driver-controller/ssd1306/ diff --git a/ssd1306/image1bit/image1bit.go b/ssd1306/image1bit/image1bit.go index 7c0d8e8..8bda7f7 100644 --- a/ssd1306/image1bit/image1bit.go +++ b/ssd1306/image1bit/image1bit.go @@ -53,14 +53,14 @@ var BitModel = color.ModelFunc(convert) // pixels high with LSB first. So the first byte represents the following // pixels, with lowest bit being the top left pixel. // -// 0 x x x x x x x -// 1 x x x x x x x -// 2 x x x x x x x -// 3 x x x x x x x -// 4 x x x x x x x -// 5 x x x x x x x -// 6 x x x x x x x -// 7 x x x x x x x +// 0 x x x x x x x +// 1 x x x x x x x +// 2 x x x x x x x +// 3 x x x x x x x +// 4 x x x x x x x +// 5 x x x x x x x +// 6 x x x x x x x +// 7 x x x x x x x // // It is designed specifically to work with SSD1306 OLED display controller. type VerticalLSB struct { diff --git a/ssd1306/ssd1306.go b/ssd1306/ssd1306.go index 9a8d29d..6c17079 100644 --- a/ssd1306/ssd1306.go +++ b/ssd1306/ssd1306.go @@ -113,7 +113,7 @@ type Opts struct { // The SSD1306 can operate at up to 3.3Mhz, which is much higher than I²C. This // permits higher refresh rates. // -// Wiring +// # Wiring // // Connect SDA to SPI_MOSI, SCK to SPI_CLK, CS to SPI_CS. // diff --git a/st7567/doc.go b/st7567/doc.go index 3fee807..46466d8 100644 --- a/st7567/doc.go +++ b/st7567/doc.go @@ -4,7 +4,7 @@ // Package st7567 implements an interface to the single-chip dot matrix LCD // -// Datasheet +// # Datasheet // // https://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7567.pdf package st7567 diff --git a/st7567/st7567.go b/st7567/st7567.go index d184f23..9e58648 100644 --- a/st7567/st7567.go +++ b/st7567/st7567.go @@ -241,7 +241,7 @@ func (rr *RegulationResistor) String() string { } } -//RegulationRatio selects the regulation resistor ratio +// RegulationRatio selects the regulation resistor ratio type RegulationRatio []RegulationResistor func (rrs *RegulationRatio) String() string { diff --git a/tlv493d/doc.go b/tlv493d/doc.go index b2bb21e..1819600 100644 --- a/tlv493d/doc.go +++ b/tlv493d/doc.go @@ -5,19 +5,20 @@ // Package tlv493d implements interfacing code to the Infineon TLV493D haff effect sensor. // // Features of the device: -// 3-dimensional hall effect sensor, measures up to +/-130 mT magnetic flux. -// temperature sensor -// i2c interface -// 12-bit resolution -// low power consumption +// +// 3-dimensional hall effect sensor, measures up to +/-130 mT magnetic flux. +// temperature sensor +// i2c interface +// 12-bit resolution +// low power consumption // // Features of the driver: -// Implemented all options of the device -// Power modes described in the documentation are defined as constants -// 2 precisions: high precision (12 bits), where all registers are read or low precision, which saves 50% of I2C bandwidth, but without temperature and only 8-bit resolution -// Continuous reading mode +// +// Implemented all options of the device +// Power modes described in the documentation are defined as constants +// 2 precisions: high precision (12 bits), where all registers are read or low precision, which saves 50% of I2C bandwidth, but without temperature and only 8-bit resolution +// Continuous reading mode // // Datasheet and application notes: // https://www.infineon.com/cms/en/product/sensor/magnetic-sensors/magnetic-position-sensors/3d-magnetics/tlv493d-a1b6/ -// package tlv493d diff --git a/tm1637/doc.go b/tm1637/doc.go index f675d52..5adf4b7 100644 --- a/tm1637/doc.go +++ b/tm1637/doc.go @@ -4,11 +4,11 @@ // Package tm1637 controls a TM1637 device over GPIO pins. // -// More details +// # More details // // See https://periph.io/device/tm1637/ for more details about the device. // -// Datasheet +// # Datasheet // // http://olimex.cl/website_MCI/static/documents/Datasheet_TM1637.pdf package tm1637 diff --git a/tm1637/tm1637.go b/tm1637/tm1637.go index 880d96c..e5233b2 100644 --- a/tm1637/tm1637.go +++ b/tm1637/tm1637.go @@ -99,11 +99,11 @@ func (d *Dev) SetBrightness(b Brightness) error { // P can be a dot or ':' following a digit. Otherwise it is likely // disconnected. Each byte is encoded as PGFEDCBA. // -// -A- -// F B -// -G- -// E C -// -D- P +// -A- +// F B +// -G- +// E C +// -D- P func (d *Dev) Write(seg []byte) (int, error) { if len(seg) > 6 { return 0, errors.New("tm1637: up to 6 segment groups are supported")