LeeHolmes / watchysim

Simulation framework for Watchy watch faces
MIT License
82 stars 8 forks source link

Possibility to run on Linux #11

Open DazDotOne opened 1 month ago

DazDotOne commented 1 month ago

Hi,

Firstly, as always, thanks for any and all work you've done on this. I'm a seasoned developer but very new to embedded systems and have recently acquired a watchy which I'm loving.

I'm looking at creating some faces (and possibly some drivers for different displays).

I'd love to be able to sim the watchy but I run Linux.

I was just wondering if you'd had any interactions with doing so and whether you had any pointers for where to start if not.

Thanks again

D.

LeeHolmes commented 1 month ago

Hey Daniel - right now, it adapts the Watchy SDK (which is pretty fully the Arduino SDK with some additions) and maps it all into a GDI application for Windows. But if you're eager, I think you could port it to run on Linux without a ton of effort. The WatchySim is essentially just a bunch of mocks.

For example, if your Watchy watch face calls "print()", there is a mock of that in Watchy.cpp (DisplaySim::print) that calls an mocked Arduino API (drawFontBitmap(...)). That does a bunch of stuff that finally calls into a few GDI-native functions like "setPixel". Then all of this is hosted inside a Windows GDI application.

If you wanted to port this to Linux, most of the work would just be cloning the very simple user interface, wiring the menu items (like setting the time) to code that already exists, and porting the handful of functions that do the actual drawing to a display area (like drawing a pixel, drawing a rectangle, drawing a line, measuring a string, and maybe a few others).

The vast majority of the code is mocking the Watchy SDK and Arduino SDKs into those primitive functions and wouldn't need to change.

DazDotOne commented 1 month ago

Amazing! Thanks for the response Lee.

I'll look at having a play then. Didn't want to go down a rabbit hole if it was going to be a no go.

I'll let you know if I make any progress.

LeeHolmes commented 1 month ago

Would love to hear how it goes.

BTW, one thing that is easy to miss - it MUST be a C or C++-based UI framework that you use. There are lots of very capable UI frameworks on Linux for Python etc (i.e.: I made an oscilloscope app: LeeHolmes/nanoscope: Front end to convert your Arduino Nano into a fully featured Oscilloscope (github.com) https://github.com/LeeHolmes/nanoscope), but the point of WatchySim is to be able to accelerate Watchy development (which is Arduino C and C++).

I looked into Qt at one point, but it was a bloated mess. There are of course many others: C++ UI Libraries • memdump (philippegroarke.com) https://philippegroarke.com/posts/2018/c++_ui_solutions/

DazDotOne commented 1 month ago

Thanks for the heads up.

Yeah I've been toying with the idea of making something in Qt for a while now but held off for similar reasons (and not having a decent endgame).

Guess this might be a good chance to get my hands dirty 😬