Hey,
Here is my code which I am using to structure my pattern sequence and send it to the DLC350. I am calling APIs in this block and then calling this block in the main.
I want to display 24 1-bit patterns in a sequence. I am using flash drive as the input source. My 24 bit image is stored at the index 3 of the flash drive.
I have a good idea about the structure of my code, but when I am running it my code is not displaying the patterns and not showing sequence running in the status.
Can someone have a look at my code and tell me what I am doing wrong. I understand that it a bit of a work to read my code, however it will be a great help if someone can give me a feedback.
Thanks
Aamir
void LCr_StructuredLightMode()
{
printf("LCr_StructuredLightMode\n");
LCR_LoadSplash(3);
LutEntry LutEntries[] = {
{
1, // int TrigType
0, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
1, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
2, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
3, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
4, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
5, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
6, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
7, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
8, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
9, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
10, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
11, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
12, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.RedOnly) ? 1 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
13, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
14, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
15, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
16, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.GreenOnly) ? 2 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
17, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
18, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
19, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
20, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
21, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
22, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
},
{
3, // int TrigType
23, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
false, // bool InsertBlack
true, // bool BufSwap
false // bool trigOutPrev))
}
/* {
3, // int TrigType
24, // int PatNum
1, // int BitDepth
(GlobalOptions.RGB || GlobalOptions.BlueOnly) ? 4 : GlobalOptions.Grayscale ? 7 : 0, // int LEDSelect
false, // bool InvertPat
true, // bool InsertBlack
false, // bool BufSwap
false // bool trigOutPrev))
}*/
};
int NumberOfLutEntries = (sizeof(LutEntries) / sizeof(LutEntry));
// Verify LUT entries by printing it
for (int ii = 0; ii < 24; ii++)
{
printf("LutEntries: %d\n", LutEntries[ii].TrigType);
printf("LutEntries: %d\n", LutEntries[ii].PatNum);
printf("LutEntries: %d\n", LutEntries[ii].BitDepth);
printf("LutEntries: %d\n", LutEntries[ii].InvertPat);
printf("LutEntries: %d\n", LutEntries[ii].InsertBlack);
printf("LutEntries: %d\n", LutEntries[ii].BufSwap);
printf("LutEntries: %d\n", LutEntries[ii].trigOutPrev);
printf("---------------------------\n");
}
if (LCR_SetMode(true) < 0) // Pattern display mode
{
printf("Error LCR_SetMode\n");
return;
}
if (LCR_PatternDisplay(0) < 0) // Stop Pattern Display
{
printf("Error LCR_PatternDisplay\n");
return;
}
if (LCR_SetInputSource(2, 1) < 0) // Flash, 24 bit
{
printf("Error LCR_SetInputSource\n");
return;
}
if (LCR_SetPatternDisplayMode(false) < 0) // Splash Memeory
{
printf("Error LCR_SetPatternDisplayMode\n");
return;
}
LCR_ClearPatLut();
for (int j = 0; j < NumberOfLutEntries; j++)
{
if (LCR_AddToPatLut(
LutEntries[j].TrigType,
LutEntries[j].PatNum,
LutEntries[j].BitDepth,
LutEntries[j].LEDSelect,
LutEntries[j].InvertPat,
LutEntries[j].InsertBlack,
LutEntries[j].BufSwap,
LutEntries[j].trigOutPrev
) < 0)
{
printf("Error LCR_AddToPatLut for index: %d\n", j);
return;
}
printf("Pointer id: %d\n", &LutEntries[j]); // priniting memory addresses of member of LUT table
}
if (LCR_SetPatternConfig(
NumberOfLutEntries /*numLutEntries*/,
1 /*repeat*/,
NumberOfLutEntries /*numPatsForTrigOut2*/,
1 /*numSplashLutEntries*/) < 0)
{
printf("Error LCR_SetPatternConfig\n");
return;
}
if (LCR_SetExposure_FramePeriod(EXPOSURE_PERIOD /*unsigned int exposurePeriod*/, FRAME_PERIOD /*unsigned int framePeriod*/) < 0)
{
printf("Error LCR_SetExposure_FramePeriod\n");
return;
}
if (LCR_SetPatternTriggerMode(1) < 0) // Internal triggers pattern
{
printf("Error Sending trigger Mode\n");
return;
}
if (LCR_SendPatLut() < 0)
{
printf("Error LCR_SendPatLut\n");
return;
}
unsigned char splashLut[1];
printf("splashLut: %d\n", &splashLut[0]+45); // Memory offset of 45 with the mem address of LutEntries[1]
if (LCR_SendSplashLut(&splashLut[0]+45, 24) < 0)
{
printf("Error Sending Image LUT");
return;
}
unsigned int status;
if (LCR_ValidatePatLutData(&status) < 0)
{
printf("Error validating LUT data\n");
return;
}
if (LCR_PatternDisplay(2) < 0) //Start pattern display
{
printf("Error starting pattern display\n");
return;
}
}