<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Save app data]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1456&amp;type=atom" />
	<updated>2022-09-01T03:43:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1456</id>
		<entry>
			<title type="html"><![CDATA[Re: Save app data]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4787#p4787" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>mic wrote:</cite><blockquote><p>Hi,<br />I believe it would be great if the app could optionally save the state of input elements, especially edit fields between sessions.</p></blockquote></div><p>Generally, you will be needing to use real, or simulated EEPROM.</p><p>The EEPROM library contains all that you will need.</p><p>I always put data that I want stored between sessions into a user-defined structure, it makes life really simple ...</p><div class="codebox"><pre><code>// Create the EEPROM data structure
struct udt_eeData {
int16_t   runaway_time;     // seconds
int16_t   gassing_time;     // seconds
uint8_t   id;               // this is last to catch structure changes
};</code></pre></div><p>then you have to create an &quot;instance&quot; data of that declared structure ...</p><div class="codebox"><pre><code>//Create the EEPROM data of type udt_eeData
udt_eeData eeData;</code></pre></div><p>Read your data using EEPROM.get(eeData) reads the whole of the data you declared.</p><p>In the example above, the saved &quot;gassing_time&quot; is addressed as &quot;eeData.gassing time&quot;.</p><p>I use the &quot;id&quot; member of the user-defined structure to detect structure changes, or i can force a change in my code by changing it before compilation, sort of like a &quot;build&quot; number. Use it to assert &quot;default&quot; values. </p><div class="codebox"><pre><code>  // initialise eeData if NOT already present
  // THIS SHOULD ONLY OCCUR IF BUILD has changed !!
  if (eeData.id != build_no) 
    {
    eeData.runaway_time = 30;
    eeData.gassing_time = 3;  
    eeData.id = build_no;
    EEPROM.put(eeAddress, eeData);
    EEPROM.commit(); // only needed for virtual EEPROM
    }</code></pre></div><p>Write data to the EEPROM using EEPROM.put(eeData).&nbsp; This function only writes to the EEPROM any bytes that have changed, prolonging the EEPROM write-cycle lifetime.</p><p>Any questions ? Please ask... I&#039;ve used this technique on several projects, with huge success .....</p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2022-09-01T03:43:28Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4787#p4787</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Save app data]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4497#p4497" />
			<content type="html"><![CDATA[<p>The board saves the state of input elements. When reconnecting, the state of the input elements is transmitted to the phone from board. If your board has been reset, you can save the states to non-volatile memory and then restore.</p>]]></content>
			<author>
				<name><![CDATA[remotexy]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2</uri>
			</author>
			<updated>2022-01-30T07:04:01Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4497#p4497</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Save app data]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4496#p4496" />
			<content type="html"><![CDATA[<p>Hi,<br />I believe it would be great if the app could optionally save the state of input elements, especially edit fields between sessions.</p>]]></content>
			<author>
				<name><![CDATA[mic]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2055</uri>
			</author>
			<updated>2022-01-28T12:48:51Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4496#p4496</id>
		</entry>
</feed>
