English (function) question

23 views
Skip to first unread message

rob...@hotmail.com

unread,
Sep 30, 2023, 4:40:26 AM9/30/23
to jallib
Hi all.

I have a question for English native speakers. I am working on a library for the HC-SR04 ultrasonic ranging module.

I have functions that return the distance in cm and inch.

My question is the following. One of the functions returns a word so the distance is without a decimal, so 2 cm, 5 inch, etc. The other function returns a float so the distance is with a decimal, so 3.5 cm, 5.1 inch.

I am looking for a good name for these functions. I now have the following names but I am wondering if there is a better name for them:

function hcsr04_get_distance_cm_coarse() return word is
function hcsr04_get_distance_inch_coarse() return word is
function hcsr04_get_distance_cm_fine() return float is
function hcsr04_get_distance_inch_fine() return float is

So I am looking for  a better name for these functions. Any suggestions? 

Thanks.

Kind regards,

Rob



vasi vasi

unread,
Sep 30, 2023, 4:51:27 AM9/30/23
to jal...@googlegroups.com
For a non-native English speaker like me, the function names are perfect!

--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/655e1cd1-adaf-49d9-b645-9ddcef475248n%40googlegroups.com.


--
Vasi

Rob CJ

unread,
Sep 30, 2023, 5:11:34 AM9/30/23
to jal...@googlegroups.com
Hi Vasile,

Thanks 🙂

I just came up with another idea. Using a float value makes the library big in ROM size (it easily adds 600 byte of ROM or more) and I only need one decimal.

So I have another idea and that is return the distance in mm. In that case I only need a word as return value.

So now I have only two functions:
function hcsr04_get_distance_mili_meter() return word is
function hcsr04_get_distance_mili_inch() return word is

I only do not know if mili-inch is an English term. Would like to know that.

Or should I use tens_of_cm and tens_of_inch?

Thanks.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens vasi vasi <fun...@gmail.com>
Verzonden: zaterdag 30 september 2023 10:51
Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: Re: [jallib] English (function) question
 

Oliver Seitz

unread,
Sep 30, 2023, 5:21:47 AM9/30/23
to jal...@googlegroups.com
Hi Rob,

I wanted to suggest to name the functions after the return data type. I never use floats, so if I would have a function called "fine", it would return a length in mm (metric) or mils (=1/1000 inch imperial)

Even if you would return a length in micrometers, a dword would suffice for a range of over 4 kilometers, still by a smaller overhead than using a float.

Greets,
Kiste

Am Samstag, 30. September 2023 um 11:11:37 MESZ hat Rob CJ <rob...@hotmail.com> Folgendes geschrieben:


Rob CJ

unread,
Sep 30, 2023, 5:49:09 AM9/30/23
to jal...@googlegroups.com
Hi Kiste,

Thanks for the suggestion. Question about the mils. The modules resoluiton is limited (see screenshot below). What would 1/000 of an inch bring? Is it because of the standard terminology mils?



So your suggestion would be the following?
function hcsr04_get_distance_mm() return dword is
function hcsr04_get_distance_mils) return dword is

Thanks.

Kind regards,

Rob


Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: zaterdag 30 september 2023 11:21

Oliver Seitz

unread,
Sep 30, 2023, 6:06:27 AM9/30/23
to jal...@googlegroups.com
Yes, otherwise you could use 1/16" or 1/32" which is near a mm, but it seems to be a bit of a strange unit for me.

byte*3 would suffice for the maximum range of 197000 mils, but I'm not sure if it's wise to use that... for 5000mm word is enough :-)

Greets,
Kiste


Am Sa., Sept. 30, 2023 at 11:49 schrieb Rob CJ

Rob CJ

unread,
Sep 30, 2023, 9:28:19 AM9/30/23
to jal...@googlegroups.com
Hi Oliver,

OK, so it will be mm (word) and mil (dword). Sample output looks like this, see below. This is not yet with a module since I did not yet get it. I used another PIC to simulate the module. 

Distance measured is: 25 mm or 1010 mil.
Distance measured is: 2.5 cm or 1.0 inch.

Distance measured is: 34 mm or 1350 mil.
Distance measured is: 3.4 cm or 1.3 inch.

Distance measured is: 58 mm or 2290 mil.
Distance measured is: 5.8 cm or 2.2 inch.

Distance measured is: 81 mm or 3180 mil.
Distance measured is: 8.1 cm or 3.1 inch.

Distance measured is: 95 mm or 3750 mil.
Distance measured is: 9.5 cm or 3.7 inch.

Distance measured is: 103 mm or 4060 mil.
Distance measured is: 10.3 cm or 4.0 inch.

Kind regards,

Rob



Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: zaterdag 30 september 2023 12:06
Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: AW: Re: [jallib] English (function) question
 
Reply all
Reply to author
Forward
0 new messages