Marc's Public Blog


All | Aquariums | Arduino | Btrfs | Cars | Cats | Clubbing | Dining | Diving | Electronics | Exercising | Flying | Hiking | Linux | Linuxha | Museums | Public | Rc | Sciencemuseums | Snow | Solar | Trips




More pages: August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 September 2017 August 2017 July 2017 June 2017 May 2017 April 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 October 2008 September 2008 August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 June 2006 May 2006 April 2006 March 2006 February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 May 2005 April 2005 March 2005 February 2005 January 2005 December 2004 November 2004 October 2004 September 2004 August 2004 July 2004 June 2004 May 2004 April 2004 March 2004 February 2004 January 2004 October 2003 August 2003 July 2003 May 2003 April 2003 March 2003 January 2003 November 2002 October 2002 July 2002 May 2002 April 2002 March 2002 February 2002 November 2001 October 2001 September 2001 August 2001 July 2001 June 2001 May 2001 April 2001 March 2001 February 2001 January 2001 December 2000 November 2000 October 2000 September 2000 August 2000 July 2000 June 2000 April 1999 March 1999 September 1997 August 1997 July 1996 September 1993 July 1991 December 1988 December 1985 January 1980



2017/04/30 Cupertino Cherry Blossom Festival
π 2017-04-30 01:01 in Public
Another year, another Cherry Blossom Festival in Cupertino, nice demos, displays and art:



Multiple sport demos and performances:





For animals, a koi pond, and japanese dogs:





Lots of Ikebana:











Dolls:




Kanji Art:




Dance and music performances:



See more images for Cupertino Cherry Blossom Festival
2017/04/29 FC Drivers Southbound to San Jose and Los Gatos Luxury Cars Open House
π 2017-04-29 01:01 in Cars
Nice weather, pretty clear roads, yummy crepes.


we got there 18mn early, we had time to burn :)
we got there 18mn early, we had time to burn :)

finally the other folks appeared :)
finally the other folks appeared :)






nice P1
nice P1










