Making Your Own Touchpad With PWM And Rust

The modern touchpads are incredible feats of engineering, with everything from complex signal processing for noise and tremendous economies of scale driving prices low. So [Kevin] decided to see if he could make his own touchpad. Partially out of curiosity of what makes one touchpad better than another, but also because he was curious if he could. Using an STM32 and a custom PCB, he was off to the races in an incredibly cost-effective way.

After writing some quick firmware in Rust, he was reporting the values read by the PWM channels. Using python, he could get a good idea of the raw values that were being written over USB and visualized. So rather than implement filtering in hardware or firmware, he elected to do the filtering and processing on the host computer side in Python. We suspect this gave him much shorter iteration cycles.

If you like the idea of making your own touchpad but perhaps are dreaming a little bigger, why not make a tablecloth-sized touchpad?

Need A New Programming Language? Try Zig

Maybe you’ve heard of it, maybe you haven’t. Zig is a new programming language that seems to be growing in popularity. Let’s do a quick dive into what it is, why it’s unique, and what sort of things you would use it for. (Ed Note: Other than “for great justice“, naturally.)

What Is It?

You’ve likely heard of Rust as it has made significant inroads in critical low-level infrastructures such as operating systems and embedded microcontrollers. As a gross oversimplification, it offers memory safety and many traditional runtime checks pushed to compile time. It has been the darling of many posts here at Hackaday as it offers some unique advantages. With Rust on the rise, it makes sense that there might be some space for some new players. Languages like Julia, Go, Swift, and even Racket are all relative newcomers vying for the highly coveted mindshare of software engineers everywhere.

So let’s talk Zig. In a broad sense, Zig is really trying to provide some of the safety of Rust with the simplicity and ease of C. It touts a few core features such as:

  • No hidden control flow
  • No hidden memory allocations
  • No preprocessor, no macros
  • First-class support for optional standard library
  • Interoperable by design
  • Adjustable Runtime Safety
  • Compile-time code-execution

Continue reading “Need A New Programming Language? Try Zig”

Embedded Rust Hack Chat

Join us on Wednesday, May 12 at noon Pacific for the Embedded Rust Hack Chat with James Munns!

Programming languages, like fashion, are very much a matter of personal taste. Professional developers often don’t have much say in which language they’ll use for a given project, either for legacy or team reasons, but if they did have a choice, they’d probably choose the language that works best with the way they think. Some languages just “fit” different brains better than others, and when everything is in sync between language and developer, code just seems to flow effortlessly through the keyboard and onto the screen.

One language that consistently scores at the top of developers’ “most loved” lists is Rust. For a language that started as a personal project and has only existed for a little more than a decade, that’s really saying something. The emphasis Rust puts on safety and performance probably has a lot to do with that. And thanks to its safe concurrency, its memory safety, and its interoperability with C and other languages, Rust has made considerable in-roads with the embedded development community.

To learn more about Rust in embedded systems, James Munns will stop by the Hack Chat. James is an embedded systems engineer, with a history of working on software for a wide range of systems, including safety-critical avionics, and rapidly prototyped IoT systems. He’s a founding member of the Rust Embedded Working Group, as well as a founder of Ferrous Systems, a consultancy focused on systems development in Rust, with a specialty in embedded systems development. James also used to write for Hackaday, so he must be a pretty cool guy. So swing by the Hack Chat and find out where Rust might be able to help you out with your next embedded project.

join-hack-chatOur Hack Chats are live community events in the Hackaday.io Hack Chat group messaging. This week we’ll be sitting down on Wednesday, May 12 at 12:00 PM Pacific time. If time zones have you tied up, we have a handy time zone converter.

Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io. You don’t have to wait until Wednesday; join whenever you want and you can see what the community is talking about.
Continue reading “Embedded Rust Hack Chat”

Low-Level Academy Gets Into Details

We often say that you don’t have to know how an engine works to drive a car, but you can bet that every driver at the Indy 500 knows exactly how it works. You could say the same for computers. You don’t need to understand the details, but it really helps, especially if something goes wrong. [Low-Level Academy] has an online class where you can program in Rust inside your browser to learn about low-level TCP and UDP networking details.

Just how low it goes, we aren’t exactly sure, yet. There are three of eight modules ready to go. The first three cover number encoding, exchanging messages with UDP, and fragmentation. Reliability, routing, server programming, TCP, and HTTP are not out yet, but the ultimate project is a web server. In addition, new modules are released to sponsors first, so the fragmentation module for example won’t be available for a few more days. While that seems unorthodox, it is no different than having to wait for an HBO show to show up on basic cable in reruns.

