Other Parts Discussed in Thread: DLP7000, DLPC410
Hi Team,
I hope you all are doing good.
Actually, I want to control DLP7000 with python. I have already a c++ script and it's really working fine for me with the *.h, *.lib and *.dll files they have already provided.
Now, I am trying to wrap c++ script into python, but it shows me some errors. When i am trying to create source.o file and source.dll file from source.cpp file it shows me errors of incompatibility and even sometimes it shows me that the functions (GetNumDev, GetDMDTYPE, SetBlkMd, SetNSFLIP, LoadControl) you have used in your source.cpp file are not defined.
Any one you ever tried to wrap c++ code into python for DLP or controlling it directly in python??
Any leads?
Code:
// #define STB_IMAGE_IMPLEMENTATION
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <stdint.h>
#include <cstdint>
#include <vector>
#include "D4100_usb.h"
#include "CyAPI.h"
#include "RegisterDefines.h"
#include "8055.D4100_usb.h"
#include "windows.h"
// #include "stb_image.h"
#pragma comment(lib, "D4100_usb.lib")
#pragma comment(lib, "6562.D4100_usb.lib")
using namespace USB;
using namespace std;
int main()
{
short numDevices = GetNumDev();
printf("NumDevices : \t\t%d\n", numDevices);
// std::cout << "Number of Devices Connected: " << numDevices << std::endl;
short DeviceNumber = numDevices - 1; // Only One device is connected.
short dmdType = GetDMDTYPE(DeviceNumber); // should be 1(DLP7000)
printf("DMD Type : \t\t%d\n", dmdType);
// std::cout << "DMD Type 0.7XGA connected: (1 = Yes, 0 = No, -1 = No USB Connected) " << dmdType << std::endl;
//// Just for Assertion ////
unsigned long driverrev = GetDriverRev(DeviceNumber);
unsigned long firmwarerev = GetFirmwareRev(DeviceNumber);
short usbspeed = GetUsbSpeed(DeviceNumber);
unsigned long dllRev = GetDLLRev();
unsigned long fpgaRev = GetFPGARev(DeviceNumber);
short ddcVersion = GetDDCVERSION(DeviceNumber);
printf("Driver Rev : \t\t0x%08X\n", driverrev);
printf("Firmware Rev : \t\t0x%08X\n", firmwarerev);
printf("USB Speed : \t\t%d\n", usbspeed);
printf("DLL Revision : \t\t0x%08X\n", dllRev);
printf("FPGA Revision: \t\t0x%08X\n", fpgaRev);
printf("DDC Version : \t\t0x%04X\n", ddcVersion);
///////////////////////////
SetWDT(0, DeviceNumber); // Watch Dog Timer (1 - Enable, 0 - Disable)
//x SetPWRFLOAT(0, DeviceNumber); // Disable Power Float - Keep this commented
SetTPGEnable(0, DeviceNumber); // Disable TestPatternGenerator with 0
char choice;
do {
cout << "Enter the filename of the bin file: ";
string filename;
getline(cin, filename); // user input
// Open the bin file
ifstream file(filename, ios::binary);
if (!file.is_open()) {
cerr << "Error: Unable to open file " << filename << "!" << endl;
return 1;
}
// Read the binary data into a buffer
const int width = 1024;
const int height = 768;
uint8_t rowData[width * height / 8];
file.read(reinterpret_cast<char*>(rowData), sizeof(rowData));
file.close();
SetBlkMd(0, DeviceNumber); // DMD Block Operations -- NOP
LoadControl(DeviceNumber); // DMD Block Operations -- Execute!
SetRowMd(3, DeviceNumber); // Set First row address (Default # 3) // 3 before
SetNSFLIP(0, DeviceNumber); // north south flip flag (0 = no flip, 1 = flip)
LoadControl(DeviceNumber); // Row Operations -- Execute!
SetRowMd(1, DeviceNumber); // Increment internal row address by 1 // 1 before
SetNSFLIP(0, DeviceNumber);
LoadControl(DeviceNumber); // Row Operations -- Execute!
ClearFifos(DeviceNumber); // Reset hardware receiving FIFO buffers and initialize DMD to take input
// LoadData(rowData, sizeof(rowData), dmdType, DeviceNumber); // Load pattern into the DMD.
LoadData(rowData, sizeof(rowData) / 2, dmdType, DeviceNumber); // Load 1st half of pattern into the DMD.
LoadData(rowData + sizeof(rowData) / 2, sizeof(rowData) / 2, dmdType, DeviceNumber); // Load last half of pattern into the DMD.
SetBlkMd(3, DeviceNumber); // DMD Block Operations -- Global Reset Request // 3 before
SetBlkAd(8, DeviceNumber); // BLK_AD=4'b10xx
LoadControl(DeviceNumber); // DMD Block Operations -- Execute!
cout<<"Do you want to add more files to load on DMD? (Y/N): ";
cin>>choice;
cin.ignore();
} while (choice == 'y' || choice == 'Y');
return 0;
}









