digistump / DigisparkArduinoIntegration

DEPRECATED - REPLACED BY: https://github.com/digistump/DigistumpArduino
280 stars 330 forks source link

Some enhancement for Digispark #5

Closed RC-Navy closed 11 years ago

RC-Navy commented 11 years ago

Hi Erik,

as you can see, I learnt to use github to propose my changes, my ideas for Digispark... I did some work/test on DigisparkArduinoIntegration for several weeks.

Mainly:

1) librairies: -a) fix some path issue in header files -b) added examples -c) fix keyword.txt for syntax color -d) added half duplex capability on a single wire in SoftSerial -e) added TinySoftPwm library to allow PWM on any Pin whilst keeping DigiUSB -f) added VirtualWire with some improvements: code size reduction + capability to call an external function in ISR (for example to share the timer for calling periodically the TinySoftPwm manager).

2) core: -a) added a modification to allow high speed hardware PWM on Pin0 (up to 32.2KHz), 1 (up to 64.5KHz) and 4 (up to 64.5KHz) without breaking micros(), millis(), delay() and without disturbing DigiUSB. FAVOR_PHASE_CORRECT_PWM shall be set to 0 in core_build_option.h, otherwise Pin1 can only reach 32.2KHz and not 64.5KHz. If you accept to merge this one with the next release, I will write a chapter on the wiki about PWM (TinySoftPwm and HW) for the Digispark focussing on the fact the DigiUSB can still be used. TinySoftPwm, HW PWM and DigiUSB can work together. For example, this allows to command the 3 PWM channels of a RGB strip Led through USB. High speed HW PWM allows to make speed controller for brushed motors, but without audible noise. What do you think about these ideas?

Regards,

RC Navy (Philippe)

digistump commented 11 years ago

RC Navy - This is great! I was just sitting down tonight to make a new release and had your changes you sent over the forum to integrate - this is much easier and it looks like a lot more changes too!

I'll merge the core stuff as well, I don't see any immediate concerns with it and it sounds like you've done much testing.

Thanks so much for contributing this - it is very much appreciated - your libraries especially are awesome!

If you want to add to the wiki about PWM it would be most appreciated - also if you would email me at support at digistump dot com I'd like to send a gift card for our webstore to you - it won't be much, but we want to show our appreciation for your contributions!

Thanks Philippe! -Erik

RC-Navy commented 11 years ago

Erik,

thanks for having merged my changes.

Yes, I did lots of tests before doing the pull request. Especially for the timer modification for PWM. I checked with an oscilloscope the HW PWM and blink period, with a sketch containing the built-in LED blink based on micros(), then after, based with millis(). So, I'm confident micros(), millis() and delay() are still working fine. This test sketch also contained DigiUSB which obviously was still working fine. Additionally, by commenting out "#define MS_TIMER_TICK_EVERY_X_CYCLES" in "wiring.c", we get back to the original operation. Maybe have you noted, some files are completely removed and completely added (ex: SoftSerial, TinyPinChange), this is because initially, I was working in different directories. This is the case for my first modifications. Now, I modified my Digispark IDE to point to directories in my local DigisparkArduinoIntegration repository using Linux symbolic links. Now, for the last modifications, only the deltas are traced with GIT rather than the whole file. [quote] If you want to add to the wiki about PWM it would be most appreciated - also if you would email me at support at digistump dot com I'd like to send a gift card for our webstore to you - it won't be much, but we want to show our appreciation for your contributions! [/quote] OK, I will add a chapter about PWM in the wiki. Thanks for the gift card -much appreciated- : nice, since I planned to order I2C expanders schields in a few days.

In a few hours, you will see a detailled chapter about HW and SW PWM on the wiki...

RC-Navy (Philippe)