mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Merged in from master.
This commit is contained in:
@@ -11,17 +11,17 @@ PRBumpers:
|
|||||||
- slingR
|
- slingR
|
||||||
PRSwitches:
|
PRSwitches:
|
||||||
flipperLwR:
|
flipperLwR:
|
||||||
number: 1
|
number: SF2
|
||||||
flipperLwL:
|
flipperLwL:
|
||||||
number: 3
|
number: SF4
|
||||||
flipperUpR:
|
flipperUpR:
|
||||||
number: 5
|
number: SF6
|
||||||
flipperUpL:
|
flipperUpL:
|
||||||
number: 7
|
number: SF8
|
||||||
slingL:
|
slingL:
|
||||||
number: 96
|
number: S34
|
||||||
slingR:
|
slingR:
|
||||||
number: 97
|
number: S35
|
||||||
PRCoils:
|
PRCoils:
|
||||||
flipperLwRMain:
|
flipperLwRMain:
|
||||||
number: 32
|
number: 32
|
||||||
@@ -40,19 +40,17 @@ PRCoils:
|
|||||||
flipperUpLHold:
|
flipperUpLHold:
|
||||||
number: 39
|
number: 39
|
||||||
slingL:
|
slingL:
|
||||||
number: 50
|
number: C11
|
||||||
slingR:
|
slingR:
|
||||||
number: 49
|
number: C10
|
||||||
shooterDiverter:
|
|
||||||
number: 55
|
|
||||||
outhole:
|
|
||||||
number: 47
|
|
||||||
ballRelease:
|
|
||||||
number: 48
|
|
||||||
rocketKicker:
|
|
||||||
number: 41
|
|
||||||
slotKickout:
|
slotKickout:
|
||||||
number: 40
|
number: C01
|
||||||
|
rocketKickout:
|
||||||
|
number: C02
|
||||||
|
outhole:
|
||||||
|
number: C08
|
||||||
|
ballRelease:
|
||||||
|
number: C09
|
||||||
PRLamps:
|
PRLamps:
|
||||||
doorTheCamera:
|
doorTheCamera:
|
||||||
number: 80
|
number: L11
|
||||||
@@ -100,3 +100,4 @@ void UpdateDots( unsigned char * dots, unsigned int dotOffset )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "pinproctest.h"
|
#include "pinproctest.h"
|
||||||
|
|
||||||
|
PRMachineType machineType = kPRMachineInvalid;
|
||||||
|
|
||||||
/** Demonstration of the custom logging callback. */
|
/** Demonstration of the custom logging callback. */
|
||||||
void TestLogger(PRLogLevel level, const char *text)
|
void TestLogger(PRLogLevel level, const char *text)
|
||||||
@@ -84,6 +85,9 @@ void RunLoop(PRHandle proc)
|
|||||||
unsigned char dots[4*((128*32)/8)];
|
unsigned char dots[4*((128*32)/8)];
|
||||||
unsigned int dotOffset = 0;
|
unsigned int dotOffset = 0;
|
||||||
|
|
||||||
|
// Retrieve and store initial switch states.
|
||||||
|
LoadSwitchStates(proc);
|
||||||
|
|
||||||
while (runLoopRun)
|
while (runLoopRun)
|
||||||
{
|
{
|
||||||
PRDriverWatchdogTickle(proc);
|
PRDriverWatchdogTickle(proc);
|
||||||
@@ -107,6 +111,7 @@ void RunLoop(PRHandle proc)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
printf("%d.%03d switch % 3d: %s\n", tv.tv_sec-startTime, tv.tv_usec/1000, event->value, stateText);
|
printf("%d.%03d switch % 3d: %s\n", tv.tv_sec-startTime, tv.tv_usec/1000, event->value, stateText);
|
||||||
|
UpdateSwitchState( event );
|
||||||
}
|
}
|
||||||
PRFlushWriteData(proc);
|
PRFlushWriteData(proc);
|
||||||
usleep(10*1000); // Sleep for 10ms so we aren't pegging the CPU.
|
usleep(10*1000); // Sleep for 10ms so we aren't pegging the CPU.
|
||||||
@@ -143,7 +148,6 @@ int main(int argc, const char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRMachineType machineType = kPRMachineInvalid;
|
|
||||||
std::string machineTypeString;
|
std::string machineTypeString;
|
||||||
yamlDoc["PRGame"]["machineType"] >> machineTypeString;
|
yamlDoc["PRGame"]["machineType"] >> machineTypeString;
|
||||||
if (machineTypeString == "wpc")
|
if (machineTypeString == "wpc")
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ void ConfigureDrivers(PRHandle proc, PRMachineType machineType, YAML::Node& yaml
|
|||||||
|
|
||||||
void ConfigureSwitches(PRHandle proc, YAML::Node& yamlDoc);
|
void ConfigureSwitches(PRHandle proc, YAML::Node& yamlDoc);
|
||||||
void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc);
|
void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc);
|
||||||
|
void UpdateSwitchState (PREvent * event);
|
||||||
|
void LoadSwitchStates (PRHandle proc);
|
||||||
|
|
||||||
void ConfigureDMD(PRHandle proc);
|
void ConfigureDMD(PRHandle proc);
|
||||||
void UpdateDots(unsigned char * dots, unsigned int dotOffset);
|
void UpdateDots(unsigned char * dots, unsigned int dotOffset);
|
||||||
|
|||||||
@@ -24,6 +24,14 @@
|
|||||||
*/
|
*/
|
||||||
#include "pinproctest.h"
|
#include "pinproctest.h"
|
||||||
|
|
||||||
|
extern PRMachineType machineType;
|
||||||
|
|
||||||
|
typedef struct SwitchStatus {
|
||||||
|
PREventType state;
|
||||||
|
uint32_t lastEventTime;
|
||||||
|
} SwitchStatus;
|
||||||
|
|
||||||
|
static SwitchStatus switches[kPRSwitchPhysicalLast + 1];
|
||||||
|
|
||||||
void ConfigureSwitches(PRHandle proc, YAML::Node& yamlDoc)
|
void ConfigureSwitches(PRHandle proc, YAML::Node& yamlDoc)
|
||||||
{
|
{
|
||||||
@@ -36,6 +44,13 @@ void ConfigureSwitches(PRHandle proc, YAML::Node& yamlDoc)
|
|||||||
switchConfig.pulsesPerBurst = 6;
|
switchConfig.pulsesPerBurst = 6;
|
||||||
switchConfig.pulseHalfPeriodTime = 13; // milliseconds
|
switchConfig.pulseHalfPeriodTime = 13; // milliseconds
|
||||||
PRSwitchUpdateConfig(proc, &switchConfig);
|
PRSwitchUpdateConfig(proc, &switchConfig);
|
||||||
|
|
||||||
|
// Go through the switches array and reset the current status of each switch
|
||||||
|
for (int i = 0; i <= kPRSwitchPhysicalLast; i++)
|
||||||
|
{
|
||||||
|
switches[i].state = kPREventTypeInvalid;
|
||||||
|
switches[i].lastEventTime = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureWPCFlipperSwitchRule (PRHandle proc, int swNum, int mainCoilNum, int holdCoilNum, int pulseTime)
|
void ConfigureWPCFlipperSwitchRule (PRHandle proc, int swNum, int mainCoilNum, int holdCoilNum, int pulseTime)
|
||||||
@@ -83,15 +98,16 @@ void ConfigureBumperRule (PRHandle proc, int swNum, int coilNum, int pulseTime)
|
|||||||
void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc)
|
void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc)
|
||||||
{
|
{
|
||||||
// WPC Flippers
|
// WPC Flippers
|
||||||
|
std::string numStr;
|
||||||
const YAML::Node& flippers = yamlDoc[kFlippersSection];
|
const YAML::Node& flippers = yamlDoc[kFlippersSection];
|
||||||
for (YAML::Iterator flippersIt = flippers.begin(); flippersIt != flippers.end(); ++flippersIt)
|
for (YAML::Iterator flippersIt = flippers.begin(); flippersIt != flippers.end(); ++flippersIt)
|
||||||
{
|
{
|
||||||
int swNum, coilMain, coilHold;
|
int swNum, coilMain, coilHold;
|
||||||
std::string flipperName;
|
std::string flipperName;
|
||||||
*flippersIt >> flipperName;
|
*flippersIt >> flipperName;
|
||||||
yamlDoc[kSwitchesSection][flipperName][kNumberField] >> swNum;
|
yamlDoc[kSwitchesSection][flipperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str());
|
||||||
yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> coilMain;
|
yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> numStr; coilMain = PRDecode(machineType, numStr.c_str());
|
||||||
yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField] >> coilHold;
|
yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField] >> numStr; coilHold = PRDecode(machineType, numStr.c_str());
|
||||||
ConfigureWPCFlipperSwitchRule (proc, swNum, coilMain, coilHold, kFlipperPulseTime);
|
ConfigureWPCFlipperSwitchRule (proc, swNum, coilMain, coilHold, kFlipperPulseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +118,48 @@ void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc)
|
|||||||
// WPC Slingshots
|
// WPC Slingshots
|
||||||
std::string bumperName;
|
std::string bumperName;
|
||||||
*bumpersIt >> bumperName;
|
*bumpersIt >> bumperName;
|
||||||
yamlDoc[kSwitchesSection][bumperName][kNumberField] >> swNum;
|
yamlDoc[kSwitchesSection][bumperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str());
|
||||||
yamlDoc[kCoilsSection][bumperName][kNumberField] >> coilNum;
|
yamlDoc[kCoilsSection][bumperName][kNumberField] >> numStr; coilNum = PRDecode(machineType, numStr.c_str());
|
||||||
ConfigureBumperRule (proc, swNum, coilNum, kBumperPulseTime);
|
ConfigureBumperRule (proc, swNum, coilNum, kBumperPulseTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateSwitchState( PREvent * event )
|
||||||
|
{
|
||||||
|
switches[event->value].state = event->type;
|
||||||
|
switches[event->value].lastEventTime = event->time;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadSwitchStates( PRHandle proc )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
PREventType procSwitchStates[kPRSwitchPhysicalLast + 1];
|
||||||
|
|
||||||
|
// Get all of the switch states from the P-ROC.
|
||||||
|
if (PRSwitchGetStates( proc, procSwitchStates, kPRSwitchPhysicalLast + 1 ) == kPRFailure)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: Unable to retrieve switch states\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Copy the returning states into the local switches array.
|
||||||
|
for (i = 0; i <= kPRSwitchPhysicalLast; i++)
|
||||||
|
{
|
||||||
|
switches[i].state = procSwitchStates[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
int zero = 0;
|
||||||
|
fprintf(stderr, "\nCurrent Switch States: %3d : ", zero);
|
||||||
|
for (i = 0; i < kPRSwitchPhysicalLast + 1; i++)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%d ", switches[i].state);
|
||||||
|
if ((i + 1) % 32 == 0)
|
||||||
|
{
|
||||||
|
printf("\n");
|
||||||
|
if (i != kPRSwitchPhysicalLast)
|
||||||
|
fprintf(stderr, "Current Switch States: %3d : ", i+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -237,6 +237,13 @@ PR_EXPORT void PRDriverStateSchedule(PRDriverState *driverState, uint32_t schedu
|
|||||||
*/
|
*/
|
||||||
PR_EXPORT void PRDriverStatePatter(PRDriverState *driverState, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t originalOnTime);
|
PR_EXPORT void PRDriverStatePatter(PRDriverState *driverState, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t originalOnTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts a coil, lamp, switch, or GI string into a P-ROC driver number.
|
||||||
|
* The following formats are accepted: Cxx (coil), Lxx (lamp), Sxx (matrix switch), SFx (flipper grounded switch), or SDx (dedicated grounded switch).
|
||||||
|
* If the string does not match this format it will be converted into an integer using atoi().
|
||||||
|
*/
|
||||||
|
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str);
|
||||||
|
|
||||||
/** @} */ // End of Drivers
|
/** @} */ // End of Drivers
|
||||||
|
|
||||||
// Switches
|
// Switches
|
||||||
@@ -343,6 +350,9 @@ PR_EXPORT PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchC
|
|||||||
*/
|
*/
|
||||||
PR_EXPORT PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers);
|
PR_EXPORT PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers);
|
||||||
|
|
||||||
|
/** Returns a list of PREventTypes describing the states of the requested number of switches */
|
||||||
|
PR_EXPORT PRResult PRSwitchGetStates(PRHandle handle, PREventType * switchStates, uint16_t numSwitches);
|
||||||
|
|
||||||
/** @} */ // End of Switches & Events
|
/** @} */ // End of Switches & Events
|
||||||
|
|
||||||
// DMD
|
// DMD
|
||||||
|
|||||||
@@ -65,14 +65,16 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
unrequestedDataQueue.empty();
|
// Make sure the data queues are empty.
|
||||||
requestedDataQueue.empty();
|
while (!unrequestedDataQueue.empty()) unrequestedDataQueue.pop();
|
||||||
|
while (!requestedDataQueue.empty()) requestedDataQueue.pop();
|
||||||
num_collected_bytes = 0;
|
num_collected_bytes = 0;
|
||||||
numPreparedWriteWords = 0;
|
numPreparedWriteWords = 0;
|
||||||
|
|
||||||
DriverLoadMachineTypeDefaults(machineType, resetFlags);
|
DriverLoadMachineTypeDefaults(machineType, resetFlags);
|
||||||
|
|
||||||
freeSwitchRuleIndexes.empty();
|
// Make sure the free list is empty.
|
||||||
|
while (!freeSwitchRuleIndexes.empty()) freeSwitchRuleIndexes.pop();
|
||||||
|
|
||||||
for (i = 0; i < kPRSwitchRulesCount; i++)
|
for (i = 0; i < kPRSwitchRulesCount; i++)
|
||||||
{
|
{
|
||||||
@@ -494,6 +496,74 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwitches )
|
||||||
|
{
|
||||||
|
uint32_t rc;
|
||||||
|
uint32_t stateWord, debounceWord;
|
||||||
|
uint8_t i, j;
|
||||||
|
PREventType eventType;
|
||||||
|
|
||||||
|
// Request one state word and one debounce word at a time. Could make more efficient
|
||||||
|
// use of the USB bus by requesting a burst of state words and then a burst of debounce
|
||||||
|
// words, but doing one word at a time makes it easier to process each switch when the
|
||||||
|
// data returns. Also, this function shouldn't be called during timing sensitive
|
||||||
|
// situations; so the inefficiencies are acceptable.
|
||||||
|
for (i = 0; i < numSwitches / 32; i++)
|
||||||
|
{
|
||||||
|
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||||
|
P_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
|
||||||
|
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||||
|
P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expect 4 words for each 32 switches. The state and debounce words,
|
||||||
|
// and the address words for both.
|
||||||
|
uint16_t numWords = 4 * (numSwitches / 32);
|
||||||
|
|
||||||
|
i = 0; // Reset i so it can be used to prevent an infinite loop below
|
||||||
|
|
||||||
|
// Wait for data to return. Give it 10 loops before giving up.
|
||||||
|
while (requestedDataQueue.size() < numWords && i++ < 10)
|
||||||
|
{
|
||||||
|
sleep (.01); // 10 milliseconds should be plenty of time.
|
||||||
|
SortReturningData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure all of the requested words are available before processing them.
|
||||||
|
// Too many words is just as bad as not enough words.
|
||||||
|
// If too many come back, can they be trusted?
|
||||||
|
if (requestedDataQueue.size() == numWords)
|
||||||
|
{
|
||||||
|
// Process the returning words.
|
||||||
|
for (i = 0; i < numSwitches / 32; i++)
|
||||||
|
{
|
||||||
|
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
|
||||||
|
stateWord = requestedDataQueue.front(); // This is the switch state word.
|
||||||
|
requestedDataQueue.pop();
|
||||||
|
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
|
||||||
|
debounceWord = requestedDataQueue.front(); // This is the debounce word.
|
||||||
|
requestedDataQueue.pop();
|
||||||
|
|
||||||
|
// Loop through each bit of the words, combining them into an eventType
|
||||||
|
for (j = 0; j < 32; j++)
|
||||||
|
{
|
||||||
|
// Only process the number of switches requested via numSwitches
|
||||||
|
if ((i * 32) + j < numSwitches)
|
||||||
|
{
|
||||||
|
if (stateWord >> j & 1)
|
||||||
|
if (debounceWord >> j & 1) eventType = kPREventTypeSwitchOpenDebounced;
|
||||||
|
else eventType = kPREventTypeSwitchOpenNondebounced;
|
||||||
|
else if (debounceWord >> j & 1) eventType = kPREventTypeSwitchClosedDebounced;
|
||||||
|
else eventType = kPREventTypeSwitchClosedNondebounced;
|
||||||
|
switchStates[(i * 32) + j] = eventType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return kPRSuccess;
|
||||||
|
}
|
||||||
|
else return kPRFailure;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t PRDevice::DMDUpdateConfig(PRDMDConfig *dmdConfig)
|
int32_t PRDevice::DMDUpdateConfig(PRDMDConfig *dmdConfig)
|
||||||
{
|
{
|
||||||
uint32_t rc;
|
uint32_t rc;
|
||||||
@@ -793,14 +863,17 @@ PRResult PRDevice::SortReturningData()
|
|||||||
|
|
||||||
switch ( (rd_buffer[0] & P_ROC_COMMAND_MASK) >> P_ROC_COMMAND_SHIFT)
|
switch ( (rd_buffer[0] & P_ROC_COMMAND_MASK) >> P_ROC_COMMAND_SHIFT)
|
||||||
{
|
{
|
||||||
// Must be a bug in the P-ROC. Unrequested packets are returning looking
|
|
||||||
// like requested packets. Commenting out requested packets for now.
|
|
||||||
case P_ROC_REQUESTED_DATA: {
|
case P_ROC_REQUESTED_DATA: {
|
||||||
int bytesRead = ReadData(rd_buffer,
|
// Push the address word so it can be used to identify the subsequent data.
|
||||||
|
requestedDataQueue.push(rd_buffer[0]);
|
||||||
|
int wordsRead = ReadData(rd_buffer,
|
||||||
(rd_buffer[0] & P_ROC_HEADER_LENGTH_MASK) >>
|
(rd_buffer[0] & P_ROC_HEADER_LENGTH_MASK) >>
|
||||||
P_ROC_HEADER_LENGTH_SHIFT);
|
P_ROC_HEADER_LENGTH_SHIFT);
|
||||||
for (int i = 0; i < bytesRead; i++)
|
for (int i = 0; i < wordsRead; i++)
|
||||||
|
{
|
||||||
|
DEBUG(PRLog(kPRLogVerbose, "Pushing onto unreq Q 0x%x\n", rd_buffer[i]));
|
||||||
requestedDataQueue.push(rd_buffer[i]);
|
requestedDataQueue.push(rd_buffer[i]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case P_ROC_UNREQUESTED_DATA: {
|
case P_ROC_UNREQUESTED_DATA: {
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public:
|
|||||||
|
|
||||||
PRResult SwitchUpdateConfig(PRSwitchConfig *switchConfig);
|
PRResult SwitchUpdateConfig(PRSwitchConfig *switchConfig);
|
||||||
PRResult SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers);
|
PRResult SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers);
|
||||||
|
PRResult SwitchGetStates(PREventType * switchStates, uint16_t numSwitches);
|
||||||
|
|
||||||
PRResult DriverWatchdogTickle();
|
PRResult DriverWatchdogTickle();
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ const uint32_t P_ROC_MANAGER_WATCHDOG_EXPIRED_SHIFT = 30;
|
|||||||
const uint32_t P_ROC_MANAGER_WATCHDOG_ENABLE_SHIFT = 14;
|
const uint32_t P_ROC_MANAGER_WATCHDOG_ENABLE_SHIFT = 14;
|
||||||
const uint32_t P_ROC_MANAGER_WATCHDOG_RESET_TIME_SHIFT = 0;
|
const uint32_t P_ROC_MANAGER_WATCHDOG_RESET_TIME_SHIFT = 0;
|
||||||
|
|
||||||
|
const uint32_t P_ROC_SWITCH_CTRL_STATE_BASE_ADDR = 4;
|
||||||
|
const uint32_t P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR = 11;
|
||||||
|
|
||||||
const uint32_t P_ROC_EVENT_SWITCH_NUM_MASK = 0xFF;
|
const uint32_t P_ROC_EVENT_SWITCH_NUM_MASK = 0xFF;
|
||||||
const uint32_t P_ROC_EVENT_SWITCH_STATE_MASK = 0x100;
|
const uint32_t P_ROC_EVENT_SWITCH_STATE_MASK = 0x100;
|
||||||
const uint32_t P_ROC_EVENT_SWITCH_STATE_SHIFT = 8;
|
const uint32_t P_ROC_EVENT_SWITCH_STATE_SHIFT = 8;
|
||||||
|
|||||||
@@ -219,6 +219,49 @@ PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint16_t millisecondsO
|
|||||||
driver->patterEnable = true;
|
driver->patterEnable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
|
||||||
|
{
|
||||||
|
if (str == NULL)
|
||||||
|
return 0;
|
||||||
|
if (strlen(str) != 3)
|
||||||
|
return atoi(str);
|
||||||
|
uint16_t x = (str[1]-'0') * 10 + (str[2]-'0');
|
||||||
|
|
||||||
|
if (machineType == kPRMachineWPC)
|
||||||
|
{
|
||||||
|
switch (str[0])
|
||||||
|
{
|
||||||
|
case 'L':
|
||||||
|
case 'l':
|
||||||
|
return 80 + 8 * ((x / 10) - 1) + ((x % 10) -1);
|
||||||
|
case 'C':
|
||||||
|
case 'c':
|
||||||
|
if (x <= 28)
|
||||||
|
return x + 39;
|
||||||
|
else
|
||||||
|
return x + 7;
|
||||||
|
case 'G':
|
||||||
|
case 'g':
|
||||||
|
return x + 71;
|
||||||
|
case 'S':
|
||||||
|
case 's':
|
||||||
|
{
|
||||||
|
switch (str[1])
|
||||||
|
{
|
||||||
|
case 'D':
|
||||||
|
case 'd':
|
||||||
|
return 8 + ((str[2]-'0') - 1);
|
||||||
|
case 'F':
|
||||||
|
case 'f':
|
||||||
|
return (str[2]-'0') - 1;
|
||||||
|
default:
|
||||||
|
return 32 + 16 * ((x / 10) - 1) + ((x % 10) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return atoi(str);
|
||||||
|
}
|
||||||
|
|
||||||
// Switches
|
// Switches
|
||||||
|
|
||||||
@@ -232,6 +275,11 @@ PR_EXPORT PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREven
|
|||||||
return handleAsDevice->SwitchUpdateRule(switchNum, eventType, rule, linkedDrivers, numDrivers);
|
return handleAsDevice->SwitchUpdateRule(switchNum, eventType, rule, linkedDrivers, numDrivers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PR_EXPORT PRResult PRSwitchGetStates(PRHandle handle, PREventType * switchStates, uint16_t numSwitches)
|
||||||
|
{
|
||||||
|
return handleAsDevice->SwitchGetStates(switchStates, numSwitches);
|
||||||
|
}
|
||||||
|
|
||||||
PR_EXPORT int32_t PRDMDUpdateConfig(PRHandle handle, PRDMDConfig *dmdConfig)
|
PR_EXPORT int32_t PRDMDUpdateConfig(PRHandle handle, PRDMDConfig *dmdConfig)
|
||||||
{
|
{
|
||||||
return handleAsDevice->DMDUpdateConfig(dmdConfig);
|
return handleAsDevice->DMDUpdateConfig(dmdConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user