HydraOS is a simple operating system for the M5Cardputer. It consists of an App system, basic utilities, and a simple component system. The App system allows for the creation of applications that can be run on the M5Cardputer. The basic utilities provide a way to interact with the system and the component system allows for the creation of components that can be used in applications.
Some basic apps are bundled with the full version of HydraOS. These apps include:
- Calculator: A simple calculator app based on tinyexpr
- LED App: A simple app that allows you to control the onboard LED
- Dino Run: A simple game where you control a dinosaur to avoid obstacles
- Settings: A simple settings app that allows you to change the system settings
Apps are the main way to interact with the system. They can be created using the App Class and can be registered in the AppManager. Check the Calculator app for an example of how to create a basic app.
Components are reusable pieces of app functionality. They can be created using the Component Class can be used in ComponentApp instances. Check the Settings app for an example of how to use predefined components, and the LAppComponent for an example of how to create a custom component.
Utilities are basic functions that can be reused across the system. They are stored in the Utils class and can be called statically.
To install HydraOS, clone the repository and run the following command:
pio run -t upload
This will compile the code and upload it to the M5Cardputer.
The following features are planned for future versions of HydraOS:
- Standalone usable components
- More bundled apps
- Launching of third-party apps
- App store
If you would like to contribute to HydraOS, please feel free to fork the repository and submit a pull request. You can also submit issues if you find any bugs or have any feature requests. We are always looking for ways to improve the system and would love to hear your ideas. If you have developed an app for HydraOS, please let us know and we will consider bundling it with the system.
HydraOS is licensed under the MIT License. Please see the LICENSE file for more information.
Please note that this is just an overview of the system. For a more detailed guide, please refer to the code itself.
The Screen is 240x135 pixels. HydraOS StatusBar uses the top 25 pixels, the bottom, left, and right 10 pixels. You are advised to use the coordinates (10, 25) to (230, 125) for your app's ui elements.
import using #include "AppManager.h"
The AppManager is a class that manages the apps in the system. It can be used to register and run apps. The AppManager
is a singleton and can be accessed using the AppManager::getInstance()
method. The AppManager has the following methods:
void addApp(const std::string& name, App* app)
: Adds an app to the systemvoid openApp(const std::string& name)
: Opens an appvoid closeCurrentApp()
: Closes the current appvoid tickCurrentApp()
: Ticks the current appvoid draw()
: Draws the current appString getCurrentAppName()
: Gets the name of the current appstd::map<std::string, App *> listApps()
: Lists all the apps in the systemApp* getApp(const std::string& name)
: Gets an app by nameApp* currentApp
: The current app, not to be changed manually
import using #include "ScreenManager.h"
The ScreenManager contains two simple methods to prepare the screen for drawing:
void StatusBar::draw()
: Draws the status barM5Canvas canvas
: The canvas to draw on
import using #include "Utils.h"
The Utils class contains some basic utility functions that can be used across the system. The Utils class can be used entirely statically.
void Utils::waitForInput(String &input, int x = 27, int hdl_t = 10, bool passwordMode = false)
: Waits for inputvoid Utils::waitForKey()
: Waits for a key pressvoid Utils::popup(const String& text, int waitMode = 0, float textSize = 1)
: Shows a popupvoid Utils::initCanvas()
: Resets most canvas properties, please draw status bar after using this
A basic app can be created by extending the App class and implementing the following methods:
void onAppOpen()
: Called when the app is openedvoid onAppClose()
: Called when the app is closedvoid onAppTick()
: Called every tick, prepare the canvas herevoid draw()
: Called every frame to draw the app, stamp the canvas here if needed
Check the Calculator
app for an example of how to create a custom app.
A basic component can be created by extending the Component class and implementing the following methods:
void initComponent()
: Called when the component is openedvoid renderComponent()
: Called every tick, draw the component herevoid updateComponent()
: Called every tick, prepare canvas and update the component herevoid closeComponent()
: Called when the component is closedvoid forceRerender()
: Forces the component to rerender
Check the LAppComponent
for an example of how to create a custom component.
A basic app that uses components can be created by extending the ComponentApp class and implementing the following methods:
Component &initApp()
: Called when the app is opened, return the component to use
Check the Settings
app for an example of how to create a custom app that uses components.
In the main.cpp
file, near the bottom of the setup, you can register apps using the AppManager::getInstance()->addApp
method. For example:
AppManager::getInstance()->addApp("calculator", new Calculator());
That's it! You should now have a basic understanding of how HydraOS works. If you have any questions, feel free to ask me on Discord: wauhundeland. Happy coding!