-
Notifications
You must be signed in to change notification settings - Fork 1
c_allocators
The header ftalloc.h defines functions to allocate and free devices and a few utility functions. The devices' main functionality is defined in the ftop.h header.
Note: In case of an error, all allocator functions return NULL! It is advisable to check the returned pointer before continuing.
#include <ft/ft.h>
fttxt2 *txt = ftop_alloc_txt("auto", 65000);
if (txt == NULL) {
// error during initialization of the TXT
// handle error
return 1;
}
Allocates the resourses for a TXT 4.0 object and initializes it. The object needs to be deleted using ftop_free_txt before the program ends to free resourses! As of now, the parameteres for host and port are unused.
Type | Parameter | Description |
---|---|---|
in | host | sting describing host, use "auto" (unused) |
in | port | port (unused) |
Return:
pointer to TXT object
Allocates the resources for a switch device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to switch object
Allocates the resources for a digital device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to digital object
Allocates the resources for a resistor device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to resistor object
Allocates the resources for a voltmeter device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to voltmeter object
Allocates the resources for an ultrasonic device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to ultrasonic object
Allocates the resources for a ncttermistor device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to ncttermistor object
Allocates the resources for a colorsensor device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to colorsensor object
Allocates the resources for a trail follower device.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_i1 - ftdev_i8] |
Return:
pointer to trail follower object
Allocates the resources for a counter device.
Note: Use the values from the ftobjects_connection enum (ftdev_c1 - ftdev_c4) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_c1 - ftdev_c4] |
Return:
pointer to counter object
Allocates the resources for a lamp device.
Note: Use the values from the ftobjects_connection enum (ftdev_o1 - ftdev_o8) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_o1 - ftdev_o8] |
Return:
pointer to lamp object
Allocates the resources for a servo device.
Note: Use the values from the ftobjects_connection enum (ftdev_s1 - ftdev_s3) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_s1 - ftdev_s3] |
Return:
pointer to servo object
Allocates the resources for a motor device.
Note: Use the values from the ftobjects_connection enum (ftdev_m1 - ftdev_m4) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_m1 - ftdev_m4] |
Return:
pointer to motor object
Allocates the resources for an encoder device including the corresponding counter.
Note: Use the values from the ftobjects_connection enum (ftdev_m1 - ftdev_m4) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_m1 - ftdev_m4] |
Return:
pointer to encoder object
Allocates the resources for a counter associated with an encoder motor. This function is mainly for internal purposes and usually not called by the user.
Note: Use the values from the ftobjects_connection enum (ftdev_c1 - ftdev_c4) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number [ftdedv_c1 - ftdev_c4] |
Return:
pointer to counter object
Deallocates the TXT object and frees all resources. This function MUST be called before the program ends.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
Frees all resources and resets connection used by device.
Type | Parameter | Description |
---|---|---|
in | devicd | pointer to device |
Returns the mode of the device. For universal inputs, this function returns the combination of measurement mode and resolution and for outputs/motors the output configuration (whether it's an output or a motor).
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8, ftdev_o1 - ftdev_o8, ftdev_m1 - ftdev_m4) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number |
Return:
allocation mode
Returns the type of the device. For universal inputs, this function returns the sensor type and for outputs/motors their type as well.
Note: Use the values from the ftobjects_connection enum (ftdev_i1 - ftdev_i8, ftdev_o1 - ftdev_o8, ftdev_m1 - ftdev_m4) to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number |
Return:
allocation code (device type)
Returns whether or not a device is allocated for that connector.
Note: Use the values from the ftobjects_connection enum to specify the pin.
Type | Parameter | Description |
---|---|---|
in | txt | pointer to TXT object |
in | num | pin number |
Return:
pin usage
Returns the connector number of given device.
Type | Parameter | Description |
---|---|---|
in | device | pointer to device |
Return:
pin number
Returns the type name as a string. Takes the device type returned by ftop_alloc_code as input.
Type | Parameter | Description |
---|---|---|
in | t | device type |
Return:
device name
Sets an input to normal or extended range. Pass 0 for normal detection range (0 - 5 V) and 1 for extended range (0 - 9 V).
Type | Parameter | Description |
---|---|---|
in | device | pointer to device |
in | mode | new mode: 0 (normal) - 1 (extended) |
Returns TXT object the device is connected.
Type | Parameter | Description |
---|---|---|
in | device | pointer to device |
Return:
pointer to TXT object