(Free42 or possibly 42s with printer) Larger graphing area - now with PLOTR graphing
|
02-06-2022, 12:12 AM
(This post was last modified: 02-14-2022 03:51 AM by arhtur.)
Post: #1
|
|||
|
|||
(Free42 or possibly 42s with printer) Larger graphing area - now with PLOTR graphing
From the first time I saw a HP 42s, I was surprised to hear that equations could be plotted on the tiny 2 line screen. On the Free42, it is possible to print the LCD to a virtual “printout”. By combining 6 calls to PRLCD, we can have a larger 131x96 area to plot pixels.
The bitmap of the pixels is stored in a 12 row by 131 column matrix where each element has an 8 bit number. Calls to STOIJ, RCLEL and STOEL make it possible to set pixels within a specific portion of the matrix. There are 2 examples that graph the sine function (XEQ SG) and produce a checkerboard pattern (XEQ CB). However, if you want to plot points on your own, first XEQ XYINIT to initialize the matrix. Then, put the Y coordinate (between 0 and 95) and the X coordinate (between 0 and 130) on the stack. Then XEQ XYP. No checks are made for valid coordinates. To “print” the graph, XEQ XYG. Because the Alpha register only holds 44 characters (on the Free42), 6 calls to AGRAPH are necessary to fill the entire LCD (3 times across and twice for the 1st and 2nd row of 8 pixels). To have a graph that is 96 pixels tall, PRLCD is called 6 times. On the Free42, in order to see the graph, tap the LCD portion of the calculator and select “Show Print-Out”. When done, tap “Done”. You will have to press EXIT (ON) to exit the blank calculator screen. This has not been tested on the 42s with a printer, since I don't have a printer. Code: 00 { 408-Byte Prgm } Plotting feature: Now I’ve added the PLOTR program that makes it easier to plot graphs. The variables XMIN, XMAX, YMIN and YMAX must be set. -10 and 10 are good starting points for the min and max values. Also, FN must hold the function to be graphed. FN must take the X value on the stack and return the Y value on the stack. For example, to plot the sine graph: LBL FN SIN RTN To graph y=2x + 3: LBL FN 2 x (times) 3 + RTN The plotter will first draw the draw the X axis (DRX) and then draw the Y axis (DRY). There is no scale to the drawn dashes (they are just 8 pixels apart). If you are using X and Y min and max values that do not include the axis, you can skip drawing the axis by calling PLT01. For a single graph, store the min and max values and the function (FN), XEQ XYINIT XEQ PLOTR XEQ XYG Tap the screen and select “Show Print-Out”. For multiple graphs, 1. XEQ XYINIT 2. Define function in FN 3. XEQ PLOTR (PLOTR can be called the first time, but for subsequent graphs XEQ PLT01 to avoid the axis drawing erasing part of the original graph) Repeat steps 2 and 3 for subsequent functions. XEQ XYG Tap the screen and select “Show Print-Out” Of course there is the limitation that a function like ln(x) cannot be graphed for x<=0. The tangent function seemed to work for me. PLOTR program: Code: 00 { 390-Byte Prgm } Sine Graph: Code: 00 { 136-Byte Prgm } Checkerboard pattern: Code: 00 { 155-Byte Prgm } |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)