Other mBuild Modules

The API functions described in this section are applicable to other mBuild electronic modules. Note: To use these functions, you need to purchase an add-on pack or kit that includes the corresponding mBuild electronic modules.

Omitting "halocode" from the code

Note: The word halocode is omitted from all the API functions described in this section. For example, led_driver.off() is actually halocode.led_driver.off(). All the functions of the mBuild electronic modules are maintained in the halocode library, and therefore it is recommended to omit halocode. from the code to simplify it.

from halocode import *


Common Parameter index

All API functions for mBuild electronic modules include the parameter index, which indicates the place of a module among the ones of the same type in the chain referred to by an API function. Generally, the default value is 1. Therefore, if only one module of each type is used in the chain, you don't need to set this parameter. When two or more modules of the same type are used in the chain, you need to set index to 2, 3, 4, or another number to specify the second, third, forth, or another module. For example, motor_driver.set(100, index = 2) indicates that the output power of the second motor driver is set to 100.

IR Remote

ir.send(message, index = 1) Sends an IR message.
Parameters:

  • message: character string with a maximum length of 30. Currently, only English characters, numbers, and punctuations are supported.

ir.receive(index = 1) Obtains the received IR message.
Returns a character string.

ir.record(record_id, index = 1) Records an IR message. This API function blocks the current thread for three seconds to complete the recording of the IR signal.
Parameters:

  • record_id: numeric value, indicating the serial number of an IR message. The setting range is 1 to 2. The IR remote module can record a maximum of two IR signals.

ir.send_record(record_id, index = 1) Sends the recorded IR message.
Parameters:

  • record_id: numeric value, indicating the serial number of an IR message. The setting range is 1 to 2. The IR remote module can record a maximum of two IR signals.

ir.is_receive(message, index = 1) Determines whether the IR remote module receives the specified IR signal.
Parameters:

  • message: character string or character string variable. The following table describes the available variables and their definitions.
    VariableDefinition
    IR_REMOTE.up
    IR_REMOTE.down
    IR_REMOTE.left
    IR_REMOTE.right
    IR_REMOTE.set Setting
    IR_REMOTE.zero 0
    IR_REMOTE.one 1
    IR_REMOTE.two 2
    IR_REMOTE.three 3
    IR_REMOTE.four 4
    IR_REMOTE.five 5
    IR_REMOTE.six 6
    IR_REMOTE.seven 7
    IR_REMOTE.eight 8
    IR_REMOTE.nine 9
    IR_REMOTE.A A
    IR_REMOTE.B B
    IR_REMOTE.C C
    IR_REMOTE.D D
    IR_REMOTE.E E
    IR_REMOTE.F F

results matching ""

    No results matching ""