infusion / Fritzing

My fritzing sketches
68 stars 96 forks source link

Nunchuk.h nunchuk_init_power() uses AVR ports which is invalid for ARM and ESP Boards #4

Open dsyleixa opened 5 years ago

dsyleixa commented 5 years ago

hi, apart from faulty i2c readings on ARM boards, another crucial issue to the nunchuk.h lib: Nunchuk.h nunchuk_init_power() uses AVR ports which is invalid for ARM and ESP Boards

static void nunchuk_init_power() {
    // Add power supply for port C2 (GND) and C3 (PWR)
    PORTC &= ~_BV(PORTC2);
    PORTC |= _BV(PORTC3);
    DDRC |= _BV(PORTC2) | _BV(PORTC3);
    delay(100);
}
#endif

why don't you use the standard Arduino port numbers A0...A4 instead? (edit: for ESP then perhaps digital output pins)

infusion commented 5 years ago

There is a #ifdef block around this function. Do you get errors on arm for that? https://github.com/infusion/Fritzing/blob/master/Nunchuk/Nunchuk.h#L46

infusion commented 5 years ago

Sorry, edited my post. I fixed this already in the online version, as lined out with the link. And you're right, constants A0...A4 could be used, but I want to make sure the ports are set to what I want and not corrupted by internal Arduino routines

dsyleixa commented 5 years ago

IMO that wouldn't interfere if it wasn't wired to it, and if not, it woudn't matter either way...?