Making internal signal level struct private and adding levels to LinkWireless_demo

This commit is contained in:
Rodrigo Alfonso 2025-01-16 08:08:48 -03:00
parent 1f298b5164
commit 190dea598e
2 changed files with 15 additions and 6 deletions

View File

@ -429,13 +429,22 @@ void messageLoop() {
linkWireless->timerIRQs = 0;
}
#endif
LinkWireless::SignalLevelResponse levels;
std::string signalStr = "";
if (linkWireless->getState() == LinkWireless::State::SERVING) {
linkWireless->getSignalLevel(levels);
for (u32 i = 1; i < linkWireless->playerCount(); i++)
signalStr += "P" + std::to_string(i) + ": " +
std::to_string(levels.signalLevels[i] * 100 / 255) + "%";
}
std::string output =
"Player #" + std::to_string(linkWireless->currentPlayerId()) + " (" +
std::to_string(linkWireless->playerCount()) + " total)" +
"\n\n(press A to increment counter)\n(hold B to do it "
"continuously)\n(press RIGHT for more options)\n\n" +
altOptionName + ": " + (altView ? "ON" : "OFF") +
"\n(switch with UP)\n\n";
altOptionName + ": " + (altView ? "ON" : "OFF") + " (UP = switch)\n" +
signalStr + "\n\n";
for (u32 i = 0; i < linkWireless->playerCount(); i++) {
output +=

View File

@ -234,10 +234,6 @@ class LinkWireless {
bool isFull() { return currentPlayerCount == 0; }
};
struct SignalLevel {
vu8 level[LINK_WIRELESS_MAX_PLAYERS] = {};
};
/**
* @brief Constructs a new LinkWireless object.
* @param forwarding If `true`, the server forwards all messages to the
@ -918,6 +914,10 @@ class LinkWireless {
private:
using MessageQueue = Link::Queue<Message, LINK_WIRELESS_QUEUE_SIZE>;
struct SignalLevel {
vu8 level[LINK_WIRELESS_MAX_PLAYERS] = {};
};
struct SessionState {
MessageQueue incomingMessages; // read by user, write by irq&user
MessageQueue outgoingMessages; // read and write by irq