Skip to content

init devices with attach() function and not via constructor#286

Merged
DocMoebiuz merged 3 commits intoMobiFlight:mainfrom
elral:attach_function
Nov 23, 2023
Merged

init devices with attach() function and not via constructor#286
DocMoebiuz merged 3 commits intoMobiFlight:mainfrom
elral:attach_function

Conversation

@elral
Copy link
Collaborator

@elral elral commented Nov 22, 2023

Description of changes

For the devices AnalogIn and Buttons an attach() function ia added where all required init paramaters are transferred. These init parameters were part of the constructor.
Now calling the constructor will only set that the device is not initialized.

The calling of the constructor is since PR #253 also done to calculate the required memory for all devices of one type and to reserve it. As no init parameters are available at this point the standard paramaters were taken and e.g. pin 1 for the output and analogIn device was set output / input.

The required changes for outputs are part of PR #285.

For the InputShifter the default value in the constructor is deleted. Not required here as it gets set also in the attach() function.

For the servo device the not required constructor was deleted.

For the stepper the default parameters in the attach() function are deleted to be the same as the other devices.

Fixes #284

@elral elral requested a review from DocMoebiuz as a code owner November 22, 2023 08:45
@github-actions
Copy link

Firmware for this pull request:
Firmware.zip

@github-actions
Copy link

Firmware for this pull request:
Firmware.zip

Copy link
Collaborator

@DocMoebiuz DocMoebiuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elral Great find
@neilenns Thanks for the review

@DocMoebiuz DocMoebiuz merged commit 91c7e1e into MobiFlight:main Nov 23, 2023
@DocMoebiuz DocMoebiuz added beta-bug bug Something isn't working labels Nov 23, 2023
@elral elral deleted the attach_function branch November 23, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-bug bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pin 1 gets set as output or input when a button/analogIn is defined

3 participants