HP48 Sources Page.


So you want to change the contrast from within a program? Well, here's how you can do it.

Recalling the contrast.

Returns the contrast as 0 <= con <= 31.
Name: RCON
Size: 27.5 Checksum: # 57CAh
CODE
	GOSBVL	=SAVPTR		save the internal pointers
	D1=(5)	=CONTRAST	point D1 to the contrast value
	A=0	A		zero out A[A]
	A=DAT1	B		read the contrast
	R0=A.F	A		prepare to push
	GOSBVL	=PUSH#		push the bint to the stack
	LC(5)	=UNCOERCE	exit, converting the bint to a real
	A=C	A
	PC=(A)
ENDCODE

Setting the contrast.

Given a real i in the interval 0 <= i <= 31 it sets the contrast to i.
Name: SCON
Size: 44 Checksum: # CA03h
::
 CK1NoBlame	(need one argument)
 CKREAL		(must be a real)
 COERCE		(convert to bint)
 THIRTYONE	(check the range)
 OVER#<
 case
 SETSIZEERR	(error if >31)
 CODE
	GOSBVL	=POP#		pop the number into A[A]
	CD1EX			save D1 in C
	D1=(5)	=CONTRAST	point D1 to contrast
	DAT1=A	B		set the contrast
	CD1EX			restore D1
	A=DAT0	A		exit code object
	D0=D0+	5
	PC=(A)
ENDCODE
;

A nice off-effect.

Assign this program to your off key and the HP will fade out every time you turn it off and it will fade in when you turn it on.
Size: 101.5 Checksum: #9B83h
<< RCON DUP 0 FOR i i SCON .1 WAIT -1 STEP 0 SWAP OFF FOR i i SCON .1 WAIT NEXT >>

Type it in and assign it to the off key: 91.3 ASN