<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4227859192204235074</id><updated>2026-08-17T04:30:38.805-07:00</updated><category term="Cpp"/><category term="Qt"/><category term="AVR"/><category term="Arduino"/><category term="Bash"/><category term="Python"/><category term="Wemos"/><title type='text'>TipsNotas</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tipsnotas.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-4610922345693942756</id><published>2023-10-18T19:14:00.004-07:00</published><updated>2023-10-18T19:39:06.945-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><title type='text'>Fast linked list without list</title><content type='html'>If you need a very fast way to iterate over a list of objects and call the same method on all of them, then here is a posible solution.
&lt;br /&gt;
Derive your objects from this class and implement &lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;i&gt;doSomething()&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;:&lt;br /&gt;


&lt;br /&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: olive;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple; font-weight: 600;&quot;&gt;Element&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;public&lt;/span&gt;:&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #00677c; font-weight: 600;&quot;&gt;Element&lt;/span&gt;();&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;~&lt;span style=&quot;color: #00677c; font-weight: 600;&quot;&gt;Element&lt;/span&gt;();&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;virtual&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #00677c; font-style: italic; font-weight: 600;&quot;&gt;doSomething&lt;/span&gt;()=&lt;span style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;Element&lt;/span&gt;*&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;next&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #00677c; font-weight: 600;&quot;&gt;addElement&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;Element&lt;/span&gt;*&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;{&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: maroon;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce5c00;&quot;&gt;first&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: #ce5c00;&quot;&gt;first&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;}&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;Element&lt;/span&gt;*&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce5c00;&quot;&gt;first&lt;/span&gt;=&lt;span style=&quot;color: purple; font-weight: 600;&quot;&gt;nullptr&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;};&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;
And to use it:&lt;br /&gt;

&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Adding&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;one&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;element&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;the&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;list:&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;Element&lt;/span&gt;::&lt;span style=&quot;color: #00677c;&quot;&gt;addElement&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #092e64; font-style: italic;&quot;&gt;myObject&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;);&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Iterating&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;over&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;the&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;objects:&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;Element&lt;/span&gt;*&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;Element&lt;/span&gt;::&lt;span style=&quot;color: #ce5c00;&quot;&gt;first&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;while&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #00677c; font-style: italic;&quot;&gt;doSomething&lt;/span&gt;();&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;el&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: maroon;&quot;&gt;next&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/4610922345693942756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/4610922345693942756'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2023/10/fast-linked-list-without-list.html' title='Fast linked list without list'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-660380035832356504</id><published>2023-09-21T06:35:00.005-07:00</published><updated>2023-09-21T08:14:33.163-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>Find file in folder recursive with Qt.</title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;/div&gt;This function returns the absolute path of a file in a folder (or subfolder).&lt;br /&gt;
It searchs recursively in all subfolders until it finds the file or return an empty QString if the file is not found.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: purple;&quot;&gt;QString&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #00677c; font-weight: 600;&quot;&gt;findFile&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;QString&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;dir&lt;/span&gt;,&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;QString&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileName&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;{&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;QDir&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;pathDir&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;dir&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;);&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;QFileInfo&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileInfo&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;:&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;pathDir&lt;/span&gt;.&lt;span style=&quot;color: #00677c;&quot;&gt;entryInfoList&lt;/span&gt;()&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;{&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileInfo&lt;/span&gt;.&lt;span style=&quot;color: #00677c;&quot;&gt;isFile&lt;/span&gt;()&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;{&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileInfo&lt;/span&gt;.&lt;span style=&quot;color: #00677c;&quot;&gt;fileName&lt;/span&gt;()&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #00677c;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileName&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileInfo&lt;/span&gt;.&lt;span style=&quot;color: #00677c;&quot;&gt;absoluteFilePath&lt;/span&gt;();&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;}&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;!&lt;span style=&quot;color: #092e64;&quot;&gt;fileInfo&lt;/span&gt;.&lt;span style=&quot;color: #00677c;&quot;&gt;fileName&lt;/span&gt;().&lt;span style=&quot;color: #00677c;&quot;&gt;endsWith&lt;/span&gt;(&lt;span style=&quot;color: green;&quot;&gt;&quot;.&quot;&lt;/span&gt;)&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;{&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;QString&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;found&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;=&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #00677c;&quot;&gt;findFile&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileInfo&lt;/span&gt;.&lt;span style=&quot;color: #00677c;&quot;&gt;absoluteFilePath&lt;/span&gt;(),&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;fileName&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;);&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;!&lt;span style=&quot;color: #092e64;&quot;&gt;found&lt;/span&gt;.&lt;span style=&quot;color: #00677c;&quot;&gt;isEmpty&lt;/span&gt;()&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;)&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #092e64;&quot;&gt;found&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;        &lt;/span&gt;}&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;}&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: silver;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: olive;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: silver;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;}&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/660380035832356504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/660380035832356504'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2023/09/find-file-in-folder-recursive-with-qt.html' title='Find file in folder recursive with Qt.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-8774821541804724143</id><published>2023-09-17T21:55:00.001-07:00</published><updated>2023-09-17T21:56:46.972-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>Connect QObject signal to non QObject class.</title><content type='html'>Usually you need to derive from QObject and use the Q_OBJECT macro to connect to some slot in your class.&lt;br&gt;
But sometimes you want to connect a QObject signal to do something in a non QObject class.&lt;br&gt;
&lt;br&gt;
There are several posible reasons to not derive from QObject or use the Q_OBJECT macro, but in any case you can connect to a non QObejct class using lambdas:&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
  // Connect to menu action

  QMenu* menu:

  QAction* myAction = menu-&gt;addAction( QIcon(&quot;:/myIcon.svg&quot;), &quot;Do something&quot; );

  QObject::connect( myAction, &amp;QAction::triggered, [=](){ myFuncion(); });



  // Connect to QPushButton

  QPushButton* button = new QPushButton();

  QObject::connect( button, &amp;QPushButton::released, [=](){ onButtonReleased(); });
