Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/ui/allen_ui.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / ui / allen_ui.h` 142 lines ยท 8298 bytes Raw Blame History 1 /* allen_ui.h -- Allen's home on the display. 2 * 3 * The screen opens on a dark night sky (ui/night.c): the stars come out, two 4 * black holes circle and merge, and from the light of the merger Allen 5 * gathers (ui/mind.c): a mind drawn as light, in the middle of the screen. 6 * The person is his guest. A quiet bar at the bottom takes what they type; 7 * Allen's answers appear under him, word by word. Small lights within his 8 * geometry respond to his voice; the surrounding stars stay quiet. Nothing else is on the screen unless it is in 9 * use: the bar fades away when the conversation rests (a key brings it 10 * back), Allen's words fade once they have been read, and the map of his 11 * notes (a small constellation) shows only when a note is saved or handed 12 * back. 13 * 14 * Drawing: every pixel is worked out from its position and the time, so a 15 * frame redraws only the parts of the screen that change, in strips that 16 * several processor cores can draw at once (ck_allen_ui_help). Integer 17 * math, no MMIO of its own (the caller hands in the framebuffer), host 18 * tested in ui/tests/allen_ui_test.c. Text uses Allen's own typeface 19 * (allen_font.h). */ 20 #ifndef AIENOS_ALLEN_UI_H 21 #define AIENOS_ALLEN_UI_H 22 #include 23 #include 24 25 /* RAM for a w x h screen (two full-screen layers, the frozen exit picture, and 26 * the glyph masks). */ 27 size_t ck_allen_ui_mem_bytes(uint32_t w, uint32_t h); 28 /* Takes over the screen and starts the night: fb = the framebuffer (pitch in 29 * pixels; format 0 RGBX, 1 BGRX), mem = ck_allen_ui_mem_bytes(w, h) bytes, 30 * hz = ticks per second of the clock `now` counts in, clock = that clock 31 * (read to time each frame; NULL: frames are not timed). 0, or -1 (bad 32 * size or format, short mem). */ 33 int ck_allen_ui_start(volatile uint32_t *fb, uint32_t w, uint32_t h, uint32_t pitch, uint32_t format, void *mem, 34 size_t mem_len, uint64_t hz, uint64_t now, uint64_t (*clock)(void)); 35 int ck_allen_ui_started(void); 36 /* Allen is ready to talk: the bar comes up once he has formed. footer: one 37 * short line shown under the empty bar. */ 38 void ck_allen_ui_wake(const char *footer, uint64_t now); 39 int ck_allen_ui_on(void); 40 /* 1 once Allen has gathered out of the night and can speak (his first words 41 * wait for it): what waits on his words, like the setup wizard, starts then. */ 42 int ck_allen_ui_formed(uint64_t now); 43 /* The line being typed changed (buf holds len characters). */ 44 void ck_allen_ui_input(const char *buf, unsigned len, uint64_t now); 45 /* A line was entered and Allen answered: the line rises from the bar into 46 * him, he thinks, then speaks the answer. line NULL: Allen speaks first (the 47 * welcome after a restart). */ 48 void ck_allen_ui_said(const char *line, const char *reply, uint64_t now); 49 /* A line was entered and the answer is coming from further off: the line 50 * rises into him and his geometry keeps moving until ck_allen_ui_said(NULL, reply) brings the words. */ 51 void ck_allen_ui_think(const char *line, uint64_t now); 52 /* More of the words already on screen: reply is the whole text so far, the 53 * earlier call's words with the new ones after them. What is showing stays, 54 * and the new letters follow. If it is not those words, or they are gone, it 55 * is a fresh reply. */ 56 void ck_allen_ui_said_more(const char *reply, uint64_t now); 57 /* The name Allen goes by, for the bar's "Speak to ..." hint ("Allen" until called). */ 58 void ck_allen_ui_named(const char *name); 59 /* Draws a frame when one is due (at most 60 a second) and returns 1, else 60 * 0. One caller at a time; ck_allen_ui_help may run on other cores. */ 61 int ck_allen_ui_tick(uint64_t now); 62 /* Another core's share of the frame in progress: draws strips while there 63 * are any; 1 if it drew one. */ 64 int ck_allen_ui_help(void); 65 /* The whole screen is drawn again by the next frame, at once (after 66 * something else wrote to it). */ 67 void ck_allen_ui_refresh(void); 68 /* Allen sleeps (asleep = 1): the stationary starfield fades as his geometry 69 * folds into a narrow cool line. The line closes to a point and black over 70 * 2.8 seconds. No spiral or full-screen resampling. ck_allen_ui_asleep() is 1 71 * only after all drawing cores finish and the final black frame is presented. 72 * A new sleep/wake request clears that acknowledgement immediately. 73 * asleep = 0 brings the sky back calmly in under a second. */ 74 void ck_allen_ui_sleep(int asleep, uint64_t now); 75 int ck_allen_ui_asleep(void); 76 /* Frames drawn, the slowest and the average (microseconds). */ 77 void ck_allen_ui_stats(uint32_t *frames, uint32_t *slowest_us, uint32_t *average_us); 78 /* The same for the frames of the dusk alone (the whole screen moves in each of them). */ 79 void ck_allen_ui_dusk_stats(uint32_t *frames, uint32_t *slowest_us, uint32_t *average_us); 80 81 /* The notes map, a small constellation to the right of Allen: n notes as 82 * stars, 0 the newest at the centre, the older ones spiralling out (at most 83 * CK_ALLEN_UI_MAP_NODES); ne links, star ea[i] to star eb[i] (notes that 84 * share a key word; at most CK_ALLEN_UI_MAP_LINKS); lit the star of the note 85 * just saved or handed back (-1: none), with label its text; total and links 86 * count every live note and link. Shown for a while when lit >= 0: a spark 87 * flies from Allen to the star. */ 88 #define CK_ALLEN_UI_MAP_NODES 48u 89 #define CK_ALLEN_UI_MAP_LINKS 160u 90 void ck_allen_ui_map(unsigned n, const uint8_t *ea, const uint8_t *eb, unsigned ne, int lit, const char *label, 91 unsigned total, unsigned links); 92 /* The model answered with a scene (svc/allen_scene.h, docs/ALLEN_CANVAS.md: len bytes, at most 93 * CK_SCENE_BYTES are read): Allen speaks its say line, as ck_allen_ui_said(NULL, say) would, and the things 94 * it asks for come round him as he starts to speak (ui/canvas.c); what was shown before goes. A reply in 95 * plain words, with no scene lines, is simply spoken. */ 96 void ck_allen_ui_scene(const char *scene, unsigned len, uint64_t now); 97 98 /* ---- sky view and real-time sky ---- */ 99 void ck_allen_ui_set_unix_time(int64_t unix_s, uint64_t tsc_at_read); 100 void ck_allen_ui_sky_mode(uint8_t mode, uint8_t region, int32_t lat_udeg, int32_t lon_udeg); 101 102 /* The setup wizard's panel (svc/setup_wizard.h): up to CK_ALLEN_UI_PANEL_LINES 103 * lines under Allen's words, each easing in a moment after the one before 104 * (a line already shown stays as it is when the panel is set again), and up 105 * to CK_ALLEN_UI_CHOICES choices in a row where the bar sits, the lit one 106 * bright, with hint under the row and aside small under that. A prompt 107 * (not NULL or "") puts the bar back for typing instead of the choices, with 108 * the prompt as its hint. While the panel is up Allen's words stay until he 109 * says something else. NULL: the panel fades and the window is as before. 110 * Strings are copied. */ 111 #define CK_ALLEN_UI_PANEL_LINES 8u 112 #define CK_ALLEN_UI_CHOICES 5u 113 typedef struct { 114 const char *line[CK_ALLEN_UI_PANEL_LINES]; 115 unsigned nline; 116 const char *choice[CK_ALLEN_UI_CHOICES]; 117 unsigned nchoice; 118 int lit; 119 const char *hint, *aside, *prompt; 120 } ck_allen_ui_panel_view; 121 void ck_allen_ui_panel(const ck_allen_ui_panel_view *p, uint64_t now); 122 123 /* Code from the Spark (svc/allen_code.h): text (bytes long, printable ASCII 124 * and newlines; at most CK_ALLEN_UI_CODE_MAX bytes are kept) shown to the left 125 * of Allen in his own type set at one width per letter, numbered by line, 126 * long lines going on in the next row, on a soft pool of shade (no window, 127 * no edge). lang names the language ("" for none). While it is up Allen's 128 * words keep to a narrower column. NULL text: the code fades away. */ 129 #define CK_ALLEN_UI_CODE_MAX 32768u 130 void ck_allen_ui_code(const char *text, unsigned bytes, const char *lang, uint64_t now); 131 /* Scrolls the code by rows (negative: up) or by pages (rows a screenful: 132 * CK_ALLEN_UI_CODE_PAGE). Returns the top row after it, or -1 with no code up. 133 * The first row shown and the rows in all are given back for the record. */ 134 #define CK_ALLEN_UI_CODE_PAGE 100000 135 int ck_allen_ui_code_scroll(int rows, unsigned *top, unsigned *total, unsigned *page); 136 /* 1 while code is shown. */ 137 int ck_allen_ui_code_on(void); 138 /* Allen is working on something far off: after his words he goes on 139 * thinking (the water turns) until this is 0 again. */ 140 void ck_allen_ui_working(int on); 141 142 #endif