Open tawjaw opened 2 years ago
The Component class right now is not a good design. https://github.com/p4labs/p4-robotsim/blob/90d181769a2005918933494fbe3a618206ef359e/src/Arduino/Component.ts#L1 At first the assumption was that a component will only have one digital pin to update.
Component
So it includes https://github.com/p4labs/p4-robotsim/blob/90d181769a2005918933494fbe3a618206ef359e/src/Arduino/Component.ts#L9-L10
and the abstract update expects true or false to update that digital pin.
abstract update
A better design would probably be to create
DigitalPin, PWMPin and AnalogPin classes that handles the logic and update each pin separately. And a Component would have a collection of pins.
DigitalPin
PWMPin
AnalogPin
and in the https://github.com/p4labs/p4-robotsim/blob/90d181769a2005918933494fbe3a618206ef359e/src/Arduino/Uno/ArduinoUno.ts#L31 we would add the pin connections to be updated inside a component, instead of the component
The
Component
class right now is not a good design. https://github.com/p4labs/p4-robotsim/blob/90d181769a2005918933494fbe3a618206ef359e/src/Arduino/Component.ts#L1 At first the assumption was that a component will only have one digital pin to update.So it includes https://github.com/p4labs/p4-robotsim/blob/90d181769a2005918933494fbe3a618206ef359e/src/Arduino/Component.ts#L9-L10
and the
abstract update
expects true or false to update that digital pin.A better design would probably be to create
DigitalPin
,PWMPin
andAnalogPin
classes that handles the logic and update each pin separately. And aComponent
would have a collection of pins.and in the https://github.com/p4labs/p4-robotsim/blob/90d181769a2005918933494fbe3a618206ef359e/src/Arduino/Uno/ArduinoUno.ts#L31 we would add the pin connections to be updated inside a component, instead of the component