LSatan / SmartRC-CC1101-Driver-Lib

This driver library can be used for many libraries that use a simple RF ASK module, with the advantages of the cc1101 module. It offers many direct setting options as in SmartRF Studio and calculates settings such as MHz directly.
Other
418 stars 94 forks source link

setGDO should be called before Init #48

Open T-vK opened 3 years ago

T-vK commented 3 years ago

I used the following code to save more power:

  for (int pin = 0; pin < 20; pin++) { // all pins to output - power saving
    pinMode(pin,OUTPUT);
    digitalWrite(pin,LOW);
  }

But then I noticed that my code stopped working. Looking at ELECHOUSE_CC1101_SRC_DRV.cpp I can see that the Init() method calls the GDO_Set() method, which is responsible for setting the pinmode for GDO0 to INPUT. But in the examples you always call Init() before GDO0 has even be set.

So from what I can tell, at the moment there are two options:

1.

ELECHOUSE_cc1101.setGDO(GDO0, 0);
ELECHOUSE_cc1101.Init();

2.

ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.setGDO(GDO0, 0);
ELECHOUSE_cc1101.GDO_Set();

Maybe it would make sense to change setGDO to include a call to GDO_Set:

void ELECHOUSE_CC1101::setGDO(byte gdo0, byte gdo2){
  GDO0 = gdo0;
  GDO2 = gdo2;  
  GDO_Set();
}

This way the examples could stay the same.

LSatan commented 3 years ago

the gdo_set function in init is a relic of the original elechouse bibliotehk. I should remove it from init as gdo_set is not relevant for the avoided examples. You're right. it is better to include it in set_gdo. Thank you very much, I will consider it in the next update. Regards

LSatan commented 3 years ago

done with v2.5.2