Skip to main content

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 first app_service(), within 28 seconds; call app_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​

HeaderWhat
app.happ_begin(), app_service(), app_poll(), app_progress(), app_halt()
lcd.h, text.h, fmt.h, fb.hthe 240x320 panel; text() and a console (con_print, con_line, con_update); a fast formatter; a RAM framebuffer sent in changed runs
controls.hcontrols_scan(), controls_event(): keys, buttons, encoders; leds(); key_semitone()
audio_hw.haudio_start_dma(), audio_block(), audio_input(), audio_done()
clock.htempo and transport from the internal clock, USB MIDI clock or SYNC IN
usbmidi.hmidi_read(), midi_send(): the unit as a USB MIDI device
usbhost.hthe unit as a USB host: MIDI devices and sticks (LIBS_app := usbhost fatfs)
fat.h, fatw.hthe internal disk's root: read, write
ffdisk.hFatFs on the internal disk (1:) and a stick (0:): folders, long names (LIBS_app := fatfs)
flashbg.hdisk writes a step at a time, so the audio never waits for the flash
wav.h, flac.h, lz4.hreading samples
launch.h, reload.h, resume.hthe launcher: the app's folder, three clicks, coming back to the app as it was
lab.hlab mode: hako press, hako screen; on in every app unless APP_NO_LAB
watchdog.h, rescue.hthe watchdog and the soft restart

Options an app sets​

Define before including app.h:

CON_Y0where the console's rows start (pixels from the top), under a title of your own
APP_USB_HOSTthe port is a USB host only (no MIDI device, disk or lab)
APP_USB_DUALa device with a computer on the port, a host without one
APP_RESUMEthree clicks, then OK on "back to", returns to the app as it was
APP_NO_LAB, APP_NO_LAB_VIDEOleave 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.