2017/04/24 Adafruit GFX on NeoMatrix and RGB Matrix Panel Demo
π 2017-04-24 01:01 in Arduino
Give me code:
  • https://github.com/marcmerlin/Adafruit_NeoMatrix/tree/master/examples/MatrixGFXDemo
  • https://github.com/marcmerlin/RGB-matrix-Panel/tree/master/examples/PanelGFXDemo
  • FastLED Version https://github.com/marcmerlin/FastLED_NeoMatrix/blob/master/examples/MatrixGFXDemo/MatrixGFXDemo.ino
  • Note that the last link uses my https://github.com/marcmerlin/FastLED_NeoMatrix library which ports NeoMatrix to the better FastLED backend. The nice thing though is that all your code keeps working just the same, no changes required outside of matrix initialization. I wrote a different page for my FastLED::NeoMatrix library.

    All the displays, 4 made with neopixels and soldered by hand
    All the displays, 4 made with neopixels and soldered by hand

    Yeah, the 24x24 one took forever to lay out, glue and solder (6H+)
    Yeah, the 24x24 one took forever to lay out, glue and solder (6H+)

    More than 2 years ago, I spent many hours writing an interrupt written driver for LED matrices that require fast line scanning while you setup the right rows, and even faster per color refreshes where you turn the color on and off depending on how bright you want each color component to be to yield different color mixes. This is explained in more details on my page on Driver for direct driving single to 3 color LED Matrices with software PWM.

    Then came in Neopixels which can be individually addressed without fast row scanning, and the Adadfruit Neomatrix library. Those made creating color matrices much more trivial (except for the part where you have to actually build and solder that matrix):

    2 row scanned matrices on the upper left, 7x7 neomatrix, another row scanned 32x16 Adafruit panel.
    2 row scanned matrices on the upper left, 7x7 neomatrix, another row scanned 32x16 Adafruit panel.

    on the bottom row, self built 16x8 neomatrix, and another 12x12 neomatrix
    on the bottom row, self built 16x8 neomatrix, and another 12x12 neomatrix

    I ended up taking my old Adafruit GFX demo I wrote fro my interrupt driven scan matrices, porting it to Neomatrix (which was trivial) and then extending it. You can find my MatrixGFXDemo code here,
    Soon afer, I dug up my Adafruit 16X32 RGB LED Matrix Panel, setup an old Arduino Mega to control it and have enough RAM left to run some fun code (on an Uno memory would have been too tight), it turns out that thanks to Adafruit GFX support, it took very little time to get my same demo working on the RGB Panel.

    Here is a video of the demo I wrote on all those different displays:

    Here are some things the demo does:

  • Init displays the same 8x8 pattern as many times as it will fit

  • The code will then draw lines, rectangles and circles that match the size of the display:


  • If the display is at least 16x8, it will display the resolution in various ways appropriate to the display size:




  • another part of the demo displays an 8x8 color pixmap with drawRGBBitmap I added in Adafruit-GFX-Library and bounces it around on any display bigger than 10x10:


  • then, it will display a 24x24 bitmap which on most displays will be panned around to show the whole picture:


  • Hope you enjoy the demo, it should work pretty trivially on any display that supports Adafruit::GFX, see https://github.com/marcmerlin/RGB-matrix-Panel/blob/master/examples/PanelGFXDemo/PanelGFXDemo.ino#L21 on how some backend specific code can be #define'd to work on other backends.

    2017/04/21 Spring Skiing at Heavenly
    π 2017-04-21 01:01 in Snow
    Neither Arturo nor Johannes had gone to Heavenly this year, and it was about to close most of its lifts after this week, so Arturo offered a day trip there, which we both graciously accepted. We left around 05:30 and arrived by the nevada border by 09:30, parked, and took the gondola up because the connecting california lifts were already closed.


    how's that cindaquil?
    how's that cindaquil?


    we actually stopped at mid station for a look, which I had never done :)
    we actually stopped at mid station for a look, which I had never done :)



    We then had to follow the sun and started down at stagecoach and went up to dipper as things got warmer, and eventually moved to sky express. The snow was spring snow, we had to avoid the ice in some places and sticky slush in others, but overall the snow was good on groomers and ok elsewhere. And for snow, there is lots of it.






    lots of things were closed of course
    lots of things were closed of course


    Thanks to Arturo for getting us there, that was fun.

    See more images for Spring Skiing at Heavenly
    2017/04/16 IoTuz Driver ported to Expressif ESP32 WROVER board
    π 2017-04-16 01:01 in Arduino
    As explained on this page, I wrote a pretty extensive driver-set for an ESP32 based board with lots of IO, but hardly anyone has that board (fewer than 100 made), so I ported what I could of the code to the WROVER.


    Sadly the WROVER lacks a touch screen, so you'll have to wire at least a rotary encoder or a joystick. In the demo above I also wired 2 neopixels and an IR receiver to mirror the hardware on the IoTuz.

    Source code: https://github.com/marcmerlin/IoTuz

    See this video for a demo:

    You'll definitely want to read https://github.com/marcmerlin/IoTuz/blob/master/README.md carefully, especially the WROVER section.

    On an ILI3941 based WROVER, you should also be able to play tetris and breakout:

    Enjoy!

    2017/04/09 Flight to Mammoth and Attempted 2ft Powder Day
    π 2017-04-09 01:01 in Flying, Snow
    It had been several years since I last went to Mammoth, and I was looking forward to finally going there with fresh powder. I carefully watched the forecast several days early including saturday when the storm was hitting the resort, to make sure that the top of the mountain would stay closed and I'd get fresh tracks the next day if I went. I got up early (actually I woke up before my alarm) and by 04:45 started getting ready. Got to Palo Alto Airport at 05:15 and then started loading up the plane, parked the car, and got in the air by 06:00 for a beautiful easy flight:







    By 07:15, I landed at KMMH, taxied to parking, found my rental car waiting for me on the tarmac (courtesy of Hertz), but sadly it was a 2 wheel drive with crappy tires (the front tires were not even M+S, they turned out to be crappy summer tires). Driving up to the resort, blowing past several chain control signs, took virtually all the driving skills I had. While I was barely able to drive up in the snow, I knew if I ever had to stop, it would be super unlikely that the car would get traction to restart at all (especially uphill), so I drove slowly with some distance with the car in front of me so I never had to stop when the traffic slowed down. Maybe in hindsight I should have gone to Eagle Lodge at much lower altitude, but powder-wise this was not a good idea, it was the wrong side of the resort and the top connecting lifts would be closed for a while. Yes, I should have had chains, but Hertz refuses to give or rent you chains because they're worried you may put them on wrong :(

    Despite the driving challenges, I arrived at the main base around 08:15, had to find a far away parking spot and walk to the ticket counter to get my pass. I eventually got to the slopes around 08:40, which wasn't too bad.

    snow all the way up to the base
    snow all the way up to the base

    the top of the mountain stayed closed until about 11:00
    the top of the mountain stayed closed until about 11:00

    strangely, there was no line at the gondola
    strangely, there was no line at the gondola

    that's because everyone got out at mid station waiting for the top to open (that took 2H)
    that's because everyone got out at mid station waiting for the top to open (that took 2H)

    every other lift had 15mn+ lines
    every other lift had 15mn+ lines

    and lines
    and lines

    and more lines
    and more lines

    while the gondola to the top wasn't open yet, but that's a lot of tracks down for a few ski patrol runs. Mmmh...
    while the gondola to the top wasn't open yet, but that's a lot of tracks down for a few ski patrol runs. Mmmh...

    sadly, the 2ft of powder were pretty packed by the wind
    sadly, the 2ft of powder were pretty packed by the wind

    line at the mid station gondola. It was better go to all the way back down and get it there
    line at the mid station gondola. It was better go to all the way back down and get it there

    Gondola towards top of cloud nine had a bit of powder (only enough for one run though)
    Gondola towards top of cloud nine had a bit of powder (only enough for one run though)

    snow was good up high, but by 9000ft the powder quality went way down :-/
    snow was good up high, but by 9000ft the powder quality went way down :-/

    hike up the ridge to santiago bowl/hemlock bowl and chair 14
    hike up the ridge to santiago bowl/hemlock bowl and chair 14

    The next morning, driving up was easier, the road was mostly clear. I also only drove up to Mill's Café, which put me at the lifts I wanted and is actually easier to get back to, than the main lodge. Some people actually camped there:


    The next morning was already spring skiing. Not bad, mostly no ice or slush, which is good, but virtually no powder left anywhere:



    During those 2 days, I got some nice pictures of the surroundings:


    airport I went to
    airport I went to

    looks nice to ride :)
    looks nice to ride :)


    this reminds me of heavenly]



    On the way back, saw one of the Alaska planes bringing in a load of passengers:



    good way to see the mountain
    good way to see the mountain

    Mill's Café where I parked, and main lodge at the end of the road
    Mill's Café where I parked, and main lodge at the end of the road

    Facelift Express
    Facelift Express


    I hiked up the hill to ski down that face a couple of times
    I hiked up the hill to ski down that face a couple of times

    2017/04/03 Arduino 328P Uno Teensy3.1 ESP8266 ESP32 IR and Neopixels
    π 2017-04-03 01:01 in Arduino, Clubbing, Electronics
  • Why my pants needed IR controlled neopixels :)
  • Why IR and Neopixels at the same time, is hard
  • Concurrent IR + Neopixels solution #1: be fast (Teensy 3.1)
  • Concurrent IR + Neopixels solution #2: don't use the CPU for neopixels (ESP8266 (I2S) and ESP32 (RMT))
  • Software and Libraries
  • Video with the whole story and details
  • Show me the code!

    Sure, it's here: https://github.com/marcmerlin/Neopixel-IR (but go to the end of this page for more details).

    Why my pants needed IR controlled neopixels :)

    I mean, don't everyone's pants need neopixels? :)

    I started with a silver shirt, I added a few LEDs, and then more I got from a swap meet, and later added some LED shoes I hacked to last 12H instead of 4



    The end goal was adding neopixel strips on my shirt sleeves and pant legs:


    Here is a 6mn clip showing the shoes and shirt if you'd like the details:

    The problem with my shirt, though, is that the colors you see on the picture are actually due to broken traces, causing the colors you see. It's better than nothing, but not what I was trying to do, and no way to create streaming effects. This is of course where neopixels come in.

    I'm not going to repeat the excellent Adafruit Neopixel Uberguide here, but I have a 3mn video clip showing a standard IR RGB LED controller, compared to a neopixel strip. It also shows how I use standard remote control servo cables to wire neopixels, and how to watch out for:

  • signal wire being in the center, so you must not feed 5V on the middle wire like you would with RC and servos
  • how if you have a neopixel strip that doesn't work right, you can only connect to the first LED, and you have to start cutting off LEDs from the strip one by one until you get to the first one that works
  • before you start cutting, make very sure you aren't connecting to the last LED (DO vs DI)
  • Why IR and Neopixels at the same time, is hard

    So, the main point of this page is however to look into the issues of controlling Neopixels and receiving IR signals at the same time.

    It's easy to listen for IR, and then change neopixels, leave them alone, and listen for IR again. It's hard (or near impossible on some chips) to actively update neopixel strips for animations and listen for IR commands at the same time.

    Why? This video explains the issue:

    What's going on is on low end arduino chips (328p, leonardo, or even AT mega and all other 16 bit AVRs), neopixels are controlled by stopping chip interrupts and sending a very precisely timed signal to the neopixels. If the timing is off just a little bit, the wrong colors get sent, or nothing works at all. This is why interrupts must be disabled


    Now, there are actually many other addressable multicolor LED types. The nice ones are 4 wire and work via SPI, which allows the CPU to control the timing and the clock, removing this exact bit banging timing issue. The cheaper 3 wire ones have a set clock and require that the CPU sends a very precisely timed signal, usually done while disabling interrupts. See https://github.com/FastLED/FastLED/wiki/Overview

    But since neopixel strips (aka WS2811/WS2812/WS2812B) is what I already had, I now had to deal with this precise timing issue. As you can guess, disabling interrupts causes issues with the IRRemote library because it has its on interrupt handler timer that also requires being run at a special timing, or it doesn't capture proper IR signals.
    The end result is that you cannot disable interrupts and receive IR signals, and if you don't disable interrupts, the neopixel signal is unstable and the colors flicker (demonstrated int the video above).

    So, unless you use some special hardware to drive neopixels strips on an AVR chip, concurrent IR + neopixels is just not going to work.

    an arduino nano v3 running neopixel strips
    an arduino nano v3 running neopixel strips

    my 328p arduiny chip (equivalent to arduino nano) and anti plug backwards toothpicks :)
    my 328p arduiny chip (equivalent to arduino nano) and anti plug backwards toothpicks :)

    because my 328p chip was unprogrammed, I had to figure out direct ISP programming pinout for it and I flashed a bootloader on it
    because my 328p chip was unprogrammed, I had to figure out direct ISP programming pinout for it and I flashed a bootloader on it

    Concurrent IR + Neopixels solution #1: be fast (Teensy 3.1)

    a few chips for comparison (uno, leostick, nano v3, arduiny, and Teensy 3.1 in green)
    a few chips for comparison (uno, leostick, nano v3, arduiny, and Teensy 3.1 in green)

    Thanks to better FastLED hardware support, when I moved my code to a Teensy 3.1 32 bit ARM CPU, the CPU was fast enough that it had time to re-enable interrupts in the middle of updating neopixels. This in turns allowed the IR Remote interrupt handler to just barely run in between pixel updates, and capture IR codes. Success!

    See this video for details:

    The magic code that makes this work, is here: https://github.com/FastLED/FastLED/blob/master/platforms/arm/k20/clockless_arm_k20.h#L34
    sei(); delayMicroseconds(WAIT_TIME); cli();

    Thanks to this re-enabling of interrupts, things work.

    So at this point, someone sensible would have declared victory. However, I felt bad wasting a Teensy 3.1 on something as simple as driving a single neopixel strip (it can drive 8 in parallel) and reading from an IR receiver, when it has around 32 I/O ports. This is why I checked if I could get this to work on ESP8266 chips which are even cheaper and have much fewer I/O pins (but add Wifi)

    Concurrent IR + Neopixels solution #2: don't use the CPU for neopixels (ESP8266 (I2S) and ESP32 (RMT))

    I had more 32bit chips, so I thought I would give them a try. I tried the ESP8266 and ESP32:


    First, the ESP8266 mostly worked with FastLED + IRRemote, but not quite. The FastLed code, just like on Teensy, is nice enough to re-enable interrupts for a short while: https://github.com/FastLED/FastLED/blob/master/platforms/esp/8266/clockless_esp8266.h#L45

    os_intr_unlock();
    delayMicroseconds(WAIT_TIME);
    os_intr_lock();

    However in my tests, the IRremoteESP8266 library was maybe a little bit too slow and caused occasional visible neopixel glitching. This is where I found this interesting library: https://github.com/JoDaNl/esp8266_ws2812_i2s/ which manages to drive the neopixels without doing bit banging with interrupts disabled ((ab)-using the I2S hardware support). It's not a very fancy library in what it offers, but it works perfectly with interrupts enabled.

    Same thing for ESP32. Actually ESP32 is even more difficult to get a perfect timing out of using bit-banging given that it's a dual core CPU running on top of an RTOS, and no matter how precise your code is, you just cannot guarantee that it'll run perfectly at the timing you need all the time. I did add ESP32 support to the Adafruit Neopixel library, but it only works most of the time, which isn't really good enough.
    This where its built in RMT support comes in. It can generate 8 precise signal waves, which are perfect for neopixels, so this is the way to go to animate neopixels without disabling interrupts (making IR receiving trivial). IRremote was missing ESP32 receive support, but I added it recently, so it's all working.

    Here's a video summary of ESP8266 and ESP32:

    Software and Libraries

    So, here's a summary of all the libraries I went through, 2 for IR, and 4 for Neopixels:
  • To receive IR signals, we'll use the excellent IRremote lib: https://github.com/z3t0/Arduino-IRremote
  • ESP8266 currently uses a fork of IRRemote, IRremoteESP8266 which may soon be in the process of being merged in the main Arduino-IRremote. See https://github.com/markszabo/IRremoteESP8266/issues/148 and https://github.com/z3t0/Arduino-IRremote/issues/400#issuecomment-294446261 .
  • For neopixels, most people use the adafruit lib: https://github.com/adafruit/Adafruit_NeoPixel . It works ok, but it requires disabling interrupts (and is therefore incompatible with IRRemote for concurrent operation)
  • FastLED is a more complete library with better hardware support (both in pixels and CPUs): https://github.com/FastLED/FastLED . The big plus of this lib is that it support re-enabling interrupts on 32bit chips, allowing the IRremote ISR to run.
  • Instead of FastLED (which does work), on ESP8266 you can use https://github.com/JoDaNl/esp8266_ws2812_i2s/ . The support is bare, but uses an inventive (ab)use of the I2S subsystem (I2C for audio) to generate neopixel signals using an onboard co-processor unit without tying up the main CPU or requiring the disabling of interrupts.
  • On ESP32, FastLED isn't supported yet (I added support in Adafruit-Neopixel) but both require disabling interrupts at least temporarily and it's hard to do anything real time on a dual core ESP32 running on top of an RTOS. The good news however is that it has 8 RMT channels which are designed to handle precise signals like this without tying up the CPU. See this code that supports Neopixels with exact timing: https://github.com/MartyMacGyver/ESP32-Digital-RGB-LED-Drivers
  • And here is my code again: https://github.com/marcmerlin/Neopixel-IR

    The big plus from that example code is that it supports 4 different Neopixel backends and abstracts them so that the adafruit (and other) demos can run on all 4 libs. See how it does it here: https://github.com/marcmerlin/Neopixel-IR/blob/v1.0/Neopixel-IR.ino#L275

    Video with the whole story and details

    This is a 25mn mashup of all the video clips, including a section on flashing the arduiny via ISP (AVR 328p):

    I also have a video showing the evolution of lights on my shirt from v1 (single non controllable color) to v2 (tri color, but not pixel addressable), to neopixels with cool patterns (jump to 3:50 if you'd like that):


    More pages: August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 September 2017 August 2017 July 2017 June 2017 May 2017 April 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 October 2008 September 2008 August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 June 2006 May 2006 April 2006 March 2006 February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 May 2005 April 2005 March 2005 February 2005 January 2005 December 2004 November 2004 October 2004 September 2004 August 2004 July 2004 June 2004 May 2004 April 2004 March 2004 February 2004 January 2004 October 2003 August 2003 July 2003 May 2003 April 2003 March 2003 January 2003 November 2002 October 2002 July 2002 May 2002 April 2002 March 2002 February 2002 November 2001 October 2001 September 2001 August 2001 July 2001 June 2001 May 2001 April 2001 March 2001 February 2001 January 2001 December 2000 November 2000 October 2000 September 2000 August 2000 July 2000 June 2000 April 1999 March 1999 September 1997 August 1997 July 1996 September 1993 July 1991 December 1988 December 1985 January 1980