-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure different kinds of busses at compile #4107
Changes from 14 commits
6655e26
fcc344b
c942345
9bb979f
d79d5db
8e4f8fc
329173e
eb06e57
5869627
c5435ec
daf0bcf
fa82e75
6a18803
e3d9417
81e412f
f16ed46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -787,7 +787,7 @@ void BusNetwork::cleanup() { | |
|
||
//utility to get the approx. memory usage of a given BusConfig | ||
uint32_t BusManager::memUsage(BusConfig &bc) { | ||
if (Bus::isOnOff(bc.type) || Bus::isPWM(bc.type)) return 5; | ||
if (Bus::isOnOff(bc.type) || Bus::isPWM(bc.type)) return OUTPUT_MAX_PINS; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewing original code, |
||
|
||
unsigned len = bc.count + bc.skipAmount; | ||
unsigned channels = Bus::getNumberOfChannels(bc.type); | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -267,6 +267,14 @@ bool PinManagerClass::isPinOk(byte gpio, bool output) const | |||||
return false; | ||||||
} | ||||||
|
||||||
bool PinManagerClass::isReadOnlyPin(byte gpio) | ||||||
{ | ||||||
#ifdef ARDUINO_ARCH_ESP32 | ||||||
if (gpio < WLED_NUM_PINS) return digitalPinCanOutput(gpio); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be !digitalPinCanOutput(). Unfortunately even with that fixed it still doesn't work because this function also returns FALSE on other pins than R/O (for example 28 to 31 on ESP32). While as far as the finalizeInit() code this doesn't matter I think we should not return TRUE for pins that are not read/only on a function called isReadOnlyPin(). This could lead to bugs in the future (e.g. usermod wanting to use this function to check if a pin can be used to read data). There are two ways I can think of to get around this problem:
EDIT: I'll try implement what I suggested above: first color digitalPinCanOutput() pins orange, then color digitalPinIsValid() red. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is used in pin manager since ever: Line 259 in df24fd7
If you do not trust HAL (you may have reasons) then use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, I had already implemented the logic fix before reading your message. Both options work the same in my testing so your call on which you prefer: pinManager.isPinOk(i) != pinManager.isPinOk(i,false) digitalPinIsValid(gpio) && !digitalPinCanOutput(gpio) |
||||||
#endif | ||||||
return false; | ||||||
} | ||||||
|
||||||
PinOwner PinManagerClass::getPinOwner(byte gpio) const | ||||||
{ | ||||||
if (!isPinOk(gpio, false)) return PinOwner::None; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BusOnOff
also has a length of 1.