├── .gitignore
├── .gitmodules
├── CMakeLists.txt
├── README.md
├── components
├── mad
│ ├── CMakeLists.txt
│ ├── D.dat
│ ├── bit.c
│ ├── bit.h
│ ├── config.h
│ ├── decoder.c
│ ├── decoder.h
│ ├── fixed.c
│ ├── fixed.h
│ ├── frame.c
│ ├── frame.h
│ ├── global.h
│ ├── huffman.c
│ ├── huffman.h
│ ├── imdct_s.dat
│ ├── layer12.c
│ ├── layer12.h
│ ├── layer3.c
│ ├── layer3.h
│ ├── mad.h
│ ├── qc_table.dat
│ ├── rq_table.dat
│ ├── sf_table.dat
│ ├── stream.c
│ ├── stream.h
│ ├── synth.c
│ ├── synth.h
│ ├── timer.c
│ ├── timer.h
│ ├── version.c
│ └── version.h
└── ugfx
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── drivers
│ └── gdisp
│ │ ├── CUBE0414
│ │ ├── CUBE0414.h
│ │ ├── driver.mk
│ │ ├── gdisp_lld_CUBE0414.c
│ │ ├── gdisp_lld_board.h
│ │ └── gdisp_lld_config.h
│ │ ├── ST7735
│ │ ├── ST7735.h
│ │ ├── driver.mk
│ │ ├── gdisp_lld_ST7735.c
│ │ ├── gdisp_lld_board.h
│ │ └── gdisp_lld_config.h
│ │ ├── ST7789
│ │ ├── ST7789.h
│ │ ├── driver.mk
│ │ ├── gdisp_lld_ST7789.c
│ │ ├── gdisp_lld_board.h
│ │ └── gdisp_lld_config.h
│ │ └── WS2812
│ │ ├── driver.mk
│ │ ├── gdisp_lld_WS2812.c
│ │ ├── gdisp_lld_board.h
│ │ └── gdisp_lld_config.h
│ ├── ffconf.h
│ ├── gfx.h
│ ├── gfx.mk
│ ├── gfxconf.h
│ ├── mf_bwfont.h
│ ├── mf_rlefont.h
│ ├── mf_scaledfont.h
│ ├── pffconf.h
│ └── src
│ ├── gadc
│ ├── gadc.c
│ ├── gadc.h
│ ├── gadc.mk
│ ├── gadc_driver.h
│ ├── gadc_mk.c
│ ├── gadc_options.h
│ └── gadc_rules.h
│ ├── gaudio
│ ├── gaudio.c
│ ├── gaudio.h
│ ├── gaudio.mk
│ ├── gaudio_driver_play.h
│ ├── gaudio_driver_record.h
│ ├── gaudio_mk.c
│ ├── gaudio_options.h
│ └── gaudio_rules.h
│ ├── gdisp
│ ├── fonts
│ │ ├── DejaVuSans-Bold.ttf
│ │ ├── DejaVuSans.license
│ │ ├── DejaVuSans.ttf
│ │ ├── DejaVuSans10.c
│ │ ├── DejaVuSans12.c
│ │ ├── DejaVuSans12_aa.c
│ │ ├── DejaVuSans16.c
│ │ ├── DejaVuSans16_aa.c
│ │ ├── DejaVuSans20.c
│ │ ├── DejaVuSans20_aa.c
│ │ ├── DejaVuSans24.c
│ │ ├── DejaVuSans24_aa.c
│ │ ├── DejaVuSans32.c
│ │ ├── DejaVuSans32_aa.c
│ │ ├── DejaVuSansBold12.c
│ │ ├── DejaVuSansBold12_aa.c
│ │ ├── DejaVuSerif.license
│ │ ├── DejaVuSerif.ttf
│ │ ├── LargeNumbers.c
│ │ ├── UI1.c
│ │ ├── UI2.c
│ │ ├── build_fonts.sh
│ │ ├── fixed_10x20.bdf
│ │ ├── fixed_10x20.c
│ │ ├── fixed_5x8.bdf
│ │ ├── fixed_5x8.c
│ │ ├── fixed_7x14.bdf
│ │ ├── fixed_7x14.c
│ │ └── fonts.h
│ ├── gdisp.c
│ ├── gdisp.h
│ ├── gdisp.mk
│ ├── gdisp_colors.h
│ ├── gdisp_driver.h
│ ├── gdisp_fonts.c
│ ├── gdisp_image.c
│ ├── gdisp_image.h
│ ├── gdisp_image_bmp.c
│ ├── gdisp_image_gif.c
│ ├── gdisp_image_jpg.c
│ ├── gdisp_image_native.c
│ ├── gdisp_image_png.c
│ ├── gdisp_image_support.h
│ ├── gdisp_mk.c
│ ├── gdisp_options.h
│ ├── gdisp_pixmap.c
│ ├── gdisp_pixmap.h
│ ├── gdisp_rules.h
│ └── mcufont
│ │ ├── mcufont.h
│ │ ├── mcufont.mk
│ │ ├── mf_bwfont.c
│ │ ├── mf_bwfont.h
│ │ ├── mf_config.h
│ │ ├── mf_encoding.c
│ │ ├── mf_encoding.h
│ │ ├── mf_font.c
│ │ ├── mf_font.h
│ │ ├── mf_justify.c
│ │ ├── mf_justify.h
│ │ ├── mf_kerning.c
│ │ ├── mf_kerning.h
│ │ ├── mf_rlefont.c
│ │ ├── mf_rlefont.h
│ │ ├── mf_scaledfont.c
│ │ ├── mf_scaledfont.h
│ │ ├── mf_wordwrap.c
│ │ └── mf_wordwrap.h
│ ├── gdriver
│ ├── gdriver.c
│ ├── gdriver.h
│ ├── gdriver.mk
│ ├── gdriver_mk.c
│ ├── gdriver_options.h
│ └── gdriver_rules.h
│ ├── gevent
│ ├── gevent.c
│ ├── gevent.h
│ ├── gevent.mk
│ ├── gevent_mk.c
│ ├── gevent_options.h
│ └── gevent_rules.h
│ ├── gfile
│ ├── gfile.c
│ ├── gfile.h
│ ├── gfile.mk
│ ├── gfile_fatfs_diskio_chibios.c
│ ├── gfile_fatfs_wrapper.c
│ ├── gfile_fatfs_wrapper.h
│ ├── gfile_fs.h
│ ├── gfile_fs_chibios.c
│ ├── gfile_fs_fatfs.c
│ ├── gfile_fs_mem.c
│ ├── gfile_fs_native.c
│ ├── gfile_fs_petitfs.c
│ ├── gfile_fs_ram.c
│ ├── gfile_fs_rom.c
│ ├── gfile_fs_strings.c
│ ├── gfile_mk.c
│ ├── gfile_options.h
│ ├── gfile_petitfs_diskio_chibios.c
│ ├── gfile_petitfs_wrapper.c
│ ├── gfile_petitfs_wrapper.h
│ ├── gfile_printg.c
│ ├── gfile_rules.h
│ ├── gfile_scang.c
│ └── gfile_stdio.c
│ ├── gfx.c
│ ├── gfx_compilers.h
│ ├── gfx_mk.c
│ ├── ginput
│ ├── ginput.c
│ ├── ginput.h
│ ├── ginput.mk
│ ├── ginput_dial.c
│ ├── ginput_dial.h
│ ├── ginput_driver_dial.h
│ ├── ginput_driver_keyboard.h
│ ├── ginput_driver_mouse.h
│ ├── ginput_driver_toggle.h
│ ├── ginput_keyboard.c
│ ├── ginput_keyboard.h
│ ├── ginput_keyboard_microcode.c
│ ├── ginput_keyboard_microcode.h
│ ├── ginput_mk.c
│ ├── ginput_mouse.c
│ ├── ginput_mouse.h
│ ├── ginput_options.h
│ ├── ginput_rules.h
│ ├── ginput_toggle.c
│ └── ginput_toggle.h
│ ├── gmisc
│ ├── gmisc.c
│ ├── gmisc.h
│ ├── gmisc.mk
│ ├── gmisc_arrayops.c
│ ├── gmisc_hittest.c
│ ├── gmisc_matrix2d.c
│ ├── gmisc_mk.c
│ ├── gmisc_options.h
│ ├── gmisc_rules.h
│ └── gmisc_trig.c
│ ├── gos
│ ├── gos.h
│ ├── gos.mk
│ ├── gos_arduino.c
│ ├── gos_arduino.h
│ ├── gos_chibios.c
│ ├── gos_chibios.h
│ ├── gos_cmsis.c
│ ├── gos_cmsis.h
│ ├── gos_cmsis2.c
│ ├── gos_cmsis2.h
│ ├── gos_ecos.c
│ ├── gos_ecos.h
│ ├── gos_freertos.c
│ ├── gos_freertos.h
│ ├── gos_keil.h
│ ├── gos_linux.c
│ ├── gos_linux.h
│ ├── gos_mk.c
│ ├── gos_nios.c
│ ├── gos_nios.h
│ ├── gos_options.h
│ ├── gos_osx.c
│ ├── gos_osx.h
│ ├── gos_qt.cpp
│ ├── gos_qt.h
│ ├── gos_raw32.c
│ ├── gos_raw32.h
│ ├── gos_rawrtos.c
│ ├── gos_rawrtos.h
│ ├── gos_rtx5.h
│ ├── gos_rules.h
│ ├── gos_win32.c
│ ├── gos_win32.h
│ ├── gos_x_heap.c
│ ├── gos_x_heap.h
│ ├── gos_x_threads.c
│ ├── gos_x_threads.h
│ ├── gos_x_threads_cortexm01.h
│ ├── gos_x_threads_cortexm347.h
│ ├── gos_x_threads_cortexm47fp.h
│ ├── gos_zephyr.c
│ └── gos_zephyr.h
│ ├── gqueue
│ ├── gqueue.c
│ ├── gqueue.h
│ ├── gqueue.mk
│ ├── gqueue_mk.c
│ ├── gqueue_options.h
│ └── gqueue_rules.h
│ ├── gtimer
│ ├── gtimer.c
│ ├── gtimer.h
│ ├── gtimer.mk
│ ├── gtimer_mk.c
│ ├── gtimer_options.h
│ └── gtimer_rules.h
│ ├── gtrans
│ ├── gtrans.c
│ ├── gtrans.h
│ ├── gtrans.mk
│ ├── gtrans_mk.c
│ ├── gtrans_options.h
│ └── gtrans_rules.h
│ └── gwin
│ ├── gwin.c
│ ├── gwin.h
│ ├── gwin.mk
│ ├── gwin_button.c
│ ├── gwin_button.h
│ ├── gwin_checkbox.c
│ ├── gwin_checkbox.h
│ ├── gwin_class.h
│ ├── gwin_console.c
│ ├── gwin_console.h
│ ├── gwin_container.c
│ ├── gwin_container.h
│ ├── gwin_frame.c
│ ├── gwin_frame.h
│ ├── gwin_gl3d.c
│ ├── gwin_gl3d.h
│ ├── gwin_graph.c
│ ├── gwin_graph.h
│ ├── gwin_image.c
│ ├── gwin_image.h
│ ├── gwin_keyboard.c
│ ├── gwin_keyboard.h
│ ├── gwin_keyboard_layout.c
│ ├── gwin_keyboard_layout.h
│ ├── gwin_label.c
│ ├── gwin_label.h
│ ├── gwin_list.c
│ ├── gwin_list.h
│ ├── gwin_mk.c
│ ├── gwin_options.h
│ ├── gwin_progressbar.c
│ ├── gwin_progressbar.h
│ ├── gwin_radio.c
│ ├── gwin_radio.h
│ ├── gwin_rules.h
│ ├── gwin_slider.c
│ ├── gwin_slider.h
│ ├── gwin_tabset.c
│ ├── gwin_tabset.h
│ ├── gwin_textedit.c
│ ├── gwin_textedit.h
│ ├── gwin_widget.c
│ ├── gwin_widget.h
│ └── gwin_wm.c
├── docs
├── acode.jpg
├── cube0414.png
├── st7735lin.png
├── st7789band.png
├── st7789log.png
├── st7789vu.png
└── ws2812.png
├── main
├── CMakeLists.txt
├── Kconfig.projbuild
├── inc
│ ├── board
│ │ ├── cube0414.h
│ │ ├── st7735.h
│ │ ├── st7789.h
│ │ └── ws2812.h
│ ├── chip
│ │ ├── bt.h
│ │ ├── i2s.h
│ │ ├── nvs.h
│ │ └── spi.h
│ ├── core
│ │ ├── app.h
│ │ └── os.h
│ └── user
│ │ ├── ain.h
│ │ ├── audio_player.h
│ │ ├── audio_render.h
│ │ ├── ble_app.h
│ │ ├── ble_gatts.h
│ │ ├── bt_app.h
│ │ ├── bt_av.h
│ │ ├── fft.h
│ │ ├── key.h
│ │ ├── key_handle.h
│ │ ├── led.h
│ │ ├── ota.h
│ │ ├── vfx.h
│ │ ├── vfx_bitmap.h
│ │ └── vfx_core.h
├── res
│ └── snd
│ │ ├── snd0.mp3
│ │ ├── snd1.mp3
│ │ ├── snd2.mp3
│ │ └── snd3.mp3
└── src
│ ├── app_main.c
│ ├── board
│ ├── cube0414.c
│ ├── st7735.c
│ ├── st7789.c
│ └── ws2812.c
│ ├── chip
│ ├── bt.c
│ ├── i2s.c
│ ├── nvs.c
│ └── spi.c
│ ├── core
│ ├── app.c
│ └── os.c
│ └── user
│ ├── ain.c
│ ├── audio_player.c
│ ├── audio_render.c
│ ├── ble_app.c
│ ├── ble_gatts.c
│ ├── bt_app.c
│ ├── bt_av.c
│ ├── fft.c
│ ├── key.c
│ ├── key_handle.c
│ ├── led.c
│ ├── ota.c
│ ├── vfx.c
│ ├── vfx_bitmap.c
│ └── vfx_core.c
├── partitions.csv
└── sdkconfig.defaults
/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | .*
3 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "esp-idf"]
2 | path = esp-idf
3 | url = https://github.com/espressif/esp-idf
4 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 |
3 | set(SUPPORTED_TARGETS esp32)
4 | include($ENV{IDF_PATH}/tools/cmake/project.cmake)
5 | project(bluetooth_visual_speaker)
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Bluetooth Visual Speaker
2 | ========================
3 |
4 | Bluetooth Visual Speaker based on ESP32 chip.
5 |
6 | ## Main Features
7 |
8 | * A2DP audio streaming
9 | * I2S & PDM input / I2S output
10 | * VFX output (Audio FFT / Rainbow / Starsky / ...)
11 | * BLE control interface (OTA firmware update / VFX remote control)
12 | * Audio prompt (Connected / Disconnected / Sleep / Wake-Up)
13 | * Sleep & Wake-Up key
14 |
15 | ## Preparing
16 |
17 | ### Obtain the source
18 |
19 | ```
20 | git clone --recursive https://github.com/redchenjs/bluetooth_visual_speaker_esp32.git
21 | ```
22 |
23 | ### Update an existing repository
24 |
25 | ```
26 | git pull
27 | git submodule update --init --recursive
28 | ```
29 |
30 | ### Setup the tools
31 |
32 | ```
33 | ./esp-idf/install.sh
34 | ```
35 |
36 | ## Building
37 |
38 | ### Setup the environment variables
39 |
40 | ```
41 | export IDF_PATH=$PWD/esp-idf
42 | source ./esp-idf/export.sh
43 | ```
44 |
45 | ### Configure
46 |
47 | ```
48 | idf.py menuconfig
49 | ```
50 |
51 | * All project configurations are under the `Bluetooth Visual Speaker` menu.
52 |
53 | ### Flash & Monitor
54 |
55 | ```
56 | idf.py flash monitor
57 | ```
58 |
59 | ## VFX on ST7789 135x240 LCD Panel (12-Band Spectrum)
60 |
61 |
62 |
63 | ## VFX on ST7789 135x240 LCD Panel (VU Meter)
64 |
65 |
66 |
67 | ## VFX on ST7735 80x160 LCD Panel (Linear Spectrum)
68 |
69 |
70 |
71 | ## VFX on ST7789 135x240 LCD Panel (Logarithmic Spectrum)
72 |
73 |
74 |
75 | ## VFX on WS2812 8x8 LED Panel (Rainbow)
76 |
77 |
78 |
79 | ## VFX on CUBE0414 8x8x8 LED Light Cube
80 |
81 |
82 |
83 | ## Mini-Program Code
84 |
85 |
86 |
87 | ## Videos Links
88 |
89 | * [音乐全彩光立方演示](https://www.bilibili.com/video/av25188707) ([YouTube](https://www.youtube.com/watch?v=F8nfA_mEhPg))
90 | * [音乐全彩光立方配套微信小程序](https://www.bilibili.com/video/av83055233) ([YouTube](https://www.youtube.com/watch?v=HlruQqkIGtc))
91 |
--------------------------------------------------------------------------------
/components/mad/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(CPPFLAGS -DHAVE_CONFIG_H)
2 |
3 | set(COMPONENT_SRCDIRS .)
4 | set(COMPONENT_ADD_INCLUDEDIRS .)
5 |
6 | set(COMPONENT_REQUIRES main)
7 |
8 | register_component()
9 |
--------------------------------------------------------------------------------
/components/mad/bit.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $
20 | */
21 |
22 | # ifndef LIBMAD_BIT_H
23 | # define LIBMAD_BIT_H
24 |
25 | struct mad_bitptr {
26 | unsigned char const *byte;
27 | unsigned short cache;
28 | unsigned short left;
29 | };
30 |
31 | void mad_bit_init(struct mad_bitptr *, unsigned char const *);
32 |
33 | # define mad_bit_finish(bitptr) /* nothing */
34 |
35 | unsigned int mad_bit_length(struct mad_bitptr const *,
36 | struct mad_bitptr const *);
37 |
38 | # define mad_bit_bitsleft(bitptr) ((bitptr)->left)
39 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
40 |
41 | void mad_bit_skip(struct mad_bitptr *, unsigned int);
42 | unsigned long mad_bit_read(struct mad_bitptr *, unsigned int);
43 | void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long);
44 |
45 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
46 |
47 | # endif
48 |
--------------------------------------------------------------------------------
/components/mad/config.h:
--------------------------------------------------------------------------------
1 | /* config.h. Generated by configure. */
2 |
3 | /* Define to enable diagnostic debugging support. */
4 | /* #undef DEBUG */
5 |
6 | /* Define to enable experimental code. */
7 | /* #undef EXPERIMENTAL */
8 |
9 | /* Define to disable debugging assertions. */
10 | #define NDEBUG
11 |
12 | /* Define to optimize for accuracy over speed. */
13 | /* #undef OPT_ACCURACY */
14 |
15 | /* Define to optimize for speed over accuracy. */
16 | #define OPT_SPEED 1
17 |
18 | /* Define to enable a fast subband synthesis approximation optimization. */
19 | #define OPT_SSO
20 |
21 | /* Define to influence a strict interpretation of the ISO/IEC standards, even
22 | if this is in opposition with best accepted practices. */
23 | /* #undef OPT_STRICT */
24 |
25 | #define FPM_DEFAULT
26 |
--------------------------------------------------------------------------------
/components/mad/fixed.c:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $
20 | */
21 |
22 | # ifdef HAVE_CONFIG_H
23 | # include "config.h"
24 | # endif
25 |
26 | # include "global.h"
27 |
28 | # include "fixed.h"
29 |
30 | /*
31 | * NAME: fixed->abs()
32 | * DESCRIPTION: return absolute value of a fixed-point number
33 | */
34 | mad_fixed_t mad_f_abs(mad_fixed_t x)
35 | {
36 | return x < 0 ? -x : x;
37 | }
38 |
39 | /*
40 | * NAME: fixed->div()
41 | * DESCRIPTION: perform division using fixed-point math
42 | */
43 | mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y)
44 | {
45 | mad_fixed_t q, r;
46 | unsigned int bits;
47 |
48 | q = mad_f_abs(x / y);
49 |
50 | if (x < 0) {
51 | x = -x;
52 | y = -y;
53 | }
54 |
55 | r = x % y;
56 |
57 | if (y < 0) {
58 | x = -x;
59 | y = -y;
60 | }
61 |
62 | if (q > mad_f_intpart(MAD_F_MAX) &&
63 | !(q == -mad_f_intpart(MAD_F_MIN) && r == 0 && (x < 0) != (y < 0)))
64 | return 0;
65 |
66 | for (bits = MAD_F_FRACBITS; bits && r; --bits) {
67 | q <<= 1, r <<= 1;
68 | if (r >= y)
69 | r -= y, ++q;
70 | }
71 |
72 | /* round */
73 | if (2 * r >= y)
74 | ++q;
75 |
76 | /* fix sign */
77 | if ((x < 0) != (y < 0))
78 | q = -q;
79 |
80 | return q << bits;
81 | }
82 |
--------------------------------------------------------------------------------
/components/mad/global.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: global.h,v 1.11 2004/01/23 09:41:32 rob Exp $
20 | */
21 |
22 | # ifndef LIBMAD_GLOBAL_H
23 | # define LIBMAD_GLOBAL_H
24 |
25 | /* conditional debugging */
26 |
27 | # if defined(DEBUG) && defined(NDEBUG)
28 | # error "cannot define both DEBUG and NDEBUG"
29 | # endif
30 |
31 | # if defined(DEBUG)
32 | # include
33 | # endif
34 |
35 | /* conditional features */
36 |
37 | # if defined(OPT_SPEED) && defined(OPT_ACCURACY)
38 | # error "cannot optimize for both speed and accuracy"
39 | # endif
40 |
41 | # if defined(OPT_SPEED) && !defined(OPT_SSO)
42 | # define OPT_SSO
43 | # endif
44 |
45 | # if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \
46 | defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK)
47 | # define USE_ASYNC
48 | # endif
49 |
50 | # if !defined(HAVE_ASSERT_H)
51 | # if defined(NDEBUG)
52 | # define assert(x) /* nothing */
53 | # else
54 | # define assert(x) do { if (!(x)) abort(); } while (0)
55 | # endif
56 | # endif
57 |
58 | # endif
59 |
--------------------------------------------------------------------------------
/components/mad/huffman.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: huffman.h,v 1.11 2004/01/23 09:41:32 rob Exp $
20 | */
21 |
22 | # ifndef LIBMAD_HUFFMAN_H
23 | # define LIBMAD_HUFFMAN_H
24 |
25 | union huffquad {
26 | struct {
27 | unsigned short final : 1;
28 | unsigned short bits : 3;
29 | unsigned short offset : 12;
30 | } ptr;
31 | struct {
32 | unsigned short final : 1;
33 | unsigned short hlen : 3;
34 | unsigned short v : 1;
35 | unsigned short w : 1;
36 | unsigned short x : 1;
37 | unsigned short y : 1;
38 | } value;
39 | unsigned short final : 1;
40 | };
41 |
42 | union huffpair {
43 | struct {
44 | unsigned short final : 1;
45 | unsigned short bits : 3;
46 | unsigned short offset : 12;
47 | } ptr;
48 | struct {
49 | unsigned short final : 1;
50 | unsigned short hlen : 3;
51 | unsigned short x : 4;
52 | unsigned short y : 4;
53 | } value;
54 | unsigned short final : 1;
55 | };
56 |
57 | struct hufftable {
58 | union huffpair const *table;
59 | unsigned short linbits;
60 | unsigned short startbits;
61 | };
62 |
63 | extern union huffquad const *const mad_huff_quad_table[2];
64 | extern struct hufftable const mad_huff_pair_table[32];
65 |
66 | # endif
67 |
--------------------------------------------------------------------------------
/components/mad/imdct_s.dat:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: imdct_s.dat,v 1.8 2004/01/23 09:41:32 rob Exp $
20 | */
21 |
22 | /* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */,
23 | -MAD_F(0x0ec835e8) /* -0.923879533 */,
24 | -MAD_F(0x0216a2a2) /* -0.130526192 */,
25 | MAD_F(0x0fdcf549) /* 0.991444861 */,
26 | -MAD_F(0x061f78aa) /* -0.382683432 */,
27 | -MAD_F(0x0cb19346) /* -0.793353340 */ },
28 |
29 | /* 6 */ { -MAD_F(0x0cb19346) /* -0.793353340 */,
30 | MAD_F(0x061f78aa) /* 0.382683432 */,
31 | MAD_F(0x0fdcf549) /* 0.991444861 */,
32 | MAD_F(0x0216a2a2) /* 0.130526192 */,
33 | -MAD_F(0x0ec835e8) /* -0.923879533 */,
34 | -MAD_F(0x09bd7ca0) /* -0.608761429 */ },
35 |
36 | /* 1 */ { MAD_F(0x061f78aa) /* 0.382683432 */,
37 | -MAD_F(0x0ec835e8) /* -0.923879533 */,
38 | MAD_F(0x0ec835e8) /* 0.923879533 */,
39 | -MAD_F(0x061f78aa) /* -0.382683432 */,
40 | -MAD_F(0x061f78aa) /* -0.382683432 */,
41 | MAD_F(0x0ec835e8) /* 0.923879533 */ },
42 |
43 | /* 7 */ { -MAD_F(0x0ec835e8) /* -0.923879533 */,
44 | -MAD_F(0x061f78aa) /* -0.382683432 */,
45 | MAD_F(0x061f78aa) /* 0.382683432 */,
46 | MAD_F(0x0ec835e8) /* 0.923879533 */,
47 | MAD_F(0x0ec835e8) /* 0.923879533 */,
48 | MAD_F(0x061f78aa) /* 0.382683432 */ },
49 |
50 | /* 2 */ { MAD_F(0x0216a2a2) /* 0.130526192 */,
51 | -MAD_F(0x061f78aa) /* -0.382683432 */,
52 | MAD_F(0x09bd7ca0) /* 0.608761429 */,
53 | -MAD_F(0x0cb19346) /* -0.793353340 */,
54 | MAD_F(0x0ec835e8) /* 0.923879533 */,
55 | -MAD_F(0x0fdcf549) /* -0.991444861 */ },
56 |
57 | /* 8 */ { -MAD_F(0x0fdcf549) /* -0.991444861 */,
58 | -MAD_F(0x0ec835e8) /* -0.923879533 */,
59 | -MAD_F(0x0cb19346) /* -0.793353340 */,
60 | -MAD_F(0x09bd7ca0) /* -0.608761429 */,
61 | -MAD_F(0x061f78aa) /* -0.382683432 */,
62 | -MAD_F(0x0216a2a2) /* -0.130526192 */ }
63 |
--------------------------------------------------------------------------------
/components/mad/layer12.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: layer12.h,v 1.10 2004/01/23 09:41:32 rob Exp $
20 | */
21 |
22 | # ifndef LIBMAD_LAYER12_H
23 | # define LIBMAD_LAYER12_H
24 |
25 | # include "stream.h"
26 | # include "frame.h"
27 |
28 | int mad_layer_I(struct mad_stream *, struct mad_frame *);
29 | int mad_layer_II(struct mad_stream *, struct mad_frame *);
30 |
31 | # endif
32 |
--------------------------------------------------------------------------------
/components/mad/layer3.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: layer3.h,v 1.10 2004/01/23 09:41:32 rob Exp $
20 | */
21 |
22 | # ifndef LIBMAD_LAYER3_H
23 | # define LIBMAD_LAYER3_H
24 |
25 | # include "stream.h"
26 | # include "frame.h"
27 |
28 | int mad_layer_III(struct mad_stream *, struct mad_frame *);
29 |
30 | # endif
31 |
--------------------------------------------------------------------------------
/components/mad/mad.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * If you would like to negotiate alternate licensing terms, you may do
20 | * so by contacting: Underbit Technologies, Inc.
21 | */
22 |
23 | # ifdef __cplusplus
24 | extern "C" {
25 | # endif
26 |
27 | # include "config.h"
28 |
29 | # ifdef __cplusplus
30 | }
31 | # endif
32 |
--------------------------------------------------------------------------------
/components/mad/synth.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $
20 | */
21 |
22 | # ifndef LIBMAD_SYNTH_H
23 | # define LIBMAD_SYNTH_H
24 |
25 | # include "fixed.h"
26 | # include "frame.h"
27 |
28 | struct mad_pcm {
29 | unsigned int samplerate; /* sampling frequency (Hz) */
30 | unsigned short channels; /* number of channels */
31 | unsigned short length; /* number of samples per channel */
32 | short samples[2][32]; /* PCM output samples [ch][sample] */
33 | };
34 |
35 | struct mad_synth {
36 | mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
37 | /* [ch][eo][peo][s][v] */
38 |
39 | unsigned int phase; /* current processing phase */
40 |
41 | struct mad_pcm pcm; /* PCM output */
42 | };
43 |
44 | /* single channel PCM selector */
45 | enum {
46 | MAD_PCM_CHANNEL_SINGLE = 0
47 | };
48 |
49 | /* dual channel PCM selector */
50 | enum {
51 | MAD_PCM_CHANNEL_DUAL_1 = 0,
52 | MAD_PCM_CHANNEL_DUAL_2 = 1
53 | };
54 |
55 | /* stereo PCM selector */
56 | enum {
57 | MAD_PCM_CHANNEL_STEREO_LEFT = 0,
58 | MAD_PCM_CHANNEL_STEREO_RIGHT = 1
59 | };
60 |
61 | void mad_synth_init(struct mad_synth *);
62 |
63 | # define mad_synth_finish(synth) /* nothing */
64 |
65 | void mad_synth_mute(struct mad_synth *);
66 |
67 | void mad_synth_frame(struct mad_synth *, struct mad_frame const *);
68 |
69 | # endif
70 |
--------------------------------------------------------------------------------
/components/mad/version.c:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: version.c,v 1.15 2004/01/23 09:41:33 rob Exp $
20 | */
21 |
22 | # ifdef HAVE_CONFIG_H
23 | # include "config.h"
24 | # endif
25 |
26 | # include "global.h"
27 |
28 | # include "version.h"
29 |
30 | char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION;
31 | char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR;
32 | char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">";
33 |
34 | char const mad_build[] = ""
35 | # if defined(DEBUG)
36 | "DEBUG "
37 | # elif defined(NDEBUG)
38 | "NDEBUG "
39 | # endif
40 |
41 | # if defined(EXPERIMENTAL)
42 | "EXPERIMENTAL "
43 | # endif
44 |
45 | # if defined(FPM_64BIT)
46 | "FPM_64BIT "
47 | # elif defined(FPM_INTEL)
48 | "FPM_INTEL "
49 | # elif defined(FPM_ARM)
50 | "FPM_ARM "
51 | # elif defined(FPM_MIPS)
52 | "FPM_MIPS "
53 | # elif defined(FPM_SPARC)
54 | "FPM_SPARC "
55 | # elif defined(FPM_PPC)
56 | "FPM_PPC "
57 | # elif defined(FPM_DEFAULT)
58 | "FPM_DEFAULT "
59 | # endif
60 |
61 | # if defined(ASO_IMDCT)
62 | "ASO_IMDCT "
63 | # endif
64 | # if defined(ASO_INTERLEAVE1)
65 | "ASO_INTERLEAVE1 "
66 | # endif
67 | # if defined(ASO_INTERLEAVE2)
68 | "ASO_INTERLEAVE2 "
69 | # endif
70 | # if defined(ASO_ZEROCHECK)
71 | "ASO_ZEROCHECK "
72 | # endif
73 |
74 | # if defined(OPT_SPEED)
75 | "OPT_SPEED "
76 | # elif defined(OPT_ACCURACY)
77 | "OPT_ACCURACY "
78 | # endif
79 |
80 | # if defined(OPT_SSO)
81 | "OPT_SSO "
82 | # endif
83 |
84 | # if defined(OPT_DCTO) /* never defined here */
85 | "OPT_DCTO "
86 | # endif
87 |
88 | # if defined(OPT_STRICT)
89 | "OPT_STRICT "
90 | # endif
91 | ;
92 |
--------------------------------------------------------------------------------
/components/mad/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libmad - MPEG audio decoder library
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | * $Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp $
20 | */
21 |
22 | # ifndef LIBMAD_VERSION_H
23 | # define LIBMAD_VERSION_H
24 |
25 | # define MAD_VERSION_MAJOR 0
26 | # define MAD_VERSION_MINOR 15
27 | # define MAD_VERSION_PATCH 1
28 | # define MAD_VERSION_EXTRA " (beta)"
29 |
30 | # define MAD_VERSION_STRINGIZE(str) #str
31 | # define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
32 |
33 | # define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
34 | MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
35 | MAD_VERSION_STRING(MAD_VERSION_PATCH) \
36 | MAD_VERSION_EXTRA
37 |
38 | # define MAD_PUBLISHYEAR "2000-2004"
39 | # define MAD_AUTHOR "Underbit Technologies, Inc."
40 | # define MAD_EMAIL "info@underbit.com"
41 |
42 | extern char const mad_version[];
43 | extern char const mad_copyright[];
44 | extern char const mad_author[];
45 | extern char const mad_build[];
46 |
47 | # endif
48 |
--------------------------------------------------------------------------------
/components/ugfx/.gitignore:
--------------------------------------------------------------------------------
1 | docs/html
2 | build
3 | .build
4 | .dep
5 | .cproject
6 | .project
7 | *.sublime*
8 | *.stackdump
9 | *.lst
10 | *.o
11 | *.map
12 | src/gdisp/fonts/*.dat
13 | docs/html.zip
14 |
--------------------------------------------------------------------------------
/components/ugfx/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(COMPONENT_SRCS src/gfx_mk.c)
2 | set(COMPONENT_ADD_INCLUDEDIRS .)
3 |
4 | set(COMPONENT_REQUIRES main)
5 |
6 | register_component()
7 |
8 | target_compile_options(${COMPONENT_LIB} PRIVATE -fno-strict-aliasing)
9 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/CUBE0414/CUBE0414.h:
--------------------------------------------------------------------------------
1 | #ifndef _CUBE0414_H
2 | #define _CUBE0414_H
3 |
4 | #ifndef CONFIG_CUBE0414_RTL_REV_2
5 | #define CUBE0414_CONF_WR 0x2A
6 | #define CUBE0414_ADDR_WR 0x2B
7 | #define CUBE0414_DATA_WR 0x2C
8 | #define CUBE0414_INFO_RD 0x3A
9 | #else
10 | #define CUBE0414_ADDR_WR 0xCC
11 | #define CUBE0414_DATA_WR 0xDA
12 | #endif
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/CUBE0414/driver.mk:
--------------------------------------------------------------------------------
1 | GFXINC += $(GFXLIB)/drivers/gdisp/CUBE0414
2 | GFXSRC += $(GFXLIB)/drivers/gdisp/CUBE0414/gdisp_lld_CUBE0414.c
3 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/CUBE0414/gdisp_lld_board.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_board.h
3 | *
4 | * Created on: 2018-05-10 16:56
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_BOARD_H
9 | #define _GDISP_LLD_BOARD_H
10 |
11 | #include "board/cube0414.h"
12 |
13 | #define init_board(g) cube0414_init_board()
14 | #define setpin_reset(g, val) cube0414_setpin_reset(val)
15 | #define write_cmd(g, cmd) cube0414_write_cmd(cmd)
16 | #define write_data(g, data) cube0414_write_data(data)
17 | #define write_buff(g, buff, n) cube0414_write_buff(buff, n)
18 | #define read_buff(g, buff, n) cube0414_read_buff(buff, n)
19 | #define refresh_gram(g, gram) cube0414_refresh_gram(gram)
20 |
21 | #endif /* _GDISP_LLD_BOARD_H */
22 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/CUBE0414/gdisp_lld_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_config.h
3 | *
4 | * Created on: 2018-05-10 16:55
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_CONFIG_H
9 | #define _GDISP_LLD_CONFIG_H
10 |
11 | #if GFX_USE_GDISP
12 |
13 | /*===========================================================================*/
14 | /* Driver hardware support. */
15 | /*===========================================================================*/
16 |
17 | #define GDISP_HARDWARE_FLUSH TRUE
18 | #define GDISP_HARDWARE_STREAM_WRITE TRUE
19 | #define GDISP_HARDWARE_STREAM_READ TRUE
20 |
21 | #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
22 |
23 | #endif /* GFX_USE_GDISP */
24 |
25 | #endif /* _GDISP_LLD_CONFIG_H */
26 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/ST7735/ST7735.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ST7735.h
3 | *
4 | * Created on: 2019-04-29 22:04
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _ST7735_H
9 | #define _ST7735_H
10 |
11 | // System Function Command List
12 | #define ST7735_NOP 0x00
13 | #define ST7735_SWRESET 0x01
14 | #define ST7735_RDDID 0x04
15 | #define ST7735_RDDST 0x09
16 | #define ST7735_RDDPM 0x0A
17 | #define ST7735_RDDMADCTL 0x0B
18 | #define ST7735_RDDCOLMOD 0x0C
19 | #define ST7735_RDDIM 0x0D
20 | #define ST7735_RDDSM 0x0E
21 | #define ST7735_RDDSDR 0x0F
22 |
23 | #define ST7735_SLPIN 0x10
24 | #define ST7735_SLPOUT 0x11
25 | #define ST7735_PTLON 0x12
26 | #define ST7735_NORON 0x13
27 |
28 | #define ST7735_INVOFF 0x20
29 | #define ST7735_INVON 0x21
30 | #define ST7735_GAMSET 0x26
31 | #define ST7735_DISPOFF 0x28
32 | #define ST7735_DISPON 0x29
33 | #define ST7735_CASET 0x2A
34 | #define ST7735_RASET 0x2B
35 | #define ST7735_RAMWR 0x2C
36 | #define ST7735_RGBSET 0x2D
37 | #define ST7735_RAMRD 0x2E
38 |
39 | #define ST7735_PTLAR 0x30
40 | #define ST7735_SCRLAR 0x33
41 | #define ST7735_TEOFF 0x34
42 | #define ST7735_TEON 0x35
43 | #define ST7735_MADCTL 0x36
44 | #define ST7735_VSCSAD 0x37
45 | #define ST7735_IDMOFF 0x38
46 | #define ST7735_IDMON 0x39
47 | #define ST7735_COLMOD 0x3A
48 |
49 | #define ST7735_RDID1 0xDA
50 | #define ST7735_RDID2 0xDB
51 | #define ST7735_RDID3 0xDC
52 |
53 | // Panel Function Command List
54 | #define ST7735_FRMCTR1 0xB1
55 | #define ST7735_FRMCTR2 0xB2
56 | #define ST7735_FRMCTR3 0xB3
57 | #define ST7735_INVCTR 0xB4
58 |
59 | #define ST7735_PWCTR1 0xC0
60 | #define ST7735_PWCTR2 0xC1
61 | #define ST7735_PWCTR3 0xC2
62 | #define ST7735_PWCTR4 0xC3
63 | #define ST7735_PWCTR5 0xC4
64 | #define ST7735_VMCTR1 0xC5
65 | #define ST7735_VMOFCTR 0xC7
66 |
67 | #define ST7735_WRID2 0xD1
68 | #define ST7735_WRID3 0xD2
69 | #define ST7735_NVCTR1 0xD9
70 | #define ST7735_NVCTR2 0xDE
71 | #define ST7735_NVCTR3 0xDF
72 |
73 | #define ST7735_GAMCTRP1 0xE0
74 | #define ST7735_GAMCTRN1 0xE1
75 |
76 | #endif // _ST7735_H
77 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/ST7735/driver.mk:
--------------------------------------------------------------------------------
1 | GFXINC += $(GFXLIB)/drivers/gdisp/ST7735
2 | GFXSRC += $(GFXLIB)/drivers/gdisp/ST7735/gdisp_lld_ST7735.c
3 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/ST7735/gdisp_lld_board.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_board.h
3 | *
4 | * Created on: 2019-04-29 22:04
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_BOARD_H
9 | #define _GDISP_LLD_BOARD_H
10 |
11 | #include "board/st7735.h"
12 |
13 | #define init_board(g) st7735_init_board()
14 | #define set_backlight(g, val) st7735_set_backlight(val)
15 | #define setpin_reset(g, val) st7735_setpin_reset(val)
16 | #define write_cmd(g, cmd) st7735_write_cmd(cmd)
17 | #define write_data(g, data) st7735_write_data(data)
18 | #define write_buff(g, buff, n) st7735_write_buff(buff, n)
19 | #define refresh_gram(g, gram) st7735_refresh_gram(gram)
20 |
21 | #endif /* _GDISP_LLD_BOARD_H */
22 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/ST7735/gdisp_lld_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_config.h
3 | *
4 | * Created on: 2019-04-29 22:04
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_CONFIG_H
9 | #define _GDISP_LLD_CONFIG_H
10 |
11 | #if GFX_USE_GDISP
12 |
13 | /*===========================================================================*/
14 | /* Driver hardware support. */
15 | /*===========================================================================*/
16 |
17 | #define GDISP_HARDWARE_FLUSH TRUE
18 | #define GDISP_HARDWARE_STREAM_WRITE TRUE
19 | #define GDISP_HARDWARE_STREAM_READ TRUE
20 | #define GDISP_HARDWARE_CONTROL TRUE
21 |
22 | #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
23 |
24 | #endif /* GFX_USE_GDISP */
25 |
26 | #endif /* _GDISP_LLD_CONFIG_H */
27 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/ST7789/driver.mk:
--------------------------------------------------------------------------------
1 | GFXINC += $(GFXLIB)/drivers/gdisp/ST7789
2 | GFXSRC += $(GFXLIB)/drivers/gdisp/ST7735/gdisp_lld_ST7789.c
3 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/ST7789/gdisp_lld_board.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_board.h
3 | *
4 | * Created on: 2019-04-29 22:04
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_BOARD_H
9 | #define _GDISP_LLD_BOARD_H
10 |
11 | #include "board/st7789.h"
12 |
13 | #define init_board(g) st7789_init_board()
14 | #define set_backlight(g, val) st7789_set_backlight(val)
15 | #define setpin_reset(g, val) st7789_setpin_reset(val)
16 | #define write_cmd(g, cmd) st7789_write_cmd(cmd)
17 | #define write_data(g, data) st7789_write_data(data)
18 | #define write_buff(g, buff, n) st7789_write_buff(buff, n)
19 | #define refresh_gram(g, gram) st7789_refresh_gram(gram)
20 |
21 | #endif /* _GDISP_LLD_BOARD_H */
22 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/ST7789/gdisp_lld_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_config.h
3 | *
4 | * Created on: 2019-04-29 22:04
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_CONFIG_H
9 | #define _GDISP_LLD_CONFIG_H
10 |
11 | #if GFX_USE_GDISP
12 |
13 | /*===========================================================================*/
14 | /* Driver hardware support. */
15 | /*===========================================================================*/
16 |
17 | #define GDISP_HARDWARE_FLUSH TRUE
18 | #define GDISP_HARDWARE_STREAM_WRITE TRUE
19 | #define GDISP_HARDWARE_STREAM_READ TRUE
20 | #define GDISP_HARDWARE_CONTROL TRUE
21 |
22 | #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
23 |
24 | #endif /* GFX_USE_GDISP */
25 |
26 | #endif /* _GDISP_LLD_CONFIG_H */
27 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/WS2812/driver.mk:
--------------------------------------------------------------------------------
1 | GFXINC += $(GFXLIB)/drivers/gdisp/WS2812
2 | GFXSRC += $(GFXLIB)/drivers/gdisp/WS2812/gdisp_lld_WS2812.c
3 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/WS2812/gdisp_lld_board.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_board.h
3 | *
4 | * Created on: 2018-05-10 16:56
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_BOARD_H
9 | #define _GDISP_LLD_BOARD_H
10 |
11 | #include "board/ws2812.h"
12 |
13 | #define init_board(g) ws2812_init_board()
14 | #define refresh_gram(g, gram) ws2812_refresh_gram(gram)
15 |
16 | #endif /* _GDISP_LLD_BOARD_H */
17 |
--------------------------------------------------------------------------------
/components/ugfx/drivers/gdisp/WS2812/gdisp_lld_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gdisp_lld_config.h
3 | *
4 | * Created on: 2018-05-10 16:55
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef _GDISP_LLD_CONFIG_H
9 | #define _GDISP_LLD_CONFIG_H
10 |
11 | #if GFX_USE_GDISP
12 |
13 | /*===========================================================================*/
14 | /* Driver hardware support. */
15 | /*===========================================================================*/
16 |
17 | #define GDISP_HARDWARE_FLUSH TRUE
18 | #define GDISP_HARDWARE_STREAM_WRITE TRUE
19 | #define GDISP_HARDWARE_STREAM_READ TRUE
20 |
21 | #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
22 |
23 | #endif /* GFX_USE_GDISP */
24 |
25 | #endif /* _GDISP_LLD_CONFIG_H */
26 |
--------------------------------------------------------------------------------
/components/ugfx/gfx.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXINC += $(GFXLIB)
7 |
8 | ifeq ($(GFXSINGLEMAKE),yes)
9 | GFXSRC += $(GFXLIB)/src/gfx_mk.c
10 | else
11 | GFXSRC += $(GFXLIB)/src/gfx.c
12 | include $(GFXLIB)/src/gos/gos.mk
13 | include $(GFXLIB)/src/gdriver/gdriver.mk
14 | include $(GFXLIB)/src/gqueue/gqueue.mk
15 | include $(GFXLIB)/src/gdisp/gdisp.mk
16 | include $(GFXLIB)/src/gevent/gevent.mk
17 | include $(GFXLIB)/src/gtimer/gtimer.mk
18 | include $(GFXLIB)/src/gwin/gwin.mk
19 | include $(GFXLIB)/src/ginput/ginput.mk
20 | include $(GFXLIB)/src/gadc/gadc.mk
21 | include $(GFXLIB)/src/gaudio/gaudio.mk
22 | include $(GFXLIB)/src/gmisc/gmisc.mk
23 | include $(GFXLIB)/src/gfile/gfile.mk
24 | include $(GFXLIB)/src/gtrans/gtrans.mk
25 | endif
26 |
27 | # Include the boards and drivers
28 | ifneq ($(GFXBOARD),)
29 | include $(GFXLIB)/boards/base/$(GFXBOARD)/board.mk
30 | endif
31 | ifneq ($(GFXDRIVERS),)
32 | include $(patsubst %,$(GFXLIB)/drivers/%/driver.mk,$(GFXDRIVERS))
33 | endif
34 | ifneq ($(GFXDEMO),)
35 | include $(GFXLIB)/demos/$(GFXDEMO)/demo.mk
36 | endif
37 |
38 | # Include the operating system define
39 | ifeq ($(OPT_OS),arduino)
40 | GFXDEFS += GFX_USE_OS_ARDUINO=TRUE
41 | endif
42 | ifeq ($(OPT_OS),win32)
43 | GFXDEFS += GFX_USE_OS_WIN32=TRUE
44 | endif
45 | ifeq ($(OPT_OS),win32.chibios)
46 | GFXDEFS += GFX_USE_OS_CHIBIOS=TRUE
47 | endif
48 | ifeq ($(OPT_OS),win32.raw32)
49 | GFXDEFS += GFX_USE_OS_RAW32=TRUE
50 | endif
51 | ifeq ($(OPT_OS),linux)
52 | GFXDEFS += GFX_USE_OS_LINUX=TRUE
53 | endif
54 | ifeq ($(OPT_OS),osx)
55 | GFXDEFS += GFX_USE_OS_OSX=TRUE
56 | endif
57 | ifeq ($(OPT_OS),chibios)
58 | GFXDEFS += GFX_USE_OS_CHIBIOS=TRUE
59 | endif
60 | ifeq ($(OPT_OS),freertos)
61 | GFXDEFS += GFX_USE_OS_FREERTOS=TRUE
62 | endif
63 | ifeq ($(OPT_OS),ecos)
64 | GFXDEFS += GFX_USE_OS_ECOS=TRUE
65 | endif
66 | ifeq ($(OPT_OS),rawrtos)
67 | GFXDEFS += GFX_USE_OS_RAWRTOS=TRUE
68 | endif
69 | ifeq ($(OPT_OS),raw32)
70 | GFXDEFS += GFX_USE_OS_RAW32=TRUE
71 | endif
72 |
--------------------------------------------------------------------------------
/components/ugfx/mf_bwfont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* This is a stub file to prevent having to include the mcufont
9 | * directory in the include path for funny compilers such as arduino
10 | * which don't support a user specified include path.
11 | *
12 | * It is not needed anyway as the files are already included.
13 | *
14 | * New versions of the font generator do not generate these include lines.
15 | */
16 |
--------------------------------------------------------------------------------
/components/ugfx/mf_rlefont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* This is a stub file to prevent having to include the mcufont
9 | * directory in the include path for funny compilers such as arduino
10 | * which don't support a user specified include path.
11 | *
12 | * It is not needed anyway as the files are already included.
13 | *
14 | * New versions of the font generator do not generate these include lines.
15 | */
16 |
--------------------------------------------------------------------------------
/components/ugfx/mf_scaledfont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* This is a stub file to prevent having to include the mcufont
9 | * directory in the include path for funny compilers such as arduino
10 | * which don't support a user specified include path.
11 | *
12 | * It is not needed anyway as the files are already included.
13 | *
14 | * New versions of the font generator do not generate these include lines.
15 | */
16 |
--------------------------------------------------------------------------------
/components/ugfx/src/gadc/gadc.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gadc/gadc.c
7 |
--------------------------------------------------------------------------------
/components/ugfx/src/gadc/gadc_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gadc.c"
9 |
--------------------------------------------------------------------------------
/components/ugfx/src/gadc/gadc_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gadc/gadc_options.h
10 | * @brief GADC - Periodic ADC subsystem options header file.
11 | *
12 | * @addtogroup GADC
13 | * @{
14 | */
15 |
16 | #ifndef _GADC_OPTIONS_H
17 | #define _GADC_OPTIONS_H
18 |
19 | /**
20 | * @name GADC Functionality to be included
21 | * @{
22 | */
23 | /**
24 | * @}
25 | *
26 | * @name GADC Optional Sizing Parameters
27 | * @{
28 | */
29 | /**
30 | * @brief The maximum GADC sample rate
31 | * @details Defaults to 44000
32 | * @note This value must be less than half the maximum sample rate allowed by the CPU.
33 | * This is to ensure there is time between high speed samples to perform low
34 | * speed device sampling.
35 | */
36 | #ifndef GADC_MAX_HIGH_SPEED_SAMPLERATE
37 | #define GADC_MAX_HIGH_SPEED_SAMPLERATE 44000
38 | #endif
39 | /** @} */
40 |
41 | #endif /* _GADC_OPTIONS_H */
42 | /** @} */
43 |
--------------------------------------------------------------------------------
/components/ugfx/src/gadc/gadc_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gadc/gadc_rules.h
10 | * @brief GADC safety rules header file.
11 | *
12 | * @addtogroup GADC
13 | * @{
14 | */
15 |
16 | #ifndef _GADC_RULES_H
17 | #define _GADC_RULES_H
18 |
19 | #if GFX_USE_GADC
20 | #if !GFX_USE_GTIMER
21 | #if GFX_DISPLAY_RULE_WARNINGS
22 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
23 | #warning "GADC: GFX_USE_GTIMER is required if GFX_USE_GADC is TRUE. It has been turned on for you."
24 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
25 | COMPILER_WARNING("GADC: GFX_USE_GTIMER is required if GFX_USE_GADC is TRUE. It has been turned on for you.")
26 | #endif
27 | #endif
28 | #undef GFX_USE_GTIMER
29 | #define GFX_USE_GTIMER TRUE
30 | #endif
31 | #if !GFX_USE_GQUEUE || !GQUEUE_NEED_GSYNC || !GQUEUE_NEED_BUFFERS
32 | #if GFX_DISPLAY_RULE_WARNINGS
33 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
34 | #warning "GADC: GFX_USE_GQUEUE, GQUEUE_NEED_BUFFERS and GQUEUE_NEED_GSYNC are required if GFX_USE_GADC is TRUE. They have been turned on for you."
35 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
36 | COMPILER_WARNING("GADC: GFX_USE_GQUEUE, GQUEUE_NEED_BUFFERS and GQUEUE_NEED_GSYNC are required if GFX_USE_GADC is TRUE. They have been turned on for you.")
37 | #endif
38 | #endif
39 | #undef GFX_USE_GQUEUE
40 | #define GFX_USE_GQUEUE TRUE
41 | #undef GQUEUE_NEED_BUFFERS
42 | #define GQUEUE_NEED_BUFFERS TRUE
43 | #undef GQUEUE_NEED_GSYNC
44 | #define GQUEUE_NEED_GSYNC TRUE
45 | #endif
46 | #endif
47 |
48 | #endif /* _GADC_RULES_H */
49 | /** @} */
50 |
--------------------------------------------------------------------------------
/components/ugfx/src/gaudio/gaudio.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gaudio/gaudio.c
7 |
--------------------------------------------------------------------------------
/components/ugfx/src/gaudio/gaudio_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gaudio.c"
9 |
--------------------------------------------------------------------------------
/components/ugfx/src/gaudio/gaudio_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gaudio/gaudio_options.h
10 | * @brief GAUDIO - Audio subsystem options header file.
11 | *
12 | * @addtogroup GAUDIO
13 | * @{
14 | */
15 |
16 | #ifndef _GAUDIO_OPTIONS_H
17 | #define _GAUDIO_OPTIONS_H
18 |
19 | /**
20 | * @name GAUDIO Functionality to be included
21 | * @{
22 | */
23 | /**
24 | * @brief Audio Play capability is needed
25 | */
26 | #ifndef GAUDIO_NEED_PLAY
27 | #define GAUDIO_NEED_PLAY FALSE
28 | #endif
29 | /**
30 | * @brief Audio Recording capability is needed
31 | */
32 | #ifndef GAUDIO_NEED_RECORD
33 | #define GAUDIO_NEED_RECORD FALSE
34 | #endif
35 | /**
36 | * @}
37 | *
38 | * @name GAUDIO Optional Sizing Parameters
39 | * @{
40 | */
41 | /** @} */
42 |
43 | #endif /* _GAUDIO_OPTIONS_H */
44 | /** @} */
45 |
--------------------------------------------------------------------------------
/components/ugfx/src/gaudio/gaudio_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gaudio/gaudio_rules.h
10 | * @brief GAUDIO safety rules header file.
11 | *
12 | * @addtogroup GAUDIO
13 | * @{
14 | */
15 |
16 | #ifndef _GAUDIO_RULES_H
17 | #define _GAUDIO_RULES_H
18 |
19 | #if GFX_USE_GAUDIO
20 | #if !GAUDIO_NEED_PLAY && !GAUDIO_NEED_RECORD
21 | #error "GAUDIO: GAUDIO_NEED_PLAY and/or GAUDIO_NEED_RECORD is required if GFX_USE_GAUDIO is TRUE"
22 | #endif
23 | #if !GFX_USE_GQUEUE
24 | #if GFX_DISPLAY_RULE_WARNINGS
25 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
26 | #warning "GAUDIO: GFX_USE_GQUEUE is required if GFX_USE_GAUDIO is TRUE. It has been turned on for you."
27 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
28 | COMPILER_WARNING("GAUDIO: GFX_USE_GQUEUE is required if GFX_USE_GAUDIO is TRUE. It has been turned on for you.")
29 | #endif
30 | #endif
31 | #undef GFX_USE_GQUEUE
32 | #define GFX_USE_GQUEUE TRUE
33 | #endif
34 | #if GAUDIO_NEED_PLAY && !GQUEUE_NEED_ASYNC
35 | #if GFX_DISPLAY_RULE_WARNINGS
36 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
37 | #warning "GAUDIO: GQUEUE_NEED_ASYNC is required if GAUDIO_NEED_PLAY is TRUE. It has been turned on for you."
38 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
39 | COMPILER_WARNING("GAUDIO: GQUEUE_NEED_ASYNC is required if GAUDIO_NEED_PLAY is TRUE. It has been turned on for you.")
40 | #endif
41 | #endif
42 | #undef GQUEUE_NEED_ASYNC
43 | #define GQUEUE_NEED_ASYNC TRUE
44 | #endif
45 | #if !GQUEUE_NEED_GSYNC || !GQUEUE_NEED_BUFFERS
46 | #if GFX_DISPLAY_RULE_WARNINGS
47 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
48 | #warning "GAUDIO: GQUEUE_NEED_BUFFERS and GQUEUE_NEED_GSYNC are required if GFX_USE_GAUDIO is TRUE. They have been turned on for you."
49 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
50 | COMPILER_WARNING("GAUDIO: GQUEUE_NEED_BUFFERS and GQUEUE_NEED_GSYNC are required if GFX_USE_GAUDIO is TRUE. They have been turned on for you.")
51 | #endif
52 | #endif
53 | #undef GQUEUE_NEED_BUFFERS
54 | #define GQUEUE_NEED_BUFFERS TRUE
55 | #undef GQUEUE_NEED_GSYNC
56 | #define GQUEUE_NEED_GSYNC TRUE
57 | #endif
58 | #if GFX_USE_GEVENT && !GFX_USE_GTIMER
59 | #if GFX_DISPLAY_RULE_WARNINGS
60 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
61 | #warning "GAUDIO: GFX_USE_GTIMER is required if GFX_USE_GAUDIO and GFX_USE_GEVENT are TRUE. It has been turned on for you."
62 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
63 | COMPILER_WARNING("GAUDIO: GFX_USE_GTIMER is required if GFX_USE_GAUDIO and GFX_USE_GEVENT are TRUE. It has been turned on for you.")
64 | #endif
65 | #endif
66 | #undef GFX_USE_GTIMER
67 | #define GFX_USE_GTIMER TRUE
68 | #endif
69 | #endif
70 |
71 | #endif /* _GAUDIO_RULES_H */
72 | /** @} */
73 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/fonts/DejaVuSans-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/components/ugfx/src/gdisp/fonts/DejaVuSans-Bold.ttf
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/fonts/DejaVuSans.license:
--------------------------------------------------------------------------------
1 | This package was debianized by Peter Cernak on
2 | Sun, 5 Sep 2004 17:10:26 +0200.
3 |
4 | It was downloaded from http://dejavu.sourceforge.net/
5 |
6 | Upstream Authors: Stepan Roh (original author),
7 | see /usr/share/doc/ttf-dejavu/AUTHORS for full list
8 |
9 | Copyright:
10 |
11 | Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
12 |
13 | Bitstream Vera Fonts Copyright
14 | ------------------------------
15 |
16 | Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
17 | a trademark of Bitstream, Inc.
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of the fonts accompanying this license ("Fonts") and associated
21 | documentation files (the "Font Software"), to reproduce and distribute the
22 | Font Software, including without limitation the rights to use, copy, merge,
23 | publish, distribute, and/or sell copies of the Font Software, and to permit
24 | persons to whom the Font Software is furnished to do so, subject to the
25 | following conditions:
26 |
27 | The above copyright and trademark notices and this permission notice shall
28 | be included in all copies of one or more of the Font Software typefaces.
29 |
30 | The Font Software may be modified, altered, or added to, and in particular
31 | the designs of glyphs or characters in the Fonts may be modified and
32 | additional glyphs or characters may be added to the Fonts, only if the fonts
33 | are renamed to names not containing either the words "Bitstream" or the word
34 | "Vera".
35 |
36 | This License becomes null and void to the extent applicable to Fonts or Font
37 | Software that has been modified and is distributed under the "Bitstream
38 | Vera" names.
39 |
40 | The Font Software may be sold as part of a larger software package but no
41 | copy of one or more of the Font Software typefaces may be sold by itself.
42 |
43 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
44 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
46 | TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
47 | FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
48 | ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
49 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
50 | THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
51 | FONT SOFTWARE.
52 |
53 | Except as contained in this notice, the names of Gnome, the Gnome
54 | Foundation, and Bitstream Inc., shall not be used in advertising or
55 | otherwise to promote the sale, use or other dealings in this Font Software
56 | without prior written authorization from the Gnome Foundation or Bitstream
57 | Inc., respectively. For further information, contact: fonts at gnome dot
58 | org.
59 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/fonts/DejaVuSans.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/components/ugfx/src/gdisp/fonts/DejaVuSans.ttf
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/fonts/DejaVuSerif.license:
--------------------------------------------------------------------------------
1 | This package was debianized by Peter Cernak on
2 | Sun, 5 Sep 2004 17:10:26 +0200.
3 |
4 | It was downloaded from http://dejavu.sourceforge.net/
5 |
6 | Upstream Authors: Stepan Roh (original author),
7 | see /usr/share/doc/ttf-dejavu/AUTHORS for full list
8 |
9 | Copyright:
10 |
11 | Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
12 |
13 | Bitstream Vera Fonts Copyright
14 | ------------------------------
15 |
16 | Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
17 | a trademark of Bitstream, Inc.
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of the fonts accompanying this license ("Fonts") and associated
21 | documentation files (the "Font Software"), to reproduce and distribute the
22 | Font Software, including without limitation the rights to use, copy, merge,
23 | publish, distribute, and/or sell copies of the Font Software, and to permit
24 | persons to whom the Font Software is furnished to do so, subject to the
25 | following conditions:
26 |
27 | The above copyright and trademark notices and this permission notice shall
28 | be included in all copies of one or more of the Font Software typefaces.
29 |
30 | The Font Software may be modified, altered, or added to, and in particular
31 | the designs of glyphs or characters in the Fonts may be modified and
32 | additional glyphs or characters may be added to the Fonts, only if the fonts
33 | are renamed to names not containing either the words "Bitstream" or the word
34 | "Vera".
35 |
36 | This License becomes null and void to the extent applicable to Fonts or Font
37 | Software that has been modified and is distributed under the "Bitstream
38 | Vera" names.
39 |
40 | The Font Software may be sold as part of a larger software package but no
41 | copy of one or more of the Font Software typefaces may be sold by itself.
42 |
43 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
44 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
46 | TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
47 | FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
48 | ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
49 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
50 | THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
51 | FONT SOFTWARE.
52 |
53 | Except as contained in this notice, the names of Gnome, the Gnome
54 | Foundation, and Bitstream Inc., shall not be used in advertising or
55 | otherwise to promote the sale, use or other dealings in this Font Software
56 | without prior written authorization from the Gnome Foundation or Bitstream
57 | Inc., respectively. For further information, contact: fonts at gnome dot
58 | org.
59 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/fonts/DejaVuSerif.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/components/ugfx/src/gdisp/fonts/DejaVuSerif.ttf
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/fonts/build_fonts.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -x -e
4 |
5 | # Path to the mcufont encoder program
6 | MCUFONT=mcufont
7 |
8 | # Character ranges to include in the fonts.
9 | # Default: ASCII only
10 | CHARS=32-127
11 |
12 | # Number of iterations in optimization
13 | # Higher numbers compress better
14 | ITERS=25
15 |
16 | function build {
17 | infile=`basename $1`
18 | outfile=$2
19 | fmt=$3
20 | size=$4
21 | bw=$5
22 | ext="${infile##*.}"
23 | noext="${infile%.*}"
24 | if [ $ext = 'ttf' ]; then
25 | dat=$noext$size$bw.dat
26 | $MCUFONT import_ttf $1 $size $bw
27 | else
28 | dat=$noext.dat
29 | $MCUFONT import_bdf $1
30 | fi
31 |
32 | $MCUFONT filter $dat $CHARS
33 |
34 | if [ $outfile = 'LargeNumbers' ]; then
35 | $MCUFONT filter $dat 0x20-0x39
36 | fi
37 |
38 | if [ $fmt = 'rlefont' ]; then
39 | $MCUFONT rlefont_optimize $dat $ITERS
40 | $MCUFONT rlefont_export $dat $outfile.c
41 | else
42 | $MCUFONT bwfont_export $dat $outfile.c
43 | fi
44 | }
45 |
46 | # Commands are of form: build [size] [bw]
47 | # If bw is not given, builds an antialiased font.
48 |
49 | rm -f *.c
50 | build DejaVuSans.ttf DejaVuSans10 bwfont 10 bw
51 | build DejaVuSans.ttf DejaVuSans12 bwfont 12 bw
52 | build DejaVuSans.ttf DejaVuSans16 rlefont 16 bw
53 | build DejaVuSans.ttf DejaVuSans20 rlefont 20 bw
54 | build DejaVuSans.ttf DejaVuSans24 rlefont 24 bw
55 | build DejaVuSans.ttf DejaVuSans32 rlefont 32 bw
56 | build DejaVuSans.ttf DejaVuSans12_aa rlefont 12
57 | build DejaVuSans.ttf DejaVuSans16_aa rlefont 16
58 | build DejaVuSans.ttf DejaVuSans20_aa rlefont 20
59 | build DejaVuSans.ttf DejaVuSans24_aa rlefont 24
60 | build DejaVuSans.ttf DejaVuSans32_aa rlefont 32
61 | build DejaVuSans-Bold.ttf DejaVuSansBold12 bwfont 12 bw
62 | build DejaVuSans-Bold.ttf DejaVuSansBold12_aa rlefont 12
63 | build DejaVuSans-Bold.ttf LargeNumbers rlefont 24 bw
64 | build fixed_10x20.bdf fixed_10x20 bwfont
65 | build fixed_7x14.bdf fixed_7x14 bwfont
66 | build fixed_5x8.bdf fixed_5x8 bwfont
67 |
68 | echo '// This file is generated by build_fonts.sh' > fonts.h
69 | for file in *.c; do
70 | echo >> fonts.h
71 | noext="${file%.*}"
72 | upper=${noext^^}
73 | defname='GDISP_INCLUDE_FONT_'$upper
74 | echo '#if defined('$defname') && '$defname >> fonts.h
75 | echo '#define GDISP_FONT_FOUND' >> fonts.h
76 | echo '#include "'$file'"' >> fonts.h
77 | echo '#endif' >> fonts.h
78 | done
79 |
80 | echo >> fonts.h
81 | echo '#if defined(GDISP_INCLUDE_USER_FONTS) && GDISP_INCLUDE_USER_FONTS' >> fonts.h
82 | echo '#define GDISP_FONT_FOUND' >> fonts.h
83 | echo '#include "userfonts.h"' >> fonts.h
84 | echo '#endif' >> fonts.h
85 | echo >> fonts.h
86 | echo '#ifndef GDISP_FONT_FOUND' >> fonts.h
87 | echo '#error "GDISP: No fonts have been included"' >> fonts.h
88 | echo '#endif' >> fonts.h
89 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/gdisp.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gdisp/gdisp.c \
7 | $(GFXLIB)/src/gdisp/gdisp_fonts.c \
8 | $(GFXLIB)/src/gdisp/gdisp_pixmap.c \
9 | $(GFXLIB)/src/gdisp/gdisp_image.c \
10 | $(GFXLIB)/src/gdisp/gdisp_image_native.c \
11 | $(GFXLIB)/src/gdisp/gdisp_image_gif.c \
12 | $(GFXLIB)/src/gdisp/gdisp_image_bmp.c \
13 | $(GFXLIB)/src/gdisp/gdisp_image_jpg.c \
14 | $(GFXLIB)/src/gdisp/gdisp_image_png.c
15 |
16 | MFDIR = $(GFXLIB)/src/gdisp/mcufont
17 | include $(GFXLIB)/src/gdisp/mcufont/mcufont.mk
18 | #GFXINC += $(MFDIR)
19 | GFXSRC += $(MFSRC)
20 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/gdisp_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* The very first thing that has to be compiled here is mf_font.c so that
9 | * inclusion of the font header files does not stop the inclusion of the
10 | * implementation specific parts of the font files.
11 | */
12 | #include "mcufont/mf_font.c"
13 | #include "mcufont/mf_rlefont.c"
14 | #include "mcufont/mf_bwfont.c"
15 | #include "mcufont/mf_scaledfont.c"
16 | #include "mcufont/mf_encoding.c"
17 | #include "mcufont/mf_justify.c"
18 | #include "mcufont/mf_kerning.c"
19 | #include "mcufont/mf_wordwrap.c"
20 |
21 | #include "gdisp.c"
22 | #include "gdisp_fonts.c"
23 | #include "gdisp_pixmap.c"
24 | #include "gdisp_image.c"
25 | #include "gdisp_image_native.c"
26 | #include "gdisp_image_gif.c"
27 | #include "gdisp_image_bmp.c"
28 | #include "gdisp_image_jpg.c"
29 | #include "gdisp_image_png.c"
30 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mcufont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* Tiny library for rendering compressed bitmap fonts on microcontrollers. */
9 |
10 | #ifndef _MCUFONT_H_
11 | #define _MCUFONT_H_
12 |
13 | #include "mf_config.h"
14 | #include "mf_encoding.h"
15 | #include "mf_justify.h"
16 | #include "mf_kerning.h"
17 | #include "mf_rlefont.h"
18 | #include "mf_scaledfont.h"
19 | #include "mf_wordwrap.h"
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mcufont.mk:
--------------------------------------------------------------------------------
1 | # Makefile fragment listing the source files for the mcufont decoder.
2 |
3 | # Directory where the decoder source code recides
4 | # Usually you'll want to set this in your own Makefile.
5 | MFDIR ?= mcufont/decoder
6 |
7 | # Name of the include directory
8 | MFINC = $(MFDIR)
9 |
10 | # Source code files to include
11 | MFSRC = \
12 | $(MFDIR)/mf_encoding.c \
13 | $(MFDIR)/mf_font.c \
14 | $(MFDIR)/mf_justify.c \
15 | $(MFDIR)/mf_kerning.c \
16 | $(MFDIR)/mf_rlefont.c \
17 | $(MFDIR)/mf_bwfont.c \
18 | $(MFDIR)/mf_scaledfont.c \
19 | $(MFDIR)/mf_wordwrap.c
20 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_bwfont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* Uncompressed font format for storing black & white fonts. Very efficient
9 | * to decode and works well for small font sizes.
10 | */
11 |
12 | #ifndef _MF_BWFONT_H_
13 | #define _MF_BWFONT_H_
14 |
15 | #include "mf_font.h"
16 |
17 | /* Versions of the BW font format that are supported. */
18 | #define MF_BWFONT_VERSION_4_SUPPORTED 1
19 |
20 | /* Structure for a range of characters. */
21 | struct mf_bwfont_char_range_s
22 | {
23 | /* The number of the first character in this range. */
24 | uint16_t first_char;
25 |
26 | /* The total count of characters in this range. */
27 | uint16_t char_count;
28 |
29 | /* The left and top skips of the characters in this range.
30 | * This is the number of empty rows at left and at top. */
31 | uint8_t offset_x;
32 | uint8_t offset_y;
33 |
34 | /* Column height for glyphs in this range, in bytes and pixels. */
35 | uint8_t height_bytes;
36 | uint8_t height_pixels;
37 |
38 | /* Positive value if the width of all glyphs in this range is the
39 | * same, or zero if it is not. */
40 | uint8_t width;
41 |
42 | /* Lookup table for the character widths. NULL if width is specified. */
43 | const uint8_t *glyph_widths;
44 |
45 | /* Lookup table for the character offsets. Multiply by height_bytes
46 | * to get the byte offset. Also allows lookup of the number of columns.
47 | * NULL if width is specified. */
48 | const uint16_t *glyph_offsets;
49 |
50 | /* Table for the glyph data.
51 | * The data for each glyph is column-by-column, with N bytes per each
52 | * column. The LSB of the first byte is the top left pixel.
53 | */
54 | const uint8_t *glyph_data;
55 | };
56 |
57 | /* Structure for the font */
58 | struct mf_bwfont_s
59 | {
60 | struct mf_font_s font;
61 |
62 | /* Version of the font format. */
63 | const uint8_t version;
64 |
65 | /* Number of character ranges. */
66 | const uint16_t char_range_count;
67 |
68 | /* Array of the character ranges */
69 | const struct mf_bwfont_char_range_s *char_ranges;
70 | };
71 |
72 | #ifdef MF_BWFONT_INTERNALS
73 | /* Internal functions, don't use these directly. */
74 | MF_EXTERN uint8_t mf_bwfont_render_character(const struct mf_font_s *font,
75 | int16_t x0, int16_t y0,
76 | uint16_t character,
77 | mf_pixel_callback_t callback,
78 | void *state);
79 |
80 | MF_EXTERN uint8_t mf_bwfont_character_width(const struct mf_font_s *font,
81 | uint16_t character);
82 | #endif
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_encoding.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "mf_encoding.h"
9 |
10 | #ifndef MF_NO_COMPILE
11 |
12 | #if MF_ENCODING == MF_ENCODING_UTF8
13 |
14 | mf_char mf_getchar(mf_str *str)
15 | {
16 | uint8_t c;
17 | uint8_t tmp, seqlen;
18 | uint16_t result;
19 |
20 | c = **str;
21 | if (!c)
22 | return 0;
23 |
24 | (*str)++;
25 |
26 | if ((c & 0x80) == 0)
27 | {
28 | /* Just normal ASCII character. */
29 | return c;
30 | }
31 | else if ((c & 0xC0) == 0x80)
32 | {
33 | /* Dangling piece of corrupted multibyte sequence.
34 | * Did you cut the string in the wrong place?
35 | */
36 | return c;
37 | }
38 | else if ((**str & 0xC0) == 0xC0)
39 | {
40 | /* Start of multibyte sequence without any following bytes.
41 | * Silly. Maybe you are using the wrong encoding.
42 | */
43 | return c;
44 | }
45 | else
46 | {
47 | /* Beginning of a multi-byte sequence.
48 | * Find out how many characters and combine them.
49 | */
50 | seqlen = 2;
51 | tmp = 0x20;
52 | result = 0;
53 | while ((c & tmp) && (seqlen < 5))
54 | {
55 | seqlen++;
56 | tmp >>= 1;
57 |
58 | result = (result << 6) | (**str & 0x3F);
59 | (*str)++;
60 | }
61 |
62 | result = (result << 6) | (**str & 0x3F);
63 | (*str)++;
64 |
65 | result |= (c & (tmp - 1)) << ((seqlen - 1) * 6);
66 | return result;
67 | }
68 | }
69 |
70 | void mf_rewind(mf_str *str)
71 | {
72 | (*str)--;
73 |
74 | while ((**str & 0x80) != 0x00 && (**str & 0xC0) != 0xC0)
75 | (*str)--;
76 | }
77 |
78 | #else
79 |
80 | mf_char mf_getchar(mf_str *str)
81 | {
82 | if (!(**str))
83 | return 0;
84 | else
85 | return *(*str)++;
86 | }
87 |
88 | void mf_rewind(mf_str *str)
89 | {
90 | (*str)--;
91 | }
92 |
93 | #endif
94 |
95 | #endif //MF_NO_COMPILE
96 |
97 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_encoding.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* Simple UTF-8 decoder. Also implements the much simpler ASCII and UTF16
9 | * input encodings.
10 | */
11 |
12 | #ifndef _MF_ENCODING_H_
13 | #define _MF_ENCODING_H_
14 |
15 | #include "mf_config.h"
16 | #ifndef MF_NO_STDINT_H
17 | #include
18 | #endif
19 |
20 | /* Type used to represent characters internally. */
21 | #if MF_ENCODING == MF_ENCODING_ASCII
22 | typedef char mf_char;
23 | #define MFCHAR2UINT16(c) ((uint16_t)(uint8_t)(c))
24 | #else
25 | typedef uint16_t mf_char;
26 | #define MFCHAR2UINT16(c) (c)
27 | #endif
28 |
29 | /* Type used to represent input strings. */
30 | #if MF_ENCODING == MF_ENCODING_ASCII
31 | typedef const char * mf_str;
32 | #elif MF_ENCODING == MF_ENCODING_UTF8
33 | typedef const char * mf_str;
34 | #elif MF_ENCODING == MF_ENCODING_UTF16
35 | typedef const uint16_t * mf_str;
36 | #elif MF_ENCODING == MF_ENCODING_WCHAR
37 | #include
38 | typedef const wchar_t * mf_str;
39 | #endif
40 |
41 | /* Returns the next character in the string and advances the pointer.
42 | * When the string ends, returns 0 and leaves the pointer at the 0 byte.
43 | *
44 | * str: Pointer to variable holding current location in string.
45 | * Initialize it to the start of the string.
46 | *
47 | * Returns: The next character, as unicode codepoint.
48 | */
49 | MF_EXTERN mf_char mf_getchar(mf_str *str);
50 |
51 | /* Moves back the pointer to the beginning of the previous character.
52 | * Be careful not to go beyond the start of the string.
53 | */
54 | MF_EXTERN void mf_rewind(mf_str *str);
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_font.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "mf_config.h"
9 |
10 | #ifndef MF_NO_COMPILE
11 |
12 | #define MF_BWFONT_INTERNALS
13 | #define MF_RLEFONT_INTERNALS
14 | #define MF_SCALEDFONT_INTERNALS
15 | #include "mf_font.h"
16 | #include "mf_rlefont.h"
17 | #include "mf_bwfont.h"
18 | #include "mf_scaledfont.h"
19 |
20 | #include
21 |
22 | /* This will be made into a list of included fonts using macro magic. */
23 | #define MF_INCLUDED_FONTS 0
24 |
25 | /* Included fonts begin here */
26 | #include MF_FONT_FILE_NAME
27 | /* Include fonts end here */
28 |
29 | uint8_t mf_render_character(const struct mf_font_s *font,
30 | int16_t x0, int16_t y0,
31 | mf_char character,
32 | mf_pixel_callback_t callback,
33 | void *state)
34 | {
35 | uint8_t width;
36 | width = font->render_character(font, x0, y0, MFCHAR2UINT16(character), callback, state);
37 |
38 | if (!width)
39 | {
40 | width = font->render_character(font, x0, y0, font->fallback_character,
41 | callback, state);
42 | }
43 |
44 | return width;
45 | }
46 |
47 | uint8_t mf_character_width(const struct mf_font_s *font,
48 | mf_char character)
49 | {
50 | uint8_t width;
51 | width = font->character_width(font, MFCHAR2UINT16(character));
52 |
53 | if (!width)
54 | {
55 | width = font->character_width(font, font->fallback_character);
56 | }
57 |
58 | return width;
59 | }
60 |
61 | /* Avoids a dependency on libc */
62 | static bool strequals(const char *a, const char *b)
63 | {
64 | while (*a)
65 | {
66 | if (*a++ != *b++)
67 | return false;
68 | }
69 | return (!*b);
70 | }
71 |
72 | const struct mf_font_s *mf_find_font(const char *name)
73 | {
74 | const struct mf_font_list_s *f;
75 | f = MF_INCLUDED_FONTS;
76 |
77 | while (f)
78 | {
79 | if (strequals(f->font->full_name, name) ||
80 | strequals(f->font->short_name, name))
81 | {
82 | return f->font;
83 | }
84 |
85 | f = f->next;
86 | }
87 |
88 | return 0;
89 | }
90 |
91 | const struct mf_font_list_s *mf_get_font_list()
92 | {
93 | return MF_INCLUDED_FONTS;
94 | }
95 |
96 | #endif //MF_NO_COMPILE
97 |
98 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_kerning.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* Automatic kerning for font rendering. This solves the issue where some
9 | * fonts (especially serif fonts) have too much space between specific
10 | * character pairs, like WA or L'.
11 | */
12 |
13 | #ifndef _MF_KERNING_H_
14 | #define _MF_KERNING_H_
15 |
16 | #include "mf_config.h"
17 | #include "mf_rlefont.h"
18 |
19 | /* Compute the kerning adjustment when c1 is followed by c2.
20 | *
21 | * font: Pointer to the font definition.
22 | * c1: The previous character.
23 | * c2: The next character to render.
24 | *
25 | * Returns the offset to add to the x position for c2.
26 | */
27 | #if MF_USE_KERNING
28 | MF_EXTERN int8_t mf_compute_kerning(const struct mf_font_s *font,
29 | mf_char c1, mf_char c2);
30 | #else
31 | #define mf_compute_kerning(font, c1, c2) 0
32 | #endif
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_rlefont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* A compressed font format based on run length encoding and dictionary
9 | * compression.
10 | */
11 |
12 | #ifndef _MF_RLEFONT_H_
13 | #define _MF_RLEFONT_H_
14 |
15 | #include "mf_font.h"
16 |
17 | /* Versions of the RLE font format that are supported. */
18 | #define MF_RLEFONT_VERSION_4_SUPPORTED 1
19 |
20 | /* Structure for a range of characters. This implements a sparse storage of
21 | * character indices, so that you can e.g. pick a 100 characters in the middle
22 | * of the UTF16 range and just store them. */
23 | struct mf_rlefont_char_range_s
24 | {
25 | /* The number of the first character in this range. */
26 | uint16_t first_char;
27 |
28 | /* The total count of characters in this range. */
29 | uint16_t char_count;
30 |
31 | /* Lookup table with the start indices into glyph_data. */
32 | const uint16_t *glyph_offsets;
33 |
34 | /* The encoded glyph data for glyphs in this range. */
35 | const uint8_t *glyph_data;
36 | };
37 |
38 | /* Structure for a single encoded font. */
39 | struct mf_rlefont_s
40 | {
41 | struct mf_font_s font;
42 |
43 | /* Version of the font definition used. */
44 | const uint8_t version;
45 |
46 | /* Big array of the data for all the dictionary entries. */
47 | const uint8_t *dictionary_data;
48 |
49 | /* Lookup table with the start indices into dictionary_data.
50 | * Contains N+1 entries, so that the length of the entry can
51 | * be determined by subtracting from the next offset. */
52 | const uint16_t *dictionary_offsets;
53 |
54 | /* Number of dictionary entries using the RLE encoding.
55 | * Entries starting at this index use the dictionary encoding. */
56 | const uint8_t rle_entry_count;
57 |
58 | /* Total number of dictionary entries.
59 | * Entries after this are nonexistent. */
60 | const uint8_t dict_entry_count;
61 |
62 | /* Number of discontinuous character ranges */
63 | const uint16_t char_range_count;
64 |
65 | /* Array of the character ranges */
66 | const struct mf_rlefont_char_range_s *char_ranges;
67 | };
68 |
69 | #ifdef MF_RLEFONT_INTERNALS
70 | /* Internal functions, don't use these directly. */
71 | MF_EXTERN uint8_t mf_rlefont_render_character(const struct mf_font_s *font,
72 | int16_t x0, int16_t y0,
73 | uint16_t character,
74 | mf_pixel_callback_t callback,
75 | void *state);
76 |
77 | MF_EXTERN uint8_t mf_rlefont_character_width(const struct mf_font_s *font,
78 | uint16_t character);
79 | #endif
80 |
81 | #endif
82 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_scaledfont.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "mf_scaledfont.h"
9 |
10 | #ifndef MF_NO_COMPILE
11 |
12 | struct scaled_renderstate
13 | {
14 | mf_pixel_callback_t orig_callback;
15 | void *orig_state;
16 | uint8_t x_scale;
17 | uint8_t y_scale;
18 | int16_t x0;
19 | int16_t y0;
20 | };
21 |
22 | static void scaled_pixel_callback(int16_t x, int16_t y, uint8_t count,
23 | uint8_t alpha, void *state)
24 | {
25 | struct scaled_renderstate *rstate = state;
26 | uint8_t dy;
27 |
28 | count *= rstate->x_scale;
29 | x = rstate->x0 + x * rstate->x_scale;
30 | y = rstate->y0 + y * rstate->y_scale;
31 |
32 | for (dy = 0; dy < rstate->y_scale; dy++)
33 | {
34 | rstate->orig_callback(x, y + dy, count, alpha, rstate->orig_state);
35 | }
36 | }
37 |
38 | uint8_t mf_scaled_character_width(const struct mf_font_s *font,
39 | uint16_t character)
40 | {
41 | struct mf_scaledfont_s *sfont = (struct mf_scaledfont_s*)font;
42 | uint8_t basewidth;
43 |
44 | basewidth = sfont->basefont->character_width(sfont->basefont, character);
45 |
46 | return sfont->x_scale * basewidth;
47 | }
48 |
49 | uint8_t mf_scaled_render_character(const struct mf_font_s *font,
50 | int16_t x0, int16_t y0,
51 | uint16_t character,
52 | mf_pixel_callback_t callback,
53 | void *state)
54 | {
55 | struct mf_scaledfont_s *sfont = (struct mf_scaledfont_s*)font;
56 | struct scaled_renderstate rstate;
57 | uint8_t basewidth;
58 |
59 | rstate.orig_callback = callback;
60 | rstate.orig_state = state;
61 | rstate.x_scale = sfont->x_scale;
62 | rstate.y_scale = sfont->y_scale;
63 | rstate.x0 = x0;
64 | rstate.y0 = y0;
65 |
66 | basewidth = sfont->basefont->render_character(sfont->basefont, 0, 0,
67 | character, scaled_pixel_callback, &rstate);
68 |
69 | return sfont->x_scale * basewidth;
70 | }
71 |
72 | void mf_scale_font(struct mf_scaledfont_s *newfont,
73 | const struct mf_font_s *basefont,
74 | uint8_t x_scale, uint8_t y_scale)
75 | {
76 | newfont->font = *basefont;
77 | newfont->basefont = basefont;
78 |
79 | newfont->font.width *= x_scale;
80 | newfont->font.height *= y_scale;
81 | newfont->font.baseline_x *= x_scale;
82 | newfont->font.baseline_y *= y_scale;
83 | newfont->font.min_x_advance *= x_scale;
84 | newfont->font.max_x_advance *= x_scale;
85 | newfont->font.line_height *= y_scale;
86 | newfont->font.character_width = &mf_scaled_character_width;
87 | newfont->font.render_character = &mf_scaled_render_character;
88 |
89 | newfont->x_scale = x_scale;
90 | newfont->y_scale = y_scale;
91 | }
92 |
93 | #endif //MF_NO_COMPILE
94 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_scaledfont.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* Generate scaled (nearest-neighbor) fonts. This can be used for displaying
9 | * larger text without spending the memory required for including larger fonts.
10 | */
11 |
12 | #ifndef _MF_SCALEDFONT_H_
13 | #define _MF_SCALEDFONT_H_
14 |
15 | #include "mf_font.h"
16 |
17 | struct mf_scaledfont_s
18 | {
19 | struct mf_font_s font;
20 |
21 | const struct mf_font_s *basefont;
22 | uint8_t x_scale;
23 | uint8_t y_scale;
24 | };
25 |
26 | MF_EXTERN void mf_scale_font(struct mf_scaledfont_s *newfont,
27 | const struct mf_font_s *basefont,
28 | uint8_t x_scale, uint8_t y_scale);
29 |
30 | #ifdef MF_SCALEDFONT_INTERNALS
31 | /* Internal functions, don't use these directly. */
32 | MF_EXTERN uint8_t mf_scaled_render_character(const struct mf_font_s *font,
33 | int16_t x0, int16_t y0,
34 | uint16_t character,
35 | mf_pixel_callback_t callback,
36 | void *state);
37 |
38 | MF_EXTERN uint8_t mf_scaled_character_width(const struct mf_font_s *font,
39 | uint16_t character);
40 | #endif
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdisp/mcufont/mf_wordwrap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /* Word wrapping algorithm with UTF-8 support. More than just a basic greedy
9 | * word-wrapper: it attempts to balance consecutive lines as pairs.
10 | */
11 |
12 | #ifndef _MF_WORDWRAP_H_
13 | #define _MF_WORDWRAP_H_
14 |
15 | #include "mf_rlefont.h"
16 | #include
17 |
18 | /* Callback function for handling each line.
19 | *
20 | * line: Pointer to the beginning of the string for this line.
21 | * count: Number of characters on the line.
22 | * state: Free variable that was passed to wordwrap().
23 | *
24 | * Returns: true to continue, false to stop after this line.
25 | */
26 | typedef bool (*mf_line_callback_t) (mf_str line, uint16_t count,
27 | void *state);
28 |
29 | /* Word wrap a piece of text. Calls the callback function for each line.
30 | *
31 | * font: Font to use for metrics.
32 | * width: Maximum line width in pixels.
33 | * text: Pointer to the start of the text to process.
34 | * state: Free variable for caller to use (can be NULL).
35 | */
36 | MF_EXTERN void mf_wordwrap(const struct mf_font_s *font, int16_t width,
37 | mf_str text, mf_line_callback_t callback, void *state);
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdriver/gdriver.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gdriver/gdriver.c
7 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdriver/gdriver_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gdriver.c"
9 |
10 | #undef GDISP_DRIVER_LIST
11 |
12 | #ifdef CONFIG_VFX_OUTPUT_WS2812
13 | #define GDISP_DRIVER_LIST GDISPVMT_WS2812
14 | #include "drivers/gdisp/WS2812/gdisp_lld_WS2812.c"
15 | #elif defined(CONFIG_VFX_OUTPUT_ST7735)
16 | #define GDISP_DRIVER_LIST GDISPVMT_ST7735
17 | #include "drivers/gdisp/ST7735/gdisp_lld_ST7735.c"
18 | #elif defined(CONFIG_VFX_OUTPUT_ST7789)
19 | #define GDISP_DRIVER_LIST GDISPVMT_ST7789
20 | #include "drivers/gdisp/ST7789/gdisp_lld_ST7789.c"
21 | #else
22 | #define GDISP_DRIVER_LIST GDISPVMT_CUBE0414
23 | #include "drivers/gdisp/CUBE0414/gdisp_lld_CUBE0414.c"
24 | #endif
25 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdriver/gdriver_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gdriver/gdriver_options.h
10 | * @brief GDRIVER - Driver options header file.
11 | *
12 | * @addtogroup GDRIVER
13 | * @{
14 | */
15 |
16 | #ifndef _GDRIVER_OPTIONS_H
17 | #define _GDRIVER_OPTIONS_H
18 |
19 | /**
20 | * @name GDRIVER Functionality to be included
21 | * @{
22 | */
23 | /**
24 | * @}
25 | *
26 | * @name GDRIVER Optional Parameters
27 | * @{
28 | */
29 | /** @} */
30 |
31 | #endif /* _GDRIVER_OPTIONS_H */
32 | /** @} */
33 |
--------------------------------------------------------------------------------
/components/ugfx/src/gdriver/gdriver_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gdriver/gdriver_rules.h
10 | * @brief GDRIVER safety rules header file.
11 | *
12 | * @addtogroup GFILE
13 | * @{
14 | */
15 |
16 | #ifndef _GDRIVER_RULES_H
17 | #define _GDRIVER_RULES_H
18 |
19 | #if GFX_USE_GDRIVER
20 | #endif
21 |
22 | #endif /* _GDRIVER_RULES_H */
23 | /** @} */
24 |
--------------------------------------------------------------------------------
/components/ugfx/src/gevent/gevent.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gevent/gevent.c
7 |
--------------------------------------------------------------------------------
/components/ugfx/src/gevent/gevent_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gevent.c"
9 |
--------------------------------------------------------------------------------
/components/ugfx/src/gevent/gevent_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gevent/gevent_options.h
10 | * @brief GEVENT sub-system options header file.
11 | *
12 | * @addtogroup GEVENT
13 | * @{
14 | */
15 |
16 | #ifndef _GEVENT_OPTIONS_H
17 | #define _GEVENT_OPTIONS_H
18 |
19 | /**
20 | * @name GEVENT Functionality to be included
21 | * @{
22 | */
23 | /**
24 | * @brief Should routines assert() if they run out of resources.
25 | * @details Defaults to FALSE.
26 | * @details If FALSE the application must be prepared to handle these
27 | * failures.
28 | */
29 | #ifndef GEVENT_ASSERT_NO_RESOURCE
30 | #define GEVENT_ASSERT_NO_RESOURCE FALSE
31 | #endif
32 | /**
33 | * @}
34 | *
35 | * @name GEVENT Optional Sizing Parameters
36 | * @{
37 | */
38 | /**
39 | * @brief Defines the maximum size of an event status variable.
40 | * @details Defaults to 32 bytes
41 | */
42 | #ifndef GEVENT_MAXIMUM_SIZE
43 | #define GEVENT_MAXIMUM_SIZE 32
44 | #endif
45 | /**
46 | * @brief Defines the maximum Source/Listener pairs in the system.
47 | * @details Defaults to 32
48 | */
49 | #ifndef GEVENT_MAX_SOURCE_LISTENERS
50 | #define GEVENT_MAX_SOURCE_LISTENERS 32
51 | #endif
52 | /** @} */
53 |
54 | #endif /* _GEVENT_OPTIONS_H */
55 | /** @} */
56 |
--------------------------------------------------------------------------------
/components/ugfx/src/gevent/gevent_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gevent/gevent_rules.h
10 | * @brief GEVENT safety rules header file.
11 | *
12 | * @addtogroup GEVENT
13 | * @{
14 | */
15 |
16 | #ifndef _GEVENT_RULES_H
17 | #define _GEVENT_RULES_H
18 |
19 | #if GFX_USE_GEVENT
20 | #endif
21 |
22 | #endif /* _GEVENT_RULES_H */
23 | /** @} */
24 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gfile/gfile.c \
7 | $(GFXLIB)/src/gfile/gfile_fs_native.c \
8 | $(GFXLIB)/src/gfile/gfile_fs_ram.c \
9 | $(GFXLIB)/src/gfile/gfile_fs_rom.c \
10 | $(GFXLIB)/src/gfile/gfile_fs_fatfs.c \
11 | $(GFXLIB)/src/gfile/gfile_fs_petitfs.c \
12 | $(GFXLIB)/src/gfile/gfile_fs_mem.c \
13 | $(GFXLIB)/src/gfile/gfile_fs_chibios.c \
14 | $(GFXLIB)/src/gfile/gfile_fs_strings.c \
15 | $(GFXLIB)/src/gfile/gfile_printg.c \
16 | $(GFXLIB)/src/gfile/gfile_scang.c \
17 | $(GFXLIB)/src/gfile/gfile_stdio.c \
18 | $(GFXLIB)/src/gfile/gfile_fatfs_wrapper.c \
19 | $(GFXLIB)/src/gfile/gfile_fatfs_diskio_chibios.c \
20 | $(GFXLIB)/src/gfile/gfile_petitfs_wrapper.c \
21 | $(GFXLIB)/src/gfile/gfile_petitfs_diskio_chibios.c \
22 |
23 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_fatfs_wrapper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gfile/gfile_fatfs_wrapper.h
10 | * @brief GFILE FATFS wrapper.
11 | *
12 | */
13 |
14 | #ifndef _FATFS_WRAPPER
15 | #define _FATFS_WRAPPER
16 |
17 | // Include the fatfs configuration from the local directory not the original source folder
18 | #include "ffconf.h"
19 |
20 | // Prevent preprocessor redefinition warnings
21 | #include "../../3rdparty/fatfs-0.13/source/integer.h"
22 | #if defined(_T) && !defined(_INC_TCHAR)
23 | #define _INC_TCHAR
24 | #endif
25 |
26 | // Include the fatfs API
27 | #include "../../3rdparty/fatfs-0.13/source/ff.h"
28 |
29 | // Include the fatfs diskio API
30 | #include "../../3rdparty/fatfs-0.13/source/diskio.h"
31 |
32 | #endif //_FATFS_WRAPPER
33 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_fs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gfile/gfile_fs.h
10 | * @brief GFILE file system header.
11 | *
12 | */
13 |
14 | #ifndef _GFILE_FS_H
15 | #define _GFILE_FS_H
16 |
17 | struct GFILE {
18 | const struct GFILEVMT * vmt;
19 | uint16_t flags;
20 | #define GFILEFLG_OPEN 0x0001 // File is open
21 | #define GFILEFLG_READ 0x0002 // Read the file
22 | #define GFILEFLG_WRITE 0x0004 // Write the file
23 | #define GFILEFLG_APPEND 0x0008 // Append on each write
24 | #define GFILEFLG_BINARY 0x0010 // Treat as a binary file
25 | #define GFILEFLG_DELONCLOSE 0x0020 // Delete on close
26 | #define GFILEFLG_CANSEEK 0x0040 // Seek operations are valid
27 | #define GFILEFLG_FAILONBLOCK 0x0080 // Fail on a blocking call
28 | #define GFILEFLG_MUSTEXIST 0x0100 // On open file must exist
29 | #define GFILEFLG_MUSTNOTEXIST 0x0200 // On open file must not exist
30 | #define GFILEFLG_TRUNC 0x0400 // On open truncate the file
31 | void * obj;
32 | long int pos;
33 | };
34 |
35 | struct gfileList {
36 | const struct GFILEVMT * vmt;
37 | bool_t dirs;
38 | };
39 |
40 | typedef struct GFILEVMT {
41 | uint8_t flags;
42 | #define GFSFLG_WRITEABLE 0x0001
43 | #define GFSFLG_CASESENSITIVE 0x0002
44 | #define GFSFLG_SEEKABLE 0x0004
45 | #define GFSFLG_FAST 0x0010
46 | #define GFSFLG_SMALL 0x0020
47 | #define GFSFLG_TEXTMODES 0x0040
48 | char prefix;
49 | bool_t (*del) (const char *fname);
50 | bool_t (*exists) (const char *fname);
51 | long int (*filesize) (const char *fname);
52 | bool_t (*ren) (const char *oldname, const char *newname);
53 | bool_t (*open) (GFILE *f, const char *fname);
54 | void (*close) (GFILE *f);
55 | int (*read) (GFILE *f, void *buf, int size);
56 | int (*write) (GFILE *f, const void *buf, int size);
57 | bool_t (*setpos) (GFILE *f, long int pos);
58 | long int (*getsize) (GFILE *f);
59 | bool_t (*eof) (GFILE *f);
60 | bool_t (*mount) (const char *drive);
61 | bool_t (*unmount) (const char *drive);
62 | bool_t (*sync) (GFILE *f);
63 | #if GFILE_NEED_FILELISTS
64 | gfileList * (*flopen) (const char *path, bool_t dirs);
65 | const char *(*flread) (gfileList *pfl);
66 | void (*flclose) (gfileList *pfl);
67 | #endif
68 | } GFILEVMT;
69 |
70 | GFILE *_gfileFindSlot(const char *mode);
71 |
72 | #endif //_GFILE_FS_H
73 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_fs_chibios.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /********************************************************
9 | * The ChibiOS FileStream file-system
10 | ********************************************************/
11 |
12 | #include "../../gfx.h"
13 |
14 | #if GFX_USE_GFILE && GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS
15 |
16 | #include "gfile_fs.h"
17 |
18 | static void ChibiOSBFSClose(GFILE *f);
19 | static int ChibiOSBFSRead(GFILE *f, void *buf, int size);
20 | static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size);
21 | static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos);
22 | static long int ChibiOSBFSGetsize(GFILE *f);
23 | static bool_t ChibiOSBFSEof(GFILE *f);
24 |
25 | static const GFILEVMT FsCHIBIOSVMT = {
26 | GFSFLG_SEEKABLE|GFSFLG_WRITEABLE, // flags
27 | 0, // prefix
28 | 0, 0, 0, 0,
29 | 0, ChibiOSBFSClose, ChibiOSBFSRead, ChibiOSBFSWrite,
30 | ChibiOSBFSSetpos, ChibiOSBFSGetsize, ChibiOSBFSEof,
31 | 0, 0, 0,
32 | #if GFILE_NEED_FILELISTS
33 | 0, 0, 0,
34 | #endif
35 | };
36 |
37 | #if CH_KERNEL_MAJOR == 2
38 | #define FileStream BaseFileStream
39 | #define fileStreamClose chFileStreamClose
40 | #define fileStreamRead chSequentialStreamRead
41 | #define fileStreamWrite chSequentialStreamWrite
42 | #define fileStreamSeek chFileStreamSeek
43 | #define fileStreamGetSize chFileStreamGetSize
44 | #endif
45 |
46 | static void ChibiOSBFSClose(GFILE *f) {
47 | fileStreamClose(((FileStream *)f->obj));
48 | }
49 | static int ChibiOSBFSRead(GFILE *f, void *buf, int size) {
50 | return fileStreamRead(((FileStream *)f->obj), (uint8_t *)buf, size);
51 | }
52 | static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size) {
53 | return fileStreamWrite(((FileStream *)f->obj), (uint8_t *)buf, size);
54 | }
55 | static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos) {
56 | fileStreamSeek(((FileStream *)f->obj), pos);
57 | return TRUE;
58 | }
59 | static long int ChibiOSBFSGetsize(GFILE *f) { return fileStreamGetSize(((FileStream *)f->obj)); }
60 | static bool_t ChibiOSBFSEof(GFILE *f) { return f->pos >= fileStreamGetSize(((FileStream *)f->obj)); }
61 |
62 | GFILE * gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode) {
63 | GFILE * f;
64 |
65 | // Get an empty file and set the flags
66 | if (!(f = _gfileFindSlot(mode)))
67 | return 0;
68 |
69 | // File is open - fill in all the details
70 | f->vmt = &FsCHIBIOSVMT;
71 | f->obj = FileStreamPtr;
72 | f->pos = 0;
73 | f->flags |= GFILEFLG_OPEN|GFILEFLG_CANSEEK;
74 | return f;
75 | }
76 |
77 | #endif //GFX_USE_GFILE && GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS
78 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_fs_mem.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /********************************************************
9 | * The virtual memory file-system
10 | ********************************************************/
11 |
12 | #include "../../gfx.h"
13 |
14 | #if GFX_USE_GFILE && GFILE_NEED_MEMFS
15 |
16 | #include "gfile_fs.h"
17 |
18 | #include
19 |
20 | static int MEMRead(GFILE *f, void *buf, int size);
21 | static int MEMWrite(GFILE *f, const void *buf, int size);
22 | static bool_t MEMSetpos(GFILE *f, long int pos);
23 |
24 | static const GFILEVMT FsMemVMT = {
25 | GFSFLG_SEEKABLE|GFSFLG_WRITEABLE, // flags
26 | 0, // prefix
27 | 0, 0, 0, 0,
28 | 0, 0, MEMRead, MEMWrite,
29 | MEMSetpos, 0, 0,
30 | 0, 0, 0,
31 | #if GFILE_NEED_FILELISTS
32 | 0, 0, 0,
33 | #endif
34 | };
35 |
36 | static int MEMRead(GFILE *f, void *buf, int size) {
37 | memcpy(buf, ((char *)f->obj)+f->pos, size);
38 | return size;
39 | }
40 | static int MEMWrite(GFILE *f, const void *buf, int size) {
41 | memcpy(((char *)f->obj)+f->pos, buf, size);
42 | return size;
43 | }
44 | static bool_t MEMSetpos(GFILE *f, long int pos) {
45 | (void) f;
46 | (void) pos;
47 | return TRUE;
48 | }
49 |
50 | GFILE * gfileOpenMemory(void *memptr, const char *mode) {
51 | GFILE *f;
52 |
53 | // Get an empty file and set the flags
54 | if (!(f = _gfileFindSlot(mode)))
55 | return 0;
56 |
57 | // File is open - fill in all the details
58 | f->vmt = &FsMemVMT;
59 | f->obj = memptr;
60 | f->pos = 0;
61 | f->flags |= GFILEFLG_OPEN|GFILEFLG_CANSEEK;
62 | return f;
63 | }
64 |
65 | #endif //GFX_USE_GFILE && GFILE_NEED_MEMFS
66 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_fs_ram.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /********************************************************
9 | * The RAM file-system
10 | ********************************************************/
11 |
12 | #include "../../gfx.h"
13 |
14 | #if GFX_USE_GFILE && GFILE_NEED_RAMFS
15 |
16 | #include "gfile_fs.h"
17 |
18 | #error "GFILE: RAMFS Not implemented yet"
19 |
20 | const GFILEVMT FsRAMVMT = {
21 | 0, // flags
22 | 'R', // prefix
23 | 0, 0, 0, 0,
24 | 0, 0, 0, 0,
25 | 0, 0, 0,
26 | 0, 0, 0,
27 | #if GFILE_NEED_FILELISTS
28 | 0, 0, 0,
29 | #endif
30 | };
31 |
32 | #endif //GFX_USE_GFILE && GFILE_NEED_RAMFS
33 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gfile.c"
9 | #include "gfile_fs_native.c"
10 | #include "gfile_fs_ram.c"
11 | #include "gfile_fs_rom.c"
12 | #include "gfile_fs_fatfs.c"
13 | #include "gfile_fs_petitfs.c"
14 | #include "gfile_fs_mem.c"
15 | #include "gfile_fs_chibios.c"
16 | #include "gfile_fs_strings.c"
17 | #include "gfile_printg.c"
18 | #include "gfile_scang.c"
19 | #include "gfile_stdio.c"
20 | #include "gfile_fatfs_wrapper.c"
21 | #include "gfile_fatfs_diskio_chibios.c"
22 | #include "gfile_petitfs_wrapper.c"
23 | #include "gfile_petitfs_diskio_chibios.c"
24 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_petitfs_wrapper.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 |
10 | #if GFX_USE_GFILE && GFILE_NEED_PETITFS && !GFILE_PETITFS_EXTERNAL_LIB
11 |
12 | #include "gfile_petitfs_wrapper.h"
13 |
14 | // Include the source we want
15 | #include "../../3rdparty/petitfs-0.03/src/pff.c"
16 |
17 | #endif // GFX_USE_GFILE && GFILE_NEED_PETITFS && !GFILE_PETITFS_EXTERNAL_LIB
18 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_petitfs_wrapper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gfile/gfile_petitfs_wrapper.h
10 | * @brief GFILE PETITFS wrapper.
11 | *
12 | */
13 |
14 | #ifndef _PETITFS_WRAPPER
15 | #define _PETITFS_WRAPPER
16 |
17 | // Include the petitfs configuration from the local directory not the original source folder
18 | #include "pffconf.h"
19 |
20 | // Include the petitfs API
21 | #include "../../3rdparty/petitfs-0.03/src/pff.h"
22 |
23 | // Include the petitfs diskio API
24 | #include "../../3rdparty/petitfs-0.03/src/diskio.h"
25 |
26 | #endif //_PETITFS_WRAPPER
27 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gfile/gfile_rules.h
10 | * @brief GFILE safety rules header file.
11 | *
12 | * @addtogroup GFILE
13 | * @{
14 | */
15 |
16 | #ifndef _GFILE_RULES_H
17 | #define _GFILE_RULES_H
18 |
19 | #if GFX_USE_GFILE
20 | #if GFILE_NEED_PETITFS && GFILE_NEED_FATFS
21 | #error "GFILE: Both GFILE_NEED_PETITFS and GFILE_NEED_FATFS cannot both be turned on at the same time."
22 | #endif
23 | #endif
24 |
25 | #endif /* _GFILE_RULES_H */
26 | /** @} */
27 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfile/gfile_stdio.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /********************************************************
9 | * Stdio Emulation Routines
10 | ********************************************************/
11 |
12 | #include "../../gfx.h"
13 |
14 | #if GFX_USE_GFILE && GFILE_NEED_STDIO && !defined(GFILE_NEED_STDIO_MUST_BE_OFF)
15 |
16 | #include "gfile_fs.h"
17 |
18 | size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f) {
19 | return gfileRead(f, ptr, size*count)/size;
20 | }
21 |
22 | size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f) {
23 | return gfileWrite(f, ptr, size*count)/size;
24 | }
25 |
26 | int gstdioSeek(GFILE *f, size_t offset, int origin) {
27 | switch(origin) {
28 | case SEEK_SET:
29 | break;
30 | case SEEK_CUR:
31 | offset += f->pos;
32 | break;
33 | case SEEK_END:
34 | offset += gfileGetSize(f);
35 | break;
36 | default:
37 | return -1;
38 | }
39 | return gfileSetPos(f, offset) ? 0 : -1;
40 | }
41 |
42 | int gstdioGetpos(GFILE *f, long int *pos) {
43 | if (!(f->flags & GFILEFLG_OPEN))
44 | return -1;
45 | *pos = f->pos;
46 | return 0;
47 | }
48 |
49 | #endif //GFX_USE_GFILE && GFILE_NEED_STDIO
50 |
--------------------------------------------------------------------------------
/components/ugfx/src/gfx_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gfx.c"
9 | #include "gos/gos_mk.c"
10 | #include "gdriver/gdriver_mk.c"
11 | #include "gqueue/gqueue_mk.c"
12 | #include "gdisp/gdisp_mk.c"
13 | #include "gevent/gevent_mk.c"
14 | #include "gtimer/gtimer_mk.c"
15 | #include "gwin/gwin_mk.c"
16 | #include "ginput/ginput_mk.c"
17 | #include "gadc/gadc_mk.c"
18 | #include "gaudio/gaudio_mk.c"
19 | #include "gmisc/gmisc_mk.c"
20 | #include "gfile/gfile_mk.c"
21 | #include "gtrans/gtrans_mk.c"
22 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/ginput/ginput.c
10 | * @brief GINPUT subsystem common code.
11 | *
12 | * @addtogroup GINPUT
13 | * @{
14 | */
15 | #include "../../gfx.h"
16 |
17 | #if GFX_USE_GINPUT
18 |
19 | #if GINPUT_NEED_MOUSE
20 | extern void _gmouseInit(void);
21 | extern void _gmouseDeinit(void);
22 | #endif
23 | #if GINPUT_NEED_KEYBOARD
24 | extern void _gkeyboardInit(void);
25 | extern void _gkeyboardDeinit(void);
26 | #endif
27 |
28 | void _ginputInit(void)
29 | {
30 | #if GINPUT_NEED_MOUSE
31 | _gmouseInit();
32 | #endif
33 | #if GINPUT_NEED_KEYBOARD
34 | _gkeyboardInit();
35 | #endif
36 | /**
37 | * This should really call an init routine for each ginput sub-system.
38 | * Maybe we'll do this later.
39 | */
40 | }
41 |
42 | void _ginputDeinit(void)
43 | {
44 | #if GINPUT_NEED_KEYBOARD
45 | _gkeyboardDeinit();
46 | #endif
47 | #if GINPUT_NEED_MOUSE
48 | _gmouseDeinit();
49 | #endif
50 | }
51 |
52 | #endif /* GFX_USE_GINPUT */
53 | /** @} */
54 |
55 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/ginput/ginput.h
10 | *
11 | * @addtogroup GINPUT
12 | *
13 | * @brief Module to interface different hardware input sources such as touchscreens
14 | *
15 | * @details GINPUT provides an easy and common interface to use different input devices
16 | * such as touchscreens and mices.
17 | *
18 | * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
19 | *
20 | * @{
21 | */
22 | #ifndef _GINPUT_H
23 | #define _GINPUT_H
24 |
25 | #include "../../gfx.h"
26 |
27 | #if GFX_USE_GINPUT || defined(__DOXYGEN__)
28 |
29 | /* How to use...
30 |
31 | 1. Get source handles for all the inputs you are interested in.
32 | - Attempting to get a handle for one instance of an input more than once will return the same handle
33 | 2. Create a listener
34 | 3. Assign inputs to your listener.
35 | - Inputs can be assigned or released from a listener at any time.
36 | - An input can be assigned to more than one listener.
37 | 4. Loop on getting listener events
38 | 5. When complete destroy the listener
39 | */
40 |
41 | // Include various ginput types
42 | #include "ginput_mouse.h"
43 | #include "ginput_keyboard.h"
44 | #include "ginput_toggle.h"
45 | #include "ginput_dial.h"
46 |
47 | #endif /* GFX_USE_GINPUT */
48 |
49 | #endif /* _GINPUT_H */
50 | /** @} */
51 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/ginput/ginput.c \
7 | $(GFXLIB)/src/ginput/ginput_mouse.c \
8 | $(GFXLIB)/src/ginput/ginput_keyboard.c \
9 | $(GFXLIB)/src/ginput/ginput_keyboard_microcode.c \
10 | $(GFXLIB)/src/ginput/ginput_toggle.c \
11 | $(GFXLIB)/src/ginput/ginput_dial.c
12 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput_driver_dial.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/ginput/ginput_driver_dial.h
10 | * @brief GINPUT header file for dial drivers.
11 | *
12 | * @defgroup Dial Dial
13 | * @ingroup GINPUT
14 | * @{
15 | */
16 |
17 | #ifndef _LLD_GINPUT_DIAL_H
18 | #define _LLD_GINPUT_DIAL_H
19 |
20 | #if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
21 |
22 | #include "ginput_lld_dial_config.h"
23 |
24 | typedef void (*DialCallbackFn)(uint16_t instance, uint16_t rawvalue);
25 |
26 | /*===========================================================================*/
27 | /* External declarations. */
28 | /*===========================================================================*/
29 |
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | void ginput_lld_dial_init(void);
35 | void ginput_lld_dial_poll(DialCallbackFn fn);
36 |
37 | #ifdef __cplusplus
38 | }
39 | #endif
40 |
41 | #endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
42 |
43 | #endif /* _LLD_GINPUT_TOGGLE_H */
44 | /** @} */
45 |
46 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput_driver_toggle.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/ginput/ginput_driver_toggle.h
10 | * @brief GINPUT header file for toggle drivers.
11 | *
12 | * @defgroup Toggle Toggle
13 | * @ingroup GINPUT
14 | * @{
15 | */
16 |
17 | #ifndef _LLD_GINPUT_TOGGLE_H
18 | #define _LLD_GINPUT_TOGGLE_H
19 |
20 | #if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__)
21 |
22 | // Describes how the toggle bits are obtained
23 | typedef struct GToggleConfig_t {
24 | void *id;
25 | unsigned mask;
26 | unsigned invert;
27 | unsigned mode;
28 | } GToggleConfig;
29 |
30 | /*===========================================================================*/
31 | /* External declarations. */
32 | /*===========================================================================*/
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | extern const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES];
39 |
40 | void ginput_lld_toggle_init(const GToggleConfig *ptc);
41 | unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc);
42 |
43 | /* This routine is provided to low level drivers to wakeup a value read from a thread context.
44 | * Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
45 | */
46 | void ginputToggleWakeup(void);
47 |
48 | /* This routine is provided to low level drivers to wakeup a value read from an ISR
49 | * Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
50 | */
51 | void ginputToggleWakeupI(void);
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
58 |
59 | #endif /* _LLD_GINPUT_TOGGLE_H */
60 | /** @} */
61 |
62 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput_keyboard_microcode.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/ginput/ginput_keyboard_microcode.c
10 | * @brief GINPUT keyboard standard microcode definitions.
11 | */
12 |
13 | #include "../../gfx.h"
14 |
15 | #if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD && !GKEYBOARD_LAYOUT_OFF
16 |
17 | #include "ginput_keyboard_microcode.h"
18 |
19 | #if GKEYBOARD_LAYOUT_SCANCODE2_US
20 |
21 | #error "Keyboard Layout SCANCODE2_US is not fully implemented yet"
22 |
23 | uint8_t KeyboardLayout_ScancodeSet2_US[] = {
24 | KMC_HEADERSTART, KMC_HEADER_ID1, KMC_HEADER_ID2, KMC_HEADER_VER_1,
25 |
26 | KMC_RECORDSTART, 0x03, // Handle E0 codes (ignore for now assuming a single character)
27 | KMC_TEST_LASTCODE, 0xE0,
28 | KMC_ACT_DONE,
29 | KMC_RECORDSTART, 0x03,
30 | KMC_TEST_CODE, 0xE0,
31 | KMC_ACT_STOP,
32 |
33 | KMC_RECORDSTART, 0x03, // Handle E1 codes (ignore for now assuming a single character)
34 | KMC_TEST_LASTCODE, 0xE1,
35 | KMC_ACT_DONE,
36 | KMC_RECORDSTART, 0x03,
37 | KMC_TEST_CODE, 0xE1,
38 | KMC_ACT_STOP,
39 |
40 | KMC_RECORDSTART, 0x03, // Handle E2 codes (ignore for now assuming a single character)
41 | KMC_TEST_LASTCODE, 0xE2,
42 | KMC_ACT_DONE,
43 | KMC_RECORDSTART, 0x03,
44 | KMC_TEST_CODE, 0xE2,
45 | KMC_ACT_STOP,
46 |
47 | KMC_RECORDSTART, 0x06, // KeyUp
48 | KMC_TEST_CODEBIT, 0x80,
49 | KMC_ACT_STATEBIT, GKEYSTATE_KEYUP_BIT,
50 | KMC_ACT_CODEBIT, 0x80 | KMC_BIT_CLEAR,
51 |
52 | KMC_RECORDSTART, 0x05, // CapsLock (on keyup to avoid repeats)
53 | KMC_TEST_CODE, 0x58,
54 | KMC_TEST_STATEBIT, GKEYSTATE_KEYUP_BIT | KMC_BIT_CLEAR,
55 | KMC_ACT_DONE,
56 | KMC_RECORDSTART, 0x05,
57 | KMC_TEST_CODE, 0x58,
58 | KMC_ACT_STATEBIT, GKEYSTATE_CAPSLOCK_BIT | KMC_BIT_INVERT,
59 | KMC_ACT_DONE,
60 |
61 | KMC_RECORDSTART, 0x05, // Detect Shift Keys
62 | //KMC_ACT_LAYOUTBIT, SCANCODESET2_LAYOUT_E0_BIT | KMC_BIT_CLEAR,
63 | KMC_ACT_STOP,
64 |
65 | KMC_RECORDSTART, 0x03,
66 | KMC_ACT_CHARRANGE, 0x00,
67 | KMC_ACT_DONE,
68 |
69 | KMC_RECORDSTART, 0x00,
70 | };
71 | #endif // GKEYBOARD_LAYOUT_SCANCODE2_US
72 |
73 | #endif // GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD && !GKEYBOARD_LAYOUT_OFF
74 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "ginput.c"
9 | #include "ginput_mouse.c"
10 | #include "ginput_keyboard.c"
11 | #include "ginput_keyboard_microcode.c"
12 | #include "ginput_toggle.c"
13 | #include "ginput_dial.c"
14 |
--------------------------------------------------------------------------------
/components/ugfx/src/ginput/ginput_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/ginput/ginput_rules.h
10 | * @brief GINPUT safety rules header file.
11 | *
12 | * @addtogroup GINPUT
13 | * @{
14 | */
15 |
16 | #ifndef _GINPUT_RULES_H
17 | #define _GINPUT_RULES_H
18 |
19 | #if GFX_USE_GINPUT
20 | #if !GFX_USE_GEVENT
21 | #if GFX_DISPLAY_RULE_WARNINGS
22 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
23 | #warning "GINPUT: GFX_USE_GEVENT is required if GFX_USE_GINPUT is TRUE. It has been turned on for you."
24 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
25 | COMPILER_WARNING("GINPUT: GFX_USE_GEVENT is required if GFX_USE_GINPUT is TRUE. It has been turned on for you.")
26 | #endif
27 | #endif
28 | #undef GFX_USE_GEVENT
29 | #define GFX_USE_GEVENT TRUE
30 | #endif
31 | #if !GFX_USE_GTIMER
32 | #if GFX_DISPLAY_RULE_WARNINGS
33 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
34 | #warning "GINPUT: GFX_USE_GTIMER is required if GFX_USE_GINPUT is TRUE. It has been turned on for you."
35 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
36 | COMPILER_WARNING("GINPUT: GFX_USE_GTIMER is required if GFX_USE_GINPUT is TRUE. It has been turned on for you.")
37 | #endif
38 | #endif
39 | #undef GFX_USE_GTIMER
40 | #define GFX_USE_GTIMER TRUE
41 | #endif
42 | #if GINPUT_NEED_MOUSE
43 | #if GINPUT_TOUCH_NOTOUCH
44 | // No warning needed for this
45 | #undef GINPUT_TOUCH_NOCALIBRATE
46 | #define GINPUT_TOUCH_NOCALIBRATE TRUE
47 | #endif
48 | #if GINPUT_TOUCH_NOCALIBRATE
49 | // No warning needed for this
50 | #undef GINPUT_TOUCH_NOCALIBRATE_GUI
51 | #define GINPUT_TOUCH_NOCALIBRATE_GUI TRUE
52 | #endif
53 | #if !GINPUT_TOUCH_NOTOUCH && GINPUT_MOUSE_CLICK_TIME > GINPUT_TOUCH_CXTCLICK_TIME
54 | #error "GINPUT MOUSE: The GINPUT_MOUSE_CLICK_TIME must be <= GINPUT_TOUCH_CXTCLICK_TIME"
55 | #endif
56 | #endif
57 | #endif
58 |
59 | #endif /* _GINPUT_RULES_H */
60 | /** @} */
61 |
--------------------------------------------------------------------------------
/components/ugfx/src/gmisc/gmisc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 |
10 | #if GFX_USE_GMISC
11 |
12 | void _gmiscInit(void)
13 | {
14 |
15 | }
16 |
17 | void _gmiscDeinit(void)
18 | {
19 |
20 | }
21 |
22 | #endif /* GFX_USE_GMISC */
23 |
--------------------------------------------------------------------------------
/components/ugfx/src/gmisc/gmisc.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gmisc/gmisc.c \
7 | $(GFXLIB)/src/gmisc/gmisc_arrayops.c \
8 | $(GFXLIB)/src/gmisc/gmisc_matrix2d.c \
9 | $(GFXLIB)/src/gmisc/gmisc_trig.c \
10 | $(GFXLIB)/src/gmisc/gmisc_hittest.c
11 |
--------------------------------------------------------------------------------
/components/ugfx/src/gmisc/gmisc_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gmisc.c"
9 | #include "gmisc_arrayops.c"
10 | #include "gmisc_matrix2d.c"
11 | #include "gmisc_trig.c"
12 | #include "gmisc_hittest.c"
13 |
--------------------------------------------------------------------------------
/components/ugfx/src/gmisc/gmisc_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gmisc/gmisc_options.h
10 | * @brief GMISC - Miscellaneous Routines options header file.
11 | *
12 | * @addtogroup GMISC
13 | * @{
14 | */
15 |
16 | #ifndef _GMISC_OPTIONS_H
17 | #define _GMISC_OPTIONS_H
18 |
19 | /**
20 | * @name GMISC Functionality to be included
21 | * @{
22 | */
23 | /**
24 | * @brief Include array operation functions
25 | * @details Defaults to FALSE
26 | */
27 | #ifndef GMISC_NEED_ARRAYOPS
28 | #define GMISC_NEED_ARRAYOPS FALSE
29 | #endif
30 | /**
31 | * @brief Include fast floating point trig functions (fsin, fcos)
32 | * @details Defaults to FALSE
33 | */
34 | #ifndef GMISC_NEED_FASTTRIG
35 | #define GMISC_NEED_FASTTRIG FALSE
36 | #endif
37 | /**
38 | * @brief Include fast fixed point trig functions (ffsin, ffcos)
39 | * @details Defaults to FALSE
40 | */
41 | #ifndef GMISC_NEED_FIXEDTRIG
42 | #define GMISC_NEED_FIXEDTRIG FALSE
43 | #endif
44 | /**
45 | * @brief Include fast inverse square root (x^-1/2)
46 | * @details Defaults to FALSE
47 | */
48 | #ifndef GMISC_NEED_INVSQRT
49 | #define GMISC_NEED_INVSQRT FALSE
50 | #endif
51 | /**
52 | * @brief Include polygon hit test functions
53 | * @details Defaults to FALSE
54 | */
55 | #ifndef GMISC_NEED_HITTEST_POLY
56 | #define GMISC_NEED_HITTEST_POLY FALSE
57 | #endif
58 | /**
59 | * @}
60 | *
61 | * @name GMISC Optional Parameters
62 | * @{
63 | */
64 | /**
65 | * @brief Modifies the @p invsqrt() function to assume a different integer to floating point endianness.
66 | * @note Normally the floating point format and the integer format have
67 | * the same endianness. Unfortunately there are some strange
68 | * processors that don't eg. some very early ARM devices.
69 | * For those where the endianness doesn't match you can fix it by
70 | * defining GMISC_INVSQRT_MIXED_ENDIAN.
71 | * @note This still assumes the processor is using an ieee floating point format.
72 | *
73 | * If you have a software floating point that uses a non-standard
74 | * floating point format (or very strange hardware) then define
75 | * GMISC_INVSQRT_REAL_SLOW and it will do it the hard way.
76 | */
77 | #ifndef GMISC_INVSQRT_MIXED_ENDIAN
78 | #define GMISC_INVSQRT_MIXED_ENDIAN FALSE
79 | #endif
80 | /**
81 | * @brief Modifies the @p invsqrt() function to do things the long slow way.
82 | * @note This causes the @p invsqrt() function to work regardless of the
83 | * processor floating point format.
84 | * @note This makes the @p invsqrt() function very slow.
85 | */
86 | #ifndef GMISC_INVSQRT_REAL_SLOW
87 | #define GMISC_INVSQRT_REAL_SLOW FALSE
88 | #endif
89 | /** @} */
90 |
91 | #endif /* _GMISC_OPTIONS_H */
92 | /** @} */
93 |
--------------------------------------------------------------------------------
/components/ugfx/src/gmisc/gmisc_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gmisc/gmisc_rules.h
10 | * @brief GMISC safety rules header file.
11 | *
12 | * @addtogroup GMISC
13 | * @{
14 | */
15 |
16 | #ifndef _GMISC_RULES_H
17 | #define _GMISC_RULES_H
18 |
19 | #if GFX_USE_GMISC
20 | #endif
21 |
22 | #endif /* _GMISC_RULES_H */
23 | /** @} */
24 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gos/gos_chibios.c \
7 | $(GFXLIB)/src/gos/gos_freertos.c \
8 | $(GFXLIB)/src/gos/gos_win32.c \
9 | $(GFXLIB)/src/gos/gos_linux.c \
10 | $(GFXLIB)/src/gos/gos_osx.c \
11 | $(GFXLIB)/src/gos/gos_raw32.c \
12 | $(GFXLIB)/src/gos/gos_ecos.c \
13 | $(GFXLIB)/src/gos/gos_rawrtos.c \
14 | $(GFXLIB)/src/gos/gos_arduino.c \
15 | $(GFXLIB)/src/gos/gos_cmsis.c \
16 | $(GFXLIB)/src/gos/gos_nios.c \
17 | $(GFXLIB)/src/gos/gos_zephyr.c \
18 | $(GFXLIB)/src/gos/gos_x_threads.c \
19 | $(GFXLIB)/src/gos/gos_x_heap.c
20 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_arduino.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 |
10 | #if GFX_USE_OS_ARDUINO
11 |
12 | #include // Prototype for memcpy()
13 |
14 | void _gosHeapInit(void);
15 | void _gosThreadsInit(void);
16 |
17 | /*********************************************************
18 | * Initialise
19 | *********************************************************/
20 |
21 | void _gosInit(void)
22 | {
23 | /* No initialization of the operating system itself is needed as there isn't one.
24 | * On the other hand the C runtime should still already be initialized before
25 | * getting here!
26 | */
27 | #if !GFX_OS_INIT_NO_WARNING
28 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
29 | #warning "GOS: Arduino - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!"
30 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
31 | COMPILER_WARNING("GOS: Arduino - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!")
32 | #endif
33 | #endif
34 |
35 | // Start the heap allocator
36 | _gosHeapInit();
37 |
38 | // Start the scheduler
39 | _gosThreadsInit();
40 | }
41 |
42 | void _gosPostInit(void)
43 | {
44 | }
45 |
46 | void _gosDeinit(void)
47 | {
48 | /* ToDo */
49 | }
50 |
51 | /*********************************************************
52 | * Exit everything functions
53 | *********************************************************/
54 |
55 | void gfxHalt(const char *msg) {
56 | volatile uint32_t dummy;
57 | (void) msg;
58 |
59 | while(1)
60 | dummy++;
61 | }
62 |
63 | void gfxExit(void) {
64 | volatile uint32_t dummy;
65 |
66 | while(1)
67 | dummy++;
68 | }
69 |
70 |
71 | /*********************************************************
72 | * Sleep functions
73 | *********************************************************/
74 |
75 | systemticks_t gfxSystemTicks(void) {
76 | return millis();
77 | }
78 | systemticks_t gfxMillisecondsToTicks(delaytime_t ms) {
79 | return ms;
80 | }
81 |
82 | #endif /* GFX_USE_OS_ARDUINO */
83 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_arduino.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * The arduino GOS implementation is similar to the bare metal raw32 gos implementation.
10 | * It uses cooperative multi-tasking. Be careful
11 | * when writing device drivers not to disturb the assumptions this creates by performing
12 | * call-backs to uGFX code unless you define the INTERRUPTS_OFF() and INTERRUPTS_ON() macros.
13 | * It still requires some C runtime library support...
14 | * enough startup to initialise the stack, interrupts, static data etc and call main().
15 | * setjmp() and longjmp() - for threading
16 | * memcpy() - for heap and threading
17 | * malloc(), realloc and free() - if GOS_RAW_HEAP_SIZE == 0
18 | *
19 | * You must also define the following routines in your own code so that timing functions will work...
20 | * systemticks_t gfxSystemTicks(void);
21 | * systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
22 | */
23 | #ifndef _GOS_ARDUINO_H
24 | #define _GOS_ARDUINO_H
25 |
26 | #if GFX_USE_OS_ARDUINO
27 |
28 | #include
29 |
30 | /*===========================================================================*/
31 | /* Type definitions */
32 | /*===========================================================================*/
33 |
34 | typedef unsigned char bool_t;
35 |
36 | #if 0
37 | // Already defined by Arduino
38 | typedef signed char int8_t;
39 | typedef unsigned char uint8_t;
40 | typedef signed short int16_t;
41 | typedef unsigned short uint16_t;
42 | typedef signed int int32_t;
43 | typedef unsigned int uint32_t;
44 | typedef uint32_t size_t;
45 | #endif
46 |
47 | #ifdef __cplusplus
48 | extern "C" {
49 | #endif
50 |
51 | void gfxHalt(const char *msg);
52 | void gfxExit(void);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | /*===========================================================================*/
59 | /* Use the generic thread handling and heap handling */
60 | /*===========================================================================*/
61 |
62 | #define GOS_NEED_X_THREADS TRUE
63 | #define GOS_NEED_X_HEAP TRUE
64 |
65 | #include "gos_x_threads.h"
66 | #include "gos_x_heap.h"
67 |
68 | #endif /* GFX_USE_OS_ARDUINO */
69 | #endif /* _GOS_ARDUINO_H */
70 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_cmsis.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 | #include
10 |
11 | #if GFX_USE_OS_CMSIS
12 |
13 | void _gosHeapInit(void);
14 |
15 | void _gosInit(void)
16 | {
17 | #if !GFX_OS_NO_INIT
18 | osKernelInitialize();
19 | if (!osKernelRunning())
20 | osKernelStart();
21 | #elif !GFX_OS_INIT_NO_WARNING
22 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
23 | #warning "GOS: Operating System initialization has been turned off. Make sure you call osKernelInitialize() and osKernelStart() before gfxInit() in your application!"
24 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
25 | COMPILER_WARNING("GOS: Operating System initialization has been turned off. Make sure you call osKernelInitialize() and osKernelStart() before gfxInit() in your application!")
26 | #endif
27 | #endif
28 |
29 | // Set up the heap allocator
30 | _gosHeapInit();
31 | }
32 |
33 | void _gosPostInit(void)
34 | {
35 | }
36 |
37 | void _gosDeinit(void)
38 | {
39 | }
40 |
41 | void gfxMutexInit(gfxMutex* pmutex)
42 | {
43 | osMutexDef_t def;
44 | def.mutex = pmutex->mutex;
45 |
46 | pmutex->id = osMutexCreate(&def);
47 | }
48 |
49 | void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)
50 | {
51 | osSemaphoreDef_t def;
52 | def.semaphore = psem->semaphore;
53 |
54 | if (val > limit) val = limit;
55 | psem->available = limit - val;
56 | psem->id = osSemaphoreCreate(&def, val);
57 | }
58 |
59 | void gfxSemDestroy(gfxSem* psem)
60 | {
61 | osSemaphoreDelete(psem->id);
62 | }
63 |
64 | bool_t gfxSemWait(gfxSem* psem, delaytime_t ms)
65 | {
66 | if (osSemaphoreWait(psem->id, ms) > 0) {
67 | psem->available++;
68 | return TRUE;
69 | }
70 | return FALSE;
71 | }
72 |
73 | bool_t gfxSemWaitI(gfxSem* psem)
74 | {
75 | return gfxSemWait(psem, 0);
76 | }
77 |
78 | void gfxSemSignal(gfxSem* psem)
79 | {
80 | gfxSemSignalI(psem);
81 | }
82 |
83 | void gfxSemSignalI(gfxSem* psem)
84 | {
85 | if (psem->available) {
86 | psem->available--;
87 | osSemaphoreRelease(psem->id);
88 | }
89 | }
90 |
91 | gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
92 | {
93 | osThreadDef_t def;
94 |
95 | (void)stackarea;
96 |
97 | def.pthread = (os_pthread)fn;
98 | def.tpriority = prio;
99 | def.instances = 1;
100 | def.stacksize = stacksz;
101 |
102 | return osThreadCreate(&def, param);
103 | }
104 |
105 | threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
106 | while(osThreadGetPriority(thread) == osPriorityError)
107 | gfxYield();
108 | }
109 |
110 | #endif /* GFX_USE_OS_CMSIS */
111 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_keil.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gos/gos_keil.h
10 | * @brief GOS - Operating System Support header file for Keil RTX
11 | */
12 |
13 | #ifndef _GOS_KEIL_H
14 | #define _GOS_KEIL_H
15 |
16 | #if GFX_USE_OS_KEIL
17 |
18 | /*
19 | * Keil RTX uses the CMSIS RTOS interface. Therefore, just use the CMSIS RTOS port
20 | */
21 |
22 | // Disable KEIL to avoid error: "GOS: More than one operation system has been defined as TRUE."
23 | #undef GFX_USE_OS_KEIL
24 | #define GFX_USE_OS_KEIL FALSE
25 |
26 | // Enable generic CMSIS RTOS implementation
27 | #undef GFX_USE_OS_CMSIS
28 | #define GFX_USE_OS_CMSIS TRUE
29 | #include "gos_cmsis.h"
30 |
31 | #endif /* GFX_USE_OS_KEIL */
32 | #endif /* _GOS_KEIL_H */
33 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gos_arduino.c"
9 | #include "gos_chibios.c"
10 | #include "gos_ecos.c"
11 | #include "gos_freertos.c"
12 | #include "gos_linux.c"
13 | #include "gos_osx.c"
14 | #include "gos_raw32.c"
15 | #include "gos_rawrtos.c"
16 | #include "gos_win32.c"
17 | #include "gos_cmsis.c"
18 | #include "gos_cmsis2.c"
19 | #include "gos_nios.c"
20 | #include "gos_zephyr.c"
21 | #include "gos_x_threads.c"
22 | #include "gos_x_heap.c"
23 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_nios.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 |
10 | #if GFX_USE_OS_NIOS
11 |
12 | void _gosHeapInit(void);
13 | void _gosThreadsInit(void);
14 |
15 | /*********************************************************
16 | * Initialise
17 | *********************************************************/
18 |
19 | void _gosInit(void)
20 | {
21 | // Set up the heap allocator
22 | _gosHeapInit();
23 |
24 | // Start the scheduler
25 | _gosThreadsInit();
26 | }
27 |
28 | void _gosPostInit(void)
29 | {
30 | }
31 |
32 | void _gosDeinit(void)
33 | {
34 | }
35 |
36 | void gfxHalt(const char *msg)
37 | {
38 | volatile uint32_t dummy;
39 |
40 | (void)msg;
41 |
42 | while(1) {
43 | dummy++;
44 | }
45 | }
46 |
47 | void gfxExit(void) {
48 | volatile uint32_t dummy;
49 |
50 | while(1) {
51 | dummy++;
52 | }
53 | }
54 |
55 | systemticks_t gfxSystemTicks(void)
56 | {
57 | return alt_nticks();
58 | }
59 |
60 | systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
61 | {
62 | return ms;
63 | }
64 |
65 | #endif /* GFX_USE_OS_NIOS */
66 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_nios.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #ifndef _GOS_NIOS_H
9 | #define _GOS_NIOS_H
10 |
11 | #if GFX_USE_OS_NIOS
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | typedef alt_u32 systemticks_t;
19 | typedef alt_u32 delaytime_t;
20 | typedef unsigned char bool_t;
21 |
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | void gfxHalt(const char* msg);
27 | void gfxExit(void);
28 | systemticks_t gfxSystemTicks(void);
29 | systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
34 |
35 |
36 | // Use the generic thread handling and heap handling
37 | #define GOS_NEED_X_THREADS TRUE
38 | #define GOS_NEED_X_HEAP TRUE
39 |
40 | #include "gos_x_threads.h"
41 | #include "gos_x_heap.h"
42 |
43 | #endif /* GFX_USE_OS_NIOS */
44 | #endif /* _GOS_NIOS_H */
45 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_osx.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #ifndef _GOS_OSX_H
9 | #define _GOS_OSX_H
10 |
11 | #if GFX_USE_OS_OSX
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | /* Already defined int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, size_t */
19 |
20 | typedef int8_t bool_t;
21 | typedef unsigned long systemticks_t;
22 | typedef void * threadreturn_t;
23 | typedef unsigned long delaytime_t;
24 | typedef pthread_t gfxThreadHandle;
25 | typedef int threadpriority_t;
26 | typedef uint32_t semcount_t;
27 | typedef pthread_mutex_t gfxMutex;
28 |
29 | #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
30 | #define DECLARE_THREAD_STACK(name, sz) uint8_t name[0];
31 | #define THREAD_RETURN(retval) return retval
32 |
33 | #define gfxExit() exit(0)
34 | #define gfxAlloc(sz) malloc(sz)
35 | #define gfxRealloc(p,osz,nsz) realloc(p, nsz)
36 | #define gfxFree(ptr) free(ptr)
37 | #define gfxMillisecondsToTicks(ms) (ms)
38 | #define gfxYield() sched_yield()
39 | #define gfxThreadMe() pthread_self()
40 | #define gfxThreadClose(th) (void)th
41 | #define gfxMutexInit(pmtx) pthread_mutex_init(pmtx, 0)
42 | #define gfxMutexDestroy(pmtx) pthread_mutex_destroy(pmtx)
43 | #define gfxMutexEnter(pmtx) pthread_mutex_lock(pmtx)
44 | #define gfxMutexExit(pmtx) pthread_mutex_unlock(pmtx)
45 | #define gfxSemWaitI(psem) gfxSemWait(psem, TIME_IMMEDIATE)
46 | #define gfxSemSignalI(psem) gfxSemSignal(psem)
47 |
48 | #define TIME_IMMEDIATE 0
49 | #define TIME_INFINITE ((delaytime_t)-1)
50 | #define MAX_SEMAPHORE_COUNT ((semcount_t)-1)
51 | #define LOW_PRIORITY 10
52 | #define NORMAL_PRIORITY 0
53 | #define HIGH_PRIORITY -10
54 |
55 | typedef struct gfxSem {
56 | pthread_mutex_t mtx;
57 | pthread_cond_t cond;
58 | semcount_t cnt;
59 | semcount_t max;
60 | } gfxSem;
61 |
62 | /*===========================================================================*/
63 | /* Function declarations. */
64 | /*===========================================================================*/
65 |
66 | #ifdef __cplusplus
67 | extern "C" {
68 | #endif
69 |
70 | void gfxHalt(const char *msg);
71 | void gfxSleepMilliseconds(delaytime_t ms);
72 | void gfxSleepMicroseconds(delaytime_t ms);
73 | systemticks_t gfxSystemTicks(void);
74 | void gfxSystemLock(void);
75 | void gfxSystemUnlock(void);
76 | void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
77 | void gfxSemDestroy(gfxSem *psem);
78 | bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
79 | void gfxSemSignal(gfxSem *psem);
80 | gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
81 | threadreturn_t gfxThreadWait(gfxThreadHandle thread);
82 |
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif /* GFX_USE_OS_OSX */
88 | #endif /* _GOS_OSX_H */
89 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_qt.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #ifndef _GOS_QT_H
9 | #define _GOS_QT_H
10 |
11 | #if GFX_USE_OS_QT
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
18 | #define DECLARE_THREAD_STACK(name, sz) uint8_t name[0]
19 | #define THREAD_RETURN(retval) return retval
20 |
21 | #define TIME_IMMEDIATE 0
22 | #define TIME_INFINITE ((delaytime_t)-1)
23 | #define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
24 | #define LOW_PRIORITY 2
25 | #define NORMAL_PRIORITY 3
26 | #define HIGH_PRIORITY 4
27 |
28 | typedef bool bool_t;
29 | typedef int systemticks_t;
30 | typedef int delaytime_t;
31 | typedef void* gfxMutex;
32 | typedef void* gfxSem;
33 | typedef int semcount_t;
34 | typedef int threadreturn_t;
35 | typedef int threadpriority_t;
36 | typedef void* gfxThreadHandle;
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | void _gosInit();
43 | void _gosDeinit();
44 |
45 | void gfxHalt(const char* msg);
46 | void gfxExit(void);
47 | void* gfxAlloc(size_t sz);
48 | void gfxFree(void* ptr);
49 | void gfxYield(void);
50 | void gfxSleepMilliseconds(delaytime_t ms);
51 | void gfxSleepMicroseconds(delaytime_t us);
52 | systemticks_t gfxSystemTicks(void);
53 | systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
54 | void gfxSystemLock(void);
55 | void gfxSystemUnlock(void);
56 | void gfxMutexInit(gfxMutex *pmutex);
57 | void gfxMutexDestroy(gfxMutex *pmutex);
58 | void gfxMutexEnter(gfxMutex *pmutex);
59 | void gfxMutexExit(gfxMutex *pmutex);
60 | void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
61 | void gfxSemDestroy(gfxSem *psem);
62 | bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
63 | bool_t gfxSemWaitI(gfxSem *psem);
64 | void gfxSemSignal(gfxSem *psem);
65 | void gfxSemSignalI(gfxSem *psem);
66 | gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
67 | threadreturn_t gfxThreadWait(gfxThreadHandle thread);
68 | gfxThreadHandle gfxThreadMe(void);
69 | void gfxThreadClose(gfxThreadHandle thread);
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif
74 |
75 | #endif /* GFX_USE_OS_QT */
76 | #endif /* _GOS_QT_H */
77 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_raw32.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * The raw32 GOS implementation supports any 32 bit processor with or without an
10 | * underlying operating system. It uses cooperative multi-tasking. Be careful
11 | * when writing device drivers not to disturb the assumptions this creates by performing
12 | * call-backs to uGFX code unless you define the INTERRUPTS_OFF() and INTERRUPTS_ON() macros.
13 | * It still requires some C runtime library support...
14 | * enough startup to initialise the stack, interrupts, static data etc and call main().
15 | * setjmp() and longjmp() - for threading
16 | * memcpy() - for heap and threading
17 | * malloc(), realloc and free() - if GOS_RAW_HEAP_SIZE == 0
18 | *
19 | * You must also define the following routines in your own code so that timing functions will work...
20 | * systemticks_t gfxSystemTicks(void);
21 | * systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
22 | */
23 | #ifndef _GOS_RAW32_H
24 | #define _GOS_RAW32_H
25 |
26 | #if GFX_USE_OS_RAW32
27 |
28 | /*===========================================================================*/
29 | /* Type definitions */
30 | /*===========================================================================*/
31 |
32 | typedef unsigned char bool_t;
33 |
34 | #if __STDC_VERSION__ >= 199901L
35 | #include
36 | #elif defined(__GNUC__) || defined(__GNUG__)
37 | typedef __INT8_TYPE__ int8_t;
38 | typedef __UINT8_TYPE__ uint8_t;
39 | typedef __INT16_TYPE__ int16_t;
40 | typedef __UINT16_TYPE__ uint16_t;
41 | typedef __INT32_TYPE__ int32_t;
42 | typedef __UINT32_TYPE__ uint32_t;
43 | #else
44 | typedef signed char int8_t;
45 | typedef unsigned char uint8_t;
46 | typedef signed short int16_t;
47 | typedef unsigned short uint16_t;
48 | typedef signed int int32_t;
49 | typedef unsigned int uint32_t;
50 | #endif
51 |
52 | #if defined(__STDC__)
53 | #include
54 | #else
55 | typedef uint32_t size_t;
56 | #endif
57 |
58 | #ifdef __cplusplus
59 | extern "C" {
60 | #endif
61 |
62 | void gfxHalt(const char *msg);
63 | void gfxExit(void);
64 |
65 | #ifdef __cplusplus
66 | }
67 | #endif
68 |
69 | /*===========================================================================*/
70 | /* Use the generic thread handling and heap handling */
71 | /*===========================================================================*/
72 |
73 | #define GOS_NEED_X_THREADS TRUE
74 | #define GOS_NEED_X_HEAP TRUE
75 |
76 | #include "gos_x_threads.h"
77 | #include "gos_x_heap.h"
78 |
79 | #endif /* GFX_USE_OS_RAW32 */
80 | #endif /* _GOS_RAW32_H */
81 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_rawrtos.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 |
10 | #if GFX_USE_OS_RAWRTOS
11 |
12 | #include
13 | #include "raw_api.h"
14 | #include "raw_config.h"
15 |
16 | #if CONFIG_RAW_MUTEX != 1
17 | #error "GOS: CONFIG_RAW_MUTEX must be defined in raw_config.h"
18 | #endif
19 |
20 | #if CONFIG_RAW_SEMAPHORE != 1
21 | #error "GOS: CONFIG_RAW_SEMAPHORE must be defined in raw_config.h"
22 | #endif
23 |
24 |
25 | void _gosInit(void)
26 | {
27 | #if !GFX_OS_NO_INIT
28 | #error "GOS: Operating System initialization for RawRTOS is not yet implemented in uGFX. Please set GFX_OS_NO_INIT to TRUE in your gfxconf.h"
29 | #endif
30 | #if !GFX_OS_INIT_NO_WARNING
31 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
32 | #warning "GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!"
33 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
34 | COMPILER_WARNING("GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!")
35 | #endif
36 | #endif
37 | }
38 |
39 | void _gosPostInit(void)
40 | {
41 | }
42 |
43 | void _gosDeinit(void)
44 | {
45 | }
46 |
47 |
48 | void gfxSleepMilliseconds(delaytime_t ms)
49 | {
50 | systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
51 | if(!ticks)ticks = 1;
52 | raw_sleep(ticks);
53 | }
54 |
55 | void gfxSleepMicroseconds(delaytime_t us)
56 | {
57 | systemticks_t ticks = (us/1000)*RAW_TICKS_PER_SECOND/1000;
58 | if(!ticks)ticks = 1;
59 | raw_sleep(ticks);
60 | }
61 |
62 | bool_t gfxSemWait(gfxSem* psem, delaytime_t ms)
63 | {
64 | systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
65 | if(!ticks)ticks=1;
66 | if(raw_semaphore_get((psem), ticks)==RAW_SUCCESS)
67 | return TRUE;
68 | return FALSE;
69 | }
70 |
71 | bool_t gfxSemWaitI(gfxSem* psem)
72 | {
73 | if(raw_semaphore_get((psem), TIME_IMMEDIATE)==RAW_SUCCESS)
74 | return TRUE;
75 | return FALSE;
76 | }
77 |
78 | gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
79 | {
80 | RAW_U16 ret;
81 | gfxThreadHandle taskobj;
82 |
83 | taskobj = gfxAlloc(sizeof(RAW_TASK_OBJ));
84 | ret = raw_task_create(taskobj, (RAW_U8 *)"uGFX_TASK", param,
85 | prio, 0, stackarea,
86 | stacksz/sizeof(PORT_STACK) , fn, 1);
87 |
88 | if (ret != RAW_SUCCESS) {
89 | for (;;);
90 | }
91 |
92 | return (taskobj);
93 | }
94 |
95 |
96 | #endif
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_rtx5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gos/gos_rtx5.h
10 | * @brief GOS - Operating System Support header file for Keil RTX
11 | */
12 |
13 | #ifndef _GOS_RTX5_H
14 | #define _GOS_RTX5_H
15 |
16 | #if GFX_USE_OS_RTX5
17 |
18 | /*
19 | * Keil RTX uses the CMSIS RTOS interface. Therefore, just use the CMSIS2 RTOS port
20 | */
21 |
22 | // Disable KEIL to avoid error: "GOS: More than one operation system has been defined as TRUE."
23 | #undef GFX_USE_OS_RTX5
24 | #define GFX_USE_OS_RTX5 FALSE
25 |
26 | // Enable generic CMSIS RTOS implementation
27 | #undef GFX_USE_OS_CMSIS2
28 | #define GFX_USE_OS_CMSIS2 TRUE
29 | #include "gos_cmsis2.h"
30 |
31 | #endif /* GFX_USE_OS_RTX5 */
32 | #endif /* _GOS_RTX5_H */
33 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gos/gos_rules.h
10 | * @brief GOS safety rules header file.
11 | *
12 | * @addtogroup GOS
13 | * @{
14 | */
15 |
16 | #ifndef _GOS_RULES_H
17 | #define _GOS_RULES_H
18 |
19 | #if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS && !GFX_USE_OS_RAWRTOS && !GFX_USE_OS_ARDUINO && !GFX_USE_OS_CMSIS && !GFX_USE_OS_CMSIS2 && !GFX_USE_OS_KEIL && !GFX_USE_OS_RTX5 && !GFX_USE_OS_NIOS && !GFX_USE_OS_ZEPHYR && !GFX_USE_OS_QT
20 | #error "GOS: No operating system has been defined."
21 | #endif
22 |
23 | #if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS + GFX_USE_OS_RAWRTOS + GFX_USE_OS_ARDUINO + GFX_USE_OS_CMSIS + GFX_USE_OS_CMSIS2 + GFX_USE_OS_KEIL + GFX_USE_OS_RTX5 + GFX_USE_OS_NIOS + GFX_USE_OS_ZEPHYR + GFX_USE_OS_QT != 1 * TRUE
24 | #error "GOS: More than one operation system has been defined as TRUE."
25 | #endif
26 |
27 | #if GFX_FREERTOS_USE_TRACE && !GFX_USE_OS_FREERTOS
28 | #error "GOS: GFX_FREERTOS_USE_TRACE is only available for the FreeRTOS port."
29 | #endif
30 |
31 | #if GFX_USE_OS_ZEPHYR && !defined(CONFIG_HEAP_MEM_POOL_SIZE)
32 | #error "GOS: CONFIG_HEAP_MEM_POOL_SIZE must be defined to use the Zephyr port."
33 | #endif
34 |
35 | #if GFX_EMULATE_MALLOC
36 | #if GFX_USE_OS_WIN32 || GFX_USE_OS_LINUX || GFX_USE_OS_OSX || GFX_USE_OS_ECOS || \
37 | (GFX_OS_HEAP_SIZE == 0 && (GFX_USE_OS_RAW32 || GFX_USE_OS_ARDUINO || GFX_USE_OS_CMSIS || GFX_USE_OS_CMSIS2 || GFX_USE_OS_KEIL || GFX_USE_OS_RTX5))
38 | #if GFX_DISPLAY_RULE_WARNINGS
39 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
40 | #warning "GOS: Cannot emulate malloc as gfxAlloc() internally uses malloc on this platform"
41 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
42 | COMPILER_WARNING("GOS: Cannot emulate malloc as gfxAlloc() internally uses malloc on this platform")
43 | #endif
44 | #endif
45 | #undef GFX_EMULATE_MALLOC
46 | #define GFX_EMULATE_MALLOC FALSE
47 | #endif
48 | #endif
49 |
50 | #endif /* _GOS_RULES_H */
51 | /** @} */
52 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_x_heap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #ifndef _GOS_X_HEAP_H
9 | #define _GOS_X_HEAP_H
10 |
11 | #if GOS_NEED_X_HEAP || defined(__DOXYGEN__)
12 |
13 | /*===========================================================================*/
14 | /* Type definitions */
15 | /*===========================================================================*/
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | #if GFX_OS_HEAP_SIZE != 0 || defined(__DOXYGEN__)
22 | /**
23 | * @brief Take a chunk of memory and add it to the available heap
24 | * @note Memory added must obviously not already be on the heap.
25 | * @note It is allowable to add multiple non-contiguous blocks of memory
26 | * to the heap. If however it is contiguous with a previously added block
27 | * it will get merged with the existing block in order to allow
28 | * allocations that span the boundary.
29 | * @pre GFX_OS_HEAP_SIZE != 0 and an operating system that uses the
30 | * internal ugfx heap allocator rather than its own allocator.
31 | */
32 | void gfxAddHeapBlock(void *ptr, size_t sz);
33 | #endif
34 |
35 | void *gfxAlloc(size_t sz);
36 | void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz);
37 | void gfxFree(void *ptr);
38 |
39 | #ifdef __cplusplus
40 | }
41 | #endif
42 |
43 | #endif /* GOS_NEED_X_HEAP */
44 | #endif /* _GOS_X_HEAP_H */
45 |
--------------------------------------------------------------------------------
/components/ugfx/src/gos/gos_zephyr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 |
10 | #if GFX_USE_OS_ZEPHYR
11 |
12 | systemticks_t gfxSystemTicks(void)
13 | {
14 | s32_t ms = k_uptime_get_32();
15 | return CONFIG_SYS_CLOCK_TICKS_PER_SEC*ms/1000;
16 | }
17 |
18 | #endif // GFX_USE_OS_ZEPHYR
19 |
--------------------------------------------------------------------------------
/components/ugfx/src/gqueue/gqueue.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gqueue/gqueue.c
7 |
--------------------------------------------------------------------------------
/components/ugfx/src/gqueue/gqueue_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gqueue.c"
9 |
--------------------------------------------------------------------------------
/components/ugfx/src/gqueue/gqueue_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gqueue/gqueue_options.h
10 | * @brief GQUEUE - Queue options header file.
11 | *
12 | * @addtogroup GQUEUE
13 | * @{
14 | */
15 |
16 | #ifndef _GQUEUE_OPTIONS_H
17 | #define _GQUEUE_OPTIONS_H
18 |
19 | /**
20 | * @name GQUEUE Functions to include.
21 | * @{
22 | */
23 | /**
24 | * @brief Enable Asynchronous Queues
25 | * @details Defaults to FALSE
26 | */
27 | #ifndef GQUEUE_NEED_ASYNC
28 | #define GQUEUE_NEED_ASYNC FALSE
29 | #endif
30 | /**
31 | * @brief Enable Get-Synchronous Queues
32 | * @details Defaults to FALSE
33 | */
34 | #ifndef GQUEUE_NEED_GSYNC
35 | #define GQUEUE_NEED_GSYNC FALSE
36 | #endif
37 | /**
38 | * @brief Enable Fully Synchronous Queues
39 | * @details Defaults to FALSE
40 | */
41 | #ifndef GQUEUE_NEED_FSYNC
42 | #define GQUEUE_NEED_FSYNC FALSE
43 | #endif
44 | /**
45 | * @brief Enable Queue-able Data Buffers
46 | */
47 | #ifndef GQUEUE_NEED_BUFFERS
48 | #define GQUEUE_NEED_BUFFERS FALSE
49 | #endif
50 | /**
51 | * @}
52 | *
53 | * @name GQUEUE Optional Sizing Parameters
54 | * @{
55 | */
56 | /** @} */
57 |
58 | #endif /* _GQUEUE_OPTIONS_H */
59 | /** @} */
60 |
--------------------------------------------------------------------------------
/components/ugfx/src/gqueue/gqueue_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gqueue/gqueue_rules.h
10 | * @brief GQUEUE safety rules header file.
11 | *
12 | * @addtogroup GQUEUE
13 | * @{
14 | */
15 |
16 | #ifndef _GQUEUE_RULES_H
17 | #define _GQUEUE_RULES_H
18 |
19 | #if GFX_USE_GQUEUE
20 | #if GQUEUE_NEED_BUFFERS && !GQUEUE_NEED_GSYNC
21 | #if GFX_DISPLAY_RULE_WARNINGS
22 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
23 | #warning "GQUEUE: GQUEUE_NEED_GSYNC is required if GQUEUE_NEED_BUFFERS is TRUE. It has been turned on for you."
24 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
25 | COMPILER_WARNING("GQUEUE: GQUEUE_NEED_GSYNC is required if GQUEUE_NEED_BUFFERS is TRUE. It has been turned on for you.")
26 | #endif
27 | #endif
28 | #undef GQUEUE_NEED_GSYNC
29 | #define GQUEUE_NEED_GSYNC TRUE
30 | #endif
31 | #endif
32 |
33 | #endif /* _GQUEUE_RULES_H */
34 | /** @} */
35 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtimer/gtimer.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gtimer/gtimer.c
7 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtimer/gtimer_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gtimer.c"
9 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtimer/gtimer_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gtimer/gtimer_options.h
10 | * @brief GTIMER sub-system options header file.
11 | *
12 | * @addtogroup GTIMER
13 | * @{
14 | */
15 |
16 | #ifndef _GTIMER_OPTIONS_H
17 | #define _GTIMER_OPTIONS_H
18 |
19 | /**
20 | * @name GTIMER Functionality to be included
21 | * @{
22 | */
23 | /**
24 | * @}
25 | *
26 | * @name GTIMER Optional Sizing Parameters
27 | * @{
28 | */
29 | /**
30 | * @brief Defines the GTIMER thread priority
31 | * @details Defaults to HIGH_PRIORITY
32 | */
33 | #ifndef GTIMER_THREAD_PRIORITY
34 | #define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
35 | #endif
36 | /**
37 | * @brief Defines the size of the timer threads work area (stack+structures).
38 | * @details Defaults to 2048 bytes
39 | */
40 | #ifndef GTIMER_THREAD_WORKAREA_SIZE
41 | #define GTIMER_THREAD_WORKAREA_SIZE 2048
42 | #endif
43 | /** @} */
44 |
45 | #endif /* _GTIMER_OPTIONS_H */
46 | /** @} */
47 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtimer/gtimer_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gtimer/gtimer_rules.h
10 | * @brief GTIMER safety rules header file.
11 | *
12 | * @addtogroup GTIMER
13 | * @{
14 | */
15 |
16 | #ifndef _GTIMER_RULES_H
17 | #define _GTIMER_RULES_H
18 |
19 | #if GFX_USE_GTIMER
20 | #if GFX_USE_GDISP && !GDISP_NEED_MULTITHREAD
21 | #if GFX_DISPLAY_RULE_WARNINGS
22 | #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
23 | #warning "GTIMER: GDISP_NEED_MULTITHREAD has not been specified. Make sure you are not performing any GDISP/GWIN drawing operations in the timer callback!"
24 | #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
25 | COMPILER_WARNING("GTIMER: GDISP_NEED_MULTITHREAD has not been specified. Make sure you are not performing any GDISP/GWIN drawing operations in the timer callback!")
26 | #endif
27 | #endif
28 | #endif
29 | #endif
30 |
31 | #endif /* _GTIMER_RULES_H */
32 | /** @} */
33 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtrans/gtrans.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include
9 | #include "../../gfx.h"
10 |
11 | #if GFX_USE_GTRANS
12 |
13 | static const transTable* _languageBase;
14 | static const transTable* _languageCurrent;
15 |
16 | void _gtransInit(void)
17 | {
18 | _languageBase = 0;
19 | _languageCurrent = 0;
20 | }
21 |
22 | void _gtransDeinit(void)
23 | {
24 | }
25 |
26 | const char* gtransString(const char* string)
27 | {
28 | // Find the index of the specified string in the base language table
29 | size_t i = 0;
30 | while (1) {
31 | // Prevent overflow
32 | if (i >= _languageBase->numEntries) {
33 | return string;
34 | }
35 |
36 | // Check if we found the string
37 | if (strcmp(string, _languageBase->strings[i]) == 0) {
38 | break;
39 | }
40 |
41 | // Otherwise keep going
42 | i++;
43 | }
44 |
45 | // Make sure that the index exists in the current language table
46 | if (i >= _languageCurrent->numEntries) {
47 | return string;
48 | }
49 |
50 | // Return the translated string
51 | return _languageCurrent->strings[i];
52 | }
53 |
54 | const char* gtransIndex(unsigned index)
55 | {
56 | if (!_languageCurrent) {
57 | return 0;
58 | }
59 |
60 | if (index >= _languageCurrent->numEntries) {
61 | return 0;
62 | }
63 |
64 | return _languageCurrent->strings[index];
65 | }
66 |
67 | void gtransSetBaseLanguage(const transTable* const translation)
68 | {
69 | _languageBase = translation;
70 | }
71 |
72 | void gtransSetLanguage(const transTable* const translation)
73 | {
74 | _languageCurrent = translation;
75 | }
76 |
77 | #endif /* GFX_USE_GTRANS */
78 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtrans/gtrans.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gtrans/gtrans.h
10 | *
11 | * @addtogroup GTRANS
12 | *
13 | * @brief Module that allows changing the language of an application dynamically during run-time.
14 | *
15 | * @{
16 | */
17 |
18 | #ifndef _TRANS_H
19 | #define _TRANS_H
20 |
21 | #include "../../gfx.h"
22 |
23 | #if GFX_USE_GTRANS || defined(__DOXYGEN__)
24 |
25 | /**
26 | * @struct transTable
27 | * @brief A table containing translated strings.
28 | */
29 | typedef struct transTable {
30 | unsigned numEntries; /**< The number of strings that this table contains */
31 | const char** strings; /**< The translated strings */
32 | } transTable;
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /**
39 | * @brief A wrapper macro to make writing and reading translatable applications easier.
40 | */
41 | #define gt(str) gtransString(str)
42 |
43 | /**
44 | * @brief Get the string of the current language specified by the string of the base language.
45 | *
46 | * @details This function will return the string of the current language that corresponds to
47 | * the specified string in the base language.
48 | * @details This function uses strcmp() internally to compare strings.
49 | *
50 | * @param[in] string The string to translate.
51 | *
52 | * @return The corresponding string of the current language or the string passed as a parameter if it doesn't exist.
53 | */
54 | const char* gtransString(const char* string);
55 |
56 | /**
57 | * @brief Get the string at the specified index position of the current language.
58 | *
59 | * @details Getting translation strings is a lot faster using the index as an accessor rather
60 | * than the string in the base language.
61 | *
62 | * @param[in] index The index of the string in the current language translation table.
63 | *
64 | * @return The string at the given index of the current language or 0 if it doesn't exist.
65 | */
66 | const char* gtransIndex(unsigned index);
67 |
68 | /**
69 | * @brief Set the base language.
70 | *
71 | * @details A translatable application needs to have a base language. All translations will
72 | * be relative to this base language.
73 | *
74 | * @param[in] translation The translation table
75 | */
76 | void gtransSetBaseLanguage(const transTable* const translation);
77 |
78 | /**
79 | * @brief Set the current language.
80 | *
81 | * @details All translations will refer to the current language set by calling this function.
82 | *
83 | * @param[in] translation The translation table
84 | */
85 | void gtransSetLanguage(const transTable* const translation);
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
91 | #endif /* GFX_USE_GTRANS */
92 |
93 | #endif /* _TRANS_H */
94 | /** @} */
95 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtrans/gtrans.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gtrans/gtrans.c
7 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtrans/gtrans_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gtrans.c"
9 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtrans/gtrans_options.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gtrans/gtrans_options.h
10 | *
11 | * @addtogroup GTRANS
12 | * @{
13 | */
14 |
15 | #ifndef _GTRANS_OPTIONS_H
16 | #define _GTRANS_OPTIONS_H
17 |
18 |
19 |
20 | #endif /* _GTRANS_OPTIONS_H */
21 | /** @} */
22 |
--------------------------------------------------------------------------------
/components/ugfx/src/gtrans/gtrans_rules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gtrans/gtrans_rules.h
10 | *
11 | * @addtogroup GTRANS
12 | * @{
13 | */
14 |
15 | #ifndef _GTRANS_RULES_H
16 | #define _GTRANS_RULES_H
17 |
18 | #if GFX_USE_GTRANS
19 | #endif
20 |
21 | #endif /* _GTRANS_RULES_H */
22 | /** @} */
23 |
--------------------------------------------------------------------------------
/components/ugfx/src/gwin/gwin.mk:
--------------------------------------------------------------------------------
1 | # This file is subject to the terms of the GFX License. If a copy of
2 | # the license was not distributed with this file, you can obtain one at:
3 | #
4 | # http://ugfx.org/license.html
5 |
6 | GFXSRC += $(GFXLIB)/src/gwin/gwin.c \
7 | $(GFXLIB)/src/gwin/gwin_widget.c \
8 | $(GFXLIB)/src/gwin/gwin_wm.c \
9 | $(GFXLIB)/src/gwin/gwin_console.c \
10 | $(GFXLIB)/src/gwin/gwin_graph.c \
11 | $(GFXLIB)/src/gwin/gwin_button.c \
12 | $(GFXLIB)/src/gwin/gwin_slider.c \
13 | $(GFXLIB)/src/gwin/gwin_checkbox.c \
14 | $(GFXLIB)/src/gwin/gwin_image.c \
15 | $(GFXLIB)/src/gwin/gwin_label.c \
16 | $(GFXLIB)/src/gwin/gwin_radio.c \
17 | $(GFXLIB)/src/gwin/gwin_list.c \
18 | $(GFXLIB)/src/gwin/gwin_progressbar.c \
19 | $(GFXLIB)/src/gwin/gwin_container.c \
20 | $(GFXLIB)/src/gwin/gwin_frame.c \
21 | $(GFXLIB)/src/gwin/gwin_tabset.c \
22 | $(GFXLIB)/src/gwin/gwin_gl3d.c \
23 | $(GFXLIB)/src/gwin/gwin_keyboard.c \
24 | $(GFXLIB)/src/gwin/gwin_keyboard_layout.c \
25 | $(GFXLIB)/src/gwin/gwin_textedit.c
26 |
27 | GFXINC += $(GFXLIB)/3rdparty/tinygl-0.4-ugfx/include
28 |
--------------------------------------------------------------------------------
/components/ugfx/src/gwin/gwin_gl3d.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | /**
9 | * @file src/gwin/gwin_gl3d.h
10 | * @brief GWIN 3D module header file
11 | *
12 | * @defgroup 3D 3D
13 | * @ingroup Windows
14 | *
15 | * @brief Widget that can be used to render OpenGL.
16 | *
17 | * @details 3D GWIN window based on OpenGL (or more exactly Tiny GL)
18 | *
19 | * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
20 | * @pre GWIN_NEED_GL3D must be set to TRUE in your gfxconf.h
21 | *
22 | * @{
23 | */
24 |
25 | #ifndef _GWIN_GL3D_H
26 | #define _GWIN_GL3D_H
27 |
28 | /* This file is included within "src/gwin/gwin.h" */
29 |
30 |
31 | // A gl3d window
32 | typedef struct GGL3DObject {
33 | GWindowObject g;
34 | struct GLContext * glcxt;
35 | } GGL3DObject;
36 |
37 | /*===========================================================================*/
38 | /* External declarations. */
39 | /*===========================================================================*/
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | /**
46 | * @brief Create a gl3d window.
47 | * @return NULL if there is no resultant drawing area, otherwise a window handle.
48 | *
49 | * @param[in] g The GDisplay to display this window on
50 | * @param[in] gg The GGL3DObject structure to initialise. If this is NULL the structure is dynamically allocated.
51 | * @param[in] pInit The initialization parameters to use
52 | *
53 | * @note The drawing color and the background color get set to the current defaults. If you haven't called
54 | * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively.
55 | * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
56 | * is no default font and text drawing operations will no nothing.
57 | * @note The dimensions and position may be changed to fit on the real screen.
58 | *
59 | * @api
60 | */
61 | GHandle gwinGGL3DCreate(GDisplay *g, GGL3DObject *gg, const GWindowInit *pInit);
62 | #define gwinGL3DCreate(gg, pInit) gwinGGL3DCreate(GDISP, gg, pInit)
63 |
64 | /* Include the gl interface */
65 | #include "../../3rdparty/tinygl-0.4-ugfx/include/GL/gl.h"
66 |
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 |
71 | #endif /* _GWIN_GL3D_H */
72 | /** @} */
73 |
74 |
--------------------------------------------------------------------------------
/components/ugfx/src/gwin/gwin_keyboard_layout.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "../../gfx.h"
9 |
10 | #if GFX_USE_GWIN && GWIN_NEED_KEYBOARD
11 |
12 | #include "gwin_keyboard_layout.h"
13 |
14 | #if GWIN_NEED_KEYBOARD_ENGLISH1
15 | /* For this keyboard mapping we use:
16 | * Set 0 = Lowercase letters
17 | * Set 1 = Uppercase letters (transient)
18 | * Set 2 = Uppercase letters (locked)
19 | * Set 3 = Numbers
20 | * Set 4 = Symbols
21 | */
22 | static const GVSpecialKey Eng1SKeys[] = {
23 | { "\001", 0, GVKEY_SINGLESET, 1 }, // \001 (1) = Shift Lower to Upper
24 | { "\001", 0, GVKEY_INVERT|GVKEY_LOCKSET, 2 }, // \002 (2) = Shift Upper to Upper Lock
25 | { "\002", 0, GVKEY_INVERT|GVKEY_LOCKSET, 0 }, // \003 (3) = Shift Upper Lock to Lower
26 | { "123", 0, GVKEY_LOCKSET, 3 }, // \004 (4) = Change to Numbers
27 | { "\010", "\b", 0, 0 }, // \005 (5) = Backspace
28 | { "\015", "\r", 0, 0 }, // \006 (6) = Enter 1
29 | { "\015", "\r", 0, 0 }, // \007 (7) = Enter 2 (Short keycap)
30 | { "Sym", 0, GVKEY_LOCKSET, 4 }, // \010 (8) = Change to Symbols
31 | { "aA", 0, GVKEY_LOCKSET, 0 }, // \011 (9) = Change to Lower Alpha
32 | };
33 | static const char Eng1Set0Row3[] = "\004 .\006\006";
34 | static const char Eng1Set1Row0[] = "QWERTYUIOP";
35 | static const char Eng1Set1Row1[] = "ASDFGHJKL";
36 | static const char *Eng1Set0[] = { "qwertyuiop", "asdfghjkl", "\001zxcvbnm\005", Eng1Set0Row3, 0 };
37 | static const char *Eng1Set1[] = { Eng1Set1Row0, Eng1Set1Row1, "\002ZXCVBNM\005", Eng1Set0Row3, 0 };
38 | static const char *Eng1Set2[] = { Eng1Set1Row0, Eng1Set1Row1, "\003ZXCVBNM\005", Eng1Set0Row3, 0 };
39 | static const char *Eng1Set3[] = { "+-*/", "@789", "\007456", "\010123", "\01100.", 0 };
40 | static const char *Eng1Set4[] = { "#$%^&*()", "~`:;\"'{}", "<>?/\\|[]", "\011\004,! .@", 0 };
41 | static const GVKeySet Eng1Sets[] = { Eng1Set0, Eng1Set1, Eng1Set2, Eng1Set3, Eng1Set4, 0 };
42 | const GVKeyTable VirtualKeyboard_English1 = { Eng1SKeys, Eng1Sets };
43 | #endif // GWIN_NEED_KEYBOARD_ENGLISH1
44 |
45 | #endif // GFX_USE_GWIN && GWIN_NEED_KEYBOARD
46 |
--------------------------------------------------------------------------------
/components/ugfx/src/gwin/gwin_mk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is subject to the terms of the GFX License. If a copy of
3 | * the license was not distributed with this file, you can obtain one at:
4 | *
5 | * http://ugfx.org/license.html
6 | */
7 |
8 | #include "gwin.c"
9 | #include "gwin_widget.c"
10 | #include "gwin_wm.c"
11 | #include "gwin_console.c"
12 | #include "gwin_graph.c"
13 | #include "gwin_button.c"
14 | #include "gwin_slider.c"
15 | #include "gwin_checkbox.c"
16 | #include "gwin_image.c"
17 | #include "gwin_label.c"
18 | #include "gwin_radio.c"
19 | #include "gwin_list.c"
20 | #include "gwin_progressbar.c"
21 | #include "gwin_container.c"
22 | #include "gwin_frame.c"
23 | #include "gwin_tabset.c"
24 | #include "gwin_gl3d.c"
25 | #include "gwin_keyboard.c"
26 | #include "gwin_keyboard_layout.c"
27 | #include "gwin_textedit.c"
28 |
--------------------------------------------------------------------------------
/docs/acode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/docs/acode.jpg
--------------------------------------------------------------------------------
/docs/cube0414.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/docs/cube0414.png
--------------------------------------------------------------------------------
/docs/st7735lin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/docs/st7735lin.png
--------------------------------------------------------------------------------
/docs/st7789band.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/docs/st7789band.png
--------------------------------------------------------------------------------
/docs/st7789log.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/docs/st7789log.png
--------------------------------------------------------------------------------
/docs/st7789vu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/docs/st7789vu.png
--------------------------------------------------------------------------------
/docs/ws2812.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/docs/ws2812.png
--------------------------------------------------------------------------------
/main/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(COMPONENT_SRCDIRS src src/user src/board src/chip src/core)
2 | set(COMPONENT_ADD_INCLUDEDIRS inc)
3 | set(COMPONENT_EMBED_FILES res/snd/snd0.mp3 res/snd/snd1.mp3 res/snd/snd2.mp3 res/snd/snd3.mp3)
4 |
5 | register_component()
6 |
--------------------------------------------------------------------------------
/main/inc/board/cube0414.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cube0414.h
3 | *
4 | * Created on: 2018-05-10 17:01
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_BOARD_CUBE0414_H_
9 | #define INC_BOARD_CUBE0414_H_
10 |
11 | #include
12 |
13 | #include "chip/spi.h"
14 |
15 | #define CUBE0414_X 8
16 | #define CUBE0414_Y 8
17 | #define CUBE0414_Z 8
18 |
19 | extern void cube0414_init_board(void);
20 |
21 | extern void cube0414_setpin_dc(spi_transaction_t *);
22 | extern void cube0414_setpin_reset(uint8_t val);
23 |
24 | extern void cube0414_write_cmd(uint8_t cmd);
25 | extern void cube0414_write_data(uint8_t data);
26 | extern void cube0414_write_buff(uint8_t *buff, uint32_t n);
27 | extern void cube0414_read_buff(uint8_t *buff, uint32_t n);
28 | extern void cube0414_refresh_gram(uint8_t *gram);
29 |
30 | #endif /* INC_BOARD_CUBE0414_H_ */
31 |
--------------------------------------------------------------------------------
/main/inc/board/st7735.h:
--------------------------------------------------------------------------------
1 | /*
2 | * st7735.h
3 | *
4 | * Created on: 2018-03-16 16:15
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_BOARD_ST7735_H_
9 | #define INC_BOARD_ST7735_H_
10 |
11 | #include
12 |
13 | #include "chip/spi.h"
14 |
15 | #define ST7735_SCREEN_WIDTH 80
16 | #define ST7735_SCREEN_HEIGHT 160
17 |
18 | extern void st7735_init_board(void);
19 |
20 | extern void st7735_set_backlight(uint8_t val);
21 | extern void st7735_setpin_dc(spi_transaction_t *);
22 | extern void st7735_setpin_reset(uint8_t val);
23 |
24 | extern void st7735_write_cmd(uint8_t cmd);
25 | extern void st7735_write_data(uint8_t data);
26 | extern void st7735_write_buff(uint8_t *buff, uint32_t n);
27 | extern void st7735_refresh_gram(uint8_t *gram);
28 |
29 | #endif /* INC_BOARD_ST7735_H_ */
30 |
--------------------------------------------------------------------------------
/main/inc/board/st7789.h:
--------------------------------------------------------------------------------
1 | /*
2 | * st7789.h
3 | *
4 | * Created on: 2018-03-16 12:30
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_BOARD_ST7789_H_
9 | #define INC_BOARD_ST7789_H_
10 |
11 | #include
12 |
13 | #include "chip/spi.h"
14 |
15 | #define ST7789_SCREEN_WIDTH 135
16 | #define ST7789_SCREEN_HEIGHT 240
17 |
18 | extern void st7789_init_board(void);
19 |
20 | extern void st7789_set_backlight(uint8_t val);
21 | extern void st7789_setpin_dc(spi_transaction_t *);
22 | extern void st7789_setpin_reset(uint8_t val);
23 |
24 | extern void st7789_write_cmd(uint8_t cmd);
25 | extern void st7789_write_data(uint8_t data);
26 | extern void st7789_write_buff(uint8_t *buff, uint32_t n);
27 | extern void st7789_refresh_gram(uint8_t *gram);
28 |
29 | #endif /* INC_BOARD_ST7789_H_ */
30 |
--------------------------------------------------------------------------------
/main/inc/board/ws2812.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ws2812.h
3 | *
4 | * Created on: 2020-06-25 22:01
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_BOARD_WS2812_H_
9 | #define INC_BOARD_WS2812_H_
10 |
11 | #include
12 |
13 | #define WS2812_X 8
14 | #define WS2812_Y 8
15 | #define WS2812_Z CONFIG_LED_PANEL_CASCADE
16 |
17 | extern void ws2812_init_board(void);
18 |
19 | extern void ws2812_refresh_gram(uint8_t *gram);
20 |
21 | #endif /* INC_BOARD_WS2812_H_ */
22 |
--------------------------------------------------------------------------------
/main/inc/chip/bt.h:
--------------------------------------------------------------------------------
1 | /*
2 | * bt.h
3 | *
4 | * Created on: 2018-03-09 10:36
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_CHIP_BT_H_
9 | #define INC_CHIP_BT_H_
10 |
11 | #include
12 |
13 | extern char *bt_get_mac_string(void);
14 | extern char *ble_get_mac_string(void);
15 |
16 | extern uint8_t *bt_get_mac_address(void);
17 | extern uint8_t *ble_get_mac_address(void);
18 |
19 | extern void bt_init(void);
20 |
21 | #endif /* INC_CHIP_BT_H_ */
22 |
--------------------------------------------------------------------------------
/main/inc/chip/i2s.h:
--------------------------------------------------------------------------------
1 | /*
2 | * i2s.h
3 | *
4 | * Created on: 2018-02-10 16:37
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_CHIP_I2S_H_
9 | #define INC_CHIP_I2S_H_
10 |
11 | #include "driver/i2s.h"
12 |
13 | extern void i2s_output_init(void);
14 | extern void i2s_output_deinit(void);
15 |
16 | extern void i2s_output_set_sample_rate(unsigned int sample_rate);
17 |
18 | extern void i2s_input_init(void);
19 | extern void i2s_input_deinit(void);
20 |
21 | #endif /* INC_CHIP_I2S_H_ */
22 |
--------------------------------------------------------------------------------
/main/inc/chip/nvs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * nvs.h
3 | *
4 | * Created on: 2018-03-30 16:45
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_CHIP_NVS_H_
9 | #define INC_CHIP_NVS_H_
10 |
11 | extern void nvs_init(void);
12 |
13 | #endif /* INC_CHIP_NVS_H_ */
14 |
--------------------------------------------------------------------------------
/main/inc/chip/spi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * spi.h
3 | *
4 | * Created on: 2018-02-10 16:37
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_CHIP_SPI_H_
9 | #define INC_CHIP_SPI_H_
10 |
11 | #include "driver/spi_master.h"
12 |
13 | #define SPI_HOST_TAG "spi-2"
14 | #define SPI_HOST_NUM SPI2_HOST
15 |
16 | extern spi_device_handle_t spi_host;
17 |
18 | extern void spi_host_init(void);
19 |
20 | #endif /* INC_CHIP_SPI_H_ */
21 |
--------------------------------------------------------------------------------
/main/inc/core/app.h:
--------------------------------------------------------------------------------
1 | /*
2 | * app.h
3 | *
4 | * Created on: 2018-04-05 19:09
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_CORE_APP_H_
9 | #define INC_CORE_APP_H_
10 |
11 | #include "esp_err.h"
12 |
13 | extern const char *app_get_version(void);
14 | extern void app_print_info(void);
15 |
16 | extern esp_err_t app_getenv(const char *key, void *out_value, size_t *length);
17 | extern esp_err_t app_setenv(const char *key, const void *value, size_t length);
18 |
19 | #endif /* INC_CORE_APP_H_ */
20 |
--------------------------------------------------------------------------------
/main/inc/core/os.h:
--------------------------------------------------------------------------------
1 | /*
2 | * os.h
3 | *
4 | * Created on: 2018-03-04 20:07
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_CORE_OS_H_
9 | #define INC_CORE_OS_H_
10 |
11 | #include "freertos/FreeRTOS.h"
12 | #include "freertos/event_groups.h"
13 |
14 | typedef enum user_event_group_bits {
15 | OS_PWR_DUMMY_BIT = 0x00,
16 | OS_PWR_RESET_BIT = BIT0,
17 | OS_PWR_SLEEP_BIT = BIT1,
18 |
19 | BT_A2DP_IDLE_BIT = BIT2,
20 |
21 | VFX_RLD_MODE_BIT = BIT3,
22 | VFX_FFT_IDLE_BIT = BIT4,
23 | VFX_FFT_MODE_BIT = BIT5,
24 |
25 | KEY_SCAN_RUN_BIT = BIT6,
26 | KEY_SCAN_CLR_BIT = BIT7,
27 |
28 | BLE_GATTS_IDLE_BIT = BIT8,
29 | BLE_GATTS_LOCK_BIT = BIT9,
30 |
31 | AUDIO_INPUT_RUN_BIT = BIT10,
32 |
33 | AUDIO_PLAYER_RUN_BIT = BIT11,
34 | AUDIO_PLAYER_IDLE_BIT = BIT12
35 | } user_event_group_bits_t;
36 |
37 | extern EventGroupHandle_t user_event_group;
38 |
39 | extern void os_pwr_reset_wait(EventBits_t bits);
40 | extern void os_pwr_sleep_wait(EventBits_t bits);
41 |
42 | extern void os_init(void);
43 |
44 | #endif /* INC_CORE_OS_H_ */
45 |
--------------------------------------------------------------------------------
/main/inc/user/ain.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ain.h
3 | *
4 | * Created on: 2019-07-05 21:22
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_AUDIO_INPUT_H_
9 | #define INC_USER_AUDIO_INPUT_H_
10 |
11 | typedef enum {
12 | AIN_MODE_IDX_OFF = 0x00,
13 | AIN_MODE_IDX_ON = 0x01
14 | } ain_mode_t;
15 |
16 | #define DEFAULT_AIN_MODE AIN_MODE_IDX_OFF
17 |
18 | extern void ain_set_mode(ain_mode_t idx);
19 | extern ain_mode_t ain_get_mode(void);
20 |
21 | extern void ain_init(void);
22 |
23 | #endif /* INC_USER_AUDIO_INPUT_H_ */
24 |
--------------------------------------------------------------------------------
/main/inc/user/audio_player.h:
--------------------------------------------------------------------------------
1 | /*
2 | * audio_player.h
3 | *
4 | * Created on: 2018-02-12 20:13
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_AUDIO_PLAYER_H_
9 | #define INC_USER_AUDIO_PLAYER_H_
10 |
11 | typedef enum {
12 | MP3_FILE_IDX_CONNECTED = 0x00,
13 | MP3_FILE_IDX_DISCONNECTED = 0x01,
14 | MP3_FILE_IDX_SLEEP = 0x02,
15 | MP3_FILE_IDX_WAKEUP = 0x03,
16 |
17 | MP3_FILE_IDX_MAX
18 | } mp3_file_t;
19 |
20 | // snd0.mp3
21 | extern const char snd0_mp3_ptr[] asm("_binary_snd0_mp3_start");
22 | extern const char snd0_mp3_end[] asm("_binary_snd0_mp3_end");
23 | // snd1.mp3
24 | extern const char snd1_mp3_ptr[] asm("_binary_snd1_mp3_start");
25 | extern const char snd1_mp3_end[] asm("_binary_snd1_mp3_end");
26 | // snd2.mp3
27 | extern const char snd2_mp3_ptr[] asm("_binary_snd2_mp3_start");
28 | extern const char snd2_mp3_end[] asm("_binary_snd2_mp3_end");
29 | // snd3.mp3
30 | extern const char snd3_mp3_ptr[] asm("_binary_snd3_mp3_start");
31 | extern const char snd3_mp3_end[] asm("_binary_snd3_mp3_end");
32 |
33 | extern void audio_player_play_file(mp3_file_t idx);
34 |
35 | extern void audio_player_init(void);
36 |
37 | #endif /* INC_USER_AUDIO_PLAYER_H_ */
38 |
--------------------------------------------------------------------------------
/main/inc/user/audio_render.h:
--------------------------------------------------------------------------------
1 | /*
2 | * audio_render.h
3 | *
4 | * Created on: 2018-04-05 16:41
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_AUDIO_RENDER_H_
9 | #define INC_USER_AUDIO_RENDER_H_
10 |
11 | #include "freertos/FreeRTOS.h"
12 | #include "freertos/ringbuf.h"
13 |
14 | extern RingbufHandle_t audio_buff;
15 |
16 | extern void audio_render_init(void);
17 |
18 | #endif /* INC_USER_AUDIO_RENDER_H_ */
19 |
--------------------------------------------------------------------------------
/main/inc/user/ble_app.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ble_app.h
3 | *
4 | * Created on: 2019-07-04 22:50
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_BLE_APP_H_
9 | #define INC_USER_BLE_APP_H_
10 |
11 | extern void *ble_app_get_adv_params(void);
12 | extern void ble_app_config_adv_data(void);
13 |
14 | extern void ble_app_init(void);
15 |
16 | #endif /* INC_USER_BLE_APP_H_ */
17 |
--------------------------------------------------------------------------------
/main/inc/user/ble_gatts.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ble_gatts.h
3 | *
4 | * Created on: 2018-05-12 22:31
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_BLE_GATTS_H_
9 | #define INC_USER_BLE_GATTS_H_
10 |
11 | #include "esp_gatts_api.h"
12 |
13 | enum gatts_profile_idx {
14 | PROFILE_IDX_OTA = 0x00,
15 | PROFILE_IDX_CFG = 0x01,
16 |
17 | PROFILE_IDX_MAX
18 | };
19 |
20 | typedef struct gatts_profile_inst {
21 | esp_gatts_cb_t gatts_cb;
22 | uint16_t gatts_if;
23 | uint16_t app_id;
24 | uint16_t conn_id;
25 | uint16_t service_handle;
26 | esp_gatt_srvc_id_t service_id;
27 | uint16_t char_handle;
28 | esp_bt_uuid_t char_uuid;
29 | esp_gatt_perm_t perm;
30 | esp_gatt_char_prop_t property;
31 | uint16_t descr_handle;
32 | esp_bt_uuid_t descr_uuid;
33 | } gatts_profile_inst_t;
34 |
35 | extern gatts_profile_inst_t gatts_profile_tbl[PROFILE_IDX_MAX];
36 |
37 | extern void ble_gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
38 |
39 | #endif /* INC_USER_BLE_GATTS_H_ */
40 |
--------------------------------------------------------------------------------
/main/inc/user/bt_app.h:
--------------------------------------------------------------------------------
1 | /*
2 | * bt_app.h
3 | *
4 | * Created on: 2018-03-09 13:57
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_BT_APP_H_
9 | #define INC_USER_BT_APP_H_
10 |
11 | extern void bt_app_init(void);
12 |
13 | #endif /* INC_USER_BT_APP_H_ */
14 |
--------------------------------------------------------------------------------
/main/inc/user/bt_av.h:
--------------------------------------------------------------------------------
1 | /*
2 | * bt_av.h
3 | *
4 | * Created on: 2019-04-29 12:31
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_BT_AV_H_
9 | #define INC_USER_BT_AV_H_
10 |
11 | #include
12 |
13 | #include "esp_a2dp_api.h"
14 | #include "esp_avrc_api.h"
15 |
16 | extern esp_bd_addr_t a2d_remote_bda;
17 | extern unsigned int a2d_sample_rate;
18 |
19 | extern void bt_a2d_data_handler(const uint8_t *data, uint32_t len);
20 | extern void bt_a2d_event_handler(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param);
21 | extern void bt_avrc_ct_event_handler(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param);
22 | extern void bt_avrc_tg_event_handler(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t *param);
23 |
24 | #endif /* INC_USER_BT_AV_H_*/
25 |
--------------------------------------------------------------------------------
/main/inc/user/fft.h:
--------------------------------------------------------------------------------
1 | /*
2 | * fft.h
3 | *
4 | * Created on: 2021-01-14 17:00
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_FFT_H_
9 | #define INC_USER_FFT_H_
10 |
11 | #include
12 |
13 | #define TWO_PI (6.2831853f)
14 |
15 | #define FFT_N (256)
16 | #define FFT_BLOCK_SIZE (FFT_N * 8)
17 |
18 | #define MIN(a, b) ((a) < (b) ? (a) : (b))
19 | #define MAX(a, b) ((a) > (b) ? (a) : (b))
20 |
21 | typedef enum {
22 | FFT_CHANNEL_L = 0x00,
23 | FFT_CHANNEL_R = 0x01,
24 | FFT_CHANNEL_LR = 0x02
25 | } fft_channel_t;
26 |
27 | extern void fft_compute_lin(uint16_t *data_out, uint16_t num, uint16_t step, uint16_t max_val, uint16_t min_val);
28 | extern void fft_compute_log(uint16_t *data_out, uint16_t num, uint16_t step, uint16_t max_val, uint16_t min_val);
29 |
30 | extern void fft_compute_bands(uint16_t *data_out, const float *xscale, uint16_t bands, uint16_t *delay, uint16_t max_val, uint16_t min_val);
31 | extern void fft_compute_xscale(float *xscale, uint16_t bands);
32 |
33 | extern void fft_execute(float scale_factor);
34 | extern void fft_load_data(const uint8_t *data_in, fft_channel_t channel);
35 |
36 | extern void fft_init(void);
37 |
38 | #endif /* INC_USER_FFT_H_ */
39 |
--------------------------------------------------------------------------------
/main/inc/user/key.h:
--------------------------------------------------------------------------------
1 | /*
2 | * key.h
3 | *
4 | * Created on: 2018-05-31 14:07
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_KEY_H_
9 | #define INC_USER_KEY_H_
10 |
11 | typedef enum {
12 | KEY_SCAN_MODE_IDX_OFF = 0x00,
13 | KEY_SCAN_MODE_IDX_ON = 0x01
14 | } key_scan_mode_t;
15 |
16 | extern void key_set_scan_mode(key_scan_mode_t idx);
17 | extern key_scan_mode_t key_get_scan_mode(void);
18 |
19 | extern void key_init(void);
20 |
21 | #endif /* INC_USER_KEY_H_ */
22 |
--------------------------------------------------------------------------------
/main/inc/user/key_handle.h:
--------------------------------------------------------------------------------
1 | /*
2 | * key_handle.h
3 | *
4 | * Created on: 2019-07-06 10:35
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_KEY_HANDLE_H_
9 | #define INC_USER_KEY_HANDLE_H_
10 |
11 | extern void sleep_key_handle(void);
12 |
13 | #endif /* INC_USER_KEY_HANDLE_H_ */
14 |
--------------------------------------------------------------------------------
/main/inc/user/led.h:
--------------------------------------------------------------------------------
1 | /*
2 | * led.h
3 | *
4 | * Created on: 2018-02-13 15:43
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_LED_H_
9 | #define INC_USER_LED_H_
10 |
11 | typedef enum {
12 | LED_MODE_IDX_BLINK_S1 = 0x00,
13 | LED_MODE_IDX_BLINK_S0 = 0x01,
14 | LED_MODE_IDX_BLINK_M1 = 0x02,
15 | LED_MODE_IDX_BLINK_M0 = 0x03,
16 | LED_MODE_IDX_BLINK_F1 = 0x04,
17 | LED_MODE_IDX_BLINK_F0 = 0x05,
18 | LED_MODE_IDX_PULSE_D0 = 0x06,
19 | LED_MODE_IDX_PULSE_D1 = 0x07,
20 | LED_MODE_IDX_PULSE_D2 = 0x08,
21 | LED_MODE_IDX_PULSE_D3 = 0x09
22 | } led_mode_t;
23 |
24 | extern void led_set_mode(led_mode_t idx);
25 | extern led_mode_t led_get_mode(void);
26 |
27 | extern void led_init(void);
28 |
29 | #endif /* INC_USER_LED_H_ */
30 |
--------------------------------------------------------------------------------
/main/inc/user/ota.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ota.h
3 | *
4 | * Created on: 2020-02-12 15:48
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_OTA_H_
9 | #define INC_USER_OTA_H_
10 |
11 | #include
12 |
13 | extern void ota_exec(const char *data, uint32_t len);
14 | extern void ota_end(void);
15 |
16 | #endif /* INC_USER_OTA_H_ */
17 |
--------------------------------------------------------------------------------
/main/inc/user/vfx.h:
--------------------------------------------------------------------------------
1 | /*
2 | * vfx.h
3 | *
4 | * Created on: 2018-02-13 22:57
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_VFX_H_
9 | #define INC_USER_VFX_H_
10 |
11 | #include
12 |
13 | #include "gfx.h"
14 |
15 | typedef enum {
16 | #if defined(CONFIG_VFX_OUTPUT_ST7735) || defined(CONFIG_VFX_OUTPUT_ST7789)
17 | VFX_MODE_IDX_12_BAND_R = 0x0A,
18 | VFX_MODE_IDX_12_BAND_G = 0x0B,
19 | VFX_MODE_IDX_SPECTRUM_R_N = 0x0C,
20 | VFX_MODE_IDX_SPECTRUM_G_N = 0x0D,
21 | VFX_MODE_IDX_SPECTRUM_M_N = 0x0E,
22 | VFX_MODE_IDX_SPECTRUM_R_L = 0x0F,
23 | VFX_MODE_IDX_SPECTRUM_G_L = 0x10,
24 | VFX_MODE_IDX_SPECTRUM_M_L = 0x11,
25 | #else
26 | VFX_MODE_IDX_RANDOM = 0x00,
27 | VFX_MODE_IDX_RAINBOW = 0x01,
28 | VFX_MODE_IDX_RIBBON = 0x02,
29 | VFX_MODE_IDX_GRADUAL = 0x03,
30 | VFX_MODE_IDX_BREATHING = 0x04,
31 | VFX_MODE_IDX_STARSKY_R = 0x05,
32 | VFX_MODE_IDX_STARSKY_G = 0x06,
33 | VFX_MODE_IDX_STARSKY_B = 0x07,
34 | VFX_MODE_IDX_NUMBERS_S = 0x08,
35 | VFX_MODE_IDX_NUMBERS_D = 0x09,
36 | VFX_MODE_IDX_MAGIC_CARPET = 0x0A,
37 | VFX_MODE_IDX_ROTATING_F = 0x0B,
38 | VFX_MODE_IDX_ROTATING_B = 0x0C,
39 | VFX_MODE_IDX_FOUNTAIN_S_N = 0x0D,
40 | VFX_MODE_IDX_FOUNTAIN_G_N = 0x0E,
41 | VFX_MODE_IDX_FOUNTAIN_H_N = 0x0F,
42 | VFX_MODE_IDX_FOUNTAIN_S_L = 0x10,
43 | VFX_MODE_IDX_FOUNTAIN_G_L = 0x11,
44 | VFX_MODE_IDX_FOUNTAIN_H_L = 0x12,
45 | #endif
46 |
47 | VFX_MODE_IDX_MAX,
48 |
49 | VFX_MODE_IDX_PAUSE = 0xFE,
50 | VFX_MODE_IDX_OFF = 0xFF
51 | } vfx_mode_t;
52 |
53 | typedef struct {
54 | vfx_mode_t mode;
55 | uint16_t scale_factor;
56 | uint16_t lightness;
57 | uint8_t backlight;
58 | } vfx_config_t;
59 |
60 | #if defined(CONFIG_VFX_OUTPUT_ST7735) || defined(CONFIG_VFX_OUTPUT_ST7789)
61 | #define DEFAULT_VFX_MODE VFX_MODE_IDX_12_BAND_G
62 | #define DEFAULT_VFX_SCALE_FACTOR 0x00FF
63 | #define DEFAULT_VFX_LIGHTNESS 0x00FF
64 | #define DEFAULT_VFX_BACKLIGHT 0xFF
65 | #else
66 | #define DEFAULT_VFX_MODE VFX_MODE_IDX_FOUNTAIN_H_L
67 | #define DEFAULT_VFX_SCALE_FACTOR 0x00FF
68 | #define DEFAULT_VFX_LIGHTNESS 0x006F
69 | #define DEFAULT_VFX_BACKLIGHT 0x00
70 | #endif
71 |
72 | extern GDisplay *vfx_gdisp;
73 |
74 | extern void vfx_set_conf(vfx_config_t *cfg);
75 | extern vfx_config_t *vfx_get_conf(void);
76 |
77 | extern void vfx_init(void);
78 |
79 | #endif /* INC_USER_VFX_H_ */
80 |
--------------------------------------------------------------------------------
/main/inc/user/vfx_bitmap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * vfx_bitmap.h
3 | *
4 | * Created on: 2018-05-13 20:29
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_VFX_BITMAP_H_
9 | #define INC_USER_VFX_BITMAP_H_
10 |
11 | extern const unsigned char vfx_bitmap_number[][8];
12 | extern const unsigned char vfx_bitmap_wave[][64];
13 | extern const unsigned char vfx_bitmap_line[][8];
14 |
15 | #endif /* INC_USER_VFX_BITMAP_H_ */
16 |
--------------------------------------------------------------------------------
/main/inc/user/vfx_core.h:
--------------------------------------------------------------------------------
1 | /*
2 | * vfx_core.h
3 | *
4 | * Created on: 2019-07-03 20:05
5 | * Author: Jack Chen
6 | */
7 |
8 | #ifndef INC_USER_VFX_CORE_H_
9 | #define INC_USER_VFX_CORE_H_
10 |
11 | #include
12 |
13 | extern uint32_t hsl2rgb(float H, float S, float L);
14 |
15 | extern void vfx_draw_pixel_raw(uint8_t x, uint8_t y, uint8_t z, uint32_t color);
16 | extern void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, float color_h, float color_l);
17 |
18 | extern void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint8_t cz, float color_h, float color_l);
19 | extern void vfx_draw_cube_bitmap(const uint8_t *bitmap, float color_l);
20 | extern void vfx_draw_layer_bitmap(uint8_t layer, const uint8_t *bitmap, float color_l);
21 | extern void vfx_draw_layer_number(uint8_t num, uint8_t layer, float color_h, float color_l);
22 |
23 | #endif /* INC_USER_VFX_CORE_H_ */
24 |
--------------------------------------------------------------------------------
/main/res/snd/snd0.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/main/res/snd/snd0.mp3
--------------------------------------------------------------------------------
/main/res/snd/snd1.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/main/res/snd/snd1.mp3
--------------------------------------------------------------------------------
/main/res/snd/snd2.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/main/res/snd/snd2.mp3
--------------------------------------------------------------------------------
/main/res/snd/snd3.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redchenjs/bluetooth_visual_speaker_esp32/876b6b9335f91ad171ae7398c926d492a74b0624/main/res/snd/snd3.mp3
--------------------------------------------------------------------------------
/main/src/app_main.c:
--------------------------------------------------------------------------------
1 | /*
2 | * app_main.c
3 | *
4 | * Created on: 2018-03-11 15:57
5 | * Author: Jack Chen
6 | */
7 |
8 | #include "core/os.h"
9 | #include "core/app.h"
10 |
11 | #include "chip/bt.h"
12 | #include "chip/nvs.h"
13 | #include "chip/spi.h"
14 | #include "chip/i2s.h"
15 |
16 | #include "user/led.h"
17 | #include "user/vfx.h"
18 | #include "user/key.h"
19 | #include "user/ain.h"
20 | #include "user/bt_app.h"
21 | #include "user/ble_app.h"
22 | #include "user/audio_player.h"
23 | #include "user/audio_render.h"
24 |
25 | static void core_init(void)
26 | {
27 | app_print_info();
28 |
29 | os_init();
30 | }
31 |
32 | static void chip_init(void)
33 | {
34 | nvs_init();
35 |
36 | bt_init();
37 |
38 | i2s_output_init();
39 |
40 | #ifndef CONFIG_AUDIO_INPUT_NONE
41 | i2s_input_init();
42 | #endif
43 |
44 | #if defined(CONFIG_ENABLE_VFX) && !defined(CONFIG_VFX_OUTPUT_WS2812)
45 | spi_host_init();
46 | #endif
47 | }
48 |
49 | static void board_init(void) {}
50 |
51 | static void user_init(void)
52 | {
53 | bt_app_init();
54 |
55 | #ifdef CONFIG_ENABLE_BLE_CONTROL_IF
56 | ble_app_init();
57 | #endif
58 |
59 | #ifdef CONFIG_ENABLE_LED
60 | led_init();
61 | #endif
62 |
63 | #ifdef CONFIG_ENABLE_VFX
64 | vfx_init();
65 | #endif
66 |
67 | #ifdef CONFIG_ENABLE_SLEEP_KEY
68 | key_init();
69 | #endif
70 |
71 | #ifndef CONFIG_AUDIO_INPUT_NONE
72 | ain_init();
73 | #endif
74 |
75 | #ifdef CONFIG_ENABLE_AUDIO_PROMPT
76 | audio_player_init();
77 | #endif
78 |
79 | audio_render_init();
80 | }
81 |
82 | int app_main(void)
83 | {
84 | core_init();
85 |
86 | chip_init();
87 |
88 | board_init();
89 |
90 | user_init();
91 |
92 | return 0;
93 | }
94 |
--------------------------------------------------------------------------------
/main/src/board/ws2812.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ws2812.c
3 | *
4 | * Created on: 2020-06-25 22:01
5 | * Author: Jack Chen
6 | */
7 |
8 | #include
9 |
10 | #include "esp_log.h"
11 |
12 | #include "driver/rmt.h"
13 | #include "board/ws2812.h"
14 |
15 | #ifdef CONFIG_VFX_OUTPUT_WS2812
16 |
17 | #define TAG "ws2812"
18 |
19 | static rmt_item32_t bit0 = {{{ 0, 1, 0, 0 }}};
20 | static rmt_item32_t bit1 = {{{ 0, 1, 0, 0 }}};
21 |
22 | static void ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, size_t src_size, size_t wanted_num, size_t *translated_size, size_t *item_num)
23 | {
24 | while (*translated_size < src_size && *item_num < wanted_num) {
25 | uint8_t temp = ((uint8_t *)src)[(*translated_size)++];
26 |
27 | for (int i = 0; i < 8; i++) {
28 | if (temp & 0x80) {
29 | (dest++)->val = bit1.val;
30 | } else {
31 | (dest++)->val = bit0.val;
32 | }
33 |
34 | temp <<= 1;
35 | }
36 |
37 | *item_num += 8;
38 | }
39 | }
40 |
41 | void ws2812_init_board(void)
42 | {
43 | uint32_t clock_hz = 0;
44 |
45 | rmt_config_t rmt_conf = RMT_DEFAULT_CONFIG_TX(CONFIG_WS2812_DIN0_PIN, RMT_CHANNEL_0);
46 | rmt_conf.mem_block_num = 3;
47 | rmt_conf.clk_div = 2;
48 |
49 | rmt_config(&rmt_conf);
50 | rmt_driver_install(RMT_CHANNEL_0, 0, 0);
51 |
52 | rmt_get_counter_clock(RMT_CHANNEL_0, &clock_hz);
53 | bit0.duration0 = clock_hz * CONFIG_LED_T0H_TIME / 1e8;
54 | bit0.duration1 = clock_hz * CONFIG_LED_T0L_TIME / 1e8;
55 | bit1.duration0 = clock_hz * CONFIG_LED_T1H_TIME / 1e8;
56 | bit1.duration1 = clock_hz * CONFIG_LED_T1L_TIME / 1e8;
57 |
58 | rmt_translator_init(RMT_CHANNEL_0, ws2812_rmt_adapter);
59 |
60 | #ifndef CONFIG_WS2812_DIN1_PIN
61 | ESP_LOGI(TAG, "initialized, din0: %d", CONFIG_WS2812_DIN0_PIN);
62 | #else
63 | rmt_conf.channel = RMT_CHANNEL_4;
64 | rmt_conf.gpio_num = CONFIG_WS2812_DIN1_PIN;
65 |
66 | rmt_config(&rmt_conf);
67 | rmt_driver_install(RMT_CHANNEL_4, 0, 0);
68 |
69 | rmt_translator_init(RMT_CHANNEL_4, ws2812_rmt_adapter);
70 |
71 | ESP_LOGI(TAG, "initialized, din0: %d, din1: %d", CONFIG_WS2812_DIN0_PIN, CONFIG_WS2812_DIN1_PIN);
72 | #endif
73 | }
74 |
75 | void ws2812_refresh_gram(uint8_t *gram)
76 | {
77 | #ifndef CONFIG_WS2812_DIN1_PIN
78 | rmt_write_sample(RMT_CHANNEL_0, gram, WS2812_X * WS2812_Y * WS2812_Z * 3, true);
79 | #else
80 | rmt_write_sample(RMT_CHANNEL_0, gram, WS2812_X * WS2812_Y * 4 * 3, false);
81 | rmt_write_sample(RMT_CHANNEL_4, gram + WS2812_X * WS2812_Y * 4 * 3, WS2812_X * WS2812_Y * (WS2812_Z - 4) * 3, true);
82 |
83 | rmt_wait_tx_done(RMT_CHANNEL_0, portMAX_DELAY);
84 | #endif
85 | }
86 | #endif
87 |
--------------------------------------------------------------------------------
/main/src/chip/bt.c:
--------------------------------------------------------------------------------
1 | /*
2 | * bt.c
3 | *
4 | * Created on: 2018-03-09 10:36
5 | * Author: Jack Chen
6 | */
7 |
8 | #include
9 |
10 | #include "esp_bt.h"
11 | #include "esp_log.h"
12 | #include "esp_bt_main.h"
13 | #include "esp_bt_device.h"
14 |
15 | #define TAG "bt"
16 |
17 | static char bt_mac_string[18] = {0};
18 | static char ble_mac_string[18] = {0};
19 |
20 | static uint8_t bt_mac_address[6] = {0};
21 | static uint8_t ble_mac_address[6] = {0};
22 |
23 | char *bt_get_mac_string(void)
24 | {
25 | return bt_mac_string;
26 | }
27 |
28 | char *ble_get_mac_string(void)
29 | {
30 | return ble_mac_string;
31 | }
32 |
33 | uint8_t *bt_get_mac_address(void)
34 | {
35 | return bt_mac_address;
36 | }
37 |
38 | uint8_t *ble_get_mac_address(void)
39 | {
40 | return ble_mac_address;
41 | }
42 |
43 | void bt_init(void)
44 | {
45 | #ifndef CONFIG_ENABLE_BLE_CONTROL_IF
46 | ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE));
47 | #endif
48 |
49 | esp_bt_controller_config_t btc_conf = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
50 | ESP_ERROR_CHECK(esp_bt_controller_init(&btc_conf));
51 | ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BTDM));
52 | ESP_ERROR_CHECK(esp_bluedroid_init());
53 | ESP_ERROR_CHECK(esp_bluedroid_enable());
54 |
55 | memcpy(bt_mac_address, esp_bt_dev_get_address(), sizeof(bt_mac_address));
56 | memcpy(ble_mac_address, esp_bt_dev_get_address(), sizeof(ble_mac_address));
57 |
58 | ble_mac_address[0] |= 0xC0;
59 |
60 | snprintf(bt_mac_string, sizeof(bt_mac_string), MACSTR, MAC2STR(bt_mac_address));
61 | snprintf(ble_mac_string, sizeof(ble_mac_string), MACSTR, MAC2STR(ble_mac_address));
62 |
63 | ESP_LOGI(TAG, "initialized, bt: 1, ble: %d",
64 | #ifdef CONFIG_ENABLE_BLE_CONTROL_IF
65 | 1
66 | #else
67 | 0
68 | #endif
69 | );
70 | }
71 |
--------------------------------------------------------------------------------
/main/src/chip/nvs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * nvs.c
3 | *
4 | * Created on: 2018-03-30 16:45
5 | * Author: Jack Chen
6 | */
7 |
8 | #include "esp_log.h"
9 |
10 | #include "nvs_flash.h"
11 |
12 | #define TAG "nvs"
13 |
14 | void nvs_init(void)
15 | {
16 | esp_err_t ret = nvs_flash_init();
17 | if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
18 | ESP_ERROR_CHECK(nvs_flash_erase());
19 | ret = nvs_flash_init();
20 | }
21 | ESP_ERROR_CHECK(ret);
22 |
23 | ESP_LOGI(TAG, "initialized.");
24 | }
25 |
--------------------------------------------------------------------------------
/main/src/chip/spi.c:
--------------------------------------------------------------------------------
1 | /*
2 | * spi.c
3 | *
4 | * Created on: 2018-02-10 16:38
5 | * Author: Jack Chen
6 | */
7 |
8 | #include "esp_log.h"
9 |
10 | #include "chip/spi.h"
11 |
12 | #include "board/st7735.h"
13 | #include "board/st7789.h"
14 | #include "board/cube0414.h"
15 |
16 | #if defined(CONFIG_ENABLE_VFX) && !defined(CONFIG_VFX_OUTPUT_WS2812)
17 | spi_device_handle_t spi_host;
18 |
19 | void spi_host_init(void)
20 | {
21 | spi_bus_config_t bus_conf = {
22 | #ifdef CONFIG_CUBE0414_RTL_REV_4
23 | .miso_io_num = CONFIG_SPI_MISO_PIN,
24 | #else
25 | .miso_io_num = -1,
26 | #endif
27 | .mosi_io_num = CONFIG_SPI_MOSI_PIN,
28 | .sclk_io_num = CONFIG_SPI_SCLK_PIN,
29 | .quadwp_io_num = -1,
30 | .quadhd_io_num = -1,
31 | #ifdef CONFIG_VFX_OUTPUT_ST7735
32 | .max_transfer_sz = ST7735_SCREEN_WIDTH * ST7735_SCREEN_HEIGHT * 2
33 | #elif defined(CONFIG_VFX_OUTPUT_ST7789)
34 | .max_transfer_sz = ST7789_SCREEN_WIDTH * ST7789_SCREEN_HEIGHT * 2
35 | #else
36 | .max_transfer_sz = CUBE0414_X * CUBE0414_Y * CUBE0414_Z * 3
37 | #endif
38 | };
39 | ESP_ERROR_CHECK(spi_bus_initialize(SPI_HOST_NUM, &bus_conf, 1));
40 |
41 | spi_device_interface_config_t dev_conf = {
42 | .mode = 0,
43 | .spics_io_num = CONFIG_SPI_CS_PIN,
44 | #ifdef CONFIG_VFX_OUTPUT_ST7735
45 | .clock_speed_hz = SPI_MASTER_FREQ_26M,
46 | .pre_cb = st7735_setpin_dc,
47 | #elif defined(CONFIG_VFX_OUTPUT_ST7789)
48 | .clock_speed_hz = SPI_MASTER_FREQ_40M,
49 | .pre_cb = st7789_setpin_dc,
50 | #else
51 | .clock_speed_hz = SPI_MASTER_FREQ_8M,
52 | .pre_cb = cube0414_setpin_dc,
53 | #endif
54 | .queue_size = 2,
55 | .flags = SPI_DEVICE_NO_DUMMY
56 | };
57 | ESP_ERROR_CHECK(spi_bus_add_device(SPI_HOST_NUM, &dev_conf, &spi_host));
58 |
59 | ESP_LOGI(SPI_HOST_TAG, "initialized, sclk: %d, mosi: %d, miso: %d, cs: %d",
60 | bus_conf.sclk_io_num,
61 | bus_conf.mosi_io_num,
62 | bus_conf.miso_io_num,
63 | dev_conf.spics_io_num
64 | );
65 | }
66 | #endif
67 |
--------------------------------------------------------------------------------
/main/src/core/app.c:
--------------------------------------------------------------------------------
1 | /*
2 | * app.c
3 | *
4 | * Created on: 2018-04-05 19:09
5 | * Author: Jack Chen
6 | */
7 |
8 | #include "esp_log.h"
9 | #include "esp_ota_ops.h"
10 |
11 | #include "nvs.h"
12 | #include "nvs_flash.h"
13 |
14 | #define TAG "app"
15 |
16 | const char *app_get_version(void)
17 | {
18 | return esp_ota_get_app_description()->version;
19 | }
20 |
21 | void app_print_info(void)
22 | {
23 | ESP_LOGW(TAG, "current version: %s", app_get_version());
24 | }
25 |
26 | esp_err_t app_getenv(const char *key, void *out_value, size_t *length)
27 | {
28 | nvs_handle_t handle;
29 |
30 | esp_err_t err = nvs_open("storage", NVS_READWRITE, &handle);
31 | if (err != ESP_OK) {
32 | ESP_LOGE(TAG, "failed to open nvs");
33 | return err;
34 | }
35 |
36 | err = nvs_get_blob(handle, key, out_value, length);
37 | if (err == ESP_ERR_NVS_NOT_FOUND) {
38 | ESP_LOGW(TAG, "env not found: %s", key);
39 | nvs_close(handle);
40 | return err;
41 | } else if (err != ESP_OK) {
42 | ESP_LOGE(TAG, "failed to read env: %s", key);
43 | nvs_close(handle);
44 | return err;
45 | }
46 |
47 | nvs_close(handle);
48 |
49 | return ESP_OK;
50 | }
51 |
52 | esp_err_t app_setenv(const char *key, const void *value, size_t length)
53 | {
54 | nvs_handle_t handle;
55 |
56 | esp_err_t err = nvs_open("storage", NVS_READWRITE, &handle);
57 | if (err != ESP_OK) {
58 | ESP_LOGE(TAG, "failed to open nvs");
59 | return err;
60 | }
61 |
62 | err = nvs_set_blob(handle, key, value, length);
63 | if (err != ESP_OK) {
64 | ESP_LOGE(TAG, "failed to set nvs blob");
65 | nvs_close(handle);
66 | return err;
67 | }
68 |
69 | err = nvs_commit(handle);
70 | if (err != ESP_OK) {
71 | ESP_LOGE(TAG, "failed to write env: %s", key);
72 | nvs_close(handle);
73 | return err;
74 | }
75 |
76 | nvs_close(handle);
77 |
78 | return ESP_OK;
79 | }
80 |
--------------------------------------------------------------------------------
/main/src/user/ain.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ain.c
3 | *
4 | * Created on: 2019-07-05 21:22
5 | * Author: Jack Chen
6 | */
7 |
8 | #include
9 |
10 | #include "esp_log.h"
11 |
12 | #include "freertos/FreeRTOS.h"
13 | #include "freertos/task.h"
14 |
15 | #include "core/os.h"
16 | #include "core/app.h"
17 |
18 | #include "chip/i2s.h"
19 |
20 | #include "user/ain.h"
21 | #include "user/fft.h"
22 |
23 | #define TAG "ain"
24 |
25 | static uint8_t data[FFT_BLOCK_SIZE] = {0};
26 | static ain_mode_t ain_mode = DEFAULT_AIN_MODE;
27 |
28 | static void ain_task(void *pvParameters)
29 | {
30 | ESP_LOGI(TAG, "started.");
31 |
32 | while (1) {
33 | xEventGroupWaitBits(
34 | user_event_group,
35 | AUDIO_INPUT_RUN_BIT | VFX_FFT_IDLE_BIT,
36 | pdFALSE,
37 | pdTRUE,
38 | portMAX_DELAY
39 | );
40 |
41 | size_t bytes_read = 0;
42 | i2s_read(CONFIG_AUDIO_INPUT_I2S_NUM, data, FFT_BLOCK_SIZE, &bytes_read, portMAX_DELAY);
43 |
44 | #ifdef CONFIG_ENABLE_VFX
45 | #ifdef CONFIG_AUDIO_INPUT_FFT_ONLY_LEFT
46 | fft_load_data(data, FFT_CHANNEL_L);
47 | #elif defined(CONFIG_AUDIO_INPUT_FFT_ONLY_RIGHT)
48 | fft_load_data(data, FFT_CHANNEL_R);
49 | #else
50 | fft_load_data(data, FFT_CHANNEL_LR);
51 | #endif
52 |
53 | xEventGroupClearBits(user_event_group, VFX_FFT_IDLE_BIT);
54 | #endif
55 | }
56 | }
57 |
58 | void ain_set_mode(ain_mode_t idx)
59 | {
60 | ain_mode = idx;
61 | ESP_LOGI(TAG, "mode: %u", ain_mode);
62 |
63 | if (ain_mode == AIN_MODE_IDX_ON) {
64 | xEventGroupSetBits(user_event_group, AUDIO_INPUT_RUN_BIT);
65 | } else {
66 | xEventGroupClearBits(user_event_group, AUDIO_INPUT_RUN_BIT);
67 | }
68 | }
69 |
70 | ain_mode_t ain_get_mode(void)
71 | {
72 | return ain_mode;
73 | }
74 |
75 | void ain_init(void)
76 | {
77 | size_t length = sizeof(ain_mode_t);
78 | app_getenv("AIN_INIT_CFG", &ain_mode, &length);
79 |
80 | ain_set_mode(ain_mode);
81 |
82 | xTaskCreatePinnedToCore(ain_task, "ainT", 1536, NULL, configMAX_PRIORITIES - 3, NULL, 0);
83 | }
84 |
--------------------------------------------------------------------------------
/main/src/user/ble_app.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ble_app.c
3 | *
4 | * Created on: 2019-07-04 22:50
5 | * Author: Jack Chen
6 | */
7 |
8 | #include
9 |
10 | #include "esp_log.h"
11 | #include "esp_gatts_api.h"
12 | #include "esp_gap_bt_api.h"
13 | #include "esp_gap_ble_api.h"
14 | #include "esp_gatt_common_api.h"
15 |
16 | #include "core/os.h"
17 | #include "chip/bt.h"
18 |
19 | #include "user/ble_app.h"
20 | #include "user/ble_gatts.h"
21 |
22 | #define BLE_APP_TAG "ble_app"
23 | #define BLE_GAP_TAG "ble_gap"
24 |
25 | #ifdef CONFIG_ENABLE_BLE_CONTROL_IF
26 | static uint8_t adv_data_raw[5 + sizeof(CONFIG_BLE_NAME)] = {
27 | 2,
28 | ESP_BT_EIR_TYPE_FLAGS,
29 | ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT,
30 | 1 + sizeof(CONFIG_BLE_NAME),
31 | ESP_BLE_AD_TYPE_NAME_CMPL
32 | };
33 |
34 | static esp_ble_adv_params_t adv_params = {
35 | .adv_int_min = 0x20,
36 | .adv_int_max = 0x40,
37 | .adv_type = ADV_TYPE_IND,
38 | .own_addr_type = BLE_ADDR_TYPE_RANDOM,
39 | .channel_map = ADV_CHNL_ALL,
40 | .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY
41 | };
42 |
43 | static void ble_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
44 | {
45 | switch (event) {
46 | case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:
47 | esp_ble_gap_start_advertising(&adv_params);
48 | break;
49 | case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
50 | if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) {
51 | ESP_LOGE(BLE_GAP_TAG, "failed to start advertising");
52 | }
53 | break;
54 | case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT:
55 | if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS) {
56 | ESP_LOGE(BLE_GAP_TAG, "failed to stop advertising");
57 | }
58 | break;
59 | case ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT:
60 | ble_app_config_adv_data();
61 | break;
62 | default:
63 | break;
64 | }
65 | }
66 |
67 | void *ble_app_get_adv_params(void)
68 | {
69 | return &adv_params;
70 | }
71 |
72 | void ble_app_config_adv_data(void)
73 | {
74 | strcpy((char *)adv_data_raw + 5, CONFIG_BLE_NAME);
75 | esp_ble_gap_config_adv_data_raw(adv_data_raw, sizeof(adv_data_raw));
76 | }
77 |
78 | void ble_app_init(void)
79 | {
80 | xEventGroupSetBits(user_event_group, BLE_GATTS_IDLE_BIT);
81 |
82 | esp_ble_gap_register_callback(ble_gap_event_handler);
83 | esp_ble_gap_config_local_privacy(true);
84 |
85 | esp_ble_gatts_register_callback(ble_gatts_event_handler);
86 | esp_ble_gatts_app_register(PROFILE_IDX_OTA);
87 | esp_ble_gatts_app_register(PROFILE_IDX_CFG);
88 |
89 | esp_ble_gatt_set_local_mtu(ESP_GATT_MAX_MTU_SIZE);
90 |
91 | ESP_LOGI(BLE_APP_TAG, "started.");
92 | }
93 | #endif
94 |
--------------------------------------------------------------------------------
/main/src/user/bt_app.c:
--------------------------------------------------------------------------------
1 | /*
2 | * bt_app.c
3 | *
4 | * Created on: 2018-03-09 13:57
5 | * Author: Jack Chen
6 | */
7 |
8 | #include
9 |
10 | #include "esp_log.h"
11 | #include "esp_bt_main.h"
12 | #include "esp_bt_device.h"
13 | #include "esp_gap_bt_api.h"
14 |
15 | #include "freertos/FreeRTOS.h"
16 | #include "freertos/queue.h"
17 |
18 | #include "core/os.h"
19 | #include "core/app.h"
20 |
21 | #include "user/bt_av.h"
22 |
23 | #define BT_APP_TAG "bt_app"
24 | #define BT_GAP_TAG "bt_gap"
25 |
26 | static void bt_gap_event_handler(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
27 | {
28 | switch (event) {
29 | case ESP_BT_GAP_AUTH_CMPL_EVT:
30 | if (param->auth_cmpl.stat == ESP_BT_STATUS_SUCCESS) {
31 | ESP_LOGI(BT_GAP_TAG, "authentication success: %s", param->auth_cmpl.device_name);
32 | } else {
33 | ESP_LOGE(BT_GAP_TAG, "authentication failed: %d", param->auth_cmpl.stat);
34 | }
35 | break;
36 | default:
37 | break;
38 | }
39 | }
40 |
41 | void bt_app_init(void)
42 | {
43 | xEventGroupSetBits(user_event_group, BT_A2DP_IDLE_BIT);
44 |
45 | esp_bt_dev_set_device_name(CONFIG_BT_NAME);
46 | esp_bt_gap_register_callback(bt_gap_event_handler);
47 |
48 | esp_avrc_ct_init();
49 | esp_avrc_ct_register_callback(bt_avrc_ct_event_handler);
50 |
51 | esp_avrc_tg_init();
52 | esp_avrc_tg_register_callback(bt_avrc_tg_event_handler);
53 |
54 | esp_a2d_sink_init();
55 | esp_a2d_register_callback(bt_a2d_event_handler);
56 | esp_a2d_sink_register_data_callback(bt_a2d_data_handler);
57 |
58 | esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
59 |
60 | ESP_LOGI(BT_APP_TAG, "started.");
61 | }
62 |
--------------------------------------------------------------------------------
/main/src/user/key_handle.c:
--------------------------------------------------------------------------------
1 | /*
2 | * key_handle.c
3 | *
4 | * Created on: 2019-07-06 10:35
5 | * Author: Jack Chen
6 | */
7 |
8 | #include "esp_log.h"
9 | #include "esp_sleep.h"
10 | #include "esp_gap_bt_api.h"
11 | #include "esp_gap_ble_api.h"
12 |
13 | #include "freertos/FreeRTOS.h"
14 | #include "freertos/task.h"
15 |
16 | #include "driver/gpio.h"
17 |
18 | #include "core/os.h"
19 | #include "user/vfx.h"
20 | #include "user/key.h"
21 | #include "user/ain.h"
22 | #include "user/bt_av.h"
23 | #include "user/ble_gatts.h"
24 | #include "user/audio_player.h"
25 |
26 | #ifdef CONFIG_ENABLE_SLEEP_KEY
27 | void sleep_key_handle(void)
28 | {
29 | key_set_scan_mode(KEY_SCAN_MODE_IDX_OFF);
30 |
31 | esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);
32 |
33 | #ifdef CONFIG_ENABLE_VFX
34 | vfx_config_t *vfx = vfx_get_conf();
35 | vfx->mode = VFX_MODE_IDX_OFF;
36 | vfx_set_conf(vfx);
37 | #if defined(CONFIG_VFX_OUTPUT_ST7735) || defined(CONFIG_VFX_OUTPUT_ST7789)
38 | vTaskDelay(500 / portTICK_RATE_MS);
39 | #endif
40 | #endif
41 |
42 | #ifndef CONFIG_AUDIO_INPUT_NONE
43 | ain_set_mode(AIN_MODE_IDX_OFF);
44 | #endif
45 |
46 | #ifdef CONFIG_ENABLE_AUDIO_PROMPT
47 | audio_player_play_file(MP3_FILE_IDX_SLEEP);
48 | #endif
49 |
50 | if (!(xEventGroupGetBits(user_event_group) & BT_A2DP_IDLE_BIT)) {
51 | esp_a2d_sink_disconnect(a2d_remote_bda);
52 | }
53 |
54 | #ifdef CONFIG_ENABLE_BLE_CONTROL_IF
55 | if (!(xEventGroupGetBits(user_event_group) & BLE_GATTS_IDLE_BIT)) {
56 | esp_ble_gatts_close(gatts_profile_tbl[PROFILE_IDX_OTA].gatts_if,
57 | gatts_profile_tbl[PROFILE_IDX_OTA].conn_id);
58 | }
59 | #endif
60 |
61 | os_pwr_sleep_wait(
62 | BT_A2DP_IDLE_BIT
63 | #ifdef CONFIG_ENABLE_BLE_CONTROL_IF
64 | | BLE_GATTS_IDLE_BIT
65 | #endif
66 | #ifdef CONFIG_ENABLE_AUDIO_PROMPT
67 | | AUDIO_PLAYER_IDLE_BIT
68 | #endif
69 | );
70 | }
71 | #endif
72 |
--------------------------------------------------------------------------------
/main/src/user/led.c:
--------------------------------------------------------------------------------
1 | /*
2 | * led.c
3 | *
4 | * Created on: 2018-02-13 15:43
5 | * Author: Jack Chen
6 | */
7 |
8 | #include "esp_log.h"
9 |
10 | #include "freertos/FreeRTOS.h"
11 | #include "freertos/task.h"
12 |
13 | #include "driver/gpio.h"
14 |
15 | #include "user/led.h"
16 |
17 | #define TAG "led"
18 |
19 | static const TickType_t led_mode_table[][2] = {
20 | [LED_MODE_IDX_BLINK_S1] = {2000, 2000},
21 | [LED_MODE_IDX_BLINK_S0] = {1000, 1000},
22 | [LED_MODE_IDX_BLINK_M1] = { 500, 500},
23 | [LED_MODE_IDX_BLINK_M0] = { 250, 250},
24 | [LED_MODE_IDX_BLINK_F1] = { 100, 100},
25 | [LED_MODE_IDX_BLINK_F0] = { 50, 50},
26 | [LED_MODE_IDX_PULSE_D0] = { 625, 25},
27 | [LED_MODE_IDX_PULSE_D1] = {1250, 25},
28 | [LED_MODE_IDX_PULSE_D2] = {1875, 25},
29 | [LED_MODE_IDX_PULSE_D3] = {2500, 25}
30 | };
31 |
32 | static led_mode_t led_mode = LED_MODE_IDX_BLINK_M0;
33 |
34 | static void led_task(void *pvParameter)
35 | {
36 | #ifdef CONFIG_ENABLE_LED
37 | bool active = false;
38 | portTickType xLastWakeTime;
39 |
40 | #ifdef CONFIG_LED_ACTIVE_LOW
41 | gpio_set_level(CONFIG_LED_PIN, 1);
42 | #else
43 | gpio_set_level(CONFIG_LED_PIN, 0);
44 | #endif
45 |
46 | gpio_config_t io_conf = {
47 | .pin_bit_mask = BIT64(CONFIG_LED_PIN),
48 | .mode = GPIO_MODE_OUTPUT,
49 | .pull_up_en = false,
50 | .pull_down_en = false,
51 | .intr_type = GPIO_INTR_DISABLE,
52 | };
53 | gpio_config(&io_conf);
54 |
55 | ESP_LOGI(TAG, "started.");
56 |
57 | while (1) {
58 | xLastWakeTime = xTaskGetTickCount();
59 |
60 | #ifdef CONFIG_LED_ACTIVE_LOW
61 | if (!active) {
62 | #else
63 | if (active) {
64 | #endif
65 | gpio_set_level(CONFIG_LED_PIN, 1);
66 | } else {
67 | gpio_set_level(CONFIG_LED_PIN, 0);
68 | }
69 |
70 | active = !active;
71 |
72 | vTaskDelayUntil(&xLastWakeTime, led_mode_table[led_mode][active] / portTICK_RATE_MS);
73 | }
74 | #endif
75 | }
76 |
77 | void led_set_mode(led_mode_t idx)
78 | {
79 | if (idx >= sizeof(led_mode_table) / sizeof(led_mode_table[0])) {
80 | return;
81 | }
82 |
83 | led_mode = idx;
84 | }
85 |
86 | led_mode_t led_get_mode(void)
87 | {
88 | return led_mode;
89 | }
90 |
91 | void led_init(void)
92 | {
93 | xTaskCreatePinnedToCore(led_task, "ledT", 1536, NULL, 9, NULL, 1);
94 | }
95 |
--------------------------------------------------------------------------------
/partitions.csv:
--------------------------------------------------------------------------------
1 | # Name, Type, SubType, Offset, Size
2 | phy_init, data, phy, 0x00f000, 0x001000
3 | otadata, data, ota, 0x010000, 0x002000
4 | nvs, data, nvs, 0x012000, 0x00e000
5 | ota_0, app, ota_0, 0x020000, 0x1f0000
6 | ota_1, app, ota_1, 0x210000, 0x1f0000
7 |
--------------------------------------------------------------------------------
/sdkconfig.defaults:
--------------------------------------------------------------------------------
1 | #
2 | # Bootloader config
3 | #
4 | CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
5 |
6 | #
7 | # Serial flasher config
8 | #
9 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
10 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
11 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
12 |
13 | #
14 | # Partition Table
15 | #
16 | CONFIG_PARTITION_TABLE_CUSTOM=y
17 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
18 |
19 | #
20 | # Bluetooth
21 | #
22 | CONFIG_BT_ENABLED=y
23 | CONFIG_BTDM_CTRL_MODE_BTDM=y
24 | CONFIG_BTDM_CTRL_BLE_MAX_CONN=1
25 | CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN=1
26 | CONFIG_BTDM_CTRL_AUTO_LATENCY=y
27 | CONFIG_BTDM_MODEM_SLEEP=n
28 | CONFIG_BT_BLUEDROID_ENABLED=y
29 | CONFIG_BT_CLASSIC_ENABLED=y
30 | CONFIG_BT_A2DP_ENABLE=y
31 | CONFIG_BT_SSP_ENABLED=y
32 | CONFIG_BT_BLE_ENABLED=y
33 | CONFIG_BT_GATTS_ENABLE=y
34 | CONFIG_BT_GATTC_ENABLE=n
35 | CONFIG_BT_BLE_SMP_ENABLE=n
36 | CONFIG_BT_STACK_NO_LOG=y
37 | CONFIG_BT_ACL_CONNECTIONS=2
38 |
39 | #
40 | # Compiler options
41 | #
42 | CONFIG_COMPILER_OPTIMIZATION_PERF=y
43 |
44 | #
45 | # ESP32-specific
46 | #
47 | CONFIG_ESP32_REV_MIN_1=y
48 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
49 |
50 | #
51 | # Common ESP-related
52 | #
53 | CONFIG_ESP_TASK_WDT=n
54 |
55 | #
56 | # Newlib
57 | #
58 | CONFIG_NEWLIB_NANO_FORMAT=y
59 |
60 | #
61 | # FreeRTOS
62 | #
63 | CONFIG_FREERTOS_HZ=1000
64 | CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
65 |
--------------------------------------------------------------------------------