All Projects → OnionIoT → i2c-exp-driver

OnionIoT / i2c-exp-driver

Licence: AGPL-3.0 license
Driver to program I2C based Onion Expansions

Programming Languages

c
50402 projects - #5 most used programming language
javascript
184084 projects - #8 most used programming language
shell
77523 projects
Makefile
30231 projects
python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to i2c-exp-driver

source
Onion's fork of OpenWRT's source build system. The firmware for the Omega2, Omega2+, and Omega2 Pro is based on the openwrt-18.06 branch.
Stars: ✭ 73 (+121.21%)
Mutual labels:  omega2
cra-tailwindcss-in-js
Integrate Tailwind CSS in a Create React App setup using css-in-js solutions
Stars: ✭ 35 (+6.06%)
Mutual labels:  utility
kyanite
A small purely functional library of curried functions, with great piping possibilities!
Stars: ✭ 26 (-21.21%)
Mutual labels:  utility
gfx demo
GFX Demo for Arduino and the ESP-IDF
Stars: ✭ 63 (+90.91%)
Mutual labels:  i2c
mpu
Martins Python Utilities - Stuff that comes in Handy
Stars: ✭ 47 (+42.42%)
Mutual labels:  utility
gobot
Golang framework for robotics, drones, and the Internet of Things (IoT)
Stars: ✭ 7,869 (+23745.45%)
Mutual labels:  i2c
ios
CoThings's iOS application. CoThings is a realtime counter for shared things.
Stars: ✭ 13 (-60.61%)
Mutual labels:  utility
vl53l0x-linux
Library for interfacing with VL53L0X time-of-flight distance sensor under Linux
Stars: ✭ 19 (-42.42%)
Mutual labels:  i2c
adafruit-i2c-pwm-driver
Node.js implementation for the Adafruit 16-Channel 12-bit PWM/Servo Driver
Stars: ✭ 25 (-24.24%)
Mutual labels:  i2c
grizzly
Extra utilities for Bear 🐻
Stars: ✭ 20 (-39.39%)
Mutual labels:  utility
Quickeys
A mac menu bar app that provides note taking functionality though a quick dropdown menu.
Stars: ✭ 54 (+63.64%)
Mutual labels:  utility
TestCards
A simple test pattern generator.
Stars: ✭ 46 (+39.39%)
Mutual labels:  utility
goroutines
provides utilities to perform common tasks on goroutines
Stars: ✭ 19 (-42.42%)
Mutual labels:  utility
pe-util
List shared object dependencies of a portable executable (PE)
Stars: ✭ 45 (+36.36%)
Mutual labels:  utility
leak
Show info about package releases on PyPI.
Stars: ✭ 15 (-54.55%)
Mutual labels:  utility
Funky
Funky is a functional utility library written in Objective-C.
Stars: ✭ 41 (+24.24%)
Mutual labels:  utility
tableize
Turn lists into tables with ease
Stars: ✭ 12 (-63.64%)
Mutual labels:  utility
mik
The Move to Islandora Kit is an extensible PHP command-line tool for converting source content and metadata into packages suitable for importing into Islandora (or other digital repository and preservations systems).
Stars: ✭ 32 (-3.03%)
Mutual labels:  utility
gut
🍱 yet another collection of go utilities & tools
Stars: ✭ 24 (-27.27%)
Mutual labels:  utility
OP1GO
Ultraportable backups for Teenage Engineering's OP-1
Stars: ✭ 34 (+3.03%)
Mutual labels:  utility

i2c-exp-driver

Project for drivers to program Omega Expansions that are I2C-based.

ubus Integration

The drivers for the I2C-based Onion Expansions have been integrated with the ubus service via RPCD. They can be accessed through the i2c_exp service.

pwm-exp ubus Commands

The Servo Expansion can be programmed using the pwm-exp command in the i2c_exp ubus service:

ubus call i2c_exp pwm-exp '{"command":"String", "params": {"key": "value" } }'

The following commands are available:

  • init
  • sleep
  • set
  • set-period

Init Command

The init command will reset the chip on the Servo Expansion and enable the oscillator.

ubus call i2c_exp pwm-exp '{"command":"init"}'

Sleep Command

The sleep command will put the oscillator into sleep mode, disabling all PWM signals

ubus call i2c_exp pwm-exp '{"command":"sleep"}'

Set Command

The set command is used to generate a PWM signal on a specific channel based on a duty cycle percentage:

ubus call i2c_exp pwm-exp '{"command":"set", "params":{"channel":"<CHANNEL>", "duty":"<DUTY CYCLE>"} }'

The CHANNEL can be:

  • 0 - 15
    • control an individual channel
  • all
    • control all channels at once

The DUTY CYCLE can be an integer or floating point number between 0 and 100

Optional parameters:

  • "frequency":"<signal frequency>"
    • Sets the PWM signal frequency
    • If not specified, default of 50 Hz is used
    • Frequency range is 24 Hz to 1526 Hz
  • "delay":"<delay percentage>"
    • Adds a delay in the PWM signal, can be an integer or floating point number between 0 and 100
    • 0% delay by default

Set-Period Command

The set-period command is used to generate a PWM signal on a specific channel based on a PWM period and pulse width (both can be integer or floating point numbers):

ubus call i2c_exp pwm-exp '{"command":"set-period", "params":{"channel":9, "pulse":"1.5", "period":20}}'

relay-exp ubus Commands

The Relay Expansion can be programmed using the relay-exp command in the i2c_exp ubus service:

