The SDK
The SDK is a folder of C headers, sdk/. An app includes app.h (which brings in the screen,
the controls, the audio, USB and the disk) and is one or more .c files in examples/NN-name/
or a tree of its own. No operating system, no heap: the app owns the unit.
The contract
sdk/app.h's opening comment is the full text. In short:
app_begin()once, first. Then do anything slow (reading files) before the firstapp_service(), within 28 seconds; callapp_progress()after each piece of a long job.app_service()every few milliseconds from then on. If the main loop stops calling it for 4 seconds, the unit restarts softly into the launcher's menu: an app that hangs comes back by itself.- The audio block is 64 frames, 1.33 ms. Whatever the loop does between blocks must fit;
draw the screen a little at a time (
con_update(n),fb_flush(cycles)). - Three power clicks go back to the launcher, holding the button 1 s switches off; both are handled for you.
- Files go in the app's own folder (
launch_home()); never write the disk while the computer has it mounted (msc.mounted).
The headers
| Header | What |
|---|---|
app.h | app_begin(), app_service(), app_poll(), app_progress(), app_halt() |
lcd.h, text.h, fmt.h, fb.h | the 240x320 panel; text() and a console (con_print, con_line, con_update); a fast formatter; a RAM framebuffer sent in changed runs |
controls.h | controls_scan(), controls_event(): keys, buttons, encoders; leds(); key_semitone() |
audio_hw.h | audio_start_dma(), audio_block(), audio_input(), audio_done() |
clock.h | tempo and transport from the internal clock, USB MIDI clock or SYNC IN |
usbmidi.h | midi_read(), midi_send(): the unit as a USB MIDI device |
usbhost.h | the unit as a USB host: MIDI devices and sticks (LIBS_app := usbhost fatfs) |
fat.h, fatw.h | the internal disk's root: read, write |
ffdisk.h | FatFs on the internal disk (1:) and a stick (0:): folders, long names (LIBS_app := fatfs) |
flashbg.h | disk writes a step at a time, so the audio never waits for the flash |
wav.h, flac.h, lz4.h | reading samples |
launch.h, reload.h, resume.h | the launcher: the app's folder, three clicks, coming back to the app as it was |
lab.h | lab mode: hako press, hako screen; on in every app unless APP_NO_LAB |
watchdog.h, rescue.h | the watchdog and the soft restart |
Options an app sets
Define before including app.h:
CON_Y0 | where the console's rows start (pixels from the top), under a title of your own |
APP_USB_HOST | the port is a USB host only (no MIDI device, disk or lab) |
APP_USB_DUAL | a device with a computer on the port, a host without one |
APP_RESUME | three clicks, then OK on "back to", returns to the app as it was |
APP_NO_LAB, APP_NO_LAB_VIDEO | leave lab mode, or its screen stream, out |
Building
make builds every examples/*/main.c (and the launcher) into work/apps/NAME/APP.BIN. An app
that needs FatFs or the USB host stack names them in the Makefile:
LIBS_07-mine := fatfs usbhost
Apps link at 0xC1800000 and may use up to 39 MB, code and data together. hako check (run by
make check) confirms an app calls nothing outside itself.