Need A Linux Kernel Module? Scratch That

If you have been for (or against) Rust in the Linux kernel, get ready for a Linux kernel module written in… Scratch. That’s right. Scratch, the MIT-developed language with blocks popular for teaching kids to code. We didn’t mean “from scratch.” We meant IN Scratch. The bootstrap code and Makefile is out there on GitHub.

Of course, it is a simple module and the reason it is possible is because of the scratchnative system that lets you compile Scratch into C code. If you want to look at the decidedly simple code, you can open it in your browser.

Continue reading “Need A Linux Kernel Module? Scratch That”

Full Printing Path Control Without Writing GCode

User-friendly slicing software is arguably the key software component that makes 3D printing approachable for most users. Without it going from a CAD design to a printing part would take hours, not seconds. As a trade-off you give up a lot of control over the exact path of the hotend, but most of the time it’s worth it. However, for some niche use-cases, having complete control over the tool path is necessary. Enter FullControl GCode Designer, a tool that gives you all the control without resorting to writing GCode directly.

FullControl takes an approach similar to OpenSCAD, where you define path geometries line by line. Need an array of circles? Choose the circle feature, define its origin, radius, starting position, and extrusion height, and define the spacing and axes (including Z) of the copies. Need a mathematically defined lamp shade? Define the functions, and FullControl generates the GCode. Non-planar printing, where your print head moves along all three axes simultaneously instead of staying at a constant Z-height is also possible. In the video after the break, [Thomas Sanladerer] demonstrates how he used FullControl to reduce the print time of a functionally identical part from two hours to 30 minutes.

FullControl is built on Microsoft Excel using Visual Basic scripting, which comes at the cost of long GCode generation times. It also doesn’t show the defined tool paths graphically, so the generated code needs to be pasted into a viewer like Repetier Host to see what it’s doing. Fortunately, a Python version is coming to should hopefully elevate many of these shortcomings.

We also featured some other GCode hacks in the last few months that bend existing GCode along a spline path, and a Blender plugin allows the surface textures of sliced objects to be modified.

Continue reading “Full Printing Path Control Without Writing GCode”

A Math Based Personality For Games

We make no apologies for being hardware focused here at Hackaday, but that doesn’t mean we aren’t occasionally impressed by a particularly inspired feat of bit wrangling. For example, [t3ssel8r] has taken a break from his game to discuss his procedural animation system and the beautiful math behind it.

Sometimes, rather than having specific keyframes, games will instead use procedural animation. This means that the position is determined on the fly rather than a predetermined set of positions. Developers can use the combination of IK or FK (inverse or forward kinematics) to solve for rotation and positions of the joints that will place the end at a specific position. Particularly with crawling multi-limb things, it’s pretty easy to put a limb on the ground and keep it there until it’s too far away, pick a new spot, and move it there. It’s simple code to write and looks convincing. It can handle complex terrain and situations with different limb positions.

However, it doesn’t offer the chance to inject some life or personality into the movement as keyframes do. [t3ssel8r] goes through the equations and reasoning behind his semi-implicit Euler solver-based system. There are some fantastic explanations in the video, but the short version is that he has three parameters to control the system’s frequency, dampening, and initial response. This allows him to tweak the behavior in a somewhat intuitive manner. One problem is stability; if the timesteps get too large, the position quickly explodes outwards. Using eigenvalues (who ever thought you’d use those) to determine the minimum timestep allows the system to remain stable and take multiple smaller steps when needed or just bound the change temporarily.

If you’re looking for more animation, this blender plugin renders your PCB traces in a new light.

Continue reading “A Math Based Personality For Games”

Bare-Metal STM32: Adding An Analog Touch With ADCs

An Analogue to Digital Converter (ADC) is at its core a straight-forward device: by measuring an analog voltage within a set range and converting the measured level to a digital value we can use this measurement value in our code. Through the use of embedded ADCs in microcontrollers we can address many essential use cases, ranging from measuring the setting on a potentiometer, to reading an analog output line on sensors, including the MCU’s internal temperature and voltage sensors.

The ADCs found in STM32 MCUs have a resolution between 12 to 16 bits, with the former being the most common type. An ADC can be configured to reduce this resolution, set a specific sampling speed, and set up a multi-mode configuration depending on the exact ADC peripheral. STM32 MCUs feature at least a single ADC peripheral, while some have multiple. In this article we will take a look at how to configure and use the basic features of the ADCs in STM32 MCUs, specifically the ADCs found in F0 and the ADC5_V1_1 type as found in most F3-family MCUs.

Continue reading “Bare-Metal STM32: Adding An Analog Touch With ADCs”

Developing A Custom WearOS Watch Face

When you think about customizing the face of a smartwatch, you probably imagine something akin to selecting a new wallpaper on an Android device, or maybe tweaking the color scheme a bit. But not [Sebastian SARBU], his plans were a bit grander than all that. So he cracked open Android Studio and started writing a truly custom watch face that would make the most out of the device’s display. Luckily for us, he’s not only released the source code for others to study, but has documented the development process in a series of videos that you can see below the break.

He’s dubbed the new interface his “Pizza Watch Face”, as it breaks the circular screen down into slices complete with a bits of multi-colored “crust” that can show various notifications using the fewest pixels possible. There’s no question the layout is able to pack a lot of information into a relatively small space, and while aesthetics are naturally subjective, we happen to think it looks pretty slick. Continue reading “Developing A Custom WearOS Watch Face”

Linux Fu: Roll With The Checksums

We are often struck by how often we spend time trying to optimize something when we would be better off just picking a better algorithm. There is the old story about the mathematician Gauss who, when in school, was given busy work to add the integers from 1 to 100. While the other students laboriously added each number, Gauss realized that 100+1 is 101 and 99 + 2 is also 101. Guess what 98 + 3 is? Of course, 101. So you can easily find that there are 50 pairs that add up to 101 and know the answer is 5,050. No matter how fast you can add, you aren’t likely to beat someone who knows that algorithm. So here’s a question: You have a large body of text and you want to search for it. What’s the best way?

Continue reading “Linux Fu: Roll With The Checksums”

Edging Ahead When Learning On The Edge

“With the power of edge AI in the palm of your hand, your business will be unstoppable.

That’s what the marketing seems to read like for artificial intelligence companies. Everyone seems to have cloud-scale AI-powered business intelligence analytics at the edge. While sounding impressive, we’re not convinced that marketing mumbo jumbo means anything. But what does AI on edge devices look like these days?

Being on the edge just means that the actual AI evaluation and maybe even fine-tuning runs locally on a user’s device rather than in some cloud environment. This is a double win, both for the business and for the user. Privacy can more easily be preserved as less information is transmitted back to a central location. Additionally, the AI can work in scenarios where a server somewhere might not be accessible or provide a response quickly enough.

Google and Apple have their own AI libraries, ML Kit and Core ML, respectively. There are tools to convert Tensorflow, PyTorch, XGBoost, and LibSVM models into formats that CoreML and ML Kit understand. But other solutions try to provide a platform-agnostic layer for training and evaluation. We’ve also previously covered Tensorflow Lite (TFL), a trimmed-down version of Tensorflow, which has matured considerably since 2017.

For this article, we’ll be looking at PyTorch Live (PTL), a slimmed-down framework for adding PyTorch models to smartphones. Unlike TFL (which can run on RPi and in a browser), PTL is focused entirely on Android and iOS and offers tight integration. It uses a react-native backed environment which means that it is heavily geared towards the node.js world.

Continue reading “Edging Ahead When Learning On The Edge”