```
&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8774821541804724143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8774821541804724143'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2023/09/connect-qobject-signal-to-non-qobject.html' title='Connect QObject signal to non QObject class.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-5286493612448115742</id><published>2023-08-09T10:52:00.002-07:00</published><updated>2023-08-09T10:58:34.162-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>Submenu in a QMenu.</title><content type='html'>Adding a submenu to a QMenu is really easy, and you add nested submenus if you want:

&lt;pre class=&quot;markdown&quot;&gt;
```c
	QMenu* mainMenu;
	
	QAction* action1 = mainMenu-&gt;addAction(QIcon(&quot;:/icon1.png&quot;),&quot;Entry1&quot; );
    connect( action1, &amp;QAction::triggered,
                this, &amp;MyClasss::mySlot1, Qt::UniqueConnection );

    QAction* action2 = mainMenu-&gt;addAction(QIcon(&quot;:/icon2.png&quot;), &quot;Entry2&quot; );
    connect( action2, &amp;QAction::triggered,
                this, &amp;MyClasss::mySlot2, Qt::UniqueConnection );

	// --- SUBMENU --------------------------------------------------------
	
	QMenu* subMenu = mainMenu-&gt;addMenu( QIcon(&quot;:/menuIcon.png&quot;), &quot;SubMenu Title&quot; );
	
	QAction* subAction1 = mainMenu-&gt;addAction(QIcon(&quot;:/subIcon1.png&quot;),&quot;subEntry1&quot; );
    connect( subAction1, &amp;QAction::triggered,
                   this, &amp;MyClasss::subSlot1, Qt::UniqueConnection );

    QAction* subAction2 = mainMenu-&gt;addAction(QIcon(&quot;:/subIcon2.png&quot;), &quot;subEntry2&quot; );
    connect( subAction2, &amp;QAction::triggered,
                   this, &amp;MyClasss::subSlot2, Qt::UniqueConnection );

	// --------------------------------------------------------------------
	
	
	QAction* action3 = mainMenu-&gt;addAction(QIcon(&quot;:/icon3.png&quot;),&quot;Entry3&quot; );
    connect( action3, &amp;QAction::triggered,
                this, &amp;MyClasss::mySlot3, Qt::UniqueConnection );

    QAction* action4 = mainMenu-&gt;addAction(QIcon(&quot;:/icon4.png&quot;), &quot;Entry4&quot; );
    connect( action4, &amp;QAction::triggered,
                this, &amp;MyClasss::mySlot4, Qt::UniqueConnection );
```
&lt;/pre&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/5286493612448115742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/5286493612448115742'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2023/08/submenu-in-qmenu.html' title='Submenu in a QMenu.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-6089312011201689269</id><published>2023-08-08T04:58:00.009-07:00</published><updated>2023-08-09T10:57:27.478-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><title type='text'>Simple and fast signal-slot system in C++.</title><content type='html'>&lt;p&gt;&amp;nbsp;This is a simple and fast implementation of a signal-slot system in C++.&lt;/p&gt;
It&#39;s goal is to be simple and as fast as possible.&lt;br /&gt;
&lt;br /&gt;
For that, we create a signal-slot system tha is specific for our use case, that&#39;s the price we pay for a fast system.&lt;br /&gt;
In this case we create callbacks that take an integer value, but it could be adapted for any oyhter use case.&lt;br /&gt;
&lt;br /&gt;
First we need a base class for our callbacks.&lt;br /&gt;
We need this class to virtualize the call() function and easily link callbacks in order to create a list.&lt;br /&gt;
It is implemented as a linked list: each callbacks holds a pointer to the function to call and a pointer to the next callback.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
class CallBackBase
{
    public:
        CallBackBase(){;}
        virtual ~CallBackBase(){;}

        virtual void call( int ){;}

        CallBackBase* nextCallBack;
};
```
&lt;/pre&gt;
&lt;br&gt;
Here we have our callback class.&lt;br /&gt;
We create callbacks with an object and a member funtion to call:&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
template &amp;lt;class Obj&amp;gt;
class CallBack : public CallBackBase
{
        friend class Signal;

    public:
        CallBack( Obj* object, void (Obj::*func)(int) )
        : CallBackBase()
        {
            m_object = object;
            m_func   = func;
            nextCallBack = 0;
        }
        ~CallBack() {;}

        virtual void call( int val ) override
        { (m_object-&amp;gt;*m_func)(val); }

