Hoe kunnen we helpen?

Print

Scrollen van verschillende tekstberichten op basis van de status van de bijbehorende bit

 
Hier zien we hoe we verschillende berichten (strings in LWx) achter elkaar kunnen weergeven in het onderste veld volgens de status van hun respectievelijke bit LBx

Dus de “groene” berichten worden achter elkaar weergegeven in een lus in het laatste veld LW50100

Dit geeft ons

  • 4 “ASCII-invoervelden” in LW50000, LW50010, LW50020 en LW50030
  • 1 “ASCII-weergave”-veld in LW50100
  • 4 bitschakelaars LB0, LB10, LB20, LB30

En een script om de weergave van het LW50100-veld te beheren

Dit script moet bijvoorbeeld elke 100 ms worden aangeroepen.

#include "MacInit.h"
#include
#include
#include // Sleep
void Macro_main(IN *p)
{
MacroInit
//ToDo
int i;
// Function copies a string of 5 characters from a source position to a destination position in LocalWord
void copyString(int sourceStart, int destStart) {
for (i = 0; i < 5; i++) {
LocalWord[destStart + i] = LocalWord[sourceStart + i];
}
}
// Fonction clears the content of a string at a given position in LocalWord
void clearString(int start) {
for (i = 0; i < 5; i++) {
LocalWord[start + i] = 0; // Clear the content
}
}
// Main
static int bitPositions[] = {0, 10, 20, 30}; // Positions of the LB bits to check
static int wordPositions[] = {50000, 50010, 50020, 50030}; // Positions of the corresponding LW strings/messages
static int numBits = sizeof(bitPositions) / sizeof(bitPositions[0]); // Number of bits/messages
int activeBits; // Number of LB at 1
static int currentIndex = 0; // Track of the current position of the loop
for (i = 0; i < numBits; i++) {
if (LocalBit[bitPositions[i]]) {
activeBits++;
}
}
if (activeBits == 0) { // No message to display
clearString(50100);
} else if (activeBits == 1) { // Only 1 message to display
for (i = 0; i < numBits; i++) {
if (LocalBit[bitPositions[i]]) { // Search whch message number to display
copyString(wordPositions[i], 50100);
}
}
} else { // More than 1 message to display
if (currentIndex < numBits) {
if (LocalBit[bitPositions[currentIndex]]) {
copyString(wordPositions[currentIndex], 50100);
sleep(1); // Wait for 1 second
}
currentIndex++; // Move to the next index for the next function call
} else {
currentIndex = 0; // Reset to start over if all bits have been processed
}
}
} // End MacroInit

Hier is het Bit-gebaseerde scrollen van tekstberichten project