Collection of functions for DM42/Free42 (updated on 2021-02-23)

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
ferni123
Posts: 36
Joined: Tue Aug 08, 2017 11:24 am

Collection of functions for DM42/Free42 (updated on 2021-02-23)

Post by ferni123 »

I have been exploring the programming capabilities of DM42/Free42 and I wrote some functions that I think that they will give some extra functionality to my calculator. So, I decided to share it here in case they are helpful to someone else.

On the other hand, notice that the code uses functionalities available in Free42 v3.0.0. So, in order to use the code in DM42, you would need to add the changes of Free42 in the DM42 code. It is not too complicate.

The main idea of this collection is to make use of the CUSTOM menu as much as possible in the same way that it can be done in HP48G. The summary of the functions are (the details of input/output of each function is embedded in the source code):

https://gitlab.com/fmartinp/programs42/-/releases/1.1.0
https://gitlab.com/fmartinp/programs42/-/tree/1.1.0

Compatible with Free42 3.0.0
MAIN, MATH, HYP, DATES, UNIT, CPX, CONSTANT, CALC, DEBUG

MAIN program
Main menu of the Application suite. It can always be called using XEQ 99

MATH program
Menu for some math functions. So far, the purpose of this function is to
create a CUSTOM menu with the top row shifted funcions.
The menu adds a the LGyX function to compute base-y logarithm.

HYP program
Menu to hyperbolic trigonometric functions.

DATES program
Collection of date related functions accessible through a CUSTOM menu.
List of functions:

