Hi again,
> > One more thought: I understand you want users to be able to specify on > which > > PWM channel the LCD backlight will be controlled. Maybe some of this > logic: > > > > > > if channel == 1 then > > include pwm_ccp1 > > -- use pwm1_*() procedures > > end if > > > > > > could be imported back to pwm libs: instead of accessing pwm procedures > with > > prefixed pwm1_*(), pwm2_*(), etc..., use a wrapper procedure taking the > > channel number as argument, then dispatching to appropriate one. Then you > > would ahev only one procedure definition: > > > > > > procedure lcd_backlight_variable(byte in value) is > > ... > > pwm_set_dutycycle(lcd_backlight_pwm,value) > > end procedure > > > > > > I wonder how optimized the code could be, if ti's worth it, but I can > give a > > try. > > > What would be the benefit? Avoiding duplication of code. Imagine the following: I'm building a motor controller. Speed is controlled by PWM. I have a PIC with several PWM channels. When writing my lib, I want to specify which channel to use. I'll use the same kind of construct (conditional compile to select appropriate implementation), same code, while (I guess) this could be put (refactored) in pwm lib. > > I think you will get code for all available pwms if you use (at least) > one, since the there is a run time parameter that might get any > value.So an other few bytes of ram and flash used... Mmh... not sure to understand. Assuming we put this logic on PWM lib, do you mean if you don't even use this "channel selection" feature, some of the code will still be used (ie. written in ram/flash, thus growing) ? > > (I think we need to take the limited envirionment into account. flash > and especially ram are scarse and jallib is takes more of those for > the same task as bert's pack.) Interesting... Do you have any figure ? Can you give a concrete example so we may dig this and try to understand why ? I know I tend not to give priority to this, I prefer having more flexibility and maintainable code. I guess there's a compromise to make here. Yet one more thought: I see in your conditional compile contruct that you specifically include "pwm_ccp1", etc... If you just include pwm_hardware, the lib will include appropriate underlying pwm_ccpX lib. It will also include pwm_common to deal with resolution/frequency. You shouldn't have to deal with includes (except if you have good reasons I did not see :)) Yet again one more thought (still): by the same way we can rename const and vars with "is" keyword, don't you think having the possibility to rename procedures and functions would be great ? procedure my_pwm_set_dutycycle is pwm1_set_dutycycle Cheers, Seb -- Sébastien Lelong http://www.sirloon.net http://sirbot.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
