Skip to content

Commit

Permalink
add getFunctionName(int function);
Browse files Browse the repository at this point in the history
  • Loading branch information
flash62au committed Dec 27, 2023
1 parent 4b24a03 commit 87d8c5f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/DCCEXLoco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ void Loco::setupFunctions(char *functionNames) {
_momentaryFlags &= ~1<<fkey;
}
}
// console->print("Function ");
// console->print(fkey);
// console->print(momentary ? F(" Momentary ") : F(""));
// console->print(" ");
// console->println(fName);
// Serial.print("Function ");
// Serial.print(fkey);
// Serial.print(momentary ? F(" Momentary ") : F(""));
// Serial.print(" ");
// Serial.println(fName);
// Serial.println(_functionNames[fkey]);
fkey++;
}
if (fkey<MAX_FUNCTIONS) {
for (int i=fkey; i<MAX_FUNCTIONS; i++) {_functionNames[i] = nullptr;}
}
}

bool Loco::isFunctionOn(int function) {
Expand All @@ -145,6 +149,10 @@ int Loco::getFunctionStates() {
return _functionStates;
}

char* Loco::getFunctionName(int function) {
return _functionNames[function];
}

Loco* Loco::getFirst() {
return _first;
}
Expand Down
6 changes: 6 additions & 0 deletions src/DCCEXLoco.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class Loco {
/// @return Integer representing current function states
int getFunctionStates();

/// @brief Get the name/label for a function
/// @param function Number of the function to return the name/label of
/// @return char* representing the function name/label
char* getFunctionName(int function);

/// @brief Get first Loco object
/// @return Pointer to the first Loco object
static Loco* getFirst();
Expand Down Expand Up @@ -235,6 +240,7 @@ class Consist {
ConsistLoco* getFirst();

/// @brief Get the loco in the consist with the specified address
/// @param address DCC address of loco to retrieve
/// @return Pointer to the first ConsistLoco object
ConsistLoco* getByAddress(int address);

Expand Down

0 comments on commit 87d8c5f

Please sign in to comment.