copy of PR #8991 code

Formatting tweaks

correct array initialization & remove test code
This commit is contained in:
Bob-the-Kuhn
2018-01-01 16:27:19 -06:00
parent d190c702de
commit 5574fad69c
3 changed files with 309 additions and 318 deletions

View File

@@ -136,8 +136,8 @@ void analogWrite(pin_t pin, int pwm_value) { // 1 - 254: pwm_value, 0: LOW, 255
digitalWrite(pin, value);
}
else {
if (LPC1768_PWM_attach_pin(pin, 1, (LPC_PWM1->MR0 - MR0_MARGIN), 0xff)) // locks up if get too close to MR0 value
LPC1768_PWM_write(pin, map(value, 1, 254, 1, (LPC_PWM1->MR0 - MR0_MARGIN))); // map 1-254 onto PWM range
if (LPC1768_PWM_attach_pin(pin, 1, LPC_PWM1->MR0, 0xff))
LPC1768_PWM_write(pin, map(value, 0, 255, 1, LPC_PWM1->MR0)); // map 1-254 onto PWM range
else { // out of PWM channels
if (!out_of_PWM_slots) MYSERIAL.printf(".\nWARNING - OUT OF PWM CHANNELS\n.\n"); //only warn once
out_of_PWM_slots = true;