Render HTML And CSS On An ESP32

As the available computing power from affordable microcontrollers continues to increase, there is an inevitable blurring of the line between them and the lower tier of application processors capable of running Linux-based operating systems. For the most part a microcontroller busies itself with behind-the-scenes tasks, but as so many projects here have demonstrated, they can be pretty capable when it comes to user-facing applications too. Now [Andy Green] has extended the possibilities with affordable silicon, by producing a proof-of-concept HTML + CSS renderer over h2 on ESP32 for libwebsockets. Surf the web on a microcontroller without settling for a text-only experience? Why not!

He freely admits that this is far from being a complete HTML rendering engine, in that while it parses and renders HTML and CSS with JPEG and PNG image support, it does so only with a subset of HTML and is not tolerant of any malformations. There is also no JS support, which is hardly surprising given the available resources.

Even with those limitations it remains an impressive piece of work, which we hope will one day be able to make some effort at displaying Hackaday on ESP32 devices such as the European conference badges. Definitely a project to watch!

Cable Modem Turned Spectrum Analyzer

Hopefully by now most of us know better than to rent a modem from an internet service provider. Buying your own and using it is almost always an easy way to save some money, but even then these pieces of equipment won’t last forever. If you’re sitting on an older cable modem and thinking about tossing it in the garbage, there might be a way to repurpose it before it goes to the great workbench in the sky. [kc9umr] has a way of turning these devices into capable spectrum analyzers.

The spectrum analyzer feature is a crucial component of cable modems to help take advantage of the wide piece of spectrum that is available to them on the cable lines. With some of them it’s possible to access this feature directly by pointing a browser at it, but apparently some of them have a patch from the cable companies to limit access. By finding one that hasn’t had this patch applied it’s possible to access the spectrum analyzer, and once [kc9umr] attached some adapters and an antenna to his cable modem he was able to demonstrate it to great effect.

While it’s somewhat down to luck as to whether or not any given modem will grant access to this feature, for the ones that do it seems like a powerful and cheap tool. It’s agnostic to platform, so any computer on the network can access it easily, and compared to an RTL-SDR it has a wider range. There are some limitations, but for the price it can’t be beat which will cost under $50 in parts unless you happen to need two inputs like this analyzer .

Thanks to [Ezra] for the tip!

SQLite On The Web: Absurd-sql

Love it or hate it, the capabilities of your modern web browser continuously grow in strange and wild ways. The ability for web apps to work offline requires a persistent local storage solution and for many, IndexedDB is the only choice as it works across most browsers and provides a database-like interface. However, as [James Long] found, IndexedDB is painfully slow on chrome and limited in querying ability. He set out to bring a tool he was familiar with, SQLite, and bring it to the web browser as absurd-sql.

Why absurd? Partially because most browsers (not chrome) implement IndexedDB on top of SQLite. So for many browsers, it is just SQLite on top of IndexedDB on top of SQLite. Luckily for [James] there already was a project known as sql.js that uses emscripten to compile the C-based SQLite into WebAssembly. However, sql.js uses an in-memory storage backing and all data is lost when refreshing the page. [James] tweaked SQLite’s method of reading and writing blocks. Instead of being memory backed, he added a layer to read and write blocks from IndexedDB. This means that only sections of the database need to be read in, bringing in huge performance gains.

a graph showing absurd-sql beating IndexDB on every benchmarkThat brings us to the other reason why it’s absurd. On chrome (as well as Firefox), absurd-sql beats IndexedDB on almost every benchmark. A query like SELECT SUM(*) FROM kv led to stunning results.

So what’s the downside? Other than a somewhat large WebAssembly file that needs to get downloaded (409KB) and cached, there really isn’t. Of course, it’s not all roses when it comes to web development. Native SQLite runs 2-3 times faster than absurd-sql, which demonstrates how slow IndexedDB really is.

There are other storage standards on the horizon for web browsers, but locking becomes an issue. SQLite expects synchronous reads and writes because it’s just simple C. IndexedDB and other storage solutions are asynchronous as the event loop of Javascript lends itself well to that model. Absurd-sql gets around that by creating a SharedArrayBuffer that is shared with a worker process. The atomics API is used to communicate with the buffer. In particular, atomics.wait() allows the worker to block main thread execution until the read or write has finished. From the perspective of SQLite, the operations are synchronous. IndexedDB provides transactions so multiple connections can happen (for example multiple tabs open). Multiple readonly transactions can occur in parallel but only one readwrite transaction can be in flight.

