-
Notifications
You must be signed in to change notification settings - Fork 1
/
getting-acquainted-with-electric-ui.html
263 lines (232 loc) · 16.2 KB
/
getting-acquainted-with-electric-ui.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Getting Acquainted With Electric UI — OrangeDurito.blog</title>
<meta name="author" content="Chandan Sinha">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/images/logo.png" rel="icon">
<link href="/theme/css/main.css" media="screen, projection"
rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/theme/css/font-awesome/fontawesome-new/css/all.css">
<link rel="stylesheet" type="text/css" href="/theme/css/custom.css">
<link href="//fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
<!-- Chrome, Firefox OS and Opera -->
<meta name="theme-color" content="#080816">
<!-- Windows Phone -->
<meta name="msapplication-navbutton-color" content="#080816">
<!-- iOS Safari -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!--
███████╗░█████╗░░██████╗████████╗███████╗██████╗░ ███████╗░██████╗░░██████╗░
██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔════╝██╔══██╗ ██╔════╝██╔════╝░██╔════╝░
█████╗░░███████║╚█████╗░░░░██║░░░█████╗░░██████╔╝ █████╗░░██║░░██╗░██║░░██╗░
██╔══╝░░██╔══██║░╚═══██╗░░░██║░░░██╔══╝░░██╔══██╗ ██╔══╝░░██║░░╚██╗██║░░╚██╗
███████╗██║░░██║██████╔╝░░░██║░░░███████╗██║░░██║ ███████╗╚██████╔╝╚██████╔╝
╚══════╝╚═╝░░╚═╝╚═════╝░░░░╚═╝░░░╚══════╝╚═╝░░╚═╝ ╚══════╝░╚═════╝░░╚═════╝░
Bingo! Glad you're here. This is how I got into web-development - by reading the source codes of hundreds of websites. I still do. Isn't curiosity a wonderful thing?
Send me a screenshot of this comment on Twitter @OrangeDurito. I'd be happy to connect :)
-->
</head>
<body>
<header role="banner"><hgroup>
<!-- <h1><a href="/">OrangeDurito.blog</a></h1> -->
<h1><a href="/"><span style="color:orange">Orange</span>Durito.blog</a></h1>
<h2>An amalgamation of engineering and artistry</h2>
</hgroup></header>
<nav role="navigation">
<div class="nav-mobile"><a id="nav-toggle" href="#!"><span></span></a></div>
<ul class="subscription" data-subscription="rss">
</ul>
<ul class="main-navigation">
<li><a href="/">Home</a></li>
<li><a href="/pages/about.html">About</a></li>
<li><a href="/pages/contact.html">Contact</a></li>
<li><a href="/pages/portfolio.html">Portfolio</a></li>
<li><a href="/archives.html">Archive</a></li>
<li><a href="http://chandansinha.me" target="_blank">Personal Website</a></li>
</ul> </nav>
<div id="main">
<div id="content">
<div>
<article class="hentry" role="article">
<header>
<h1 class="entry-title">Getting Acquainted With Electric UI</h1>
<p class="meta">
<time datetime="2021-04-17T01:15:00+05:30" pubdate>Sat 17 April 2021</time> </p>
</header>
<div class="entry-content"><h2>Prologue</h2>
<p>I came across Electric UI during the recent live-stream by <a href="https://www.youtube.com/watch?v=d1w2P0XJZME">CCS Technologies</a>. It can be used to make <strong>cross-platform user interface for real time hardware visualization and control</strong>. I did the quick setup and went on to read their documentation. While going through the basics, I stumbled upon several questions embedded within the texts. They required us to have an understanding of ReactJS as well as ElectricUI's core components. There were no clue around, so the readers were left to find the solutions themselves. After a lot of WTHs and pulling my hair out, I figured them out one by one. Through this post, I wanted to document my solutions.</p>
<h2>Q&As</h2>
<blockquote>
<h3>Try adding another Switch, or a Checkbox component to manually set the led_state variable to 0 or 1 while led_blink is disabled. [From <a href="https://electricui.com/docs/quick-start/ui">Blink Mode Control</a>]</h3>
</blockquote>
<p>Solution - </p>
<div class="highlight"><pre><span></span><code><span class="k">import</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">useHardwareState</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="kr">from</span><span class="w"> </span><span class="s1">'@electricui/components-core'</span>
<span class="p">...</span>
<span class="kd">const</span><span class="w"> </span><span class="nx">isBlinking</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">useHardwareState</span><span class="p">(</span><span class="s1">'led_blink'</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="nx">isBlinking</span><span class="p">)</span><span class="o">?</span><span class="w"> </span>
<span class="w"> </span><span class="p">(</span>
<span class="w"> </span><span class="o"><</span><span class="nx">Switch</span>
<span class="w"> </span><span class="nx">unchecked</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="mf">0</span><span class="p">}</span>
<span class="w"> </span><span class="nx">checked</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="mf">1</span><span class="p">}</span>
<span class="w"> </span><span class="nx">accessor</span><span class="o">=</span><span class="p">{</span><span class="nx">state</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="nx">state</span><span class="p">.</span><span class="nx">led_state</span><span class="p">}</span>
<span class="w"> </span><span class="nx">writer</span><span class="o">=</span><span class="p">{(</span><span class="nx">state</span><span class="p">,</span><span class="w"> </span><span class="nx">value</span><span class="p">)</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">state</span><span class="p">.</span><span class="nx">led_state</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">value</span>
<span class="w"> </span><span class="p">}}</span>
<span class="w"> </span><span class="o">></span>
<span class="w"> </span><span class="nx">Manually</span><span class="w"> </span><span class="nx">toggle</span><span class="w"> </span><span class="nx">LED</span><span class="w"> </span><span class="nx">state</span>
<span class="w"> </span><span class="o"><</span><span class="err">/Switch></span>
<span class="w"> </span><span class="p">)</span><span class="o">:</span><span class="kc">null</span>
<span class="p">}</span>
</code></pre></div></div>
<footer>
<p class="meta">
<span class="byline author vcard">
Posted by <span class="fn">
Chandan Sinha
</span>
</span>
<time datetime="2021-04-17T01:15:00+05:30" pubdate>Sat 17 April 2021</time> <span class="categories">
<a class='category' href='/category/programming.html'>Programming</a>
</span>
<span class="categories">
<a class="category" href="/tag/engineering.html">engineering</a>, <a class="category" href="/tag/features.html">features</a>, <a class="category" href="/tag/javascript.html">javascript</a>, <a class="category" href="/tag/learning.html">learning</a>, <a class="category" href="/tag/software.html">software</a>, <a class="category" href="/tag/troubleshooting.html">troubleshooting</a> </span>
</p><div class="sharing">
</div> </footer>
</article>
<section>
<h1>Comments</h1>
<div id="disqus_thread" aria-live="polite"> <script type="text/javascript">
var disqus_shortname = 'mechanicalcodertechblog';
// // var disqus_identifier = '/getting-acquainted-with-electric-ui.html';
// var disqus_url = '/getting-acquainted-with-electric-ui.html';
// var disqus_title = 'Getting Acquainted With Electric UI';
//
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = "//" + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</div>
</section>
<!-- -->
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/techrantsrandom.html">Techrants.Random</a>
</li>
<li class="post">
<a href="/cummins-internship-experience.html">Cummins Internship Experience</a>
</li>
<li class="post">
<a href="/spacevt-experience.html">Space@VT Experience</a>
</li>
<li class="post">
<a href="/acsl-research-work.html">ACSL Research Work</a>
</li>
<li class="post">
<a href="/making-my-own-discord-bots.html">Making My Own Discord Bots</a>
</li>
</ul>
</section>
<section>
<h1>Categories</h1>
<ul id="recent_posts">
<li><a href="/category/aerospace.html">Aerospace</a> (3)</li>
<li><a href="/category/design.html">Design</a> (4)</li>
<li><a href="/category/filmmaking.html">Filmmaking</a> (3)</li>
<li><a href="/category/life.html">Life</a> (4)</li>
<li><a href="/category/programming.html">Programming</a> (8)</li>
<li><a href="/category/research.html">Research</a> (4)</li>
<li><a href="/category/technology.html">Technology</a> (7)</li>
</ul>
</section>
<!-- <section>
<h1>Tags</h1>
<a href="/tag/intership.html">intership</a>, <a href="/tag/research.html">research</a>, <a href="/tag/engineering.html">engineering</a>, <a href="/tag/programming.html">programming</a>, <a href="/tag/events.html">events</a>, <a href="/tag/learning.html">learning</a>, <a href="/tag/fun.html">fun</a>, <a href="/tag/life.html">life</a>, <a href="/tag/aerospace.html">aerospace</a>, <a href="/tag/masters.html">masters</a>, <a href="/tag/space.html">space</a>, <a href="/tag/technology.html">technology</a>, <a href="/tag/javascript.html">javascript</a>, <a href="/tag/software.html">software</a>, <a href="/tag/troubleshooting.html">troubleshooting</a>, <a href="/tag/features.html">features</a>, <a href="/tag/notes.html">notes</a>, <a href="/tag/web-development.html">web-development</a>, <a href="/tag/editing.html">editing</a>, <a href="/tag/art.html">art</a>, <a href="/tag/creativity.html">creativity</a>, <a href="/tag/iisc.html">IISc</a>, <a href="/tag/combustion.html">combustion</a>, <a href="/tag/blogging.html">blogging</a>, <a href="/tag/design.html">design</a>, <a href="/tag/test.html">test</a>, <a href="/tag/product-design.html">product-design</a>, <a href="/tag/exploration.html">exploration</a>, <a href="/tag/science.html">science</a>, <a href="/tag/markdown.html">markdown</a>, <a href="/tag/pelican.html">pelican</a>, <a href="/tag/automation.html">automation</a>, <a href="/tag/letter.html">letter</a>, <a href="/tag/advice.html">advice</a>, <a href="/tag/mathematics.html">mathematics</a>, <a href="/tag/feature.html">feature</a>, <a href="/tag/internship.html">internship</a> </section> -->
<section>
<h1>Internet Coordinates</h1>
<ul>
<li><a href="https://github.com/mechandansinha" target="_blank"><i class="fab fa-github"></i>GitHub</a></li>
<li><a href="https://www.goodreads.com/user/show/37670581-chandan-sinha" target="_blank"><i class="fab fa-goodreads"></i>Goodreads</a></li>
<li><a href="https://in.linkedin.com/in/chandansinha1" target="_blank"><i class="fab fa-linkedin"></i>LinkedIn</a></li>
<li><a href="https://space.stackexchange.com/users/28487/orangedurito" target="_blank"><i class="fab fa-stack-exchange"></i>Stack Exchange</a></li>
<li><a href="https://twitter.com/OrangeDurito" target="_blank"><i class="fab fa-twitter"></i>Twitter</a></li>
<li><a href="https://thevindicatedaxiom.wordpress.com/" target="_blank"><i class="fab fa-wordpress"></i>WordPress</a></li>
<li><a href="https://www.youtube.com/channel/UC-9V3F-jbe9Kq4sN_NJYakw" target="_blank"><i class="fab fa-youtube"></i>YouTube</a></li>
</ul>
</section>
<section>
<h1> Misc. Websites </h1>
<ul>
<li><a href="https://mechanicalcoder.github.io/launch" target="_blank"><i class="fas fa-rocket"></i>Upcoming Rocket Launches</a></li>
<li><a href="https://movie-reviews-reactjs.vercel.app/" target="_blank"><i class="fas fa-film"></i>Movie Reviews</a></li>
<li><a href="https://nextjs-blog-green-pi.vercel.app/" target="_blank"><i class="fas fa-link"></i>NextJS Sample Blog</a></li>
</ul>
</section>
</aside> </div>
</div>
<footer role="contentinfo"><p>
<!-- -->
Copyright © Chandan Sinha 2016–2023 —
<span class="credit">Powered by <a href="http://getpelican.com" target="_blank">Pelican</a> | </span>
<span class= credit"> <a href="https://github.com/duilio/pelican-octopress-theme" target="_blank">Octopress</a> Theme </span>
</p></footer>
<script src="/theme/js/modernizr-2.0.js"></script>
<script src="/theme/js/ender.js"></script>
<script src="/theme/js/octopress.js" type="text/javascript"></script>
<!-- <script type="text/javascript">
var disqus_shortname = 'mechanicalcodertechblog';
// // var disqus_identifier = '/getting-acquainted-with-electric-ui.html';
// var disqus_url = '/getting-acquainted-with-electric-ui.html';
// var disqus_title = 'Getting Acquainted With Electric UI';
//
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = "//" + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
(function($) {
$(function() {
// Toggle open and close nav styles on click
$('#nav-toggle').click(function() {
$('nav ul').slideToggle();
});
// Hamburger to X toggle
$('#nav-toggle').on('click', function() {
this.classList.toggle('active');
});
});
})(jQuery);
</script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-EHEWDJ9MNH"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-EHEWDJ9MNH');
</script>
</body>
</html>