void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    if (nrhs < 1 || nrhs > 1)
    {
        mexErrMsgIdAndTxt("lcr:usage", "Usage: lcrSetPatternDisplayMode(external)");
        return;
    }
    
    bool external = mxGetScalar(prhs[0]);
    
    int result = LCR_SetPatternDisplayMode(external);
    if (result == -1)
    {
        mexErrMsgIdAndTxt("lcr:failedToSetPatternDisplayMode", "Failed to set pattern display mode");
        return;
    }
}
Example #2
0
ProjectorLC4500::ProjectorLC4500(unsigned int): nPatterns(0), isRunning(false){

    std::cout << "ProjectorLC4500: preparing LightCrafter 4500 for duty... " << std::endl;

    // Initialize usb connection
    if(USB_Init()){
        showError("Could not init USB!");
    }
    if(USB_Open()){
        showError("Could not connect!");
    }
    if(!USB_IsConnected()){
        showError("Could not connect.");
    }
//    unsigned char HWStatus, SysStatus, MainStatus;
//    while(LCR_GetStatus(&HWStatus, &SysStatus, &MainStatus) != 0){
//        std::cout << ".";
//        continue;
//    }

    // Make sure LC is not in standby
    const bool standby = false;
    if(!LCR_SetPowerMode(standby)){
        showError("Error Setting Power Mode");
    }

    // Set LED selection
    const bool SeqCtrl  = true; // manual (false) or automatic (true)
    const bool LEDRed  = true;
    const bool LEDGreen  = false;
    const bool LEDBlue  = false;
    LCR_SetLedEnables(SeqCtrl, LEDRed, LEDGreen,  LEDBlue);

    // Set LED currents
    const unsigned char RedCurrent = 90;
    const unsigned char GreenCurrent = 0;
    const unsigned char BlueCurrent = 0;
    LCR_SetLedCurrents(255-RedCurrent, 255-GreenCurrent, 255-BlueCurrent);

    unsigned char Red;
    unsigned char Green;
    unsigned char Blue;
    LCR_GetLedCurrents(&Red, &Green, &Blue);

    // Set to pattern sequence mode
    const bool patternSequenceMode = true;
    if(!LCR_SetMode(patternSequenceMode)){
        showError("Error Setting Mode");
    }
        
    // Clear pattern LUT
    LCR_ClearPatLut();
    
    const int bitDepth = 8;
    const int ledSelect = 1;
    bool invertPattern = false;

    //int LCR_AddToPatLut(int TrigType, int PatNum,int BitDepth,int LEDSelect,bool InvertPat, bool InsertBlack,bool BufSwap, bool trigOutPrev)
    // 2 x 8.333 exposures of the 2x3 psp pattern
    LCR_AddToPatLut(0, 1, bitDepth, ledSelect, invertPattern, false, true, false);
    LCR_AddToPatLut(3, 1, bitDepth, ledSelect, invertPattern, true, false, true);
    LCR_AddToPatLut(0, 0, bitDepth, ledSelect, invertPattern, false, false, false);
    LCR_AddToPatLut(3, 0, bitDepth, ledSelect, invertPattern, true, false, true);
    LCR_AddToPatLut(0, 2, bitDepth, ledSelect, invertPattern, false, false, false);
    LCR_AddToPatLut(3, 2, bitDepth, ledSelect, invertPattern, true, false, true);

    LCR_AddToPatLut(0, 1, bitDepth, ledSelect, invertPattern, false, true, false);
    LCR_AddToPatLut(3, 1, bitDepth, ledSelect, invertPattern, true, false, true);
    LCR_AddToPatLut(0, 0, bitDepth, ledSelect, invertPattern, false, false, false);
    LCR_AddToPatLut(3, 0, bitDepth, ledSelect, invertPattern, true, false, true);
    LCR_AddToPatLut(0, 2, bitDepth, ledSelect, invertPattern, false, false, false);
    LCR_AddToPatLut(3, 2, bitDepth, ledSelect, invertPattern, true, false, true);

    // Set to internal flash source
    const bool patternDisplayMode = false;
    LCR_SetPatternDisplayMode(patternDisplayMode);

    LCR_SetPatternConfig(12, true, 12, 2);

    LCR_SetExpsosure_FramePeriod(16666, 16666);

    // Internal trigger
    const bool patternTriggerMode = true;
    LCR_SetPatternTriggerMode(patternTriggerMode);

    if(LCR_SendPatLut() < 0)
        showError("Error Sending Pattern LUT");

    unsigned char splashLutEntries[] = {3, 4};
    unsigned int numEntries = 2;
    LCR_SendSplashLut(splashLutEntries, numEntries);

    unsigned int status;
    if(LCR_ValidatePatLutData(&status) < 0)
        showError("Error validating LUT data");

    // Set trigger signal configuration
    LCR_SetTrigOutConfig(1, true, 0, 0);

}