MCPcopy Create free account
hub / github.com/FastLED/FastLED / pinToPort

Function pinToPort

src/fl/system/pins.cpp.hpp:73–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71} // namespace pin_port_table
72
73int pinToPort(int pin) {
74 if (pin < 0) return -1;
75
76 if (!pin_port_table::allPortsNull()) {
77 auto ptr = pin_port_table::getPortPtr(pin);
78 if (ptr == nullptr) return -1;
79
80 // Assign sequential port IDs by counting unique pointers before this one
81 const auto* table = pin_port_table::portTable();
82 for (int i = 0; i < pin_port_table::TABLE_SIZE; ++i) {
83 if (table[i] == ptr) {
84 int id = 0;
85 for (int j = 0; j < i; ++j) {
86 bool unique = true;
87 for (int k = 0; k < j; ++k) {
88 if (table[k] == table[j]) { unique = false; break; }
89 }
90 if (unique && table[j] != nullptr) ++id;
91 }
92 return id;
93 }
94 }
95 return -1;
96 }
97
98 // Stub/WASM fallback: all FastPin ports are null, group by pin / 32
99 return pin / 32;
100}
101
102#elif defined(FASTLED_NO_PINMAP)
103

Callers 4

initMethod · 0.85
allSamePortMethod · 0.85
pinMapFunction · 0.85
FL_TEST_FILEFunction · 0.85

Calls 4

allPortsNullFunction · 0.85
getPortPtrFunction · 0.85
portTableFunction · 0.85
portValueToIdFunction · 0.85

Tested by

no test coverage detected