arduino / arduino/ArduinoCore-avr

Virtual Pins

Open
#1 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Virtualization of pins, allowing the environment to be extended with external pin over SPI or I²C and making them transparent to user and libraries.

This can be implemented on multiple ways:

1. Add an extra burden to the pinMode/digitalRead/digital by installing an
`if (pin>nr_of_digital_pins) «call virtual pins handler here»`
2. Extend the pin tables with a predefined set of allowed extra virtual pins, then the actual `if (port == NOT_A_PIN)` already present on the pin functions could be used to call the virtual pins handler with no extra burden to pin functions.

About the virtual pins handler, I suggest it to be **just** a function address (x3) pointing to a dumb function (just return). This way virtual pins would have only the extra 3 function pointers and a simple return function allowing it to be implemented as a library

All this can be conditionally compiled if there's a way of introducing preprocessor defines to the compiler environment (`-D` flag). However, there is not an easy way of doing that when using Arduino IDE.

Option 2 has the advantage of being compatible with code that checks the pin tables https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/Arduino.h#L177

I leave this to consideration and expect feedback of pros and cons before advancing.

I've done essays by extending the pin tables and they worked very well.

### Additional context

#### Related

- https://github.com/arduino/Arduino/issues/6207
- https://github.com/arduino/ArduinoCore-avr/issues/149

Contributor guide

No contributing guide indexed for this repository

Research direction

Begin with Arduino.h and the existing pin-table checks described in the issue, then review related issues #6207 and ArduinoCore-avr #149. A contribution first needs an agreed virtualization design; completion would mean implementing that agreed behavior while preserving compatibility with code that checks the pin tables.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, c
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.