    private:
        Obj* m_object;
        void (Obj::*m_func)(uint8_t);
};
```
&lt;/pre&gt;
&lt;br&gt;
And this is our signal class:&lt;br /&gt;
We can add callbacks with the function connect() and remove callbacks with the function disconnect().&lt;br /&gt;
On emitValue() we call all the callbacks with an integer value as argument:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
class Signal
{
    public:
        Signal()
        {
            m_slot = 0;
        }
        ~Signal()       // Free resources created
        {
            CallBackBase* slot = m_slot;
            while( slot ) // delete slots
            {
                CallBackBase* slotDel = slot;
                slot = slot-&amp;gt;nextCallBack;
                delete slotDel;
        }   }

        template &amp;lt;class Obj&amp;gt;
        void connect( Obj* obj, void (Obj::*func)(int) )
        {
            CallBack&amp;lt;Obj&amp;gt;* slot = new CallBack&amp;lt;Obj&amp;gt;( obj, func );

            slot-&amp;gt;nextCallBack = m_slot;
            m_slot = slot;
        }

        template &amp;lt;class Obj&amp;gt;
        void disconnect( Obj* obj, void (Obj::*func)(int) )
        {
            CallBackBase* preSlot = 0;
            CallBackBase* posSlot = m_slot;
            while( posSlot )
            {
                CallBack&amp;lt;Obj&amp;gt;* cb = dynamic_cast&amp;lt;CallBack&amp;lt;Obj&amp;gt;*&amp;gt;(posSlot);

                if( cb-&amp;gt;m_object == obj &amp;amp;&amp;amp; cb-&amp;gt;m_func == func )
                {
                    if( preSlot ) preSlot-&amp;gt;nextCallBack = posSlot-&amp;gt;nextCallBack;
                    else          m_slot = posSlot-&amp;gt;nextCallBack;
                    delete posSlot;
                    break;
                }
                preSlot = posSlot;
                posSlot = posSlot-&amp;gt;nextCallBack;
        }   }

        void emitValue( int val ) // Calls all connected CallBacks 
        {
            CallBackBase* slot = m_slot;
            while( slot )
            {
                slot-&amp;gt;call( val );
                slot = slot-&amp;gt;nextCallBack;
        }   }

    private:
        CallBackBase* m_slot;
};
```
&lt;/pre&gt;
&lt;br&gt;
To use it we create signals, connect callbacks and call emitValue() when needed.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
	AnObjectClass*    anObject     = new AnObjectClass();
	OtherObjectClass* otherObject  = new OtherObjectClass();
	ThirdObjectClass* thirdObject  = new ThirdObjectClass();
	OtherObjectClass* otherObject2 = new OtherObjectClass();

    Signal on_write;
    on_write.connect( anObject,    &amp;amp;AnObjectClass::writeFunc );
    on_write.connect( otherObject, &amp;amp;OtherObjectClass::otherFunc );
    
    Signal on_read;
    on_read.connect( thirdObject,  &amp;amp;ThirdObjectClass::readFunc );
    on_read.connect( otherObject2, &amp;amp;OtherObjectClass::someFunc );
    
    
    void on_write_event( int value )
    {
		on_write.emitValue( value );
	}
	
	void on_read_event( int value )
	{
		on_read.emitValue( value );
	}
```
&lt;/pre&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6089312011201689269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6089312011201689269'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2023/08/simple-and-fast-signal-slot-system-in-c.html' title='Simple and fast signal-slot system in C++.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-6271056845153294512</id><published>2022-08-15T21:03:00.004-07:00</published><updated>2023-08-09T10:57:49.825-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><title type='text'>C++ Pointer to member Function.</title><content type='html'>&lt;pre class=&quot;markdown&quot;&gt;
```c
// Create a data type: &quot;Pointer to MyClass function&quot; with type name: &quot;funcPtr_t&quot;
typedef void (MyClass::*funcPtr_t)();

QList&lt;funcPtr_t&gt; funcList;           // Create a list of pointers

funcPtr_t fp = &amp;MyClass::myFunction; // Create a pointer to function &quot;myFunction&quot; with name &quot;fp&quot;

funcList.append( fp );               // Add to list

for( funcPtr_t func : funcList)      // Call all functions in our list (there is only one)
{
	(this-&gt;*func)();                 // We are calling from an object of the same class
}

// ---------------------------------------------------------------------------------------------

Myclass myObject;

for( funcPtr_t func : funcList)      // Call all functions in our list (there is only one)
{
	(myObject.*func)();              // We are calling from outside &quot;MyClass&quot;
}

	// ---------------------------------------------------------------------------------------------

Myclass* myObject = new Myclass();

