This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Add-On Resources

An Arduino® add-on library resource can exist only as a limited or single instance. Resources can be pins, properties, or add-on instances themselves. By specifying and acquiring resources in your add-on library, you protect the resource from being acquired or altered by another add-on. For example, a pin set by add-on library to act as an analog input must not be allowed to be changed to a digital output by another add-on library. Two types of resources exist for an add-on library: Counted and Shared

Counted

A counted resource is limited to certain number of instances due to pin usages or application constraints. The incrementResourceCount and decrementResourceCount enable you to increment and decrement the number or instances of the resource. When a counted resource increments, the next available resource is always taken in order. Similarly, when decremented, the last acquired resource is released.

For example, an LCD shield can be a counted resource since only one LCD shield can exist in MATLAB® at the same time.

Shared

A shared resource is used by multiple objects of the same class. In a shared resource, when any object modifies a property of that resource, the change is applied to all other objects that use the resource. To modify a shared resource, use the getSharedResourceProperty and setSharedResourceProperty functions.

For example, all instances of an add-on library class using a shared communication resource must set the properties of the bus to be the same. Once the first add-on library instance acquires the resource, any later instance must query and set the bus property to the same value as the first instance.

See Also

| | |

Related Topics