-
Notifications
You must be signed in to change notification settings - Fork 70
Pico - only one PWM pin is set #287
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule CustomDevices
updated
from d7e3f3 to 6a2b28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,10 +29,6 @@ namespace Output | |
| return; | ||
| outputs[outputsRegistered] = MFOutput(); | ||
| outputs[outputsRegistered].attach(pin); | ||
| #if defined(ARDUINO_ARCH_RP2040) | ||
| pinMode(pin, OUTPUT_12MA); | ||
| analogWrite(pin, false); | ||
| #endif | ||
| outputsRegistered++; | ||
| #ifdef DEBUG2CMDMESSENGER | ||
| cmdMessenger.sendCmd(kDebug, F("Added output")); | ||
|
|
@@ -52,11 +48,21 @@ namespace Output | |
| // Read led state argument, interpret string as boolean | ||
| int pin = cmdMessenger.readInt16Arg(); | ||
| int state = cmdMessenger.readInt16Arg(); | ||
|
|
||
| // Set led | ||
| analogWrite(pin, state); // why does the UI sends the pin number and not the x.th output number like other devices? | ||
| // output[pin].set(state); // once this is changed uncomment this | ||
| #if defined(ARDUINO_ARCH_RP2040) | ||
|
||
| if (state == 0xFF) | ||
| digitalWrite(pin, HIGH); | ||
| else if (state == 0x00) | ||
| digitalWrite(pin, LOW); | ||
| else | ||
| analogWrite(pin, state); // why does the UI sends the pin number and not the x.th output number like other devices? | ||
| // output[pin].set(state); // once this is changed uncomment this | ||
| #else | ||
| analogWrite(pin, state); // why does the UI sends the pin number and not the x.th output number like other devices? | ||
| // output[pin].set(state); // once this is changed uncomment this | ||
| #endif | ||
| } | ||
|
|
||
| void PowerSave(bool state) | ||
| { | ||
| for (uint8_t i = 0; i < outputsRegistered; ++i) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
i think it would be easier to read if we introduce a deviated method like
setRp2040and then put the custom logic there instead of having everything inlineThere 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.
Hmhm, in this case the
CommandMessenger.cppmust also be changed:Due to the differnet pinMode initialization
MFOutput.cppwould look like:And
Output.cppmust be as:Not sure if this increases readability, also as the
CommandMessegner.cppmust also be changed (changes not as much bundled as before).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.
i was thinking of a private local method only - nothing fancy
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.
After some more testing the logic from Pico to set outputs can also be used for AVR's.
So I wouldn't differ anymore between both. Just for setting
pinMode()it has to be differ betwenn AVR and Pico.The class
MFOutput()is "only" needed for setting the pinMode and setting the powersave Mode.I am wondering if we still need this class, both could also be done within
Output.cpplike setting the output.