for( funcPtr_t func : funcList)      // Call all functions in our list (there is only one)
{
	(myObject-&gt;*func)();             // We are calling from outside &quot;MyClass&quot;
}
```
&lt;/pre&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6271056845153294512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6271056845153294512'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2022/08/c-pointer-to-member-function.html' title='C++ Pointer to member Function.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-5573765499119544792</id><published>2019-09-16T16:50:00.000-07:00</published><updated>2019-09-16T17:03:00.134-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Bash"/><title type='text'>Bash script to create gif from ogv video</title><content type='html'>Adjust FPS to your needs.&lt;br /&gt;
&lt;br /&gt;
If you save it as &quot;ogvtogif&quot; use like this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;$ ogvtogif file.ogv&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
_____________________________________________________________&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;INPUT_FILE=$1&lt;br /&gt;FPS=8&lt;br /&gt;&lt;br /&gt;TEMP_FILE_PATH=&quot;tmp.png&quot;&lt;br /&gt;&lt;br /&gt;ffmpeg -i $INPUT_FILE -vf fps=$FPS,palettegen $TEMP_FILE_PATH&lt;br /&gt;ffmpeg -i $INPUT_FILE -i $TEMP_FILE_PATH -loop 0 -filter_complex &quot;fps=$FPS,paletteuse&quot; $INPUT_FILE.gif&lt;br /&gt;&lt;br /&gt;rm $TEMP_FILE_PATH&lt;/span&gt;&lt;/blockquote&gt;
_____________________________________________________________</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/5573765499119544792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/5573765499119544792'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2019/09/create-gif-from-ogv-video-bash-script.html' title='Bash script to create gif from ogv video'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-8890734859314144426</id><published>2018-07-25T07:41:00.003-07:00</published><updated>2023-08-09T11:27:05.335-07:00</updated><title type='text'>Symple JavaScript applet.</title><content type='html'>Simple JavaScript applet to do some calculations in a webpage:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```html
	&amp;lt;br /&amp;gt;
	This is a JS applet example.&amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	Set &quot;A&quot; value and choose &quot;Multiplier&quot;.&amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	Click on &quot;Calculate&quot; to perform the operation.&amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	&amp;lt;hr /&amp;gt;
	&amp;lt;br /&amp;gt;
	&amp;lt;div&amp;gt;
	  &amp;lt;script&amp;gt;

		function mult(form)
		{
		  var valA = form.A.value;
		  var valM = form.M.value;
		  
		  form.AxM.value = valA*valM;
		}
	  &amp;lt;/script&amp;gt; &amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	&amp;lt;form name=&quot;multiply&quot;&amp;gt;
	&amp;lt;br /&amp;gt;
	Number A: &amp;lt;input name=&quot;A&quot; style=&quot;background-color: white; width: 100px;&quot; value=&quot;0&quot; /&amp;gt;&amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	Multiplier : &amp;lt;select name=&quot;M&quot; style=&quot;background-color: white; width: 100px;&quot; value=&quot;2&quot;&amp;gt;
					 &amp;lt;option value=&quot;2&quot;&amp;gt;x2&amp;lt;/option&amp;gt;
					 &amp;lt;option value=&quot;4&quot;&amp;gt;x4&amp;lt;/option&amp;gt; &amp;lt;/select&amp;gt; &amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	&amp;lt;input name=&quot;Calc&quot; onclick=&quot;mult(this.form)&quot; style=&quot;width: 100px;&quot; type=&quot;button&quot; value=&quot;Calculate&quot; /&amp;gt;  &amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	&amp;lt;hr /&amp;gt;
	&amp;lt;br /&amp;gt;
	A x Multiplier = &amp;lt;input name=&quot;AxM&quot; style=&quot;width: 95px;&quot; value=&quot;&quot; /&amp;gt; &amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;
	&amp;lt;br /&amp;gt;&amp;lt;/form&amp;gt;
	&amp;lt;/div&amp;gt;
```
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
This is how it looks:&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;--------------------------------------------------&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is a JS applet example.&lt;br /&gt;
&lt;br /&gt;
Set &quot;A&quot; value and choose &quot;Multiplier&quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &quot;Calculate&quot; to perform the operation.&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;script&gt;

    function mult(form)
    {
      var valA = form.A.value;
      var valM = form.M.value;
      
      form.AxM.value = valA*valM;
    }
  &lt;/script&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;form name=&quot;multiply&quot;&gt;
&lt;br /&gt;
Number A: &lt;input name=&quot;A&quot; style=&quot;background-color: white; width: 100px;&quot; value=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Multiplier : &lt;select name=&quot;M&quot; style=&quot;background-color: white; width: 100px;&quot; value=&quot;2&quot;&gt;
                 &lt;option value=&quot;2&quot;&gt;x2&lt;/option&gt;
                 &lt;option value=&quot;4&quot;&gt;x4&lt;/option&gt; &lt;/select&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;input name=&quot;Calc&quot; onclick=&quot;mult(this.form)&quot; style=&quot;width: 100px;&quot; type=&quot;button&quot; value=&quot;Calculate&quot; /&gt;  &lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
A x Multiplier = &lt;input name=&quot;AxM&quot; style=&quot;width: 95px;&quot; value=&quot;&quot; /&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/form&gt;
&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8890734859314144426'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8890734859314144426'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2018/07/symple-javascript-applet.html' title='Symple JavaScript applet.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-8546912176377892766</id><published>2018-06-23T02:02:00.003-07:00</published><updated>2023-08-09T10:59:14.985-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>Integer to any base QString</title><content type='html'>This function takes an integer and returns a QString with the representation in any base &amp;lt; 16.&lt;br /&gt;
&lt;br /&gt;
It uses the &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;val2hex &lt;/span&gt;function from previous post: &lt;br /&gt;

.....................................................................................................&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
QString val2hex( int d )
{
    QString Hex=&quot;0123456789ABCDEF&quot;;

    QString h = Hex.mid( d&amp;15, 1 );

    while( d&gt;15 )
    {
        d &gt;&gt;= 4;
        h = Hex.mid( d&amp;15,1 ) + h;
    }
    return h;
}

QString decToBase( int value, int base, int digits )
{
    QString converted = &quot;&quot;;

    for( int i=0; i&lt;digits; i++ )
    {
        if( value &gt;= base ) converted = val2hex(value%base) + converted;
        else                converted = val2hex(value) + converted;

        value = floor( value/base );
    }
    return converted;
}
```
&lt;/pre&gt;
.....................................................................................................</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8546912176377892766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8546912176377892766'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2018/06/integer-to-any-base-qstring.html' title='Integer to any base QString'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-6220638922413518888</id><published>2018-06-23T01:56:00.004-07:00</published><updated>2023-08-09T10:59:42.132-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>Integer to Hex QString</title><content type='html'>This function takes an integer and returns a QString with the exadecimal representation:&lt;br /&gt;

