loadState in 2.3.2 is not a happy function....
-
I am trying to get another node done and using saveState and loadState in the node for power cut recovery.
Although I can get saveState to work in the receive function (wasn't expecting that to complie I must admit), whenever I try to loadState in setup I get an error like this.....
Arduino: 1.8.9 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"
WARNING: Spurious .ci folder in 'MySensors' library
WARNING: Spurious .mystools folder in 'MySensors' library
C:\Users\captain\Documents\Arduino\MYS-M_BED_LED-0.2\MYS-M_BED_LED-0.2.ino: In function 'void setup()':MYS-M_BED_LED-0.2:69:23: error: too many arguments to function 'uint8_t loadState(uint8_t)'
loadState(10, lights);
^In file included from C:\Users\captain\Documents\Arduino\libraries\MySensors/MySensors.h:433:0,
from C:\Users\captain\Documents\Arduino\MYS-M_BED_LED-0.2\MYS-M_BED_LED-0.2.ino:32:C:\Users\captain\Documents\Arduino\libraries\MySensors/core/MySensorsCore.cpp:550:9: note: declared here
uint8_t loadState(const uint8_t pos)
^~~~~~~~~exit status 1
too many arguments to function 'uint8_t loadState(uint8_t)'This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.void setup() { Serial.begin(9600); // loadState(1, SOUND_Armed); // loadState(7, Auto_lights); loadState(10, lights); if (lights == 1) { newcodeRX == 1; code = 0xFFA25D; } irrecv.enableIRIn(); // Start the receiver LightMeter.begin(); wdt_enable(WDTO_8S); }So I wonder why saveState(10, lights); compiles and loadState(10, lights); does not? What am I not knowing about this as I have not had this issue before.
-
Just tested this and my assumption was incorrect it seems (using arduino 1.8.9 and mysensors 2.3.2).....
Correct usage is......
lights = loadState(10); //to read value from eeprom to variable.
saveState(10, lights); //to write value from variable to eeprom.Now I got it!
-
It has always been like this. In order to do like you propose, you'd have to send in a pointer for the light variable into the function to be able to update it. This would be a bit awkward and none standard for simple scalar values.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login