What Have I Been Doing Lately?
Some netizens have commented that it’s been a long time since I wrote technical posts about embedded systems. Has my technical skills rusted?
Hehe, I’ve indeed been quite busy lately, only finding time to write short blog posts. Today, I slept too much in the afternoon and couldn’t sleep at night, so I’ll write something technical. Some things are under NDA, so I can’t go into detail.
What have I been doing? With knockoffs running rampant across the nation, under the slogan “Learn from Dazhai in agriculture, learn from knockoffs in industry,” I’ve started my own knockoff journey. I’m working on a knockoff version of some software, copying a certain engine from a certain hu company. The goal is to make all the little things that run on that engine also run on Windows CE. If I can achieve 100% support, there’ll definitely be a market — at least it’ll attract attention.
I’ve been working on this for months. Between what I’ve written myself and what others have ported, I’ve accumulated tens of MB of code. A full compile takes 5 minutes… Although there are tons of bugs, I still feel accomplished. Some pretty cool little things are already running. In cliché terms, it fills a domestic gap and reaches “domestic first-class, international leading” level.
As for the coding itself, there have been plenty of technical issues. But thinking about it, not many are actually related to Windows CE. Almost the entire architecture, algorithms, and data structures are my own design. When there are problems, they’re usually my own fault. Where it interfaces with the OS, I only use one Windows CE window, no controls, and only a handful of API calls…
Let me talk about one window-related issue: how to create irregular-shaped windows under Windows CE. Creating irregular-shaped windows is the same as on desktop Windows — the SetWindowRegion API, basically the only way. On embedded devices, efficiency is key. If you use GetPixel + CombinRegion like on desktop Windows, creating one takes over 1000ms — too slow. Our project requires it to be under 100ms, otherwise it’s not viable. Below is an article where someone provides a better algorithm using pre-built bitmaps to create irregular-shaped windows. Their method directly manipulates the bitmap’s raw data, scans the bitmap twice, and creates numerous 1-pixel-high rectangles to form the region.
http://www.codeproject.com/KB/mobile/cergn.aspx
I tested it — faster than CombineRegion + GetPixel, about 400ms. Still not good enough. After racking my brains, I made some optimizations based on that algorithm, such as removing the monochrome bitmap creation step. The final result: 10-20ms!
How did I do it? Alas… seems I can’t disclose it yet (might as well have said nothing).