Developing Applications for FRANK OS
Apps are standalone ARM ELF binaries compiled against frankos-app.h. Call OS through sys_table at 0x10FFF000 — binary compatible across firmware versions.
Minimal App Example
#include "frankos-app.h"
static hwnd_t my_hwnd;
static void on_paint(hwnd_t hwnd) {
wd_begin(hwnd);
wd_clear(COLOR_WHITE);
wd_text_ui(10, 10, "Hello, FRANK OS!", COLOR_BLACK, COLOR_WHITE);
wd_end();
}
static bool on_event(hwnd_t hwnd, const window_event_t *ev) {
if (ev->type == WM_CLOSE) {
wm_destroy_window(hwnd);
return true;
}
return false;
}
int main(void) {
my_hwnd = wm_create_window(100, 50, 300, 200,
"My App", WSTYLE_DEFAULT,
on_event, on_paint);
wm_show_window(my_hwnd);
wm_set_focus(my_hwnd);
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
return 0;
}
Window Management API
| Option | Description |
|---|---|
| wm_create_window(x,y,w,h,title,style,event_cb,paint_cb) | Create window, returns hwnd_t |
| wm_destroy_window(hwnd) | Destroy and free |
| wm_show_window(hwnd) | Make visible |
| wm_set_focus(hwnd) | Set input focus |
| wm_invalidate(hwnd) | Mark for repaint |
| wm_toggle_fullscreen(hwnd) | Toggle fullscreen |
Window Styles
| Option | Description |
|---|---|
| WSTYLE_DEFAULT | Closable, resizable, movable, bordered |
| WSTYLE_DIALOG | Closable, movable, bordered (not resizable) |
| WSTYLE_POPUP | No decorations |
Drawing Context
All drawing in wd_begin()/wd_end(). Coordinates relative to client area. Key functions:
| Option | Description |
|---|---|
| wd_pixel(x,y,color) | Set pixel |
| wd_hline(x,y,w,color) | Horizontal line |
| wd_vline(x,y,h,color) | Vertical line |
| wd_fill_rect(x,y,w,h,color) | Filled rect |
| wd_clear(color) | Clear client area |
| wd_text_ui(x,y,str,fg,bg) | Draw text (6x12 font) |
| wd_button(x,y,w,h,label,focused,pressed) | Win95 button |
Event Types
| Option | Description |
|---|---|
| WM_CREATE | Window created |
| WM_CLOSE | Close button clicked |
| WM_PAINT | Repaint needed |
| WM_KEYDOWN | Key pressed (scancode + modifiers) |
| WM_CHAR | Character input |
| WM_MOUSEMOVE | Mouse moved (x, y, buttons) |
| WM_LBUTTONDOWN | Left click |
| WM_RBUTTONDOWN | Right click |
| WM_TIMER | Timer fired |
| WM_COMMAND | Menu/dialog command (id) |
| WM_DROPFILES | File opened via association |
Menus
The menu_bar_t struct supports up to 5 menus with 8 items each. Alt+letter accelerators are available for keyboard navigation. Selections arrive as WM_COMMAND events with the menu item id.
Dialogs
- Message boxes (OK/Cancel/Yes/No) via
dialog_show() - File Open dialog via
file_dialog_open() - File Save dialog via
file_dialog_save() - Input dialog via
dialog_input_show() - Find/Replace dialogs (modeless)
Clipboard
clipboard_set_text(text, len)clipboard_get_text()clipboard_get_length()clipboard_clear()
Sound
snd_open(sample_rate) opens a mixer channel, snd_write(ch, samples, count) writes stereo 16-bit PCM, snd_close(ch) closes. 4 concurrent channels, resampled to 44100 Hz.
PSRAM Allocator
psram_is_available(), psram_alloc(size), psram_free(ptr). For large buffers that don't need SRAM speed.
Fullscreen 8bpp Mode
Apps request 320x240 8bpp exclusive mode via display_request_mode(). Set 256-color palette, render to display_draw_buffer_ptr, display_swap_buffers(). Poll keyboard directly. Restore with display_request_mode(640,480,4) + wm_force_full_repaint().
File Associations
Apps register via .inf file (format: AppName\next:txt,log,cfg). Users opening matching files launch the app with WM_DROPFILES.
Application Flags
| Option | Description |
|---|---|
| APPFLAG_BACKGROUND | App keeps running when not focused |
| APPFLAG_SINGLETON | Only one instance allowed |
Deploying
- Place source in
apps/source/myapp/ - Create
CMakeLists.txt - Add
myapp.icofor icon - Add to
tools/regen_inf.pyAPPS list - Run
build_apps.sh - Copy
sdcard/fos/to SD card