Continue reading “Low-Level Academy Gets Into Details”

Linux Fu: Global Search And Replace With Ripgrep

If you are even a casual Linux user, you probably know how to use grep. Even if you aren’t a regular expression guru, it is easy to use grep to search for lines in a file that match anything from simple strings to complex patterns. Of course, grep is fine for looking, but what if you want to find things and change them. Maybe you want to change each instance of “HackADay” to “Hackaday,” for example. You might use sed, but it is somewhat hard to use. You could use awk, but as a general-purpose language, it seems a bit of overkill for such a simple and common task. That’s the idea behind ripgrep which actually has the command name rg. Using rg, you can do things that grep can do using more modern regular expressions and also do replacements.

A Note on Installing Ripgrep

Your best bet is to get ripgrep from your repositories. When I tried running KDE Neon, it helpfully told me that I could install a version using apt or take a Snap version that was newer. I usually hate installing a snap, but I did anyway. It informed me that I had to add –classic to the install line because ripgrep could affect files outside the Snap sandbox. Since the whole purpose of the program is to change files, I didn’t think that was too surprising, so I did the install.

Continue reading “Linux Fu: Global Search And Replace With Ripgrep”

3D-Printed Thermite Brings The Heat, And The Safety

Thermites are a double-edged sword. Packing a tremendous energy density, and eager to produce tremendous heat when ignited, thermite is great for welding train tracks. But sometimes you might be looking for a little more finesse. A new approach to 3D printing thermites might just be able to tame the beast.

Most of us do our soldering while sitting safely indoors in a comfortable climate. The biggest dangers we’re likely to face are burnt fingertips, forgetting the heat shrink, or accidentally releasing the smoke monster. But outside of our homes and workshops, there’s a lot of extreme joining of metals going on. No matter where it’s done, welding and brazing in the field requires a lot of equipment, some of which is unwieldy and even more difficult to move around in harsh conditions.

Welding railroad tracks with thermite. Image via YouTube

The utility of brazing is limited by all the complex scaffolding of hardware required to support it. This limiting factor and the discovery of thermite led to exothermic welding, which uses an energetic material to provide enough heat to melt a filler metal and join the pieces. Energetic materials can store a lot of chemical energy and forcefully release it in a short period of time.

Thermites are made of metal oxide and metal powder, often iron oxide and aluminium. When ignited by a source of high heat, thermite compounds undergo an exothermic reduction-oxidation (redox) reaction as the aluminium reduces the number of electrons in the iron oxide atoms. More heat makes the reaction run faster, generating more heat, and so on. The result is molten iron and aluminium oxide slag.

Continue reading “3D-Printed Thermite Brings The Heat, And The Safety”

Exotic Device Gets Linux Support Via Wireshark And Rust

What can you do if you have a nice piece of hardware that kinda works out of the box, but doesn’t have support for your operating system to get the full functionality out of it? [Harry Gill] found himself in such a situation with a new all-in-one (AIO) water cooling system. It didn’t technically require any operating system interaction to perform its main task, but things like settings adjustments or reading back statistics were only possible with Windows. He thought it would be nice to have those features in Linux as well, and as the communication is done via USB, figured the obvious solution is to reverse engineer the protocol and simply replicate it.

His first step was to set up a dual boot system (his attempts at running the software in a VM didn’t go very well) which allowed him to capture the USB traffic with Wireshark and USBPcap. Then it would simply be a matter of analyzing the captures and writing some Linux software to make sense of the data. The go-to library for USB tasks would be libusb, which has bindings for plenty of languages, but as an avid Rust user, that choice was never really an issue anyway.

How to actually make use of the captured data was an entirely different story though, and without documentation or much help from the vendor, [Harry] resorted to good old trial and error to find out which byte does what. Eventually he succeeded and was able to get the additional features he wanted supported in Linux — check out the final code in the GitHub repository if you’re curious what this looks like in Rust.

Capturing the USB communication with Wireshark seems generally a great way to port unsupported features to Linux, as we’ve seen earlier with an RGB keyboard and the VGA frame grabber that inspired it. If you want to dig deeper into the subject, [Harry] listed a few resources regarding USB in general, but there’s plenty more to explore with reverse engineering USB.