Why not pull up your browser and start playing around with it? You’re already doomed to learn WebAssembly anyway.

C++ Compiler Targets The Web

It is a common problem these days. You have a piece of code in C or C++. Maybe it is older code. Or maybe you prefer prototyping your ideas using C. But, inevitably, someone now wants your code to run in a Web browser. The options for making this happen have expanded quite a bit lately and one possibility is Cheerp, an open-source compiler that handles up to C++ 17 and can output to WebAssembly, JavaScript, or asm.js.

The compiler is free to use for GPLv2 projects. If you aren’t open yourself, it looks like you have to cut a deal to use Cheerp with its maker, Learning Technologies.

Continue reading “C++ Compiler Targets The Web”

Flash Is Dead, But Its Culture Should Live On

Flash is all but gone already, but as we approach the official Adobe end-of-life date on December 31st, it’s picking up traction one last time as people reminisce about the days of Internet past. Back in July, [Jonas Richner] created an impressive website that catalogs not only almost 20 years of Flash games, but also testimonials for the software from dozens of developers who began their careers with it.

Flash started in 1996 with the intention of being a standard for animations and vector graphics on the early Web. With the release of Flash Player 5 in August of 2000, Macromedia (later acquired by Adobe) presented the first version of ActionScript, an object-oriented scripting language meant to bring interactivity to animated Flash movies. Since then, thousands of games made with the platform were released online through websites like Newgrounds and shared all over the world, with the most popular games easily reaching tens of millions of plays.

These games became popular in part thanks to how quickly they could be created with the Flash authoring tools, but also because it was so easy for players to run them. With a single plugin for your web browser of choice, the barrier of entry was extremely low. Most home computers from the mid-2000s were able to run Flash software without needing dedicated graphics hardware. This prompted a “creative chaos” as [Richner] puts it, spawning millions of games and animations which started genres and careers lasting to this day.

Unfortunately, browsers have been dropping support for the plugin due to vulnerabilities in the most recent iterations of its scripting engine and Google no longer indexes Flash files. It would seem this particularly creative era of the Internet is coming to an end. However, you can still relive old games and animations made with plugins such as Flash and Shockwave with [BlueMaxima]’s Flashpoint, and like [Richner], we also hope that the people building today’s platforms and technologies keep the lessons from Flash in mind.

The Open Source Smart Home

[Tijmen Schep] sends in his project, Candle Smart Home, which is an exhibit of 12 smart home devices which are designed around the concepts of ownership, open source, and privacy.

The central controller runs on a Raspberry Pi which is running Mozilla’s new smart home operating system. Each individual device is Arduino based, and when you click through on the site you get a well designed graphic explaining how to build each device.

It’s also fun to see how many people worked together on this project and added their own flair. Whether it’s a unique covering for the devices or a toggle switch that can toggle itself there’s quite a few personal touches.

As anyone who’s had the sneaking suspicion that Jeff Bezos was listening in to their conversations, we get the need for this. We also love how approachable it makes hacking your own hardware. What are your thoughts?

It’s The Web, Basically

If you are of a certain age, you probably learned to program in Basic. Even if you aren’t, a lot of microcontroller hobbyists got started on the Basic Stamp, and there are plenty of other places where to venerable language still hides out. But if you want to write cool browser applications, you have to write JavaScript, right? Google will now let you code your web pages in Basic. Known as WWWBasic, this is — of course — a Javascript hack that you can load remotely into a web page and then have your page use Basic for customization. You can even import the thing into Node.js and use Basic inside your JavaScript, although it is hard to think of why you’d want to.

According to the project’s documentation — which is pretty sparse so far, we’re afraid — the Basic program is compiled into JavaScript on page load. There are a few examples, so you can generally pick up what’s available to use. There are graphics, the ability to read a keyboard key, and a way to handle the mouse.

Continue reading “It’s The Web, Basically”