<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>gamaral – Software Engineer</title>
    <description>Incredibly handsome engineer with a knack for electronics, gamedev, webcomics and content creation in general.
</description>
    <link>https://guillermoamaral.com/</link>
    <atom:link href="/feed/" rel="self" type="application/rss+xml" />
    <pubDate>Sat, 06 Aug 2016 19:50:37 -0700</pubDate>
    <lastBuildDate>Sat, 06 Aug 2016 19:50:37 -0700</lastBuildDate>
    <generator>Jekyll v3.1.6</generator>
    
      <item>
        <title>PICOPi</title>
        <description>
          
          &lt;img src=&quot;http://img.youtube.com/vi/NCth5oqSYBk/maxresdefault.jpg&quot; alt=&quot;PICOPi&quot; /&gt;
          

          &lt;p&gt;PICO-8 console and stand-alone cartridge firmware distributed in an SD card
image for the Raspberry Pi.&lt;/p&gt;

&lt;!--more--&gt;

&lt;h1 id=&quot;update&quot;&gt;Update&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Sat Aug  6 12:43:42 PDT 2016&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I sacrificed an extra second or two in boot time for ease of deployment. No
more having to &lt;strong&gt;flash&lt;/strong&gt; an SD cards. You can simply unzip the contents of the
PICOPi archive onto a &lt;strong&gt;FAT32&lt;/strong&gt; formated SD card.&lt;/p&gt;

&lt;h1 id=&quot;what-is-it&quot;&gt;What is it?&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PICO-8 is a fantasy console for making, sharing and playing tiny games and
other computer programs. When you turn it on, the machine greets you with a
shell for typing in Lua commands and provides simple built-in tools for
creating your own cartridges.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;I fell in love this this little virtual console from day one. It catered
perfectly to my 8-bit/16-bit graphic and C64 nostalgia.&lt;/p&gt;

&lt;h1 id=&quot;pico-8-on-the-minnowboard&quot;&gt;PICO-8 on the MinnowBoard&lt;/h1&gt;

&lt;p&gt;Some time ago, I made a similar image for the &lt;strong&gt;Minnowboard&lt;/strong&gt; since there was
no &lt;a href=&quot;http://www.lexaloffle.com/pico-8.php&quot; title=&quot;PICO-8 Fantasy Console&quot;&gt;PICO-8&lt;/a&gt; build for ARM at the time:&lt;/p&gt;

&lt;div class=&quot;youtube&quot; id=&quot;0YRHtbOdxbc&quot;&gt;&lt;/div&gt;

&lt;p&gt;Soon after &lt;a href=&quot;https://twitter.com/lexaloffle&quot; title=&quot;Zep on Twitter&quot;&gt;Zep&lt;/a&gt; released a build for Raspbian and all was good –
except for the fact that as an embedded engineer, using Raspbian for this
purpose made my skin crawl.&lt;/p&gt;

&lt;p&gt;I wanted something that I could just pop in and play some games with in my
hotel room, without needing to fiddle around with a full blown desktop, or
worry about power cutting out and possibly corrupting the OS.&lt;/p&gt;

&lt;p&gt;I was sure I could do better, so I found myself with some free time and I made
my own OS image for the &lt;a href=&quot;http://www.lexaloffle.com/pico-8.php&quot; title=&quot;PICO-8 Fantasy Console&quot;&gt;PICO-8&lt;/a&gt; on the Raspberry Pi…&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/posts/picopi/bender.jpg&quot; alt=&quot;Bender Meme&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I specially wanted to (&lt;strong&gt;optionally&lt;/strong&gt;) be super wasteful and use a single SD
card per cartridge (which you can totally do and it’s great). I mean, can you
imagine the tiny labels printed on the SD card? I sure can!&lt;/p&gt;

&lt;h1 id=&quot;picopi&quot;&gt;PICOPi&lt;/h1&gt;

&lt;h2 id=&quot;features&quot;&gt;Features&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Boots directly to the ‘splorer’ or directly to a console (when not in stand-alone cartridge mode).&lt;/li&gt;
  &lt;li&gt;Corruption resistant.&lt;/li&gt;
  &lt;li&gt;Crazy-fast boot time.&lt;/li&gt;
  &lt;li&gt;HDMI audio output on by default.&lt;/li&gt;
  &lt;li&gt;Keymaps supported.&lt;/li&gt;
  &lt;li&gt;Nothing on screen but PICO-8.&lt;/li&gt;
  &lt;li&gt;Raspberry Pi will do a clean shutdown when PICO-8 does.&lt;/li&gt;
  &lt;li&gt;X-Box controller support (tested).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;download&quot;&gt;Download&lt;/h2&gt;

&lt;h3 id=&quot;raspberry-pi&quot;&gt;Raspberry Pi&lt;/h3&gt;

