Some parameter tests added.
This commit is contained in:
parent
ddd6c713f5
commit
0988f91b42
2 changed files with 19 additions and 0 deletions
|
@ -14,3 +14,7 @@
|
||||||
|
|
||||||
#define SUCCESSFULLY_CONNECTED 1
|
#define SUCCESSFULLY_CONNECTED 1
|
||||||
|
|
||||||
|
#define PARAMETER_FRAME_OUT_OF_RANGE -10
|
||||||
|
#define PARAMETER_DELAY_OUT_OF_RANGE -20
|
||||||
|
#define PARAMETER_INDEX_OUT_OF_RANGE -30
|
||||||
|
#define PARAMETER_MODE_OUT_OF_RANGE -40
|
||||||
|
|
|
@ -21,6 +21,9 @@ int lc_setFrame(unsigned long frame)
|
||||||
if (_lc_handle == NULL)
|
if (_lc_handle == NULL)
|
||||||
return NOT_CONNECTED_ERROR;
|
return NOT_CONNECTED_ERROR;
|
||||||
|
|
||||||
|
if (frame < 0 || frame > 0xffffffff)
|
||||||
|
return PARAMETER_FRAME_OUT_OF_RANGE;
|
||||||
|
|
||||||
int low = frame & 0xffff;
|
int low = frame & 0xffff;
|
||||||
int high = (frame & 0xffff0000) >> 16;
|
int high = (frame & 0xffff0000) >> 16;
|
||||||
|
|
||||||
|
@ -39,6 +42,9 @@ int lc_setMode(int mode)
|
||||||
if (_lc_handle == NULL)
|
if (_lc_handle == NULL)
|
||||||
return NOT_CONNECTED_ERROR;
|
return NOT_CONNECTED_ERROR;
|
||||||
|
|
||||||
|
if (mode < MODE_ANIMATION_STOP || mode > MODE_ANIMATION_LOOP)
|
||||||
|
return PARAMETER_MODE_OUT_OF_RANGE;
|
||||||
|
|
||||||
return usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_MODE, mode, 0, _lc_buffer, 0, 300);
|
return usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_MODE, mode, 0, _lc_buffer, 0, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +59,15 @@ int lc_saveFrame(unsigned long frame, int delay, int index)
|
||||||
if (_lc_handle == NULL)
|
if (_lc_handle == NULL)
|
||||||
return NOT_CONNECTED_ERROR;
|
return NOT_CONNECTED_ERROR;
|
||||||
|
|
||||||
|
if (frame < 0 || frame > 0xffffffff)
|
||||||
|
return PARAMETER_FRAME_OUT_OF_RANGE;
|
||||||
|
|
||||||
|
if (delay < 0 || delay > 31)
|
||||||
|
return PARAMETER_DELAY_OUT_OF_RANGE;
|
||||||
|
|
||||||
|
if (index < 0 || index > 31)
|
||||||
|
return PARAMETER_INDEX_OUT_OF_RANGE;
|
||||||
|
|
||||||
frame = frame + (delay << 27);
|
frame = frame + (delay << 27);
|
||||||
|
|
||||||
lc_setFrame(frame);
|
lc_setFrame(frame);
|
||||||
|
|
Loading…
Reference in a new issue