.....................................................................................................&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
QString val2hex( int d )
{
    QString Hex=&quot;0123456789ABCDEF&quot;;

    QString h = Hex.mid( d&amp;15, 1 );

    while( d&gt;15 )
    {
        d &gt;&gt;= 4;
        h = Hex.mid( d&amp;15,1 ) + h;
    }
    return h;
}
```
&lt;/pre&gt;
.....................................................................................................</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6220638922413518888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6220638922413518888'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2018/06/integer-to-hex-qstring.html' title='Integer to Hex QString'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-7356237642631450807</id><published>2018-06-22T01:50:00.005-07:00</published><updated>2023-08-09T10:58:43.735-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>File to QString</title><content type='html'>Read a file and parse whole content to a QString:&lt;br /&gt;

.....................................................................................................&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
QString fileToString( const QString &amp;fileName, const QString &amp;caller )
{
    QFile file( fileName );

    if( !file.open(QFile::ReadOnly | QFile::Text))
    {
        QMessageBox::warning( 0l, caller, 
                              &quot;Cannot read file &quot;
                              +fileName+&quot;:\n&quot;
                              +file.errorString());
        return &quot;&quot;;
    }

    QTextStream in( &amp;file );
    QString text = in.readAll();
    file.close();

    return text;
}
```
&lt;/pre&gt;
.....................................................................................................&lt;br /&gt;
&lt;br /&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/7356237642631450807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/7356237642631450807'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2018/06/file-to-qstring.html' title='File to QString'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-6882700929057168090</id><published>2018-06-22T01:42:00.003-07:00</published><updated>2023-08-09T10:59:32.028-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>File to QStringList </title><content type='html'>Read a file and parse each line to a QStringList:&lt;br /&gt;
&lt;br /&gt;
.....................................................................................................&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
QStringList fileToStringList( const QString &amp;fileName, const QString &amp;caller )
{
    QStringList text;
    QFile file(fileName);

    if( !file.open( QFile::ReadOnly | QFile::Text) )
    {
        QMessageBox::warning( 0l, caller, 
                              &quot;Cannot read file &quot;
                              +fileName+&quot;:\n&quot;
                              +file.errorString());
        return text;
    }

    QTextStream in( &amp;file );
    while( !in.atEnd() ) text.append( in.readLine() );
    file.close();

    return text;
}
```
&lt;/pre&gt;
&lt;br /&gt;
.....................................................................................................</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6882700929057168090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6882700929057168090'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2018/06/file-content-to-qstringlist.html' title='File to QStringList '/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-4510601705317428576</id><published>2018-06-22T01:25:00.002-07:00</published><updated>2023-08-09T11:00:06.535-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><title type='text'>Add entry to QListWidget and resize to content</title><content type='html'>Sometimes is useful resizing a QListWidget to the size of its content.&lt;br /&gt;
This is one way to do it.&lt;br /&gt;
&lt;br /&gt;
Don&#39;t forget resizing again when you remove an item.&lt;br /&gt;
&lt;br /&gt;
.....................................................................................................&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
void addEntry( QString name, QListWidget* list )
{
    QListWidgetItem* item = new QListWidgetItem( name, list, 0 );
  
    QFont font;
    font.setPointSize(10);
    font.setWeight(70);
    item-&gt;setFont( font );

    item-&gt;setIcon( QIcon(&quot;:/icon.png&quot;) );
       
    int iconSize = 22;                       // I know icon size

    int size = list-&gt;count()*iconSize + 2;

    list-&gt;setFixedHeight( size );
}
```
&lt;/pre&gt;
&lt;br /&gt;
..................................................................................................... </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/4510601705317428576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/4510601705317428576'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2018/06/add-entry-to-qlistwidget-and-resize-to.html' title='Add entry to QListWidget and resize to content'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-8297810373153134301</id><published>2018-04-24T13:07:00.004-07:00</published><updated>2023-08-09T11:00:23.085-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="Wemos"/><title type='text'>Wemos to InfluxDB via Wifi</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;This is a simple example of how to send data from a Wemos board to InfluxDB&amp;nbsp; throught wifi.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Tested with Wemos D1 R2 and Arduino IDE. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;You should change ssid, password to your wifi.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Also InfluxDB database name and data you are using.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
.....................................................................................................&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;markdown&quot;&gt;
```c
#include &amp;lt;Arduino.h&amp;gt;

#include &amp;lt;ESP8266WiFi.h&amp;gt;
#include &amp;lt;ESP8266WiFiMulti.h&amp;gt;
#include &amp;lt;ESP8266HTTPClient.h&amp;gt;

#define USE_SERIAL // Comment this line for no serial

const char* ssid = &quot;Your_SSID&quot;;
const char* password = &quot;Your_Pass&quot;;

ESP8266WiFiMulti WiFiMulti;

void setup()
{
    #ifdef USE_SERIAL
    Serial.begin( 115200 );
    #endif

    WiFi.mode( WIFI_STA );
    WiFiMulti.addAP( ssid, password );
}

void loop()
{
    if( WiFiMulti.run() == WL_CONNECTED ) // wait for WiFi connection
    {
        int sensorValue = analogRead( A0 );
       
        // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.2V):
        float voltage = sensorValue * (3.2/1023.0);
       
        #ifdef USE_SERIAL
        Serial.println( voltage );
        #endif
       
        HTTPClient http;

        #ifdef USE_SERIAL
        Serial.print( &quot;[HTTP] begin...\n&quot; );
        #endif
       
        // Start writting to influxbd database: mydb
        // Set database, IP and Port you are using
        http.begin( &quot;http://192.168.1.33:8086/write?db=mydb&quot; );
  
        // Send data to influxbd
        // Set data you are using
        int httpCode = http.POST( &quot;Volts,Bat=Lead-Acid,Ser=pruebas value=&quot;+String(voltage) );
       
        #ifdef USE_SERIAL
        if(httpCode == 204) // Data Succesfully Written
        {
            Serial.printf( &quot;Data Succesfully Written... code: %d\n&quot;, httpCode );

        }
        else // Data Failed
        {
            Serial.printf( &quot;Data Failed... code: %d\n&quot;, httpCode );
            Serial.printf( &quot;Error: %s\n&quot;, http.errorToString(httpCode).c_str() );
        }
        #endif
       
        http.end();
    }

    delay( 10000 ); // Wait for 10 seconds
}
```
&lt;/pre&gt;
&lt;br /&gt;
.....................................................................................................</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8297810373153134301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/8297810373153134301'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2018/04/wemos-to-influxdb-via-wifi.html' title='Wemos to InfluxDB via Wifi'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-6789972103815198126</id><published>2017-10-25T08:56:00.004-07:00</published><updated>2023-08-09T11:17:01.768-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AVR"/><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><title type='text'>AVR Software PWM</title><content type='html'>One way to do software pwm is setting up a timer with interrupt corresponding to each pwm step. then in the interrupt routine check whether each pwm channel should be on or off.&lt;br /&gt;
&lt;br /&gt;
The key question here is how fast and how many steps should be the PWM.&lt;br /&gt;
All depends in how much processing time you need for other tasks, and how many PWMs to run.&lt;br /&gt;
&lt;br /&gt;
A good aproach that works for me is doing a 64 steps, 200 uS per step PWM for around 50 PWM channels.&lt;br /&gt;
This give us a total time of 50*200=12800 uS = 12.8 mS =&amp;gt; 78.125 Hz.&lt;br /&gt;
Getting less than 10% of processing time.&lt;br /&gt;
&lt;br /&gt;
I ussually do it with Timer0, this creates a 200 uS Timer0 CompA Interrupt.&lt;br /&gt;
I think it works for most AVR, but you can choose the part you need depending on wich registers your mcu uses:&lt;br /&gt;
&lt;br /&gt;