&lt;p&gt;Tested on Model A, A+, B, B+, CM, Zero.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://dl.guillermoamaral.com/picopi/picopi-rpi1.zip&quot;&gt;http://dl.guillermoamaral.com/picopi/picopi-rpi1.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;raspberry-pi-2&quot;&gt;Raspberry Pi 2&lt;/h3&gt;

&lt;p&gt;Tested on Model B&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://dl.guillermoamaral.com/picopi/picopi-rpi2.zip&quot;&gt;http://dl.guillermoamaral.com/picopi/picopi-rpi2.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;raspberry-pi-3&quot;&gt;Raspberry Pi 3&lt;/h3&gt;

&lt;p&gt;I currently don’t own one – so no image.
Feel free to send me a board if you have any spares. :-)&lt;/p&gt;

&lt;h1 id=&quot;setup&quot;&gt;Setup&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;Format your SD card with a single FAT32 partition.&lt;/li&gt;
  &lt;li&gt;Unzip the PICOPi onto the SD card.&lt;/li&gt;
  &lt;li&gt;Unzip the PICO-8 archive (from Lexaloffle) onto the SD card (more
information in the PICO-8 section below).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;linux-sd-card-setup&quot;&gt;Linux SD Card Setup&lt;/h3&gt;

&lt;div class=&quot;youtube&quot; id=&quot;tlIF5Xkoz14&quot;&gt;&lt;/div&gt;

&lt;h3 id=&quot;mac-os-x-sd-card-setup&quot;&gt;Mac OS X SD Card Setup&lt;/h3&gt;

&lt;div class=&quot;youtube&quot; id=&quot;SucyxNnT27E&quot;&gt;&lt;/div&gt;

&lt;h3 id=&quot;windows-sd-card-setup&quot;&gt;Windows SD Card Setup&lt;/h3&gt;

&lt;div class=&quot;youtube&quot; id=&quot;DrC_n_Y18aM&quot;&gt;&lt;/div&gt;

&lt;h1 id=&quot;pico-8&quot;&gt;PICO-8&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;http://www.lexaloffle.com/pico-8.php&quot; title=&quot;PICO-8 Fantasy Console&quot;&gt;PICO-8&lt;/a&gt; is not free in any sense of the word.&lt;/p&gt;

&lt;p&gt;At the moment of writing it will set you back &lt;strong&gt;15 USD&lt;/strong&gt; for a lot of games
which includes &lt;strong&gt;PICO-8&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Download the &lt;strong&gt;Raspberry-Pi&lt;/strong&gt;(ARM) archive, expand it in the first partition of
the SD card that’s it. &lt;strong&gt;It Should Just Work&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Your first partition should look something like this afterwards:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bcm2708-rpi-b.dtb
bcm2708-rpi-b-plus.dtb
bcm2708-rpi-cm.dtb
bootcode.bin
config.txt
fixup.dat
start.elf
pico.pi
pico-8/ &amp;lt;----
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;stand-alone-cartridge-mode&quot;&gt;Stand-alone Cartridge Mode&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;pico8&quot;&gt;Download your favorite cartridge from the PICO-8 website&lt;/a&gt;, rename it to
&lt;strong&gt;rom.p8&lt;/strong&gt; or &lt;strong&gt;rom.p8.png&lt;/strong&gt; and place it in the boot partition.&lt;/p&gt;

&lt;p&gt;Your first partition should look something like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bcm2708-rpi-b-plus.dtb
bcm2708-rpi-b.dtb
bcm2708-rpi-cm.dtb
bootcode.bin
config.txt
fixup.dat
rom.p8.png &amp;lt;----
start.elf
pico-pi
pico-8/
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;When the Raspberry Pi board boots, it will automatically load the cartrige file
and run it.&lt;/p&gt;

&lt;h1 id=&quot;configuration&quot;&gt;Configuration&lt;/h1&gt;

&lt;h2 id=&quot;offline-carts&quot;&gt;Offline Carts&lt;/h2&gt;

&lt;p&gt;Download your favorite carts from the &lt;a href=&quot;http://www.lexaloffle.com/pico-8.php&quot; title=&quot;PICO-8 Fantasy Console&quot;&gt;PICO-8&lt;/a&gt; website and copy them
into the &lt;strong&gt;pico-8/carts&lt;/strong&gt; directory on the SD Card. If the &lt;strong&gt;carts&lt;/strong&gt; directory
doesn’t exist, feel free to create it.&lt;/p&gt;

&lt;h2 id=&quot;keyboard-layout&quot;&gt;Keyboard Layout&lt;/h2&gt;

&lt;p&gt;If you wish to switch keyboard layout, you will need to modify the following
line in &lt;strong&gt;config.txt&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;keymap=us
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The usual standard Linux system keymaps are available; Valid keymap names
include:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;* azerty
* dvorak
* es
* fr
* us
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;disable-splorer&quot;&gt;Disable Splorer&lt;/h2&gt;

