Programming HP Calculators/Commands/Graphic Commands

DISPLAY→ edit

Syntax

DISPLAY→ <name>:

Detail

  • Stores the display in GROB <name>. (Note that the arrow is going out of DISPLAY.)
  • Usually used to generate GROBs on which to perform additional graphic commands.

Example

DISPLAY→ G1:
ERASE:WAIT 2:
→DISPLAY G1:
FREEZE:

Stores the display in GROB G1, clears the screen, waits two seconds, then reloads the display on the screen and pauses. (Effectively useless without other graphic commands).

→DISPLAY edit

Syntax

→DISPLAY <name>:

Detail

  • Sends GROB <name> to the display. (Note that the arrow is going in to DISPLAY.)
  • Usually used to output GROBs to the display after altering them using other graphic commands.

Example
See example for DISPLAY→.

→GROB edit

GROBNOT edit

Syntax

GROBNOT <name>:

Detail

  • Inverts the colors in GROB <name>, that is, switches all ON pixels OFF and vice-versa.
  • Could be used to select buttons, for example, but is generally too slow for this purpose.

Example

ERASE:
DISPLAY→ G0:
GROBNOT G0:
→DISPLAY G0:
FREEZE:

This program will erase the screen (ie. turn all pixels OFF), then invert the colours (ie. turn all pixels ON), giving you a black screen.

GROBOR edit

GROBXOR edit

MAKEGROB edit

Syntax

MAKEGROB <name>; <width> <height>
<hex-data>:

Detail

  • Allows you to make a custom grob, pixel-by-pixel using hexadecimal.
  • Much faster than regular drawing commands, so if you have the time to write your GROBs manually, it's strongly recommended. However, it does usually increase the size of the program far more than just using other drawing commands, although this does not affect compile time - so you need to decide which is more important, program size or program speed.
  • Each hexadecimal digit (a number between 0-9, or a letter between A-F) represents a four-digit binary number, which in turn represents four pixels on the screen (where 1 is on and 0 is off). The following table illustrates the pixel on/off sequences produced by each hex digit:
0: 0000 or □□□□ 1: 1000 or ■□□□ 2: 0100 or □■□□ 3: 1100 or ■■□□
4: 0010 or □□■□ 5: 1010 or ■□■□ 6: 0110 or □■■□ 7: 1110 or ■■■□
8: 0001 or □□□■ 9: 1001 or ■□□■ A: 0101 or □■□■ B: 1101 or ■■□■
C: 0011 or □□■■ D: 1011 or ■□■■ E: 0111 or □■■■ F: 1111 or ■■■■
Table detailing pixel patterns created by using different hex digits.
  • The syntax is quite counter-intuitive; the grob name (G0 for example) comes first, followed by a semicolon and a space, then the width and height measurements for the grob, separated by spaces (rather than the usual semicolons). After that, a new line must be created, and the hex-data begins, which is finally ended with the regular :. No newlines must be created whilst typing the hex-data, although the calculator will naturally wrap the data onto the next line anyway.
  • Useful tip: To generate the MAKEGROB code for the entire screen, use other methods to draw the image you desire (eg. SKETCH mode), then press ON+PLOT to save a screenshot to G0. Now, go into HOME view and enter G0, then hit ENTER. Finally, select the text that has just appeared starting with MAKEGROB, and press F5 (COPY), then hit ENTER again. The code is now stored in the Editline program, and you can insert it into any other program by pressing VARS, scrolling down to Programs, selecting Editline, pressing F4 (VALUE), and pressing F6 (OK).
    • Another idea is to crop this grob using SUB to create a sub-GROB, then typing the variable name (eg. G1) for the cropped GROB in HOME view. Use the above procedure to copy this MAKEGROB code into your program, and you will be able to save substantial amounts of space in the program that would otherwise have been taken up by 0s or other erroneous data. If only the calculator had some form of RLE..

Example

MAKEGROB G1; 12 12
FFF10810899999910850A999168108FFF:
■■■■■■■■■■■■
■□□□□□□□□□□■
■□□□□□□□□□□■
■□□■■□□■■□□■
■□□■■□□■■□□■
■□□□□□□□□□□■
■□■□□□□□□■□■
■□□■■□□■■□□■
■□□□□■■□□□□■
■□□□□□□□□□□■
■■■■■■■■■■■■

The above MAKEGROB code translated into the creation of the GROB roughly approximated by the ASCII sketch above.

PLOT→ edit

→PLOT edit

REPLACE edit

SUB edit

ZEROGROB edit