DDAYS (Free42 builtin function): Compute number of days between 2 dates
DATE+ Free42 builtin function): Compute the addition of a date and number of days
D→DOY: Convert a date into the day of the year
DOY→D: Convert a day of the year into a date
D→YWD: Convert a date into a year, ISO week and day of the week
YWD→D: Convert a year, ISO week and day of the week in a date
UTIME: Compute current UNIX time (based on Thomas Okken's program: https://thomasokken.com/free42/42progs/unixtime.txt)
T→U: Convert a date into UNIX time (based on Thomas Okken's program: https://thomasokken.com/free42/42progs/unixtime.txt)
U→T: Convert a UNIX time into a date (based on Thomas Okken's program: https://thomasokken.com/free42/42progs/unixtime.txt)
GTIME: Compute current GPS time
T→G: Convert a date into GPS time (GPS week and seconds of the week)
G→T: Conver GPS time (GPS week and seconds of the week) into a date
SDATE: Compute current ESA Solar Orbiter mission planning cycle
D→STP: Convert a date into a ESA Solar Orbiter mission planning cycle
STP→D: Convert a ESA Solar Orbiter mission planning cycle into a date

Note: The convention of days of the week is 1-Monday, 2-Tuesday, 3-Wednesday, 4-Thursday, 5-Friday, 6-Saturday, 0-Sunday

CALC program
Collection of calculus related functions accessible through a CUSTOM menu.
List of functions:

DERIV: Compute the derivative of a selected order and accuracy of a MVAR function (Interactive app)
TAYLR: Compute the taylor expansion of a selected order and accuracy of a MVAR function (Interactive app)
SUMN: Compute the sum of a serie specified by MVAR function (Interactive app)


UNIT converter program
Collection of unit conversion functions accessible through a CUSTOM menu.
List of functions and units:

LENG: meter, inch, yard, mile, nautic mile
AREA: square meter, square foot, acre, hectometer, square kilometer, square mile
MASS: kilogram, dram, onze, pound, stone, carat
VOL: liter, fluid onze, gill, pint, quart, gallon
SPEED: m/s, km, mph, knot, ft/s, in/s
TEMP: Celsius, Kelvin and Farenheit degrees
Time: second, minute, hour, day, sideral day, week
ENGY: Joule, Calorie, Watt per hour, eV
PWER: Watt, Electrical (E), Mechanical (I) and Metric (M) horsepower
Usage:
Select the unit applicable for the X-register and afterwards select the conversion unit.
If no new X-register is introduced with the keyboard, the current value in X-register
as it has already assigned a unit, it can be converted to a new unit just pressing the
unit name in the soft menu
Alternative use, if a unit is pressed twice, the unit is selected and any new value in
X-register is automatically converted to that unit once a unit is assigned to the value.
This behaviour is disabled pressing over the selected unit.


CPX program
Menu to some complex functions. So far, the purpose of this function is to
create a CUSTOM menu with some commons complex funcions.
The program adds the following functions:

CONJ: Computes the conjugate of a complex number
R<>P: Swaps between rectangular and polar modes


CONSTANT Library program
Constant Libray implemented through a programmable menu.

DEBUG program
Menu for some debug functions following Thomas Okken recommendation at:
https://thomasokken.com/free42/

------
Last edited by ferni123 on Tue Feb 23, 2021 7:43 pm, edited 9 times in total.
Vitasam

Re: Collection of functions for DM42/Free42

Post by Vitasam »

Good stuff! Forked it
cdmackay
Posts: 281
Joined: Fri Oct 05, 2018 8:33 pm
Location: Cambridge, UK
Contact:

Re: Collection of functions for DM42/Free42

Post by cdmackay »

nice, thank you.
Cambridge, UK
41CL/DM41X 12/15C/16C DM15/16 17B/II/II+ 28S 42S/DM42 32SII 48GX 50g 35s WP34S PrimeG2 WP43S/pilot
Casio, Rockwell 18R
ferni123
Posts: 36
Joined: Tue Aug 08, 2017 11:24 am

Re: Collection of functions for DM42/Free42

Post by ferni123 »

Thank you. Notice, that there was a typo in the YWD->D function. It was missing the RTN command. I updated the src folder.

My intention is to expand the collection with some functions. I will post here when there is an update.
Thomas Okken
Posts: 1102
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: Collection of functions for DM42/Free42

Post by Thomas Okken »

Note that the next version of Free42 has a change to the RTNERR function, which will take the error number as an argument rather than from the X register. So you'd write RTNERR 4 instead of 4 RTNERR. Old programs will be converted automatically, translating RTNERR without arguments to RTNERR IND ST X, so they will keep working.
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

Re: Collection of functions for DM42/Free42

Post by whuyse »

You implement it before I can even suggest it Thomas ;-)
Werner
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
Thomas Okken
Posts: 1102
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: Collection of functions for DM42/Free42

Post by Thomas Okken »

Don't worry, it's not telepathy. :D

Someone else pointed out that the way RTNERR works now is not ideal if you want to use it without using FUNC. I couldn't argue with that!
ferni123
Posts: 36
Joined: Tue Aug 08, 2017 11:24 am

Re: Collection of functions for DM42/Free42

Post by ferni123 »

Thanks Thomas for the information. Indeed, the new approach of RTNERR has more sense.
ferni123
Posts: 36
Joined: Tue Aug 08, 2017 11:24 am

Re: Collection of functions for DM42/Free42

Post by ferni123 »

For information, I have just added a new program with some calculus operations like derivatives, taylor expansion and sumation of series.

Any comment is welcomed.
User avatar
salvomic
Posts: 186
Joined: Sat Dec 30, 2017 10:09 am
Location: Ragusa, Sicily
Contact:

Re: Collection of functions for DM42/Free42 (updated on 2021-02-03)

Post by salvomic »

very compliments, nice program suite.
Please, could you give some examples to use the new CALC submenu?
I mean: how to prepare the MVAR with the function to evaluate...
thanks,
Salvo
∫aL√0mic (IT9CLU) :: DM42 (SN: 00881), DM41X (SN 00523), DM16, HP Prime, 50g, 41CX, 42s, 71b, 15C, 12C, 35s, WP34s -- Free42
Post Reply