&lt;p&gt;It’s possible to boot directly to the console instead of ‘splorer’. To do so,
comment out, remove or set the following line in &lt;strong&gt;config.txt&lt;/strong&gt; to &lt;strong&gt;off&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;splorer=on
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


        </description>
        <pubDate>Tue, 19 Jul 2016 22:34:32 -0700</pubDate>
        <link>https://guillermoamaral.com/read/picopi/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/picopi/</guid>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Canon DSLR WiFi Remote</title>
        <description>
          
          &lt;img src=&quot;http://img.youtube.com/vi/ukUMP7jty64/maxresdefault.jpg&quot; alt=&quot;Canon DSLR WiFi Remote&quot; /&gt;
          

          &lt;p&gt;Make your own WiFi DSLR Remote!&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;&lt;strong&gt;Part 2 of the video is now available.&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;youtube&quot; id=&quot;l1oXFDUl1DU&quot;&gt;&lt;/div&gt;

&lt;p&gt;Having a tripod with you is not always all you need in order to take sharp,
good looking pictures. Sometimes in low light conditions, your hand pressing
down on the shutter trigger can make the image come out blurry.&lt;/p&gt;

&lt;p&gt;So why not mix the power of the &lt;a href=&quot;https://www.sparkfun.com/products/13678&quot; title=&quot;ESP8266 at SparkFun&quot;&gt;ESP8266&lt;/a&gt; with a convenience of a
shutter control? That way you could take photos while you’re chilling watching
Netflix.&lt;/p&gt;

&lt;p&gt;Check out the video to find out how you can make it happen!&lt;/p&gt;

&lt;h1 id=&quot;canon-e3&quot;&gt;Canon E3&lt;/h1&gt;

&lt;p&gt;You will need to get your hands on a 2.5 mm Stero Mini Plug like the
&lt;a href=&quot;http://www.mouser.com/ProductDetail/CUI/SP-2501/&quot; title=&quot;SP-2501 on Mouser&quot;&gt;SP-2501&lt;/a&gt;; When plugged into the camera, the &lt;strong&gt;tip&lt;/strong&gt; and the &lt;strong&gt;ring&lt;/strong&gt;
will be pulled high. The &lt;a href=&quot;https://www.sparkfun.com/products/13678&quot; title=&quot;ESP8266 at SparkFun&quot;&gt;ESP8266&lt;/a&gt; module will need to drive each of
them down to common ground in order to trigger the shutter and/or focus
respectively.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/posts/canon-wifimote/plug.png&quot; alt=&quot;E3 Mini Plug&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;schematic&quot;&gt;Schematic&lt;/h1&gt;

&lt;p&gt;As you can see in the schematic below, the &lt;strong&gt;GPIO2&lt;/strong&gt; and &lt;strong&gt;GPIO0&lt;/strong&gt; in the
&lt;a href=&quot;https://www.sparkfun.com/products/13678&quot; title=&quot;ESP8266 at SparkFun&quot;&gt;ESP8266 &lt;strong&gt;ESP-01&lt;/strong&gt; v2 module&lt;/a&gt; will be used to drive the two lines
low. The board can be powered through a USB port, a USB charger or even a
battery pack.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/posts/canon-wifimote/schematic.png&quot; alt=&quot;Schematic&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The circuit is very simple so I’ll leave it up to you, the reader, to adjust
it to fit your needs. :)&lt;/p&gt;

&lt;h1 id=&quot;code&quot;&gt;Code&lt;/h1&gt;

&lt;p&gt;The code for this project is hosted along with the schematics and gerbers on
GitHub.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/gamaral/canon-wifimote&quot;&gt;https://github.com/gamaral/canon-wifimote&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;board&quot;&gt;Board&lt;/h1&gt;

&lt;p&gt;I shared the board I made on OSHPark, if you plan on using my design as-is,
here’s the URL:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://oshpark.com/shared_projects/4nVf0mTo&quot;&gt;https://oshpark.com/shared_projects/4nVf0mTo&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;components&quot;&gt;Components&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;1x 10uF POL capacitor&lt;/li&gt;
  &lt;li&gt;1x 2x4 pin header&lt;/li&gt;
  &lt;li&gt;1x Micro USB-B connector&lt;/li&gt;
  &lt;li&gt;1x &lt;a href=&quot;https://www.sparkfun.com/products/13678&quot; title=&quot;ESP8266 at SparkFun&quot;&gt;ESP8266&lt;/a&gt; ESP-01 v2&lt;/li&gt;
  &lt;li&gt;1x &lt;a href=&quot;http://www.mouser.com/ProductDetail/Infineon/IFX8117ME-V33/&quot; title=&quot;IFX8117ME on Mouser&quot;&gt;IFX8117ME V33&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;1x &lt;a href=&quot;http://www.mouser.com/ProductDetail/CUI/SP-2501/&quot; title=&quot;SP-2501 on Mouser&quot;&gt;SP-2501 2.5 mm Stereo Plug&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;3x 10k Resistors (0603)&lt;/li&gt;
