infusion / Fritzing

My fritzing sketches
68 stars 96 forks source link

compellingly need for Nunchuk Wire.setClock(400000); ? or perhaps at 100000? #5

Closed dsyleixa closed 5 years ago

dsyleixa commented 5 years ago

Nunchuk_init is starting Wire.setClock(400000);

Is there compellinglya need for Nunchuk Wire.setClock(400000); ? or perhaps at 100000?

Instead, I would suggest to enable different clock speeds by

static void nunchuk_init( unsigned long clock ) {
    // Change TWI speed for nuchuk, which uses Fast-TWI (400kHz)
    //Wire.setClock(400000);
    Wire.setClock( clock );
  // ...

optionally one could perhaps have that feature additionally by overloading this function...?

infusion commented 5 years ago

I added it since I read that the Nunchuk operates at 400kHz. We could remote it and make it optional (=adding it to the demo.ino setup routine). Adding a new/overloaded function for that purpose is maybe a bit too much

infusion commented 5 years ago

Done

dsyleixa commented 5 years ago

I tried it with this trick:

static void nunchuk_init(unsigned long clock=400000) {
    // Change TWI speed for nuchuk, which uses Fast-TWI (400kHz) by default; 
   //  different values by passing the actual clock speed (e.g., 100000)
    Wire.setClock(clock);

now one may call the init function with or without passing clock speed values; 400000 is still default.

nunchuk_init(); // uses default nunchuk_init(100000); // uses 100kHz nunchuk_init(400000); // uses 400kHz arbitrarily

HTH!