SmartRC-CC1101-Driver-Lib icon indicating copy to clipboard operation
SmartRC-CC1101-Driver-Lib copied to clipboard

setGDO should be called before Init

Open T-vK opened this issue 4 years ago • 2 comments

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:

ELECHOUSE_cc1101.setGDO(GDO0, 0);
ELECHOUSE_cc1101.Init();
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.

T-vK avatar Sep 03 '20 16:09 T-vK

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 avatar Sep 03 '20 22:09 LSatan

done with v2.5.2

LSatan avatar Oct 01 '20 21:10 LSatan