&lt;/ul&gt;


        </description>
        <pubDate>Fri, 15 Jan 2016 06:00:00 -0800</pubDate>
        <link>https://guillermoamaral.com/read/canon-wifimote/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/canon-wifimote/</guid>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Flux Capacitor Notification Light Hack</title>
        <description>
          
          &lt;img src=&quot;http://img.youtube.com/vi/_DYADybJz0s/maxresdefault.jpg&quot; alt=&quot;Flux Capacitor Notification Light Hack&quot; /&gt;
          

          &lt;p&gt;I modded my Flux Capacitor USB Charger and turned it into an instant
notification widget.&lt;/p&gt;

&lt;p&gt;It can now be controlled through WiFi, which comes in handy when I get pinged
on IRC or get important email.&lt;/p&gt;

&lt;h1 id=&quot;hack&quot;&gt;Hack&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;https://guillermoamaral.com/assets/posts/flux-capacitor-notification-widget/flux-internals.jpg&quot; alt=&quot;Hack&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I replaced the resistor used to power the flux circuit with a 3v3 SMD regulator
that fit the resistor’s footprint. The regulator now powers both the flux
circuit IC and the ESP8266 module.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GPIO2&lt;/strong&gt; and &lt;strong&gt;GPIO0&lt;/strong&gt; in the ESP8266 module are used to toggle the flux
circuit and keep state respectively. Using custom firmware, &lt;strong&gt;GPIO2&lt;/strong&gt; is pulled
low for half a second when we need to toggle the flux circuit. This is
accomplished by connecting to the ESP module via TCP and sending one of the
following commands:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TIME CIRCUIT ON&lt;/strong&gt;
&lt;strong&gt;TIME CIRCUIT OFF&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the flux circuit fluxes, the cathode-side of the LEDs is pulled low; I
hoked up &lt;strong&gt;GPIO0&lt;/strong&gt; to the cathode of one of the LEDs and made it interrupt on
falling edge.  When the interrupt is triggered I set the internal state to
&lt;em&gt;fluxing&lt;/em&gt;, an internal timer is restarted every time the LED is turned on. When
the time circuit is turned off, the timer expires and sets the state back to
&lt;em&gt;off&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Just in case it wasn’t obvious, we need to know if the time circuit is &lt;strong&gt;ON&lt;/strong&gt;
or &lt;strong&gt;OFF&lt;/strong&gt; so that we don’t toggle it &lt;strong&gt;OFF&lt;/strong&gt; when we want it to be &lt;strong&gt;ON&lt;/strong&gt; by
mistake.&lt;/p&gt;

&lt;h1 id=&quot;components&quot;&gt;Components&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://espressif.com/en/products/esp8266/&quot;&gt;ESP8266&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.thinkgeek.com/product/1dbd/&quot;&gt;ThinkGeek Flux Capacitor USB Car Charger&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


        </description>
        <pubDate>Wed, 11 Feb 2015 23:00:00 -0800</pubDate>
        <link>https://guillermoamaral.com/read/flux-capacitor-notification-widget/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/flux-capacitor-notification-widget/</guid>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Xeno-GC Clone Mini</title>
        <description>
          
          &lt;img src=&quot;https://guillermoamaral.com/assets/posts/xeno-gc-clone-mini/main.jpg&quot; alt=&quot;Xeno-GC Clone Mini&quot; /&gt;
          

          &lt;p&gt;Since I wasn’t satisfied with how I laid out it’s big bother, I decided to redo
the board, the Xeno-GC Clone Mini is the end result. It’s about the size of a
quarter dollar and twice as sexy. Check out the images above and see for
yourself.&lt;/p&gt;

&lt;h1 id=&quot;make-your-own&quot;&gt;Make your own!&lt;/h1&gt;

&lt;p&gt;The mini model, like it’s big brother, uses 0805 SMD components. No rework
station or solder paste required; Just a standard soldering iron and some
whiskey &lt;em&gt;(Ok, the whiskey is optional)&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;parts&quot;&gt;Parts&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;2x&lt;/strong&gt; 100nF 0805 ceramic capacitors.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2x&lt;/strong&gt; 1kΩ 0805 resistors.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2x&lt;/strong&gt; 330Ω 0805 resistors.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1x&lt;/strong&gt; 100Ω 0805 resistor.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1x&lt;/strong&gt; Red 0805 LED.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1x&lt;/strong&gt; Green 0805 LED.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1x&lt;/strong&gt; Atmel AVR ATmega8L 32-pin TQFP.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;schematic&quot;&gt;Schematic&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;https://guillermoamaral.com/assets/posts/xeno-gc-clone-mini/schematic.png&quot; alt=&quot;Xeno-GC Clone Mini Schematic&quot; title=&quot;Xeno-GC Clone Mini Schematic&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;order&quot;&gt;Order&lt;/h2&gt;