&lt;pre class=&quot;markdown&quot;&gt;
```c
// For 16 MHz clock

#define T0Top_Avr 50
#define T0PresAvr 3

   #if defined( OCR0 )
      OCR0  = T0TOP_Avr;
      TCCR0 = 64 + TMR0PresAvr; // CTC mode: TOP = OCR0
   #elif defined( OCR0A )
      OCR0A  = T0TOP_Avr;
      TCCR0A = 2;               // CTC mode: TOP = OCR0A
      TCCR0B = TMR0PresAvr;
   #endif
  
   // enable Timer 0 compare_A interrupt
   #if defined( TIMSK0 )
      TIMSK0 = 0;
      TIMSK0 |= (1 &lt;&lt; OCIE0A);
   #elif defined( TIMSK )
      TIMSK = 0;
      TIMSK |= (1 &lt;&lt; OCIE0A);
   #endif
  
   sei();      // Enable interrupts



// Now in the interrupt routine:

#define numPWM 32             // Number of PWM Channels
uint8_t pwmChannel[ numPWM ]; // Array containing pwm values
uint8_t pwmCounter=0;

ISR(TIMER0_COMPA_vect)        // Timer 0 compare_A interrupt
 { 
    for( uint8_t i=0; i&lt;numPWM; i++ )
    {
        if( pwmChannel[i] &gt; pwmCounter ) 
        {
            // Set the output line &quot;i&quot; HIGH
            // This depends on the hardware you are using
        }
        else
        {
            // Set the output line &quot;i&quot; LOW
        }
    }
    pwmCounter++;
    if( pwmCounter &gt; 63 ) pwmCounter = 0;
{ 
```
&lt;/pre&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6789972103815198126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/6789972103815198126'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2017/10/avr-software-pwm.html' title='AVR Software PWM'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-1036619071639784458</id><published>2017-09-05T16:09:00.003-07:00</published><updated>2018-06-22T01:29:35.113-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AVR"/><title type='text'>USBaspLoader: Bootloader por USB sin ftdi</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
USBaspLoader es un bootloader por USB para microcontroladores AVR con al menos 2 KB flash de memoria para bootloader, por ejemplo los populares ATMega8, 168 y 328.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
La ventaja es que no necesita ningún chip conversor USB-Serie ni ningún otro controlador usb ya que tiene un driver por software basado en V-USB, también de obdev.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Basicamente emula un programador USBasp que se puede usar desde avrdude, de manera que en el host USB se presenta como si hubiéramos conectado un USBasp y se programa normalmente con avrdude, por tanto las placas que lo usen se pueden integrar en el software Arduino seleccionando USBasp como método de programación.&lt;/div&gt;
Ejemplo de uso con avrdude para grabar un Atmega328p:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #674ea7; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&amp;nbsp;&lt;b&gt;avrdude -c usbasp -p m328p -u -U flash:w:archivo.hex&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Al resetear el micro arranca el bootloader si se cumple cierta condición, normalmente el estado de un pin, que se puede ajustar con un jumper o conmutador; aunque esta condición es configurable si se editan y compilan las fuentes; si no se cumple la condición se ejecuta normalmente el programa grabado en la sección baja de la flash.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Este bootloader se puede grabar al chip con cualquier programador ICSP, pero antes hay que ajustar los fuses correctamente, esta información se puede encontrar en el makefile del firmware, por ejemplo para Atmega328 a 16 MHz:&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #674ea7; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;lfuse: 0xF7&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: #674ea7; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;hfuse: 0xDA&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: #674ea7; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;b&gt;efuse: 0x03&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: #9fc5e8; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
El bootloader lo podéis descargar de aquí: http://www.obdev.at/products/vusb/usbasploader.html  Más info sobre V-USB: http://www.obdev.at/products/vusb/index.html&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp;USBaspLoader permite hacer placas de desarrollo u otros proyectos con un mínimo de hardware y por tanto de costo reducido.&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/1036619071639784458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/1036619071639784458'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2017/09/usbasploader-bootloader-por-usb-sin-ftdi.html' title='USBaspLoader: Bootloader por USB sin ftdi'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-794287153830360425</id><published>2017-06-21T20:34:00.000-07:00</published><updated>2017-06-21T20:34:02.040-07:00</updated><title type='text'>Simulador de Circuitos.</title><content type='html'>SimulIDE es un simulador de circuitos electrónicos en tiempo real que incluye simulación de microcontroladores PIC y AVR.&lt;br /&gt;
&lt;br /&gt;
ES simple y facil de usar, con una interface gráfica muy limpia en la que no te sentirás sobrecargado por infinidad de opciones y herramientas.&lt;br /&gt;
Simplemente eliges componentes, los colocas en el circuito, los conectas y le das al botón de encendido.&lt;br /&gt;
&lt;br /&gt;
La mayoria de las cosas las puedes hacer con el ratón, a veces usando las teclas ctrl o shift.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgecIQbneRuFVWXWTUCH9gL3JcnfAvjW3OWinRGv0ZV_xcDa1YLyq4_qfvvy1MR502zdgYAcciEEZUZImuxUnqCazH7FM9y4fA7uoHov57UgPdtcbHJLcJSSWBoYfibNOqRgr28y6tcGs2x/s1600/simulide.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;646&quot; data-original-width=&quot;1009&quot; height=&quot;408&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgecIQbneRuFVWXWTUCH9gL3JcnfAvjW3OWinRGv0ZV_xcDa1YLyq4_qfvvy1MR502zdgYAcciEEZUZImuxUnqCazH7FM9y4fA7uoHov57UgPdtcbHJLcJSSWBoYfibNOqRgr28y6tcGs2x/s640/simulide.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Tiene un buen número de componentes y en cada versión añaden algunos nuevos.&lt;br /&gt;
&lt;br /&gt;
Dispone de osciloscopio así como de plotter, que se activan con el componente &quot;Probe&quot;. &lt;br /&gt;
&lt;br /&gt;
Es de destacar que en la simulación de microcontroladores tienes varias opcione interesantes:&lt;br /&gt;
&lt;br /&gt;
- Monitor serie, para monitorizar comunicaciones por puerto serie primario, pudiendo también enviar datos/ASCII al micro.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- Conectar a un puerto serie en tu computadora, ya sea un puerto serie real como virtual.&lt;br /&gt;
&lt;br /&gt;
- Observar variables y registros del Micro&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En resumen, interesante y muy facil de usar simulador, con versiones para Windows y Linux.&lt;br /&gt;
&lt;br /&gt;
Esta es su página web: &lt;a href=&quot;http://simulide.blogspot.com/&quot; target=&quot;_blank&quot;&gt;SimulIDE&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/794287153830360425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/794287153830360425'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2017/06/simulador-de-circuitos.html' title='Simulador de Circuitos.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgecIQbneRuFVWXWTUCH9gL3JcnfAvjW3OWinRGv0ZV_xcDa1YLyq4_qfvvy1MR502zdgYAcciEEZUZImuxUnqCazH7FM9y4fA7uoHov57UgPdtcbHJLcJSSWBoYfibNOqRgr28y6tcGs2x/s72-c/simulide.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-3539707262611623512</id><published>2012-03-16T02:48:00.002-07:00</published><updated>2012-03-16T02:52:00.840-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AVR"/><title type='text'>Sensor de tempearatura interno Atmega328p</title><content type='html'>El atmega320P y algunos otros AVR tienen un sensor de tempeartura interna, accesible desde el conversor analógico-digital. Util para detectar sobrecalentamiento. &lt;br /&gt;
&lt;br /&gt;
La precisión no es muy buena en principio, pero se puede calibrar.&lt;br /&gt;
Hay una guía de Atmel pra el calibrado:&amp;nbsp;&lt;a href=&quot;http://www.atmel.com/Images/doc8108.pdf&quot; target=&quot;_blank&quot;&gt;www.atmel.com/Images/doc8108.pdf&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Para leer el sensor hay que configurar el ADC con referencia interna de voltaje 1.1 V, y leer el canal 8:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
ADMUX = 1100 1000&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
La conversión a ºC puede variar según condiciones, pero una aproximación podría ser:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;ºC = (lectura-325)/1.22&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/3539707262611623512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/3539707262611623512'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2012/03/sensor-de-tempearatura-interno.html' title='Sensor de tempearatura interno Atmega328p'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-2681862403881803493</id><published>2011-10-09T13:35:00.001-07:00</published><updated>2023-08-09T11:01:25.980-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AVR"/><title type='text'>Atmel AVR Free Running ADC</title><content type='html'>Lectura continua de ADC.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;La lectura de ADC se dispara automaticamente cada vez que finaliza la lectura anterior.&lt;br /&gt;
&lt;br /&gt;
En modo 8 bits se puede conseguir una lectura cada 13 uS (con reloj 16 MHz) lo que nos da una frecuencia de muestreo de 76923 sps sin usar tiempo de procesador.&lt;br /&gt;
&lt;br /&gt;
Basta con configurar ADC de la siguiente forma para leer el canal 0:&lt;br /&gt;
&lt;br /&gt;&lt;blockquote&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ADMUX&amp;nbsp; = b&#39;&lt;span style=&quot;color: #351c75;&quot;&gt;01100000&lt;/span&gt;&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #999999;&quot;&gt;&#39; Channel 0, Left justified, Vref = Avcc&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADCSRA = b&#39;&lt;span style=&quot;color: #351c75;&quot;&gt;11100100&lt;/span&gt;&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #999999;&quot;&gt;&#39; Enabled, Auto-Trigger, presc = 16&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADCSRB = &lt;span style=&quot;color: #351c75;&quot;&gt;0&lt;/span&gt;&lt;/blockquote&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/2681862403881803493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/2681862403881803493'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2011/10/atmel-avr-free-running-adc.html' title='Atmel AVR Free Running ADC'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-2411052468994234206</id><published>2011-10-03T05:14:00.003-07:00</published><updated>2023-08-09T11:11:38.323-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cpp"/><title type='text'>Interrupciones Puerto Paralelo en C</title><content type='html'>Ejemplo de uso, espera por una interrupción, lee e imprime por pantalla el valor presente en el puerto de datos.&lt;br /&gt;
&lt;br /&gt;

