Wie können wir helfen?

Print

Durchblättern verschiedener Textnachrichten je nach Zustand des zugehörigen Bits

 
Hier sehen wir, wie man verschiedene Meldungen (Strings in LWx) nacheinander im unteren Feld entsprechend dem Zustand ihres jeweiligen Bits LBx anzeigt

Die „grünen“ Meldungen werden also nacheinander in einer Schleife im letzten Feld LW50100 angezeigt

Dies gibt uns

  • 4 „ASCII-Eingabe“-Felder in LW50000, LW50010, LW50020 und LW50030
  • 1 „ASCII-Anzeige“-Feld in LW50100
  • 4 Bit-Schalter LB0, LB10, LB20, LB30

Und ein Skript zur Verwaltung der Anzeige des Feldes LW50100

Dieses Skript muss z.B. alle 100 ms aufgerufen werden.

#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 ist das Projekt zum Bit-basierten Scrollen von Textnachrichten