79 lines
15 KiB
XML
79 lines
15 KiB
XML
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
|
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_bsp___calculus_8cpp_source" xml:lang="zh">
|
|
<title>bsp_Calculus.cpp</title>
|
|
<indexterm><primary>D:/gitt/MicrochipFor32/bsp_Device/bsp_Calculus.cpp</primary></indexterm>
|
|
浏览该文件的文档.<programlisting linenumbering="unnumbered"><anchor xml:id="_bsp___calculus_8cpp_source_1l00001"/>00001 <emphasis role="comment">/*----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00002"/>00002 <emphasis role="comment"> #</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00003"/>00003 <emphasis role="comment"> #  Copyright (c) 2022 Yuankang Liang(XerolySkinner)</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00004"/>00004 <emphasis role="comment"> #</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00005"/>00005 <emphasis role="comment"> #  本软件按原样提供,无任何明示或暗示</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00006"/>00006 <emphasis role="comment"> #  在任何情况下,作者都不承担任何损害赔偿责任</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00007"/>00007 <emphasis role="comment"> #</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00008"/>00008 <emphasis role="comment"> #  使用的许可声明:</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00009"/>00009 <emphasis role="comment"> #  1.  不得歪曲本软件的来源,你不能声称你编写了原始软件.</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00010"/>00010 <emphasis role="comment"> #  2.  免费授予以任何目的,前提是版权声明出现在所有副本中.</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00011"/>00011 <emphasis role="comment"> #      并且版权声明和许可声明同时出现.</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00012"/>00012 <emphasis role="comment"> #  3.  你有使用,复制,修改,分发,和销售本软件的许可.</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00013"/>00013 <emphasis role="comment"> #  4.  如果你在产品中使用,产品文档中的声明是赞赏的但不是必须的.</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00014"/>00014 <emphasis role="comment"> #  5.  本通知不得从任何来源删除或更改.</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00015"/>00015 <emphasis role="comment"> #</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00016"/>00016 <emphasis role="comment"> #  Yuankang Liang(XerolySkinner)</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00017"/>00017 <emphasis role="comment"> #      E-mail:zabbcccbbaz@163.com</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00018"/>00018 <emphasis role="comment"> #      QQ:2715099320</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00019"/>00019 <emphasis role="comment"> #      Mobile Phone:13005636215</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00020"/>00020 <emphasis role="comment"> #</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00021"/>00021 <emphasis role="comment"> #  All rights reserved.</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00022"/>00022 <emphasis role="comment"> */</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00023"/>00023
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00035"/>00035 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00036"/>00036 <emphasis role="comment">//  头文件</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00037"/>00037 <emphasis role="preprocessor">#include "<link linkend="_bsp___calculus_8h">bsp_Calculus.h</link>"</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00039"/>00039 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00040"/>00040 <emphasis role="comment">//  类函数</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00046"/><link linkend="_classbsp___differential_1a46536b15be29d856b09dd7d261a12ab1">00046</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">float</emphasis> <link linkend="_classbsp___differential_1a46536b15be29d856b09dd7d261a12ab1">bsp_Differential::Differential</link>(<emphasis role="keywordtype">float</emphasis> var) {
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00047"/>00047     <emphasis role="keyword">static</emphasis> <emphasis role="keywordtype">float</emphasis> old=var;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00048"/>00048     <emphasis role="keywordtype">float</emphasis> result= (var - old) / <link linkend="_classbsp___differential_1ab25588868059974b8356e975c6e96992">dt</link>;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00049"/>00049     old = var;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00050"/>00050     <emphasis role="keywordflow">return</emphasis> result;}
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00052"/>00052 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00053"/>00053 <emphasis role="comment">//  类函数</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00059"/><link linkend="_classbsp___integral_1ade46f89bfdc6dd778c045a51c76c1839">00059</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">float</emphasis> <link linkend="_classbsp___integral_1ade46f89bfdc6dd778c045a51c76c1839">bsp_Integral::Integral</link>(<emphasis role="keywordtype">float</emphasis> var) {
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00060"/>00060     <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">results</link> += var * <link linkend="_classbsp___integral_1a4494cf9fc2873d457ed3bf8618b68045">dt</link>;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00061"/>00061     <emphasis role="keywordflow">return</emphasis> <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">results</link>;}
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00062"/>00062 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00067"/><link linkend="_classbsp___integral_1aaf7474301ed76ca9ce2b1884ae870019">00067</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis> <link linkend="_classbsp___integral_1aaf7474301ed76ca9ce2b1884ae870019">bsp_Integral::Integral_set</link>(<emphasis role="keywordtype">float</emphasis> results) {
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00068"/>00068     <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">bsp_Integral::results</link> = <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">results</link>;}
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00069"/>00069 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00075"/><link linkend="_classbsp___integral_1a86d9e02d1146744fe80ebab69070abb4">00075</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1afaa62991928fb9fb18ff0db62a040aba">u32</link> <link linkend="_classbsp___integral_1a86d9e02d1146744fe80ebab69070abb4">bsp_Integral::Integral_makelist</link>(<link linkend="_varint_8h_1afaa62991928fb9fb18ff0db62a040aba">u32</link> len) {
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00076"/>00076     <link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link> = (<emphasis role="keywordtype">float</emphasis>*)malloc(<emphasis role="keyword">sizeof</emphasis>(<emphasis role="keywordtype">float</emphasis>)* len);
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00077"/>00077     <link linkend="_classbsp___integral_1a662c735b9432a46e48a642ebb9c0e8fa">result_len</link> = len;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00078"/>00078     <link linkend="_classbsp___integral_1aae2b6143ca39861a83b77befc131bf5e">Integral_clslist</link>();
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00079"/>00079     <emphasis role="keywordflow">return</emphasis> (<link linkend="_varint_8h_1afaa62991928fb9fb18ff0db62a040aba">u32</link>)<link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link>;}
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00080"/>00080 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00086"/><link linkend="_classbsp___integral_1a80693e18b9b9509bdec0ebfd72f84072">00086</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">float</emphasis> <link linkend="_classbsp___integral_1a80693e18b9b9509bdec0ebfd72f84072">bsp_Integral::Integral_list</link>(<emphasis role="keywordtype">float</emphasis> var) {
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00087"/>00087     <emphasis role="keyword">static</emphasis> <link linkend="_varint_8h_1afaa62991928fb9fb18ff0db62a040aba">u32</link> len=0;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00088"/>00088     <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">results</link> += var * <link linkend="_classbsp___integral_1a4494cf9fc2873d457ed3bf8618b68045">dt</link>;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00089"/>00089     <emphasis role="comment">//  保存历史</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00090"/>00090     <link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link>[len] = var * <link linkend="_classbsp___integral_1a4494cf9fc2873d457ed3bf8618b68045">dt</link>;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00091"/>00091     <emphasis role="comment">//  轮盘转</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00092"/>00092     ++len;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00093"/>00093     <emphasis role="keywordflow">if</emphasis> (len == <link linkend="_classbsp___integral_1a662c735b9432a46e48a642ebb9c0e8fa">result_len</link>)len = 0;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00094"/>00094     <emphasis role="comment">//  去除尾值</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00095"/>00095     <emphasis role="keywordflow">if</emphasis> (len < <link linkend="_classbsp___integral_1a662c735b9432a46e48a642ebb9c0e8fa">result_len</link> - 1)
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00096"/>00096         <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">results</link> -= <link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link>[len + 1];
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00097"/>00097     <emphasis role="keywordflow">else</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00098"/>00098         <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">results</link> -= <link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link>[0];
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00099"/>00099     <emphasis role="comment">//  </emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00100"/>00100     <emphasis role="keywordflow">return</emphasis> <link linkend="_classbsp___integral_1a910f1f3faa2b4963e00718472b8389bc">results</link>;}
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00101"/>00101 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00105"/><link linkend="_classbsp___integral_1a47307ddf418d2686245b118dcf61a199">00105</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis> <link linkend="_classbsp___integral_1a47307ddf418d2686245b118dcf61a199">bsp_Integral::Integral_dellist</link>(<emphasis role="keywordtype">void</emphasis>) {
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00106"/>00106     free(<link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link>);
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00107"/>00107     <link linkend="_classbsp___integral_1a662c735b9432a46e48a642ebb9c0e8fa">result_len</link> = 0;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00108"/>00108     <link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link> = NULL;}
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00109"/>00109 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00113"/><link linkend="_classbsp___integral_1aae2b6143ca39861a83b77befc131bf5e">00113</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">void</emphasis> <link linkend="_classbsp___integral_1aae2b6143ca39861a83b77befc131bf5e">bsp_Integral::Integral_clslist</link>(<emphasis role="keywordtype">void</emphasis>) {
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00114"/>00114     <emphasis role="keywordflow">if</emphasis> (<link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link> == NULL)<emphasis role="keywordflow">return</emphasis>;
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00115"/>00115     <emphasis role="keywordflow">for</emphasis> (<link linkend="_varint_8h_1afaa62991928fb9fb18ff0db62a040aba">u32</link> i = 0; i < <link linkend="_classbsp___integral_1a662c735b9432a46e48a642ebb9c0e8fa">result_len</link>; i++)
|
|
<anchor xml:id="_bsp___calculus_8cpp_source_1l00116"/>00116         <link linkend="_classbsp___integral_1a656d90c5a713abf0665f1dcbf1a5101a">result_list</link>[i] = 0;}
|
|
</programlisting></section>
|