&lt;pre class=&quot;markdown&quot;&gt;
```c
//gcc -opport pport.c


#include &amp;lt;linux/ppdev.h&amp;gt;
#include &amp;lt;linux/parport.h&amp;gt;
#include &amp;lt;stropts.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;sys/stat.h&amp;gt;
#include &amp;lt;fcntl.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
#include &amp;lt;sys/ioctl.h&amp;gt;
#include &amp;lt;sys/select.h&amp;gt;
 
#define PP_DEV_NAME &quot;/dev/parport0&quot;
 
int main()
{
    //Get a file descriptor for the parallel port
    int ppfd;
 
    ppfd = open(PP_DEV_NAME, O_RDWR);
    if(ppfd == -1)
    {
        printf(&quot;Unable to open parallel port!\n&quot;);
        return 1;
    }
 
    //Have to claim the device
    if(ioctl(ppfd, PPCLAIM))
    {
        printf(&quot;Couldn&#39;t claim parallel port!\n&quot;);
        close(ppfd);
        return 1;
    }
 
    while(1)
    {
        //Set up the control lines for when an interrupt happens
        int int_count;
        int busy = PARPORT_STATUS_ACK | PARPORT_STATUS_ERROR;
        int acking = PARPORT_STATUS_ERROR;
        int ready = PARPORT_STATUS_ACK | PARPORT_STATUS_ERROR;
        unsigned char value;
 
        int dir = 1;
        ioctl(ppfd, PPDATADIR, &amp;dir);  // data port as inputs
        
        //Let ppdev know we&#39;re ready for interrupts
        ioctl(ppfd, PPWCONTROL, &amp;ready);
 
        //Wait for an interrupt....................................................
        fd_set rfds;
        FD_ZERO(&amp;rfds);
        FD_SET(ppfd, &amp;rfds);

        if(select(ppfd + 1, &amp;rfds, NULL, NULL, NULL))
        {
            printf(&quot;Received interrupt\n&quot;);
        }
        else
        {
            printf(&quot;No interrupt\n&quot;);
            continue; //Caught a signal
        }//.........................................................................
 
            //Read Data port
        ioctl(ppfd, PPRDATA, &amp;value[i]);
        
        unsigned int int_value = value;
        printf(&quot;data =  %i\n&quot;, int_value);
        
        
        //Clear the interrupt
        ioctl(ppfd, PPCLRIRQ, &amp;int_count);
        if(int_count &gt; 1)
            printf(&quot;Uh oh, missed %i interrupts!\n&quot;, int_count - 1);
 
        //Acknowledge the interrupt
        //ioctl(ppfd, PPWCONTROL, &amp;acking);
        //usleep(2);
        //ioctl(ppfd, PPWCONTROL, &amp;busy);
    }
 
    return 0;
}
```
&lt;/pre&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/2411052468994234206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/2411052468994234206'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2011/10/interrupciones-puerto-paralelo-eb-c.html' title='Interrupciones Puerto Paralelo en C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-4227859192204235074.post-837400908391831062</id><published>2011-09-30T15:56:00.002-07:00</published><updated>2023-08-09T11:03:37.294-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>PyParallel, puerto paralelo en Python</title><content type='html'>&lt;br /&gt;&lt;pre&gt;&lt;/pre&gt;
En Consola:&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;:~$ sudo apt-get install python-parallel&lt;/pre&gt;
&lt;pre&gt;:~$ sudo rmmod lp&lt;/pre&gt;
&lt;pre&gt;:~$ sudo modprobe ppdev&lt;/pre&gt;
&lt;pre&gt;:~$ python
Python 2.5.1 (r251:54863, Mar  7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&amp;gt;&amp;gt;&amp;gt; import parallel
&amp;gt;&amp;gt;&amp;gt; p = parallel.Parallel()
&amp;gt;&amp;gt;&amp;gt; p.setData(0x55)&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En programa:&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;#!/usr/bin/env python&lt;/pre&gt;
&lt;pre&gt;import parallel

if __name__ == &quot;__main__&quot;:
	pyp = parallel.Parallel()
	pyp.setData(0x01)             # Valor en d0-d7, pines 2-9&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pyparallel.sourcearchive.com/documentation/0.2-6/classparallel_1_1parallelppdev_1_1Parallel.html&quot;&gt;Class referenfe pyparallel 0.2-6&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/837400908391831062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4227859192204235074/posts/default/837400908391831062'/><link rel='alternate' type='text/html' href='http://tipsnotas.blogspot.com/2011/09/en-consola-sudo-apt-get-install-python.html' title='PyParallel, puerto paralelo en Python'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>