The main goal of this example is to show how to use the SPI commands byteOut() in order to adjust the SPI-based digital pots which control the contrast setting and backlight intensity of the Amulet Easy GUI module. The main page, CompileMe.htm merely has a large button which launches to another page called Adjust.html. Adjust.html contains two custom sliders(Contrast and Backlight) and two custom buttons(Save and Cancel). One slider controls the contrast setting and the other slider controls the backlight intensity. The "Save" button saves the new values and returns to the calling page. The "Cancel" button restores the contrast and backlight settings to where they were upon entering Adjust.html and then returns to the calling page.
This example will only adjust the contrast and backlight if your Easy GUI module is equipped with SPI-based digital pots. If so, then the contrast digital pot is connected to SPI Slave Select line 2 and the backlight digital pot is connected to line 3. To reference SPI slave select line X within the html source, use the following nomenclature "Amulet:SPI(X)". Click here for more detailed information regarding the Software Controlled Contrast and Backlighting. Here is a snapshot of what the html page looks like in a "WYSIWYG" tool:

Figure 1.
Adjust.html also has two META Refresh tags which launch only once 10ms after loading the page. One takes the value of InternalRAM.contrast and saves it in InternalRAM.byte(0xFE). The other one takes the value of InternalRAM.backlight and saves it in InternalRAM.byte(0xFF). These values are saved so we can restore the initial values if the Cancel button is pressed.
<meta http-equiv="Refresh" content="0,0.01;URL=Amulet:InternalRAM.byte(0xFE).setValue(InternalRAM.contrast)">
<meta
http-equiv="Refresh" content="0,0.01;URL=Amulet:InternalRAM.byte(0xFF).setValue(InternalRAM.backlight)">
The contrast slider performs two functions. It sends its intrinsic value directly to the SPI-based digital pot connected to the contrast circuit on the Amulet Easy GUI module. And it also saves its intrinsic value to the InternalRAM.contrast variable.
<PARAM NAME="href" VALUE="Amulet:SPI(2).byteOut(),Amulet:InternalRAM.contrast.setValue()">
The backlight slider also performs two functions. It sends its intrinsic value directly to the SPI-based digital pot connected to the backlight circuit on the Amulet Easy GUI module. And it also saves its intrinsic value to the InternalRAM.backlight variable.
<PARAM NAME="href" VALUE="Amulet:SPI(3).byteOut(),Amulet:InternalRAM.backlight.setValue()">
It is important to remember that the InternalRAM variables contrast and backlight do not, in and of themselves, change the contrast and backlight intensity. The values saved in those variables are used by the OS upon first powering up to set the contrast and backlight, but to actually change the contrast and backlight, you must send a byteOut() command to SPI(2) for the contrast and SPI(3) for the backlight.
If the change in contrast and backlight intensity is acceptable, then push the Save button. The Save button performs two functions. First it writes the current values stored in InternalRAM.contrast and InternalRAM.backlight to serial data flash. Then it performs an Amulet:back(), which returns to the calling page. At this point, if you cycle the power, the Easy GUI module will power up at the same contrast setting and backlight intensity as you specified because you saved the values to InternalRAM.contrast and InternalRAM.contrast.
<PARAM NAME="href" VALUE="Amulet:InternalRAM.saveContrast(),Amulet:back()">
If the Cancel button is pushed, it performs five functions. Since the original values of InternalRAM.contrast and InternalRAM.backlight at the time of entering Adjust.html were saved to InternalRAM byte variable 0xFE and 0xFF, respectively, InternalRAM.contrast and InternalRAM.backlight are restored. The original values are also sent out to the appropriate SPI device, so contrast and backlight return to the levels they originally were at the time of entering Adjust.html. Finally, it performs an Amulet:back() which returns to the calling page.
<PARAM NAME="href" VALUE="Amulet:InternalRAM.contrast.setValue(internalRAM.byte(0xFE)),
Amulet:SPI(2).byteOut(internalRAM.byte(0xFE)),
Amulet:InternalRAM.backlight.setValue(internalRAM.byte(0xFF)),
Amulet:SPI(3).byteOut(internalRAM.byte(0xFF)),Amulet:back()">
NOTES: