mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
Utils.pm: add round() (Forum #33488)
git-svn-id: https://svn.fhem.de/fhem/trunk@7914 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8e004788d0
commit
7ea1f70721
@ -237,6 +237,13 @@ fhemNc($$$)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
round($$)
|
||||||
|
{
|
||||||
|
my($v,$n) = @_;
|
||||||
|
return sprintf("%.${n}f",$v);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
@ -245,47 +252,9 @@ fhemNc($$$)
|
|||||||
<a name="Utils"></a>
|
<a name="Utils"></a>
|
||||||
<h3>Utils</h3>
|
<h3>Utils</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<br/>
|
This is a collection of functions that can be used module-independant
|
||||||
This is a collection of functions that can be used module-independant in all your own development<br/>
|
in all your own development<br/>
|
||||||
</br>
|
</br>
|
||||||
<pre>
|
|
||||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
# IMPORTANT: do not insert your own functions inside
|
|
||||||
# the file 99_Utils.pm!
|
|
||||||
#
|
|
||||||
# This file will be overwritten during an FHEM update and all
|
|
||||||
# your own inserts will be lost.
|
|
||||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
#
|
|
||||||
# To avoid this, we recommend following procedure:
|
|
||||||
#
|
|
||||||
# 1. Create your own file 99_myUtils.pm from the template below,
|
|
||||||
# e.g. with FHEMWEB, Edit files, Editing 99_Utils.pm, and saving it as
|
|
||||||
# 99_myUtils.pm
|
|
||||||
# 2. Put this file inside the ./FHEM directory
|
|
||||||
# 3. Put your own functions into this new file
|
|
||||||
#
|
|
||||||
<br/>
|
|
||||||
<code>
|
|
||||||
# start-of-template
|
|
||||||
package main;
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use POSIX;
|
|
||||||
|
|
||||||
sub
|
|
||||||
myUtils_Initialize($$)
|
|
||||||
{
|
|
||||||
my ($hash) = @_;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
||||||
</code>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
</br>
|
|
||||||
<b>Defined functions</b><br/><br/>
|
<b>Defined functions</b><br/><br/>
|
||||||
<ul>
|
<ul>
|
||||||
<li><b>abstime2rel("HH:MM:SS")</b><br>tells you the difference as HH:MM:SS
|
<li><b>abstime2rel("HH:MM:SS")</b><br>tells you the difference as HH:MM:SS
|
||||||
@ -336,6 +305,10 @@ myUtils_Initialize($$)
|
|||||||
nc replacement.
|
nc replacement.
|
||||||
</li></br>
|
</li></br>
|
||||||
|
|
||||||
|
<li><b>round(value, digits)</b><br>
|
||||||
|
round <value> to given digits behind comma
|
||||||
|
</li></br>
|
||||||
|
|
||||||
<li><b>getUniqueId()</b><br>
|
<li><b>getUniqueId()</b><br>
|
||||||
return the FHEM uniqueID used by the fheminfo command. Uses the
|
return the FHEM uniqueID used by the fheminfo command. Uses the
|
||||||
getKeyValue / setKeyValue functions.
|
getKeyValue / setKeyValue functions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user