&lt;p&gt;You can order your boards directly from &lt;a href=&quot;http://oshpark.com/shared_projects/XDNLoePV&quot;&gt;OSH
Park&lt;/a&gt;. If you have any questions,
feel free to email me. Now go get your homebrew on!&lt;/p&gt;

        </description>
        <pubDate>Mon, 14 Oct 2013 12:43:00 -0700</pubDate>
        <link>https://guillermoamaral.com/read/xeno-gc-clone-mini/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/xeno-gc-clone-mini/</guid>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>ITEAD Studio Vs. OSH Park - Raspberry Pi PSU PCBs</title>
        <description>
          
          &lt;img src=&quot;https://guillermoamaral.com/assets/posts/iteadstudio_vs_oshpark/main.jpg&quot; alt=&quot;ITEAD Studio Vs. OSH Park - Raspberry Pi PSU PCBs&quot; /&gt;
          

          &lt;p&gt;So is it worth it ordering from China based
&lt;a href=&quot;http://blog.iteadstudio.com/&quot;&gt;ITeadStudio&lt;/a&gt; versus tried and tested &lt;a href=&quot;http://oshpark.com/&quot;&gt;OSH
Park&lt;/a&gt;? Watch the video and find out!&lt;/p&gt;

&lt;p&gt;I’ll be giving away some Raspberry Pi PSU PCBs, subscribe and/or comment on
YouTube for a chance to win your own!&lt;/p&gt;

&lt;h1 id=&quot;it-works&quot;&gt;It works!&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;http://youtu.be/LZMlZWQTFWQ&quot;&gt;Click here to watch it in action!&lt;/a&gt;&lt;/p&gt;


        </description>
        <pubDate>Sat, 05 Oct 2013 21:16:00 -0700</pubDate>
        <link>https://guillermoamaral.com/read/iteadstudio_vs_oshpark/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/iteadstudio_vs_oshpark/</guid>
        
        
        <category>review</category>
        
      </item>
    
      <item>
        <title>Make your own Raspberry Pi - PSU</title>
        <description>
          
          &lt;img src=&quot;https://guillermoamaral.com/assets/posts/rpi-psu-r3/main.png&quot; alt=&quot;Make your own Raspberry Pi - PSU&quot; /&gt;
          

          &lt;p&gt;Here’s the Raspberry Pi R3 PCB TH (Through-Hole) model fully populated.&lt;/p&gt;

&lt;p&gt;The R3 board is
&lt;a href=&quot;http://oshpark.com/shared_projects/MmabtNcO&quot;&gt;&lt;strong&gt;shared on OSH Park&lt;/strong&gt;&lt;/a&gt;
which means &lt;strong&gt;you can order your own boards&lt;/strong&gt; which you can assemble yourself!&lt;/p&gt;

&lt;h1 id=&quot;components&quot;&gt;Components&lt;/h1&gt;

&lt;p&gt;All parts are fairly common, specially the passives. Here are a few suppliers for the parts you may have a hard time finding.&lt;/p&gt;

&lt;h2 id=&quot;attiny85&quot;&gt;ATTiny85&lt;/h2&gt;

&lt;p&gt;SparkFun: &lt;a href=&quot;https://www.sparkfun.com/products/9378&quot;&gt;COM-09378&lt;/a&gt;
Mouser: &lt;a href=&quot;http://www.mouser.com/ProductDetail/Atmel/ATtiny85-20PU/?qs=8jWQYweyg6NCiiaOb5GI9Q==&quot;&gt;556-ATTINY85-20PU&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;programming&quot;&gt;Programming&lt;/h3&gt;

&lt;p&gt;You will need a way to program the ATTiny, I suggest getting yourself an &lt;a href=&quot;http://www.mouser.com/ProductDetail/Atmel/ATAVRISP2/?qs=2mdvTlUeTfBRoycsKqwYpg==&quot;&gt;Atmel AVR mkII&lt;/a&gt;, a &lt;a href=&quot;https://www.sparkfun.com/products/9825&quot;&gt;Pocket AVR Programmer&lt;/a&gt; or if you already own an Arduino you can make an &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot;&gt;ArduinoISP&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;ld33v&quot;&gt;LD33V&lt;/h2&gt;

&lt;p&gt;SparkFun: &lt;a href=&quot;https://www.sparkfun.com/products/526&quot;&gt;COM-00526&lt;/a&gt;
Mouser: &lt;a href=&quot;http://www.mouser.com/ProductDetail/STMicroelectronics/LD1117V33/?qs=arR7071FstdSYX/AthFGRA==&quot;&gt;511-LD1117V33&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;tip125&quot;&gt;TIP125&lt;/h2&gt;

&lt;p&gt;Mouser: &lt;a href=&quot;http://www.mouser.com/ProductDetail/STMicroelectronics/TIP125/?qs=ljbEvF4DwOOVTDztFiRz8A==&quot;&gt;511-TIP125&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;pn2222&quot;&gt;PN2222&lt;/h2&gt;

