text
stringlengths
0
1.49k
**Brian Ketelsen:** It took me - how many minutes to get into politics?
**Erik St. Martin:** Right?! \[laughter\]
**Carlisia Thompson:** Wow... That was a record.
**Erik St. Martin:** He was just sitting on that button.
**Carlisia Thompson:** But today is a tough day...
**Brian Ketelsen:** It is a very tough day.
**Erik St. Martin:** So on a more exciting note, your project Periph -- I'm gonna say [Periph.io](https://periph.io/)... It rolls off the tongue better than just Periph, I think.
**Marc-Antoine Ruel:** That's true.
**Erik St. Martin:** So you haven't learned to pronounce it yet, so we're gonna make up the pronunciation on the show...
**Carlisia Thompson:** \[04:11\] You have heard it here first.
**Marc-Antoine Ruel:** Yeah, that's great. So the fun thing is that it started in 2014. Back at that time there was a company named GroupGet, and they wanted to test a platform; it was a small startup. And they started to do a googlers-only selling of the [FLIR Lepton](https://www.flir.com/products/lepton/), which is a...
At that point I decided to say, "Well, I'm going to write a driver for it in Go, because I wasn't really happy with the code that was provided with the device.
**Brian Ketelsen:** Now, I have an important question for you - is this infrared camera heat-proof?
**Marc-Antoine Ruel:** No. It's actually designed to look at temperatures. The FLIR company makes infrared cameras to be able to read temperature via infrared images. So it's not like the low-light cameras that you can see in the dark, it's really just about looking at temperature.
**Brian Ketelsen:** Still sounds interesting.
**Erik St. Martin:** I already see where you're going with this, Brian.
**Brian Ketelsen:** \[laughs\] We'll get there.
**Marc-Antoine Ruel:** \[laughs\] Yeah... I actually know what your question is. I don't recall what's the highest temperature it can register...
**Brian Ketelsen:** It'll probably melt.
**Marc-Antoine Ruel:** \[laughs\] It'll probably melt. Yeah, so basically I started writing code for that in early 2015. I had a lot of fun with it, but the device was kind of tricky, the interface, and I had a lot of trouble with keeping a good signal, but on the other hand I started learning with websockets and a lot...
Then in the summer I attended the first [GopherCon](https://www.gophercon.com), and I saw the Gobots room and then I realized that they existed, because I didn't realize before. But at the time it didn't support SPI protocol, which is needed for this camera, so I was like "Okay... Too bad." But then eventually I just d...
Later in the Christmas period [Brad Fitzpatrick](https://twitter.com/bradfitz) did his Christmas slide on Christmas evening I was like, "Oh, that's a neat idea." So I bought a few LEDs... They are quite expensive in Canada. Amazon doesn't really have any roll of them, so basically I bought them on Alibaba. I bought 12 ...
Then I decided to start the project that I named [dlibox](https://github.com/maruel/dlibox) and I wrote my own driver for that. The reason I decided to go with this one in particular is because I wanted to do night lights for my children's room. These can go really dark -- actually, really faint in the brightness... Be...
Because of that, I was actually able to make them so that basically you can have very, very faint lighting that you can keep in the room for the whole night. It's pretty nice.
**Brian Ketelsen:** \[07:56\] That's fantastic. I have very long - maybe 15-meter - LED strips under the bunk beds in all of my kids' room, because underneath the bunk bed gets almost no light at all. So they even use those during the day time, but it would be awesome to be able to control the brightness of those.
**Marc-Antoine Ruel:** Yeah, that's cool. Because otherwise, depending on the kind of light, it can be very bright and then it's kind of aggressive, especially at night. So yeah, having the possibility to have a very faint light is really nice.
**Erik St. Martin:** Now, this is controllable through the [SPI](https://en.wikipedia.org/wiki/Serial_Peripheral_Interface) bus, or this is just like doing PWM, or something?
**Marc-Antoine Ruel:** No, it's SPI bus. One of the nice things about these lights is that each device has its own sets of PWMs. Actually, there's four PWMs per light, so one per channel - one red, one green and one blue, and then there's another one... So basically there's an overall brightness, and then one per chann...
So what I did in the driver is that I tried to use the channel PWMs, and one I'd go to the very dim coloring, then I'd start using the other ones. Basically, I use a ramp, a \[unintelligible 00:09:13.04\] ramp so that for example if you ask a 50% light intensity, in practice you get about 10% because that's how the eye...
**Erik St. Martin:** Nice. Now, do you have like a Raspberry Pi or like a BeagleBone running a Go process that controls this?
**Marc-Antoine Ruel:** Yeah, so I started with a Raspberry Pi. I really wanted it to run well on the Raspberry Pi, and just for the fun of it I wanted to see if I could do performance optimization on that. Eventually, I just bought a fair chunk of Raspberry Pi 3's. The main advantage of the 3 is that it boots faster. S...
The way it works - it's really not Raspberry Pi specific at all. Basically, as long as you have an SPI bus, it just works.
**Brian Ketelsen:** That's very nice.
**Marc-Antoine Ruel:** Then I started to take a look at more serious projects. Once it started working - it was closer to summer of last year - then I decided to look at... Well, actually I started talking with Jana, and I saw that she had been working on standardizing an SPI protocol there, so I was like "Oh, okay, bu...
One of the reasons is that actually in a previous library I used to do Kernel development on Windows at Matrox, a video card maker in the late '90s. I was doing just trivial imaging over FireWire 1394 and it was really nice. I had 1,000 fps cameras, which was very amazing at that time. But I was working on Windows NT 4...
\[12:31\] On the other hand, I got to learn a lot about terminal development. For example, Windows NT 4 didn't have any native support for plug and play, so it was really a pain to work with. But then Windows 2000 came out and it was awesome, obviously. \[laughs\] At least it worked.
Basically, this concept of managing discoveries of device -- well, actually, at the time I didn't want to have discovery of device, but I wanted to have a discovery of the functionality provided by the host. I experimented with that for many months, and I finally got something that I like, maybe in October or November ...
**Brian Ketelsen:** How do you encapsulate that sort of -- I mean, it's almost like service discovery for the host. How does that look at a conceptual level?
**Marc-Antoine Ruel:** Basically, I wanted to create a registry... What happens is that each of the drivers that you want to register, Periph provides a few - they are registered automatically - the driver specifies the dependencies it has. For example, right now I'm working on a DMA controller driver, so basically it ...
Basically, it registers a DAG. It's really a directed graph of all the drivers, and each of the drivers specify which other drivers they need to be able to be worth trying to be loaded. So the library makes sure that the DAG is actually good, valid, there's no cycle, things like that. And once it detects that it's vali...
The driver can return three different states. Either it's ignored, because it's just not relevant on the platform... For example, the driver for the [C.H.I.P.](https://en.wikipedia.org/wiki/CHIP_(computer)) pinout is ignored if it's not running on the Allwinner CPU.
There's also it was valid and it worked, or it was valid and it failed to load. For example, on most platforms, if it's not running by default, most of the operating systems (Linux distributions) are not configured in a way where we can use, for example, SPI arbitrarily without running as root or yourself modifying the...
**Erik St. Martin:** So all of this is meant to kind of create an abstraction, kind of like layers? Because I noticed that you had some drivers for like Maxim temperatures sensors, or the Dallas temperature sensors and things like that... So basically you would include one of those and then it tries to load the SPI dri...
**Marc-Antoine Ruel:** Actually, it's the reverse. When you start it up, it tries to discover all the hardware features of the platform, of the host itself, but it doesn't try to discover anything attached to it, so to not start interfering, or anything like that. Then it's really up to the application, basically.
**Erik St. Martin:** \[16:15\] Okay, yeah. So it tries to discover whether things like SPI or [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) or UR is available on board, and then from there you kind of take control of those connections?
**Marc-Antoine Ruel:** Exactly. For example, if you take a chip, by default SPI is not enabled, so it will not be loaded, so then when you request SPI bus/ SPI connection, it will refuse because it didn't find any... If you then follow the instructions to enable it, then after that it would be available, and when you r...
The general idea is really about all the underlying platform support, to have that as automatic as possible, basically. So the part of the device drivers - basically, I started writing the device drivers because I felt that I couldn't implement the underlying host drivers without having something to test against. So I ...
Good examples are the BME280. One of the reasons I decided to start using it is that it supports both SPI and I2C. But the way the protocol works in SPI is very different from I2C. I wanted to be able to write a device driver that would be able to talk both dialects, but in a way that would abstract out the fact that u...
The SSD1306 - it's also a dual protocol device that can talk I2C and SPI, but the difference there is that it actually... First, it's a write-only device, but also when you write over SPI, you have to play with the (CS) line manually; it's kind of weird. Or you can use a 9-bit SPI protocol. I actually haven't finished ...
**Erik St. Martin:** Yeah, and one thing I saw too was you have 1-Wire support, which was kind of fun. I'm actually using that for some temperature sensors that I have, thermocouple sensors.