Storing 0.0005 in memory
The RTC Pi is a Real-time clock for the Raspberry Pi
26/01/2017
Posted by:
Johnu
26/01/2017
Posted by:
Johnu
26/01/2017
Posted by:
andrew
The RTC memory example would only work with whole numbers as it saved the value as an integer. I have created a new python script which shows how you can save a number with decimal places to the RTC memory. You can view the file at our GitHub repository.
To save a number to the memory you have to convert it into an array of bytes. As the number you want to save is not a whole number it would have to be saved as a double which contains 8 bytes. I created two functions double_to_array() and array_to_double() that you can use to convert the number from a double into an array of bytes and back again.
Hopefully, you can use this example to get your project working.
26/01/2017
Posted by:
Johnu
If I wanted to run both of those functions under one function call and pass the variable into it, is that possible?
I'm having problems passing variables between functions and in and out of functions
John
26/01/2017
Posted by:
andrew
If you are having trouble passing variables then it may be worth reading this page on how functions work in python. The main cause of problems I normally find is trying to pass the wrong data type or the number of arguments into the functions.
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.