&lt;p&gt;Adafruit: &lt;a href=&quot;http://www.adafruit.com/products/756&quot;&gt;756&lt;/a&gt;
Mouser: &lt;a href=&quot;http://www.mouser.com/ProductDetail/Fairchild-Semiconductor/PN2222ABU/?qs=sGAEpiMZZMshyDBzk1%2fWi8oN7VHZ91Oksd99mJbzy1A%3d&quot;&gt;512-PN2222ABU&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;resources&quot;&gt;Resources&lt;/h1&gt;

&lt;p&gt;OSH Park: &lt;a href=&quot;http://oshpark.com/shared_projects/MmabtNcO&quot;&gt;http://oshpark.com/shared_projects/MmabtNcO&lt;/a&gt;&lt;/p&gt;

        </description>
        <pubDate>Mon, 23 Sep 2013 14:05:02 -0700</pubDate>
        <link>https://guillermoamaral.com/read/rpi-psu-r3/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/rpi-psu-r3/</guid>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Raspberry Pi GPIO using plain C and SysFS</title>
        <description>
          
          &lt;img src=&quot;https://guillermoamaral.com/assets/posts/rpi-gpio-c-sysfs/main.jpg&quot; alt=&quot;Raspberry Pi GPIO using plain C and SysFS&quot; /&gt;
          

          &lt;p&gt;I recently gave a talk on the Raspberry Pi during which I mentioned using the
GPIO sysfs interface instead of something like the WiringPi library, I was
asked if I could provide a small example… I can.&lt;/p&gt;

&lt;h1 id=&quot;example&quot;&gt;Example&lt;/h1&gt;

&lt;p&gt;I’m about to unleash the electronic world’s version of the “Hello World!”
program, a blinking LED. Remember, this example requires no special libraries
since it uses the sysfs interface.&lt;/p&gt;

&lt;h2 id=&quot;blinkc&quot;&gt;blink.c&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;cm&quot;&gt;/* blink.c
 *
 * Raspberry Pi GPIO example using sysfs interface.
 * Guillermo A. Amaral B. &amp;lt;g@maral.me&amp;gt;
 *
 * This program blinks GPIO 4 (P1-07) while reading GPIO 24 (P1_18).
 */&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;#include &amp;lt;sys/stat.h&amp;gt;
#include &amp;lt;sys/types.h&amp;gt;
#include &amp;lt;fcntl.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#define IN   0
#define OUT  1
&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#define LOW  0
#define HIGH 1
&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#define PIN  24 &lt;/span&gt;&lt;span class=&quot;cm&quot;&gt;/* P1-18 */&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#define POUT 4  &lt;/span&gt;&lt;span class=&quot;cm&quot;&gt;/* P1-07 */&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOExport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOUnexport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIODirection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIORead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[])&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;repeat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;cm&quot;&gt;/*
     * Enable GPIO pins
     */&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOExport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;POUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOExport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PIN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;cm&quot;&gt;/*
     * Set GPIO directions
     */&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIODirection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;POUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIODirection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PIN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;cm&quot;&gt;/*
	 * Write GPIO value
	 */&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;POUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;repeat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
	    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

	&lt;span class=&quot;cm&quot;&gt;/*
	 * Read GPIO value
	 */&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;I&#39;m reading %d in GPIO %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIORead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PIN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PIN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;usleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;cm&quot;&gt;/*
     * Disable GPIO pins
     */&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOUnexport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;POUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPIOUnexport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PIN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;GPIOExport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#define BUFFER_MAX 3
&lt;/span&gt;    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BUFFER_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;ssize_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes_written&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/sys/class/gpio/export&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_WRONLY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to open export for writing!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;bytes_written&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;snprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BUFFER_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes_written&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;GPIOUnexport&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BUFFER_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;ssize_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes_written&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/sys/class/gpio/unexport&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_WRONLY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to open unexport for writing!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;bytes_written&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;snprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BUFFER_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bytes_written&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;GPIODirection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s_directions_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;in&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;out&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;#define DIRECTION_MAX 35
&lt;/span&gt;    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DIRECTION_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;snprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DIRECTION_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/sys/class/gpio/gpio%d/direction&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_WRONLY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to open gpio direction for writing!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s_directions_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to set direction!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;GPIORead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#define VALUE_MAX 30
&lt;/span&gt;    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;VALUE_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;snprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;VALUE_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/sys/class/gpio/gpio%d/value&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_RDONLY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to open gpio value for reading!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to read value!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;atoi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;GPIOWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s_values_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;VALUE_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;snprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;VALUE_MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/sys/class/gpio/gpio%d/value&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_WRONLY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to open gpio value for writing!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s_values_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LOW&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Failed to write value!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You can &lt;a href=&quot;http://dl.guillermoamaral.com/rpi/blink.c&quot;&gt;download the source by clicking here&lt;/a&gt;.&lt;/p&gt;


        </description>
        <pubDate>Sun, 04 Aug 2013 02:49:00 -0700</pubDate>
        <link>https://guillermoamaral.com/read/rpi-gpio-c-sysfs/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/rpi-gpio-c-sysfs/</guid>
        
        
        <category>educational</category>
        
        <category>rpi</category>
        
      </item>
    
      <item>
        <title>Marshmallow Entertainment System</title>
        <description>
          
          &lt;img src=&quot;https://guillermoamaral.com/assets/posts/mes/main.jpg&quot; alt=&quot;Marshmallow Entertainment System&quot; /&gt;
          

          &lt;p&gt;Back when I was a kid, I decided I wanted to make my own game console. Granted
