mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Minor changes to avoid compilation errors in MSVC
This commit is contained in:
@@ -64,14 +64,14 @@ void UpdateDots( unsigned char * dots, unsigned int dotOffset )
|
||||
const int rate_reduction_divisor = 1;
|
||||
|
||||
loopCtr = dotOffset/rate_reduction_divisor;
|
||||
color = pow(2,kDMDSubFrames) - 1;
|
||||
color = (1 << kDMDSubFrames) - 1;
|
||||
byte_shifter = 0x80;
|
||||
|
||||
// Slow it down just a tad
|
||||
if (dotOffset%rate_reduction_divisor == 0)
|
||||
{
|
||||
// Set up byte_shifter to rotate pattern to the right.
|
||||
byte_shifter = pow(2,(loopCtr%8));
|
||||
byte_shifter = 1 << (loopCtr%8);
|
||||
|
||||
// Clear the DMD dots every time the rotation occurs
|
||||
memset(dots,0,((kDMDColumns*kDMDRows)/8)*kDMDSubFrames);
|
||||
@@ -91,13 +91,13 @@ void UpdateDots( unsigned char * dots, unsigned int dotOffset )
|
||||
{
|
||||
// Turn on the byte in each sub-frame that's enabled
|
||||
// active for the color code.
|
||||
if ((mappedColor >> subFrame) & 1 == 1)
|
||||
if (((mappedColor >> subFrame) & 1) == 1)
|
||||
dots[subFrame*(kDMDColumns*kDMDRows/8)+((row%kDMDRows)*(kDMDColumns / 8))+col] = byte_shifter;
|
||||
}
|
||||
}
|
||||
// Determine where to change the color in order to progress from row 0 = color 0
|
||||
// to the last row being the last color.
|
||||
if (row % (int)((kDMDRows/pow(2,kDMDSubFrames))) == 0) color--;
|
||||
if (row % (int)((kDMDRows/(1 << kDMDSubFrames))) == 0) color--;
|
||||
if (byte_shifter == 1) byte_shifter = 0x80;
|
||||
else byte_shifter = byte_shifter >> 1;
|
||||
}
|
||||
|
||||
@@ -89,8 +89,6 @@ void RunLoop(PRHandle proc)
|
||||
// Retrieve and store initial switch states.
|
||||
LoadSwitchStates(proc);
|
||||
|
||||
uint32_t rdBuffer[1];
|
||||
|
||||
if (machineType != kPRMachineWPCAlphanumeric) {
|
||||
// Send 3 frames
|
||||
for (i=0; i<3; i++)
|
||||
@@ -105,9 +103,6 @@ void RunLoop(PRHandle proc)
|
||||
{
|
||||
PRDriverWatchdogTickle(proc);
|
||||
|
||||
//PRReadData(proc, 5, 0, 1, rdBuffer);
|
||||
//printf("dmd config: %x\n",rdBuffer[0]);
|
||||
|
||||
int numEvents = PRGetEvents(proc, events, maxEvents);
|
||||
for (int i = 0; i < numEvents; i++)
|
||||
{
|
||||
@@ -120,8 +115,13 @@ void RunLoop(PRHandle proc)
|
||||
case kPREventTypeSwitchOpenNondebounced: stateText = "open(ndb)"; break;
|
||||
case kPREventTypeSwitchClosedNondebounced: stateText = "closed(ndb)"; break;
|
||||
}
|
||||
#ifdef _VC_
|
||||
struct _timeb tv;
|
||||
_ftime(&tv);
|
||||
#else
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
#endif
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
@@ -130,7 +130,11 @@ void RunLoop(PRHandle proc)
|
||||
case kPREventTypeSwitchOpenNondebounced:
|
||||
case kPREventTypeSwitchClosedNondebounced:
|
||||
{
|
||||
printf("%d.%03d switch % 3d: %s\n", tv.tv_sec-startTime, tv.tv_usec/1000, event->value, stateText);
|
||||
#ifdef _VC_
|
||||
printf("%d.%03d switch % 3d: %s\n", tv.time-startTime, tv.millitm, event->value, stateText);
|
||||
#else
|
||||
printf("%d.%03d switch % 3d: %s\n", (int)(tv.tv_sec-startTime), (int)tv.tv_usec/1000, event->value, stateText);
|
||||
#endif
|
||||
UpdateSwitchState( event );
|
||||
break;
|
||||
}
|
||||
@@ -148,7 +152,11 @@ void RunLoop(PRHandle proc)
|
||||
}
|
||||
}
|
||||
PRFlushWriteData(proc);
|
||||
#ifdef _VC_
|
||||
Sleep(10);
|
||||
#else
|
||||
usleep(10*1000); // Sleep for 10ms so we aren't pegging the CPU.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,23 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef _VC_
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include "../../include/pinproc.h" // Include libpinproc's header.
|
||||
#include <fstream>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef _VC_
|
||||
#include <time.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define kFlippersSection "PRFlippers"
|
||||
#define kBumpersSection "PRBumpers"
|
||||
|
||||
Reference in New Issue
Block a user