Lambdas For C — Sort Of

A lot of programming languages these days feature lambda functions, or what I would be just as happy to call anonymous functions. Some people make a big deal out of these but the core idea is very simple. Sometimes you need a little snippet of code that you only need in one place — most commonly, as a callback function to pass another function — so why bother giving it a name? Depending on the language, there can be more to it that, especially if you get into closures and currying.

For example, in Python, the map function takes a function as an argument. Suppose you have a list and you want to capitalize each word in the list. A Python string has a capitalize method and you could write a loop to apply it to each element in the list. However, map and a lambda can do it more concisely:

map(lambda x: x.capitalize(), ['madam','im','adam'])

The anonymous function here takes an argument x and calls the capitalize method on it. The map call ensures that the anonymous function is called once for each item.

Modern C++ has lambda expressions. However, in C you have to define a function by name and pass a pointer — not a huge problem, but it can get messy if you have a lot of callback functions that you use only one time. It’s just hard to think up that many disposable function names. However, if you use gcc, there are some nonstandard C features you can use to get most of what you want out of lambda expressions.

Continue reading “Lambdas For C — Sort Of”

Pan And Tilt To A New 3D Printed Business Model

When shooting video, an easy way to get buttery smooth panning and tracking is to use a mechanical device like a rail to literally slide the camera side to side. These range from what is essentially a skateboard to incredible programmable multi-axis industrial robots, a wide variety of which have been visible in the backgrounds of Youtuber’s sets for years. But even the “low end” devices can run hundreds of dollars (all that anodized aluminum doesn’t come cheap!). Edelkrone has been building lust worthy professional (read, pricey) motion setups for a decade. But in the last year they’ve started something pretty unusual; lowering prices with their Ortak series of 3D printed equipment. But this time, you do the printing.

In the FlexTILT Head 3D, everything in red is printed at home

Since the RepRap we’ve been excited about the future of democratized at home manufacturing, but to a large extent that dream hasn’t materialized. Printers are much more useful now than in the early days but you can’t buy a new mug from Starbucks and print it at home. But maybe that’s changing with Edelkrone’s offering.

When you buy an Ortak product you get one thing: all the fasteners and hardware. So the final product is more durable and appears more finished than what would pop out of your Prusa unaided. What about the rest of the device? That’s free. Seriously. Edelkrone freely provides STLs (including print setting recommendations) with detailed step-by-step assembly instructions and videos (sample after the break). Nice hack to avoid piracy, isn’t it?

Why choose the do-it-at-home style product? A significant price reduction of course! The Ortak line currently includes two products, the FlexTILT head you see above, and a skateboard-style slide called the SKATER 3D. Both of these were sold fully finished before making it to the DIY scene. The FlexTILT Head 2 comes in at $149 when you buy it whole. And when the PocketSKATER 2 was for sale, it included a FlexTILT Head and came to $249. Now? Each hardware kit is just $29.

So is this it? Have we hit the artisanal DIY micro-manufactured utopian dream? Not yet, but maybe we’re a little closer. Edelkrone is a real company which is really selling these as products, right there on their website along with everything else. They refer to it as “co-manufacturing” which we think is a clever name, and talk about expanding the program to include electronics. We can’t wait to see how the experiment goes!

Continue reading “Pan And Tilt To A New 3D Printed Business Model”

Does Your Home Assistant Know When You Are Sleeping?

It always gives us a sense of wonder when we realize that what would be a simple task for a human child is a big deal for a computer. For example, if you asked someone if you or someone else was in bed, that’s a pretty simple thing to check. For you, that is. For a computer, it requires some sort of sensor. [Lewis] used load cells to tell if someone is in a particular bed or not. He uses Home Assistant and has a great post about how he created and interfaced the sensors. Of course, the sensors really only tell you if something heavy is in the bed. It doesn’t know who it is or even that it isn’t an overstuffed suitcase.

Load cells aren’t exactly high tech. There are several different types that use hydraulic pressure or pneumatics to measure force. However, the most common that we encounter use strain gauges. A strain gauge is a resistor that changes value when it deformed and a load cell usually has several strain gauges wired in a bridge configuration so that small forces create larger output changes.

Continue reading “Does Your Home Assistant Know When You Are Sleeping?”