I also wanted to be an astronaut and the first man on Mars, but I had to draw
the line somewhere.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://marshmallow.me/&quot; title=&quot;Marshmallow Game Engine&quot;&gt;Marshmallow Game Engine&lt;/a&gt; started as a way for me to keep my
cross-platform game engine chops up during my spare time (not that I have that
much spare time mind you). But with the advent of both powerful and affordable
hardware like the &lt;a href=&quot;http://raspberrypi.org/&quot; title=&quot;RaspberryPi - An ARM GNU/Linux box for $25. Take a byte!&quot;&gt;Raspberry Pi&lt;/a&gt;, I started looking into creating my own
game console again, and I have to admit, I’m very excited.&lt;/p&gt;

&lt;h1 id=&quot;mes&quot;&gt;MES&lt;/h1&gt;

&lt;p&gt;Thanks to the wonderful &lt;a href=&quot;http://raspberrypi.org/&quot; title=&quot;RaspberryPi - An ARM GNU/Linux box for $25. Take a byte!&quot;&gt;Raspberry Pi&lt;/a&gt;, I’m finally able to create an
affordable &lt;strong&gt;DIY console kit&lt;/strong&gt; for my game engine.&lt;/p&gt;

&lt;p&gt;The following are some common components in game consoles, I’ll go through the
list so you can get an idea of how the end product will work.&lt;/p&gt;

&lt;h2 id=&quot;controllers--ports&quot;&gt;Controllers &amp;amp; Ports&lt;/h2&gt;

&lt;p&gt;Luckily the RPI has a couple of built in USB ports. A simple USB port hub or
something like the &lt;a href=&quot;http://www.mayflash.com/?Products/NINTENDOWiiGC/PC045.html&quot;&gt;Mayflash Wii classic controller pro to
PC&lt;/a&gt; which can
handle two controllers per USB slot can be used to add more ports when needed.&lt;/p&gt;

&lt;p&gt;Not all USB controllers will be supported, but I will target the most common
ones in the beginning, user submitted mappings will soon follow.&lt;/p&gt;

&lt;h2 id=&quot;media-slot&quot;&gt;Media Slot&lt;/h2&gt;

&lt;p&gt;Since I’m planning on having mainly downloadable content, an optical media
drive or cartage slot would not make much sense (fun as it may be). I might add
external USB storage support.&lt;/p&gt;

&lt;h2 id=&quot;enclosure&quot;&gt;Enclosure&lt;/h2&gt;

&lt;p&gt;No definitive case design yet. I’m considering laser cut PCB.&lt;/p&gt;

&lt;h2 id=&quot;operating-system&quot;&gt;Operating System&lt;/h2&gt;

&lt;p&gt;Since speed and boot time are very high priority when it comes to game
consoles, &lt;a href=&quot;https://github.com/gamaral/rpi-buildroot&quot; title=&quot;BuildRoot for Raspberry Pi&quot;&gt;I decided to build my own distro&lt;/a&gt;. It’s lean, mean
and comes in one single flavor, COUGAR.&lt;/p&gt;

&lt;p&gt;You can see it boot here, don’t look away or you might not see it boot
up at all.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=4Fjfqz6FxC8&quot;&gt;http://www.youtube.com/watch?v=4Fjfqz6FxC8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I found that on some LCD displays, screen settling takes longer than the actual
system boot, which is pretty awesome. The game engine waits for the screen to
be ready before it continues running, this applies for first boot and for video
output switching (HDMI &amp;lt;=&amp;gt; Composite).&lt;/p&gt;

&lt;h2 id=&quot;game-engine&quot;&gt;Game Engine&lt;/h2&gt;

&lt;p&gt;I’m using &lt;a href=&quot;http://marshmallow.me/&quot; title=&quot;Marshmallow Game Engine&quot;&gt;my own game engine&lt;/a&gt; which is still under heavy
development, I’m trying to get people interested in helping out with port
maintenance (specially the Windows and MacOS X ports). If you’re interested
&lt;a href=&quot;&amp;#109;&amp;#097;&amp;#105;&amp;#108;&amp;#116;&amp;#111;:&amp;#103;&amp;#064;&amp;#109;&amp;#097;&amp;#114;&amp;#097;&amp;#108;&amp;#046;&amp;#109;&amp;#101;&quot; title=&quot;Contact me now!!!&quot;&gt;please contact me&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;try-it-out&quot;&gt;Try it out!&lt;/h1&gt;

