Example Internal RAM

The main goal of this example is to show how to use Internal RAM variables. For a detailed description of Internal RAM variables, see the Internal RAM documentation. This example uses a slider widget (varSlider) to set the value of Internal RAM byte variable # 0 and a numeric field widget (NumField) which is displaying the value of Internal RAM byte variable # 0. This examples shows you: a) how to use a Control Widget to write to an Internal RAM variable, b) how to read a value from an Internal RAM variable and use that as an input to a View Widget and c) how to save an Internal RAM variable into flash memory.


In CompileMe.htm, a slider named varSlider which writes its value to Internal RAM byte variable # 0 is created by using the following:

<APPLET CODE="Slider.class" WIDTH="104" HEIGHT="26" NAME="varSlider">
<PARAM NAME="href" VALUE="Amulet:InternalRAM.byte(0).setValue()">
<PARAM NAME="min" VALUE="0">
<PARAM NAME="max" VALUE="255">
<PARAM NAME="tickCount" VALUE="10">
<PARAM NAME="handleThickness" VALUE="10">
<PARAM NAME="tickPosition" VALUE="center">
<PARAM NAME="tickLength" VALUE="7">
<PARAM NAME="initialCondition" VALUE="fromInitHref">
<PARAM NAME="initHref" value="Amulet:InternalRAM.byte(0).value()">
</APPLET>

To create a numeric field widget named NumField that displays the value of Internal RAM byte variable # 0, the following is used:

<APPLET NAME="NumField" CODE="Field.class" WIDTH="81" HEIGHT="59">
<PARAM NAME="href" VALUE="Amulet:InternalRAM.byte(0).value()">
<PARAM NAME="fontSize" VALUE="5">
<PARAM NAME="fontStyle" VALUE="bold">
<PARAM NAME="min" VALUE="0">
<PARAM NAME="max" VALUE="255">
<PARAM NAME="printf" VALUE="%3i">
<PARAM NAME="minFld" VALUE="0">
<PARAM NAME="maxFld" VALUE="255">
<PARAM NAME="updateRate" VALUE=".3,0.01">
<PARAM NAME="border" VALUE="2">
<PARAM NAME="waitForInit" VALUE="true">
<PARAM NAME="horizontalAlign" VALUE="center">
<PARAM NAME="verticalAlign" VALUE="middle">
</APPLET>

Note that Slider1's href is Amulet:InternalRAM.byte(0).setValue(), which means the value of Internal RAM byte variable #0 is being set to the intrinsic value of the slider, based upon the current location of the slider handle.

Correspondingly, NumField's href is Amulet:InternalRAM.byte(0).value(), which means the value of Internal RAM byte variable #0 is the input to NumField.

So, as Slider1 changes Internal RAM byte variable #0, NumField will reflect those changes since it is reading the same variable that Slider1 is writing to.

CompileMe.htm also has a button with the label Page 1. By hitting the Page 1 button, the Amulet will launch to another page called Page1.htm, which does not have a slider, but still has a numeric field widget requesting the same Internal RAM byte variable #0. This page displays how an Internal RAM variable has persistence throughout your project, from page to page. As you will see, the numeric field is reading the same value as the numeric field on the first page.

Page1.htm also has a button with the label Page 2. By hitting the Page 2 button, the Amulet will launch to another page called Page2.htm, which has a numeric field reading Internal RAM byte variable #0 and a button that says "Save To Flash". If you hit the Save To Flash button, it invokes the following href function: "Amulet:InternalRAM.byte(0).saveToFlash()"

This method actually saves all internal RAM variables to the flash, not just the variable specified. If you then hit the reset button on the Amulet, it should reboot back to the first page of this example, which has a numeric field widget reading Internal RAM byte variable #0. You should notice that even after hitting the reset button, the value of Internal RAM byte variable #0 is the same as on Page2.htm, assuming you did hit the Save To Flash button.

NOTES:



Amulet HTMLCompiler,
Copyright © 2000-2004 by
Amulet Technologies, LLC

Back to Welcome - Contact Amulet - Amulet Home