├── README.md ├── common.mk ├── doc ├── V3s_Brief_V1.0.pdf ├── V3s_Datasheet_V1.0.pdf ├── lichee_base.pdf ├── lichee_zero.pdf └── lichee_zero_sch.pdf ├── drv ├── arm32.h ├── boot.c ├── boot.ld ├── display.c ├── display.h ├── dram.c ├── link.ld ├── mmu.c ├── spi.c ├── spi.h ├── sys.c ├── sys.h └── v3s.h ├── lib ├── lvgl │ ├── README.md │ ├── component.mk │ ├── lv_conf.h │ ├── lv_ex_conf.h │ ├── lv_examples │ │ ├── assets │ │ │ ├── blue_flower_32.bin │ │ │ ├── img_cogwheel_argb.bin │ │ │ ├── img_cogwheel_rgb565.bin │ │ │ ├── img_hand_argb.bin │ │ │ ├── img_hand_rgb565.bin │ │ │ ├── imgbtn_blue_argb.bin │ │ │ ├── imgbtn_blue_rgb565.bin │ │ │ ├── imgbtn_green_argb.bin │ │ │ └── imgbtn_green_rgb565.bin │ │ ├── lv_examples.h │ │ └── src │ │ │ ├── assets │ │ │ ├── img_cogwheel_alpha16.c │ │ │ ├── img_cogwheel_argb.c │ │ │ ├── img_cogwheel_argb.png │ │ │ ├── img_cogwheel_chroma_keyed.c │ │ │ ├── img_cogwheel_chroma_keyed.png │ │ │ ├── img_cogwheel_indexed16.c │ │ │ ├── img_cogwheel_indexed16.png │ │ │ ├── img_cogwheel_rgb.c │ │ │ ├── img_cogwheel_rgb.png │ │ │ ├── img_hand.c │ │ │ ├── img_hand.png │ │ │ ├── lv_font_montserrat_12_compr_az.c │ │ │ ├── lv_font_montserrat_16_compr_az.c │ │ │ └── lv_font_montserrat_28_compr_az.c │ │ │ ├── lv_demo_benchmark │ │ │ ├── README.md │ │ │ ├── lv_demo_benchmark.c │ │ │ ├── lv_demo_benchmark.h │ │ │ ├── screenshot1.png │ │ │ └── screenshot2.png │ │ │ ├── lv_demo_stress │ │ │ ├── README.md │ │ │ ├── lv_demo_stress.c │ │ │ ├── lv_demo_stress.h │ │ │ ├── screenshot1.gif │ │ │ └── screenshot1.png │ │ │ ├── lv_demo_widgets │ │ │ ├── lv_demo_widgets.c │ │ │ ├── lv_demo_widgets.h │ │ │ ├── lv_demo_widgets.py │ │ │ ├── screenshot1.gif │ │ │ └── screenshot1.png │ │ │ └── lv_examples.h │ ├── lvgl.h │ ├── lvgl.mk │ └── src │ │ ├── lv_api_map.h │ │ ├── lv_conf_internal.h │ │ ├── lv_conf_kconfig.h │ │ ├── lv_core │ │ ├── lv_core.mk │ │ ├── lv_disp.c │ │ ├── lv_disp.h │ │ ├── lv_group.c │ │ ├── lv_group.h │ │ ├── lv_indev.c │ │ ├── lv_indev.h │ │ ├── lv_obj.c │ │ ├── lv_obj.h │ │ ├── lv_obj_style_dec.h │ │ ├── lv_refr.c │ │ ├── lv_refr.h │ │ ├── lv_style.c │ │ └── lv_style.h │ │ ├── lv_draw │ │ ├── lv_draw.h │ │ ├── lv_draw.mk │ │ ├── lv_draw_arc.c │ │ ├── lv_draw_arc.h │ │ ├── lv_draw_blend.c │ │ ├── lv_draw_blend.h │ │ ├── lv_draw_img.c │ │ ├── lv_draw_img.h │ │ ├── lv_draw_label.c │ │ ├── lv_draw_label.h │ │ ├── lv_draw_line.c │ │ ├── lv_draw_line.h │ │ ├── lv_draw_mask.c │ │ ├── lv_draw_mask.h │ │ ├── lv_draw_rect.c │ │ ├── lv_draw_rect.h │ │ ├── lv_draw_triangle.c │ │ ├── lv_draw_triangle.h │ │ ├── lv_img_buf.c │ │ ├── lv_img_buf.h │ │ ├── lv_img_cache.c │ │ ├── lv_img_cache.h │ │ ├── lv_img_decoder.c │ │ └── lv_img_decoder.h │ │ ├── lv_font │ │ ├── lv_font.c │ │ ├── lv_font.h │ │ ├── lv_font.mk │ │ ├── lv_font_dejavu_16_persian_hebrew.c │ │ ├── lv_font_fmt_txt.c │ │ ├── lv_font_fmt_txt.h │ │ ├── lv_font_loader.c │ │ ├── lv_font_loader.h │ │ ├── lv_font_montserrat_10.c │ │ ├── lv_font_montserrat_12.c │ │ ├── lv_font_montserrat_12_subpx.c │ │ ├── lv_font_montserrat_14.c │ │ ├── lv_font_montserrat_16.c │ │ ├── lv_font_montserrat_18.c │ │ ├── lv_font_montserrat_20.c │ │ ├── lv_font_montserrat_22.c │ │ ├── lv_font_montserrat_24.c │ │ ├── lv_font_montserrat_26.c │ │ ├── lv_font_montserrat_28.c │ │ ├── lv_font_montserrat_28_compressed.c │ │ ├── lv_font_montserrat_30.c │ │ ├── lv_font_montserrat_32.c │ │ ├── lv_font_montserrat_34.c │ │ ├── lv_font_montserrat_36.c │ │ ├── lv_font_montserrat_38.c │ │ ├── lv_font_montserrat_40.c │ │ ├── lv_font_montserrat_42.c │ │ ├── lv_font_montserrat_44.c │ │ ├── lv_font_montserrat_46.c │ │ ├── lv_font_montserrat_48.c │ │ ├── lv_font_montserrat_8.c │ │ ├── lv_font_simsun_16_cjk.c │ │ ├── lv_font_unscii_16.c │ │ ├── lv_font_unscii_8.c │ │ └── lv_symbol_def.h │ │ ├── lv_gpu │ │ ├── lv_gpu.mk │ │ ├── lv_gpu_nxp_pxp.c │ │ ├── lv_gpu_nxp_pxp.h │ │ ├── lv_gpu_nxp_pxp_osa.c │ │ ├── lv_gpu_nxp_pxp_osa.h │ │ ├── lv_gpu_nxp_vglite.c │ │ ├── lv_gpu_nxp_vglite.h │ │ ├── lv_gpu_stm32_dma2d.c │ │ └── lv_gpu_stm32_dma2d.h │ │ ├── lv_hal │ │ ├── lv_hal.h │ │ ├── lv_hal.mk │ │ ├── lv_hal_disp.c │ │ ├── lv_hal_disp.h │ │ ├── lv_hal_indev.c │ │ ├── lv_hal_indev.h │ │ ├── lv_hal_tick.c │ │ └── lv_hal_tick.h │ │ ├── lv_misc │ │ ├── lv_anim.c │ │ ├── lv_anim.h │ │ ├── lv_area.c │ │ ├── lv_area.h │ │ ├── lv_async.c │ │ ├── lv_async.h │ │ ├── lv_bidi.c │ │ ├── lv_bidi.h │ │ ├── lv_color.c │ │ ├── lv_color.h │ │ ├── lv_debug.c │ │ ├── lv_debug.h │ │ ├── lv_fs.c │ │ ├── lv_fs.h │ │ ├── lv_gc.c │ │ ├── lv_gc.h │ │ ├── lv_ll.c │ │ ├── lv_ll.h │ │ ├── lv_log.c │ │ ├── lv_log.h │ │ ├── lv_math.c │ │ ├── lv_math.h │ │ ├── lv_mem.c │ │ ├── lv_mem.h │ │ ├── lv_misc.mk │ │ ├── lv_printf.c │ │ ├── lv_printf.h │ │ ├── lv_task.c │ │ ├── lv_task.h │ │ ├── lv_templ.c │ │ ├── lv_templ.h │ │ ├── lv_txt.c │ │ ├── lv_txt.h │ │ ├── lv_txt_ap.c │ │ ├── lv_txt_ap.h │ │ ├── lv_types.h │ │ ├── lv_utils.c │ │ └── lv_utils.h │ │ ├── lv_themes │ │ ├── lv_theme.c │ │ ├── lv_theme.h │ │ ├── lv_theme_empty.c │ │ ├── lv_theme_empty.h │ │ ├── lv_theme_material.c │ │ ├── lv_theme_material.h │ │ ├── lv_theme_mono.c │ │ ├── lv_theme_mono.h │ │ ├── lv_theme_template.c │ │ ├── lv_theme_template.h │ │ └── lv_themes.mk │ │ ├── lv_widgets │ │ ├── lv_arc.c │ │ ├── lv_arc.h │ │ ├── lv_bar.c │ │ ├── lv_bar.h │ │ ├── lv_btn.c │ │ ├── lv_btn.h │ │ ├── lv_btnmatrix.c │ │ ├── lv_btnmatrix.h │ │ ├── lv_calendar.c │ │ ├── lv_calendar.h │ │ ├── lv_canvas.c │ │ ├── lv_canvas.h │ │ ├── lv_chart.c │ │ ├── lv_chart.h │ │ ├── lv_checkbox.c │ │ ├── lv_checkbox.h │ │ ├── lv_cont.c │ │ ├── lv_cont.h │ │ ├── lv_cpicker.c │ │ ├── lv_cpicker.h │ │ ├── lv_dropdown.c │ │ ├── lv_dropdown.h │ │ ├── lv_gauge.c │ │ ├── lv_gauge.h │ │ ├── lv_img.c │ │ ├── lv_img.h │ │ ├── lv_imgbtn.c │ │ ├── lv_imgbtn.h │ │ ├── lv_keyboard.c │ │ ├── lv_keyboard.h │ │ ├── lv_label.c │ │ ├── lv_label.h │ │ ├── lv_led.c │ │ ├── lv_led.h │ │ ├── lv_line.c │ │ ├── lv_line.h │ │ ├── lv_linemeter.c │ │ ├── lv_linemeter.h │ │ ├── lv_list.c │ │ ├── lv_list.h │ │ ├── lv_msgbox.c │ │ ├── lv_msgbox.h │ │ ├── lv_objmask.c │ │ ├── lv_objmask.h │ │ ├── lv_objx_templ.c │ │ ├── lv_objx_templ.h │ │ ├── lv_page.c │ │ ├── lv_page.h │ │ ├── lv_roller.c │ │ ├── lv_roller.h │ │ ├── lv_slider.c │ │ ├── lv_slider.h │ │ ├── lv_spinbox.c │ │ ├── lv_spinbox.h │ │ ├── lv_spinner.c │ │ ├── lv_spinner.h │ │ ├── lv_switch.c │ │ ├── lv_switch.h │ │ ├── lv_table.c │ │ ├── lv_table.h │ │ ├── lv_tabview.c │ │ ├── lv_tabview.h │ │ ├── lv_textarea.c │ │ ├── lv_textarea.h │ │ ├── lv_tileview.c │ │ ├── lv_tileview.h │ │ ├── lv_widgets.mk │ │ ├── lv_win.c │ │ └── lv_win.h │ │ └── lvgl.h └── tinygl │ ├── api.c │ ├── arrays.c │ ├── clear.c │ ├── clip.c │ ├── error.c │ ├── gears.h │ ├── get.c │ ├── gl.h │ ├── glu.c │ ├── glu.h │ ├── image_util.c │ ├── init.c │ ├── light.c │ ├── list.c │ ├── matrix.c │ ├── memory.c │ ├── misc.c │ ├── msghandling.c │ ├── msghandling.h │ ├── opinfo.h │ ├── oscontext.c │ ├── oscontext.h │ ├── select.c │ ├── specbuf.c │ ├── specbuf.h │ ├── texture.c │ ├── vertex.c │ ├── zbuffer.c │ ├── zbuffer.h │ ├── zdither.c │ ├── zfeatures.h │ ├── zgl.h │ ├── zline.c │ ├── zline.h │ ├── zmath.c │ ├── zmath.h │ ├── ztriangle.c │ └── ztriangle.h ├── src ├── coremark │ ├── core_list_join.c │ ├── core_main.c │ ├── core_matrix.c │ ├── core_portme.c │ ├── core_portme.h │ ├── core_state.c │ ├── core_util.c │ ├── coremark.h │ ├── main.c │ ├── makefile │ ├── out │ │ ├── boot.bin │ │ └── coremark.bin │ └── readme.md └── tinygl │ ├── gears │ ├── main.c │ ├── makefile │ ├── out │ │ ├── boot.bin │ │ └── gears.bin │ └── readme.md │ └── wave │ ├── main.c │ ├── makefile │ ├── out │ ├── boot.bin │ └── wave.bin │ └── readme.md └── tools ├── sunxi ├── libusb-1.0.dll ├── libwinpthread-1.dll ├── mksunxi.exe ├── msvcr120d.dll └── sunxi-fel.exe └── zadig ├── Zadig.url └── zadig-2.7.exe /README.md: -------------------------------------------------------------------------------- 1 | # Bare metal code examples for Allwinner's V3S SOC 2 | 3 | These examples work without any operating system environment. It's like programming simple microcontrollers or "old school" programming techniques. Examples can be used for educational purposes to teach low-level programming. All programs can be run on [LicheePi Zero](https://linux-sunxi.org/LicheePi_Zero) demoboard. 4 | 5 | **Project directories:** 6 | 7 | | Name | Description | 8 | |--------------------------------|--------------------------------------------| 9 | | [doc](./doc) | Documentation | 10 | | [drv](./drv) | Low-level drivers | 11 | | [lib](./lib) | Third-party libraries | 12 | | [src/tinygl](./src/tinygl) | TinyGl 3D-demo examples | 13 | | [src/coremark](./src/coremark) | CoreMark Benchmark | 14 | | [tools/sunxi](./tools/sunxi) | Tools for loading and flashing the SOC | 15 | | [tools/zadig](./tools/zadig) | Windows tool for installing SOC-driver | 16 | 17 | **Useful links:** 18 | 1. [XBOOT](https://github.com/xboot/xboot) 19 | 2. [RT-Thread](https://github.com/RT-Thread/rt-thread) 20 | 3. [WhyCan Forum](https://whycan.com/f_17.html) 21 | 22 | **Disclaimer:** 23 | The Software is furnished "AS IS", without warranty as to performance or results, and the entire risk as to performance or results is assumed by YOU. I disclaims all warranties, express, implied or otherwise, with regard to the Software, its use, or operation, including without limitation any and all warranties of merchantability, fitness for a particular purpose, and non-infringement of intellectual property rights. 24 | 25 | -------------------------------------------------------------------------------- /common.mk: -------------------------------------------------------------------------------- 1 | BOOT = out/boot 2 | SRCS = $(foreach dir,$(DIRS) $(DIRD),$(wildcard $(dir)/*.c)) 3 | SRCH = $(foreach dir,$(DIRS) $(DIRD),$(wildcard $(dir)/*.h)) 4 | OBJS = $(patsubst %.c,out/%.o,$(notdir $(SRCS) $(CSRCS))) 5 | vpath %.c $(dir $(SRCS)) 6 | 7 | CC = arm-none-eabi- 8 | CFLAGS += $(addprefix -I,$(DIRS)) -c -O3 \ 9 | -march=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=hard \ 10 | -marm -mno-thumb-interwork -mno-unaligned-access \ 11 | -ffunction-sections -fdata-sections \ 12 | -MMD -MT$@ -Wall -Wformat=0 -DARM 13 | LFLAGS += -lm -march=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=hard \ 14 | -Xlinker --gc-sections -Wl,-Map,$(NAME).map -T$(BASE)drv/ 15 | FEL = "$(BASE)tools\sunxi\sunxi-fel" 16 | MKSUNXI = "$(BASE)tools\sunxi\mksunxi" 17 | 18 | .PHONY: all clean run flash 19 | 20 | all: out $(BOOT).bin $(NAME).bin 21 | $(CC)size -G out/*.elf 22 | run: all 23 | $(FEL) -p spl $(BOOT).bin 24 | $(FEL) -p write 0x40000000 $(NAME).bin 25 | $(FEL) exec 0x40000000 26 | flash: all 27 | $(FEL) -p spiflash-write 0 $(BOOT).bin 28 | $(FEL) -p spiflash-write 32768 $(NAME).bin 29 | $(NAME).bin: $(NAME).elf 30 | $(CC)objcopy -O binary $^ $@ 31 | $(NAME).elf: $(OBJS) 32 | $(CC)gcc $^ -o$@ --specs=rdimon.specs $(LFLAGS)link.ld 33 | $(BOOT).bin: $(BOOT).elf 34 | $(CC)objcopy -O binary $^ $@ 35 | $(MKSUNXI) $@ 1>&0 36 | $(BOOT).elf: $(OBJS) 37 | $(CC)gcc $^ -o$@ -nostartfiles $(LFLAGS)boot.ld 38 | out/%.o: %.c 39 | @echo . $(notdir $<) 40 | $(CC)gcc $(CFLAGS) -o$@ $< 41 | out: 42 | mkdir $@ 43 | clean: 44 | echo Clean 45 | rm -fr out 46 | 47 | -include $(patsubst %.o,%.d,$(OBJS)) 48 | 49 | -------------------------------------------------------------------------------- /doc/V3s_Brief_V1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/doc/V3s_Brief_V1.0.pdf -------------------------------------------------------------------------------- /doc/V3s_Datasheet_V1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/doc/V3s_Datasheet_V1.0.pdf -------------------------------------------------------------------------------- /doc/lichee_base.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/doc/lichee_base.pdf -------------------------------------------------------------------------------- /doc/lichee_zero.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/doc/lichee_zero.pdf -------------------------------------------------------------------------------- /doc/lichee_zero_sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/doc/lichee_zero_sch.pdf -------------------------------------------------------------------------------- /drv/arm32.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARM32_H__ 2 | #define __ARM32_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | static inline uint32_t arm32_read_p15_c1(void) 11 | { 12 | uint32_t value; 13 | 14 | __asm__ __volatile__( 15 | "mrc p15, 0, %0, c1, c0, 0" 16 | : "=r" (value) 17 | : 18 | : "memory"); 19 | 20 | return value; 21 | } 22 | 23 | static inline void arm32_write_p15_c1(uint32_t value) 24 | { 25 | __asm__ __volatile__( 26 | "mcr p15, 0, %0, c1, c0, 0" 27 | : 28 | : "r" (value) 29 | : "memory"); 30 | arm32_read_p15_c1(); 31 | } 32 | 33 | static inline void arm32_interrupt_enable(void) 34 | { 35 | uint32_t tmp; 36 | 37 | __asm__ __volatile__( 38 | "mrs %0, cpsr\n" 39 | "bic %0, %0, #(1<<7)\n" 40 | "msr cpsr_cxsf, %0" 41 | : "=r" (tmp) 42 | : 43 | : "memory"); 44 | } 45 | 46 | static inline void arm32_interrupt_disable(void) 47 | { 48 | uint32_t tmp; 49 | 50 | __asm__ __volatile__( 51 | "mrs %0, cpsr\n" 52 | "orr %0, %0, #(1<<7)\n" 53 | "msr cpsr_cxsf, %0" 54 | : "=r" (tmp) 55 | : 56 | : "memory"); 57 | } 58 | 59 | static inline void arm32_mmu_enable(void) 60 | { 61 | uint32_t value = arm32_read_p15_c1(); 62 | arm32_write_p15_c1(value | (1 << 0)); 63 | } 64 | 65 | static inline void arm32_mmu_disable(void) 66 | { 67 | uint32_t value = arm32_read_p15_c1(); 68 | arm32_write_p15_c1(value & ~(1 << 0)); 69 | } 70 | 71 | static inline void arm32_dcache_enable(void) 72 | { 73 | uint32_t value = arm32_read_p15_c1(); 74 | arm32_write_p15_c1(value | (1 << 2)); 75 | } 76 | 77 | static inline void arm32_dcache_disable(void) 78 | { 79 | uint32_t value = arm32_read_p15_c1(); 80 | arm32_write_p15_c1(value & ~(1 << 2)); 81 | } 82 | 83 | static inline void arm32_icache_enable(void) 84 | { 85 | uint32_t value = arm32_read_p15_c1(); 86 | arm32_write_p15_c1(value | (1 << 12)); 87 | } 88 | 89 | static inline void arm32_icache_disable(void) 90 | { 91 | uint32_t value = arm32_read_p15_c1(); 92 | arm32_write_p15_c1(value & ~(1 << 12)); 93 | } 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* __ARM32_H__ */ 100 | -------------------------------------------------------------------------------- /drv/boot.c: -------------------------------------------------------------------------------- 1 | #include "v3s.h" 2 | #include "spi.h" 3 | 4 | void __attribute__((naked)) _boot (void) 5 | { 6 | __asm__ __volatile__ ( 7 | /* Loader structure */ 8 | "b _res\n" // [00] jump to reset vector 9 | ".long 0x4E4F4765\n" // [04] eGON 10 | ".long 0x3054422E\n" // [08] .BT0 11 | ".long 0x00000000\n" // [12] checksum for boot0 12 | ".long __spl_size\n" // [16] length for boot0 13 | ".long 0x024c5053\n" // [20] SPL 14 | ".long 0, 0\n" // [24], [28] 15 | ".long 0, 0, 0, 0, 0, 0, 0, 0\n" // [32]..[60] 16 | ".long 0, 0, 0, 0\n" // [64]..[76] 17 | /* Save boot params */ 18 | "_res: mov r0, #64\n" 19 | "mrc p15, 0, r1, c1, c0, 0\n" // [64] = CP15 SCTLR Register 20 | "mrc p15, 0, r2, c1, c0, 0\n" // [68] = CP15 Control Register 21 | "stmia r0, {r1-r2, sp, lr}\n" // [72] = SP, [76] = LR 22 | /* Enable SMP mode for dcache, by setting bit 6 of auxiliary ctl reg */ 23 | "mrc p15, 0, r0, c1, c0, 1\n" 24 | "orr r0, r0, #(1 << 6)\n" 25 | "mcr p15, 0, r0, c1, c0, 1\n" 26 | /* Enable neon/vfp unit */ 27 | "mrc p15, 0, r0, c1, c0, 2\n" 28 | "orr r0, r0, #(0xf << 20)\n" 29 | "mcr p15, 0, r0, c1, c0, 2\n" 30 | "isb\n" 31 | "mov r0, #0x40000000\n" 32 | "vmsr fpexc, r0\n" 33 | "bl boot\n" 34 | /* Return to FEL */ 35 | "mov r0, #64\n" 36 | "ldmia r0, {r1-r4}\n" 37 | "mov lr, r4\n" 38 | "mov sp, r3\n" 39 | "mcr p15, 0, r2, c1, c0, 0\n" 40 | "mcr p15, 0, r1, c1, c0, 0\n" 41 | "bx lr\n" 42 | ); 43 | } 44 | 45 | static inline void sdelay(int loops) 46 | { 47 | __asm__ __volatile__ ( 48 | "1:subs %0, %1, #1\n" 49 | "bne 1b":"=r" (loops):"0"(loops)); 50 | } 51 | 52 | void put_char (char c) 53 | { 54 | if(c == '\n') put_char('\r'); 55 | while((UART0->LSR & 64) == 0); 56 | UART0->THR = c; 57 | } 58 | 59 | void put_string (char *ptr) 60 | { 61 | while(*ptr != 0) put_char(*ptr++); 62 | } 63 | 64 | void put_num (unsigned int num) 65 | { 66 | int i; 67 | char str[16]; 68 | if(num) 69 | { 70 | for(i = 0; num; num /= 10) str[i++] = num % 10 + '0'; 71 | while(i) put_char(str[--i]); 72 | } 73 | else put_char('0'); 74 | put_char('\n'); 75 | } 76 | 77 | void sys_dram_init(void); 78 | 79 | void boot (void) 80 | { 81 | /* System clock initialization */ 82 | CCU->PLL_STABLE0 = 0x1FF; 83 | CCU->PLL_STABLE1 = 0x1FF; 84 | CCU->CPU_AXI_CFG = 0x10012; 85 | sdelay(800); 86 | for(CCU->PLL_CPU_CTRL = 0x80001410; !(CCU->PLL_CPU_CTRL & (1 << 28));) {}; // CPU:1008MHz 87 | CCU->CPU_AXI_CFG = 0x20012; 88 | for(CCU->PLL_PERIPH0_CTRL = 0x80041711; !(CCU->PLL_PERIPH0_CTRL & (1 << 28));) {}; // PERIPH: 576MHz 89 | CCU->AHB1_APB1_CFG = 0x00003180; // AHB1=PLL_PERIPH/3=192MHz, APB1=AHB1/2 = 96MHz 90 | CCU->MBUS_CLK = 0x81000003; 91 | CCU->DRAM_GATING &= ~(1 << 31); 92 | /* DDR initialization */ 93 | sys_dram_init(); 94 | /* UART initialization */ 95 | CCU->APB2_CFG = 0x02010002; 96 | PB->CFG1 = 0x77777733; // PB8-UART0_TX, PB9-UART0_RX 97 | CCU->BUS_CLK_GATING3 |= (1 << 16); 98 | CCU->BUS_SOFT_RST4 |= (1 << 16); 99 | UART0->THR = 0; 100 | UART0->FCR = 0xF7; 101 | UART0->MCR = 0; 102 | UART0->LCR = 0x83; 103 | #if 0 104 | UART0->DLL = 2; // 3000000bps @ 576MHz 105 | #else 106 | UART0->DLL = 52; // 115200bps @ 576MHz 107 | #endif 108 | UART0->DLH = 0; 109 | UART0->LCR = 3; 110 | /* Firmware loading */ 111 | if(*(unsigned int*)8 != 0x4c45462e) 112 | { 113 | /* SPI NOR initialization */ 114 | put_string("\n\n\033[36mSPI-boot\033[0m\nImage size: "); 115 | spi_init(); 116 | spi_flash_read(32768, (void*)0x40000000, 32); 117 | put_num(*(int*)0x40000014); 118 | spi_flash_read(32768 , (void*)0x40000000, *(int*)0x40000014); 119 | ((void(*)())0x40000000)(); 120 | } 121 | else put_string("\n\n\033[36mUSB-boot\033[0m\n"); 122 | } 123 | -------------------------------------------------------------------------------- /drv/boot.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_boot) 2 | 3 | SECTIONS 4 | { 5 | . = 0; 6 | .text : 7 | { 8 | out/boot.o (.text*) 9 | out/dram.o (.text*) 10 | *(.text*) 11 | } 12 | .data : { *(.data) } 13 | PROVIDE(__spl_size = .); 14 | } 15 | -------------------------------------------------------------------------------- /drv/display.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sys.h" 4 | 5 | struct LAY layer[4]; 6 | struct DISP *display; 7 | 8 | struct DISP TFT_800x480 = { 800, 480, 2, 23, 4, 46, 0x81004107, 5, 0, 2 }; // 198 / 6 = 33.0MHz 9 | //struct DISP TFT_800x480 = { 800, 480, 3, 45, 48, 152, 0x81004107, 8, 0 }; // 198 / 8 = 33MHz 10 | 11 | int disp_init (struct DISP *cfg, u32 bg) 12 | { 13 | u32 size = (((cfg->height - 1) << 16) | (cfg->width - 1)); 14 | if(cfg == NULL) return KO; 15 | display = cfg; 16 | for(CCU->PLL_VIDEO_CTRL = cfg->pll; !(CCU->PLL_VIDEO_CTRL & (1 << 28));) {}; 17 | CCU->DE_CLK = 1UL << 31; 18 | CCU->TCON_CLK = 1UL << 31; 19 | CCU->BUS_CLK_GATING1 |= (1 << 12) | (1 << 4); 20 | CCU->BUS_SOFT_RST1 &= ~((1 << 12) | (1 << 4)); 21 | CCU->BUS_SOFT_RST1 |= (1 << 12) | (1 << 4); 22 | PE->CFG0 = 0x33333333; // PD0..PD7: LCD D2..D7, D10, D11 23 | PE->CFG1 = 0x33333333; // PD8..PD15: LCD D12..D15, D18..D21 24 | PE->CFG2 = 0x30003333; // PD16..PD21: LCD D22..D23, CLK, DE, HS, VS 25 | PE->CFG3 = 0x00000003; // PD16..PD21: LCD D22..D23, CLK, DE, HS, VS 26 | PE->DRV0 = 0xFFFFFFFF; // Drive strong (level 3) 27 | PE->DRV1 = 0x00000FFF; 28 | PE->PUL0 = 0; // Pull-up/down disable 29 | PE->PUL1 = 0; 30 | TCON->CTRL = 0; 31 | TCON->INT0 = 0; 32 | TCON->T0_CLK &= 0x0FFFFFFF; 33 | TCON->T0_IO_CTRL[1] = 0xFFFFFFFF; 34 | TCON->T1_IO_CTRL[1] = 0xFFFFFFFF; 35 | DE_CTRL->RST_CFG |= 1; 36 | DE_CTRL->GATE_CFG |= 1; 37 | DE_CTRL->BUS_CFG |= 1; 38 | DE_CTRL->SEL_CFG &= ~1; 39 | DE_GLB->CTRL = 1; 40 | DE_GLB->STAT = 0; 41 | DE_GLB->DBUF = 0;//1; 42 | DE_GLB->SIZE = size; 43 | memset(DE_OVL_V, 0, sizeof(DE_OVL_V_T)); 44 | memset(DE_OVL_UI0, 0, sizeof(DE_OVL_UI_T)); 45 | memset(DE_OVL_UI1, 0, sizeof(DE_OVL_UI_T)); 46 | memset(DE_OVL_UI2, 0, sizeof(DE_OVL_UI_T)); 47 | memset(DE_BLD, 0, sizeof(DE_BLD_T)); 48 | DE_BLD->FCOL_CTRL = 0x101; 49 | DE_BLD->ROUTE = 2; 50 | DE_BLD->PREMULT = 0; 51 | DE_BLD->BCOL = bg;//0xFF000000; 52 | DE_BLD->MODE[0] = 0x03010301; 53 | DE_BLD->MODE[1] = 0x03010301; 54 | DE_BLD->OUTSIZE = size; 55 | DE_BLD->OUTCTRL = 0; 56 | DE_BLD->KEY_CTRL = 0; 57 | for(int i = 0; i < 4; i++) 58 | { 59 | DE_BLD->ATTR[i].FCOL = 0xFF000000; 60 | DE_BLD->ATTR[i].INSIZE = size; 61 | } 62 | V3S_DE_MUX_VSU = 0; 63 | V3S_DE_MUX_GSU1 = 0; 64 | V3S_DE_MUX_GSU2 = 0; 65 | V3S_DE_MUX_GSU3 = 0; 66 | V3S_DE_MUX_FCE = 0; 67 | V3S_DE_MUX_BWS = 0; 68 | V3S_DE_MUX_LTI = 0; 69 | V3S_DE_MUX_PEAK = 0; 70 | V3S_DE_MUX_ASE = 0; 71 | V3S_DE_MUX_FCC = 0; 72 | V3S_DE_MUX_DCSC = 0; 73 | TCON->T0_CTRL = (1UL << 31) | (1UL << 21) | ((cfg->vbp + cfg->vsp) << 4); 74 | TCON->T0_CLK = (1UL << 28) | cfg->div; 75 | TCON->T0_TIMING[0] = ((cfg->width - 1) << 16) | (cfg->height - 1); 76 | TCON->T0_TIMING[1] = ((cfg->width + cfg->hbp + cfg->hsp - 1) << 16) | (cfg->hbp - 1); // ?????? 77 | TCON->T0_TIMING[2] = ((cfg->height + cfg->vbp + cfg->vsp) << 17) | (cfg->vbp - 1); 78 | TCON->T0_TIMING[3] = ((cfg->hsp - 1) << 16) | (cfg->vsp - 1); 79 | TCON->T0_HV_TIMING = 0; 80 | TCON->T0_CPU_IF = 0; 81 | TCON->T0_IO_CTRL[0] = cfg->inv << 24; 82 | TCON->T0_IO_CTRL[1] = 0; 83 | TCON->CTRL = 0x80000000; 84 | while(TCON->T0_CTRL & (1 << 21)); 85 | return OK; 86 | } 87 | 88 | u8 disp_backlight (u8 x) 89 | { 90 | PB->CFG0 = 0x77717777; 91 | PB->DAT = 0b10000; 92 | return x; 93 | } 94 | 95 | void lay_config (int i, int width, int height, int posx, int posy, int stride, 96 | void *addr, int attr0, int attr1) 97 | { 98 | layer[i].width = width; 99 | layer[i].height = height; 100 | layer[i].posx = posx; 101 | layer[i].posy = posy; 102 | layer[i].stride = width * stride; 103 | layer[i].addr = addr; 104 | layer[i].attr0 = attr0; 105 | layer[i].attr1 = attr1; 106 | } 107 | 108 | void lay_update (int i) 109 | { 110 | u32 size = (((layer[i].height - 1) << 16) | (layer[i].width - 1)); 111 | DE_OVL_UI0->CFG[0].ATTR = (1 << 0) | (10 << 8); 112 | DE_OVL_UI0->CFG[0].SIZE = size; 113 | DE_OVL_UI0->CFG[0].COORD = 0; 114 | DE_OVL_UI0->CFG[0].PITCH = 2 * layer[i].width; 115 | DE_OVL_UI0->CFG[0].TOP_LADDR = (u32)layer[i].addr; 116 | DE_OVL_UI0->OVL_SIZE = size; 117 | DE_OVL_UI1->CFG[0].ATTR = (1 << 0) | (10 << 8); 118 | DE_OVL_UI1->CFG[0].SIZE = size; 119 | DE_OVL_UI1->CFG[0].COORD = 0; 120 | DE_OVL_UI1->CFG[0].PITCH = 2 * layer[i].width; 121 | DE_OVL_UI1->CFG[0].TOP_LADDR = (u32)layer[i].addr; 122 | DE_OVL_UI1->OVL_SIZE = size; 123 | DE_GLB->CTRL = 1; 124 | DE_GLB->STAT = 0; 125 | DE_GLB->DBUF = 1; 126 | DE_GLB->SIZE = size; 127 | } 128 | 129 | void *fb_alloc (int width, int height, int stride) 130 | { 131 | int size = width * height * stride / 8; 132 | void *ptr = memalign(4096, size); 133 | if(ptr) memset(ptr, 0, size); 134 | return ptr; 135 | } 136 | -------------------------------------------------------------------------------- /drv/display.h: -------------------------------------------------------------------------------- 1 | #ifndef DISP_H 2 | #define DISP_H 3 | 4 | struct DISP { 5 | u16 width; // Horizontal resolution 6 | u16 height; // Vertical resolution 7 | u16 vsp; // Vertical sync pulse width 8 | u16 vbp; // Vertical back porch width 9 | u16 hsp; // Horizontal sync pulse width 10 | u16 hbp; // Horizontal back porch width 11 | u32 pll; // PLL_VIDEO_CTRL 12 | u8 div; // DCLKDIV: dot clock divider 13 | u8 inv; // IO_CTRL_0 (1-invert) 14 | u16 ctrl; // 0/1: tft/tv 15 | }; 16 | 17 | struct LAY { 18 | u16 width; 19 | u16 height; 20 | u16 posx; 21 | u16 posy; 22 | u32 stride; 23 | void *addr; 24 | u32 attr0; 25 | u32 attr1; 26 | }; 27 | 28 | extern struct LAY layer[4]; 29 | extern struct DISP *display; 30 | extern struct DISP TV_PAL; 31 | extern struct DISP TV_NTSC; 32 | extern struct DISP TFT_800x480; 33 | 34 | int disp_init (struct DISP *cfg, u32 bg); 35 | u8 disp_backlight (u8 x); 36 | 37 | void lay_config (int i, int width, int height, int posx, int posy, int stride, 38 | void *addr, int attr0, int attr1); 39 | void lay_update (int i); 40 | 41 | void *fb_alloc (int width, int height, int stride); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /drv/link.ld: -------------------------------------------------------------------------------- 1 | MEMORY { ram : org = 0x40000000, len = 64M } 2 | 3 | stack_und = ORIGIN(ram) + LENGTH(ram) - 0x10000; 4 | stack_abt = stack_und - 0x10000; 5 | stack_irq = stack_abt - 0x10000; 6 | stack_fiq = stack_irq - 0x10000; 7 | stack_usr = stack_fiq - 0x10000; 8 | stack_srv = stack_usr - 0x40000; 9 | 10 | ENTRY(_vectors) 11 | 12 | SECTIONS 13 | { 14 | .text : 15 | { 16 | *(.vectors); 17 | . = ALIGN(4); 18 | *(.init); 19 | . = ALIGN(4); 20 | *(.text); 21 | . = ALIGN(4); 22 | *(.rodata); 23 | . = ALIGN(4); 24 | *(.rodata*); 25 | . = ALIGN(4); 26 | } > ram 27 | .data : 28 | { 29 | *(.data) 30 | . = ALIGN(4); 31 | } > ram 32 | . = ALIGN(4); 33 | PROVIDE(image_size = . - ORIGIN(ram)); 34 | .bss : 35 | { 36 | PROVIDE(bss_start = .); 37 | *(.bss) 38 | *(.bss.**) 39 | *(COMMON) 40 | . = ALIGN(4); 41 | PROVIDE(bss_end = .); 42 | } > ram 43 | . = ALIGN(8); 44 | end = .; 45 | } 46 | -------------------------------------------------------------------------------- /drv/mmu.c: -------------------------------------------------------------------------------- 1 | #include "arm32.h" 2 | 3 | static inline uint32_t get_cache(void) 4 | { 5 | uint32_t cache; 6 | 7 | __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 1" : "=r" (cache)); 8 | return cache; 9 | } 10 | 11 | static inline void __v5_cache_inv_range(uint32_t start, uint32_t stop, uint32_t line) 12 | { 13 | uint32_t mva; 14 | 15 | start &= ~(line - 1); 16 | if(stop & (line - 1)) 17 | stop = (stop + line) & ~(line - 1); 18 | for(mva = start; mva < stop; mva = mva + line) 19 | { 20 | __asm__ __volatile__("mcr p15, 0, %0, c7, c6, 1" : : "r" (mva)); 21 | } 22 | } 23 | 24 | /* 25 | * Invalidate range, affects the range [start, stop - 1] 26 | */ 27 | void cache_inv_range(unsigned long start, unsigned long stop) 28 | { 29 | uint32_t cache; 30 | uint32_t line; 31 | 32 | cache = get_cache(); 33 | line = 1 << ((cache & 0x3) + 3); 34 | __v5_cache_inv_range(start, stop, line); 35 | //dsb(); 36 | __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory"); 37 | } 38 | 39 | #define MB (1U << 20) 40 | 41 | enum { 42 | MAP_TYPE_NCNB = 0x0, 43 | MAP_TYPE_NCB = 0x1, 44 | MAP_TYPE_CNB = 0x2, 45 | MAP_TYPE_CB = 0x3, 46 | }; 47 | 48 | static uint32_t __mmu_ttb[4096] __attribute__((aligned(0x4000))); 49 | //uint32_t *__mmu_ttb = (uint32_t*)0;//x4000; 50 | 51 | static inline void mmu_ttb_set(uint32_t base) 52 | { 53 | __asm__ __volatile__("mcr p15, 0, %0, c2, c0, 0" : : "r" (base) : "memory"); 54 | } 55 | 56 | static inline void mmu_domain_set(uint32_t domain) 57 | { 58 | __asm__ __volatile__("mcr p15, 0, %0, c3, c0, 0" : : "r" (domain) : "memory"); 59 | } 60 | 61 | static inline void mmu_inv_tlb(void) 62 | { 63 | __asm__ __volatile__("mcr p15, 0, %0, c8, c7, 0" : : "r" (0)); 64 | __asm__ __volatile__("mcr p15, 0, %0, c8, c6, 0" : : "r" (0)); 65 | __asm__ __volatile__("mcr p15, 0, %0, c8, c5, 0" : : "r" (0)); 66 | //dsb(); 67 | //isb(); 68 | __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory"); 69 | __asm__ __volatile__ ("" : : : "memory"); 70 | } 71 | 72 | static void map_l1_section(uint32_t virt, uint32_t phys, uint32_t size, int type) 73 | { 74 | uint32_t i; 75 | 76 | virt >>= 20; 77 | phys >>= 20; 78 | size >>= 20; 79 | type &= 0x3; 80 | 81 | for(i = size; i > 0; i--, virt++, phys++) 82 | __mmu_ttb[virt] = (phys << 20) | (1 << 16) | (0x3 << 10) | (0x0 << 5) | (type << 2) | (0x2 << 0); 83 | } 84 | 85 | void mmu_setup(void) 86 | { 87 | //extern unsigned char __dma_start; 88 | //extern unsigned char __dma_end; 89 | map_l1_section(0x00000000, 0x00000000, 2048*MB, 0);//SZ_2G, 0); 90 | map_l1_section(0x40000000, 0x40000000, 2048*MB, 0);//SZ_2G, 0); 91 | map_l1_section(0x40000000, 0x40000000, 64*MB, MAP_TYPE_CB);// SZ_32M, MAP_TYPE_CB); 92 | // map_l1_section(&__dma_start, &__dma_start, &__dma_end - &__dma_start, MAP_TYPE_NCNB); 93 | } 94 | 95 | void mmu_enable(void) 96 | { 97 | mmu_ttb_set((uint32_t)(__mmu_ttb)); 98 | cache_inv_range(0, ~0); 99 | //outer_cache_enable(); 100 | //outer_cache_inv_range(0, ~0); 101 | mmu_inv_tlb(); 102 | mmu_domain_set(0x3); 103 | arm32_mmu_enable(); 104 | arm32_icache_enable(); 105 | arm32_dcache_enable(); 106 | } 107 | -------------------------------------------------------------------------------- /drv/spi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "sys.h" 3 | 4 | /******************************************************************************/ 5 | /* SPI0 (FLASH) */ 6 | /******************************************************************************/ 7 | #define spi_flash_select() SPI0->TC = 0x44 8 | #define spi_flash_deselect() SPI0->TC = 0xC4 9 | 10 | void spi_init (void) 11 | { 12 | CCU->SPI0_CLK = 0x81000006; 13 | CCU->BUS_CLK_GATING0 |= (1 << 20); // SPI0 14 | CCU->BUS_SOFT_RST0 &= ~(1 << 20); 15 | CCU->BUS_SOFT_RST0 |= (1 << 20); 16 | PC->CFG0 = 0x3333; // PC0-CLK, PC1-CS, PC2-MISO, PC3-MOSI 17 | SPI0->CC = 0x1001; // AHB / 4 = 48MHz 18 | for(SPI0->GC = 0x80000083; SPI0->GC & 0x80000000;) {}; 19 | spi_flash_deselect(); 20 | for(SPI0->FC = 0x80408001; SPI0->FC & 0x80008000;) {}; 21 | } 22 | 23 | int spi_flash_read (u32 addr, void *buf, u32 len) 24 | { 25 | u8 i, *rx = (u8*)buf; 26 | if(!buf || !len) return 1; 27 | spi_flash_select(); 28 | SPI0->MBC = 4; 29 | SPI0->MTC = 4; 30 | SPI0->BCC = 4; 31 | SPI0->TX.word = __builtin_bswap32((addr & 0x00FFFFFF) | 0x03000000); 32 | for(SPI0->TC |= (1U << 31); SPI0->TC & (1U << 31); ) {}; 33 | SPI0->RX.word; 34 | do 35 | { 36 | i = len > 64 ? 64 : len; 37 | SPI0->MBC = i; 38 | SPI0->TC |= (1U << 31); 39 | len -= i; 40 | do 41 | { 42 | if(SPI0->FS & 0xFF) 43 | { 44 | *rx++ = SPI0->RX.byte; 45 | i--; 46 | } 47 | } while(i); 48 | } while(len); 49 | spi_flash_deselect(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /drv/spi.h: -------------------------------------------------------------------------------- 1 | void spi_init (void); 2 | int spi_flash_read (u32 addr, void *buf, u32 len); 3 | 4 | -------------------------------------------------------------------------------- /drv/sys.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_H 2 | #define SYS_H 3 | 4 | #include "v3s.h" 5 | #include "display.h" 6 | #include "spi.h" 7 | 8 | #define ctr_us (TIM->AVS_CNT0) 9 | #define ctr_ms (TIM->AVS_CNT1) 10 | void delay (u32 ms); 11 | void udelay (u32 us); 12 | 13 | int kbhit(void); 14 | void dump (void *ptr, uint16_t len); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/lvgl/component.mk: -------------------------------------------------------------------------------- 1 | # ESP-IDF component file for make based commands 2 | 3 | COMPONENT_SRCDIRS := . 4 | COMPONENT_SRCDIRS += src 5 | COMPONENT_SRCDIRS += src/lv_core 6 | COMPONENT_SRCDIRS += src/lv_draw 7 | COMPONENT_SRCDIRS += src/lv_font 8 | COMPONENT_SRCDIRS += src/lv_gpu 9 | COMPONENT_SRCDIRS += src/lv_hal 10 | COMPONENT_SRCDIRS += src/lv_misc 11 | COMPONENT_SRCDIRS += src/lv_themes 12 | COMPONENT_SRCDIRS += src/lv_widgets 13 | 14 | COMPONENT_ADD_INCLUDEDIRS := . 15 | COMPONENT_ADD_INCLUDEDIRS += src 16 | COMPONENT_ADD_INCLUDEDIRS += src/lv_core 17 | COMPONENT_ADD_INCLUDEDIRS += src/lv_draw 18 | COMPONENT_ADD_INCLUDEDIRS += src/lv_font 19 | COMPONENT_ADD_INCLUDEDIRS += src/lv_gpu 20 | COMPONENT_ADD_INCLUDEDIRS += src/lv_hal 21 | COMPONENT_ADD_INCLUDEDIRS += src/lv_misc 22 | COMPONENT_ADD_INCLUDEDIRS += src/lv_themes 23 | COMPONENT_ADD_INCLUDEDIRS += src/lv_widgets 24 | -------------------------------------------------------------------------------- /lib/lvgl/lv_ex_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_ex_conf.h 3 | * Configuration file for v7.11.0 4 | * 5 | */ 6 | /* 7 | * COPY THIS FILE AS lv_ex_conf.h 8 | */ 9 | 10 | #if 1 /*Set it to "1" to enable the content*/ 11 | 12 | #ifndef LV_EX_CONF_H 13 | #define LV_EX_CONF_H 14 | 15 | 16 | /******************* 17 | * GENERAL SETTING 18 | *******************/ 19 | #define LV_EX_PRINTF 0 /*Enable printf-ing data in demoes and examples*/ 20 | #define LV_EX_KEYBOARD 0 /*Add PC keyboard support to some examples (`lv_drivers` repository is required)*/ 21 | #define LV_EX_MOUSEWHEEL 0 /*Add 'encoder' (mouse wheel) support to some examples (`lv_drivers` repository is required)*/ 22 | 23 | /********************* 24 | * DEMO USAGE 25 | *********************/ 26 | 27 | /*Show some widget*/ 28 | #define LV_USE_DEMO_WIDGETS 1 29 | #if LV_USE_DEMO_WIDGETS 30 | #define LV_DEMO_WIDGETS_SLIDESHOW 1 31 | #endif 32 | 33 | /*Printer demo, optimized for 800x480*/ 34 | #define LV_USE_DEMO_PRINTER 1 35 | 36 | /*Demonstrate the usage of encoder and keyboard*/ 37 | #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 38 | 39 | /*Benchmark your system*/ 40 | #define LV_USE_DEMO_BENCHMARK 1 41 | 42 | /*Stress test for LVGL*/ 43 | #define LV_USE_DEMO_STRESS 1 44 | 45 | /*Music player for LVGL*/ 46 | #define LV_USE_DEMO_MUSIC 0 47 | #if LV_USE_DEMO_MUSIC 48 | #define LV_DEMO_MUSIC_AUTO_PLAY 0 49 | #endif 50 | 51 | #endif /*LV_EX_CONF_H*/ 52 | 53 | #endif /*End of "Content enable"*/ 54 | 55 | -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/blue_flower_32.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/blue_flower_32.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/img_cogwheel_argb.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/img_cogwheel_argb.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/img_cogwheel_rgb565.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/img_cogwheel_rgb565.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/img_hand_argb.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/img_hand_argb.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/img_hand_rgb565.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/img_hand_rgb565.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/imgbtn_blue_argb.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/imgbtn_blue_argb.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/imgbtn_blue_rgb565.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/imgbtn_blue_rgb565.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/imgbtn_green_argb.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/imgbtn_green_argb.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/assets/imgbtn_green_rgb565.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/assets/imgbtn_green_rgb565.bin -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/lv_examples.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_examples.h 3 | * 4 | */ 5 | 6 | #ifndef LV_EXAMPLES_H 7 | #define LV_EXAMPLES_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #define LV_LVGL_H_INCLUDE_SIMPLE 14 | #define LV_EX_CONF_INCLUDE_SIMPLE 15 | 16 | /********************* 17 | * INCLUDES 18 | *********************/ 19 | #if defined(LV_LVGL_H_INCLUDE_SIMPLE) 20 | #include "lvgl.h" 21 | #else 22 | #include "../lvgl/lvgl.h" 23 | #endif 24 | 25 | #if defined(LV_EX_CONF_PATH) 26 | #define __LV_TO_STR_AUX(x) #x 27 | #define __LV_TO_STR(x) __LV_TO_STR_AUX(x) 28 | #include __LV_TO_STR(LV_EX_CONF_PATH) 29 | #undef __LV_TO_STR_AUX 30 | #undef __LV_TO_STR 31 | #elif defined(LV_EX_CONF_INCLUDE_SIMPLE) 32 | #include "lv_ex_conf.h" 33 | #else 34 | #include "../lv_ex_conf.h" 35 | #endif 36 | 37 | //#include "src/lv_ex_get_started/lv_ex_get_started.h" 38 | //#include "src/lv_ex_style/lv_ex_style.h" 39 | //#include "src/lv_ex_widgets/lv_ex_widgets.h" 40 | #include "src/lv_demo_widgets/lv_demo_widgets.h" 41 | #include "src/lv_demo_benchmark/lv_demo_benchmark.h" 42 | #include "src/lv_demo_stress/lv_demo_stress.h" 43 | //#include "src/lv_demo_keypad_encoder/lv_demo_keypad_encoder.h" 44 | //#include "src/lv_demo_printer/lv_demo_printer.h" 45 | //#include "src/lv_demo_music/lv_demo_music.h" 46 | 47 | /********************* 48 | * DEFINES 49 | *********************/ 50 | /*Test lvgl version*/ 51 | #if LV_VERSION_CHECK(7, 11, 0) == 0 52 | #error "lv_examples: Wrong lvgl version" 53 | #endif 54 | 55 | /********************** 56 | * TYPEDEFS 57 | **********************/ 58 | 59 | /********************** 60 | * GLOBAL PROTOTYPES 61 | **********************/ 62 | 63 | 64 | /********************** 65 | * MACROS 66 | **********************/ 67 | 68 | 69 | #ifdef __cplusplus 70 | } /* extern "C" */ 71 | #endif 72 | 73 | #endif /*LV_EXAMPLES_H*/ 74 | -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/assets/img_cogwheel_argb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/assets/img_cogwheel_argb.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/assets/img_cogwheel_chroma_keyed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/assets/img_cogwheel_chroma_keyed.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/assets/img_cogwheel_indexed16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/assets/img_cogwheel_indexed16.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/assets/img_cogwheel_rgb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/assets/img_cogwheel_rgb.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/assets/img_hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/assets/img_hand.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_benchmark/README.md: -------------------------------------------------------------------------------- 1 | # Benchmark demo 2 | 3 | ## Overview 4 | 5 | The benchmark demo tests the performance in various cases. 6 | For example rectangle, border, shadow, text, image blending, image transformation, bleding modes, etc. 7 | All tests are repeated with 50% opacity. 8 | 9 | The size an position of the objects during testing are set with a pseudo random number to make the benchmark repeatable. 10 | 11 | On to top of the screen the title of the current test step, and the result of the previous step is displayed. 12 | 13 | ## Run the benchmark 14 | - In `lv_ex_conf.h` set `LV_USE_DEMO_BENCHMARK 1` 15 | - After `lv_init()` and initializing the drivers call `lv_demo_benchmark()` 16 | 17 | ## Interpret the result 18 | 19 | The FPS is measured like this: 20 | - load the next step 21 | - in the display driver's `monitor_cb` accumulate the time-to-render and the number of cycles 22 | - measure for 1 second 23 | - calculate `FPS = time_sum / render_cnt` 24 | 25 | Note that it can result in very high FPS results for simple cases. 26 | E.g. if some simple rectangles are drawn in 5 ms, the benchmark will tell it's 200 FPS. 27 | So it ignores `LV_DISP_REFR_PERIOD` which tells LVGL how often it should refresh the screen. 28 | In other words, the benchmark shows the FPS from the pure rendering time. 29 | 30 | By default, only the changed areas are refreshed. It means if only a few pixels are changed in 1 ms the benchmark will show 1000 FPS. To measure the performance with full screen refresh uncomment `lv_obj_invalidate(lv_scr_act())` in `monitor_cb()` in `lv_demo_benchmark.c`. 31 | 32 | ![LVGL benchmark running](https://github.com/lvgl/lv_examples/blob/master/src/lv_demo_benchmark/screenshot1.png?raw=true) 33 | 34 | 35 | ## Result summary 36 | In the end, a table is created to display measured FPS values. 37 | 38 | On top of the summary screen, the "Weighted FPS" value is shown. 39 | In this, the result of the more common cases are taken into account with a higher weight. 40 | 41 | "Opa. speed" shows the speed of the measurements with opacity compared to full opacity. 42 | E.g. "Opa. speed = 90%" means that rendering with opacity is 10% slower. 43 | 44 | In the first section of the table, "Slow but common cases", those cases are displayed which are considered common but were slower than 20 FPS. 45 | 46 | Below this in the "All cases section" all the results are shown. The < 10 FPS results are shown with red, the >= 10 but < 20 FPS values are displayed with orange. 47 | 48 | 49 | ![LVGL benchmark result summary](https://github.com/lvgl/lv_examples/blob/master/src/lv_demo_benchmark/screenshot2.png?raw=true) 50 | -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_benchmark/lv_demo_benchmark.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_demo_benchmark.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DEMO_BENCHMARK_H 7 | #define LV_DEMO_BENCHMARK_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | void lv_demo_benchmark(void); 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_DEMO_BENCHMARK_H*/ 39 | -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_benchmark/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/lv_demo_benchmark/screenshot1.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_benchmark/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/lv_demo_benchmark/screenshot2.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_stress/README.md: -------------------------------------------------------------------------------- 1 | # Stress demo 2 | 3 | ## Overview 4 | 5 | A stress test for LVGL. 6 | It contains a lot of object creation, deletion, animations, styles usage, and so on. It can be used if there is any memory corruption during heavy usage or any memory leaks. 7 | 8 | ![Printer demo with LVGL embedded GUI library](https://github.com/lvgl/lv_examples/blob/master/src/lv_demo_stress/screenshot1.gif?raw=true) 9 | 10 | ## Run the demo 11 | - In `lv_ex_conf.h` set `LV_USE_DEMO_STRESS 1` 12 | - In `lv_conf.h` enable all the widgets (`LV_USE_BTN 1`) and the animations (`LV_USE_ANIMATION 1`) 13 | - After `lv_init()` and initializing the drivers call `lv_demo_stress()` 14 | -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_stress/lv_demo_stress.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_demo_stress.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DEMO_STRESS_H 7 | #define LV_DEMO_STRESS_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | void lv_demo_stress(void); 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_DEMO_STRESS_H*/ 39 | -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_stress/screenshot1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/lv_demo_stress/screenshot1.gif -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_stress/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/lv_demo_stress/screenshot1.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_widgets/lv_demo_widgets.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_demo_widgets.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DEMO_WIDGETS_H 7 | #define LV_DEMO_WIDGETS_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | void lv_demo_widgets(void); 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_DEMO_WIDGETS_H*/ 39 | -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_widgets/screenshot1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/lv_demo_widgets/screenshot1.gif -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_demo_widgets/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/lib/lvgl/lv_examples/src/lv_demo_widgets/screenshot1.png -------------------------------------------------------------------------------- /lib/lvgl/lv_examples/src/lv_examples.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_examples.h 3 | * This file exists only to be compatible with Arduino's library structure 4 | */ 5 | 6 | #ifndef LV_EXAMPLES_SRC_H 7 | #define LV_EXAMPLES_SRC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #include "../lv_examples.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * GLOBAL PROTOTYPES 29 | **********************/ 30 | 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | 37 | #ifdef __cplusplus 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #endif /*LV_EXAMPLES_SRC_H*/ 42 | -------------------------------------------------------------------------------- /lib/lvgl/lvgl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lvgl.h 3 | * Include all LittleV GL related headers 4 | */ 5 | 6 | #ifndef LVGL_H 7 | #define LVGL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /*************************** 14 | * CURRENT VERSION OF LVGL 15 | ***************************/ 16 | #define LVGL_VERSION_MAJOR 7 17 | #define LVGL_VERSION_MINOR 11 18 | #define LVGL_VERSION_PATCH 0 19 | #define LVGL_VERSION_INFO "" 20 | 21 | /********************* 22 | * INCLUDES 23 | *********************/ 24 | 25 | #include "src/lv_misc/lv_log.h" 26 | #include "src/lv_misc/lv_task.h" 27 | #include "src/lv_misc/lv_math.h" 28 | #include "src/lv_misc/lv_async.h" 29 | 30 | #include "src/lv_hal/lv_hal.h" 31 | 32 | #include "src/lv_core/lv_obj.h" 33 | #include "src/lv_core/lv_group.h" 34 | #include "src/lv_core/lv_indev.h" 35 | 36 | #include "src/lv_core/lv_refr.h" 37 | #include "src/lv_core/lv_disp.h" 38 | 39 | #include "src/lv_themes/lv_theme.h" 40 | 41 | #include "src/lv_font/lv_font.h" 42 | #include "src/lv_font/lv_font_loader.h" 43 | #include "src/lv_font/lv_font_fmt_txt.h" 44 | #include "src/lv_misc/lv_printf.h" 45 | 46 | #include "src/lv_widgets/lv_btn.h" 47 | #include "src/lv_widgets/lv_imgbtn.h" 48 | #include "src/lv_widgets/lv_img.h" 49 | #include "src/lv_widgets/lv_label.h" 50 | #include "src/lv_widgets/lv_line.h" 51 | #include "src/lv_widgets/lv_page.h" 52 | #include "src/lv_widgets/lv_cont.h" 53 | #include "src/lv_widgets/lv_list.h" 54 | #include "src/lv_widgets/lv_chart.h" 55 | #include "src/lv_widgets/lv_table.h" 56 | #include "src/lv_widgets/lv_checkbox.h" 57 | #include "src/lv_widgets/lv_cpicker.h" 58 | #include "src/lv_widgets/lv_bar.h" 59 | #include "src/lv_widgets/lv_slider.h" 60 | #include "src/lv_widgets/lv_led.h" 61 | #include "src/lv_widgets/lv_btnmatrix.h" 62 | #include "src/lv_widgets/lv_keyboard.h" 63 | #include "src/lv_widgets/lv_dropdown.h" 64 | #include "src/lv_widgets/lv_roller.h" 65 | #include "src/lv_widgets/lv_textarea.h" 66 | #include "src/lv_widgets/lv_canvas.h" 67 | #include "src/lv_widgets/lv_win.h" 68 | #include "src/lv_widgets/lv_tabview.h" 69 | #include "src/lv_widgets/lv_tileview.h" 70 | #include "src/lv_widgets/lv_msgbox.h" 71 | #include "src/lv_widgets/lv_objmask.h" 72 | #include "src/lv_widgets/lv_gauge.h" 73 | #include "src/lv_widgets/lv_linemeter.h" 74 | #include "src/lv_widgets/lv_switch.h" 75 | #include "src/lv_widgets/lv_arc.h" 76 | #include "src/lv_widgets/lv_spinner.h" 77 | #include "src/lv_widgets/lv_calendar.h" 78 | #include "src/lv_widgets/lv_spinbox.h" 79 | 80 | #include "src/lv_draw/lv_img_cache.h" 81 | 82 | #include "src/lv_api_map.h" 83 | 84 | /********************* 85 | * DEFINES 86 | *********************/ 87 | 88 | /********************** 89 | * TYPEDEFS 90 | **********************/ 91 | 92 | /********************** 93 | * GLOBAL PROTOTYPES 94 | **********************/ 95 | 96 | /********************** 97 | * MACROS 98 | **********************/ 99 | 100 | /** Gives 1 if the x.y.z version is supported in the current version 101 | * Usage: 102 | * 103 | * - Require v6 104 | * #if LV_VERSION_CHECK(6,0,0) 105 | * new_func_in_v6(); 106 | * #endif 107 | * 108 | * 109 | * - Require at least v5.3 110 | * #if LV_VERSION_CHECK(5,3,0) 111 | * new_feature_from_v5_3(); 112 | * #endif 113 | * 114 | * 115 | * - Require v5.3.2 bugfixes 116 | * #if LV_VERSION_CHECK(5,3,2) 117 | * bugfix_in_v5_3_2(); 118 | * #endif 119 | * 120 | * */ 121 | #define LV_VERSION_CHECK(x,y,z) (x == LVGL_VERSION_MAJOR && (y < LVGL_VERSION_MINOR || (y == LVGL_VERSION_MINOR && z <= LVGL_VERSION_PATCH))) 122 | 123 | /** 124 | * Wrapper functions for VERSION macros 125 | */ 126 | 127 | static inline int lv_version_major(void) 128 | { 129 | return LVGL_VERSION_MAJOR; 130 | } 131 | 132 | static inline int lv_version_minor(void) 133 | { 134 | return LVGL_VERSION_MINOR; 135 | } 136 | 137 | static inline int lv_version_patch(void) 138 | { 139 | return LVGL_VERSION_PATCH; 140 | } 141 | 142 | static inline const char *lv_version_info(void) 143 | { 144 | return LVGL_VERSION_INFO; 145 | } 146 | 147 | #ifdef __cplusplus 148 | } 149 | #endif 150 | 151 | #endif /*LVGL_H*/ 152 | -------------------------------------------------------------------------------- /lib/lvgl/lvgl.mk: -------------------------------------------------------------------------------- 1 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core/lv_core.mk 2 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal/lv_hal.mk 3 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets/lv_widgets.mk 4 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font/lv_font.mk 5 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc/lv_misc.mk 6 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes/lv_themes.mk 7 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw/lv_draw.mk 8 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu/lv_gpu.mk 9 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_core/lv_core.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_group.c 2 | CSRCS += lv_indev.c 3 | CSRCS += lv_disp.c 4 | CSRCS += lv_obj.c 5 | CSRCS += lv_refr.c 6 | CSRCS += lv_style.c 7 | 8 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core 9 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core 10 | 11 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core" 12 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_core/lv_refr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_refr.h 3 | * 4 | */ 5 | 6 | #ifndef LV_REFR_H 7 | #define LV_REFR_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_obj.h" 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | #define LV_REFR_TASK_PRIO LV_TASK_PRIO_MID 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * STATIC PROTOTYPES 31 | **********************/ 32 | 33 | /********************** 34 | * STATIC VARIABLES 35 | **********************/ 36 | 37 | /********************** 38 | * MACROS 39 | **********************/ 40 | 41 | /********************** 42 | * GLOBAL FUNCTIONS 43 | **********************/ 44 | 45 | /** 46 | * Initialize the screen refresh subsystem 47 | */ 48 | void _lv_refr_init(void); 49 | 50 | /** 51 | * Redraw the invalidated areas now. 52 | * Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process 53 | * can prevent the call of `lv_task_handler`. In this case if the GUI is updated in the process 54 | * (e.g. progress bar) this function can be called when the screen should be updated. 55 | * @param disp pointer to display to refresh. NULL to refresh all displays. 56 | */ 57 | void lv_refr_now(lv_disp_t * disp); 58 | 59 | /** 60 | * Invalidate an area on display to redraw it 61 | * @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas) 62 | * @param disp pointer to display where the area should be invalidated (NULL can be used if there is 63 | * only one display) 64 | */ 65 | void _lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p); 66 | 67 | /** 68 | * Get the display which is being refreshed 69 | * @return the display being refreshed 70 | */ 71 | lv_disp_t * _lv_refr_get_disp_refreshing(void); 72 | 73 | /** 74 | * Set the display which is being refreshed. 75 | * It shouldn't be used directly by the user. 76 | * It can be used to trick the drawing functions about there is an active display. 77 | * @param the display being refreshed 78 | */ 79 | void _lv_refr_set_disp_refreshing(lv_disp_t * disp); 80 | 81 | #if LV_USE_PERF_MONITOR 82 | /** 83 | * Get the average FPS since start up 84 | * @return the average FPS 85 | */ 86 | uint32_t lv_refr_get_fps_avg(void); 87 | #endif 88 | 89 | /** 90 | * Called periodically to handle the refreshing 91 | * @param task pointer to the task itself 92 | */ 93 | void _lv_disp_refr_task(lv_task_t * task); 94 | 95 | /********************** 96 | * STATIC FUNCTIONS 97 | **********************/ 98 | 99 | #ifdef __cplusplus 100 | } /* extern "C" */ 101 | #endif 102 | 103 | #endif /*LV_REFR_H*/ 104 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_H 7 | #define LV_DRAW_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #include "../lv_core/lv_style.h" 19 | #include "../lv_misc/lv_txt.h" 20 | #include "lv_img_decoder.h" 21 | 22 | #include "lv_draw_rect.h" 23 | #include "lv_draw_label.h" 24 | #include "lv_draw_img.h" 25 | #include "lv_draw_line.h" 26 | #include "lv_draw_triangle.h" 27 | #include "lv_draw_arc.h" 28 | #include "lv_draw_blend.h" 29 | #include "lv_draw_mask.h" 30 | 31 | /********************* 32 | * DEFINES 33 | *********************/ 34 | 35 | /********************** 36 | * TYPEDEFS 37 | **********************/ 38 | 39 | /********************** 40 | * GLOBAL PROTOTYPES 41 | **********************/ 42 | 43 | /********************** 44 | * GLOBAL VARIABLES 45 | **********************/ 46 | 47 | /********************** 48 | * MACROS 49 | **********************/ 50 | 51 | /********************** 52 | * POST INCLUDES 53 | *********************/ 54 | 55 | #ifdef __cplusplus 56 | } /* extern "C" */ 57 | #endif 58 | 59 | #endif /*LV_DRAW_H*/ 60 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_draw_mask.c 2 | CSRCS += lv_draw_blend.c 3 | CSRCS += lv_draw_rect.c 4 | CSRCS += lv_draw_label.c 5 | CSRCS += lv_draw_line.c 6 | CSRCS += lv_draw_img.c 7 | CSRCS += lv_draw_arc.c 8 | CSRCS += lv_draw_triangle.c 9 | CSRCS += lv_img_decoder.c 10 | CSRCS += lv_img_cache.c 11 | CSRCS += lv_img_buf.c 12 | 13 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw 14 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw 15 | 16 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw" 17 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw_arc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_arc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_ARC_H 7 | #define LV_DRAW_ARC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw_line.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw an arc. (Can draw pie too with great thickness.) 32 | * @param center_x the x coordinate of the center of the arc 33 | * @param center_y the y coordinate of the center of the arc 34 | * @param radius the radius of the arc 35 | * @param mask the arc will be drawn only in this mask 36 | * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) 37 | * @param end_angle the end angle of the arc 38 | * @param clip_area the arc will be drawn only in this area 39 | * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable 40 | */ 41 | void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, 42 | const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc); 43 | 44 | /********************** 45 | * MACROS 46 | **********************/ 47 | 48 | #ifdef __cplusplus 49 | } /* extern "C" */ 50 | #endif 51 | 52 | #endif /*LV_DRAW_ARC*/ 53 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw_blend.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_blend.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_BLEND_H 7 | #define LV_DRAW_BLEND_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_misc/lv_color.h" 17 | #include "../lv_misc/lv_area.h" 18 | #include "lv_draw_mask.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | enum { 28 | LV_BLEND_MODE_NORMAL, 29 | #if LV_USE_BLEND_MODES 30 | LV_BLEND_MODE_ADDITIVE, 31 | LV_BLEND_MODE_SUBTRACTIVE, 32 | #endif 33 | }; 34 | 35 | typedef uint8_t lv_blend_mode_t; 36 | 37 | /********************** 38 | * GLOBAL PROTOTYPES 39 | **********************/ 40 | 41 | //! @cond Doxygen_Suppress 42 | LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area, lv_color_t color, 43 | lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode); 44 | 45 | LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, 46 | const lv_color_t * map_buf, 47 | lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode); 48 | 49 | //! @endcond 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #ifdef __cplusplus 55 | } /* extern "C" */ 56 | #endif 57 | 58 | #endif /*LV_DRAW_BLEND_H*/ 59 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw_img.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_img.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_IMG_H 7 | #define LV_DRAW_IMG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_img_decoder.h" 17 | #include "lv_img_buf.h" 18 | #include "../lv_core/lv_style.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * MACROS 26 | **********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | typedef struct { 33 | lv_opa_t opa; 34 | 35 | uint16_t angle; 36 | lv_point_t pivot; 37 | uint16_t zoom; 38 | 39 | lv_opa_t recolor_opa; 40 | lv_color_t recolor; 41 | 42 | lv_blend_mode_t blend_mode; 43 | 44 | uint8_t antialias : 1; 45 | } lv_draw_img_dsc_t; 46 | 47 | /********************** 48 | * GLOBAL PROTOTYPES 49 | **********************/ 50 | 51 | void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc); 52 | /** 53 | * Draw an image 54 | * @param coords the coordinates of the image 55 | * @param mask the image will be drawn only in this area 56 | * @param src pointer to a lv_color_t array which contains the pixels of the image 57 | * @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable 58 | */ 59 | void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc); 60 | 61 | /** 62 | * Get the type of an image source 63 | * @param src pointer to an image source: 64 | * - pointer to an 'lv_img_t' variable (image stored internally and compiled into the code) 65 | * - a path to a file (e.g. "S:/folder/image.bin") 66 | * - or a symbol (e.g. LV_SYMBOL_CLOSE) 67 | * @return type of the image source LV_IMG_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN 68 | */ 69 | lv_img_src_t lv_img_src_get_type(const void * src); 70 | 71 | /** 72 | * Get the pixel size of a color format in bits 73 | * @param cf a color format (`LV_IMG_CF_...`) 74 | * @return the pixel size in bits 75 | */ 76 | uint8_t lv_img_cf_get_px_size(lv_img_cf_t cf); 77 | 78 | /** 79 | * Check if a color format is chroma keyed or not 80 | * @param cf a color format (`LV_IMG_CF_...`) 81 | * @return true: chroma keyed; false: not chroma keyed 82 | */ 83 | bool lv_img_cf_is_chroma_keyed(lv_img_cf_t cf); 84 | 85 | /** 86 | * Check if a color format has alpha channel or not 87 | * @param cf a color format (`LV_IMG_CF_...`) 88 | * @return true: has alpha channel; false: doesn't have alpha channel 89 | */ 90 | bool lv_img_cf_has_alpha(lv_img_cf_t cf); 91 | 92 | #ifdef __cplusplus 93 | } /* extern "C" */ 94 | #endif 95 | 96 | #endif /*LV_DRAW_IMG_H*/ 97 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw_label.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_label.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LABEL_H 7 | #define LV_DRAW_LABEL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_misc/lv_bidi.h" 17 | #include "../lv_misc/lv_txt.h" 18 | #include "../lv_core/lv_style.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | #define LV_DRAW_LABEL_NO_TXT_SEL (0xFFFF) 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | typedef struct { 30 | lv_color_t color; 31 | lv_color_t sel_color; 32 | lv_color_t sel_bg_color; 33 | const lv_font_t * font; 34 | lv_opa_t opa; 35 | lv_style_int_t line_space; 36 | lv_style_int_t letter_space; 37 | uint32_t sel_start; 38 | uint32_t sel_end; 39 | lv_coord_t ofs_x; 40 | lv_coord_t ofs_y; 41 | lv_bidi_dir_t bidi_dir; 42 | lv_txt_flag_t flag; 43 | lv_text_decor_t decor; 44 | lv_blend_mode_t blend_mode; 45 | } lv_draw_label_dsc_t; 46 | 47 | /** Store some info to speed up drawing of very large texts 48 | * It takes a lot of time to get the first visible character because 49 | * all the previous characters needs to be checked to calculate the positions. 50 | * This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line. 51 | * Therefore the calculations can start from here.*/ 52 | typedef struct { 53 | /** Index of the line at `y` coordinate*/ 54 | int32_t line_start; 55 | 56 | /** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/ 57 | int32_t y; 58 | 59 | /** The 'y1' coordinate of the label when the hint was saved. 60 | * Used to invalidate the hint if the label has moved too much. */ 61 | int32_t coord_y; 62 | } lv_draw_label_hint_t; 63 | 64 | /********************** 65 | * GLOBAL PROTOTYPES 66 | **********************/ 67 | 68 | //! @cond Doxygen_Suppress 69 | 70 | LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc); 71 | 72 | /** 73 | * Write a text 74 | * @param coords coordinates of the label 75 | * @param mask the label will be drawn only in this area 76 | * @param dsc pointer to draw descriptor 77 | * @param txt `\0` terminated text to write 78 | * @param hint pointer to a `lv_draw_label_hint_t` variable. 79 | * It is managed by the drawer to speed up the drawing of very long texts (thousands of lines). 80 | */ 81 | LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, 82 | const lv_draw_label_dsc_t * dsc, 83 | const char * txt, lv_draw_label_hint_t * hint); 84 | 85 | //! @endcond 86 | /*********************** 87 | * GLOBAL VARIABLES 88 | ***********************/ 89 | extern const uint8_t _lv_bpp2_opa_table[]; 90 | extern const uint8_t _lv_bpp3_opa_table[]; 91 | extern const uint8_t _lv_bpp1_opa_table[]; 92 | extern const uint8_t _lv_bpp4_opa_table[]; 93 | extern const uint8_t _lv_bpp8_opa_table[]; 94 | 95 | /********************** 96 | * MACROS 97 | **********************/ 98 | 99 | #ifdef __cplusplus 100 | } /* extern "C" */ 101 | #endif 102 | 103 | #endif /*LV_DRAW_LABEL_H*/ 104 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw_line.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_line.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LINE_H 7 | #define LV_DRAW_LINE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_core/lv_style.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | typedef struct { 26 | lv_color_t color; 27 | lv_style_int_t width; 28 | lv_style_int_t dash_width; 29 | lv_style_int_t dash_gap; 30 | lv_opa_t opa; 31 | lv_blend_mode_t blend_mode : 2; 32 | uint8_t round_start : 1; 33 | uint8_t round_end : 1; 34 | uint8_t raw_end : 1; /*Do not bother with perpendicular line ending is it's not visible for any reason*/ 35 | } lv_draw_line_dsc_t; 36 | 37 | /********************** 38 | * GLOBAL PROTOTYPES 39 | **********************/ 40 | 41 | //! @cond Doxygen_Suppress 42 | /** 43 | * Draw a line 44 | * @param point1 first point of the line 45 | * @param point2 second point of the line 46 | * @param clip the line will be drawn only in this area 47 | * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable 48 | */ 49 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, 50 | const lv_draw_line_dsc_t * dsc); 51 | 52 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc); 53 | 54 | //! @endcond 55 | 56 | /********************** 57 | * MACROS 58 | **********************/ 59 | 60 | #ifdef __cplusplus 61 | } /* extern "C" */ 62 | #endif 63 | 64 | #endif /*LV_DRAW_LINE_H*/ 65 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw_rect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_rect.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_RECT_H 7 | #define LV_DRAW_RECT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_core/lv_style.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | typedef struct { 27 | lv_style_int_t radius; 28 | 29 | /*Background*/ 30 | lv_color_t bg_color; 31 | lv_color_t bg_grad_color; 32 | lv_grad_dir_t bg_grad_dir; 33 | lv_style_int_t bg_main_color_stop; 34 | lv_style_int_t bg_grad_color_stop; 35 | lv_opa_t bg_opa; 36 | lv_blend_mode_t bg_blend_mode; 37 | 38 | /*Border*/ 39 | lv_color_t border_color; 40 | lv_style_int_t border_width; 41 | lv_style_int_t border_side; 42 | lv_opa_t border_opa; 43 | lv_blend_mode_t border_blend_mode; 44 | uint8_t border_post : 1; /*There is a border it will be drawn later. */ 45 | 46 | /*Outline*/ 47 | lv_color_t outline_color; 48 | lv_style_int_t outline_width; 49 | lv_style_int_t outline_pad; 50 | lv_opa_t outline_opa; 51 | lv_blend_mode_t outline_blend_mode; 52 | 53 | /*Shadow*/ 54 | lv_color_t shadow_color; 55 | lv_style_int_t shadow_width; 56 | lv_style_int_t shadow_ofs_x; 57 | lv_style_int_t shadow_ofs_y; 58 | lv_style_int_t shadow_spread; 59 | lv_opa_t shadow_opa; 60 | lv_blend_mode_t shadow_blend_mode; 61 | 62 | /*Pattern*/ 63 | const void * pattern_image; 64 | const lv_font_t * pattern_font; 65 | lv_color_t pattern_recolor; 66 | lv_opa_t pattern_opa; 67 | lv_opa_t pattern_recolor_opa; 68 | uint8_t pattern_repeat : 1; 69 | lv_blend_mode_t pattern_blend_mode; 70 | 71 | /*Value*/ 72 | const char * value_str; 73 | const lv_font_t * value_font; 74 | lv_opa_t value_opa; 75 | lv_color_t value_color; 76 | lv_style_int_t value_ofs_x; 77 | lv_style_int_t value_ofs_y; 78 | lv_style_int_t value_letter_space; 79 | lv_style_int_t value_line_space; 80 | lv_align_t value_align; 81 | lv_blend_mode_t value_blend_mode; 82 | } lv_draw_rect_dsc_t; 83 | 84 | /********************** 85 | * GLOBAL PROTOTYPES 86 | **********************/ 87 | 88 | LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc); 89 | 90 | //! @endcond 91 | 92 | /** 93 | * Draw a rectangle 94 | * @param coords the coordinates of the rectangle 95 | * @param mask the rectangle will be drawn only in this mask 96 | * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable 97 | */ 98 | void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc); 99 | 100 | /** 101 | * Draw a pixel 102 | * @param point the coordinates of the point to draw 103 | * @param mask the pixel will be drawn only in this mask 104 | * @param style pointer to a style 105 | */ 106 | void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style); 107 | 108 | /********************** 109 | * MACROS 110 | **********************/ 111 | 112 | #ifdef __cplusplus 113 | } /* extern "C" */ 114 | #endif 115 | 116 | #endif /*LV_DRAW_RECT_H*/ 117 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_draw_triangle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_triangle.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_TRIANGLE_H 7 | #define LV_DRAW_TRIANGLE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw_rect.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw a triangle 32 | * @param points pointer to an array with 3 points 33 | * @param clip_area the triangle will be drawn only in this area 34 | * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable 35 | */ 36 | void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, const lv_draw_rect_dsc_t * draw_dsc); 37 | 38 | /** 39 | * Draw a polygon. Only convex polygons are supported. 40 | * @param points an array of points 41 | * @param point_cnt number of points 42 | * @param clip_area polygon will be drawn only in this area 43 | * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable 44 | */ 45 | void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * mask, 46 | const lv_draw_rect_dsc_t * draw_dsc); 47 | 48 | /********************** 49 | * MACROS 50 | **********************/ 51 | 52 | #ifdef __cplusplus 53 | } /* extern "C" */ 54 | #endif 55 | 56 | #endif /*LV_DRAW_TRIANGLE_H*/ 57 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_draw/lv_img_cache.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_img_cache.h 3 | * 4 | */ 5 | 6 | #ifndef LV_IMG_CACHE_H 7 | #define LV_IMG_CACHE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_img_decoder.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /** 27 | * When loading images from the network it can take a long time to download and decode the image. 28 | * 29 | * To avoid repeating this heavy load images can be cached. 30 | */ 31 | typedef struct { 32 | lv_img_decoder_dsc_t dec_dsc; /**< Image information */ 33 | 34 | /** Count the cache entries's life. Add `time_to_open` to `life` when the entry is used. 35 | * Decrement all lifes by one every in every ::lv_img_cache_open. 36 | * If life == 0 the entry can be reused */ 37 | int32_t life; 38 | } lv_img_cache_entry_t; 39 | 40 | /********************** 41 | * GLOBAL PROTOTYPES 42 | **********************/ 43 | 44 | /** 45 | * Open an image using the image decoder interface and cache it. 46 | * The image will be left open meaning if the image decoder open callback allocated memory then it will remain. 47 | * The image is closed if a new image is opened and the new image takes its place in the cache. 48 | * @param src source of the image. Path to file or pointer to an `lv_img_dsc_t` variable 49 | * @param color The color of the image with `LV_IMG_CF_ALPHA_...` 50 | * @return pointer to the cache entry or NULL if can open the image 51 | */ 52 | lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color); 53 | 54 | /** 55 | * Set the number of images to be cached. 56 | * More cached images mean more opened image at same time which might mean more memory usage. 57 | * E.g. if 20 PNG or JPG images are open in the RAM they consume memory while opened in the cache. 58 | * @param new_entry_cnt number of image to cache 59 | */ 60 | void lv_img_cache_set_size(uint16_t new_slot_num); 61 | 62 | /** 63 | * Invalidate an image source in the cache. 64 | * Useful if the image source is updated therefore it needs to be cached again. 65 | * @param src an image source path to a file or pointer to an `lv_img_dsc_t` variable. 66 | */ 67 | void lv_img_cache_invalidate_src(const void * src); 68 | 69 | /********************** 70 | * MACROS 71 | **********************/ 72 | 73 | #ifdef __cplusplus 74 | } /* extern "C" */ 75 | #endif 76 | 77 | #endif /*LV_IMG_CACHE_H*/ 78 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_font/lv_font.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_font.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_font.h" 11 | #include "../lv_misc/lv_utils.h" 12 | #include "../lv_misc/lv_log.h" 13 | 14 | /********************* 15 | * DEFINES 16 | *********************/ 17 | 18 | /********************** 19 | * TYPEDEFS 20 | **********************/ 21 | 22 | /********************** 23 | * STATIC PROTOTYPES 24 | **********************/ 25 | 26 | /********************** 27 | * STATIC VARIABLES 28 | **********************/ 29 | 30 | /********************** 31 | * GLOBAL PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | /********************** 39 | * GLOBAL FUNCTIONS 40 | **********************/ 41 | 42 | /** 43 | * Return with the bitmap of a font. 44 | * @param font_p pointer to a font 45 | * @param letter an UNICODE character code 46 | * @return pointer to the bitmap of the letter 47 | */ 48 | const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter) 49 | { 50 | return font_p->get_glyph_bitmap(font_p, letter); 51 | } 52 | 53 | /** 54 | * Get the descriptor of a glyph 55 | * @param font_p pointer to font 56 | * @param dsc_out store the result descriptor here 57 | * @param letter an UNICODE letter code 58 | * @return true: descriptor is successfully loaded into `dsc_out`. 59 | * false: the letter was not found, no data is loaded to `dsc_out` 60 | */ 61 | bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, 62 | uint32_t letter_next) 63 | { 64 | return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next); 65 | } 66 | 67 | /** 68 | * Get the width of a glyph with kerning 69 | * @param font pointer to a font 70 | * @param letter an UNICODE letter 71 | * @param letter_next the next letter after `letter`. Used for kerning 72 | * @return the width of the glyph 73 | */ 74 | uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next) 75 | { 76 | lv_font_glyph_dsc_t g; 77 | bool ret; 78 | ret = lv_font_get_glyph_dsc(font, &g, letter, letter_next); 79 | if(ret) return g.adv_w; 80 | else return 0; 81 | } 82 | 83 | /********************** 84 | * STATIC FUNCTIONS 85 | **********************/ 86 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_font/lv_font.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_font.c 2 | CSRCS += lv_font_fmt_txt.c 3 | CSRCS += lv_font_loader.c 4 | 5 | CSRCS += lv_font_dejavu_16_persian_hebrew.c 6 | CSRCS += lv_font_montserrat_8.c 7 | CSRCS += lv_font_montserrat_10.c 8 | CSRCS += lv_font_montserrat_12.c 9 | CSRCS += lv_font_montserrat_12_subpx.c 10 | CSRCS += lv_font_montserrat_14.c 11 | CSRCS += lv_font_montserrat_16.c 12 | CSRCS += lv_font_montserrat_18.c 13 | CSRCS += lv_font_montserrat_20.c 14 | CSRCS += lv_font_montserrat_22.c 15 | CSRCS += lv_font_montserrat_24.c 16 | CSRCS += lv_font_montserrat_26.c 17 | CSRCS += lv_font_montserrat_28.c 18 | CSRCS += lv_font_montserrat_28_compressed.c 19 | CSRCS += lv_font_montserrat_30.c 20 | CSRCS += lv_font_montserrat_32.c 21 | CSRCS += lv_font_montserrat_34.c 22 | CSRCS += lv_font_montserrat_36.c 23 | CSRCS += lv_font_montserrat_38.c 24 | CSRCS += lv_font_montserrat_40.c 25 | CSRCS += lv_font_montserrat_42.c 26 | CSRCS += lv_font_montserrat_44.c 27 | CSRCS += lv_font_montserrat_46.c 28 | CSRCS += lv_font_montserrat_48.c 29 | CSRCS += lv_font_simsun_16_cjk.c 30 | CSRCS += lv_font_unscii_8.c 31 | CSRCS += lv_font_unscii_16.c 32 | 33 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font 34 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font 35 | 36 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font" 37 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_font/lv_font_loader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_font_loader.h 3 | * 4 | */ 5 | 6 | #ifndef LV_FONT_LOADER_H 7 | #define LV_FONT_LOADER_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | #if LV_USE_FILESYSTEM 30 | 31 | lv_font_t * lv_font_load(const char * fontName); 32 | void lv_font_free(lv_font_t * font); 33 | 34 | #endif 35 | 36 | /********************** 37 | * MACROS 38 | **********************/ 39 | 40 | #ifdef __cplusplus 41 | } /* extern "C" */ 42 | #endif 43 | 44 | #endif /*LV_FONT_LOADER_H*/ 45 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_gpu/lv_gpu.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_gpu_stm32_dma2d.c 2 | 3 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu 4 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu 5 | 6 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu" 7 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_gpu/lv_gpu_nxp_pxp_osa.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gpu_nxp_pxp_osa.c 3 | * 4 | */ 5 | 6 | /** 7 | * MIT License 8 | * 9 | * Copyright (c) 2020 NXP 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights to 14 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | * the Software, and to permit persons to whom the Software is furnished to do so, 16 | * subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice (including the next paragraph) 19 | * shall be included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 23 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 25 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 26 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | * 28 | */ 29 | 30 | /********************* 31 | * INCLUDES 32 | *********************/ 33 | 34 | #include "../lv_conf_internal.h" 35 | 36 | #if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT 37 | 38 | #include "lv_gpu_nxp_pxp.h" 39 | #include "fsl_pxp.h" 40 | 41 | #if defined(FSL_RTOS_FREE_RTOS) 42 | #include "FreeRTOS.h" 43 | #include "semphr.h" 44 | #endif 45 | 46 | /********************* 47 | * DEFINES 48 | *********************/ 49 | 50 | /********************** 51 | * TYPEDEFS 52 | **********************/ 53 | 54 | /********************** 55 | * STATIC PROTOTYPES 56 | **********************/ 57 | static lv_res_t _lv_gpu_nxp_pxp_interrupt_init(void); 58 | static void _lv_gpu_nxp_pxp_interrupt_deinit(void); 59 | static void _lv_gpu_nxp_pxp_run(void); 60 | 61 | /********************** 62 | * STATIC VARIABLES 63 | **********************/ 64 | 65 | #if defined(FSL_RTOS_FREE_RTOS) 66 | static SemaphoreHandle_t s_pxpIdle; 67 | #else 68 | static volatile bool s_pxpIdle; 69 | #endif 70 | 71 | /********************** 72 | * MACROS 73 | **********************/ 74 | 75 | /********************** 76 | * GLOBAL FUNCTIONS 77 | **********************/ 78 | 79 | /** 80 | * PXP device interrupt handler. Used to check PXP task completion status. 81 | */ 82 | void PXP_IRQHandler(void) 83 | { 84 | #if defined(FSL_RTOS_FREE_RTOS) 85 | BaseType_t taskAwake = pdFALSE; 86 | #endif 87 | 88 | if(kPXP_CompleteFlag & PXP_GetStatusFlags(LV_GPU_NXP_PXP_ID)) { 89 | PXP_ClearStatusFlags(LV_GPU_NXP_PXP_ID, kPXP_CompleteFlag); 90 | #if defined(FSL_RTOS_FREE_RTOS) 91 | xSemaphoreGiveFromISR(s_pxpIdle, &taskAwake); 92 | portYIELD_FROM_ISR(taskAwake); 93 | #else 94 | s_pxpIdle = true; 95 | #endif 96 | 97 | } 98 | } 99 | 100 | /********************** 101 | * STATIC FUNCTIONS 102 | **********************/ 103 | 104 | /** 105 | * PXP interrupt initialization. 106 | */ 107 | static lv_res_t _lv_gpu_nxp_pxp_interrupt_init(void) 108 | { 109 | #if defined(FSL_RTOS_FREE_RTOS) 110 | s_pxpIdle = xSemaphoreCreateBinary(); 111 | if(s_pxpIdle == NULL) { 112 | return LV_RES_INV; 113 | } 114 | 115 | NVIC_SetPriority(LV_GPU_NXP_PXP_IRQ_ID, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1); 116 | #else 117 | s_pxpIdle = true; 118 | #endif 119 | 120 | NVIC_EnableIRQ(LV_GPU_NXP_PXP_IRQ_ID); 121 | 122 | return LV_RES_OK; 123 | } 124 | 125 | /** 126 | * PXP interrupt de-initialization. 127 | */ 128 | static void _lv_gpu_nxp_pxp_interrupt_deinit(void) 129 | { 130 | NVIC_DisableIRQ(LV_GPU_NXP_PXP_IRQ_ID); 131 | #if defined(FSL_RTOS_FREE_RTOS) 132 | vSemaphoreDelete(s_pxpIdle); 133 | #endif 134 | } 135 | 136 | /** 137 | * Function to start PXP job. This function must wait for task complete. 138 | */ 139 | static void _lv_gpu_nxp_pxp_run(void) 140 | { 141 | #if !defined(FSL_RTOS_FREE_RTOS) 142 | s_pxpIdle = false; 143 | #endif 144 | 145 | PXP_EnableInterrupts(LV_GPU_NXP_PXP_ID, kPXP_CompleteInterruptEnable); 146 | PXP_Start(LV_GPU_NXP_PXP_ID); 147 | 148 | #if defined(FSL_RTOS_FREE_RTOS) 149 | if(xSemaphoreTake(s_pxpIdle, portMAX_DELAY) != pdTRUE) { 150 | LV_LOG_ERROR("xSemaphoreTake error. Task halted."); 151 | for(; ;) ; 152 | } 153 | #else 154 | while(s_pxpIdle == false) { 155 | } 156 | #endif 157 | } 158 | 159 | lv_nxp_pxp_cfg_t pxp_default_cfg = { 160 | .pxp_interrupt_init = _lv_gpu_nxp_pxp_interrupt_init, 161 | .pxp_interrupt_deinit = _lv_gpu_nxp_pxp_interrupt_deinit, 162 | .pxp_run = _lv_gpu_nxp_pxp_run 163 | }; 164 | 165 | #endif /* LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT */ 166 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_gpu/lv_gpu_nxp_pxp_osa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gpu_nxp_pxp_osa.h 3 | * 4 | */ 5 | 6 | /** 7 | * MIT License 8 | * 9 | * Copyright (c) 2020 NXP 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights to 14 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | * the Software, and to permit persons to whom the Software is furnished to do so, 16 | * subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice (including the next paragraph) 19 | * shall be included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 23 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 25 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 26 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | * 28 | */ 29 | 30 | #ifndef LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_ 31 | #define LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_ 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #include "../lv_conf_internal.h" 38 | 39 | #if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT 40 | extern lv_nxp_pxp_cfg_t pxp_default_cfg; 41 | #endif 42 | 43 | #ifdef __cplusplus 44 | } /* extern "C" */ 45 | #endif 46 | 47 | #endif /* LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_ */ 48 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_gpu/lv_gpu_stm32_dma2d.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gpu_stm32_dma2d.h 3 | * 4 | */ 5 | 6 | #ifndef LV_GPU_STM32_DMA2D_H 7 | #define LV_GPU_STM32_DMA2D_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_misc/lv_area.h" 17 | #include "../lv_misc/lv_color.h" 18 | #include "../lv_hal/lv_hal_disp.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | #define LV_DMA2D_ARGB8888 0 25 | #define LV_DMA2D_RGB888 1 26 | #define LV_DMA2D_RGB565 2 27 | #define LV_DMA2D_ARGB1555 3 28 | #define LV_DMA2D_ARGB4444 4 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL PROTOTYPES 36 | **********************/ 37 | 38 | /** 39 | * Turn on the peripheral and set output color mode, this only needs to be done once 40 | */ 41 | void lv_gpu_stm32_dma2d_init(void); 42 | 43 | /** 44 | * Fill an area in the buffer with a color 45 | * @param buf a buffer which should be filled 46 | * @param buf_w width of the buffer in pixels 47 | * @param color fill color 48 | * @param fill_w width to fill in pixels (<= buf_w) 49 | * @param fill_h height to fill in pixels 50 | * @note `buf_w - fill_w` is offset to the next line after fill 51 | */ 52 | void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, lv_coord_t fill_w, 53 | lv_coord_t fill_h); 54 | 55 | /** 56 | * Fill an area in the buffer with a color but take into account a mask which describes the opacity of each pixel 57 | * @param buf a buffer which should be filled using a mask 58 | * @param buf_w width of the buffer in pixels 59 | * @param color fill color 60 | * @param mask 0..255 values describing the opacity of the corresponding pixel. It's width is `fill_w` 61 | * @param opa overall opacity. 255 in `mask` should mean this opacity. 62 | * @param fill_w width to fill in pixels (<= buf_w) 63 | * @param fill_h height to fill in pixels 64 | * @note `buf_w - fill_w` is offset to the next line after fill 65 | */ 66 | void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, const lv_opa_t * mask, 67 | lv_opa_t opa, lv_coord_t fill_w, lv_coord_t fill_h); 68 | 69 | /** 70 | * Copy a map (typically RGB image) to a buffer 71 | * @param buf a buffer where map should be copied 72 | * @param buf_w width of the buffer in pixels 73 | * @param map an "image" to copy 74 | * @param map_w width of the map in pixels 75 | * @param copy_w width of the area to copy in pixels (<= buf_w) 76 | * @param copy_h height of the area to copy in pixels 77 | * @note `map_w - fill_w` is offset to the next line after copy 78 | */ 79 | void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_coord_t map_w, 80 | lv_coord_t copy_w, lv_coord_t copy_h); 81 | /** 82 | * Blend a map (e.g. ARGB image or RGB image with opacity) to a buffer 83 | * @param buf a buffer where `map` should be copied 84 | * @param buf_w width of the buffer in pixels 85 | * @param map an "image" to copy 86 | * @param opa opacity of `map` 87 | * @param map_w width of the map in pixels 88 | * @param copy_w width of the area to copy in pixels (<= buf_w) 89 | * @param copy_h height of the area to copy in pixels 90 | * @note `map_w - fill_w` is offset to the next line after copy 91 | */ 92 | void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_opa_t opa, 93 | lv_coord_t map_w, lv_coord_t copy_w, lv_coord_t copy_h); 94 | 95 | /** 96 | * Can be used as `gpu_wait_cb` in display driver to 97 | * let the MCU run while the GPU is working 98 | */ 99 | void lv_gpu_stm32_dma2d_wait_cb(lv_disp_drv_t * drv); 100 | 101 | /********************** 102 | * MACROS 103 | **********************/ 104 | 105 | #ifdef __cplusplus 106 | } /* extern "C" */ 107 | #endif 108 | 109 | #endif /*LV_GPU_STM32_DMA2D_H*/ 110 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_hal/lv_hal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_hal.h 3 | * 4 | */ 5 | 6 | #ifndef LV_HAL_H 7 | #define LV_HAL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_hal_disp.h" 17 | #include "lv_hal_indev.h" 18 | #include "lv_hal_tick.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | #ifdef __cplusplus 37 | } /* extern "C" */ 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_hal/lv_hal.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_hal_disp.c 2 | CSRCS += lv_hal_indev.c 3 | CSRCS += lv_hal_tick.c 4 | 5 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal 6 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal 7 | 8 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal" 9 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_hal/lv_hal_tick.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_hal_tick.c 3 | * Provide access to the system tick with 1 millisecond resolution 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_hal_tick.h" 10 | #include 11 | 12 | #if LV_TICK_CUSTOM == 1 13 | #include LV_TICK_CUSTOM_INCLUDE 14 | #endif 15 | 16 | /********************* 17 | * DEFINES 18 | *********************/ 19 | 20 | /********************** 21 | * TYPEDEFS 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC PROTOTYPES 26 | **********************/ 27 | 28 | /********************** 29 | * STATIC VARIABLES 30 | **********************/ 31 | static uint32_t sys_time = 0; 32 | static volatile uint8_t tick_irq_flag; 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | /********************** 39 | * GLOBAL FUNCTIONS 40 | **********************/ 41 | 42 | /** 43 | * You have to call this function periodically 44 | * @param tick_period the call period of this function in milliseconds 45 | */ 46 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) 47 | { 48 | tick_irq_flag = 0; 49 | sys_time += tick_period; 50 | } 51 | 52 | /** 53 | * Get the elapsed milliseconds since start up 54 | * @return the elapsed milliseconds 55 | */ 56 | uint32_t lv_tick_get(void) 57 | { 58 | #if LV_TICK_CUSTOM == 0 59 | 60 | /* If `lv_tick_inc` is called from an interrupt while `sys_time` is read 61 | * the result might be corrupted. 62 | * This loop detects if `lv_tick_inc` was called while reading `sys_time`. 63 | * If `tick_irq_flag` was cleared in `lv_tick_inc` try to read again 64 | * until `tick_irq_flag` remains `1`. */ 65 | uint32_t result; 66 | do { 67 | tick_irq_flag = 1; 68 | result = sys_time; 69 | } while(!tick_irq_flag); /*Continue until see a non interrupted cycle */ 70 | 71 | return result; 72 | #else 73 | return LV_TICK_CUSTOM_SYS_TIME_EXPR; 74 | #endif 75 | } 76 | 77 | /** 78 | * Get the elapsed milliseconds since a previous time stamp 79 | * @param prev_tick a previous time stamp (return value of lv_tick_get() ) 80 | * @return the elapsed milliseconds since 'prev_tick' 81 | */ 82 | uint32_t lv_tick_elaps(uint32_t prev_tick) 83 | { 84 | uint32_t act_time = lv_tick_get(); 85 | 86 | /*If there is no overflow in sys_time simple subtract*/ 87 | if(act_time >= prev_tick) { 88 | prev_tick = act_time - prev_tick; 89 | } 90 | else { 91 | prev_tick = UINT32_MAX - prev_tick + 1; 92 | prev_tick += act_time; 93 | } 94 | 95 | return prev_tick; 96 | } 97 | 98 | /********************** 99 | * STATIC FUNCTIONS 100 | **********************/ 101 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_hal/lv_hal_tick.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_hal_tick.h 3 | * Provide access to the system tick with 1 millisecond resolution 4 | */ 5 | 6 | #ifndef LV_HAL_TICK_H 7 | #define LV_HAL_TICK_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #include 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | #ifndef LV_ATTRIBUTE_TICK_INC 25 | #define LV_ATTRIBUTE_TICK_INC 26 | #endif 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | //! @cond Doxygen_Suppress 37 | 38 | /** 39 | * You have to call this function periodically 40 | * @param tick_period the call period of this function in milliseconds 41 | */ 42 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period); 43 | 44 | //! @endcond 45 | 46 | /** 47 | * Get the elapsed milliseconds since start up 48 | * @return the elapsed milliseconds 49 | */ 50 | uint32_t lv_tick_get(void); 51 | 52 | /** 53 | * Get the elapsed milliseconds since a previous time stamp 54 | * @param prev_tick a previous time stamp (return value of lv_tick_get() ) 55 | * @return the elapsed milliseconds since 'prev_tick' 56 | */ 57 | uint32_t lv_tick_elaps(uint32_t prev_tick); 58 | 59 | /********************** 60 | * MACROS 61 | **********************/ 62 | 63 | #ifdef __cplusplus 64 | } /* extern "C" */ 65 | #endif 66 | 67 | #endif /*LV_HAL_TICK_H*/ 68 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_async.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_async.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_async.h" 11 | 12 | /********************* 13 | * DEFINES 14 | *********************/ 15 | 16 | /********************** 17 | * TYPEDEFS 18 | **********************/ 19 | 20 | typedef struct _lv_async_info_t { 21 | lv_async_cb_t cb; 22 | void * user_data; 23 | } lv_async_info_t; 24 | 25 | /********************** 26 | * STATIC PROTOTYPES 27 | **********************/ 28 | 29 | static void lv_async_task_cb(lv_task_t * task); 30 | 31 | /********************** 32 | * STATIC VARIABLES 33 | **********************/ 34 | 35 | /********************** 36 | * MACROS 37 | **********************/ 38 | 39 | /********************** 40 | * GLOBAL FUNCTIONS 41 | **********************/ 42 | 43 | lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data) 44 | { 45 | /*Allocate an info structure */ 46 | lv_async_info_t * info = lv_mem_alloc(sizeof(lv_async_info_t)); 47 | 48 | if(info == NULL) 49 | return LV_RES_INV; 50 | 51 | /* Create a new task */ 52 | /* Use highest priority so that it will run before a refresh */ 53 | lv_task_t * task = lv_task_create(lv_async_task_cb, 0, LV_TASK_PRIO_HIGHEST, info); 54 | 55 | if(task == NULL) { 56 | lv_mem_free(info); 57 | return LV_RES_INV; 58 | } 59 | 60 | info->cb = async_xcb; 61 | info->user_data = user_data; 62 | 63 | lv_task_set_repeat_count(task, 1); 64 | return LV_RES_OK; 65 | } 66 | 67 | /********************** 68 | * STATIC FUNCTIONS 69 | **********************/ 70 | 71 | static void lv_async_task_cb(lv_task_t * task) 72 | { 73 | lv_async_info_t * info = (lv_async_info_t *)task->user_data; 74 | 75 | info->cb(info->user_data); 76 | 77 | lv_mem_free(info); 78 | } 79 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_async.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_async.h 3 | * 4 | */ 5 | 6 | #ifndef LV_ASYNC_H 7 | #define LV_ASYNC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #include "lv_task.h" 18 | #include "lv_types.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /** 29 | * Type for async callback. 30 | */ 31 | typedef void (*lv_async_cb_t)(void *); 32 | 33 | /********************** 34 | * GLOBAL PROTOTYPES 35 | **********************/ 36 | 37 | /** 38 | * Call an asynchronous function the next time lv_task_handler() is run. This function is likely to return 39 | * **before** the call actually happens! 40 | * @param async_xcb a callback which is the task itself. 41 | * (the 'x' in the argument name indicates that its not a fully generic function because it not follows 42 | * the `func_name(object, callback, ...)` convention) 43 | * @param user_data custom parameter 44 | */ 45 | lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data); 46 | 47 | /********************** 48 | * MACROS 49 | **********************/ 50 | 51 | #ifdef __cplusplus 52 | } /* extern "C" */ 53 | #endif 54 | 55 | #endif /*LV_ASYNC_H*/ 56 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_bidi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_bidi.h 3 | * 4 | */ 5 | 6 | #ifndef LV_BIDI_H 7 | #define LV_BIDI_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #include 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | /* Special non printable strong characters. 25 | * They can be inserted to texts to affect the run's direction*/ 26 | #define LV_BIDI_LRO "\xE2\x80\xAD" /*U+202D*/ 27 | #define LV_BIDI_RLO "\xE2\x80\xAE" /*U+202E*/ 28 | 29 | /********************** 30 | * TYPEDEFS 31 | **********************/ 32 | enum { 33 | /*The first 4 values are stored in `lv_obj_t` on 2 bits*/ 34 | LV_BIDI_DIR_LTR = 0x00, 35 | LV_BIDI_DIR_RTL = 0x01, 36 | LV_BIDI_DIR_AUTO = 0x02, 37 | LV_BIDI_DIR_INHERIT = 0x03, 38 | 39 | LV_BIDI_DIR_NEUTRAL = 0x20, 40 | LV_BIDI_DIR_WEAK = 0x21, 41 | }; 42 | 43 | typedef uint8_t lv_bidi_dir_t; 44 | 45 | /********************** 46 | * GLOBAL PROTOTYPES 47 | **********************/ 48 | #if LV_USE_BIDI 49 | 50 | /** 51 | * Convert a text to get the characters in the correct visual order according to 52 | * Unicode Bidirectional Algorithm 53 | * @param str_in the text to process 54 | * @param str_out store the result here. Has the be `strlen(str_in)` length 55 | * @param base_dir `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 56 | */ 57 | void _lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir); 58 | 59 | /** 60 | * Auto-detect the direction of a text based on the first strong character 61 | * @param txt the text to process 62 | * @return `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 63 | */ 64 | lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt); 65 | 66 | /** 67 | * Get the logical position of a character in a line 68 | * @param str_in the input string. Can be only one line. 69 | * @param bidi_txt internally the text is bidi processed which buffer can be get here. 70 | * If not required anymore has to freed with `lv_mem_free()` 71 | * Can be `NULL` is unused 72 | * @param len length of the line in character count 73 | * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 74 | * @param visual_pos the visual character position which logical position should be get 75 | * @param is_rtl tell the char at `visual_pos` is RTL or LTR context 76 | * @return the logical character position 77 | */ 78 | uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, 79 | uint32_t visual_pos, bool * is_rtl); 80 | 81 | /** 82 | * Get the visual position of a character in a line 83 | * @param str_in the input string. Can be only one line. 84 | * @param bidi_txt internally the text is bidi processed which buffer can be get here. 85 | * If not required anymore has to freed with `lv_mem_free()` 86 | * Can be `NULL` is unused 87 | * @param len length of the line in character count 88 | * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 89 | * @param logical_pos the logical character position which visual position should be get 90 | * @param is_rtl tell the char at `logical_pos` is RTL or LTR context 91 | * @return the visual character position 92 | */ 93 | uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, 94 | uint32_t logical_pos, bool * is_rtl); 95 | 96 | /** 97 | * Bidi process a paragraph of text 98 | * @param str_in the string to process 99 | * @param str_out store the result here 100 | * @param len length of the text 101 | * @param base_dir base dir of the text 102 | * @param pos_conv_out an `uint16_t` array to store the related logical position of the character. 103 | * Can be `NULL` is unused 104 | * @param pos_conv_len length of `pos_conv_out` in element count 105 | */ 106 | void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, 107 | uint16_t * pos_conv_out, uint16_t pos_conv_len); 108 | 109 | /********************** 110 | * MACROS 111 | **********************/ 112 | 113 | #endif /*LV_USE_BIDI*/ 114 | 115 | #ifdef __cplusplus 116 | } /* extern "C" */ 117 | #endif 118 | 119 | #endif /*LV_BIDI_H*/ 120 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_debug.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_debug.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_debug.h" 10 | 11 | #if LV_USE_DEBUG 12 | 13 | #include "lv_mem.h" 14 | #include 15 | 16 | /********************* 17 | * DEFINES 18 | *********************/ 19 | #ifndef LV_DEBUG_STR_MAX_LENGTH 20 | #define LV_DEBUG_STR_MAX_LENGTH (1024 * 8) 21 | #endif 22 | 23 | #ifndef LV_DEBUG_STR_MAX_REPEAT 24 | #define LV_DEBUG_STR_MAX_REPEAT 8 25 | #endif 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /********************** 31 | * STATIC PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * STATIC VARIABLES 36 | **********************/ 37 | 38 | /********************** 39 | * MACROS 40 | **********************/ 41 | 42 | /********************** 43 | * GLOBAL FUNCTIONS 44 | **********************/ 45 | 46 | bool lv_debug_check_null(const void * p) 47 | { 48 | if(p) return true; 49 | 50 | return false; 51 | } 52 | 53 | bool lv_debug_check_mem_integrity(void) 54 | { 55 | return lv_mem_test() == LV_RES_OK ? true : false; 56 | } 57 | 58 | bool lv_debug_check_str(const void * str) 59 | { 60 | const uint8_t * s = (const uint8_t *)str; 61 | uint8_t last_byte = 0; 62 | uint32_t rep = 0; 63 | uint32_t i; 64 | 65 | for(i = 0; i < LV_DEBUG_STR_MAX_LENGTH && s[i] != '\0'; i++) { 66 | if(s[i] != last_byte) { 67 | last_byte = s[i]; 68 | rep = 1; 69 | } 70 | else if(s[i] > 0x7F) { 71 | rep++; 72 | if(rep > LV_DEBUG_STR_MAX_REPEAT) { 73 | LV_LOG_WARN("lv_debug_check_str: a non-ASCII char has repeated more than LV_DEBUG_STR_MAX_REPEAT times)"); 74 | return false; 75 | } 76 | } 77 | 78 | if(s[i] < 10) { 79 | LV_LOG_WARN("lv_debug_check_str: invalid char in the string (< 10 value)"); 80 | return false; /*Shouldn't occur in strings*/ 81 | } 82 | } 83 | 84 | if(s[i] == '\0') return true; 85 | 86 | LV_LOG_WARN("lv_debug_check_str: string is longer than LV_DEBUG_STR_MAX_LENGTH"); 87 | return false; 88 | } 89 | 90 | void lv_debug_log_error(const char * msg, uint64_t value) 91 | { 92 | static const char hex[] = "0123456789ABCDEF"; 93 | 94 | size_t msg_len = strlen(msg); 95 | uint32_t value_len = sizeof(unsigned long int); 96 | 97 | if(msg_len < 230) { 98 | char buf[255]; 99 | char * bufp = buf; 100 | 101 | /*Add the function name*/ 102 | _lv_memcpy(bufp, msg, msg_len); 103 | bufp += msg_len; 104 | 105 | /*Add value in hey*/ 106 | *bufp = ' '; 107 | bufp ++; 108 | *bufp = '('; 109 | bufp ++; 110 | *bufp = '0'; 111 | bufp ++; 112 | *bufp = 'x'; 113 | bufp ++; 114 | 115 | int8_t i; 116 | for(i = value_len * 2 - 1; i >= 0; i--) { 117 | uint8_t x = (unsigned long int)((unsigned long int)value >> (i * 4)) & 0xF; 118 | 119 | *bufp = hex[x]; 120 | bufp++; 121 | } 122 | 123 | *bufp = ')'; 124 | bufp ++; 125 | 126 | *bufp = '\0'; 127 | LV_LOG_ERROR(buf); 128 | } 129 | else { 130 | LV_LOG_ERROR(msg); 131 | } 132 | } 133 | 134 | /********************** 135 | * STATIC FUNCTIONS 136 | **********************/ 137 | 138 | #endif /*LV_USE_DEBUG*/ 139 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_debug.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_debug.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DEBUG_H 7 | #define LV_DEBUG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_DEBUG 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * GLOBAL PROTOTYPES 31 | **********************/ 32 | bool lv_debug_check_null(const void * p); 33 | 34 | bool lv_debug_check_mem_integrity(void); 35 | 36 | bool lv_debug_check_str(const void * str); 37 | 38 | void lv_debug_log_error(const char * msg, uint64_t value); 39 | 40 | /********************** 41 | * MACROS 42 | **********************/ 43 | 44 | #ifndef LV_DEBUG_ASSERT 45 | #define LV_DEBUG_ASSERT(expr, msg, value) \ 46 | do { \ 47 | if(!(expr)) { \ 48 | LV_LOG_ERROR(__func__); \ 49 | lv_debug_log_error(msg, (uint64_t)((uintptr_t)value)); \ 50 | while(1); \ 51 | } \ 52 | } while(0) 53 | #endif 54 | 55 | /*---------------- 56 | * CHECKS 57 | *----------------*/ 58 | 59 | #ifndef LV_DEBUG_IS_NULL 60 | #define LV_DEBUG_IS_NULL(p) (lv_debug_check_null(p)) 61 | #endif 62 | 63 | #ifndef LV_DEBUG_CHECK_MEM_INTEGRITY 64 | #define LV_DEBUG_CHECK_MEM_INTEGRITY() (lv_debug_check_mem_integrity()) 65 | #endif 66 | 67 | #ifndef LV_DEBUG_IS_STR 68 | #define LV_DEBUG_IS_STR(str) (lv_debug_check_null(str) && \ 69 | lv_debug_check_str(str)) 70 | #endif 71 | 72 | /*----------------- 73 | * ASSERTS 74 | *-----------------*/ 75 | 76 | /*clang-format off*/ 77 | 78 | #if LV_USE_ASSERT_NULL 79 | # ifndef LV_ASSERT_NULL 80 | # define LV_ASSERT_NULL(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "NULL pointer", p); 81 | # endif 82 | #else 83 | # define LV_ASSERT_NULL(p) 84 | #endif 85 | 86 | #if LV_USE_ASSERT_MEM 87 | # ifndef LV_ASSERT_MEM 88 | # define LV_ASSERT_MEM(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "Out of memory", p); 89 | # endif 90 | #else 91 | # define LV_ASSERT_MEM(p) 92 | #endif 93 | 94 | #if LV_USE_ASSERT_MEM_INTEGRITY 95 | # ifndef LV_ASSERT_MEM_INTEGRITY 96 | # define LV_ASSERT_MEM_INTEGRITY() LV_DEBUG_ASSERT(LV_DEBUG_CHECK_MEM_INTEGRITY(), "Memory integrity error", 0); 97 | # endif 98 | #else 99 | # define LV_ASSERT_MEM_INTEGRITY() 100 | #endif 101 | 102 | #if LV_USE_ASSERT_STR 103 | # ifndef LV_ASSERT_STR 104 | # define LV_ASSERT_STR(str) LV_DEBUG_ASSERT(LV_DEBUG_IS_STR(str), "Strange or invalid string", str); 105 | # endif 106 | #else /* LV_USE_ASSERT_OBJ == 0 */ 107 | # if LV_USE_ASSERT_NULL /*Use at least LV_ASSERT_NULL if enabled*/ 108 | # define LV_ASSERT_STR(str) LV_ASSERT_NULL(str) 109 | # else 110 | # define LV_ASSERT_STR(str) 111 | # endif 112 | #endif 113 | 114 | #else /* LV_USE_DEBUG == 0 */ 115 | 116 | #define LV_DEBUG_ASSERT(expr, msg, value) do{}while(0) 117 | 118 | #define LV_ASSERT_NULL(p) 119 | #define LV_ASSERT_MEM(p) 120 | #define LV_ASSERT_MEM_INTEGRITY() 121 | #define LV_ASSERT_STR(p) 122 | #define LV_ASSERT_OBJ(obj, obj_type) 123 | 124 | #endif /* LV_USE_DEBUG */ 125 | /*clang-format on*/ 126 | 127 | #ifdef __cplusplus 128 | } /* extern "C" */ 129 | #endif 130 | 131 | #endif /*LV_DEBUG_H*/ 132 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_gc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gc.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_gc.h" 11 | #include "string.h" 12 | 13 | /********************* 14 | * DEFINES 15 | *********************/ 16 | 17 | /********************** 18 | * TYPEDEFS 19 | **********************/ 20 | 21 | /********************** 22 | * STATIC PROTOTYPES 23 | **********************/ 24 | 25 | /********************** 26 | * STATIC VARIABLES 27 | **********************/ 28 | 29 | #if(!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0 30 | LV_ROOTS 31 | #endif /* LV_ENABLE_GC */ 32 | 33 | /********************** 34 | * MACROS 35 | **********************/ 36 | 37 | /********************** 38 | * GLOBAL FUNCTIONS 39 | **********************/ 40 | 41 | void _lv_gc_clear_roots(void) 42 | { 43 | #define LV_CLEAR_ROOT(root_type, root_name) _lv_memset_00(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name))); 44 | LV_ITERATE_ROOTS(LV_CLEAR_ROOT) 45 | } 46 | 47 | /********************** 48 | * STATIC FUNCTIONS 49 | **********************/ 50 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_gc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_GC_H 7 | #define LV_GC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include 18 | #include "lv_mem.h" 19 | #include "lv_ll.h" 20 | #include "lv_task.h" 21 | #include "../lv_draw/lv_img_cache.h" 22 | #include "../lv_draw/lv_draw_mask.h" 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | #define LV_ITERATE_ROOTS(f) \ 29 | f(lv_ll_t, _lv_task_ll) /*Linked list to store the lv_tasks*/ \ 30 | f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \ 31 | f(lv_ll_t, _lv_indev_ll) /*Linked list of input device*/ \ 32 | f(lv_ll_t, _lv_drv_ll) \ 33 | f(lv_ll_t, _lv_file_ll) \ 34 | f(lv_ll_t, _lv_anim_ll) \ 35 | f(lv_ll_t, _lv_group_ll) \ 36 | f(lv_ll_t, _lv_img_defoder_ll) \ 37 | f(lv_ll_t, _lv_obj_style_trans_ll) \ 38 | f(lv_img_cache_entry_t*, _lv_img_cache_array) \ 39 | f(lv_task_t*, _lv_task_act) \ 40 | f(lv_mem_buf_arr_t , _lv_mem_buf) \ 41 | f(_lv_draw_mask_saved_arr_t , _lv_draw_mask_list) \ 42 | f(void * , _lv_theme_material_styles) \ 43 | f(void * , _lv_theme_template_styles) \ 44 | f(void * , _lv_theme_mono_styles) \ 45 | f(void * , _lv_theme_empty_styles) \ 46 | f(uint8_t *, _lv_font_decompr_buf) \ 47 | 48 | #define LV_DEFINE_ROOT(root_type, root_name) root_type root_name; 49 | #define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT) 50 | 51 | #if LV_ENABLE_GC == 1 52 | #if LV_MEM_CUSTOM != 1 53 | #error "GC requires CUSTOM_MEM" 54 | #endif /* LV_MEM_CUSTOM */ 55 | #include LV_GC_INCLUDE 56 | #else /* LV_ENABLE_GC */ 57 | #define LV_GC_ROOT(x) x 58 | #define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name; 59 | LV_ITERATE_ROOTS(LV_EXTERN_ROOT) 60 | #endif /* LV_ENABLE_GC */ 61 | 62 | /********************** 63 | * TYPEDEFS 64 | **********************/ 65 | 66 | /********************** 67 | * GLOBAL PROTOTYPES 68 | **********************/ 69 | 70 | void _lv_gc_clear_roots(void); 71 | 72 | /********************** 73 | * MACROS 74 | **********************/ 75 | 76 | #ifdef __cplusplus 77 | } /* extern "C" */ 78 | #endif 79 | 80 | #endif /*LV_GC_H*/ 81 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_log.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_log.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_log.h" 10 | #if LV_USE_LOG 11 | 12 | #include 13 | #include 14 | #include "lv_printf.h" 15 | 16 | #if LV_LOG_PRINTF 17 | #include 18 | #endif 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * STATIC PROTOTYPES 30 | **********************/ 31 | 32 | /********************** 33 | * STATIC VARIABLES 34 | **********************/ 35 | static lv_log_print_g_cb_t custom_print_cb; 36 | 37 | /********************** 38 | * MACROS 39 | **********************/ 40 | 41 | /********************** 42 | * GLOBAL FUNCTIONS 43 | **********************/ 44 | 45 | /** 46 | * Register custom print/write function to call when a log is added. 47 | * It can format its "File path", "Line number" and "Description" as required 48 | * and send the formatted log message to a console or serial port. 49 | * @param print_cb a function pointer to print a log 50 | */ 51 | void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb) 52 | { 53 | custom_print_cb = print_cb; 54 | } 55 | 56 | /** 57 | * Add a log 58 | * @param level the level of log. (From `lv_log_level_t` enum) 59 | * @param file name of the file when the log added 60 | * @param line line number in the source code where the log added 61 | * @param func name of the function when the log added 62 | * @param format printf-like format string 63 | * @param ... parameters for `format` 64 | */ 65 | void _lv_log_add(lv_log_level_t level, const char * file, int line, const char * func, const char * format, ...) 66 | { 67 | if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/ 68 | 69 | if(level >= LV_LOG_LEVEL) { 70 | va_list args; 71 | va_start(args, format); 72 | char buf[256]; 73 | lv_vsnprintf(buf, sizeof(buf), format, args); 74 | va_end(args); 75 | 76 | #if LV_LOG_PRINTF 77 | /*Use only the file name not the path*/ 78 | size_t p; 79 | for(p = strlen(file); p > 0; p--) { 80 | if(file[p] == '/' || file[p] == '\\') { 81 | p++; /*Skip the slash*/ 82 | break; 83 | } 84 | } 85 | 86 | static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"}; 87 | printf("%s: %s \t(%s #%d %s())\n", lvl_prefix[level], buf, &file[p], line, func); 88 | #else 89 | if(custom_print_cb) custom_print_cb(level, file, line, func, buf); 90 | #endif 91 | } 92 | } 93 | 94 | /********************** 95 | * STATIC FUNCTIONS 96 | **********************/ 97 | 98 | #endif /*LV_USE_LOG*/ 99 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_log.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LOG_H 7 | #define LV_LOG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/ 24 | 25 | #define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/ 26 | #define LV_LOG_LEVEL_INFO 1 /**< Log important events*/ 27 | #define LV_LOG_LEVEL_WARN 2 /**< Log if something unwanted happened but didn't caused problem*/ 28 | #define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/ 29 | #define LV_LOG_LEVEL_USER 4 /**< Custom logs from the user*/ 30 | #define LV_LOG_LEVEL_NONE 5 /**< Do not log anything*/ 31 | #define _LV_LOG_LEVEL_NUM 6 /**< Number of log levels */ 32 | 33 | LV_EXPORT_CONST_INT(LV_LOG_LEVEL_TRACE); 34 | LV_EXPORT_CONST_INT(LV_LOG_LEVEL_INFO); 35 | LV_EXPORT_CONST_INT(LV_LOG_LEVEL_WARN); 36 | LV_EXPORT_CONST_INT(LV_LOG_LEVEL_ERROR); 37 | LV_EXPORT_CONST_INT(LV_LOG_LEVEL_USER); 38 | LV_EXPORT_CONST_INT(LV_LOG_LEVEL_NONE); 39 | 40 | typedef int8_t lv_log_level_t; 41 | 42 | #if LV_USE_LOG 43 | /********************** 44 | * TYPEDEFS 45 | **********************/ 46 | 47 | /** 48 | * Log print function. Receives "Log Level", "File path", "Line number", "Function name" and "Description". 49 | */ 50 | typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char *, uint32_t, const char *, const char *); 51 | 52 | /********************** 53 | * GLOBAL PROTOTYPES 54 | **********************/ 55 | 56 | /** 57 | * Register custom print/write function to call when a log is added. 58 | * It can format its "File path", "Line number" and "Description" as required 59 | * and send the formatted log message to a console or serial port. 60 | * @param print_cb a function pointer to print a log 61 | */ 62 | void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb); 63 | 64 | /** 65 | * Add a log 66 | * @param level the level of log. (From `lv_log_level_t` enum) 67 | * @param file name of the file when the log added 68 | * @param line line number in the source code where the log added 69 | * @param func name of the function when the log added 70 | * @param format printf-like format string 71 | * @param ... parameters for `format` 72 | */ 73 | void _lv_log_add(lv_log_level_t level, const char * file, int line, const char * func, const char * format, ...); 74 | 75 | /********************** 76 | * MACROS 77 | **********************/ 78 | 79 | #if LV_LOG_LEVEL <= LV_LOG_LEVEL_TRACE 80 | #define LV_LOG_TRACE(...) _lv_log_add(LV_LOG_LEVEL_TRACE, __FILE__, __LINE__, __func__, __VA_ARGS__); 81 | #else 82 | #define LV_LOG_TRACE(...) 83 | #endif 84 | 85 | #if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO 86 | #define LV_LOG_INFO(...) _lv_log_add(LV_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__); 87 | #else 88 | #define LV_LOG_INFO(...) 89 | #endif 90 | 91 | #if LV_LOG_LEVEL <= LV_LOG_LEVEL_WARN 92 | #define LV_LOG_WARN(...) _lv_log_add(LV_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__); 93 | #else 94 | #define LV_LOG_WARN(...) 95 | #endif 96 | 97 | #if LV_LOG_LEVEL <= LV_LOG_LEVEL_ERROR 98 | #define LV_LOG_ERROR(...) _lv_log_add(LV_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__); 99 | #else 100 | #define LV_LOG_ERROR(...) 101 | #endif 102 | 103 | #if LV_LOG_LEVEL <= LV_LOG_LEVEL_USER 104 | #define LV_LOG_USER(...) _lv_log_add(LV_LOG_LEVEL_USER, __FILE__, __LINE__, __func__, __VA_ARGS__); 105 | #else 106 | #define LV_LOG_USER(...) 107 | #endif 108 | 109 | #else /*LV_USE_LOG*/ 110 | 111 | /*Do nothing if `LV_USE_LOG 0`*/ 112 | #define _lv_log_add(level, file, line, ...) 113 | #define LV_LOG_TRACE(...) 114 | #define LV_LOG_INFO(...) 115 | #define LV_LOG_WARN(...) 116 | #define LV_LOG_ERROR(...) 117 | #define LV_LOG_USER(...) 118 | #endif /*LV_USE_LOG*/ 119 | 120 | #ifdef __cplusplus 121 | } /* extern "C" */ 122 | #endif 123 | 124 | #endif /*LV_LOG_H*/ 125 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_math.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_math.h 3 | * 4 | */ 5 | 6 | #ifndef LV_MATH_H 7 | #define LV_MATH_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | #define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b)) 23 | #define LV_MATH_MIN3(a, b, c) (LV_MATH_MIN(LV_MATH_MIN(a,b), c)) 24 | #define LV_MATH_MIN4(a, b, c, d) (LV_MATH_MIN(LV_MATH_MIN(a,b), LV_MATH_MIN(c,d))) 25 | 26 | #define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b)) 27 | #define LV_MATH_MAX3(a, b, c) (LV_MATH_MAX(LV_MATH_MAX(a,b), c)) 28 | #define LV_MATH_MAX4(a, b, c, d) (LV_MATH_MAX(LV_MATH_MAX(a,b), LV_MATH_MAX(c,d))) 29 | 30 | #define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) 31 | 32 | #define LV_MATH_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17) 33 | 34 | #define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0)) 35 | #define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL))) 36 | #define LV_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL))) 37 | #define LV_MAX_OF(t) ((unsigned long) (LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t))) 38 | 39 | #define LV_TRIGO_SIN_MAX 32767 40 | #define LV_TRIGO_SHIFT 15 /**< >> LV_TRIGO_SHIFT to normalize*/ 41 | 42 | #define LV_BEZIER_VAL_MAX 1024 /**< Max time in Bezier functions (not [0..1] to use integers) */ 43 | #define LV_BEZIER_VAL_SHIFT 10 /**< log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/ 44 | 45 | /********************** 46 | * TYPEDEFS 47 | **********************/ 48 | 49 | typedef struct { 50 | uint16_t i; 51 | uint16_t f; 52 | } lv_sqrt_res_t; 53 | 54 | /********************** 55 | * GLOBAL PROTOTYPES 56 | **********************/ 57 | 58 | //! @cond Doxygen_Suppress 59 | /** 60 | * Return with sinus of an angle 61 | * @param angle 62 | * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 63 | */ 64 | LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle); 65 | 66 | //! @endcond 67 | 68 | /** 69 | * Calculate a value of a Cubic Bezier function. 70 | * @param t time in range of [0..LV_BEZIER_VAL_MAX] 71 | * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] 72 | * @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX] 73 | * @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX] 74 | * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] 75 | * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] 76 | */ 77 | uint32_t _lv_bezier3(uint32_t t, uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3); 78 | 79 | /** 80 | * Calculate the atan2 of a vector. 81 | * @param x 82 | * @param y 83 | * @return the angle in degree calculated from the given parameters in range of [0..360] 84 | */ 85 | uint16_t _lv_atan2(int x, int y); 86 | 87 | //! @cond Doxygen_Suppress 88 | 89 | /** 90 | * Get the square root of a number 91 | * @param x integer which square root should be calculated 92 | * @param q store the result here. q->i: integer part, q->f: fractional part in 1/256 unit 93 | * @param mask: optional to skip some iterations if the magnitude of the root is known. 94 | * Set to 0x8000 by default. 95 | * If root < 16: mask = 0x80 96 | * If root < 256: mask = 0x800 97 | * Else: mask = 0x8000 98 | */ 99 | LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask); 100 | 101 | //! @endcond 102 | 103 | /** 104 | * Calculate the integer exponents. 105 | * @param base 106 | * @param power 107 | * @return base raised to the power exponent 108 | */ 109 | int64_t _lv_pow(int64_t base, int8_t exp); 110 | 111 | /** 112 | * Get the mapped of a number given an input and output range 113 | * @param x integer which mapped value should be calculated 114 | * @param min_in min input range 115 | * @param max_in max input range 116 | * @param min_out max output range 117 | * @param max_out max output range 118 | * @return the mapped number 119 | */ 120 | int32_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max); 121 | 122 | /********************** 123 | * MACROS 124 | **********************/ 125 | 126 | #ifdef __cplusplus 127 | } /* extern "C" */ 128 | #endif 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_misc.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_area.c 2 | CSRCS += lv_task.c 3 | CSRCS += lv_fs.c 4 | CSRCS += lv_anim.c 5 | CSRCS += lv_mem.c 6 | CSRCS += lv_ll.c 7 | CSRCS += lv_color.c 8 | CSRCS += lv_txt.c 9 | CSRCS += lv_txt_ap.c 10 | CSRCS += lv_math.c 11 | CSRCS += lv_log.c 12 | CSRCS += lv_gc.c 13 | CSRCS += lv_utils.c 14 | CSRCS += lv_async.c 15 | CSRCS += lv_printf.c 16 | CSRCS += lv_bidi.c 17 | CSRCS += lv_debug.c 18 | 19 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc 20 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc 21 | 22 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc" 23 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_printf.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // \author (c) Marco Paland (info@paland.com) 3 | // 2014-2019, PALANDesign Hannover, Germany 4 | // 5 | // \license The MIT License (MIT) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // \brief Tiny printf, sprintf and snprintf implementation, optimized for speed on 26 | // embedded systems with a very limited resources. 27 | // Use this instead of bloated standard/newlib printf. 28 | // These routines are thread safe and reentrant. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _LV_PRINTF_H_ 33 | #define _LV_PRINTF_H_ 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #include "../lv_conf_internal.h" 40 | 41 | #if LV_SPRINTF_CUSTOM == 0 42 | 43 | #include 44 | #include 45 | 46 | /** 47 | * Tiny snprintf/vsnprintf implementation 48 | * \param buffer A pointer to the buffer where to store the formatted string 49 | * \param count The maximum number of characters to store in the buffer, including a terminating null character 50 | * \param format A string that specifies the format of the output 51 | * \param va A value identifying a variable arguments list 52 | * \return The number of characters that COULD have been written into the buffer, not counting the terminating 53 | * null character. A value equal or larger than count indicates truncation. Only when the returned value 54 | * is non-negative and less than count, the string has been completely written. 55 | */ 56 | int lv_snprintf(char * buffer, size_t count, const char * format, ...); 57 | int lv_vsnprintf(char * buffer, size_t count, const char * format, va_list va); 58 | 59 | #else 60 | #include LV_SPRINTF_INCLUDE 61 | #endif 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif // _LV_PRINTF_H_ 68 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_templ.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | /********************* 11 | * DEFINES 12 | *********************/ 13 | 14 | /********************** 15 | * TYPEDEFS 16 | **********************/ 17 | 18 | /* This typedef exists purely to keep -Wpedantic happy when the file is empty. */ 19 | /* It can be removed. */ 20 | typedef int _keep_pedantic_happy; 21 | 22 | /********************** 23 | * STATIC PROTOTYPES 24 | **********************/ 25 | 26 | /********************** 27 | * STATIC VARIABLES 28 | **********************/ 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL FUNCTIONS 36 | **********************/ 37 | 38 | /********************** 39 | * STATIC FUNCTIONS 40 | **********************/ 41 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEMPL_H 7 | #define LV_TEMPL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | /********************** 30 | * MACROS 31 | **********************/ 32 | 33 | #ifdef __cplusplus 34 | } /* extern "C" */ 35 | #endif 36 | 37 | #endif /*LV_TEMPL_H*/ 38 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_txt_ap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_txt_ap.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TXT_AP_H 7 | #define LV_TXT_AP_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include "lv_txt.h" 18 | #include "../lv_draw/lv_draw.h" 19 | 20 | #if LV_USE_ARABIC_PERSIAN_CHARS == 1 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | #define LV_UNDEF_ARABIC_PERSIAN_CHARS (UINT32_MAX) 27 | #define LV_AP_ALPHABET_BASE_CODE 0x0622 28 | #define LV_AP_END_CHARS_LIST {0,0,0,0,0,{0,0}} 29 | /********************** 30 | * TYPEDEFS 31 | **********************/ 32 | typedef struct { 33 | uint8_t char_offset; 34 | uint16_t char_end_form; 35 | int8_t char_begining_form_offset; 36 | int8_t char_middle_form_offset; 37 | int8_t char_isolated_form_offset; 38 | struct { 39 | uint8_t conj_to_previous; 40 | uint8_t conj_to_next; 41 | } ap_chars_conjunction; 42 | } ap_chars_map_t; 43 | 44 | /********************** 45 | * GLOBAL PROTOTYPES 46 | **********************/ 47 | uint32_t _lv_txt_ap_calc_bytes_cnt(const char * txt); 48 | void _lv_txt_ap_proc(const char * txt, char * txt_out); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif // LV_USE_ARABIC_PERSIAN_CHARS 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_TXT_AP_H*/ 61 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_types.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TYPES_H 7 | #define LV_TYPES_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | #if defined(__cplusplus) || __STDC_VERSION__ >= 199901L // If c99 or newer, use stdint.h to determine arch size 22 | #include 23 | #endif 24 | 25 | // If __UINTPTR_MAX__ or UINTPTR_MAX are available, use them to determine arch size 26 | #if defined(__UINTPTR_MAX__) && __UINTPTR_MAX__ > 0xFFFFFFFF 27 | #define LV_ARCH_64 28 | 29 | #elif defined(UINTPTR_MAX) && UINTPTR_MAX > 0xFFFFFFFF 30 | #define LV_ARCH_64 31 | 32 | // Otherwise use compiler-dependent means to determine arch size 33 | #elif defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined (__aarch64__) 34 | #define LV_ARCH_64 35 | 36 | #endif 37 | 38 | /********************** 39 | * TYPEDEFS 40 | **********************/ 41 | 42 | /** 43 | * LVGL error codes. 44 | */ 45 | enum { 46 | LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action 47 | function or an operation was failed*/ 48 | LV_RES_OK, /*The object is valid (no deleted) after the action*/ 49 | }; 50 | typedef uint8_t lv_res_t; 51 | 52 | #if defined(__cplusplus) || __STDC_VERSION__ >= 199901L 53 | // If c99 or newer, use the definition of uintptr_t directly from 54 | typedef uintptr_t lv_uintptr_t; 55 | 56 | #else 57 | 58 | // Otherwise, use the arch size determination 59 | #ifdef LV_ARCH_64 60 | typedef uint64_t lv_uintptr_t; 61 | #else 62 | typedef uint32_t lv_uintptr_t; 63 | #endif 64 | 65 | #endif 66 | 67 | /********************** 68 | * GLOBAL PROTOTYPES 69 | **********************/ 70 | 71 | /********************** 72 | * MACROS 73 | **********************/ 74 | 75 | #define LV_UNUSED(x) ((void) x) 76 | 77 | #define _LV_CONCAT(x, y) x ## y 78 | #define LV_CONCAT(x, y) _LV_CONCAT(x, y) 79 | 80 | #define _LV_CONCAT3(x, y, z) x ## y ## z 81 | #define LV_CONCAT3(x, y, z) _LV_CONCAT3(x, y, z) 82 | 83 | #ifdef __cplusplus 84 | } /* extern "C" */ 85 | #endif 86 | 87 | #endif /*LV_TYPES_H*/ 88 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_utils.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_utils.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include 10 | 11 | #include "lv_utils.h" 12 | #include "lv_math.h" 13 | #include "lv_printf.h" 14 | #include "lv_txt.h" 15 | 16 | /********************* 17 | * DEFINES 18 | *********************/ 19 | 20 | /********************** 21 | * TYPEDEFS 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC PROTOTYPES 26 | **********************/ 27 | 28 | /********************** 29 | * STATIC VARIABLES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL FUNCTIONS 38 | **********************/ 39 | 40 | /** 41 | * Convert a number to string 42 | * @param num a number 43 | * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) 44 | * @return same as `buf` (just for convenience) 45 | */ 46 | char * _lv_utils_num_to_str(int32_t num, char * buf) 47 | { 48 | if(num == 0) { 49 | buf[0] = '0'; 50 | buf[1] = '\0'; 51 | return buf; 52 | } 53 | int8_t digitCount = 0; 54 | int8_t i = 0; 55 | if(num < 0) { 56 | buf[digitCount++] = '-'; 57 | num = LV_MATH_ABS(num); 58 | ++i; 59 | } 60 | while(num) { 61 | char digit = num % 10; 62 | buf[digitCount++] = digit + 48; 63 | num /= 10; 64 | } 65 | buf[digitCount] = '\0'; 66 | digitCount--; 67 | while(digitCount > i) { 68 | char temp = buf[i]; 69 | buf[i] = buf[digitCount]; 70 | buf[digitCount] = temp; 71 | digitCount--; 72 | i++; 73 | } 74 | return buf; 75 | } 76 | 77 | /** Searches base[0] to base[n - 1] for an item that matches *key. 78 | * 79 | * @note The function cmp must return negative if its first 80 | * argument (the search key) is less that its second (a table entry), 81 | * zero if equal, and positive if greater. 82 | * 83 | * @note Items in the array must be in ascending order. 84 | * 85 | * @param key Pointer to item being searched for 86 | * @param base Pointer to first element to search 87 | * @param n Number of elements 88 | * @param size Size of each element 89 | * @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function 90 | * example) 91 | * 92 | * @return a pointer to a matching item, or NULL if none exists. 93 | */ 94 | void * _lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, 95 | int32_t (*cmp)(const void * pRef, const void * pElement)) 96 | { 97 | const char * middle; 98 | int32_t c; 99 | 100 | for(middle = base; n != 0;) { 101 | middle += (n / 2) * size; 102 | if((c = (*cmp)(key, middle)) > 0) { 103 | n = (n / 2) - ((n & 1) == 0); 104 | base = (middle += size); 105 | } 106 | else if(c < 0) { 107 | n /= 2; 108 | middle = base; 109 | } 110 | else { 111 | return (char *)middle; 112 | } 113 | } 114 | return NULL; 115 | } 116 | 117 | /********************** 118 | * STATIC FUNCTIONS 119 | **********************/ 120 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_misc/lv_utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_utils.h 3 | * 4 | */ 5 | 6 | #ifndef LV_UTILS_H 7 | #define LV_UTILS_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * GLOBAL PROTOTYPES 29 | **********************/ 30 | /** 31 | * Convert a number to string 32 | * @param num a number 33 | * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) 34 | * @return same as `buf` (just for convenience) 35 | */ 36 | char * _lv_utils_num_to_str(int32_t num, char * buf); 37 | 38 | /** Searches base[0] to base[n - 1] for an item that matches *key. 39 | * 40 | * @note The function cmp must return negative if its first 41 | * argument (the search key) is less that its second (a table entry), 42 | * zero if equal, and positive if greater. 43 | * 44 | * @note Items in the array must be in ascending order. 45 | * 46 | * @param key Pointer to item being searched for 47 | * @param base Pointer to first element to search 48 | * @param n Number of elements 49 | * @param size Size of each element 50 | * @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function 51 | * example) 52 | * 53 | * @return a pointer to a matching item, or NULL if none exists. 54 | */ 55 | void * _lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, 56 | int32_t (*cmp)(const void * pRef, const void * pElement)); 57 | 58 | /********************** 59 | * MACROS 60 | **********************/ 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_themes/lv_theme_empty.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_empty.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "../../lvgl.h" /*To see all the widgets*/ 10 | 11 | #if LV_USE_THEME_EMPTY 12 | 13 | #include "../lv_misc/lv_gc.h" 14 | 15 | /********************* 16 | * DEFINES 17 | *********************/ 18 | 19 | /********************** 20 | * TYPEDEFS 21 | **********************/ 22 | typedef struct { 23 | lv_style_t opa_cover; 24 | } theme_styles_t; 25 | 26 | /********************** 27 | * STATIC PROTOTYPES 28 | **********************/ 29 | static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); 30 | 31 | /********************** 32 | * STATIC VARIABLES 33 | **********************/ 34 | static lv_theme_t theme; 35 | static theme_styles_t * styles; 36 | 37 | /********************** 38 | * MACROS 39 | **********************/ 40 | 41 | /********************** 42 | * STATIC FUNCTIONS 43 | **********************/ 44 | 45 | /********************** 46 | * GLOBAL FUNCTIONS 47 | **********************/ 48 | 49 | /** 50 | * Initialize the default 51 | * @param color_primary the primary color of the theme 52 | * @param color_secondary the secondary color for the theme 53 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 54 | * @param font_small pointer to a small font 55 | * @param font_normal pointer to a normal font 56 | * @param font_subtitle pointer to a large font 57 | * @param font_title pointer to a extra large font 58 | * @return a pointer to reference this theme later 59 | */ 60 | lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 61 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 62 | const lv_font_t * font_title) 63 | { 64 | /* This trick is required only to avoid the garbage collection of 65 | * styles' data if LVGL is used in a binding (e.g. Micropython) 66 | * In a general case styles could be simple `static lv_style_t my style` variables*/ 67 | if(styles == NULL) { 68 | styles = lv_mem_alloc(sizeof(theme_styles_t)); 69 | if(styles == NULL) return NULL; 70 | _lv_memset_00(styles, sizeof(theme_styles_t)); 71 | LV_GC_ROOT(_lv_theme_empty_styles) = styles; 72 | } 73 | 74 | theme.color_primary = color_primary; 75 | theme.color_secondary = color_secondary; 76 | theme.font_small = font_small; 77 | theme.font_normal = font_normal; 78 | theme.font_subtitle = font_subtitle; 79 | theme.font_title = font_title; 80 | theme.flags = flags; 81 | 82 | lv_style_reset(&styles->opa_cover); 83 | lv_style_set_bg_opa(&styles->opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER); 84 | 85 | theme.apply_xcb = NULL; 86 | theme.apply_cb = theme_apply; 87 | return &theme; 88 | } 89 | 90 | /********************** 91 | * STATIC FUNCTIONS 92 | **********************/ 93 | 94 | static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) 95 | { 96 | LV_UNUSED(th); 97 | if(name == LV_THEME_SCR) { 98 | lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover); 99 | lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); 100 | } 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_themes/lv_theme_empty.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_empty.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_EMPTY_H 7 | #define LV_THEME_EMPTY_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_EMPTY 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /** 33 | * Initialize the default 34 | * @param color_primary the primary color of the theme 35 | * @param color_secondary the secondary color for the theme 36 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 37 | * @param font_small pointer to a small font 38 | * @param font_normal pointer to a normal font 39 | * @param font_subtitle pointer to a large font 40 | * @param font_title pointer to a extra large font 41 | * @return a pointer to reference this theme later 42 | */ 43 | lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 44 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 45 | const lv_font_t * font_title); 46 | /********************** 47 | * MACROS 48 | **********************/ 49 | 50 | #endif 51 | 52 | #ifdef __cplusplus 53 | } /* extern "C" */ 54 | #endif 55 | 56 | #endif /*LV_THEME_EMPTY_H*/ 57 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_themes/lv_theme_material.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_material.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_MATERIAL_H 7 | #define LV_THEME_MATERIAL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_MATERIAL 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | typedef enum { 24 | LV_THEME_MATERIAL_FLAG_DARK = 0x01, 25 | LV_THEME_MATERIAL_FLAG_LIGHT = 0x02, 26 | LV_THEME_MATERIAL_FLAG_NO_TRANSITION = 0x10, 27 | LV_THEME_MATERIAL_FLAG_NO_FOCUS = 0x20, 28 | } lv_theme_material_flag_t; 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL PROTOTYPES 36 | **********************/ 37 | 38 | /** 39 | * Initialize the default 40 | * @param color_primary the primary color of the theme 41 | * @param color_secondary the secondary color for the theme 42 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 43 | * @param font_small pointer to a small font 44 | * @param font_normal pointer to a normal font 45 | * @param font_subtitle pointer to a large font 46 | * @param font_title pointer to a extra large font 47 | * @return a pointer to reference this theme later 48 | */ 49 | lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 50 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 51 | const lv_font_t * font_title); 52 | /********************** 53 | * MACROS 54 | **********************/ 55 | 56 | #endif 57 | 58 | #ifdef __cplusplus 59 | } /* extern "C" */ 60 | #endif 61 | 62 | #endif /*LV_THEME_MATERIAL_H*/ 63 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_themes/lv_theme_mono.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_mono.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_MONO_H 7 | #define LV_THEME_MONO_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_MONO 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /** 33 | * Initialize the mono theme. 34 | * @param color_primary the primary color of the theme 35 | * @param color_secondary the secondary color for the theme 36 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 37 | * @param font_small pointer to a small font 38 | * @param font_normal pointer to a normal font 39 | * @param font_subtitle pointer to a large font 40 | * @param font_title pointer to a extra large font 41 | * @return a pointer to reference this theme later 42 | */ 43 | lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 44 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 45 | const lv_font_t * font_title); 46 | /********************** 47 | * MACROS 48 | **********************/ 49 | 50 | #endif 51 | 52 | #ifdef __cplusplus 53 | } /* extern "C" */ 54 | #endif 55 | 56 | #endif /*LV_THEME_MONO_H*/ 57 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_themes/lv_theme_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_template.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_TEMPLATE_H 7 | #define LV_THEME_TEMPLATE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_TEMPLATE 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /** 33 | * Initialize the default 34 | * @param color_primary the primary color of the theme 35 | * @param color_secondary the secondary color for the theme 36 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 37 | * @param font_small pointer to a small font 38 | * @param font_normal pointer to a normal font 39 | * @param font_subtitle pointer to a large font 40 | * @param font_title pointer to a extra large font 41 | * @return a pointer to reference this theme later 42 | */ 43 | lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 44 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 45 | const lv_font_t * font_title); 46 | /********************** 47 | * MACROS 48 | **********************/ 49 | 50 | #endif 51 | 52 | #ifdef __cplusplus 53 | } /* extern "C" */ 54 | #endif 55 | 56 | #endif /*LV_THEME_TEMPLATE_H*/ 57 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_themes/lv_themes.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_theme.c 2 | 3 | CSRCS += lv_theme_empty.c 4 | CSRCS += lv_theme_material.c 5 | CSRCS += lv_theme_mono.c 6 | CSRCS += lv_theme_template.c 7 | 8 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes 9 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes 10 | 11 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes" 12 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_widgets/lv_checkbox.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_cb.h 3 | * 4 | */ 5 | 6 | #ifndef LV_CHECKBOX_H 7 | #define LV_CHECKBOX_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_CHECKBOX != 0 19 | 20 | /*Testing of dependencies*/ 21 | #if LV_USE_BTN == 0 22 | #error "lv_cb: lv_btn is required. Enable it in lv_conf.h (LV_USE_BTN 1)" 23 | #endif 24 | 25 | #if LV_USE_LABEL == 0 26 | #error "lv_cb: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)" 27 | #endif 28 | 29 | #include "../lv_core/lv_obj.h" 30 | #include "lv_btn.h" 31 | #include "lv_label.h" 32 | 33 | /********************* 34 | * DEFINES 35 | *********************/ 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | 41 | /*Data of check box*/ 42 | typedef struct { 43 | lv_btn_ext_t bg_btn; /*Ext. of ancestor*/ 44 | /*New data for this type */ 45 | lv_obj_t * bullet; /*Pointer to button*/ 46 | lv_obj_t * label; /*Pointer to label*/ 47 | } lv_checkbox_ext_t; 48 | 49 | /** Checkbox styles. */ 50 | enum { 51 | LV_CHECKBOX_PART_BG = LV_BTN_PART_MAIN, /**< Style of object background. */ 52 | _LV_CHECKBOX_PART_VIRTUAL_LAST, 53 | LV_CHECKBOX_PART_BULLET = _LV_BTN_PART_REAL_LAST, /**< Style of box (released). */ 54 | _LV_CHECKBOX_PART_REAL_LAST 55 | }; 56 | typedef uint8_t lv_checkbox_style_t; 57 | 58 | /********************** 59 | * GLOBAL PROTOTYPES 60 | **********************/ 61 | 62 | /** 63 | * Create a check box objects 64 | * @param par pointer to an object, it will be the parent of the new check box 65 | * @param copy pointer to a check box object, if not NULL then the new object will be copied from it 66 | * @return pointer to the created check box 67 | */ 68 | lv_obj_t * lv_checkbox_create(lv_obj_t * par, const lv_obj_t * copy); 69 | 70 | /*===================== 71 | * Setter functions 72 | *====================*/ 73 | 74 | /** 75 | * Set the text of a check box. `txt` will be copied and may be deallocated 76 | * after this function returns. 77 | * @param cb pointer to a check box 78 | * @param txt the text of the check box. NULL to refresh with the current text. 79 | */ 80 | void lv_checkbox_set_text(lv_obj_t * cb, const char * txt); 81 | 82 | /** 83 | * Set the text of a check box. `txt` must not be deallocated during the life 84 | * of this checkbox. 85 | * @param cb pointer to a check box 86 | * @param txt the text of the check box. NULL to refresh with the current text. 87 | */ 88 | void lv_checkbox_set_text_static(lv_obj_t * cb, const char * txt); 89 | 90 | /** 91 | * Set the state of the check box 92 | * @param cb pointer to a check box object 93 | * @param checked true: make the check box checked; false: make it unchecked 94 | */ 95 | void lv_checkbox_set_checked(lv_obj_t * cb, bool checked); 96 | 97 | /** 98 | * Make the check box inactive (disabled) 99 | * @param cb pointer to a check box object 100 | */ 101 | void lv_checkbox_set_disabled(lv_obj_t * cb); 102 | 103 | /** 104 | * Set the state of a check box 105 | * @param cb pointer to a check box object 106 | * @param state the new state of the check box (from lv_btn_state_t enum) 107 | */ 108 | void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state); 109 | /*===================== 110 | * Getter functions 111 | *====================*/ 112 | 113 | /** 114 | * Get the text of a check box 115 | * @param cb pointer to check box object 116 | * @return pointer to the text of the check box 117 | */ 118 | const char * lv_checkbox_get_text(const lv_obj_t * cb); 119 | 120 | /** 121 | * Get the current state of the check box 122 | * @param cb pointer to a check box object 123 | * @return true: checked; false: not checked 124 | */ 125 | static inline bool lv_checkbox_is_checked(const lv_obj_t * cb) 126 | { 127 | return lv_btn_get_state(cb) == LV_BTN_STATE_RELEASED ? false : true; 128 | } 129 | 130 | /** 131 | * Get whether the check box is inactive or not. 132 | * @param cb pointer to a check box object 133 | * @return true: inactive; false: not inactive 134 | */ 135 | static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb) 136 | { 137 | return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false; 138 | } 139 | 140 | /** 141 | * Get the current state of a check box 142 | * @param cb pointer to a check box object 143 | * @return the state of the check box (from lv_btn_state_t enum) 144 | */ 145 | static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb) 146 | { 147 | return lv_btn_get_state(cb); 148 | } 149 | 150 | /********************** 151 | * MACROS 152 | **********************/ 153 | 154 | #endif /*LV_USE_CHECKBOX*/ 155 | 156 | #ifdef __cplusplus 157 | } /* extern "C" */ 158 | #endif 159 | 160 | #endif /*LV_CHECKBOX_H*/ 161 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_widgets/lv_led.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_led.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LED_H 7 | #define LV_LED_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_LED != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /*Data of led*/ 31 | typedef struct { 32 | /*No inherited ext.*/ 33 | /*New data for this type */ 34 | uint8_t bright; /*Current brightness of the LED (0..255)*/ 35 | } lv_led_ext_t; 36 | 37 | /*Parts of LED*/ 38 | enum { 39 | LV_LED_PART_MAIN = LV_OBJ_PART_MAIN, 40 | }; 41 | typedef uint8_t lv_led_part_t; 42 | 43 | /********************** 44 | * GLOBAL PROTOTYPES 45 | **********************/ 46 | 47 | /** 48 | * Create a led objects 49 | * @param par pointer to an object, it will be the parent of the new led 50 | * @param copy pointer to a led object, if not NULL then the new object will be copied from it 51 | * @return pointer to the created led 52 | */ 53 | lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy); 54 | 55 | /** 56 | * Set the brightness of a LED object 57 | * @param led pointer to a LED object 58 | * @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light) 59 | */ 60 | void lv_led_set_bright(lv_obj_t * led, uint8_t bright); 61 | 62 | /** 63 | * Light on a LED 64 | * @param led pointer to a LED object 65 | */ 66 | void lv_led_on(lv_obj_t * led); 67 | 68 | /** 69 | * Light off a LED 70 | * @param led pointer to a LED object 71 | */ 72 | void lv_led_off(lv_obj_t * led); 73 | 74 | /** 75 | * Toggle the state of a LED 76 | * @param led pointer to a LED object 77 | */ 78 | void lv_led_toggle(lv_obj_t * led); 79 | 80 | /** 81 | * Get the brightness of a LEd object 82 | * @param led pointer to LED object 83 | * @return bright 0 (max. dark) ... 255 (max. light) 84 | */ 85 | uint8_t lv_led_get_bright(const lv_obj_t * led); 86 | 87 | /********************** 88 | * MACROS 89 | **********************/ 90 | 91 | #endif /*LV_USE_LED*/ 92 | 93 | #ifdef __cplusplus 94 | } /* extern "C" */ 95 | #endif 96 | 97 | #endif /*LV_LED_H*/ 98 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_widgets/lv_line.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_line.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LINE_H 7 | #define LV_LINE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_LINE != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /*Data of line*/ 31 | typedef struct { 32 | /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ 33 | const lv_point_t * point_array; /*Pointer to an array with the points of the line*/ 34 | uint16_t point_num; /*Number of points in 'point_array' */ 35 | uint8_t auto_size : 1; /*1: set obj. width to x max and obj. height to y max */ 36 | uint8_t y_inv : 1; /*1: y == 0 will be on the bottom*/ 37 | } lv_line_ext_t; 38 | 39 | /*Styles*/ 40 | enum { 41 | LV_LINE_PART_MAIN, 42 | }; 43 | typedef uint8_t lv_line_style_t; 44 | 45 | /********************** 46 | * GLOBAL PROTOTYPES 47 | **********************/ 48 | 49 | /** 50 | * Create a line objects 51 | * @param par pointer to an object, it will be the parent of the new line 52 | * @return pointer to the created line 53 | */ 54 | lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy); 55 | 56 | /*===================== 57 | * Setter functions 58 | *====================*/ 59 | 60 | /** 61 | * Set an array of points. The line object will connect these points. 62 | * @param line pointer to a line object 63 | * @param point_a an array of points. Only the address is saved, 64 | * so the array can NOT be a local variable which will be destroyed 65 | * @param point_num number of points in 'point_a' 66 | */ 67 | void lv_line_set_points(lv_obj_t * line, const lv_point_t point_a[], uint16_t point_num); 68 | 69 | /** 70 | * Enable (or disable) the auto-size option. The size of the object will fit to its points. 71 | * (set width to x max and height to y max) 72 | * @param line pointer to a line object 73 | * @param en true: auto size is enabled, false: auto size is disabled 74 | */ 75 | void lv_line_set_auto_size(lv_obj_t * line, bool en); 76 | 77 | /** 78 | * Enable (or disable) the y coordinate inversion. 79 | * If enabled then y will be subtracted from the height of the object, 80 | * therefore the y=0 coordinate will be on the bottom. 81 | * @param line pointer to a line object 82 | * @param en true: enable the y inversion, false:disable the y inversion 83 | */ 84 | void lv_line_set_y_invert(lv_obj_t * line, bool en); 85 | 86 | #define lv_line_set_y_inv \ 87 | lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will \ 88 | work */ 89 | 90 | /*===================== 91 | * Getter functions 92 | *====================*/ 93 | 94 | /** 95 | * Get the auto size attribute 96 | * @param line pointer to a line object 97 | * @return true: auto size is enabled, false: disabled 98 | */ 99 | bool lv_line_get_auto_size(const lv_obj_t * line); 100 | 101 | /** 102 | * Get the y inversion attribute 103 | * @param line pointer to a line object 104 | * @return true: y inversion is enabled, false: disabled 105 | */ 106 | bool lv_line_get_y_invert(const lv_obj_t * line); 107 | 108 | /********************** 109 | * MACROS 110 | **********************/ 111 | 112 | #endif /*LV_USE_LINE*/ 113 | 114 | #ifdef __cplusplus 115 | } /* extern "C" */ 116 | #endif 117 | 118 | #endif /*LV_LINE_H*/ 119 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_widgets/lv_objmask.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_objmask.h 3 | * 4 | */ 5 | 6 | #ifndef LV_OBJMASK_H 7 | #define LV_OBJMASK_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_OBJMASK != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | #include "../lv_widgets/lv_cont.h" 22 | 23 | /********************* 24 | * DEFINES 25 | *********************/ 26 | 27 | /********************** 28 | * TYPEDEFS 29 | **********************/ 30 | 31 | typedef struct { 32 | void * param; 33 | } lv_objmask_mask_t; 34 | 35 | /*Data of object mask*/ 36 | typedef struct { 37 | lv_cont_ext_t cont; /*Ext. of ancestor*/ 38 | /*New data for this type */ 39 | lv_ll_t mask_ll; /*Store the created masks*/ 40 | 41 | } lv_objmask_ext_t; 42 | 43 | /*Parts of the object*/ 44 | enum { 45 | LV_OBJMASK_PART_MAIN, 46 | }; 47 | typedef uint8_t lv_objmask_part_t; 48 | 49 | /********************** 50 | * GLOBAL PROTOTYPES 51 | **********************/ 52 | 53 | /** 54 | * Create a object mask objects 55 | * @param par pointer to an object, it will be the parent of the new object mask 56 | * @param copy pointer to a object mask object, if not NULL then the new object will be copied from it 57 | * @return pointer to the created object mask 58 | */ 59 | lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy); 60 | 61 | /*====================== 62 | * Add/remove functions 63 | *=====================*/ 64 | 65 | /** 66 | * Add a mask 67 | * @param objmask pointer to an Object mask object 68 | * @param param an initialized mask parameter 69 | * @return pointer to the added mask 70 | */ 71 | lv_objmask_mask_t * lv_objmask_add_mask(lv_obj_t * objmask, void * param); 72 | 73 | /** 74 | * Update an already created mask 75 | * @param objmask pointer to an Object mask object 76 | * @param mask pointer to created mask (returned by `lv_objmask_add_mask`) 77 | * @param param an initialized mask parameter (initialized by `lv_draw_mask_line/angle/.../_init`) 78 | */ 79 | void lv_objmask_update_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask, void * param); 80 | 81 | /** 82 | * Remove a mask 83 | * @param objmask pointer to an Object mask object 84 | * @param mask pointer to created mask (returned by `lv_objmask_add_mask`) 85 | * If `NULL` passed all masks will be deleted. 86 | */ 87 | void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask); 88 | 89 | /*===================== 90 | * Setter functions 91 | *====================*/ 92 | 93 | /*===================== 94 | * Getter functions 95 | *====================*/ 96 | 97 | /*===================== 98 | * Other functions 99 | *====================*/ 100 | 101 | /********************** 102 | * MACROS 103 | **********************/ 104 | 105 | #endif /*LV_USE_OBJMASK*/ 106 | 107 | #ifdef __cplusplus 108 | } /* extern "C" */ 109 | #endif 110 | 111 | #endif /*LV_OBJMASK_H*/ 112 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_widgets/lv_objx_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.h 3 | * 4 | */ 5 | 6 | /* TODO Remove these instructions 7 | * Search an replace: template -> object normal name with lower case (e.g. button, label etc.) 8 | * templ -> object short name with lower case(e.g. btn, label etc) 9 | * TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.) 10 | * 11 | */ 12 | 13 | #ifndef LV_TEMPL_H 14 | #define LV_TEMPL_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /********************* 21 | * INCLUDES 22 | *********************/ 23 | #include "../lv_conf_internal.h" 24 | 25 | #if LV_USE_TEMPL != 0 26 | 27 | #include "../lv_core/lv_obj.h" 28 | 29 | /********************* 30 | * DEFINES 31 | *********************/ 32 | 33 | /********************** 34 | * TYPEDEFS 35 | **********************/ 36 | /*Data of template*/ 37 | typedef struct { 38 | lv_ANCESTOR_ext_t ANCESTOR; /*Ext. of ancestor*/ 39 | /*New data for this type */ 40 | } lv_templ_ext_t; 41 | 42 | /*Styles*/ 43 | enum { 44 | LV_TEMPL_STYLE_X, 45 | LV_TEMPL_STYLE_Y, 46 | }; 47 | typedef uint8_t lv_templ_style_t; 48 | 49 | /********************** 50 | * GLOBAL PROTOTYPES 51 | **********************/ 52 | 53 | /** 54 | * Create a template objects 55 | * @param par pointer to an object, it will be the parent of the new template 56 | * @param copy pointer to a template object, if not NULL then the new object will be copied from it 57 | * @return pointer to the created template 58 | */ 59 | lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy); 60 | 61 | /*====================== 62 | * Add/remove functions 63 | *=====================*/ 64 | 65 | /*===================== 66 | * Setter functions 67 | *====================*/ 68 | 69 | /** 70 | * Set a style of a template. 71 | * @param templ pointer to template object 72 | * @param type which style should be set 73 | * @param style pointer to a style 74 | */ 75 | void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, const lv_style_t * style); 76 | 77 | /*===================== 78 | * Getter functions 79 | *====================*/ 80 | 81 | /** 82 | * Get style of a template. 83 | * @param templ pointer to template object 84 | * @param type which style should be get 85 | * @return style pointer to the style 86 | */ 87 | lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type); 88 | 89 | /*===================== 90 | * Other functions 91 | *====================*/ 92 | 93 | /********************** 94 | * MACROS 95 | **********************/ 96 | 97 | #endif /*LV_USE_TEMPL*/ 98 | 99 | #ifdef __cplusplus 100 | } /* extern "C" */ 101 | #endif 102 | 103 | #endif /*LV_TEMPL_H*/ 104 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_widgets/lv_switch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_sw.h 3 | * 4 | */ 5 | 6 | #ifndef LV_SWITCH_H 7 | #define LV_SWITCH_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_SWITCH != 0 19 | 20 | /*Testing of dependencies*/ 21 | #if LV_USE_SLIDER == 0 22 | #error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1)" 23 | #endif 24 | 25 | #include "../lv_core/lv_obj.h" 26 | #include "lv_bar.h" 27 | 28 | /********************* 29 | * DEFINES 30 | *********************/ 31 | 32 | /********************** 33 | * TYPEDEFS 34 | **********************/ 35 | /*Data of switch*/ 36 | typedef struct { 37 | lv_bar_ext_t bar; /*Ext. of ancestor*/ 38 | /*New data for this type */ 39 | lv_style_list_t style_knob; /*Style of the knob*/ 40 | } lv_switch_ext_t; 41 | 42 | /** 43 | * Switch parts. 44 | */ 45 | enum { 46 | LV_SWITCH_PART_BG = LV_BAR_PART_BG, /**< Switch background. */ 47 | LV_SWITCH_PART_INDIC = LV_BAR_PART_INDIC, /**< Switch fill area. */ 48 | LV_SWITCH_PART_KNOB = _LV_BAR_PART_VIRTUAL_LAST, /**< Switch knob. */ 49 | _LV_SWITCH_PART_VIRTUAL_LAST 50 | }; 51 | 52 | typedef uint8_t lv_switch_part_t; 53 | 54 | /********************** 55 | * GLOBAL PROTOTYPES 56 | **********************/ 57 | 58 | /** 59 | * Create a switch objects 60 | * @param par pointer to an object, it will be the parent of the new switch 61 | * @param copy pointer to a switch object, if not NULL then the new object will be copied from it 62 | * @return pointer to the created switch 63 | */ 64 | lv_obj_t * lv_switch_create(lv_obj_t * par, const lv_obj_t * copy); 65 | 66 | /*===================== 67 | * Setter functions 68 | *====================*/ 69 | 70 | /** 71 | * Turn ON the switch 72 | * @param sw pointer to a switch object 73 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 74 | */ 75 | void lv_switch_on(lv_obj_t * sw, lv_anim_enable_t anim); 76 | 77 | /** 78 | * Turn OFF the switch 79 | * @param sw pointer to a switch object 80 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 81 | */ 82 | void lv_switch_off(lv_obj_t * sw, lv_anim_enable_t anim); 83 | 84 | /** 85 | * Toggle the position of the switch 86 | * @param sw pointer to a switch object 87 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 88 | * @return resulting state of the switch. 89 | */ 90 | bool lv_switch_toggle(lv_obj_t * sw, lv_anim_enable_t anim); 91 | 92 | /** 93 | * Set the animation time of the switch 94 | * @param sw pointer to a switch object 95 | * @param anim_time animation time 96 | * @return style pointer to a style 97 | */ 98 | static inline void lv_switch_set_anim_time(lv_obj_t * sw, uint16_t anim_time) 99 | { 100 | lv_bar_set_anim_time(sw, anim_time); 101 | } 102 | 103 | /*===================== 104 | * Getter functions 105 | *====================*/ 106 | 107 | /** 108 | * Get the state of a switch 109 | * @param sw pointer to a switch object 110 | * @return false: OFF; true: ON 111 | */ 112 | static inline bool lv_switch_get_state(const lv_obj_t * sw) 113 | { 114 | return lv_bar_get_value(sw) == 1 ? true : false; 115 | } 116 | 117 | /** 118 | * Get the animation time of the switch 119 | * @param sw pointer to a switch object 120 | * @return style pointer to a style 121 | */ 122 | static inline uint16_t lv_switch_get_anim_time(const lv_obj_t * sw) 123 | { 124 | return lv_bar_get_anim_time(sw); 125 | } 126 | 127 | /********************** 128 | * MACROS 129 | **********************/ 130 | 131 | #endif /*LV_USE_SWITCH*/ 132 | 133 | #ifdef __cplusplus 134 | } /* extern "C" */ 135 | #endif 136 | 137 | #endif /*LV_SWITCH_H*/ 138 | -------------------------------------------------------------------------------- /lib/lvgl/src/lv_widgets/lv_widgets.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_arc.c 2 | CSRCS += lv_bar.c 3 | CSRCS += lv_checkbox.c 4 | CSRCS += lv_cpicker.c 5 | CSRCS += lv_dropdown.c 6 | CSRCS += lv_keyboard.c 7 | CSRCS += lv_line.c 8 | CSRCS += lv_msgbox.c 9 | CSRCS += lv_spinner.c 10 | CSRCS += lv_roller.c 11 | CSRCS += lv_table.c 12 | CSRCS += lv_tabview.c 13 | CSRCS += lv_tileview.c 14 | CSRCS += lv_btn.c 15 | CSRCS += lv_calendar.c 16 | CSRCS += lv_chart.c 17 | CSRCS += lv_canvas.c 18 | CSRCS += lv_gauge.c 19 | CSRCS += lv_label.c 20 | CSRCS += lv_list.c 21 | CSRCS += lv_slider.c 22 | CSRCS += lv_textarea.c 23 | CSRCS += lv_spinbox.c 24 | CSRCS += lv_btnmatrix.c 25 | CSRCS += lv_cont.c 26 | CSRCS += lv_img.c 27 | CSRCS += lv_imgbtn.c 28 | CSRCS += lv_led.c 29 | CSRCS += lv_linemeter.c 30 | CSRCS += lv_page.c 31 | CSRCS += lv_switch.c 32 | CSRCS += lv_win.c 33 | CSRCS += lv_objmask.c 34 | 35 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets 36 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets 37 | 38 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets" 39 | -------------------------------------------------------------------------------- /lib/lvgl/src/lvgl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lvgl.h 3 | * This file exists only to be compatible with Arduino's library structure 4 | */ 5 | 6 | #ifndef LVGL_SRC_H 7 | #define LVGL_SRC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #include "../lvgl.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * GLOBAL PROTOTYPES 29 | **********************/ 30 | 31 | /********************** 32 | * MACROS 33 | **********************/ 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /*LVGL_SRC_H*/ 40 | -------------------------------------------------------------------------------- /lib/tinygl/clear.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | 4 | void glopClearColor(GLContext *c,GLParam *p) 5 | { 6 | c->clear_color.v[0]=p[1].f; 7 | c->clear_color.v[1]=p[2].f; 8 | c->clear_color.v[2]=p[3].f; 9 | c->clear_color.v[3]=p[4].f; 10 | } 11 | void glopClearDepth(GLContext *c,GLParam *p) 12 | { 13 | c->clear_depth=p[1].f; 14 | } 15 | 16 | 17 | void glopClear(GLContext *c,GLParam *p) 18 | { 19 | int mask=p[1].i; 20 | int z=0; 21 | int r=(int)(c->clear_color.v[0]*65535); 22 | int g=(int)(c->clear_color.v[1]*65535); 23 | int b=(int)(c->clear_color.v[2]*65535); 24 | 25 | /* TODO : correct value of Z */ 26 | 27 | ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z, 28 | mask & GL_COLOR_BUFFER_BIT,r,g,b); 29 | } 30 | -------------------------------------------------------------------------------- /lib/tinygl/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zgl.h" 3 | 4 | void gl_fatal_error(char *format, ...) 5 | { 6 | va_list ap; 7 | 8 | va_start(ap,format); 9 | 10 | fprintf(stderr,"TinyGL: fatal error: "); 11 | vfprintf(stderr,format,ap); 12 | fprintf(stderr,"\n"); 13 | exit(1); 14 | 15 | va_end(ap); 16 | } 17 | -------------------------------------------------------------------------------- /lib/tinygl/gears.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gears.h 3 | * 4 | */ 5 | 6 | #ifndef GEARS_H 7 | #define GEARS_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | void gears_init(int xsize, int ysize, int mode, void *buf); 29 | void gears_update(void); 30 | 31 | /********************** 32 | * MACROS 33 | **********************/ 34 | 35 | #ifdef __cplusplus 36 | } /* extern "C" */ 37 | #endif 38 | 39 | #endif /*GEARS_H*/ 40 | -------------------------------------------------------------------------------- /lib/tinygl/get.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | void glGetIntegerv(int pname,int *params) 4 | { 5 | GLContext *c=gl_get_context(); 6 | 7 | switch(pname) { 8 | case GL_VIEWPORT: 9 | params[0]=c->viewport.xmin; 10 | params[1]=c->viewport.ymin; 11 | params[2]=c->viewport.xsize; 12 | params[3]=c->viewport.ysize; 13 | break; 14 | case GL_MAX_MODELVIEW_STACK_DEPTH: 15 | *params = MAX_MODELVIEW_STACK_DEPTH; 16 | break; 17 | case GL_MAX_PROJECTION_STACK_DEPTH: 18 | *params = MAX_PROJECTION_STACK_DEPTH; 19 | break; 20 | case GL_MAX_LIGHTS: 21 | *params = MAX_LIGHTS; 22 | break; 23 | case GL_MAX_TEXTURE_SIZE: 24 | *params = 256; /* not completely true, but... */ 25 | break; 26 | case GL_MAX_TEXTURE_STACK_DEPTH: 27 | *params = MAX_TEXTURE_STACK_DEPTH; 28 | break; 29 | default: 30 | gl_fatal_error("glGet: option not implemented"); 31 | break; 32 | } 33 | } 34 | 35 | void glGetFloatv(int pname, float *v) 36 | { 37 | int i; 38 | int mnr = 0; /* just a trick to return the correct matrix */ 39 | GLContext *c = gl_get_context(); 40 | switch (pname) { 41 | case GL_TEXTURE_MATRIX: 42 | mnr++; 43 | case GL_PROJECTION_MATRIX: 44 | mnr++; 45 | case GL_MODELVIEW_MATRIX: 46 | { 47 | float *p = &c->matrix_stack_ptr[mnr]->m[0][0];; 48 | for (i = 0; i < 4; i++) { 49 | *v++ = p[0]; 50 | *v++ = p[4]; 51 | *v++ = p[8]; 52 | *v++ = p[12]; 53 | p++; 54 | } 55 | } 56 | break; 57 | case GL_LINE_WIDTH: 58 | *v = 1.0f; 59 | break; 60 | case GL_LINE_WIDTH_RANGE: 61 | v[0] = v[1] = 1.0f; 62 | break; 63 | case GL_POINT_SIZE: 64 | *v = 1.0f; 65 | break; 66 | case GL_POINT_SIZE_RANGE: 67 | v[0] = v[1] = 1.0f; 68 | default: 69 | fprintf(stderr,"warning: unknown pname in glGetFloatv()\n"); 70 | break; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/tinygl/glu.h: -------------------------------------------------------------------------------- 1 | 2 | void gluPerspective( GLdouble fovy, GLdouble aspect, 3 | GLdouble zNear, GLdouble zFar ); 4 | 5 | typedef struct { 6 | int draw_style; 7 | } GLUquadricObj; 8 | 9 | #define GLU_LINE 0 10 | 11 | GLUquadricObj *gluNewQuadric(void); 12 | void gluQuadricDrawStyle(GLUquadricObj *obj, int style); 13 | 14 | void gluSphere(GLUquadricObj *qobj, 15 | float radius,int slices,int stacks); 16 | void gluCylinder( GLUquadricObj *qobj, 17 | GLdouble baseRadius, GLdouble topRadius, GLdouble height, 18 | GLint slices, GLint stacks ); 19 | void gluDisk( GLUquadricObj *qobj, 20 | GLdouble innerRadius, GLdouble outerRadius, 21 | GLint slices, GLint loops ); 22 | 23 | void drawTorus(float rc, int numc, float rt, int numt); 24 | -------------------------------------------------------------------------------- /lib/tinygl/image_util.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | /* 4 | * image conversion 5 | */ 6 | 7 | void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb, 8 | int xsize,int ysize) 9 | { 10 | int i,n; 11 | unsigned char *p; 12 | 13 | p=rgb; 14 | n=xsize*ysize; 15 | for(i=0;i>3); 17 | p+=3; 18 | } 19 | } 20 | 21 | void gl_convertRGB_to_8A8R8G8B(unsigned int *pixmap, unsigned char *rgb, 22 | int xsize, int ysize) 23 | { 24 | int i,n; 25 | unsigned char *p; 26 | 27 | p=rgb; 28 | n=xsize*ysize; 29 | for(i=0;i> INTERP_NORM_BITS); 47 | } 48 | 49 | 50 | /* 51 | * TODO: more accurate resampling 52 | */ 53 | 54 | void gl_resizeImage(unsigned char *dest,int xsize_dest,int ysize_dest, 55 | unsigned char *src,int xsize_src,int ysize_src) 56 | { 57 | unsigned char *pix,*pix_src; 58 | float x1,y1,x1inc,y1inc; 59 | int xi,yi,j,xf,yf,x,y; 60 | 61 | pix=dest; 62 | pix_src=src; 63 | 64 | x1inc=(float) (xsize_src - 1) / (float) (xsize_dest - 1); 65 | y1inc=(float) (ysize_src - 1) / (float) (ysize_dest - 1); 66 | 67 | y1=0; 68 | for(y=0;y> FRAC_BITS; 123 | yi=y1 >> FRAC_BITS; 124 | pix1=pix_src+(yi*xsize_src+xi)*3; 125 | 126 | pix[0]=pix1[0]; 127 | pix[1]=pix1[1]; 128 | pix[2]=pix1[2]; 129 | 130 | pix+=3; 131 | x1+=x1inc; 132 | } 133 | y1+=y1inc; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /lib/tinygl/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory allocator for TinyGL 3 | */ 4 | #include "zgl.h" 5 | 6 | /* modify these functions so that they suit your needs */ 7 | 8 | void gl_free(void *p) 9 | { 10 | free(p); 11 | } 12 | 13 | void *gl_malloc(int size) 14 | { 15 | return malloc(size); 16 | } 17 | 18 | void *gl_zalloc(int size) 19 | { 20 | return calloc(1, size); 21 | } 22 | -------------------------------------------------------------------------------- /lib/tinygl/misc.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | #include "msghandling.h" 3 | 4 | void glopViewport(GLContext *c,GLParam *p) 5 | { 6 | int xsize,ysize,xmin,ymin,xsize_req,ysize_req; 7 | 8 | xmin=p[1].i; 9 | ymin=p[2].i; 10 | xsize=p[3].i; 11 | ysize=p[4].i; 12 | 13 | /* we may need to resize the zbuffer */ 14 | 15 | if (c->viewport.xmin != xmin || 16 | c->viewport.ymin != ymin || 17 | c->viewport.xsize != xsize || 18 | c->viewport.ysize != ysize) { 19 | 20 | xsize_req=xmin+xsize; 21 | ysize_req=ymin+ysize; 22 | 23 | if (c->gl_resize_viewport && 24 | c->gl_resize_viewport(c,&xsize_req,&ysize_req) != 0) { 25 | gl_fatal_error("glViewport: error while resizing display"); 26 | } 27 | 28 | xsize=xsize_req-xmin; 29 | ysize=ysize_req-ymin; 30 | if (xsize <= 0 || ysize <= 0) { 31 | gl_fatal_error("glViewport: size too small"); 32 | } 33 | 34 | tgl_trace("glViewport: %d %d %d %d\n", 35 | xmin, ymin, xsize, ysize); 36 | c->viewport.xmin=xmin; 37 | c->viewport.ymin=ymin; 38 | c->viewport.xsize=xsize; 39 | c->viewport.ysize=ysize; 40 | 41 | c->viewport.updated=1; 42 | } 43 | } 44 | 45 | void glopEnableDisable(GLContext *c,GLParam *p) 46 | { 47 | int code=p[1].i; 48 | int v=p[2].i; 49 | 50 | switch(code) { 51 | case GL_CULL_FACE: 52 | c->cull_face_enabled=v; 53 | break; 54 | case GL_LIGHTING: 55 | c->lighting_enabled=v; 56 | break; 57 | case GL_COLOR_MATERIAL: 58 | c->color_material_enabled=v; 59 | break; 60 | case GL_TEXTURE_2D: 61 | c->texture_2d_enabled=v; 62 | break; 63 | case GL_NORMALIZE: 64 | c->normalize_enabled=v; 65 | break; 66 | case GL_DEPTH_TEST: 67 | c->depth_test = v; 68 | break; 69 | case GL_POLYGON_OFFSET_FILL: 70 | if (v) c->offset_states |= TGL_OFFSET_FILL; 71 | else c->offset_states &= ~TGL_OFFSET_FILL; 72 | break; 73 | case GL_POLYGON_OFFSET_POINT: 74 | if (v) c->offset_states |= TGL_OFFSET_POINT; 75 | else c->offset_states &= ~TGL_OFFSET_POINT; 76 | break; 77 | case GL_POLYGON_OFFSET_LINE: 78 | if (v) c->offset_states |= TGL_OFFSET_LINE; 79 | else c->offset_states &= ~TGL_OFFSET_LINE; 80 | break; 81 | default: 82 | if (code>=GL_LIGHT0 && codecurrent_shade_model=code; 97 | } 98 | 99 | void glopCullFace(GLContext *c,GLParam *p) 100 | { 101 | int code=p[1].i; 102 | c->current_cull_face=code; 103 | } 104 | 105 | void glopFrontFace(GLContext *c,GLParam *p) 106 | { 107 | int code=p[1].i; 108 | c->current_front_face=code; 109 | } 110 | 111 | void glopPolygonMode(GLContext *c,GLParam *p) 112 | { 113 | int face=p[1].i; 114 | int mode=p[2].i; 115 | 116 | switch(face) { 117 | case GL_BACK: 118 | c->polygon_mode_back=mode; 119 | break; 120 | case GL_FRONT: 121 | c->polygon_mode_front=mode; 122 | break; 123 | case GL_FRONT_AND_BACK: 124 | c->polygon_mode_front=mode; 125 | c->polygon_mode_back=mode; 126 | break; 127 | default: 128 | assert(0); 129 | } 130 | } 131 | 132 | void glopHint(GLContext *c,GLParam *p) 133 | { 134 | #if 0 135 | int target=p[1].i; 136 | int mode=p[2].i; 137 | 138 | /* do nothing */ 139 | #endif 140 | } 141 | 142 | void 143 | glopPolygonOffset(GLContext *c, GLParam *p) 144 | { 145 | c->offset_factor = p[1].f; 146 | c->offset_units = p[2].f; 147 | } 148 | -------------------------------------------------------------------------------- /lib/tinygl/msghandling.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define NDEBUG 5 | 6 | #ifdef NDEBUG 7 | #define NO_DEBUG_OUTPUT 8 | #endif 9 | 10 | /* Use this function to output messages when something unexpected 11 | happens (which might be an indication of an error). *Don't* use it 12 | when there's internal errors in the code - these should be handled 13 | by asserts. */ 14 | void 15 | tgl_warning(const char *format, ...) 16 | { 17 | #ifndef NO_DEBUG_OUTPUT 18 | va_list args; 19 | va_start(args, format); 20 | fprintf(stderr, "*WARNING* "); 21 | vfprintf(stderr, format, args); 22 | va_end(args); 23 | #endif /* !NO_DEBUG_OUTPUT */ 24 | } 25 | 26 | /* This function should be used for debug output only. */ 27 | void 28 | tgl_trace(const char *format, ...) 29 | { 30 | #ifndef NO_DEBUG_OUTPUT 31 | va_list args; 32 | va_start(args, format); 33 | fprintf(stderr, "*DEBUG* "); 34 | vfprintf(stderr, format, args); 35 | va_end(args); 36 | #endif /* !NO_DEBUG_OUTPUT */ 37 | } 38 | 39 | /* Use this function to output info about things in the code which 40 | should be fixed (missing handling of special cases, important 41 | features not implemented, known bugs/buglets, ...). */ 42 | void 43 | tgl_fixme(const char *format, ...) 44 | { 45 | #ifndef NO_DEBUG_OUTPUT 46 | va_list args; 47 | va_start(args, format); 48 | fprintf(stderr, "*FIXME* "); 49 | vfprintf(stderr, format, args); 50 | va_end(args); 51 | #endif /* !NO_DEBUG_OUTPUT */ 52 | } 53 | -------------------------------------------------------------------------------- /lib/tinygl/msghandling.h: -------------------------------------------------------------------------------- 1 | #ifndef _msghandling_h_ 2 | #define _msghandling_h_ 3 | 4 | extern void tgl_warning(const char *text, ...); 5 | extern void tgl_trace(const char *text, ...); 6 | extern void tgl_fixme(const char *text, ...); 7 | 8 | #endif /* _msghandling_h_ */ 9 | -------------------------------------------------------------------------------- /lib/tinygl/opinfo.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | ADD_OP(Color,7,"%f %f %f %f %d %d %d") 4 | ADD_OP(TexCoord,4,"%f %f %f %f") 5 | ADD_OP(EdgeFlag,1,"%d") 6 | ADD_OP(Normal,3,"%f %f %f") 7 | 8 | ADD_OP(Begin,1,"%C") 9 | ADD_OP(Vertex,4,"%f %f %f %f") 10 | ADD_OP(End,0,"") 11 | 12 | ADD_OP(EnableDisable,2,"%C %d") 13 | 14 | ADD_OP(MatrixMode,1,"%C") 15 | ADD_OP(LoadMatrix,16,"") 16 | ADD_OP(LoadIdentity,0,"") 17 | ADD_OP(MultMatrix,16,"") 18 | ADD_OP(PushMatrix,0,"") 19 | ADD_OP(PopMatrix,0,"") 20 | ADD_OP(Rotate,4,"%f %f %f %f") 21 | ADD_OP(Translate,3,"%f %f %f") 22 | ADD_OP(Scale,3,"%f %f %f") 23 | 24 | ADD_OP(Viewport,4,"%d %d %d %d") 25 | ADD_OP(Frustum,6,"%f %f %f %f %f %f") 26 | 27 | ADD_OP(Material,6,"%C %C %f %f %f %f") 28 | ADD_OP(ColorMaterial,2,"%C %C") 29 | ADD_OP(Light,6,"%C %C %f %f %f %f") 30 | ADD_OP(LightModel,5,"%C %f %f %f %f") 31 | 32 | ADD_OP(Clear,1,"%d") 33 | ADD_OP(ClearColor,4,"%f %f %f %f") 34 | ADD_OP(ClearDepth,1,"%f") 35 | 36 | ADD_OP(InitNames,0,"") 37 | ADD_OP(PushName,1,"%d") 38 | ADD_OP(PopName,0,"") 39 | ADD_OP(LoadName,1,"%d") 40 | 41 | ADD_OP(TexImage2D,9,"%d %d %d %d %d %d %d %d %d") 42 | ADD_OP(BindTexture,2,"%C %d") 43 | ADD_OP(TexEnv,7,"%C %C %C %f %f %f %f") 44 | ADD_OP(TexParameter,7,"%C %C %C %f %f %f %f") 45 | ADD_OP(PixelStore,2,"%C %C") 46 | 47 | ADD_OP(ShadeModel,1,"%C") 48 | ADD_OP(CullFace,1,"%C") 49 | ADD_OP(FrontFace,1,"%C") 50 | ADD_OP(PolygonMode,2,"%C %C") 51 | 52 | ADD_OP(CallList,1,"%d") 53 | ADD_OP(Hint,2,"%C %C") 54 | 55 | /* special opcodes */ 56 | ADD_OP(EndList,0,"") 57 | ADD_OP(NextBuffer,1,"%p") 58 | 59 | /* opengl 1.1 arrays */ 60 | ADD_OP(ArrayElement, 1, "%d") 61 | ADD_OP(EnableClientState, 1, "%C") 62 | ADD_OP(DisableClientState, 1, "%C") 63 | ADD_OP(VertexPointer, 4, "%d %C %d %p") 64 | ADD_OP(ColorPointer, 4, "%d %C %d %p") 65 | ADD_OP(NormalPointer, 3, "%C %d %p") 66 | ADD_OP(TexCoordPointer, 4, "%d %C %d %p") 67 | 68 | /* opengl 1.1 polygon offset */ 69 | ADD_OP(PolygonOffset, 2, "%f %f") 70 | 71 | #undef ADD_OP 72 | -------------------------------------------------------------------------------- /lib/tinygl/oscontext.c: -------------------------------------------------------------------------------- 1 | #include "oscontext.h" 2 | #include "zbuffer.h" 3 | #include "zgl.h" 4 | #include "gl.h" 5 | #include 6 | #include 7 | 8 | static int buffercnt = 0; 9 | 10 | ostgl_context * 11 | ostgl_create_context(const int xsize, 12 | const int ysize, 13 | const int depth, 14 | void **framebuffers, 15 | const int numbuffers) 16 | { 17 | ostgl_context *context; 18 | int i; 19 | ZBuffer *zb; 20 | 21 | assert(depth == 16); /* support for other depths must include bpp 22 | convertion */ 23 | assert(numbuffers >= 1); 24 | 25 | context = gl_malloc(sizeof(ostgl_context)); 26 | assert(context); 27 | context->zbs = gl_malloc(sizeof(void*)*numbuffers); 28 | context->framebuffers = gl_malloc(sizeof(void*)*numbuffers); 29 | 30 | assert(context->zbs != NULL && context->framebuffers != NULL); 31 | 32 | for (i = 0; i < numbuffers; i++) { 33 | context->framebuffers[i] = framebuffers[i]; 34 | zb = ZB_open(xsize, ysize, ZB_MODE_5R6G5B, 0, NULL, NULL, framebuffers[i]); 35 | if (zb == NULL) { 36 | fprintf(stderr, "Error while initializing Z buffer\n"); 37 | exit(1); 38 | } 39 | context->zbs[i] = zb; 40 | } 41 | if (++buffercnt == 1) { 42 | glInit(context->zbs[0]); 43 | } 44 | context->xsize = xsize; 45 | context->ysize = ysize; 46 | context->numbuffers = numbuffers; 47 | return context; 48 | } 49 | 50 | void 51 | ostgl_delete_context(ostgl_context *context) 52 | { 53 | int i; 54 | for (i = 0; i < context->numbuffers; i++) { 55 | ZB_close(context->zbs[i]); 56 | } 57 | gl_free(context->zbs); 58 | gl_free(context->framebuffers); 59 | gl_free(context); 60 | 61 | if (--buffercnt == 0) { 62 | glClose(); 63 | } 64 | } 65 | 66 | void 67 | ostgl_make_current(ostgl_context *oscontext, const int idx) 68 | { 69 | GLContext *context = gl_get_context(); 70 | assert(idx < oscontext->numbuffers); 71 | context->zb = oscontext->zbs[idx]; 72 | } 73 | 74 | void 75 | ostgl_resize(ostgl_context *context, 76 | const int xsize, 77 | const int ysize, 78 | void **framebuffers) 79 | { 80 | int i; 81 | for (i = 0; i < context->numbuffers; i++) { 82 | ZB_resize(context->zbs[i], framebuffers[i], xsize, ysize); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /lib/tinygl/oscontext.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_osbuffer_h_ 2 | #define _tgl_osbuffer_h_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef struct { 9 | void **zbs; 10 | void **framebuffers; 11 | int numbuffers; 12 | int xsize, ysize; 13 | } ostgl_context; 14 | 15 | ostgl_context * 16 | ostgl_create_context(const int xsize, 17 | const int ysize, 18 | const int depth, 19 | void **framebuffers, 20 | const int numbuffers); 21 | void 22 | ostgl_delete_context(ostgl_context *context); 23 | 24 | void 25 | ostgl_make_current(ostgl_context *context, const int index); 26 | 27 | void 28 | ostgl_resize(ostgl_context * context, 29 | const int xsize, 30 | const int ysize, 31 | void **framebuffers); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* _tgl_osbuffer_h_ */ 38 | -------------------------------------------------------------------------------- /lib/tinygl/select.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | 3 | int glRenderMode(int mode) 4 | { 5 | GLContext *c=gl_get_context(); 6 | int result=0; 7 | 8 | switch(c->render_mode) { 9 | case GL_RENDER: 10 | break; 11 | case GL_SELECT: 12 | if (c->select_overflow) { 13 | result=-c->select_hits; 14 | } else { 15 | result=c->select_hits; 16 | } 17 | c->select_overflow=0; 18 | c->select_ptr=c->select_buffer; 19 | c->name_stack_size=0; 20 | break; 21 | default: 22 | assert(0); 23 | } 24 | switch(mode) { 25 | case GL_RENDER: 26 | c->render_mode=GL_RENDER; 27 | break; 28 | case GL_SELECT: 29 | c->render_mode=GL_SELECT; 30 | assert( c->select_buffer != NULL); 31 | c->select_ptr=c->select_buffer; 32 | c->select_hits=0; 33 | c->select_overflow=0; 34 | c->select_hit=NULL; 35 | break; 36 | default: 37 | assert(0); 38 | } 39 | return result; 40 | } 41 | 42 | void glSelectBuffer(int size,unsigned int *buf) 43 | { 44 | GLContext *c=gl_get_context(); 45 | 46 | assert(c->render_mode != GL_SELECT); 47 | 48 | c->select_buffer=buf; 49 | c->select_size=size; 50 | } 51 | 52 | 53 | void glopInitNames(GLContext *c,GLParam *p) 54 | { 55 | if (c->render_mode == GL_SELECT) { 56 | c->name_stack_size=0; 57 | c->select_hit=NULL; 58 | } 59 | } 60 | 61 | void glopPushName(GLContext *c,GLParam *p) 62 | { 63 | if (c->render_mode == GL_SELECT) { 64 | assert(c->name_stack_sizename_stack[c->name_stack_size++]=p[1].i; 66 | c->select_hit=NULL; 67 | } 68 | } 69 | 70 | void glopPopName(GLContext *c,GLParam *p) 71 | { 72 | if (c->render_mode == GL_SELECT) { 73 | assert(c->name_stack_size>0); 74 | c->name_stack_size--; 75 | c->select_hit=NULL; 76 | } 77 | } 78 | 79 | void glopLoadName(GLContext *c,GLParam *p) 80 | { 81 | if (c->render_mode == GL_SELECT) { 82 | assert(c->name_stack_size>0); 83 | c->name_stack[c->name_stack_size-1]=p[1].i; 84 | c->select_hit=NULL; 85 | } 86 | } 87 | 88 | void gl_add_select(GLContext *c,unsigned int zmin,unsigned int zmax) 89 | { 90 | unsigned int *ptr; 91 | int n,i; 92 | 93 | if (!c->select_overflow) { 94 | if (c->select_hit==NULL) { 95 | n=c->name_stack_size; 96 | if ((c->select_ptr-c->select_buffer+3+n) > 97 | c->select_size) { 98 | c->select_overflow=1; 99 | } else { 100 | ptr=c->select_ptr; 101 | c->select_hit=ptr; 102 | *ptr++=c->name_stack_size; 103 | *ptr++=zmin; 104 | *ptr++=zmax; 105 | for(i=0;iname_stack[i]; 106 | c->select_ptr=ptr; 107 | c->select_hits++; 108 | } 109 | } else { 110 | if (zminselect_hit[1]) c->select_hit[1]=zmin; 111 | if (zmax>c->select_hit[2]) c->select_hit[2]=zmax; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /lib/tinygl/specbuf.c: -------------------------------------------------------------------------------- 1 | #include "zgl.h" 2 | #include "msghandling.h" 3 | #include 4 | #include 5 | 6 | static void calc_buf(GLSpecBuf *buf, const float shininess) 7 | { 8 | int i; 9 | float val, inc; 10 | val = 0.0f; 11 | inc = 1.0f/SPECULAR_BUFFER_SIZE; 12 | for (i = 0; i <= SPECULAR_BUFFER_SIZE; i++) { 13 | buf->buf[i] = pow(val, shininess); 14 | val += inc; 15 | } 16 | } 17 | 18 | GLSpecBuf * 19 | specbuf_get_buffer(GLContext *c, const int shininess_i, 20 | const float shininess) 21 | { 22 | GLSpecBuf *found, *oldest; 23 | found = oldest = c->specbuf_first; 24 | while (found && found->shininess_i != shininess_i) { 25 | if (found->last_used < oldest->last_used) { 26 | oldest = found; 27 | } 28 | found = found->next; 29 | } 30 | if (found) { /* hey, found one! */ 31 | found->last_used = c->specbuf_used_counter++; 32 | return found; 33 | } 34 | if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { 35 | /* create new buffer */ 36 | GLSpecBuf *buf = gl_malloc(sizeof(GLSpecBuf)); 37 | if (!buf) gl_fatal_error("could not allocate specular buffer"); 38 | c->specbuf_num_buffers++; 39 | buf->next = c->specbuf_first; 40 | c->specbuf_first = buf; 41 | buf->last_used = c->specbuf_used_counter++; 42 | buf->shininess_i = shininess_i; 43 | calc_buf(buf, shininess); 44 | return buf; 45 | } 46 | /* overwrite the lru buffer */ 47 | /*tgl_trace("overwriting spec buffer :(\n");*/ 48 | oldest->shininess_i = shininess_i; 49 | oldest->last_used = c->specbuf_used_counter++; 50 | calc_buf(oldest, shininess); 51 | return oldest; 52 | } 53 | -------------------------------------------------------------------------------- /lib/tinygl/specbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_specbuf_h_ 2 | #define _tgl_specbuf_h_ 3 | 4 | /* Max # of specular light pow buffers */ 5 | #define MAX_SPECULAR_BUFFERS 8 6 | /* # of entries in specular buffer */ 7 | #define SPECULAR_BUFFER_SIZE 1024 8 | /* specular buffer granularity */ 9 | #define SPECULAR_BUFFER_RESOLUTION 1024 10 | 11 | typedef struct GLSpecBuf { 12 | int shininess_i; 13 | int last_used; 14 | float buf[SPECULAR_BUFFER_SIZE+1]; 15 | struct GLSpecBuf *next; 16 | } GLSpecBuf; 17 | 18 | GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, 19 | const float shininess); 20 | void specbuf_cleanup(GLContext *c); /* free all memory used */ 21 | 22 | #endif /* _tgl_specbuf_h_ */ 23 | -------------------------------------------------------------------------------- /lib/tinygl/zbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_zbuffer_h_ 2 | #define _tgl_zbuffer_h_ 3 | 4 | /* 5 | * Z buffer 6 | */ 7 | 8 | #include "zfeatures.h" 9 | 10 | #define ZB_Z_BITS 16 11 | 12 | #define ZB_POINT_Z_FRAC_BITS 14 13 | 14 | #define ZB_POINT_S_MIN ((1 << 13)) 15 | #define ZB_POINT_S_MAX ((1 << 22) - (1 << 13)) 16 | #define ZB_POINT_T_MIN ((1 << 21)) 17 | #define ZB_POINT_T_MAX ((1 << 30) - (1 << 21)) 18 | 19 | #define ZB_POINT_RED_MIN ((1 << 10)) 20 | #define ZB_POINT_RED_MAX ((1 << 16) - (1 << 10)) 21 | #define ZB_POINT_GREEN_MIN ((1 << 9)) 22 | #define ZB_POINT_GREEN_MAX ((1 << 16) - (1 << 9)) 23 | #define ZB_POINT_BLUE_MIN ((1 << 10)) 24 | #define ZB_POINT_BLUE_MAX ((1 << 16) - (1 << 10)) 25 | 26 | /* display modes */ 27 | #define ZB_MODE_5R6G5B 1 /* true color 16 bits */ 28 | #define ZB_MODE_INDEX 2 /* color index 8 bits */ 29 | #define ZB_MODE_RGBA 3 /* 32 bit rgba mode */ 30 | #define ZB_MODE_RGB24 4 /* 24 bit rgb mode */ 31 | #define ZB_NB_COLORS 225 /* number of colors for 8 bit display */ 32 | 33 | #if TGL_FEATURE_RENDER_BITS == 15 34 | 35 | #define RGB_TO_PIXEL(r, g, b) \ 36 | ((((r) >> 1) & 0x7c00) | (((g) >> 6) & 0x03e0) | ((b) >> 11)) 37 | typedef unsigned short PIXEL; 38 | /* bytes per pixel */ 39 | #define PSZB 2 40 | /* bits per pixel = (1 << PSZH) */ 41 | #define PSZSH 4 42 | 43 | #elif TGL_FEATURE_RENDER_BITS == 16 44 | 45 | /* 16 bit mode */ 46 | #define RGB_TO_PIXEL(r,g,b) \ 47 | (((r) & 0xF800) | (((g >> 5)) & 0x07E0) | ((b) >> 11)) 48 | typedef unsigned short PIXEL; 49 | #define PSZB 2 50 | #define PSZSH 4 51 | 52 | #elif TGL_FEATURE_RENDER_BITS == 24 53 | 54 | #define RGB_TO_PIXEL(r, g, b) \ 55 | ((((r) << 8) & 0xff0000) | ((b)&0xff00) | ((g) >> 8)) 56 | typedef unsigned char PIXEL; 57 | #define PSZB 3 58 | #define PSZSH 5 59 | 60 | #elif TGL_FEATURE_RENDER_BITS == 32 61 | 62 | #define RGB_TO_PIXEL(r, g, b) \ 63 | (0xFF000000 | ((b) << 16) & 0xFF0000) 64 | 65 | // 0xFFFF0000 == RED 66 | 67 | typedef unsigned int PIXEL; 68 | #define PSZB 4 69 | #define PSZSH 5 70 | 71 | #else 72 | 73 | #error Incorrect number of bits per pixel 74 | 75 | #endif 76 | 77 | typedef struct 78 | { 79 | int xsize, ysize; 80 | int linesize; /* line size, in bytes */ 81 | int mode; 82 | 83 | unsigned short *zbuf; 84 | PIXEL *pbuf; 85 | int frame_buffer_allocated; 86 | 87 | int nb_colors; 88 | unsigned char *dctable; 89 | int *ctable; 90 | PIXEL *current_texture; 91 | } ZBuffer; 92 | 93 | typedef struct 94 | { 95 | int x, y, z; /* integer coordinates in the zbuffer */ 96 | int s, t; /* coordinates for the mapping */ 97 | int r, g, b; /* color indexes */ 98 | 99 | float sz, tz; /* temporary coordinates for mapping */ 100 | } ZBufferPoint; 101 | 102 | /* zbuffer.c */ 103 | 104 | ZBuffer *ZB_open(int xsize, int ysize, int mode, 105 | int nb_colors, 106 | unsigned char *color_indexes, 107 | int *color_table, 108 | void *frame_buffer); 109 | 110 | void ZB_close(ZBuffer *zb); 111 | 112 | void ZB_resize(ZBuffer *zb, void *frame_buffer, int xsize, int ysize); 113 | void ZB_clear(ZBuffer *zb, int clear_z, int z, 114 | int clear_color, int r, int g, int b); 115 | /* linesize is in BYTES */ 116 | void ZB_copyFrameBuffer(ZBuffer *zb, void *buf, int linesize); 117 | 118 | /* zdither.c */ 119 | 120 | void ZB_initDither(ZBuffer *zb, int nb_colors, 121 | unsigned char *color_indexes, int *color_table); 122 | void ZB_closeDither(ZBuffer *zb); 123 | void ZB_ditherFrameBuffer(ZBuffer *zb, unsigned char *dest, 124 | int linesize); 125 | 126 | /* zline.c */ 127 | 128 | void ZB_plot(ZBuffer *zb, ZBufferPoint *p); 129 | void ZB_line(ZBuffer *zb, ZBufferPoint *p1, ZBufferPoint *p2); 130 | void ZB_line_z(ZBuffer *zb, ZBufferPoint *p1, ZBufferPoint *p2); 131 | 132 | /* ztriangle.c */ 133 | 134 | void ZB_setTexture(ZBuffer *zb, PIXEL *texture); 135 | 136 | void ZB_fillTriangleFlat(ZBuffer *zb, 137 | ZBufferPoint *p1, ZBufferPoint *p2, ZBufferPoint *p3); 138 | 139 | void ZB_fillTriangleSmooth(ZBuffer *zb, 140 | ZBufferPoint *p1, ZBufferPoint *p2, ZBufferPoint *p3); 141 | 142 | void ZB_fillTriangleMapping(ZBuffer *zb, 143 | ZBufferPoint *p1, ZBufferPoint *p2, ZBufferPoint *p3); 144 | 145 | void ZB_fillTriangleMappingPerspective(ZBuffer *zb, 146 | ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2); 147 | 148 | typedef void (*ZB_fillTriangleFunc)(ZBuffer *, 149 | ZBufferPoint *, ZBufferPoint *, ZBufferPoint *); 150 | 151 | /* memory.c */ 152 | void gl_free(void *p); 153 | void *gl_malloc(int size); 154 | void *gl_zalloc(int size); 155 | 156 | #endif /* _tgl_zbuffer_h_ */ 157 | -------------------------------------------------------------------------------- /lib/tinygl/zdither.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Highly optimised dithering 16 bits -> 8 bits. 3 | * The formulas were taken in Mesa (Bob Mercier mercier@hollywood.cinenet.net). 4 | */ 5 | 6 | #include 7 | #include 8 | #include "zbuffer.h" 9 | #include 10 | 11 | #if defined(TGL_FEATURE_8_BITS) 12 | 13 | #define _R 5 14 | #define _G 9 15 | #define _B 5 16 | #define _DX 4 17 | #define _DY 4 18 | #define _D (_DX*_DY) 19 | #define _MIX(r,g,b) ( ((g)<<6) | ((b)<<3) | (r) ) 20 | 21 | #define DITHER_TABLE_SIZE (1 << 15) 22 | 23 | #define DITHER_INDEX(r,g,b) ((b) + (g) * _B + (r) * (_B * _G)) 24 | 25 | #define MAXC 256 26 | static int kernel8[_DY*_DX] = { 27 | 0 * MAXC, 8 * MAXC, 2 * MAXC, 10 * MAXC, 28 | 12 * MAXC, 4 * MAXC, 14 * MAXC, 6 * MAXC, 29 | 3 * MAXC, 11 * MAXC, 1 * MAXC, 9 * MAXC, 30 | 15 * MAXC, 7 * MAXC, 13 * MAXC, 5 * MAXC, 31 | }; 32 | 33 | /* we build the color table and the lookup table */ 34 | 35 | void ZB_initDither(ZBuffer *zb,int nb_colors, 36 | unsigned char *color_indexes,int *color_table) 37 | { 38 | int c,r,g,b,i,index,r1,g1,b1; 39 | 40 | if (nb_colors < (_R * _G * _B)) { 41 | fprintf(stderr,"zdither: not enough colors\n"); 42 | exit(1); 43 | } 44 | 45 | for(i=0;inb_colors=nb_colors; 48 | zb->ctable=gl_malloc(nb_colors * sizeof(int)); 49 | 50 | for (r = 0; r < _R; r++) { 51 | for (g = 0; g < _G; g++) { 52 | for (b = 0; b < _B; b++) { 53 | r1=(r*255) / (_R - 1); 54 | g1=(g*255) / (_G - 1); 55 | b1=(b*255) / (_B - 1); 56 | index=DITHER_INDEX(r,g,b); 57 | c=(r1 << 16) | (g1 << 8) | b1; 58 | zb->ctable[index]=c; 59 | color_table[index]=c; 60 | } 61 | } 62 | } 63 | 64 | zb->dctable=gl_malloc( DITHER_TABLE_SIZE ); 65 | 66 | for(i=0;i> 12) & 0x7; 68 | g=(i >> 8) & 0xF; 69 | b=(i >> 3) & 0x7; 70 | index=DITHER_INDEX(r,g,b); 71 | zb->dctable[i]=color_indexes[index]; 72 | } 73 | } 74 | 75 | void ZB_closeDither(ZBuffer *zb) 76 | { 77 | gl_free(zb->ctable); 78 | gl_free(zb->dctable); 79 | } 80 | 81 | #if 0 82 | int ZDither_lookupColor(int r,int g,int b) 83 | { 84 | unsigned char *ctable=zdither_color_table; 85 | return ctable[_MIX(_DITH0(_R, r), _DITH0(_G, g),_DITH0(_B, b))]; 86 | } 87 | #endif 88 | 89 | 90 | #define DITHER_PIXEL2(a) \ 91 | { \ 92 | register int v,t,r,g,c; \ 93 | v=*(unsigned int *)(pp+(a)); \ 94 | g=(v & 0x07DF07DF) + g_d; \ 95 | r=(((v & 0xF800F800) >> 2) + r_d) & 0x70007000; \ 96 | t=r | g; \ 97 | c=ctable[t & 0xFFFF] | (ctable[t >> 16] << 8); \ 98 | *(unsigned short *)(dest+(a))=c; \ 99 | } 100 | 101 | /* NOTE: all the memory access are 16 bit aligned, so if buf or 102 | linesize are not multiple of 2, it cannot work efficiently (or 103 | hang!) */ 104 | 105 | void ZB_ditherFrameBuffer(ZBuffer *zb,unsigned char *buf, 106 | int linesize) 107 | { 108 | int xk,yk,x,y,c1,c2; 109 | unsigned char *dest1; 110 | unsigned short *pp1; 111 | int r_d,g_d,b_d; 112 | unsigned char *ctable=zb->dctable; 113 | register unsigned char *dest; 114 | register unsigned short *pp; 115 | 116 | assert( ((long)buf & 1) == 0 && (linesize & 1) == 0); 117 | 118 | for(yk=0;yk<4;yk++) { 119 | for(xk=0;xk<4;xk+=2) { 120 | #if BYTE_ORDER == BIG_ENDIAN 121 | c1=kernel8[yk*4+xk+1]; 122 | c2=kernel8[yk*4+xk]; 123 | #else 124 | c1=kernel8[yk*4+xk]; 125 | c2=kernel8[yk*4+xk+1]; 126 | #endif 127 | r_d=((c1 << 2) & 0xF800) >> 2; 128 | g_d=(c1 >> 4) & 0x07C0; 129 | b_d=(c1 >> 9) & 0x001F; 130 | 131 | r_d|=(((c2 << 2) & 0xF800) >> 2) << 16; 132 | g_d|=((c2 >> 4) & 0x07C0) << 16; 133 | b_d|=((c2 >> 9) & 0x001F) << 16; 134 | g_d=b_d | g_d; 135 | 136 | dest1=buf + (yk * linesize) + xk; 137 | pp1=zb->pbuf + (yk * zb->xsize) + xk; 138 | 139 | for(y=yk;yysize;y+=4) { 140 | dest=dest1; 141 | pp=pp1; 142 | for(x=xk;xxsize;x+=16) { 143 | 144 | DITHER_PIXEL2(0); 145 | DITHER_PIXEL2(1*4); 146 | DITHER_PIXEL2(2*4); 147 | DITHER_PIXEL2(3*4); 148 | 149 | pp+=16; 150 | dest+=16; 151 | } 152 | dest1+=linesize*4; 153 | pp1+=zb->xsize*4; 154 | } 155 | } 156 | } 157 | } 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /lib/tinygl/zfeatures.h: -------------------------------------------------------------------------------- 1 | #ifndef _tgl_features_h_ 2 | #define _tgl_features_h_ 3 | 4 | /* Define BYTE_ORDER correctly where missing */ 5 | #ifndef BYTE_ORDER 6 | #define LITTLE_ENDIAN 1234 7 | #define BIG_ENDIAN 4321 8 | 9 | #if (defined(__i386__) || defined(__i386)) || \ 10 | defined(__ia64__) || defined(WIN32) || defined(_WIN64) ||\ 11 | (defined(__alpha__) || defined(__alpha)) || \ 12 | defined(__arm__) || \ 13 | (defined(__mips__) && defined(__MIPSEL__)) || \ 14 | defined(__SYMBIAN32__) || \ 15 | defined(__x86_64__) || \ 16 | defined(__LITTLE_ENDIAN__) 17 | #define BYTE_ORDER LITTLE_ENDIAN 18 | #else 19 | #define BYTE_ORDER BIG_ENDIAN 20 | #endif 21 | 22 | #endif 23 | 24 | 25 | /* It is possible to enable/disable (compile time) features in this 26 | header file. */ 27 | 28 | #define TGL_FEATURE_ARRAYS 1 29 | #define TGL_FEATURE_DISPLAYLISTS 1 30 | #define TGL_FEATURE_POLYGON_OFFSET 1 31 | 32 | /* 33 | * Matrix of internal and external pixel formats supported. 'Y' means 34 | * supported. 35 | * 36 | * External 8 16 24 32 37 | * Internal 38 | * 15 . . . . 39 | * 16 Y Y Y Y 40 | * 24 . Y Y . 41 | * 32 . Y . Y 42 | * 43 | * 44 | * 15 bpp does not work yet (although it is easy to add it - ask me if 45 | * you need it). 46 | * 47 | * Internal pixel format: see TGL_FEATURE_RENDER_BITS 48 | * External pixel format: see TGL_FEATURE_xxx_BITS 49 | */ 50 | 51 | /* enable various convertion code from internal pixel format (usually 52 | 16 bits per pixel) to any external format */ 53 | #define TGL_FEATURE_16_BITS 1 54 | //#define TGL_FEATURE_8_BITS 1 55 | //#define TGL_FEATURE_24_BITS 1 56 | //#define TGL_FEATURE_32_BITS 1 57 | 58 | 59 | //#define TGL_FEATURE_RENDER_BITS 15 60 | #define TGL_FEATURE_RENDER_BITS 16 61 | //#define TGL_FEATURE_RENDER_BITS 24 62 | //#define TGL_FEATURE_RENDER_BITS 32 63 | 64 | #endif /* _tgl_features_h_ */ 65 | -------------------------------------------------------------------------------- /lib/tinygl/zline.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zbuffer.h" 3 | 4 | 5 | #define ZCMP(z,zpix) ((z) >= (zpix)) 6 | 7 | void ZB_plot(ZBuffer * zb, ZBufferPoint * p) 8 | { 9 | unsigned short *pz; 10 | PIXEL *pp; 11 | int zz; 12 | 13 | pz = zb->zbuf + (p->y * zb->xsize + p->x); 14 | pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB); 15 | zz = p->z >> ZB_POINT_Z_FRAC_BITS; 16 | if (ZCMP(zz, *pz)) { 17 | #if TGL_FEATURE_RENDER_BITS == 24 18 | pp[0]=p->r>>8; 19 | pp[1]=p->g>>8; 20 | pp[2]=p->b>>8; 21 | #else 22 | *pp = RGB_TO_PIXEL(p->r, p->g, p->b); 23 | #endif 24 | *pz = zz; 25 | } 26 | } 27 | 28 | #define INTERP_Z 29 | static void ZB_line_flat_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2, 30 | int color) 31 | { 32 | #include "zline.h" 33 | } 34 | 35 | /* line with color interpolation */ 36 | #define INTERP_Z 37 | #define INTERP_RGB 38 | static void ZB_line_interp_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 39 | { 40 | #include "zline.h" 41 | } 42 | 43 | /* no Z interpolation */ 44 | 45 | static void ZB_line_flat(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2, 46 | int color) 47 | { 48 | #include "zline.h" 49 | } 50 | 51 | #define INTERP_RGB 52 | static void ZB_line_interp(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 53 | { 54 | #include "zline.h" 55 | } 56 | 57 | void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 58 | { 59 | int color1, color2; 60 | 61 | color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b); 62 | color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b); 63 | 64 | /* choose if the line should have its color interpolated or not */ 65 | if (color1 == color2) { 66 | ZB_line_flat_z(zb, p1, p2, color1); 67 | } else { 68 | ZB_line_interp_z(zb, p1, p2); 69 | } 70 | } 71 | 72 | void ZB_line(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2) 73 | { 74 | int color1, color2; 75 | 76 | color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b); 77 | color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b); 78 | 79 | /* choose if the line should have its color interpolated or not */ 80 | if (color1 == color2) { 81 | ZB_line_flat(zb, p1, p2, color1); 82 | } else { 83 | ZB_line_interp(zb, p1, p2); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /lib/tinygl/zline.h: -------------------------------------------------------------------------------- 1 | { 2 | int n, dx, dy, sx, pp_inc_1, pp_inc_2; 3 | register int a; 4 | register PIXEL *pp; 5 | #if defined(INTERP_RGB) || TGL_FEATURE_RENDER_BITS == 24 6 | register unsigned int r, g, b; 7 | #endif 8 | #ifdef INTERP_RGB 9 | register unsigned int rinc, ginc, binc; 10 | #endif 11 | #ifdef INTERP_Z 12 | register unsigned short *pz; 13 | int zinc; 14 | register int z, zz; 15 | #endif 16 | 17 | if (p1->y > p2->y || (p1->y == p2->y && p1->x > p2->x)) { 18 | ZBufferPoint *tmp; 19 | tmp = p1; 20 | p1 = p2; 21 | p2 = tmp; 22 | } 23 | sx = zb->xsize; 24 | pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p1->y + p1->x * PSZB); 25 | #ifdef INTERP_Z 26 | pz = zb->zbuf + (p1->y * sx + p1->x); 27 | z = p1->z; 28 | #endif 29 | 30 | dx = p2->x - p1->x; 31 | dy = p2->y - p1->y; 32 | #ifdef INTERP_RGB 33 | r = p2->r << 8; 34 | g = p2->g << 8; 35 | b = p2->b << 8; 36 | #elif TGL_FEATURE_RENDER_BITS == 24 37 | /* for 24 bits, we store the colors in different variables */ 38 | r = p2->r >> 8; 39 | g = p2->g >> 8; 40 | b = p2->b >> 8; 41 | #endif 42 | 43 | #ifdef INTERP_RGB 44 | #define RGB(x) x 45 | #if TGL_FEATURE_RENDER_BITS == 24 46 | #define RGBPIXEL pp[0] = r >> 16, pp[1] = g >> 16, pp[2] = b >> 16 47 | #else 48 | #define RGBPIXEL *pp = RGB_TO_PIXEL(r >> 8,g >> 8,b >> 8) 49 | #endif 50 | #else /* INTERP_RGB */ 51 | #define RGB(x) 52 | #if TGL_FEATURE_RENDER_BITS == 24 53 | #define RGBPIXEL pp[0] = r, pp[1] = g, pp[2] = b 54 | #else 55 | #define RGBPIXEL *pp = color 56 | #endif 57 | #endif /* INTERP_RGB */ 58 | 59 | #ifdef INTERP_Z 60 | #define ZZ(x) x 61 | #define PUTPIXEL() \ 62 | { \ 63 | zz=z >> ZB_POINT_Z_FRAC_BITS; \ 64 | if (ZCMP(zz,*pz)) { \ 65 | RGBPIXEL; \ 66 | *pz=zz; \ 67 | } \ 68 | } 69 | #else /* INTERP_Z */ 70 | #define ZZ(x) 71 | #define PUTPIXEL() RGBPIXEL 72 | #endif /* INTERP_Z */ 73 | 74 | #define DRAWLINE(dx,dy,inc_1,inc_2) \ 75 | n=dx;\ 76 | ZZ(zinc=(p2->z-p1->z)/n);\ 77 | RGB(rinc=((p2->r-p1->r) << 8)/n;\ 78 | ginc=((p2->g-p1->g) << 8)/n;\ 79 | binc=((p2->b-p1->b) << 8)/n);\ 80 | a=2*dy-dx;\ 81 | dy=2*dy;\ 82 | dx=2*dx-dy;\ 83 | pp_inc_1 = (inc_1) * PSZB;\ 84 | pp_inc_2 = (inc_2) * PSZB;\ 85 | do {\ 86 | PUTPIXEL();\ 87 | ZZ(z+=zinc);\ 88 | RGB(r+=rinc;g+=ginc;b+=binc);\ 89 | if (a>0) { pp=(PIXEL *)((char *)pp + pp_inc_1); ZZ(pz+=(inc_1)); a-=dx; }\ 90 | else { pp=(PIXEL *)((char *)pp + pp_inc_2); ZZ(pz+=(inc_2)); a+=dy; }\ 91 | } while (--n >= 0); 92 | 93 | /* fin macro */ 94 | 95 | if (dx == 0 && dy == 0) { 96 | PUTPIXEL(); 97 | } else if (dx > 0) { 98 | if (dx >= dy) { 99 | DRAWLINE(dx, dy, sx + 1, 1); 100 | } else { 101 | DRAWLINE(dy, dx, sx + 1, sx); 102 | } 103 | } else { 104 | dx = -dx; 105 | if (dx >= dy) { 106 | DRAWLINE(dx, dy, sx - 1, -1); 107 | } else { 108 | DRAWLINE(dy, dx, sx - 1, sx); 109 | } 110 | } 111 | } 112 | 113 | #undef INTERP_Z 114 | #undef INTERP_RGB 115 | 116 | /* internal defines */ 117 | #undef DRAWLINE 118 | #undef PUTPIXEL 119 | #undef ZZ 120 | #undef RGB 121 | #undef RGBPIXEL 122 | -------------------------------------------------------------------------------- /lib/tinygl/zmath.h: -------------------------------------------------------------------------------- 1 | #ifndef __ZMATH__ 2 | #define __ZMATH__ 3 | 4 | /* Matrix & Vertex */ 5 | 6 | typedef struct { 7 | float m[4][4]; 8 | } M4; 9 | 10 | typedef struct { 11 | float m[3][3]; 12 | } M3; 13 | 14 | typedef struct { 15 | float m[3][4]; 16 | } M34; 17 | 18 | 19 | #define X v[0] 20 | #define Y v[1] 21 | #define Z v[2] 22 | #define W v[3] 23 | 24 | typedef struct { 25 | float v[3]; 26 | } V3; 27 | 28 | typedef struct { 29 | float v[4]; 30 | } V4; 31 | 32 | void gl_M4_Id(M4 *a); 33 | int gl_M4_IsId(M4 *a); 34 | void gl_M4_Move(M4 *a,M4 *b); 35 | void gl_MoveV3(V3 *a,V3 *b); 36 | void gl_MulM4V3(V3 *a,M4 *b,V3 *c); 37 | void gl_MulM3V3(V3 *a,M4 *b,V3 *c); 38 | 39 | void gl_M4_MulV4(V4 * a,M4 *b,V4 * c); 40 | void gl_M4_InvOrtho(M4 *a,M4 b); 41 | void gl_M4_Inv(M4 *a,M4 *b); 42 | void gl_M4_Mul(M4 *c,M4 *a,M4 *b); 43 | void gl_M4_MulLeft(M4 *c,M4 *a); 44 | void gl_M4_Transpose(M4 *a,M4 *b); 45 | void gl_M4_Rotate(M4 *c,float t,int u); 46 | int gl_V3_Norm(V3 *a); 47 | 48 | V3 gl_V3_New(float x,float y,float z); 49 | V4 gl_V4_New(float x,float y,float z,float w); 50 | 51 | int gl_Matrix_Inv(float *r,float *m,int n); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/coremark/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int coremark_main(void); 4 | 5 | int main (void) 6 | { 7 | puts("\e[36mAllwinner V3S Coremark\e[0m"); 8 | while(1) 9 | { 10 | printf("Benchmark started\r"); 11 | coremark_main(); 12 | printf("Press any key\r"); 13 | getchar(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/coremark/makefile: -------------------------------------------------------------------------------- 1 | NAME = out/coremark 2 | BASE = ../../ 3 | DIRS = . $(BASE)drv 4 | CFLAGS = -DITERATIONS=60000 5 | include $(BASE)common.mk 6 | -------------------------------------------------------------------------------- /src/coremark/out/boot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/src/coremark/out/boot.bin -------------------------------------------------------------------------------- /src/coremark/out/coremark.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/src/coremark/out/coremark.bin -------------------------------------------------------------------------------- /src/coremark/readme.md: -------------------------------------------------------------------------------- 1 | # V3S [CoreMark](https://www.eembc.org/coremark/) 2 | 3 | V3S performance on bare metal: 4 | ``` 5 | Allwinner V3S Coremark 6 | 2K performance run parameters for coremark. 7 | CoreMark Size : 666 8 | Total ticks : 19341 9 | Total time (secs): 19.341000 10 | Iterations/Sec : 3102.218086 11 | Iterations : 60000 12 | Compiler version : GCC10.3.1 20210824 (release) 13 | Compiler flags : -O3 14 | Memory location : STACK 15 | seedcrc : 0xe9f5 16 | [0]crclist : 0xe714 17 | [0]crcmatrix : 0x1fd7 18 | [0]crcstate : 0x8e3a 19 | [0]crcfinal : 0xbd59 20 | Correct operation validated. See README.md for run and reporting rules. 21 | CoreMark 1.0 : 3102.218086 / GCC10.3.1 20210824 (release) -O3 / STACK 22 | ``` 23 | Comparison with other popular chips: 24 | 25 | | Chip | Freq (MHz) | CoreMark | 26 | |--------------------------------------------------------------------------|------------|-------------| 27 | | [V3S](./) | 1008 | 3102 | 28 | | [F1C100S](https://github.com/minilogic/f1c_nonos/tree/main/src/coremark) | 576 | 1296 | 29 | | [iMXRT1062](https://www.pjrc.com/store/teensy40_pins.html) | 600 | 2314 | 30 | | [ESP32 S2](https://github.com/ochrin/coremark) | 80/160/240 | 157/315/472 | 31 | | [ESP8266](https://github.com/ochrin/coremark) | 80 | 191 | 32 | | [nRF52840](https://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.1.pdf) | 64 | 212 | 33 | | [STM32F427](https://github.com/hacklabos/CoremarkPlatform) | 180 | 258 | 34 | | [STM32F103](https://github.com/hacklabos/CoremarkPlatform) | 72/128 | 95/146 | 35 | | [RP2040](https://github.com/nickfox-taterli/pico-coremark) | 125 | 157 | 36 | -------------------------------------------------------------------------------- /src/tinygl/gears/makefile: -------------------------------------------------------------------------------- 1 | NAME = out/gears 2 | BASE = ../../../ 3 | DIRS = . $(BASE)drv $(BASE)lib/tinygl 4 | #LFLAGS := --specs=nano.specs 5 | include $(BASE)common.mk 6 | -------------------------------------------------------------------------------- /src/tinygl/gears/out/boot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/src/tinygl/gears/out/boot.bin -------------------------------------------------------------------------------- /src/tinygl/gears/out/gears.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/src/tinygl/gears/out/gears.bin -------------------------------------------------------------------------------- /src/tinygl/gears/readme.md: -------------------------------------------------------------------------------- 1 | # TinyGl Gears Demo 2 | 3 | Based on the [source code](http://ftp.kolibrios.org/arch/libraries/TinyGL/examples) from the KolibriOs project. 4 | 5 | https://user-images.githubusercontent.com/108269914/219818393-5c48d4a0-1d87-4324-a51a-ade433511e81.mp4 6 | -------------------------------------------------------------------------------- /src/tinygl/wave/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sys.h" 4 | #include "gl.h" 5 | #include "glu.h" 6 | #include "zbuffer.h" 7 | 8 | float angle = 0.0; 9 | 10 | GLfloat lightpos[4] = {0.0, 2.5, 0.0, 1.0}; 11 | GLfloat lightdirect[3] = {0.0, 0.0, 0.0}; 12 | 13 | #define DIM 6 14 | #define DIM2 (1.0/(2.0*DIM)) 15 | #define T 1 16 | 17 | float rad[2*DIM+1][2*DIM]; 18 | 19 | void DrawPlan(int zoom) 20 | { 21 | float v1,v2,v3,v4, ang; 22 | int i,j,n; 23 | n = 1; 24 | i = 0; 25 | j = 0; 26 | glLoadIdentity(); 27 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 28 | glTranslatef(0.0, 0.0, zoom); 29 | glRotatef(30.0, 1.0, 0.0, 0.0); 30 | glRotatef(angle, 0.0, 1.0, 0.0); 31 | glLightfv(GL_LIGHT0, GL_POSITION, lightpos); 32 | glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, lightdirect); 33 | for (i = -DIM; iwidth, display->height, 16); 76 | lay_config(0, display->width, display->height, 0, 0, 16, fb, 0, 5 << 8); 77 | lay_update(0); 78 | delay(100); 79 | disp_backlight(100); 80 | 81 | frameBuffer = ZB_open(display->width, display->height, ZB_MODE_5R6G5B, 0, 82 | NULL, NULL, NULL); 83 | glInit(frameBuffer); 84 | glMatrixMode(GL_MODELVIEW); 85 | glLoadIdentity(); 86 | glClearColor (0, 0.0, 0.0, 1.0); 87 | glEnable(GL_LIGHTING); 88 | glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 0.0); 89 | glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180.0); 90 | glEnable(GL_LIGHT0); 91 | glNormal3f(0.0, 1.0, 0.0); 92 | glEnable(GL_COLOR_MATERIAL); 93 | glEnable(GL_NORMALIZE); 94 | glClearDepth(1.0); 95 | glEnable( GL_CULL_FACE ); 96 | glEnable(GL_DEPTH_TEST); 97 | for (int i = -DIM; iwidth, display->height); 106 | glMatrixMode(GL_PROJECTION); 107 | glLoadIdentity(); 108 | gluPerspective(30.0, (GLfloat)display->width / display->height, 1.0, 300.0); 109 | glMatrixMode(GL_MODELVIEW); 110 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 111 | glPolygonMode(GL_FRONT,GL_FILL); 112 | //glPolygonMode(GL_FRONT,GL_LINE); 113 | //glPolygonMode(GL_FRONT,GL_POINT); 114 | while(1) 115 | { 116 | angle += 0.1; 117 | if(angle == 360.0) angle = 0.0; 118 | DrawPlan(i); 119 | ZB_copyFrameBuffer(frameBuffer, fb, display->width * sizeof(PIXEL)); 120 | if(ctr_ms > 50) 121 | { 122 | ctr_ms = 0; 123 | if(i <= -50.0) j = ZOOM; 124 | if(i >= -10.0) j = -ZOOM; 125 | i += j; 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/tinygl/wave/makefile: -------------------------------------------------------------------------------- 1 | NAME = out/wave 2 | BASE = ../../../ 3 | DIRS = . $(BASE)drv $(BASE)lib/tinygl 4 | include $(BASE)common.mk 5 | -------------------------------------------------------------------------------- /src/tinygl/wave/out/boot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/src/tinygl/wave/out/boot.bin -------------------------------------------------------------------------------- /src/tinygl/wave/out/wave.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/src/tinygl/wave/out/wave.bin -------------------------------------------------------------------------------- /src/tinygl/wave/readme.md: -------------------------------------------------------------------------------- 1 | # TinyGl Wave Demo 2 | 3 | Based on the [source code](http://ftp.kolibrios.org/arch/libraries/TinyGL/examples) from the KolibriOs project. 4 | -------------------------------------------------------------------------------- /tools/sunxi/libusb-1.0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/tools/sunxi/libusb-1.0.dll -------------------------------------------------------------------------------- /tools/sunxi/libwinpthread-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/tools/sunxi/libwinpthread-1.dll -------------------------------------------------------------------------------- /tools/sunxi/mksunxi.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/tools/sunxi/mksunxi.exe -------------------------------------------------------------------------------- /tools/sunxi/msvcr120d.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/tools/sunxi/msvcr120d.dll -------------------------------------------------------------------------------- /tools/sunxi/sunxi-fel.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/tools/sunxi/sunxi-fel.exe -------------------------------------------------------------------------------- /tools/zadig/Zadig.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://zadig.akeo.ie/# 3 | -------------------------------------------------------------------------------- /tools/zadig/zadig-2.7.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minilogic/v3s_nonos/1a00cb42e0fe6d4b22bea7fbca963c0bb87f0e1f/tools/zadig/zadig-2.7.exe --------------------------------------------------------------------------------