&lt;p&gt;If you want to try out the demo, just follow the instructions below:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget http://downloads.marshmallow.me/sdcard.img.xz
xz -d sdcard.img.xz
sudo dd if=sdcard.img of=/dev/**YOUR-DEV-NODE**
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After it’s done, insert the sdcard in your Raspberry Pi and plug it in!&lt;/p&gt;

&lt;h3 id=&quot;notes&quot;&gt;Notes&lt;/h3&gt;

&lt;p&gt;You will need to have a keyboard handy since the odds you have a supported
gamepad/joystick is pretty thin (donations welcome!).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;F1&lt;/strong&gt; - restarts the demo&lt;br /&gt;
&lt;strong&gt;ESC&lt;/strong&gt; - kills the demo&lt;br /&gt;
&lt;strong&gt;SPACE&lt;/strong&gt; - Jumps&lt;br /&gt;
&lt;strong&gt;LEFT&lt;/strong&gt; - Move left&lt;br /&gt;
&lt;strong&gt;RIGHT&lt;/strong&gt; - Move right&lt;br /&gt;
&lt;strong&gt;LSHIFT&lt;/strong&gt; - Run&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Thanks for your interest in my project, please feel free to leave comments or
suggestions below.&lt;/p&gt;

&lt;p&gt;Also, I’m usually around on &lt;a href=&quot;http://webchat.freenode.net/?channels=#marshmallow_h&quot; title=&quot;Connect to freenode IRC&quot;&gt;IRC #marshmallow_h @ freenode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;G&lt;/strong&gt;&lt;/p&gt;


        </description>
        <pubDate>Sun, 11 Nov 2012 22:58:00 -0800</pubDate>
        <link>https://guillermoamaral.com/read/mes/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/mes/</guid>
        
        
        <category>projects</category>
        
        <category>rpi</category>
        
      </item>
    
      <item>
        <title>Marshmallow PandaBoard</title>
        <description>
          
          &lt;img src=&quot;https://guillermoamaral.com/assets/posts/marshmallow-panda/main.jpg&quot; alt=&quot;Marshmallow PandaBoard&quot; /&gt;
          

          &lt;p&gt;As tasty as it might sound, it seems to not be a nutritious partnership, at
least not yet.&lt;/p&gt;

&lt;p&gt;Performance ranges from 60 fps to 40 fps at times, I’m fairly sure I can tweak
it to work faster since the PandaBoard has far more processing power than the
Raspberry Pi, but I’m just not sure about it’s GLES2 implementation.&lt;/p&gt;

&lt;p&gt;I’m using PowerVR SGX OMAP4 with the X11-EGL driver, maybe the extra layer is
slowing it down, I’m not sure. I tried running marshmallow as a fullscreen
window and as the window manager itself, but performance didn’t improve much.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://guillermoamaral.com/assets/posts/marshmallow-panda/12080001-640.jpg&quot; alt=&quot;Pandaboard running Marshmallow Game Engine&quot; title=&quot;Marshmallow on Panda&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On the bright side, input hot-plug works like a charm, native builds are fast
and it has a considerably shorter boot time compared to the Raspberry Pi.&lt;/p&gt;

        </description>
        <pubDate>Fri, 24 Aug 2012 01:53:40 -0700</pubDate>
        <link>https://guillermoamaral.com/read/marshmallow-panda/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/marshmallow-panda/</guid>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Raspberry Pi + Linux uinput + Marshmallow Game Engine</title>
        <description>
          
          &lt;img src=&quot;http://img.youtube.com/vi/BaP87biaBsU/maxresdefault.jpg&quot; alt=&quot;Raspberry Pi + Linux uinput + Marshmallow Game Engine&quot; /&gt;
          

          &lt;p&gt;I recently added uinput support to &lt;a href=&quot;https://github.com/gamaral/marshmallow_h&quot; title=&quot;Marshmallow Game Engine on GitHub&quot;&gt;Marshmallow Game Engine&lt;/a&gt;,
allowing me to received input events on the Raspberry Pi. Also, You can now
select which input source you want to use at compile time (evdev, x11, etc).&lt;/p&gt;

&lt;p&gt;If you’re interested in watching that in action, you’ve come to the right place. :)&lt;/p&gt;


        </description>
        <pubDate>Sat, 04 Aug 2012 20:02:49 -0700</pubDate>
        <link>https://guillermoamaral.com/read/marshmallow_evdev/</link>
        <guid isPermaLink="true">https://guillermoamaral.com/read/marshmallow_evdev/</guid>
        
        
        <category>projects</category>
        
        <category>rpi</category>
        
      </item>
    
  </channel>
</rss>
