Repository navigation
3. API: Enum Definition
waiweng83 edited this page Aug 11, 2015
·
5 revisions
These are the definition for the enumeration used in the API functions.
Error code returned from the external module API:
typedef enum __attribute__((packed)) {
EM_NO_ERROR = 0x0000,
EM_ERR_INPUT_VOLTAGE = 0x0001,
EM_ERR_ANGLE_LIMIT = 0x0002,
EM_ERR_OVERHEATING = 0x0004,
EM_ERR_TX_CHECKSUM = 0x0010,
EM_ERR_OVERLOAD = 0x0020,
EM_ERR_INSTRUCTION = 0x0040,
EM_ERR_RX_TIMEOUT = 0x0100,
EM_ERR_RX_HEADER = 0x0200,
EM_ERR_RX_ID = 0x0400,
EM_ERR_RX_CHECKSUM = 0x0800,
EM_ERR_TX_BUSY = 0x1000,
EM_ERR_INVALID_MODULE = 0x2000
} EM_ERROR;
External module model.
typedef enum __attribute__((packed)) {
EM_MODEL_NONE, // None.
EM_MODEL_IMU, // Althought IMU is not an external module, we put it here for easier grouping.
EM_MODEL_G15 = 0x470f, // G15.
EM_MODEL_IR = 0x4952, // Infrared sensor.
EM_MODEL_US = 0x5553, // Ultrasonic sensor.
EM_MODEL_HEAD = 0x484d, // Head Module.
EM_MODEL_HM_MIC, // Microphone on head module.
EM_MODEL_HM_IR, // Infrared sensor on head module.
EM_MODEL_TACTILE = 0x5453, // Tactile sensor.
EM_MODEL_COLOUR = 0x4353, // Colour sensor.
EM_MODEL_LINE = 0x4c53 // Line sensor.
} EM_MODEL;
Write mode.
typedef enum __attribute__((packed)) {
WRITE_NOW = 0x00, // Write to control table immediately.
WAIT_ACTION = 0x01 // Write to temporary register and wait for action command.
} EM_WRITE_MODE;
G15 Position Control Mode.
typedef enum __attribute__((packed)) {
NORMAL_POSITIONING = 0x0000,
DIRECTION_POSITIONING_CCW = 0x8000,
DIRECTION_POSITIONING_CW = 0xc000
} G15_POSITIONING_MODE;
G15 Speed Control Mode.
typedef enum __attribute__((packed)) {
POSITION_SPEED_CONTROL = 0x0000,
POSITION_TIME_CONTROL = 0x8000,
WHEEL_CCW = 0x0000,
WHEEL_CW = 0x0400
} G15_SPEED_CONTROL_MODE;
Colour sensor detected colour.
typedef enum __attribute__((packed)) {
CL_RED = 0,
CL_GREEN = 1,
CL_BLUE = 2,
CL_CYAN = 3,
CL_MAGENTA = 4,
CL_YELLOW = 5,
CL_WHITE = 6,
CL_ANY_COLOUR = 7,
CL_BLACK = 8
} CL_SENSOR_COLOUR;