I am writing a program to control a flashbulb. The flash fires in response to a key press by the user. I am trying to limit the occurence regularity of the flash to prevent the bulb burning out. I have already received some help from this forum, but am unable to implement the code with my own. A user suggested using a class, as follows:
class bulb
{
__int64 clocks;
__int64 frequency;
public:
bulb()
{
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
frequency = li.QuadPart;
clocks = 0;
}
void WINAPI flash (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
// If this is the first occurence, set the 'clocks' to system time (+10000 to allow flash to occur)
if (clocks == 0) clocks = li.QuadPart + 10000;
__int64 timepassed = clocks - li.QuadPart;
if (timepassed >= (((double)frequency) / 10000))
{
//Set the clock
clocks = li.QuadPart;
//Define the serial port procedure
HANDLE hSerial;
//Open the serial port (fire the flash)
hSerial = CreateFile("COM1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
//Close the serial port
CloseHandle(hSerial);
}
}
};
I receive a few syntax errors that I can't seem to shift, all of which are at either the first or last bracket of the class - "syntax error : identifier 'bulb'", "syntax error : ';'", "syntax error : '}'" and "syntax error : '}'". I have never worked with classes before though, so expect this is something to do with that. Where am I going wrong?
Please note '10000' is the minimum delay between flashes.