All new Amulet 3.8" modules are being shipped with SPI-based digital pots which are used to control the LCD's contrast settings and backlight intensity. These digital pots can be set via software commands which can be entered into an .html page. See the spiContrast example. The Amulet 5.7" modules have the ability to add these digital pots to get this functionality, as well.
The contrast adjust pot is tied to the Amulet Easy GUI browser chip's SPI Slave Select line 2. It takes a single byte as its input and the resultant contrast setting is determined by the value of that byte. The valid range is from 0x00-0xFF.
To send a byte to the contrast adjust pot, use the byteOut() command. For example,
to set the contrast adjust to midscale, use the following function call in any
control widget href:
Amulet:SPI(2).byteOut(0x80)
Notice the use of SPI(2). The 2 is used to determine which SPI Slave Select to use for the communications.
If you are using a Control Widget which has a variable intrinsic value, such as a slider, you can leave the value of the byteOut() command empty. This will result in the intrinsic value of the widget being sent to the byteOut command.
The backlight intensity pot is tied to the Amulet Easy GUI browser chip's SPI Slave Select line 3. It takes a single byte as its input and the resultant backlight intensity is determined by the value of that byte. The valid range is from 0x00-0xFF. When dealing with LED backlighting, 0x00 is full off and 0xFF is full on. On the other hand, when dealing with CCFL backlighting, 0x00 is full on and 0xFF is full off.
To send a byte to the backlight intensity pot, use the byteOut() command. For example,
to set an LED backlight to full on, use the following function call in any
control widget href:
Amulet:SPI(3).byteOut(0xFF)
Notice the use of SPI(3). The 3 is used to determine which SPI Slave Select to use for the communications.
If you are using a Control Widget which has a variable intrinsic value, such as a slider, you can leave the value of the byteOut() command empty. This will result in the intrinsic value of the widget being sent to the byteOut command.
By default, the Amulet OS uses two InternalRAM byte variables to hold the current value of the contrast and backlight settings, Amulet:InternalRAM.contrast and Amulet:InternalRAM.backlight. These two variables are initialized by the LCD Settings menu options Contrast Adjust and Backlight Intensity. Immediately upon powering up, the Amulet OS takes the values in these two variables and sets the digital pots accordingly.
These InternalRAM variables can be written to, read from, and saved to flash. The nomenclature is as follows:
To read from the contrast and backlight InternalRAM variables:
Amulet:InternalRAM.contrast.value()
Amulet:InternalRAM.backlight.value()
To write to the contrast and backlight InternalRAM variables:
Amulet:InternalRAM.contrast.setValue(0x80)
Amulet:InternalRAM.backlight.setValue(0x00)
To save the contrast and backlight InternalRAM variables to flash:
Amulet:InternalRAM.saveContrast()
<!-- This saves both the contrast and backlight settings to serial data flash
-->
Setting these variables at runtime will do nothing. These variables are only sent out to the contrast and backlight digital pots upon first powering the Easy GUI module. If you have a page that is used for setting the contrast and backlight, it is highly recommended that you save your settings to the appropriate variables as well as saving them to flash memory.
If you ever want to restore the contrast or backlight to the values saved
in the InternalRAM variables, you can send them directly out the SPI lines by
using the following:
Amulet:SPI(2).byteOut(InternalRAM.contrast),Amulet:SPI(3).byteOut(InternalRAM.backlight)