Set Command

The set command allows for programming the relay state:

ubus call i2c_exp relay-exp '{"command":"set", "params":{"channel":"<CHANNEL>", "state":"RELAY STATE", "address":"<ADDRESS>"}}'

The CHANNEL can be one of:

  • 0 - controls Relay0
  • 1 - controls Relay1
  • all - controls both relays

The RELAY STATE can be one of:

  • off - relay is switched off
  • on - relay is switched on

The ADDRESS argument can be either:

  • The DIP-SWITCH STATES
  • The Hex I2C device address

Dip Switch States

The DIP-SWITCH STATES should reflect the dip switch settings in binary starting with switch 1, then switch 2, then switch 3. The 0 position is when the switch is close the numbers.

Not required when all switches are 0.

Examples:

  • Switches 1 and 2 are 0 (close to the printed numbers), switch 3 is 1:
    • "address":"001"
  • Switches 1 and 3 are 1, switch 2 is 0:
    • "address":"101"
  • All switches are 1:
    • "address":"111"

I2C Device Address

The I2C Device Address should be just the hex address.

For example:

  • 0x27
  • 0x23

Get Command

The get command implements reading the current state of a relay:

ubus call i2c_exp relay-exp '{"command":"get", "params":{"channel":"<CHANNEL>", "address":"<ADDRESS>"}}'

The CHANNEL can be one of:

  • 0 - controls Relay0
  • 1 - controls Relay1

The ADDRESS argument can be either:

  • The DIP-SWITCH STATES
  • The Hex I2C device address

Dip Switch States

The DIP-SWITCH STATES should reflect the dip switch settings in binary starting with switch 1, then switch 2, then switch 3. The 0 position is when the switch is close the numbers.

Not required when all switches are 0.

Examples:

  • Switches 1 and 2 are 0 (close to the printed numbers), switch 3 is 1:
    • "address":"001"
  • Switches 1 and 3 are 1, switch 2 is 0:
    • "address":"101"
  • All switches are 1:
    • "address":"111"

I2C Device Address

The I2C Device Address should be just the hex address.

For example:

  • 0x27
  • 0x23

Return Values

The ubus call will return different values based on if the command was successful or not.

Successful Command:

{"status":"success", "channel":"<CHANNEL>, "state":"<RELAY STATE>"}

Unsuccessful Command:

{"status":"success", "error":"<INFO ON ERROR>"}

oled-exp ubus Commands

The OLED Expansion can be programmed using the oled-exp command in the i2c_exp ubus service:

Set Command

The only command is the set command, it allows the relays to be programmed:

ubus call i2c_exp relay-exp '{"command":"set", "option":"opt" "params":{"<COMMAND>":"<COMMAND PARAMETER>}}'

Options

Available options are

  • i
    • Initialize the display, this must be done at powerup
  • c
    • Clear the screen and set the cursor to the top left"

Example Usage:

  • Initialize the display
    • ubus call i2c_exp oled-exp '{"command":"set", "option":"i"}}'
  • Clear the display and then write Onion Omega to it
    • ubus call i2c_exp oled-exp '{"command":"set", "option":"c", "params":{"write":"Onion Omega"}}'

Commands

The following are the commands and their parameters as accepted by the oled-exp:

  • power <on|off>
  • invert <on|off>
  • dim <on|off>
  • cursor <row>,<column>
  • write <msg>
  • scroll <direction>
  • draw <lcd file>

Commands can be strung together!

Power

Turn the display on or off. Can be used to toggle the display after it has been initialized.

"params":{"power":"<on|off>"}
Invert

Invert black and white on the display. Setting to on will enable the invert, setting to off will disable the inversion.

"params":{"invert":"<on|off>"}
Dim

Enable dimming the display. Setting to on will dim the display, setting to off will restore the default brightness.

"params":{"dim":"<on|off>"}
Cursor

Set the cursor position on the display.

The row parameter represents each character row (8 pixel rows) on the display, so the range is 0 to 7

The column parameter represents each character column, the range is 0 to 20

"params":{"cursor":"<row>,<column>"}
Examples

Set the cursor to the start of the last character row:

"params":{"cursor":"7,0"}

Set the cursor to the middle of the 4th character row:

"params":{"cursor":"3,10"}

Set the cursor to the start of the 2nd character row:

"params":{"cursor":"1,0"}

Set the cursor to the top left (home position):

"params":{"cursor":"0,0"}
Write

Write a string to the display.

"params":{"write":"<message>"}
Notes

To get a newline on the display, need to write \\\\\n in the message.

For now, avoid the following characters:

  • "
  • '
Examples

Write Onion Omega to the display:

"params":{"write":"Onion Omega"}

Write Onion Corporation and then the office address on the lines below:

"params":{"write":"Onion Corporation\\\\\n187 Denison St\\\\\nMarkham, ON\\\\\nCanada\\\\\nL3R-1B5"}
Scroll

Enable scrolling of whatever is currently on the display.

"params":{"scroll":"<direction>"}
Directions

Available directions:

  • left
  • right
  • diagonal-left
  • diagonal-right
  • stop
    • To disable scrolling
Draw

Display an image from an LCD file on the display.

Details on LCD file: The LCD file must be generated by the Onion utility. For a 128x64 image, there should be 1024 bytes. Each byte is one character column (8 vertical pixels), with the LSB representing the top-most pixel.

"params":{"draw":"<path to lcd file>"}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].