DMCP interface 03.15_021
Loading...
Searching...
No Matches
dmcp.h
1#ifndef __SYS_DMCP_H__
2#define __SYS_DMCP_H__
3
4
5
6#include <stdint.h>
7
8typedef unsigned int uint;
9
10// Remove space before ! in next line to enable Intro page
11/* ! \mainpage Introduction
12 *
13 * \section intro_sec Introduction
14 *
15 * This is the introduction.
16 *
17 * \section install_sec Installation
18 *
19 * \subsection step1 Step 1: Opening the box
20 *
21 * etc...
22 */
23
24
25// --------------------------------------
27// -------------------------------------
28
29
30// -----------------------------------
32// ----------------------------------
47// -----------------------------------
49// ----------------------------------
64// -----------------------------------
66// ----------------------------------
81// --------------------------------------
83// -------------------------------------
92// --------------------------------------
94// -------------------------------------
112// ----------------------------------------
114// ---------------------------------------
115
131// -----------------------------------
133// ----------------------------------
134
155#include "ff_ifc.h"
156
157
164// HW interface
165
170
175
179void LCD_power_off(int clear);
180
196void LCD_write_line(uint8_t * buf);
197
212// --------------------------------------
214// -------------------------------------
220// Configuration
221#define LCD_INVERT_XAXIS
222#define LCD_INVERT_DATA
223// -------
224
225
226#define BLT_OR 0
227#define BLT_ANDN 1
228#define BLT_XOR 2
230#define BLT_NONE 0
231#define BLT_SET 1
234#ifdef LCD_INVERT_DATA
235# define LCD_EMPTY_VALUE 0xFF
236# define LCD_SET_VALUE 0
237#else
238# define LCD_EMPTY_VALUE 0
239# define LCD_SET_VALUE 0xFF
240#endif
241
242#define LCD_X 400
243#define LCD_Y 240
244#define LCD_LINE_SIZE 50
245#define LCD_LINE_BUF_SIZE (LCD_LINE_SIZE+4)
252// Drawing Prototypes
253
258
264
270
275
280
284void lcd_refresh_lines(int ln, int cnt);
285
286
305void bitblt24(uint32_t x, uint32_t dx, uint32_t y, uint32_t val, int blt_op, int fill);
306
307
308
316uint8_t * lcd_line_addr(int y);
317
318
327void lcd_fill_rect(uint32_t x, uint32_t y, uint32_t dx, uint32_t dy, int val);
328
329
339void lcd_fill_ptrn(int x, int y, int dx, int dy, int ptrn1, int ptrn2);
340
341
349void lcd_fillLine(int ln, uint8_t val);
350
351
360void lcd_fillLines(int ln, uint8_t val, int cnt);
361
362
371
381
382
388uint8_t reverse_byte(uint8_t x);
389
403#define SCR_DIR "/SCREENS"
404
408#define OFFIMG_DIR "/OFFIMG"
409
410
411
412// Screenshot
421int create_screenshot(int report_error);
422
423// Place image into LCD buffer
424
436void lcd_draw_img(const char* img, uint32_t xo, uint32_t yo, uint32_t x, uint32_t y);
437
438
450void lcd_draw_img_direct(const char* img, uint32_t xo, uint32_t yo, uint32_t x, uint32_t y);
451
452
465void lcd_draw_img_part(const char* img, uint32_t xo, uint32_t yo, uint32_t x, uint32_t y, uint32_t dx);
466
467
468
469// Off images
475void draw_power_off_image(int allow_errors);
476
483
484#define BG_COL_PAPER 0xf4f2dc
485#define BG_COL_LCD 0xdff5cc
503int update_bmp_file_header(FIL* fp, int width, int height, uint32_t bg_color);
504
505
506// ----------------------------------
507
508
512// ----------------------------------
513
527typedef struct {
528 const char * name;
529 uint8_t width;
530 uint8_t height;
531 uint8_t baseline;
532 uint8_t first_char;
533 uint8_t char_cnt;
534 uint8_t scale_x;
535 uint8_t scale_y;
536 uint8_t const * data;
537 uint16_t const * offs;
539
540
544#define NR2T(x) (-(x)-1) // x<0
545
549#define T2NR(x) (-(x)-1) // x>=0
550
551
557typedef struct {
558 line_font_t const * f;
559 int16_t x;
560 int16_t y;
561 int16_t ln_offs;
562 int16_t y_top_grd;
563 int8_t ya;
564 int8_t yb;
565 int8_t xspc;
566 int8_t xoffs;
568 uint8_t fixed;
569 uint8_t inv;
570 uint8_t bgfill;
571 uint8_t lnfill;
572 uint8_t newln;
582 const uint8_t *post_offs;
584
585
586
592
598
604
605
611void lcd_setLine(disp_stat_t * ds, int ln_nr);
612
613
620void lcd_setXY(disp_stat_t * ds, int x, int y);
621
628
629
636
637
644
645
654void lcd_writeText(disp_stat_t * ds, const char* text);
655
672void lcd_textToBox(disp_stat_t * ds, int x, int width, char *text, int from_right, int align_right);
673
674
675
682int lcd_textWidth(disp_stat_t * ds, const char* text);
683
690int lcd_charWidth(disp_stat_t * ds, int c);
691
692
693
704int lcd_textToWidth(disp_stat_t * ds, const char* text, int expected_width, int * plen);
705
706
707
718int lcd_textToWidthR(disp_stat_t * ds, const char* text, int expected_width, int * plen);
719
720
721
729void lcd_writeTextWidth(disp_stat_t * ds, const char* text);
730
731
746int lcd_textForWidth(disp_stat_t * ds, const char* text, int expected_width, int * plen);
747
748
749
756int lcd_nextFontNr(int nr);
757
764int lcd_prevFontNr(int nr);
765
771void lcd_switchFont(disp_stat_t * ds, int nr);
772
777int lcd_toggleFontT(int nr);
778
779
785void lcd_print(disp_stat_t * ds, const char* fmt, ...);
786
787
793#define lcd_printAt(ds, ln, ...) do { lcd_setLine(ds, ln); lcd_print(ds, __VA_ARGS__); } while(0)
794
799#define lcd_printR(ds, ...) do { ds->inv=1; lcd_print(ds, __VA_ARGS__); ds->inv=0; } while(0)
800
806#define lcd_printRAt(ds, ln, ...) do { lcd_setLine(ds, ln); ds->inv=1; lcd_print(ds, __VA_ARGS__); ds->inv=0; } while(0)
807
811#define lcd_puts lcd_writeText
812
819#define lcd_putsAt(ds, ln, str) do { lcd_setLine(ds, ln); lcd_puts(ds,str); } while(0)
820
826#define lcd_putsR(ds, str) do { ds->inv=1; lcd_puts(ds,str); ds->inv=0; } while(0)
827
828
835#define lcd_putsRAt(ds, ln, str) do { lcd_setLine(ds, ln); ds->inv=1; lcd_puts(ds,str); ds->inv=0; } while(0)
836
841// ----------------------------------
842
843
850#define DISP_CALC 0
851#define DISP_SYS_MENU 2
852#define DISP_BOOTLOADER 4
853#define DISP_UNIMPLEMENTED 5
854#define DISP_USB_WRITE 6
855#define DISP_MSC_CONNECT_USB 7
856#define DISP_ABOUT 8
857#define DISP_FAT_FORMAT 9
858#define DISP_FAULT 11
859#define DISP_QSPI_BAD_CRC 12
860#define DISP_QSPI_CHECK 13
861#define DISP_MARK_REGION 15
862#define DISP_DISK_TEST 16
863#define DISP_DSKTST_CONNECT_USB 17
864#define DISP_QSPI_CONNECT_USB 18
865#define DISP_OFF_IMAGE_ERR 19
866#define DISP_HELP 21
867#define DISP_BOOTLDR_CON_USB 22
868#define DISP_PROD_DIAG 23
869#define DISP_POWER_CHECK 24
870#define DISP_FLASH_CONNECT_USB 26
871// ----
872
873
879int lcd_for_calc(int what);
880
891#define LCD_MENU_LINES 32
893#define MENU_KEY_LABEL_LEN 12
894#define MENU_KEY_COUNT 6
898
904void lcd_draw_menu_key(int nr, const char *key, int highlight);
905
911void lcd_draw_menu_keys(const char *keys[]);
912
917// ----------------------------------
918
919
926// === Date/Time
927
928
929
934#define PRINT_DT_TM_SZ 20
935
936
940typedef struct {
941 uint16_t year;
942 uint8_t month;
943 uint8_t day;
944} dt_t;
945
949typedef struct {
950 uint8_t hour;
951 uint8_t min;
952 uint8_t sec;
953 uint8_t csec;
959 uint8_t dow;
960} tm_t;
961
966const char* get_wday_shortcut(int day); // 0 = Monday
971const char* get_month_shortcut(int month); // 1 = Jan
972
977
982
994void print_dmy_date(char * s, int const sz, dt_t *dt, const char * prefix, int shortmon, char sep_arg);
995
1006void print_clk24_time(char * t, int const sz, tm_t *tm, int disp_sec, int disp_dow);
1007
1011// ----------------------------------
1012
1022// System data block (SDB)
1023
1024
1025
1026
1027
1041typedef int get_flag_fn_t();
1042typedef void set_flag_fn_t(int val);
1054
1062
1063
1069
1075
1076
1082
1088
1097
1098
1099
1103typedef void void_fn_t();
1104
1108uint32_t calc_state;
1109
1116
1117
1118
1126
1127
1128
1129
1142
1147
1168
1175
1182
1195// ----------------------------------
1196
1197#define PLATFORM_VERSION "3.20"
1198
1199// System interface version
1200#define PLATFORM_IFC_CNR 3
1201#define PLATFORM_IFC_VER 15
1202
1203// STATIC_ASSERT ...
1204#define ASSERT_CONCAT_(a, b) a##b
1205#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
1206#define STATIC_ASSERT(e,m) ;enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(int)(!!(e)) }
1207//#define STATIC_ASSERT(expr, msg) typedef char ASSERT_CONCAT(static_assert_check_, __LINE__) [(expr) ? (+1) : (-1)]
1208
1209#define _STRINGIFY(x) #x
1210#define STR(x) _STRINGIFY(x)
1211
1212#define BIT(n) (1<<(n))
1213
1214
1215
1216
1242int qspi_user_write(uint8_t *data, int size, int offset, int erase);
1243
1248uint8_t * qspi_user_addr();
1249
1255
1256
1274void rtc_read(tm_t * tm, dt_t *dt);
1275
1281void rtc_write(tm_t * tm, dt_t *dt);
1282
1283
1288void rtc_update_time_sec(int delta_sec);
1289
1290
1298
1310void rtc_write_century(uint8_t cent);
1311
1317
1323
1331
1332
1342
1343
1344
1348#define RTCREGS_SS_PER_SEC 256
1349
1350
1358uint32_t get_rtc_ticks();
1359
1360
1361
1365typedef struct {
1366 uint32_t dt;
1367 uint32_t tm;
1368 uint16_t ss;
1370
1371
1375typedef struct {
1377 uint64_t dsec;
1378 uint32_t jday;
1379 uint32_t sec;
1380 uint32_t msec;
1382
1383
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1406void rtc_set_alarm(tm_t * tm, dt_t *dt);
1407
1408
1413
1414
1415
1428// ==== VBAT
1429
1435
1441
1447
1448// ==== USB functions
1454
1467// ==== Buzzer
1468
1469// Freq in mHz
1470
1475void start_buzzer_freq(uint32_t freq);
1476
1481
1487void set_buzzer(int pin1val, int pin2val);
1488
1489
1494
1499
1505
1525// ==== REGIONS
1526
1531uint32_t mark_region(uint32_t id);
1532
1537
1547// ==== RESET values
1548
1549#define NO_SPLASH_MAGIC 0xEACE7362
1550#define ALLOC_FAIL_MAGIC 0x363EACE7
1551#define CLEAN_RESET_MAGIC 0x3EACE736
1552#define RUN_DMCP_MAGIC 0x3CE7EA37
1559void set_reset_magic(uint32_t value);
1560
1561
1562
1563// === RESET STATE FILE
1564
1565#define RESET_STATE_FILE_SIZE 0x38
1572
1578
1588void set_reset_state_file(const char * str);
1589
1590
1595
1596
1623// Aux buf
1624#define AUX_BUF_SIZE (5*512)
1631
1637
1643
1644
1649
1658
1666// Program info structure
1667#define PROG_INFO_MAGIC 0xd377C0DE
1668
1669void program_main();
1670
1673typedef struct {
1674 uint32_t pgm_magic;
1675 uint32_t pgm_size;
1676 void * pgm_entry;
1677 uint32_t ifc_cnr;
1678 uint32_t ifc_ver;
1679 uint32_t qspi_size;
1680 uint32_t qspi_crc;
1681 char pgm_name[16];
1682 char pgm_ver[16];
1683} prog_info_t;
1684
1688// Keyboard
1689int read_key(int *k1, int *k2);
1690void suspended_bg_key_read();
1691void resume_bg_key_read();
1692
1693
1694// Timer
1695uint32_t get_tim1_timer();
1696
1697
1698// Base frequency 8MHz
1699#define TIMER_BASE_FREQ (8000000)
1700void start_timer2(uint32_t div32);
1701void start_timer3(uint16_t div16);
1702void stop_timer2();
1703void stop_timer3();
1704
1705
1706
1707
1708
1709
1710
1711
1712// ----------------------------------
1713
1761// Printer
1762#define PRINT_GRA_LN 1
1763#define PRINT_TXT_LN 0
1765#define MAX_82240_WIDTH 166
1766#define DFLT_82240_LINE_DUR 1800
1774void print_byte(uint8_t b);
1775
1776
1785void print_buffer(uint8_t * buf, int cnt);
1786
1787
1788
1794
1795
1796
1797// Printer delay in ms
1803
1808void printer_set_delay(uint val);
1809
1817void printer_advance_buf(int what);
1818
1826int printer_busy_for(int what);
1827
1832// ----------------------------------
1833
1849// --------------------------------
1850// Menu pages
1851// --------------------------------
1852
1853
1861typedef struct {
1862 const char * name;
1863 const uint8_t * items;
1873 const char* const * msg;
1874
1879} smenu_t;
1880
1881
1882// --------------------------------------
1884// -------------------------------------
1894extern const smenu_t MID_SYS_WARN;
1895extern const smenu_t MID_SYSTEM;
1896extern const smenu_t MID_FAT_FORMAT;
1897extern const smenu_t MID_DSKTST_ENTER;
1898extern const smenu_t MID_PROD_DIAG;
1899extern const smenu_t MID_PROD_DIAG2;
1900extern const smenu_t MID_DMCP;
1901extern const smenu_t MID_BASE_SETUP;
1909// --------------------------------------
1911// -------------------------------------
1922#define MI_SYSTEM 192
1923#define MI_BOOTLOADER 193
1924#define MI_QSPI_LOADER 194
1925#define MI_DIAG 195
1926#define MI_MSC 196
1927#define MI_ABOUT 197
1928#define MI_BASE_SETUP 198
1929#define MI_BEEP_MUTE 199
1930#define MI_SYSTEM_ENTER 200
1931#define MI_RELOAD_RESET 201
1932#define MI_SET_TIME 202
1933#define MI_SET_DATE 203
1934#define MI_FF_ENTER 204
1935#define MI_FAT_FORMAT 205
1936#define MI_DISK_TEST 206
1937#define MI_DSKTST_ENTER 207
1938#define MI_DISK_INFO 208
1939#define MI_LOAD_QSPI 209
1940#define MI_SLOW_AUTOREP 210
1942#define MI_EXIT 211
1944#define MI_KBD_TEST 212
1945#define MI_LCD_TEST 213
1946#define MI_IR_TEST 214
1947#define MI_BEEP_TEST 215
1948#define MI_DMCP_MENU 216
1950#define MI_SELF_TEST 217
1952#define MI_RAMFLASH 218
1954#define MI_PGM_INFO 219
1955#define MI_PGM_RUN 220
1956#define MI_PGM_LOAD 221
1958#define MI_RUN_DMCP 222
1960#define MI_OFF_MODE 223
1961// --------------------------------
1962
1963
1970typedef int run_menu_item_fn_t(uint8_t line_id);
1971
1975typedef const char * menu_line_str_fn_t(uint8_t line_id, char * s, const int slen);
1976
1977
1978// --------------------------------------
1980// -------------------------------------
1985// --------------------------------
1986#define MENU_MAX_LEVEL 8
1988#define MENU_FONT t24
1989#define MENU_LCD_LINES 8
1991#define MENU_RESET 0
1992#define MENU_ADD 1
1994#define MRET_UNIMPL -1
1995#define MRET_EXIT -2
2001#define MRET_LEAVELIMIT 512
2002// --------------------------------
2007// === Base menu functions ===
2016int handle_menu(const smenu_t * menu_id, int action, int cur_line);
2017
2018
2026int run_menu_item_sys(uint8_t line_id);
2027
2028
2038int run_menu_item(uint8_t line_id);
2039
2051const char * menu_line_str(uint8_t line_id, char * ln, const int ln_len);
2052
2053
2054// --------------------------------------
2056// -------------------------------------
2064// === Menu formatting support
2070const char * rb_str(int val);
2071
2072
2078const char * sel_str(int val);
2079
2088char * opt_str(char * s, char const *txt, int val);
2089
2097char * date_str(char * s, const char * txt);
2098
2106char * time_str(char * s, const char * txt);
2107
2127
2132
2133// === Base dialogs
2137void disp_disk_info(const char * hdr);
2138
2148
2149// === File selection ===
2150
2152#define MAX_PGM_FN_LEN 24
2163typedef int (*file_sel_fn_t)(const char * fpath, const char * fname, void * data);
2164
2177int file_selection_screen(const char * title, const char * base_dir, const char * ext, file_sel_fn_t sel_fn,
2178 int disp_new, int overwrite_check, void * data);
2179
2180
2198// ---------------------------------------------------
2199// Item selection screen
2200// ---------------------------------------------------
2201
2209#define ISEL_FILL_ITEMS -100
2210
2218#define ISEL_KEY_PRESSED -101
2219
2227#define ISEL_EXIT -102
2228
2236#define ISEL_POST_DRAW -2
2237
2245#define ISEL_PRE_DRAW -1
2246
2247
2251typedef uint16_t list_item_t;
2252
2253struct item_sel_state;
2254
2258typedef void isel_disp_line_fn_t(int lnr, list_item_t *fis, int cur_fnr, struct item_sel_state *st);
2259
2263typedef void fis_name_fn_t(struct item_sel_state *st, list_item_t fis, char * nmbuf, int len);
2264
2265
2269typedef struct item_sel_state {
2270 int8_t fnr;
2271 int8_t top_nr;
2272 int8_t lncnt;
2273 int8_t roll_lines;
2274 int8_t key;
2279 int fcnt;
2281 // -- Set by user --
2282 const char * title;
2283 char * title2;
2285 char * lnbuf;
2288 void * data;
2289 void * items;
2292
2293
2301
2302
2310
2311
2318
2319
2330void item_sel_header(item_sel_state_t *st, int update);
2331
2332
2341// ---------------------------------------------------
2342
2361void msg_box(disp_stat_t * ds, const char * txt, int inv);
2362
2365// ----------------------------------
2366
2367
2368#define MAX_LCD_LINE_LEN 40
2369
2370
2371// -----------------------
2372// Bit masks operations
2373// -----------------------
2374#define VAL(x,val) ((x) & (val))
2375#define CLR(x,val) val &= ~(x)
2376#define SET(x,val) val |= (x)
2377#define MSK(x,val) (~(x) & (val))
2378#define SETMSK(x,m,val) val = (MSK(m,val)|(x))
2379//#define SETBY(c,x,val) (c) ? SET(x,val) : CLR(x,val)
2380#define SETBY(c,x,val) if (c) { SET(x,val); } else { CLR(x,val); }
2381
2382
2383
2384
2385
2386
2387#define ST(x) VAL(x,calc_state)
2388#define VAL_ST(x) VAL(x,calc_state)
2389#define CLR_ST(x) CLR(x,calc_state)
2390#define SET_ST(x) SET(x,calc_state)
2391#define SETMSK_ST(x,m) SETMSK(x,m,calc_state)
2392#define SETBY_ST(c,x) SETBY(c,x,calc_state)
2393
2394
2395
2396#define STAT_CLEAN_RESET BIT(0)
2397#define STAT_RUNNING BIT(1)
2398#define STAT_SUSPENDED BIT(2)
2399#define STAT_KEYUP_WAIT BIT(3)
2400#define STAT_OFF BIT(4)
2401#define STAT_SOFT_OFF BIT(5)
2402#define STAT_MENU BIT(6)
2403#define STAT_BEEP_MUTE BIT(7)
2404#define STAT_SLOW_AUTOREP BIT(8)
2405#define STAT_PGM_END BIT(9)
2406#define STAT_CLK_WKUP_ENABLE BIT(10)
2407#define STAT_CLK_WKUP_SECONDS BIT(11) // 0 - wakeup runner each minute, 1 - each second
2408#define STAT_CLK_WKUP_FLAG BIT(12)
2409#define STAT_DMY BIT(13)
2410#define STAT_CLK24 BIT(14)
2411#define STAT_POWER_CHANGE BIT(15)
2412
2413#define STAT_HW_BEEP BIT(28)
2414#define STAT_HW_USB BIT(29)
2415#define STAT_HW_IR BIT(30)
2416
2417#define STAT_HW (STAT_HW_BEEP | STAT_HW_USB | STAT_HW_IR)
2418
2419
2420
2421
2422
2423
2424// --------------------------------------
2425
2426// -------------------------------------
2435#define MAX_KEY_NR 37
2436#define MAX_FNKEY_NR 43
2439// -------------
2440// Key codes
2441// -------------
2442
2443#define KEY_SIGMA 1
2444#define KEY_INV 2
2445#define KEY_SQRT 3
2446#define KEY_LOG 4
2447#define KEY_LN 5
2448#define KEY_XEQ 6
2449#define KEY_STO 7
2450#define KEY_RCL 8
2451#define KEY_RDN 9
2452#define KEY_SIN 10
2453#define KEY_COS 11
2454#define KEY_TAN 12
2455#define KEY_ENTER 13
2456#define KEY_SWAP 14
2457#define KEY_CHS 15
2458#define KEY_E 16
2459#define KEY_BSP 17
2460#define KEY_UP 18
2461#define KEY_7 19
2462#define KEY_8 20
2463#define KEY_9 21
2464#define KEY_DIV 22
2465#define KEY_DOWN 23
2466#define KEY_4 24
2467#define KEY_5 25
2468#define KEY_6 26
2469#define KEY_MUL 27
2470#define KEY_SHIFT 28
2471#define KEY_1 29
2472#define KEY_2 30
2473#define KEY_3 31
2474#define KEY_SUB 32
2475#define KEY_EXIT 33
2476#define KEY_0 34
2477#define KEY_DOT 35
2478#define KEY_RUN 36
2479#define KEY_ADD 37
2481#define KEY_F1 38
2482#define KEY_F2 39
2483#define KEY_F3 40
2484#define KEY_F4 41
2485#define KEY_F5 42
2486#define KEY_F6 43
2488#define KEY_SCREENSHOT 44
2489#define KEY_SH_UP 45
2490#define KEY_SH_DOWN 46
2492#define KEY_DOUBLE_RELEASE 99
2494#define KEY_PAGEUP KEY_DIV
2495#define KEY_PAGEDOWN KEY_MUL
2506// ---------------------------
2507// Key buffer functions
2508// ---------------------------
2509
2515
2521int key_push(int k1);
2522
2528
2534
2535
2540int key_pop_last();
2547
2548
2549// Key functions
2555int key_to_nr(int key);
2556
2557// Key
2563
2573
2579
2580
2581
2606int runner_get_key(int *repeat);
2607
2619int runner_get_key_delay(int *repeat, uint timeout, uint rep0, uint rep1, uint rep1tout);
2620
2621
2622// ---------------------------
2623// Runner get key
2624// ---------------------------
2625
2640int runner_key_tout_value(const int first);
2641
2642
2643
2653// Autorepeat
2658
2663
2675void runner_key_tout_init(const int slow);
2676
2677
2678
2689// Auto off
2690
2691
2692#define AUTO_OFF_SECONDS 600
2693#define AUTO_OFF_MENU 300
2700
2706
2712
2718
2736// Check and create dir
2737// returns 0 on success
2738int check_create_dir(const char * dir);
2739
2745int file_exists(const char * fn);
2746
2752int file_size(const char * fn);
2753
2754
2770void make_date_filename(char * fn, const char * dir, const char * ext);
2771
2772
2792
2800
2806
2807
2823
2828void set_fat_label(const char * label);
2829
2846void sys_timer_disable(int timer_ix);
2847
2853void sys_timer_start(int timer_ix, uint32_t ms_value);
2854
2860int sys_timer_active(int timer_ix);
2861
2866int sys_timer_timeout(int timer_ix);
2867
2868
2869
2873void sys_delay(uint32_t ms_delay);
2874
2875// Current systick count
2876
2886
2892
2906// Critical sections
2907
2912
2917
2918// Sleep
2919
2924
2925// Free memory
2926
2932
2933// ==== HW ID
2934
2941uint8_t get_hw_id();
2942
2957// ---------------------------
2958// Flashing
2959// ---------------------------
2960
2961
2966
2974int sys_flash_erase_block(void* start_addr, uint32_t size);
2975
2984int sys_flash_write_block(void* dst_addr, uint8_t * src_buf, uint32_t size);
2985
2988// ---------------------------
2989
2990
3009// ----------------------------------
3010
3011
3012// Help
3013#define HELP_INDEX "/HELP/index.htm"
3021
3022
3028void run_help_file(const char * help_file);
3029
3030
3036typedef void user_style_fn_t(char *class_attr, disp_stat_t *ds);
3037
3038
3053void run_help_file_style(const char * help_file, user_style_fn_t *user_style_fn);
3054
3055
3058// ----------------------------------
3059
3060
3061
3062#endif
3063
void stop_buzzer()
Stop tone.
int get_beep_volume()
Returns current tone volume.
void beep_volume_down()
Decrease tone volume.
void set_buzzer(int pin1val, int pin2val)
Set buzzer IO pins to given values.
void beep_volume_up()
Increase tone volume.
void start_buzzer_freq(uint32_t freq)
Start tone.
int sys_disk_write_enable(int val)
(En/Dis)able disk write mode
void set_fat_label(const char *label)
Sets disk label.
int sys_disk_ok()
Returns current disk status.
int sys_is_disk_write_enable()
Returns current disk write state.
void sys_disk_check_valid()
Update disk state based on low level disk state.
int check_create_dir(const char *dir)
Creates directory if doesn't exist.
int file_exists(const char *fn)
Check whether file exists.
int file_size(const char *fn)
Returns file size.
void make_date_filename(char *fn, const char *dir, const char *ext)
Creates filename using current date/time.
void run_help_file(const char *help_file)
Starts help screen.
void run_help_file_style(const char *help_file, user_style_fn_t *user_style_fn)
Starts help screen.
void user_style_fn_t(char *class_attr, disp_stat_t *ds)
Prototype for user style callback function.
Definition dmcp.h:3036
void run_help()
Starts default help screen.
void msg_box(disp_stat_t *ds, const char *txt, int inv)
Display message box.
int item_sel_engine(item_sel_state_t *st, int upd)
Main item selection engine loop.
void item_sel_header(item_sel_state_t *st, int update)
Display header for item selection dialog.
void isel_disp_line_fn_t(int lnr, list_item_t *fis, int cur_fnr, struct item_sel_state *st)
Display line callback prototype.
Definition dmcp.h:2258
void item_sel_reinit(item_sel_state_t *st)
Cleanup before items reload.
uint16_t list_item_t
Type for item list item_sel_state::fis.
Definition dmcp.h:2251
struct item_sel_state item_sel_state_t
Item selection state.
void item_sel_init(item_sel_state_t *st)
Initializes item sel structure.
void fis_name_fn_t(struct item_sel_state *st, list_item_t fis, char *nmbuf, int len)
Callback function for getting list item name.
Definition dmcp.h:2263
int(* file_sel_fn_t)(const char *fpath, const char *fname, void *data)
"File selected" callback for file_selection_screen()
Definition dmcp.h:2163
int power_check_screen()
Check power voltage and requests USB connection if power is low.
void run_set_time()
Activates "Set Time" screen.
void disp_disk_info(const char *hdr)
Activates "Disk Info" screen.
int file_selection_screen(const char *title, const char *base_dir, const char *ext, file_sel_fn_t sel_fn, int disp_new, int overwrite_check, void *data)
Displays file selection dialog.
void run_set_date()
Activates "Set Date" screen.
int sys_last_key()
Returns currently pressed key code.
int key_tail()
Check for key in key buffer.
int key_to_nr(int key)
Returns corresponding number for key code key.
void wait_for_key_press()
Wait for key press.
void key_pop_all()
Remove all keys from key buffer.
int key_pop()
Remove and return next key from key buffer.
int key_push(int k1)
Push key at the end of key buffer.
void wait_for_key_release(int tout)
Wait for key release or timeout.
int key_empty()
Check whether key buffer is empty.
int runner_key_tout_value(const int first)
Returns key repeat timeout value.
int runner_get_key(int *repeat)
Wait for key event or timeout.
int runner_get_key_delay(int *repeat, uint timeout, uint rep0, uint rep1, uint rep1tout)
Wait for key event or timeout with more autorepeat and timeout control.
int toggle_slow_autorepeat()
Toggle slow_autorepeat flag in system.
int is_slow_autorepeat()
Query slow autorepeat flag value.
void runner_key_tout_init(const int slow)
Initialize slow autorepeat flag.
void lcd_forced_refresh()
Write immediately whole LCD buffer to LCD regardless of dirty flags.
void lcd_refresh_dma()
Start non-blocking LCD refresh, LCD refresh continues in background (only dirty lines are updated)
uint8_t reverse_byte(uint8_t x)
Swaps bits in byte.
void lcd_refresh()
Start lcd refresh - could be blocking or non-blocking based on current system default (only dirty lin...
void lcd_set_buf_cleared(int val)
Sets 'LCD buffer cleared' flag.
int lcd_get_buf_cleared()
Reads 'LCD buffer cleared' flag.
void lcd_fillLines(int ln, uint8_t val, int cnt)
Fill LCD lines with value.
void lcd_fill_rect(uint32_t x, uint32_t y, uint32_t dx, uint32_t dy, int val)
Fills rectangular area of LCD.
void lcd_refresh_lines(int ln, int cnt)
Write immediately lines [ln .. ln+cnt-1] to LCD.
void lcd_refresh_wait()
Issue LCD refresh and wait until done (only dirty lines are updated)
void lcd_clear_buf()
Clear LCD buffer.
void lcd_fillLine(int ln, uint8_t val)
Fill LCD line with value.
uint8_t * lcd_line_addr(int y)
Returns pointer to line data (doesn't depend on LCD_INVERT_XAXIS)
void lcd_fill_ptrn(int x, int y, int dx, int dy, int ptrn1, int ptrn2)
Fills rectangular area with prescribed pattern.
void bitblt24(uint32_t x, uint32_t dx, uint32_t y, uint32_t val, int blt_op, int fill)
Blits dx bits from val at position x, y.
void draw_power_off_image(int allow_errors)
Draw subsequent image from OFFIMG_DIR directory.
int update_bmp_file_header(FIL *fp, int width, int height, uint32_t bg_color)
Write or update .bmp file header.
void lcd_draw_img_direct(const char *img, uint32_t xo, uint32_t yo, uint32_t x, uint32_t y)
Put image directly on LCD.
void lcd_draw_img(const char *img, uint32_t xo, uint32_t yo, uint32_t x, uint32_t y)
Put image into LCD buffer.
void reset_off_image_cycle()
Resets off image loop to first image.
void lcd_draw_img_part(const char *img, uint32_t xo, uint32_t yo, uint32_t x, uint32_t y, uint32_t dx)
Put part of image into LCD buffer.
int create_screenshot(int report_error)
Create screenshot.
int lcd_for_calc(int what)
Displays predefined static screen by id.
void lcd_draw_menu_key(int nr, const char *key, int highlight)
void lcd_draw_menu_keys(const char *keys[])
void lcd_draw_menu_bg()
int lcd_nextFontNr(int nr)
Get next (bigger) font number.
int lcd_fontWidth(disp_stat_t *ds)
Returns width of font.
int lcd_charWidth(disp_stat_t *ds, int c)
Returns width of character.
int lcd_toggleFontT(int nr)
Toggle font number between normal and TT font.
void lcd_print(disp_stat_t *ds, const char *fmt,...)
Print formatted string.
void lcd_setXY(disp_stat_t *ds, int x, int y)
Jump to pixel position (x,y)
int lcd_baseHeight(disp_stat_t *ds)
Returns baseline position.
void lcd_writeClr(disp_stat_t *ds)
Jump to first line.
void lcd_writeNl(disp_stat_t *ds)
Jump to next line.
void lcd_textToBox(disp_stat_t *ds, int x, int width, char *text, int from_right, int align_right)
Display text in confined area.
int lcd_textToWidth(disp_stat_t *ds, const char *text, int expected_width, int *plen)
Determines which part of text fits in expected_width.
void lcd_prevLn(disp_stat_t *ds)
Jump to previous line.
void lcd_switchFont(disp_stat_t *ds, int nr)
Set current font to given font number.
void lcd_writeTextWidth(disp_stat_t *ds, const char *text)
Updates display state as if lcd_writeText() was be called.
void lcd_setLine(disp_stat_t *ds, int ln_nr)
Jump to given line.
int lcd_lineHeight(disp_stat_t *ds)
Returns line height.
void lcd_writeText(disp_stat_t *ds, const char *text)
Display text.
int lcd_textForWidth(disp_stat_t *ds, const char *text, int expected_width, int *plen)
Calculate text width without breaking words
int lcd_textWidth(disp_stat_t *ds, const char *text)
Calculates width of text.
int lcd_textToWidthR(disp_stat_t *ds, const char *text, int expected_width, int *plen)
Determines which part of text from the end of the string fits in expected_width.
int lcd_prevFontNr(int nr)
Get previous (smaller) font number.
void LCD_power_off(int clear)
Powers off the LCD hardware.
void LCD_power_on()
Powers on the LCD hardware.
void LCD_write_line(uint8_t *buf)
Sends line data to LCD.
void LCD_clear()
Sends clear command to LCD.
const char * sel_str(int val)
Returns 'cross' selection string.
char * opt_str(char *s, char const *txt, int val)
Format selection string.
const char * rb_str(int val)
Returns 'dot' selection string.
char * date_str(char *s, const char *txt)
Formats text followed by date.
char * time_str(char *s, const char *txt)
Formats text followed by time.
const smenu_t MID_SYSTEM
System menu.
const smenu_t MID_DMCP
Top level system menu.
const smenu_t MID_SYS_WARN
System menu entry warning.
const smenu_t MID_PROD_DIAG2
Production diagnostic screen - selftest version in main menu.
const smenu_t MID_DSKTST_ENTER
Disk test menu.
const smenu_t MID_FAT_FORMAT
FAT format menu.
const smenu_t MID_BASE_SETUP
System setup menu.
const smenu_t MID_PROD_DIAG
Production diagnostic screen.
int run_menu_item_sys(uint8_t line_id)
Invoke particular sys menu function.
int run_menu_item_fn_t(uint8_t line_id)
Prototype for run_menu_item function.
Definition dmcp.h:1970
const char * menu_line_str(uint8_t line_id, char *ln, const int ln_len)
(Defined by user) Should return string representation of given menu item
const char * menu_line_str_fn_t(uint8_t line_id, char *s, const int slen)
Prototype for menu_line_str function.
Definition dmcp.h:1975
int handle_menu(const smenu_t *menu_id, int action, int cur_line)
Starts menu screen.
int run_menu_item(uint8_t line_id)
(Defined by user) Invoke functionality for selected menu item
int print_is_ready()
Check whether IR hw is ready for send.
void printer_set_delay(uint val)
Sets printer line delay.
void print_byte(uint8_t b)
Send byte to printer.
void print_buffer(uint8_t *buf, int cnt)
Send bytes to printer.
void printer_advance_buf(int what)
Add line type to printer buffer emulation.
int printer_busy_for(int what)
Wait until printer buffer is free for given line type.
uint printer_get_delay()
Returns current printer line delay.
uint32_t read_power_voltage()
Reads power voltage.
int usb_powered()
Returns USB powered status.
int get_lowbat_state()
Returns low-battery flag.
int get_vbat()
Returns battery voltage.
int qspi_user_size()
Returns size (in bytes) of the user QSPI data area.
uint8_t * qspi_user_addr()
Returns pointer to the user QSPI data area.
int qspi_user_write(uint8_t *data, int size, int offset, int erase)
Writes data to the user QSPI data area.
uint8_t rtc_read_sec()
Reads current second.
void rtc_write(tm_t *tm, dt_t *dt)
Set date and time.
uint8_t rtc_read_century()
Read current century.
void rtc_check_unset()
Check whether RTC was updated from cold start state. Displays set time and set date dialogs if it was...
void rtc_wakeup_delay()
Workaround for CPU bug.
uint8_t rtc_read_min()
Reads current minute.
uint32_t get_rtc_ticks()
Get time ticks (linear time)
void rtc_cancel_alarm()
Cancels any pending RTC alarm.
void rtc_write_century(uint8_t cent)
Write century.
void rtc_set_alarm(tm_t *tm, dt_t *dt)
Plants RTC alarm at given time.
rtc_ticks_stat_t * rtc_update_ticks()
Returns pointer to currently updated RTC ticks structure.
void rtc_update_time_sec(int delta_sec)
Shift time by given amount of seconds.
void rtc_read(tm_t *tm, dt_t *dt)
Read current data and time.
void set_flag_fn_t(int val)
Set flag function prototype.
Definition dmcp.h:1042
set_flag_fn_t * set_flag_clk24
Setter callback for CLK24 flag.
Definition dmcp.h:1074
set_flag_fn_t * set_beep_mute
Setter callback for Beep Mute flag.
Definition dmcp.h:1087
get_flag_fn_t * get_flag_dmy
Getter callback for DMY flag.
Definition dmcp.h:1053
get_flag_fn_t * is_flag_clk24
Getter callback for CLK24 flag.
Definition dmcp.h:1068
int get_flag_fn_t()
Get flag function prototype.
Definition dmcp.h:1041
get_flag_fn_t * is_beep_mute
Getter callback for Beep Mute flag.
Definition dmcp.h:1081
set_flag_fn_t * set_flag_dmy
Setter callback for DMY flag.
Definition dmcp.h:1061
disp_stat_t * t24
Font state for normal system font.
Definition dmcp.h:1174
disp_stat_t * fReg
Font state for user font.
Definition dmcp.h:1181
disp_stat_t * t20
Font state for small system font.
Definition dmcp.h:1167
run_menu_item_fn_t * run_menu_item_app
System callback variable to run menu item (see Menu system for details)
Definition dmcp.h:1141
menu_line_str_fn_t * menu_line_str_app
System callback variable to get menu item string (see Menu system for details)
Definition dmcp.h:1146
int is_menu_auto_off()
Check menu auto-off state.
int is_auto_off()
Check auto-off state.
int sys_auto_off_cnt()
Returns remaining auto-off seconds.
void reset_auto_off()
Resets auto-off timer.
char * aux_buf_ptr()
Get pointer to aux memory buffer.
int sys_write_buf_used()
Get 'write-buffer-used' flag.
void sys_clear_write_buf_used()
Clear 'write-buffer-used' flag.
int write_buf_size()
Get write buffer size.
void * write_buf_ptr()
Get pointer to write buffer.
void sys_flashing_finish()
Disable flashing.
int sys_flash_write_block(void *dst_addr, uint8_t *src_buf, uint32_t size)
Write data to flash.
void sys_flashing_init()
Enable flashing.
int sys_flash_erase_block(void *start_addr, uint32_t size)
Flash block erase.
void sys_critical_end()
Leave critical section.
int sys_free_mem()
Query free memory for malloc.
void sys_sleep()
Suspend program until next event.
uint8_t get_hw_id()
Query hardware id.
void sys_critical_start()
Enter critical section.
uint32_t mark_region(uint32_t id)
Mark executed code.
void no_region()
Clear current region.
char * get_reset_state_file()
Get pointer to reset state file.
int is_reset_state_file()
Check for reset state file.
void set_reset_magic(uint32_t value)
Set reset constant.
void set_reset_state_file(const char *str)
Set reset state file to given string.
void sys_reset()
Invoke CPU reset.
int sys_timer_active(int timer_ix)
Check timer running status.
void sys_timer_disable(int timer_ix)
Disables system timer.
int sys_timer_timeout(int timer_ix)
Check for timer timeout.
void sys_timer_start(int timer_ix, uint32_t ms_value)
Starts system timer (non-periodic pooling timer)
uint32_t sys_current_ms()
Get current millisecond.
void sys_delay(uint32_t ms_delay)
Delays program by specified number of milliseconds.
uint32_t sys_tick_count()
Get current tick count.
const char * key_to_alpha_table
Key to alpha translation table.
Definition dmcp.h:1125
uint32_t calc_state
Main calculator state flags.
Definition dmcp.h:1108
void void_fn_t()
General prototype for void function.
Definition dmcp.h:1103
FIL * ppgm_fp
Pointer to file handle provided by system.
Definition dmcp.h:1115
void_fn_t * after_fat_format
This callback function is called by system after FAT disk format (if set)
Definition dmcp.h:1096
void print_clk24_time(char *t, int const sz, tm_t *tm, int disp_sec, int disp_dow)
Formats time according to supplied and system flags.
const char * get_month_shortcut(int month)
Three character shortcut of month name.
const char * get_wday_shortcut(int day)
Three character shortcut of day name.
void print_dmy_date(char *s, int const sz, dt_t *dt, const char *prefix, int shortmon, char sep_arg)
Formats date according to supplied and system flags.
int julian_day(dt_t *d)
Calculates Julian day for given date.
void julian_to_date(int julian_day, dt_t *d)
Calculates date for given Julian day.
FatFs file structure used in file operations.
Definition ff_ifc.h:66
Font display state.
Definition dmcp.h:557
int8_t xspc
Space between chars.
Definition dmcp.h:565
int8_t xoffs
X offset for first char on line.
Definition dmcp.h:566
line_font_t const * f
Current font.
Definition dmcp.h:558
int16_t y_top_grd
Don't overwrite anything above this LCD y-line.
Definition dmcp.h:562
const uint8_t * post_offs
Array with character x offsets (optional)
Definition dmcp.h:582
uint8_t lnfill
Fill whole line before writing line.
Definition dmcp.h:571
int8_t ya
Lines to fill above the font.
Definition dmcp.h:563
int8_t yb
Lines to fill below the font.
Definition dmcp.h:564
uint8_t fixed
Draw in fixed width.
Definition dmcp.h:568
uint8_t bgfill
Fill background while drawing.
Definition dmcp.h:570
int16_t x
Current x position.
Definition dmcp.h:559
uint8_t inv
Draw inverted.
Definition dmcp.h:569
int16_t ln_offs
Line offset (when displaying by line numbers)
Definition dmcp.h:561
uint8_t newln
Jump to new line after writing line.
Definition dmcp.h:572
int16_t y
Current y position.
Definition dmcp.h:560
Date info structure.
Definition dmcp.h:940
uint8_t month
Month 1-12.
Definition dmcp.h:942
uint16_t year
Year.
Definition dmcp.h:941
uint8_t day
Day 1-31.
Definition dmcp.h:943
Item selection state.
Definition dmcp.h:2269
char * lnbuf
Line buffer (optional - only app wants to use it for line drawing)
Definition dmcp.h:2285
fis_name_fn_t * fis_name_fn
Name callback.
Definition dmcp.h:2277
list_item_t * fis
List items.
Definition dmcp.h:2276
int8_t top_nr
Item number currently first on LCD.
Definition dmcp.h:2271
isel_disp_line_fn_t * disp_line_fn
Line draw function.
Definition dmcp.h:2284
void * data
Custom data (useful for line draw callback)
Definition dmcp.h:2288
int lnsize
Size of lnbuf.
Definition dmcp.h:2286
int8_t lncnt
Number of LCD lines available.
Definition dmcp.h:2272
const char * title
Screen title.
Definition dmcp.h:2282
int max_items
Maximal number of items.
Definition dmcp.h:2278
int8_t roll_lines
How many lines should remain visible while scrolling up/down.
Definition dmcp.h:2273
char * title2
(Optional) Right part of the title (aligned right)
Definition dmcp.h:2283
void * items
Custom data for items.
Definition dmcp.h:2289
int8_t key
key code, set by engine for ISEL_KEY_PRESSED
Definition dmcp.h:2274
int8_t fnr
Currently selected list item.
Definition dmcp.h:2270
int fcnt
Current item count.
Definition dmcp.h:2279
Font structure.
Definition dmcp.h:527
uint8_t width
Font width in pixels
Definition dmcp.h:529
uint8_t char_cnt
Number of characters
Definition dmcp.h:533
uint8_t first_char
Code of first character
Definition dmcp.h:532
uint16_t const * offs
Character offsets in data.
Definition dmcp.h:537
const char * name
Font name
Definition dmcp.h:528
uint8_t const * data
Font data.
Definition dmcp.h:536
uint8_t scale_x
Scaling factor in x direction
Definition dmcp.h:534
uint8_t baseline
Baseline in pixels
Definition dmcp.h:531
uint8_t scale_y
Scaling factor in y direction
Definition dmcp.h:535
uint8_t height
Font height in pixels
Definition dmcp.h:530
RTC ticks state.
Definition dmcp.h:1375
uint32_t sec
seconds in day
Definition dmcp.h:1379
rtc_time_regs_t regs
Time stamp.
Definition dmcp.h:1376
uint32_t jday
julian day
Definition dmcp.h:1378
uint32_t msec
seconds in day corresponding to current minute (for easy sub-minute updates)
Definition dmcp.h:1380
uint64_t dsec
julian day * seconds_per_day
Definition dmcp.h:1377
RTC time stamp parts.
Definition dmcp.h:1365
uint16_t ss
Subsecond part.
Definition dmcp.h:1368
uint32_t tm
Date part.
Definition dmcp.h:1367
uint32_t dt
Time part.
Definition dmcp.h:1366
Single menu screen definition.
Definition dmcp.h:1861
const char *const * msg
Message displayed above menu. NULL = no message.
Definition dmcp.h:1873
const uint8_t * items
Menu items.
Definition dmcp.h:1863
void_fn_t * post_disp
Function called after the menu is drawn to LCD.
Definition dmcp.h:1878
const char * name
Display name of the menu.
Definition dmcp.h:1862
Time info structure.
Definition dmcp.h:949
uint8_t csec
Centiseconds (1/100s)
Definition dmcp.h:953
uint8_t dow
Day of week.
Definition dmcp.h:959
uint8_t min
Minutes.
Definition dmcp.h:951
uint8_t sec
Seconds.
Definition dmcp.h:952
uint8_t hour
Hours.
Definition dmcp.h:950