Other Parts Discussed in Thread: DLPC150
Tool/software: Code Composer Studio
The DLPNIRscanNano works and now we want to send self-generated patterns to the DMD so that we can compare several NIRscanNanos with each other.
We know that the actual pattern generation takes place in the dlpspececlib. To understand how to generate a pattern we have looked at the column generation. Especially at the moment the file "dlpspec_scan_col.c" with the function "dlpspec_scan_col_genPatterns". Now we have some questions:
- Where is the value for numPatterns generated? Is it the Digital Resolution from the GUI?
- Are the patterns merged to buffers (16 or 24) for better handling or what does patterns_per_image mean?
- Is it possible (is there already) to store patterns on the SD card and use them?
- And we have one last question for now. Did we understand the procedure correctly? First the patterns are generated, then they are bent. Then x measurements are carried out and then the patterns are applied?
Best regards
Michael
int32_t dlpspec_scan_col_genPatterns(const patDefCol *patDefCol, const FrameBufferDescriptor *pFB, uint32_t startPattern) /** * @brief Function to generate patterns for a column scan. * * This function takes the column pattern definition an writes the described * patterns to the frame buffer described in the frame buffer descriptor. * * @param[in] patDefCol Pointer to column pattern definition * @param[in] pFB Pointer to frame buffer descriptor where the * patterns will be stored * @param[in] startPattern Pattern number at which to start drawing * * @return >0 Number of binary patterns generated from the pattern definition * @return ≤0 Error code as #DLPSPEC_ERR_CODE */ { int i; RectangleDescriptor rect; int curPattern; int patterns_per_image; uint32_t curBuffer=0; int frameBufferSz = (pFB->width * pFB->height * (pFB->bpp/8)); FrameBufferDescriptor frameBuffer; if ((patDefCol == NULL) || (pFB == NULL)) return (ERR_DLPSPEC_NULL_POINTER); memcpy(&frameBuffer, pFB, sizeof(FrameBufferDescriptor)); if(frameBuffer.bpp == 16) patterns_per_image=16; else patterns_per_image=24; /* Depending on startPattern, skip N buffers */ curBuffer = startPattern/patterns_per_image; frameBuffer.frameBuffer += ((frameBufferSz/4)*curBuffer); curPattern = startPattern - curBuffer*patterns_per_image; for(i=0; i < patDefCol->numPatterns; i++) { if(curPattern % patterns_per_image == 0) { //First clear the area of interest rect.startX = 0; rect.startY = 0; rect.height = frameBuffer.height; rect.width = frameBuffer.width; rect.pixelVal = 0; DrawRectangle(&rect, &frameBuffer, true); } //Guard against rectangles drawn out of the left bound of the frame if((patDefCol->colMidPix[i] - patDefCol->colWidth/2) < 0) rect.startX = 0; else rect.startX = patDefCol->colMidPix[i] - patDefCol->colWidth/2; rect.startY = 0; rect.height = frameBuffer.height; //Guard against rectangles drawn out of the right bound of the frame if((rect.startX + patDefCol->colWidth) > pFB->width) rect.width = pFB->width - rect.startX; else rect.width = patDefCol->colWidth; rect.pixelVal = 1 << (curPattern%patterns_per_image); DrawRectangle(&rect, &frameBuffer, false); curPattern++; if(curPattern % patterns_per_image == 0) { //Advance frame buffer pointer frameBuffer.frameBuffer += frameBufferSz/4; curBuffer++; if(curBuffer == frameBuffer.numFBs) break; } } return (patDefCol->numPatterns); }