├── .clang-format ├── .gitignore ├── README.md ├── docs ├── pio_env_change.png └── pio_env_choose.png ├── firmware └── M5StackCoreS3-UserDemo-V0.5-BO-20230601_0x0.bin ├── include ├── README ├── config.h └── lv_conf.h ├── lib ├── BMI270-Sensor-API │ ├── LICENSE │ ├── OIS_README.md │ ├── README.md │ ├── bmi2.c │ ├── bmi2.h │ ├── bmi270.c │ ├── bmi270.h │ ├── bmi270_context.c │ ├── bmi270_context.h │ ├── bmi270_legacy.c │ ├── bmi270_legacy.h │ ├── bmi270_maximum_fifo.c │ ├── bmi270_maximum_fifo.h │ ├── bmi2_defs.h │ ├── bmi2_ois.c │ └── bmi2_ois.h ├── BMM150-Sensor-API │ ├── Interrupt_settings.md │ ├── LICENSE │ ├── README.md │ ├── bmm150.c │ ├── bmm150.h │ ├── bmm150_defs.h │ └── examples │ │ ├── coines │ │ ├── common │ │ │ ├── common.c │ │ │ └── common.h │ │ ├── high_threshold │ │ │ ├── Makefile │ │ │ └── high_threshold_interrupt.c │ │ ├── low_threshold │ │ │ ├── Makefile │ │ │ └── low_threshold_interrupt.c │ │ └── mag_drdy_interrupt │ │ │ ├── Makefile │ │ │ └── mag_drdy_interrupt.c │ │ └── generic │ │ ├── common │ │ ├── bmm150_common.c │ │ └── bmm150_common.h │ │ ├── high_threshold │ │ ├── Makefile │ │ └── high_threshold_interrupt.c │ │ ├── low_threshold │ │ ├── Makefile │ │ └── low_threshold_interrupt.c │ │ └── mag_drdy_interrupt │ │ ├── Makefile │ │ └── mag_drdy_interrupt.c ├── PageManager │ ├── PM_Anim.cpp │ ├── PM_Base.cpp │ ├── PM_Drag.cpp │ ├── PM_Log.h │ ├── PM_Router.cpp │ ├── PM_State.cpp │ ├── PageBase.cpp │ ├── PageBase.h │ ├── PageFactory.h │ └── PageManager.h ├── README ├── ResourceManager │ ├── ResourceManager.cpp │ └── ResourceManager.h ├── libesp32-camera.a ├── lv_anim_label │ ├── lv_anim_label.c │ └── lv_anim_label.h ├── lv_ext │ ├── lv_anim_timeline_wrapper.c │ ├── lv_anim_timeline_wrapper.h │ ├── lv_obj_ext_func.cpp │ └── lv_obj_ext_func.h ├── lv_poly_line │ ├── lv_poly_line.cpp │ └── lv_poly_line.h └── m5gfx_lvgl │ ├── m5gfx_lvgl.cpp │ └── m5gfx_lvgl.h ├── partitions_ffat.csv ├── platformio.ini ├── src ├── App.cpp ├── App.h ├── main.cpp ├── pages │ ├── AppCamera │ │ ├── AppCamera.cpp │ │ ├── AppCamera.h │ │ ├── AppCameraModel.cpp │ │ ├── AppCameraModel.h │ │ ├── AppCameraView.cpp │ │ └── AppCameraView.h │ ├── AppFactory.cpp │ ├── AppFactory.h │ ├── AppI2C │ │ ├── AppI2C.cpp │ │ ├── AppI2C.h │ │ ├── AppI2CModel.cpp │ │ ├── AppI2CModel.h │ │ ├── AppI2CView.cpp │ │ └── AppI2CView.h │ ├── AppIMU │ │ ├── AppIMU.cpp │ │ ├── AppIMU.h │ │ ├── AppIMUModel.cpp │ │ ├── AppIMUModel.h │ │ ├── AppIMUView.cpp │ │ └── AppIMUView.h │ ├── AppMic │ │ ├── AppMic.cpp │ │ ├── AppMic.h │ │ ├── AppMicModel.cpp │ │ ├── AppMicModel.h │ │ ├── AppMicView.cpp │ │ └── AppMicView.h │ ├── AppPower │ │ ├── AppPower.cpp │ │ ├── AppPower.h │ │ ├── AppPowerModel.cpp │ │ ├── AppPowerModel.h │ │ ├── AppPowerView.cpp │ │ └── AppPowerView.h │ ├── AppRTC │ │ ├── AppRTC.cpp │ │ ├── AppRTC.h │ │ ├── AppRTCModel.cpp │ │ ├── AppRTCModel.h │ │ ├── AppRTCView.cpp │ │ └── AppRTCView.h │ ├── AppSD │ │ ├── AppSD.cpp │ │ ├── AppSD.h │ │ ├── AppSDModel.cpp │ │ ├── AppSDModel.h │ │ ├── AppSDView.cpp │ │ └── AppSDView.h │ ├── AppTouch │ │ ├── AppTouch.cpp │ │ ├── AppTouch.h │ │ ├── AppTouchModel.cpp │ │ ├── AppTouchModel.h │ │ ├── AppTouchView.cpp │ │ └── AppTouchView.h │ ├── AppWiFi │ │ ├── AppWiFi.cpp │ │ ├── AppWiFi.h │ │ ├── AppWiFiModel.cpp │ │ ├── AppWiFiModel.h │ │ ├── AppWiFiView.cpp │ │ └── AppWiFiView.h │ ├── HomeMenu │ │ ├── HomeMenu.cpp │ │ ├── HomeMenu.h │ │ ├── HomeMenuModel.cpp │ │ ├── HomeMenuModel.h │ │ ├── HomeMenuView.cpp │ │ └── HomeMenuView.h │ ├── Page.h │ ├── StartUp │ │ ├── StartUp.cpp │ │ ├── StartUp.h │ │ ├── StartUpModel.cpp │ │ ├── StartUpModel.h │ │ ├── StartUpView.cpp │ │ └── StartUpView.h │ └── _Template │ │ ├── Template.cpp │ │ ├── Template.h │ │ ├── TemplateModel.cpp │ │ ├── TemplateModel.h │ │ ├── TemplateView.cpp │ │ └── TemplateView.h └── res │ ├── ResourcePool.cpp │ ├── ResourcePool.h │ ├── font │ ├── alibaba_pht_26.c │ ├── alibaba_pht_list.txt │ ├── ubuntu_mono_14.c │ └── ubuntu_mono_8.c │ ├── img │ ├── app_camera.c │ ├── app_camera_als.c │ ├── app_camera_als_ps.c │ ├── app_camera_ps.c │ ├── app_i2c_internal.c │ ├── app_i2c_pa.c │ ├── app_i2c_pb.c │ ├── app_i2c_pc.c │ ├── app_imu_graphic.c │ ├── app_imu_raw.c │ ├── app_mic.c │ ├── app_power_bat0.c │ ├── app_power_bat1.c │ ├── app_power_bat2.c │ ├── app_power_busin.c │ ├── app_power_busout.c │ ├── app_power_ii.c │ ├── app_power_io.c │ ├── app_power_oi.c │ ├── app_power_oo.c │ ├── app_power_usbin.c │ ├── app_power_usbout.c │ ├── app_rtc.c │ ├── app_sd.c │ ├── app_touch.c │ ├── app_touch_min.c │ ├── app_wifi.c │ ├── background.c │ ├── ball.c │ ├── compass_face.c │ ├── core_text.c │ ├── core_text_se.c │ ├── cores3_diagram.c │ ├── cores3_diagram_se.c │ ├── cross.c │ ├── cursor_hand.c │ ├── failed.c │ ├── home_p.c │ ├── home_r.c │ ├── info_text.c │ ├── menu.c │ ├── menu_bg.c │ ├── menu_bg_se.c │ ├── menu_cam.c │ ├── menu_cam_se.c │ ├── menu_i2c.c │ ├── menu_imu.c │ ├── menu_imu_se.c │ ├── menu_mic.c │ ├── menu_power.c │ ├── menu_sd.c │ ├── menu_se.c │ ├── menu_sys.c │ ├── menu_touch.c │ ├── menu_wifi.c │ ├── next_p.c │ ├── next_r.c │ ├── pass.c │ ├── raw │ │ ├── app_camera.png │ │ ├── app_camera_als.png │ │ ├── app_camera_als_ps.png │ │ ├── app_camera_ps.png │ │ ├── app_i2c_internal.png │ │ ├── app_i2c_pa.png │ │ ├── app_i2c_pb.png │ │ ├── app_i2c_pc.png │ │ ├── app_imu_graphic.png │ │ ├── app_imu_raw.png │ │ ├── app_mic.png │ │ ├── app_power_bat0.png │ │ ├── app_power_bat1.png │ │ ├── app_power_bat2.png │ │ ├── app_power_busin.png │ │ ├── app_power_busout.png │ │ ├── app_power_ii.png │ │ ├── app_power_io.png │ │ ├── app_power_oi.png │ │ ├── app_power_oo.png │ │ ├── app_power_usbin.png │ │ ├── app_power_usbout.png │ │ ├── app_rtc.png │ │ ├── app_sd.png │ │ ├── app_touch.png │ │ ├── app_touch_min.png │ │ ├── app_wifi.png │ │ ├── background.png │ │ ├── ball.png │ │ ├── compass_face.png │ │ ├── core_text.png │ │ ├── core_text_se.png │ │ ├── cores3_diagram.png │ │ ├── cores3_diagram_se.png │ │ ├── cross.png │ │ ├── cursor_hand.png │ │ ├── failed.png │ │ ├── home_p.png │ │ ├── home_r.png │ │ ├── info_text.png │ │ ├── menu.png │ │ ├── menu_bg.png │ │ ├── menu_bg_se.png │ │ ├── menu_cam.png │ │ ├── menu_cam_se.png │ │ ├── menu_i2c.png │ │ ├── menu_imu.png │ │ ├── menu_imu_se.png │ │ ├── menu_mic.png │ │ ├── menu_power.png │ │ ├── menu_sd.png │ │ ├── menu_se.png │ │ ├── menu_sys.png │ │ ├── menu_touch.png │ │ ├── menu_wifi.png │ │ ├── next_p.png │ │ ├── next_r.png │ │ ├── pass.png │ │ ├── s3_text.png │ │ └── s3_text_se.png │ ├── s3_text.c │ └── s3_text_se.c │ └── wav │ ├── poweron_2_5s.c │ ├── raw │ ├── poweron_2_5s.wav │ └── select_0_5s.wav │ └── select_0_5s.c └── test └── README /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode 3 | 4 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## M5CoreS3 & M5CoreS3SE User Demo 2 | 3 | You may encounter the "cam_task canary ..." error, please consider replacing the 4 | libesp32-camera.a(under pio package folder) to lib/libesp32-camera.a 5 | 6 | ### How to change board 7 | 8 | 1. Click PIO environment switch button 9 | ![](./docs/pio_env_change.png) 10 | 2. Select M5CoreS3 or M5CoreS3SE env 11 | ![](./docs/pio_env_choose.png) 12 | 13 | ### Build info: 14 | ```bash 15 | Processing esp32-s3-devkitc-1 (platform: espressif32; board: esp32-s3-devkitc-1; framework: arduino) 16 | ------------------------------------------------------------------------------------------------------------------------------------------- 17 | Verbose mode can be enabled via `-v, --verbose` option 18 | CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1.html 19 | PLATFORM: Espressif 32 (6.1.0) > Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM) 20 | HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash 21 | DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) 22 | PACKAGES: 23 | - framework-arduinoespressif32 @ 3.20007.0 (2.0.7) 24 | - tool-esptoolpy @ 1.40500.0 (4.5.0) 25 | - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 26 | - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5 27 | LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf 28 | LDF Modes: Finder ~ chain, Compatibility ~ soft 29 | Found 45 compatible libraries 30 | Scanning dependencies... 31 | Dependency Graph 32 | |-- M5GFX @ 0.1.6 33 | |-- M5Unified @ 0.1.6 34 | |-- lvgl @ 8.3.4 35 | |-- Madgwick @ 1.2.0 36 | |-- PageManager 37 | |-- m5gfx_lvgl 38 | |-- ESP32 BLE Arduino @ 2.0.0 39 | |-- FFat @ 2.0.0 40 | |-- Wire @ 2.0.0 41 | |-- ResourceManager 42 | |-- BMI270-Sensor-API 43 | |-- BMM150-Sensor-API 44 | |-- SD @ 2.0.0 45 | |-- WiFi @ 2.0.0 46 | |-- lv_anim_label 47 | |-- lv_ext 48 | Building in release mode 49 | Retrieving maximum program size .pio/build/esp32-s3-devkitc-1/firmware.elf 50 | Checking size .pio/build/esp32-s3-devkitc-1/firmware.elf 51 | Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" 52 | RAM: [=== ] 31.2% (used 102132 bytes from 327680 bytes) 53 | Flash: [========= ] 92.1% (used 6759441 bytes from 7340032 bytes) 54 | ``` -------------------------------------------------------------------------------- /docs/pio_env_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/docs/pio_env_change.png -------------------------------------------------------------------------------- /docs/pio_env_choose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/docs/pio_env_choose.png -------------------------------------------------------------------------------- /firmware/M5StackCoreS3-UserDemo-V0.5-BO-20230601_0x0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/firmware/M5StackCoreS3-UserDemo-V0.5-BO-20230601_0x0.bin -------------------------------------------------------------------------------- /include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_H 2 | #define __CONFIG_H 3 | 4 | #define DEMO_VERSION "0.6" 5 | 6 | #define GC0308_ADDR 0x21 7 | #define LTR553_ADDR 0x23 8 | #define AXP2101_ADDR 0x34 9 | #define AW88298_ADDR 0x36 10 | #define FT6336_ADDR 0x38 11 | #define ES7210_ADDR 0x40 12 | #define BM8563_ADDR 0x51 13 | #define AW9523_ADDR 0x58 14 | #define BMI270_ADDR 0x69 15 | #define BMM150_ADDR 0x10 16 | 17 | #define SYS_I2C_PORT 0 18 | #define SYS_I2C_SDA 12 19 | #define SYS_I2C_SCL 11 20 | 21 | #define EXT_I2C_PORT 0 22 | 23 | #define PORTA_PIN_0 1 24 | #define PORTA_PIN_1 2 25 | #define PORTB_PIN_0 8 26 | #define PORTB_PIN_1 9 27 | #define PORTC_PIN_0 18 28 | #define PORTC_PIN_1 17 29 | 30 | #define POWER_MODE_USB_IN_BUS_IN 0 31 | #define POWER_MODE_USB_IN_BUS_OUT 1 32 | #define POWER_MODE_USB_OUT_BUS_IN 2 33 | #define POWER_MODE_USB_OUT_BUS_OUT 3 34 | 35 | #define MIC_BUF_SIZE 256 36 | 37 | #define MONKEY_TEST_ENABLE 0 38 | 39 | #endif // __CONFIG_H -------------------------------------------------------------------------------- /lib/BMI270-Sensor-API/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. 2 | 3 | BSD-3-Clause 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /lib/BMI270-Sensor-API/README.md: -------------------------------------------------------------------------------- 1 | BMI270 Sensor API 2 | 3 | > This package contains the sensor APIs for the BMI270 sensor 4 | 5 | ## Sensor Overview 6 | The BMI270 is a small, low power, low noise inertial measurement unit designed for use in mobile applications like augmented reality or indoor navigation which require highly accurate, real-time sensor data. 7 | 8 | ## Applications 9 | 10 | ### BMI270 (base) 11 | 12 | - Any motion, No motion, Significant motion detectors 13 | - Wrist worn Step counter and Step detector (Pedometer) 14 | - Activity change recognition 15 | - Still 16 | - Walking 17 | - Running 18 | - Wrist gestures 19 | - Push arm down 20 | - Pivot up 21 | - Wrist shake jiggle 22 | - Flick in 23 | - Flick out 24 | - Wrist wear wake up 25 | 26 | ### BMI270 Context 27 | 28 | - Step counter and Step detector (Pedometer) 29 | - Activity change recognition 30 | - Still 31 | - Walking 32 | - Running 33 | 34 | ### BMI270 Legacy 35 | 36 | - Any motion, No motion, Significant motion detector 37 | - Orientation detector (Advanced Potrait-Landscape) 38 | - High-G, Low-G (Freefall) detector 39 | - Flat detector 40 | - Tap detection (Single, Double, Triple taps) 41 | - Smartphone Step counter and Step detector (Pedometer) 42 | - Activity change recognition 43 | - Still 44 | - Walking 45 | - Running 46 | 47 | ### BMI270 Maximum FIFO 48 | 49 | - Supports a 6kB FIFO 50 | 51 | For more information refer product page [Link](https://www.bosch-sensortec.com/products/motion-sensors/imus/bmi270.html) 52 | 53 | --- -------------------------------------------------------------------------------- /lib/BMI270-Sensor-API/bmi270_maximum_fifo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * BSD-3-Clause 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. Neither the name of the copyright holder nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | * @file bmi270_maximum_fifo.h 34 | * @date 2021-09-30 35 | * @version v2.71.8 36 | * 37 | */ 38 | 39 | /** 40 | * \ingroup bmi2xy 41 | * \defgroup bmi270_maximum_fifo BMI270_MAXIMUM_FIFO 42 | * @brief Sensor driver for BMI270_MAXIMUM_FIFO sensor 43 | */ 44 | 45 | #ifndef BMI270_MAXIMUM_FIFO_H_ 46 | #define BMI270_MAXIMUM_FIFO_H_ 47 | 48 | /*! CPP guard */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /***************************************************************************/ 54 | 55 | /*! Header files 56 | ****************************************************************************/ 57 | #include "bmi2.h" 58 | 59 | /***************************************************************************/ 60 | 61 | /*! Macro definitions 62 | ****************************************************************************/ 63 | 64 | /*! @name BMI270 Chip identifier */ 65 | #define BMI270_MAXIMUM_FIFO_CHIP_ID UINT8_C(0x24) 66 | 67 | /*! @name Defines maximum number of pages */ 68 | #define BMI270_MAXIMUM_FIFO_MAX_PAGE_NUM UINT8_C(0) 69 | 70 | /*! @name Defines maximum number of feature input configurations */ 71 | #define BMI270_MAXIMUM_FIFO_MAX_FEAT_IN UINT8_C(0) 72 | 73 | /*! @name Defines maximum number of feature outputs */ 74 | #define BMI270_MAXIMUM_FIFO_MAX_FEAT_OUT UINT8_C(0) 75 | 76 | /*! @name Mask definitions for feature interrupt status bits */ 77 | 78 | /***************************************************************************/ 79 | 80 | /*! BMI270 User Interface function prototypes 81 | ****************************************************************************/ 82 | 83 | /** 84 | * \ingroup bmi270_maximum_fifo 85 | * \defgroup bmi270_maximum_fifoApiInit Initialization 86 | * @brief Initialize the sensor and device structure 87 | */ 88 | 89 | /*! 90 | * \ingroup bmi270_maximum_fifoApiInit 91 | * \page bmi270_maximum_fifo_api_bmi270_maximum_fifo_init bmi270_maximum_fifo_init 92 | * \code 93 | * int8_t bmi270_maximum_fifo_init(struct bmi2_dev *dev); 94 | * \endcode 95 | * @details This API: 96 | * 1) updates the device structure with address of the configuration file. 97 | * 2) Initializes BMI270 sensor. 98 | * 3) Writes the configuration file. 99 | * 4) Updates the feature offset parameters in the device structure. 100 | * 5) Updates the maximum number of pages, in the device structure. 101 | * 102 | * @param[in, out] dev : Structure instance of bmi2_dev. 103 | * 104 | * @return Result of API execution status 105 | * @retval 0 -> Success 106 | * @retval < 0 -> Fail 107 | */ 108 | int8_t bmi270_maximum_fifo_init(struct bmi2_dev *dev); 109 | 110 | /******************************************************************************/ 111 | /*! @name C++ Guard Macros */ 112 | /******************************************************************************/ 113 | #ifdef __cplusplus 114 | } 115 | #endif /* End of CPP guard */ 116 | 117 | #endif /* BMI270_MAXIMUM_FIFO_H_ */ 118 | -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 2 | 3 | BSD-3-Clause 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/README.md: -------------------------------------------------------------------------------- 1 | # BMM150 sensor API 2 | 3 | ### Sensor overview 4 | 5 | BMM150 is a standalone geomagnetic sensor for consumer market applications. 6 | Performance and feature of BMM150 are carefully tuned and perfectly match the 7 | demanding requirements of all 3-axis mobile applications such as electronic 8 | compass, navigation or augmented reality. 9 | 10 | ### Target Application 11 | - Magnetic heading information 12 | - Tilt-compensated electronic compass 13 | - Gyroscope calibration in 9-DoF application for mobile devices 14 | - In-door navigation 15 | - Gaming 16 | 17 | ### Feature 18 | - Magnetic field data 19 | 20 | ### Important links 21 | 22 | - [BMM150 product page](https://www.bosch-sensortec.com/products/motion-sensors/magnetometers-bmm150/) 23 | - [BMM150 datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmm150-ds001.pdf) 24 | - [BMM150 shuttle board flyer](https://www.bosch-sensortec.com/media/boschsensortec/downloads/shuttle_board_flyer/bst-dhw-fl016.pdf) 25 | - [Community support page](https://community.bosch-sensortec.com) 26 | 27 | --- 28 | #### Copyright (C) 2020 Bosch Sensortec GmbH -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/coines/common/common.h: -------------------------------------------------------------------------------- 1 | /**\ 2 | * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | **/ 6 | 7 | #ifndef _COMMON_H 8 | #define _COMMON_H 9 | 10 | /*! CPP guard */ 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include 16 | #include "bmm150.h" 17 | 18 | /***************************************************************************/ 19 | 20 | /*! User function prototypes 21 | ****************************************************************************/ 22 | 23 | /*! 24 | * @brief Function for reading the sensor's registers through SPI bus. 25 | * 26 | * @param[in] cs : Chip select to enable the sensor. 27 | * @param[in] reg_addr : Register address. 28 | * @param[out] reg_data : Pointer to the data buffer to store the read data. 29 | * @param[in] length : No of bytes to read. 30 | * @param[in] intf_ptr : Interface pointer 31 | * 32 | * @return Status of execution 33 | * 34 | * @retval BMM150_INTF_RET_SUCCESS -> Success. 35 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure. 36 | * 37 | */ 38 | BMM150_INTF_RET_TYPE bmm150_spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr); 39 | 40 | /*! 41 | * @brief Function for reading the sensor's registers through I2C bus. 42 | * 43 | * @param[in] i2c_addr : Sensor I2C address. 44 | * @param[in] reg_addr : Register address. 45 | * @param[out] reg_data : Pointer to the data buffer to store the read data. 46 | * @param[in] length : No of bytes to read. 47 | * @param[in] intf_ptr : Interface pointer 48 | * 49 | * @return Status of execution 50 | * 51 | * @retval BMM150_INTF_RET_SUCCESS -> Success. 52 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure. 53 | * 54 | */ 55 | BMM150_INTF_RET_TYPE bmm150_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr); 56 | 57 | /*! 58 | * @brief Function for writing the sensor's registers through SPI bus. 59 | * 60 | * @param[in] cs : Chip select to enable the sensor. 61 | * @param[in] reg_addr : Register address. 62 | * @param[in] reg_data : Pointer to the data buffer whose data has to be written. 63 | * @param[in] length : No of bytes to write. 64 | * @param[in] intf_ptr : Interface pointer 65 | * 66 | * @return Status of execution 67 | * 68 | * @retval BMM150_INTF_RET_SUCCESS -> Success. 69 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure. 70 | * 71 | */ 72 | BMM150_INTF_RET_TYPE bmm150_spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr); 73 | 74 | /*! 75 | * @brief Function for writing the sensor's registers through I2C bus. 76 | * 77 | * @param[in] i2c_addr : Sensor I2C address. 78 | * @param[in] reg_addr : Register address. 79 | * @param[in] reg_data : Pointer to the data buffer whose value is to be written. 80 | * @param[in] length : No of bytes to write. 81 | * @param[in] intf_ptr : Interface pointer 82 | * 83 | * @return Status of execution 84 | * 85 | * @retval BMM150_INTF_RET_SUCCESS -> Success. 86 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure. 87 | * 88 | */ 89 | BMM150_INTF_RET_TYPE bmm150_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr); 90 | 91 | /*! 92 | * @brief This function provides the delay for required time (Microsecond) as per the input provided in some of the 93 | * APIs. 94 | * 95 | * @param[in] period_us : The required wait time in microsecond. 96 | * @param[in] intf_ptr : Interface pointer 97 | * 98 | * @return void. 99 | */ 100 | void bmm150_delay_us(uint32_t period_us, void *intf_ptr); 101 | 102 | /*! 103 | * @brief This function is to select the interface between SPI and I2C. 104 | * 105 | * @param[in] dev : Structure instance of bmm150_dev 106 | * @param[in] intf : Interface selection parameter 107 | * For I2C : BMM150_I2C_INTF 108 | * For SPI : BMM150_SPI_INTF 109 | * 110 | * @return Status of execution 111 | * @retval 0 -> Success 112 | * @retval < 0 -> Failure 113 | */ 114 | int8_t bmm150_interface_selection(struct bmm150_dev *dev, uint8_t intf); 115 | 116 | /*! 117 | * @brief This API is used to print the execution status. 118 | * 119 | * @param[in] api_name : Name of the API whose execution status has to be printed. 120 | * @param[in] rslt : Error code returned by the API whose execution status has to be printed. 121 | * 122 | * @return void. 123 | */ 124 | void bmm150_error_codes_print_result(const char api_name[], int8_t rslt); 125 | 126 | /*! 127 | * @brief This function deinitializes coines platform 128 | * 129 | * @return void. 130 | * 131 | */ 132 | void bmm150_coines_deinit(void); 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif /* End of CPP guard */ 137 | 138 | #endif /* _COMMON_H */ 139 | -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/coines/high_threshold/Makefile: -------------------------------------------------------------------------------- 1 | REPO_COINES_PATH ?= ../../../submodules/coines 2 | 3 | MAIN_FILE ?= high_threshold_interrupt.c 4 | 5 | C_SRCS += \ 6 | ../../../source/bmm150.c \ 7 | ../common/common.c 8 | 9 | INCLUDEPATHS += \ 10 | ../../../source \ 11 | ../common 12 | 13 | include ../../../scripts/coines.mk -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/coines/high_threshold/high_threshold_interrupt.c: -------------------------------------------------------------------------------- 1 | /**\ 2 | * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | **/ 6 | 7 | /******************************************************************************/ 8 | /*! Header Files */ 9 | #include 10 | #include "bmm150.h" 11 | #include "common.h" 12 | 13 | /******************************************************************************/ 14 | /*! Static Function Declaration */ 15 | 16 | /*! 17 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 18 | * 19 | * @param[in] dev : Structure instance of bmm150_dev. 20 | * 21 | * @return Status of execution. 22 | */ 23 | static int8_t set_config(struct bmm150_dev *dev); 24 | 25 | /******************************************************************************/ 26 | /*! Functions */ 27 | 28 | /* This function starts the execution of program. */ 29 | int main(void) 30 | { 31 | /* Status of api are returned to this variable */ 32 | int8_t rslt; 33 | 34 | /* Sensor initialization configuration. */ 35 | struct bmm150_dev dev; 36 | 37 | /* Interface selection is to be updated as parameter 38 | * For I2C : BMM150_I2C_INTF 39 | * For SPI : BMM150_SPI_INTF 40 | */ 41 | rslt = bmm150_interface_selection(&dev, BMM150_I2C_INTF); 42 | bmm150_error_codes_print_result("bmm150_interface_selection", rslt); 43 | 44 | if (rslt == BMM150_OK) 45 | { 46 | rslt = bmm150_init(&dev); 47 | bmm150_error_codes_print_result("bmm150_init", rslt); 48 | 49 | if (rslt == BMM150_OK) 50 | { 51 | rslt = set_config(&dev); 52 | bmm150_error_codes_print_result("set_config", rslt); 53 | } 54 | 55 | while (1) 56 | { 57 | /* Get the interrupt status */ 58 | rslt = bmm150_get_interrupt_status(&dev); 59 | 60 | if (dev.int_status & BMM150_INT_ASSERTED_HIGH_THRES) 61 | { 62 | printf("High threshold interrupt occured"); 63 | break; 64 | } 65 | } 66 | } 67 | 68 | bmm150_coines_deinit(); 69 | 70 | return rslt; 71 | } 72 | 73 | /*! 74 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 75 | */ 76 | static int8_t set_config(struct bmm150_dev *dev) 77 | { 78 | /* Status of api are returned to this variable. */ 79 | int8_t rslt; 80 | struct bmm150_settings settings; 81 | 82 | /* Read the default configuration from the sensor */ 83 | settings.pwr_mode = BMM150_POWERMODE_NORMAL; 84 | rslt = bmm150_set_op_mode(&settings, dev); 85 | bmm150_error_codes_print_result("bmm150_set_op_mode", rslt); 86 | 87 | if (rslt == BMM150_OK) 88 | { 89 | /* Set any threshold level above which high threshold interrupt occurs */ 90 | settings.int_settings.high_threshold = 0x14; 91 | rslt = bmm150_set_sensor_settings(BMM150_SEL_HIGH_THRESHOLD_SETTING, &settings, dev); 92 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_1", rslt); 93 | 94 | if (rslt == BMM150_OK) 95 | { 96 | rslt = bmm150_get_sensor_settings(&settings, dev); 97 | bmm150_error_codes_print_result("bmm150_get_sensor_settings", rslt); 98 | printf("High threshold: %d \n", settings.int_settings.high_threshold); 99 | } 100 | 101 | if (rslt == BMM150_OK) 102 | { 103 | /* High interrupt pins are active low as per datasheet */ 104 | settings.int_settings.high_int_en = 0x00; 105 | rslt = bmm150_set_sensor_settings(BMM150_SEL_HIGH_THRESHOLD_INT, &settings, dev); 106 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_2", rslt); 107 | 108 | if (rslt == BMM150_OK) 109 | { 110 | settings.int_settings.int_pin_en = 0x01; 111 | rslt = bmm150_set_sensor_settings(BMM150_SEL_INT_PIN_EN, &settings, dev); 112 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_3", rslt); 113 | } 114 | } 115 | } 116 | 117 | return rslt; 118 | } 119 | -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/coines/low_threshold/Makefile: -------------------------------------------------------------------------------- 1 | REPO_COINES_PATH ?= ../../../submodules/coines 2 | 3 | MAIN_FILE ?= low_threshold_interrupt.c 4 | 5 | C_SRCS += \ 6 | ../../../source/bmm150.c \ 7 | ../common/common.c 8 | 9 | INCLUDEPATHS += \ 10 | ../../../source \ 11 | ../common 12 | 13 | include ../../../scripts/coines.mk -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/coines/low_threshold/low_threshold_interrupt.c: -------------------------------------------------------------------------------- 1 | /**\ 2 | * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | **/ 6 | 7 | /******************************************************************************/ 8 | /*! Header Files */ 9 | #include 10 | #include "bmm150.h" 11 | #include "common.h" 12 | 13 | /******************************************************************************/ 14 | /*! Static Function Declaration */ 15 | 16 | /*! 17 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 18 | * 19 | * @param[in] dev : Structure instance of bmm150_dev. 20 | * 21 | * @return Status of execution. 22 | */ 23 | static int8_t set_config(struct bmm150_dev *dev); 24 | 25 | /******************************************************************************/ 26 | /*! Functions */ 27 | 28 | /* This function starts the execution of program. */ 29 | int main(void) 30 | { 31 | /* Status of api are returned to this variable */ 32 | int8_t rslt; 33 | 34 | /* Sensor initialization configuration. */ 35 | struct bmm150_dev dev; 36 | 37 | /* Interface selection is to be updated as parameter 38 | * For I2C : BMM150_I2C_INTF 39 | * For SPI : BMM150_SPI_INTF 40 | */ 41 | rslt = bmm150_interface_selection(&dev, BMM150_I2C_INTF); 42 | bmm150_error_codes_print_result("bmm150_interface_selection", rslt); 43 | 44 | if (rslt == BMM150_OK) 45 | { 46 | rslt = bmm150_init(&dev); 47 | bmm150_error_codes_print_result("bmm150_init", rslt); 48 | 49 | if (rslt == BMM150_OK) 50 | { 51 | rslt = set_config(&dev); 52 | bmm150_error_codes_print_result("set_config", rslt); 53 | } 54 | 55 | while (1) 56 | { 57 | /* Get the interrupt status */ 58 | rslt = bmm150_get_interrupt_status(&dev); 59 | 60 | if (dev.int_status & BMM150_INT_ASSERTED_LOW_THRES) 61 | { 62 | printf("Low threshold interrupt occured"); 63 | break; 64 | } 65 | } 66 | } 67 | 68 | bmm150_coines_deinit(); 69 | 70 | return rslt; 71 | } 72 | 73 | /*! 74 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 75 | */ 76 | static int8_t set_config(struct bmm150_dev *dev) 77 | { 78 | /* Status of api are returned to this variable. */ 79 | int8_t rslt; 80 | 81 | struct bmm150_settings settings; 82 | 83 | /* Read the default configuration from the sensor */ 84 | settings.pwr_mode = BMM150_POWERMODE_NORMAL; 85 | rslt = bmm150_set_op_mode(&settings, dev); 86 | bmm150_error_codes_print_result("bmm150_set_op_mode", rslt); 87 | 88 | if (rslt == BMM150_OK) 89 | { 90 | /* Set any threshold level below which low threshold interrupt occurs */ 91 | settings.int_settings.low_threshold = 0x0A; 92 | rslt = bmm150_set_sensor_settings(BMM150_SEL_LOW_THRESHOLD_SETTING, &settings, dev); 93 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_1", rslt); 94 | 95 | if (rslt == BMM150_OK) 96 | { 97 | rslt = bmm150_get_sensor_settings(&settings, dev); 98 | bmm150_error_codes_print_result("bmm150_get_sensor_settings", rslt); 99 | printf("Low threshold: %d \n", settings.int_settings.low_threshold); 100 | } 101 | 102 | if (rslt == BMM150_OK) 103 | { 104 | /* Low interrupt pins are active low as per datasheet */ 105 | settings.int_settings.low_int_en = 0x00; 106 | rslt = bmm150_set_sensor_settings(BMM150_SEL_LOW_THRESHOLD_INT, &settings, dev); 107 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_2", rslt); 108 | 109 | if (rslt == BMM150_OK) 110 | { 111 | settings.int_settings.int_pin_en = 0x01; 112 | rslt = bmm150_set_sensor_settings(BMM150_SEL_INT_PIN_EN, &settings, dev); 113 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_3", rslt); 114 | } 115 | } 116 | } 117 | 118 | return rslt; 119 | } 120 | -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/coines/mag_drdy_interrupt/Makefile: -------------------------------------------------------------------------------- 1 | REPO_COINES_PATH ?= ../../../submodules/coines 2 | 3 | MAIN_FILE ?= mag_drdy_interrupt.c 4 | 5 | C_SRCS += \ 6 | ../../../source/bmm150.c \ 7 | ../common/common.c 8 | 9 | INCLUDEPATHS += \ 10 | ../../../source \ 11 | ../common 12 | 13 | include ../../../scripts/coines.mk -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/generic/common/bmm150_common.h: -------------------------------------------------------------------------------- 1 | /**\ 2 | * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | **/ 6 | 7 | #ifndef _BMM150_COMMON_H 8 | #define _BMM150_COMMON_H 9 | 10 | /*! CPP guard */ 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include 16 | #include "bmm150.h" 17 | 18 | /*! 19 | * @brief Function for initialization of I2C bus 20 | * 21 | * @retval 0 -> Success 22 | * @retval < 0 -> Failure Info 23 | */ 24 | int8_t bmm150_user_i2c_init(void); 25 | 26 | /*! 27 | * @brief Function for initialization of SPI bus 28 | * 29 | * @retval 0 -> Success 30 | * @retval < 0 -> Failure Info 31 | */ 32 | int8_t bmm150_user_spi_init(void); 33 | 34 | /*! 35 | * @brief This function provides the delay for required time (Microseconds) as per the input provided in some of the 36 | * APIs. 37 | * @param[in] period_us : The required wait time in microseconds. 38 | * @param[in] intf_ptr : Pointer to interface. 39 | * 40 | * @return void. 41 | * 42 | */ 43 | void bmm150_user_delay_us(uint32_t period_us, void *intf_ptr); 44 | 45 | /*! 46 | * @brief This function is for reading the sensor's registers through I2C bus. 47 | * 48 | * @param[in] reg_addr : Register address. 49 | * @param[out] reg_data: Pointer to the data buffer to store the read data. 50 | * @param[in] length : No of bytes to read. 51 | * @param[in] intf_ptr : Pointer to interface. 52 | * 53 | * @return Status of execution 54 | * 55 | * @retval = BMM150_INTF_RET_SUCCESS -> Success 56 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure 57 | * 58 | */ 59 | int8_t bmm150_user_i2c_reg_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr); 60 | 61 | /*! 62 | * @brief This function is for writing the sensor's registers through I2C bus. 63 | * 64 | * @param[in] reg_addr : Register address. 65 | * @param[in] reg_data : Pointer to the data buffer whose value is to be written. 66 | * @param[in] length : No of bytes to write. 67 | * @param[in] intf_ptr : Pointer to interface. 68 | * 69 | * @return Status of execution 70 | * 71 | * @retval = BMM150_INTF_RET_SUCCESS -> Success 72 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure 73 | * 74 | */ 75 | int8_t bmm150_user_i2c_reg_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr); 76 | 77 | /*! 78 | * @brief This function is for reading the sensor's registers through SPI bus. 79 | * 80 | * @param[in] reg_addr : Register address. 81 | * @param[out] reg_data: Pointer to the data buffer to store the read data. 82 | * @param[in] length : No of bytes to read. 83 | * @param[in] intf_ptr : Pointer to interface. 84 | * 85 | * @return Status of execution 86 | * 87 | * @retval = BMM150_INTF_RET_SUCCESS -> Success 88 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure 89 | * 90 | */ 91 | int8_t bmm150_user_spi_reg_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr); 92 | 93 | /*! 94 | * @brief This function is for writing the sensor's registers through SPI bus. 95 | * 96 | * @param[in] reg_addr : Register address. 97 | * @param[in] reg_data : Pointer to the data buffer whose data has to be written. 98 | * @param[in] length : No of bytes to write. 99 | * @param[in] intf_ptr : Pointer to interface. 100 | * 101 | * @return Status of execution 102 | * 103 | * @retval = BMM150_INTF_RET_SUCCESS -> Success 104 | * @retval != BMM150_INTF_RET_SUCCESS -> Failure 105 | * 106 | */ 107 | int8_t bmm150_user_spi_reg_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr); 108 | 109 | /*! 110 | * @brief This function is to select the interface between SPI and I2C. 111 | * 112 | * @param[in] dev : Structure instance of bmm150_dev 113 | * 114 | * @return Status of execution 115 | * @retval 0 -> Success 116 | * @retval < 0 -> Failure Info 117 | */ 118 | int8_t bmm150_interface_selection(struct bmm150_dev *dev); 119 | 120 | /*! 121 | * @brief This API is used to print the execution status. 122 | * 123 | * @param[in] api_name : Name of the API whose execution status has to be printed. 124 | * @param[in] rslt : Error code returned by the API whose execution status has to be printed. 125 | * 126 | * @return void. 127 | */ 128 | void bmm150_error_codes_print_result(const char api_name[], int8_t rslt); 129 | 130 | #ifdef __cplusplus 131 | } 132 | #endif /* End of CPP guard */ 133 | 134 | #endif /* _BMM150_COMMON_H */ 135 | -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/generic/high_threshold/Makefile: -------------------------------------------------------------------------------- 1 | REPO_COINES_PATH ?= ../../../submodules/coines 2 | 3 | MAIN_FILE ?= high_threshold_interrupt.c 4 | 5 | C_SRCS += \ 6 | ../../../source/bmm150.c \ 7 | ../common/common.c 8 | 9 | INCLUDEPATHS += \ 10 | ../../../source \ 11 | ../common 12 | 13 | include ../../../scripts/coines.mk -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/generic/high_threshold/high_threshold_interrupt.c: -------------------------------------------------------------------------------- 1 | /**\ 2 | * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | **/ 6 | 7 | /******************************************************************************/ 8 | /*! Header Files */ 9 | #include 10 | #include "bmm150.h" 11 | #include "bmm150_common.h" 12 | 13 | /******************************************************************************/ 14 | /*! Static Function Declaration */ 15 | 16 | /*! 17 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 18 | * 19 | * @param[in] dev : Structure instance of bmm150_dev. 20 | * 21 | * @return Status of execution. 22 | */ 23 | static int8_t set_config(struct bmm150_dev *dev); 24 | 25 | /******************************************************************************/ 26 | /*! Functions */ 27 | 28 | /* This function starts the execution of program. */ 29 | int main(void) 30 | { 31 | /* Status of api are returned to this variable */ 32 | int8_t rslt; 33 | 34 | /* Sensor initialization configuration. */ 35 | struct bmm150_dev dev; 36 | 37 | rslt = bmm150_interface_selection(&dev); 38 | bmm150_error_codes_print_result("bmm150_interface_selection", rslt); 39 | 40 | if (rslt == BMM150_OK) 41 | { 42 | rslt = bmm150_init(&dev); 43 | bmm150_error_codes_print_result("bmm150_init", rslt); 44 | 45 | if (rslt == BMM150_OK) 46 | { 47 | rslt = set_config(&dev); 48 | bmm150_error_codes_print_result("set_config", rslt); 49 | } 50 | 51 | while (1) 52 | { 53 | /* Get the interrupt status */ 54 | rslt = bmm150_get_interrupt_status(&dev); 55 | 56 | if (dev.int_status & BMM150_INT_ASSERTED_HIGH_THRES) 57 | { 58 | printf("High threshold interrupt occured"); 59 | break; 60 | } 61 | } 62 | } 63 | 64 | return rslt; 65 | } 66 | 67 | /*! 68 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 69 | */ 70 | static int8_t set_config(struct bmm150_dev *dev) 71 | { 72 | /* Status of api are returned to this variable. */ 73 | int8_t rslt; 74 | 75 | struct bmm150_settings settings; 76 | 77 | /* Read the default configuration from the sensor */ 78 | settings.pwr_mode = BMM150_POWERMODE_NORMAL; 79 | rslt = bmm150_set_op_mode(&settings, dev); 80 | bmm150_error_codes_print_result("bmm150_set_op_mode", rslt); 81 | 82 | if (rslt == BMM150_OK) 83 | { 84 | /* Set any threshold level above which high threshold interrupt occurs */ 85 | settings.int_settings.high_threshold = 0x14; 86 | rslt = bmm150_set_sensor_settings(BMM150_SEL_HIGH_THRESHOLD_SETTING, &settings, dev); 87 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_1", rslt); 88 | 89 | if (rslt == BMM150_OK) 90 | { 91 | rslt = bmm150_get_sensor_settings(&settings, dev); 92 | bmm150_error_codes_print_result("bmm150_get_sensor_settings", rslt); 93 | printf("High threshold: %d \n", settings.int_settings.high_threshold); 94 | } 95 | 96 | if (rslt == BMM150_OK) 97 | { 98 | /* High interrupt pins are active low as per datasheet */ 99 | settings.int_settings.high_int_en = 0x00; 100 | rslt = bmm150_set_sensor_settings(BMM150_SEL_HIGH_THRESHOLD_INT, &settings, dev); 101 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_2", rslt); 102 | 103 | if (rslt == BMM150_OK) 104 | { 105 | settings.int_settings.int_pin_en = 0x01; 106 | rslt = bmm150_set_sensor_settings(BMM150_SEL_INT_PIN_EN, &settings, dev); 107 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_3", rslt); 108 | } 109 | } 110 | } 111 | 112 | return rslt; 113 | } 114 | -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/generic/low_threshold/Makefile: -------------------------------------------------------------------------------- 1 | REPO_COINES_PATH ?= ../../../submodules/coines 2 | 3 | MAIN_FILE ?= low_threshold_interrupt.c 4 | 5 | C_SRCS += \ 6 | ../../../source/bmm150.c \ 7 | ../common/common.c 8 | 9 | INCLUDEPATHS += \ 10 | ../../../source \ 11 | ../common 12 | 13 | include ../../../scripts/coines.mk -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/generic/low_threshold/low_threshold_interrupt.c: -------------------------------------------------------------------------------- 1 | /**\ 2 | * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | **/ 6 | 7 | /******************************************************************************/ 8 | /*! Header Files */ 9 | #include 10 | #include "bmm150.h" 11 | #include "bmm150_common.h" 12 | 13 | /******************************************************************************/ 14 | /*! Static Function Declaration */ 15 | 16 | /*! 17 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 18 | * 19 | * @param[in] dev : Structure instance of bmm150_dev. 20 | * 21 | * @return Status of execution. 22 | */ 23 | static int8_t set_config(struct bmm150_dev *dev); 24 | 25 | /******************************************************************************/ 26 | /*! Functions */ 27 | 28 | /* This function starts the execution of program. */ 29 | int main(void) 30 | { 31 | /* Status of api are returned to this variable */ 32 | int8_t rslt; 33 | 34 | /* Sensor initialization configuration. */ 35 | struct bmm150_dev dev; 36 | 37 | rslt = bmm150_interface_selection(&dev); 38 | bmm150_error_codes_print_result("bmm150_interface_selection", rslt); 39 | 40 | if (rslt == BMM150_OK) 41 | { 42 | rslt = bmm150_init(&dev); 43 | bmm150_error_codes_print_result("bmm150_init", rslt); 44 | 45 | if (rslt == BMM150_OK) 46 | { 47 | rslt = set_config(&dev); 48 | bmm150_error_codes_print_result("set_config", rslt); 49 | } 50 | 51 | while (1) 52 | { 53 | /* Get the interrupt status */ 54 | rslt = bmm150_get_interrupt_status(&dev); 55 | 56 | if (dev.int_status & BMM150_INT_ASSERTED_LOW_THRES) 57 | { 58 | printf("Low threshold interrupt occured"); 59 | break; 60 | } 61 | } 62 | } 63 | 64 | return rslt; 65 | } 66 | 67 | /*! 68 | * @brief This internal API is used to set configurations like threshold and interrupt mapping. 69 | */ 70 | static int8_t set_config(struct bmm150_dev *dev) 71 | { 72 | /* Status of api are returned to this variable. */ 73 | int8_t rslt; 74 | 75 | struct bmm150_settings settings; 76 | 77 | /* Read the default configuration from the sensor */ 78 | settings.pwr_mode = BMM150_POWERMODE_NORMAL; 79 | rslt = bmm150_set_op_mode(&settings, dev); 80 | bmm150_error_codes_print_result("bmm150_set_op_mode", rslt); 81 | 82 | if (rslt == BMM150_OK) 83 | { 84 | /* Set any threshold level below which low threshold interrupt occurs */ 85 | settings.int_settings.low_threshold = 0x0A; 86 | rslt = bmm150_set_sensor_settings(BMM150_SEL_LOW_THRESHOLD_SETTING, &settings, dev); 87 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_1", rslt); 88 | 89 | if (rslt == BMM150_OK) 90 | { 91 | rslt = bmm150_get_sensor_settings(&settings, dev); 92 | bmm150_error_codes_print_result("bmm150_get_sensor_settings", rslt); 93 | printf("Low threshold: %d \n", settings.int_settings.low_threshold); 94 | } 95 | 96 | if (rslt == BMM150_OK) 97 | { 98 | /* Low interrupt pins are active low as per datasheet */ 99 | settings.int_settings.low_int_en = 0x00; 100 | rslt = bmm150_set_sensor_settings(BMM150_SEL_LOW_THRESHOLD_INT, &settings, dev); 101 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_2", rslt); 102 | 103 | if (rslt == BMM150_OK) 104 | { 105 | settings.int_settings.int_pin_en = 0x01; 106 | rslt = bmm150_set_sensor_settings(BMM150_SEL_INT_PIN_EN, &settings, dev); 107 | bmm150_error_codes_print_result("bmm150_set_sensor_settings_3", rslt); 108 | } 109 | } 110 | } 111 | 112 | return rslt; 113 | } 114 | -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/generic/mag_drdy_interrupt/Makefile: -------------------------------------------------------------------------------- 1 | REPO_COINES_PATH ?= ../../../submodules/coines 2 | 3 | MAIN_FILE ?= mag_drdy_interrupt.c 4 | 5 | C_SRCS += \ 6 | ../../../source/bmm150.c \ 7 | ../common/common.c 8 | 9 | INCLUDEPATHS += \ 10 | ../../../source \ 11 | ../common 12 | 13 | include ../../../scripts/coines.mk -------------------------------------------------------------------------------- /lib/BMM150-Sensor-API/examples/generic/mag_drdy_interrupt/mag_drdy_interrupt.c: -------------------------------------------------------------------------------- 1 | /**\ 2 | * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | **/ 6 | 7 | /******************************************************************************/ 8 | /*! Header Files */ 9 | #include 10 | #include "bmm150.h" 11 | #include "bmm150_common.h" 12 | 13 | /******************************************************************************/ 14 | /*! Static Function Declaration */ 15 | 16 | /*! 17 | * @brief This internal API is used to set configurations powermode, odr and interrupt mapping. 18 | * 19 | * @param[in] dev : Structure instance of bmm150_dev. 20 | * 21 | * @return Status of execution. 22 | */ 23 | static int8_t set_config(struct bmm150_dev *dev); 24 | 25 | /*! 26 | * @brief This internal API is used to get gyro data. 27 | * 28 | * @param[in] dev : Structure instance of bmm150_dev. 29 | * 30 | * @return Status of execution. 31 | */ 32 | static int8_t get_data(struct bmm150_dev *dev); 33 | 34 | /******************************************************************************/ 35 | /*! Functions */ 36 | 37 | /* This function starts the execution of program. */ 38 | int main(void) 39 | { 40 | /* Status of api are returned to this variable */ 41 | int8_t rslt; 42 | 43 | /* Sensor initialization configuration. */ 44 | struct bmm150_dev dev; 45 | 46 | rslt = bmm150_interface_selection(&dev); 47 | bmm150_error_codes_print_result("bmm150_interface_selection", rslt); 48 | 49 | if (rslt == BMM150_OK) 50 | { 51 | rslt = bmm150_init(&dev); 52 | bmm150_error_codes_print_result("bmm150_init", rslt); 53 | 54 | if (rslt == BMM150_OK) 55 | { 56 | rslt = set_config(&dev); 57 | bmm150_error_codes_print_result("set_config", rslt); 58 | 59 | if (rslt == BMM150_OK) 60 | { 61 | rslt = get_data(&dev); 62 | bmm150_error_codes_print_result("get_data", rslt); 63 | } 64 | } 65 | } 66 | 67 | return rslt; 68 | } 69 | 70 | /*! 71 | * @brief This internal API is used to set configurations like powermode, odr and interrupt mapping. 72 | */ 73 | static int8_t set_config(struct bmm150_dev *dev) 74 | { 75 | /* Status of api are returned to this variable. */ 76 | int8_t rslt; 77 | 78 | struct bmm150_settings settings; 79 | 80 | /* Set powermode as normal mode */ 81 | settings.pwr_mode = BMM150_POWERMODE_NORMAL; 82 | rslt = bmm150_set_op_mode(&settings, dev); 83 | bmm150_error_codes_print_result("bmm150_set_op_mode", rslt); 84 | 85 | if (rslt == BMM150_OK) 86 | { 87 | /* Setting the preset mode as Low power mode 88 | * i.e. data rate = 10Hz, XY-rep = 1, Z-rep = 2 89 | */ 90 | settings.preset_mode = BMM150_PRESETMODE_LOWPOWER; 91 | rslt = bmm150_set_presetmode(&settings, dev); 92 | bmm150_error_codes_print_result("bmm150_set_presetmode", rslt); 93 | 94 | if (rslt == BMM150_OK) 95 | { 96 | /* Map the data interrupt pin */ 97 | settings.int_settings.drdy_pin_en = 0x01; 98 | rslt = bmm150_set_sensor_settings(BMM150_SEL_DRDY_PIN_EN, &settings, dev); 99 | bmm150_error_codes_print_result("bmm150_set_sensor_settings", rslt); 100 | } 101 | } 102 | 103 | return rslt; 104 | } 105 | 106 | /*! 107 | * @brief This internal API is used to get gyro data. 108 | */ 109 | static int8_t get_data(struct bmm150_dev *dev) 110 | { 111 | /* Status of api are returned to this variable. */ 112 | int8_t rslt; 113 | 114 | int8_t idx; 115 | 116 | struct bmm150_mag_data mag_data; 117 | 118 | /* Reading the mag data */ 119 | while (1) 120 | { 121 | /* Get the interrupt status */ 122 | rslt = bmm150_get_interrupt_status(dev); 123 | 124 | if (dev->int_status & BMM150_INT_ASSERTED_DRDY) 125 | { 126 | printf("Data interrupt occurred\n"); 127 | 128 | for (idx = 0; idx < 50; idx++) 129 | { 130 | /* Read mag data */ 131 | rslt = bmm150_read_mag_data(&mag_data, dev); 132 | bmm150_error_codes_print_result("bmm150_read_mag_data", rslt); 133 | 134 | /* Unit for magnetometer data is microtesla(uT) */ 135 | printf("MAG DATA[%d] X : %d uT Y : %d uT Z : %d uT\n", idx, mag_data.x, mag_data.y, mag_data.z); 136 | } 137 | } 138 | 139 | break; 140 | } 141 | 142 | return rslt; 143 | } 144 | -------------------------------------------------------------------------------- /lib/PageManager/PM_Log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #ifndef __PM_LOG_H 24 | #define __PM_LOG_H 25 | 26 | #define PAGE_MANAGER_USE_LOG 1 27 | 28 | #if !defined(ARDUINO) && PAGE_MANAGER_USE_LOG 29 | #include 30 | # define _PM_LOG(format, ...) printf("[PM]" format "\r\n", ##__VA_ARGS__) 31 | # define PM_LOG_INFO(format, ...) //_PM_LOG("[Info] " format, ##__VA_ARGS__) 32 | # define PM_LOG_WARN(format, ...) _PM_LOG("[Warn] " format, ##__VA_ARGS__) 33 | # define PM_LOG_ERROR(format, ...) _PM_LOG("[Error] " format, ##__VA_ARGS__) 34 | #else 35 | #include 36 | // # define _PM_LOG(format, ...) Serial.printf("[PM]" format "\r\n", ##__VA_ARGS__) 37 | # define _PM_LOG(format, ...) 38 | # define PM_LOG_INFO(format, ...) _PM_LOG("[Info] " format, ##__VA_ARGS__) 39 | # define PM_LOG_WARN(format, ...) _PM_LOG("[Warn] " format, ##__VA_ARGS__) 40 | # define PM_LOG_ERROR(format, ...) _PM_LOG("[Error] " format, ##__VA_ARGS__) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/PageManager/PageBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #include "PageBase.h" 24 | #include "PM_Log.h" 25 | 26 | void PageBase::SetCustomCacheEnable(bool en) 27 | { 28 | PM_LOG_INFO("Page(%s) %s = %d", _Name, __func__, en); 29 | SetCustomAutoCacheEnable(false); 30 | priv.ReqEnableCache = en; 31 | } 32 | 33 | void PageBase::SetCustomAutoCacheEnable(bool en) 34 | { 35 | PM_LOG_INFO("Page(%s) %s = %d", _Name, __func__, en); 36 | priv.ReqDisableAutoCache = !en; 37 | } 38 | 39 | void PageBase::SetCustomLoadAnimType( 40 | uint8_t animType, 41 | uint16_t time, 42 | lv_anim_path_cb_t path 43 | ) 44 | { 45 | priv.Anim.Attr.Type = animType; 46 | priv.Anim.Attr.Time = time; 47 | priv.Anim.Attr.Path = path; 48 | } 49 | 50 | bool PageBase::StashPop(void* ptr, uint32_t size) 51 | { 52 | if (priv.Stash.ptr == nullptr) 53 | { 54 | PM_LOG_WARN("No Stash found"); 55 | return false; 56 | } 57 | 58 | if (priv.Stash.size != size) 59 | { 60 | PM_LOG_WARN( 61 | "Stash[0x%p](%d) does not match the size(%d)", 62 | priv.Stash.ptr, 63 | priv.Stash.size, 64 | size 65 | ); 66 | return false; 67 | } 68 | 69 | memcpy(ptr, priv.Stash.ptr, priv.Stash.size); 70 | lv_mem_free(priv.Stash.ptr); 71 | priv.Stash.ptr = nullptr; 72 | return false; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /lib/PageManager/PageFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #ifndef __PAGE_FACTORY_H 24 | #define __PAGE_FACTORY_H 25 | 26 | #include "PageBase.h" 27 | 28 | class PageFactory 29 | { 30 | public: 31 | 32 | virtual PageBase* CreatePage(const char* name) 33 | { 34 | return nullptr; 35 | }; 36 | }; 37 | 38 | 39 | #endif // !__PAGE_FACTORY_H 40 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /lib/ResourceManager/ResourceManager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #include "ResourceManager.h" 24 | #include 25 | #include 26 | #include "lvgl.h" 27 | 28 | #define RES_LOG_INFO LV_LOG_INFO 29 | #define RES_LOG_WARN LV_LOG_WARN 30 | #define RES_LOG_ERROR LV_LOG_ERROR 31 | 32 | ResourceManager::ResourceManager() 33 | { 34 | DefaultPtr = nullptr; 35 | } 36 | 37 | ResourceManager::~ResourceManager() 38 | { 39 | } 40 | 41 | /** 42 | * @brief Search resource node based on name 43 | * @param name: Resource Name 44 | * @param node: Pointer to the resource node 45 | * @retval Return true if the search is successful 46 | */ 47 | bool ResourceManager::SearchNode(const char* name, ResourceNode_t* node) 48 | { 49 | for(auto iter : NodePool) 50 | { 51 | if (strcmp(name, iter.name) == 0) 52 | { 53 | *node = iter; 54 | return true; 55 | } 56 | } 57 | return false; 58 | } 59 | 60 | /** 61 | * @brief Add resources to the resource pool 62 | * @param name: Resource Name 63 | * @param ptr: Pointer to the resource 64 | * @retval Return true if the addition is successful 65 | */ 66 | bool ResourceManager::AddResource(const char* name, void* ptr) 67 | { 68 | ResourceNode_t node; 69 | if (SearchNode(name, &node)) 70 | { 71 | RES_LOG_WARN("Resource: %s was register", name); 72 | return false; 73 | } 74 | 75 | node.name = name; 76 | node.ptr = ptr; 77 | NodePool.push_back(node); 78 | 79 | RES_LOG_INFO("Resource: %s[0x%p] add success", node.name, node.ptr); 80 | 81 | return true; 82 | } 83 | 84 | /** 85 | * @brief Remove resources from the resource pool 86 | * @param name: Resource Name 87 | * @retval Return true if the removal is successful 88 | */ 89 | bool ResourceManager::RemoveResource(const char* name) 90 | { 91 | ResourceNode_t node; 92 | if(!SearchNode(name, &node)) 93 | { 94 | RES_LOG_ERROR("Resource: %s was not found", name); 95 | return false; 96 | } 97 | 98 | auto iter = std::find(NodePool.begin(), NodePool.end(), node); 99 | 100 | if (iter == NodePool.end()) 101 | { 102 | RES_LOG_ERROR("Resource: %s was not found", name); 103 | return false; 104 | } 105 | 106 | NodePool.erase(iter); 107 | 108 | RES_LOG_INFO("Resource: %s remove success", name); 109 | 110 | return true; 111 | } 112 | 113 | /** 114 | * @brief Get resource address 115 | * @param name: Resource Name 116 | * @retval If the acquisition is successful, return the address of the resource, otherwise return the default resource 117 | */ 118 | void* ResourceManager::GetResource(const char* name) 119 | { 120 | ResourceNode_t node; 121 | 122 | if(!SearchNode(name, &node)) 123 | { 124 | RES_LOG_WARN("Resource: %s was not found, return default[0x%p]", name, DefaultPtr); 125 | return DefaultPtr; 126 | } 127 | 128 | RES_LOG_INFO("Resource: %s[0x%p] was found", name, node.ptr); 129 | 130 | return node.ptr; 131 | } 132 | 133 | /** 134 | * @brief Set default resources 135 | * @param ptr: Pointer to the default resource 136 | * @retval None 137 | */ 138 | void ResourceManager::SetDefault(void* ptr) 139 | { 140 | DefaultPtr = ptr; 141 | RES_LOG_INFO("Resource: set [0x%p] to default", DefaultPtr); 142 | } 143 | -------------------------------------------------------------------------------- /lib/ResourceManager/ResourceManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #ifndef __RESOURCE_MANAGER_H 24 | #define __RESOURCE_MANAGER_H 25 | 26 | #include 27 | 28 | class ResourceManager 29 | { 30 | 31 | public: 32 | ResourceManager(); 33 | ~ResourceManager(); 34 | 35 | bool AddResource(const char* name, void* ptr); 36 | bool RemoveResource(const char* name); 37 | void* GetResource(const char* name); 38 | void SetDefault(void* ptr); 39 | 40 | private: 41 | typedef struct ResourceNode 42 | { 43 | const char* name; 44 | void* ptr; 45 | 46 | bool operator==(const struct ResourceNode n) const 47 | { 48 | return (this->name == n.name && this->ptr == n.ptr); 49 | } 50 | } ResourceNode_t; 51 | 52 | private: 53 | std::vector NodePool; 54 | void* DefaultPtr; 55 | bool SearchNode(const char* name, ResourceNode_t* node); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lib/libesp32-camera.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/lib/libesp32-camera.a -------------------------------------------------------------------------------- /lib/lv_anim_label/lv_anim_label.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_anim_label.h 3 | * 4 | */ 5 | 6 | #ifndef LV_ANIM_LABEL_H 7 | #define LV_ANIM_LABEL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lvgl.h" 17 | 18 | typedef struct { 19 | lv_obj_t obj; 20 | lv_obj_t * label_1; 21 | lv_obj_t * label_2; 22 | lv_obj_t * label_act; 23 | lv_dir_t enter_dir; 24 | lv_dir_t exit_dir; 25 | lv_anim_t a_enter; 26 | lv_anim_t a_exit; 27 | uint32_t duration; 28 | lv_anim_path_cb_t path_cb; 29 | }lv_anim_label_t; 30 | 31 | extern const lv_obj_class_t lv_anim_label_class; 32 | 33 | lv_obj_t * lv_anim_label_create(lv_obj_t * parent); 34 | 35 | void lv_anim_label_set_dir(lv_obj_t * obj, lv_dir_t dir); 36 | 37 | void lv_anim_label_set_enter_dir(lv_obj_t * obj, lv_dir_t dir); 38 | 39 | void lv_anim_label_set_exit_dir(lv_obj_t * obj, lv_dir_t dir); 40 | 41 | void lv_anim_label_set_time(lv_obj_t * obj, uint32_t duration); 42 | 43 | void lv_anim_label_set_path(lv_obj_t * obj, lv_anim_path_cb_t path_cb); 44 | 45 | void lv_anim_label_add_style(lv_obj_t * obj, lv_style_t * style); 46 | 47 | void lv_anim_label_set_custom_enter_anim(lv_obj_t * obj, const lv_anim_t * a); 48 | 49 | void lv_anim_label_set_custom_exit_anim(lv_obj_t * obj, const lv_anim_t * a); 50 | 51 | void lv_anim_label_push_text(lv_obj_t * obj, const char* txt); 52 | 53 | lv_dir_t lv_anim_label_get_enter_dir(lv_obj_t * obj); 54 | 55 | lv_dir_t lv_anim_label_get_exit_dir(lv_obj_t * obj); 56 | 57 | uint32_t lv_anim_label_get_time(lv_obj_t * obj); 58 | 59 | lv_anim_path_cb_t lv_anim_label_get_path(lv_obj_t * obj); 60 | 61 | const char * lv_anim_label_get_text(lv_obj_t * obj); 62 | 63 | #ifdef __cplusplus 64 | } /*extern "C"*/ 65 | #endif 66 | 67 | #endif /*LV_ANIM_LABEL_H*/ 68 | -------------------------------------------------------------------------------- /lib/lv_ext/lv_anim_timeline_wrapper.c: -------------------------------------------------------------------------------- 1 | #include "lv_anim_timeline_wrapper.h" 2 | 3 | void lv_anim_timeline_add_wrapper(lv_anim_timeline_t* at, const lv_anim_timeline_wrapper_t* wrapper) 4 | { 5 | for(uint32_t i = 0; wrapper[i].obj != NULL; i++) 6 | { 7 | const lv_anim_timeline_wrapper_t* atw = &wrapper[i]; 8 | 9 | lv_anim_t a; 10 | lv_anim_init(&a); 11 | lv_anim_set_var(&a, atw->obj); 12 | lv_anim_set_values(&a, atw->start, atw->end); 13 | lv_anim_set_exec_cb(&a, atw->exec_cb); 14 | lv_anim_set_time(&a, atw->duration); 15 | lv_anim_set_path_cb(&a, atw->path_cb); 16 | lv_anim_set_early_apply(&a, atw->early_apply); 17 | 18 | lv_anim_timeline_add(at, atw->start_time, &a); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/lv_ext/lv_anim_timeline_wrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef LV_ANIM_TIMELINE_WRAPPER_H 2 | #define LV_ANIM_TIMELINE_WRAPPER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "lvgl.h" 9 | 10 | /*Data of anim_timeline*/ 11 | typedef struct { 12 | uint32_t start_time; 13 | lv_obj_t* obj; 14 | lv_anim_exec_xcb_t exec_cb; 15 | int32_t start; 16 | int32_t end; 17 | uint16_t duration; 18 | lv_anim_path_cb_t path_cb; 19 | bool early_apply; 20 | } lv_anim_timeline_wrapper_t; 21 | 22 | /********************** 23 | * GLOBAL PROTOTYPES 24 | **********************/ 25 | 26 | /** 27 | * Start animation according to the timeline 28 | * @param anim_timeline timeline array address 29 | * @param playback whether to play in reverse 30 | * @return timeline total time spent 31 | */ 32 | void lv_anim_timeline_add_wrapper(lv_anim_timeline_t* at, const lv_anim_timeline_wrapper_t* wrapper); 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | #define LV_ANIM_TIMELINE_WRAPPER_END {0, NULL} 39 | 40 | #ifdef __cplusplus 41 | } /*extern "C"*/ 42 | #endif 43 | 44 | #endif /*LV_ANIM_TIMELINE_wrapper_H*/ 45 | -------------------------------------------------------------------------------- /lib/lv_ext/lv_obj_ext_func.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #include "lv_obj_ext_func.h" 24 | 25 | void lv_obj_set_opa_scale(lv_obj_t* obj, int16_t opa) 26 | { 27 | lv_obj_set_style_bg_opa(obj, (lv_opa_t)opa, LV_PART_MAIN); 28 | } 29 | 30 | int16_t lv_obj_get_opa_scale(lv_obj_t* obj) 31 | { 32 | return lv_obj_get_style_bg_opa(obj, LV_PART_MAIN); 33 | } 34 | 35 | /** 36 | * @brief 在label后追加字符串 37 | * @param label:被追加的对象 38 | * @param text:追加的字符串 39 | * @retval 无 40 | */ 41 | void lv_label_set_text_add(lv_obj_t * label, const char * text) 42 | { 43 | if(!label) 44 | return; 45 | 46 | lv_label_ins_text(label, (uint32_t)strlen(lv_label_get_text(label)), text); 47 | } 48 | 49 | /** 50 | * @brief 为对象添加动画 51 | * @param obj:对象地址 52 | * @param a:动画控制器地址 53 | * @param exec_cb:控制对象属性的函数地址 54 | * @param start:动画的开始值 55 | * @param end:动画的结束值 56 | * @param time:动画的执行时间 57 | * @param delay:动画开始前的延时时间 58 | * @param ready_cb:动画结束事件回调 59 | * @param path_cb:动画曲线 60 | * @retval 无 61 | */ 62 | void lv_obj_add_anim( 63 | lv_obj_t * obj, lv_anim_t * a, 64 | lv_anim_exec_xcb_t exec_cb, 65 | int32_t start, int32_t end, 66 | uint16_t time, 67 | uint32_t delay, 68 | lv_anim_ready_cb_t ready_cb, 69 | lv_anim_path_cb_t path_cb 70 | ) 71 | { 72 | lv_anim_t anim_temp; 73 | 74 | if (a == NULL) 75 | { 76 | a = &anim_temp; 77 | 78 | /* INITIALIZE AN ANIMATION 79 | *-----------------------*/ 80 | lv_anim_init(a); 81 | } 82 | 83 | /* MANDATORY SETTINGS 84 | *------------------*/ 85 | 86 | /*Set the "animator" function*/ 87 | lv_anim_set_exec_cb(a, exec_cb); 88 | 89 | /*Set the "animator" function*/ 90 | lv_anim_set_var(a, obj); 91 | 92 | /*Length of the animation [ms]*/ 93 | lv_anim_set_time(a, time); 94 | 95 | /*Set start and end values. E.g. 0, 150*/ 96 | lv_anim_set_values(a, start, end); 97 | 98 | 99 | /* OPTIONAL SETTINGS 100 | *------------------*/ 101 | 102 | /*Time to wait before starting the animation [ms]*/ 103 | lv_anim_set_delay(a, delay); 104 | 105 | /*Set the path in an animation*/ 106 | lv_anim_set_path_cb(a, path_cb); 107 | 108 | /*Set a callback to call when animation is ready.*/ 109 | lv_anim_set_ready_cb(a, ready_cb); 110 | 111 | /*Set a callback to call when animation is started (after delay).*/ 112 | lv_anim_set_start_cb(a, ready_cb); 113 | 114 | /* START THE ANIMATION 115 | *------------------*/ 116 | lv_anim_start(a); /*Start the animation*/ 117 | } 118 | 119 | lv_indev_t* lv_get_indev(lv_indev_type_t type) 120 | { 121 | lv_indev_t* cur_indev = NULL; 122 | for (;;) 123 | { 124 | cur_indev = lv_indev_get_next(cur_indev); 125 | if (!cur_indev) 126 | { 127 | break; 128 | } 129 | 130 | if (cur_indev->driver->type == type) 131 | { 132 | return cur_indev; 133 | } 134 | } 135 | return NULL; 136 | } 137 | -------------------------------------------------------------------------------- /lib/lv_ext/lv_obj_ext_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #ifndef __LV_OBJ_EXT_FUNC_H 24 | #define __LV_OBJ_EXT_FUNC_H 25 | 26 | #include "lvgl.h" 27 | 28 | #define LV_ANIM_TIME_DEFAULT 400 29 | #define LV_ANIM_EXEC(attr) (lv_anim_exec_xcb_t)lv_obj_set_##attr 30 | 31 | void lv_obj_set_opa_scale(lv_obj_t* obj, int16_t opa); 32 | int16_t lv_obj_get_opa_scale(lv_obj_t* obj); 33 | void lv_label_set_text_add(lv_obj_t * label, const char * text); 34 | void lv_obj_add_anim( 35 | lv_obj_t * obj, lv_anim_t * a, 36 | lv_anim_exec_xcb_t exec_cb, 37 | int32_t start, int32_t end, 38 | uint16_t time = LV_ANIM_TIME_DEFAULT, 39 | uint32_t delay = 0, 40 | lv_anim_ready_cb_t ready_cb = NULL, 41 | lv_anim_path_cb_t path_cb = lv_anim_path_ease_out 42 | ); 43 | #define LV_OBJ_ADD_ANIM(obj,attr,target,time)\ 44 | do{\ 45 | lv_obj_add_anim(\ 46 | (obj), NULL,\ 47 | (lv_anim_exec_xcb_t)lv_obj_set_##attr,\ 48 | lv_obj_get_##attr(obj),\ 49 | (target),\ 50 | (time)\ 51 | );\ 52 | }while(0) 53 | #define LV_OBJ_ADD_DELAY_ANIM(obj,attr,target,delay,time)\ 54 | do{\ 55 | lv_obj_add_anim(\ 56 | (obj), NULL,\ 57 | (lv_anim_exec_xcb_t)lv_obj_set_##attr,\ 58 | lv_obj_get_##attr(obj),\ 59 | (target),\ 60 | (time),\ 61 | (delay)\ 62 | );\ 63 | }while(0) 64 | lv_indev_t* lv_get_indev(lv_indev_type_t type); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /lib/lv_poly_line/lv_poly_line.h: -------------------------------------------------------------------------------- 1 | #ifndef LV_POLY_LINE_H 2 | #define LV_POLY_LINE_H 3 | 4 | #include "lvgl.h" 5 | #include 6 | 7 | class lv_poly_line 8 | { 9 | public: 10 | lv_poly_line(lv_obj_t* par); 11 | ~lv_poly_line(); 12 | 13 | void set_style(lv_style_t* style) 14 | { 15 | styleLine = style; 16 | } 17 | 18 | void start(); 19 | void append(const lv_point_t* point); 20 | void append(lv_coord_t x, lv_coord_t y) 21 | { 22 | lv_point_t point = { x, y }; 23 | append(&point); 24 | } 25 | void append_to_end(const lv_point_t* point); 26 | void append_to_end(lv_coord_t x, lv_coord_t y) 27 | { 28 | lv_point_t point = { x, y }; 29 | append_to_end(&point); 30 | } 31 | void stop(); 32 | void reset(); 33 | bool get_end_point(lv_point_t* point); 34 | 35 | private: 36 | typedef struct 37 | { 38 | lv_obj_t* line; 39 | std::vector points; 40 | } single_line_t; 41 | 42 | private: 43 | void add_line(); 44 | void refresh_line(); 45 | single_line_t* get_end_line(); 46 | const lv_point_t* get_points(single_line_t* single_line); 47 | 48 | private: 49 | std::vector poly_line; 50 | uint32_t current_index; 51 | lv_style_t* styleLine; 52 | lv_obj_t* parent; 53 | }; 54 | 55 | #endif // !LV_POLY_LINE_H 56 | -------------------------------------------------------------------------------- /lib/m5gfx_lvgl/m5gfx_lvgl.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "m5gfx_lvgl.h" 3 | 4 | SemaphoreHandle_t xGuiSemaphore; 5 | static lv_disp_draw_buf_t draw_buf; 6 | 7 | LV_IMG_DECLARE(cursor_hand); 8 | 9 | static void m5gfx_lvgl_flush(lv_disp_drv_t *disp, const lv_area_t *area, 10 | lv_color_t *color_p) { 11 | int w = (area->x2 - area->x1 + 1); 12 | int h = (area->y2 - area->y1 + 1); 13 | 14 | M5.Display.startWrite(); 15 | M5.Display.setAddrWindow(area->x1, area->y1, w, h); 16 | M5.Display.writePixels((lgfx::swap565_t *)&color_p->full, w * h); 17 | M5.Display.endWrite(); 18 | lv_disp_flush_ready(disp); 19 | } 20 | 21 | static void m5gfx_lvgl_read(lv_indev_drv_t *indev_driver, 22 | lv_indev_data_t *data) { 23 | uint16_t touchX, touchY; 24 | lgfx::touch_point_t tp[1]; 25 | 26 | M5.update(); 27 | 28 | M5.Display.getTouchRaw(&touchX, &touchY); 29 | 30 | int nums = M5.Display.getTouchRaw(tp, 1); 31 | if (nums) { 32 | data->state = LV_INDEV_STATE_PR; 33 | data->point.x = tp[0].x; 34 | data->point.y = tp[0].y; 35 | } else { 36 | data->state = LV_INDEV_STATE_REL; 37 | } 38 | 39 | // bool touched = M5.Display.getTouch(&touchX, &touchY); 40 | // if (!touched) { 41 | // data->state = LV_INDEV_STATE_REL; 42 | // } else { 43 | // data->state = LV_INDEV_STATE_PR; 44 | // data->point.x = touchX; 45 | // data->point.y = touchY; 46 | // } 47 | } 48 | 49 | static void lvgl_tick_task(void *arg) { 50 | (void)arg; 51 | lv_tick_inc(LV_TICK_PERIOD_MS); 52 | } 53 | 54 | void m5gfx_lvgl_init(void) { 55 | static lv_color_t *buf1 = (lv_color_t *)heap_caps_malloc( 56 | LCD_WIDTH * 80 * sizeof(lv_color_t), MALLOC_CAP_SPIRAM); 57 | static lv_color_t *buf2 = (lv_color_t *)heap_caps_malloc( 58 | LCD_WIDTH * 80 * sizeof(lv_color_t), MALLOC_CAP_SPIRAM); 59 | 60 | lv_disp_draw_buf_init(&draw_buf, buf1, buf2, LCD_WIDTH * 80); 61 | static lv_disp_drv_t disp_drv; 62 | lv_disp_drv_init(&disp_drv); 63 | disp_drv.hor_res = LCD_WIDTH; 64 | disp_drv.ver_res = LCD_HEIGHT; 65 | disp_drv.flush_cb = m5gfx_lvgl_flush; 66 | disp_drv.draw_buf = &draw_buf; 67 | lv_disp_drv_register(&disp_drv); 68 | 69 | static lv_indev_drv_t indev_drv; 70 | lv_indev_drv_init(&indev_drv); 71 | indev_drv.type = LV_INDEV_TYPE_POINTER; 72 | indev_drv.read_cb = m5gfx_lvgl_read; 73 | lv_indev_t *indev = lv_indev_drv_register(&indev_drv); 74 | 75 | // Uncomment this to enable cursor icon 76 | // lv_obj_t *cursor = lv_img_create(lv_scr_act()); 77 | // lv_img_set_src(cursor, &cursor_hand); 78 | // lv_indev_set_cursor(indev, cursor); 79 | 80 | xGuiSemaphore = xSemaphoreCreateMutex(); 81 | const esp_timer_create_args_t periodic_timer_args = { 82 | .callback = &lvgl_tick_task, .name = "periodic_gui"}; 83 | esp_timer_handle_t periodic_timer; 84 | ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer)); 85 | ESP_ERROR_CHECK( 86 | esp_timer_start_periodic(periodic_timer, LV_TICK_PERIOD_MS * 1000)); 87 | } -------------------------------------------------------------------------------- /lib/m5gfx_lvgl/m5gfx_lvgl.h: -------------------------------------------------------------------------------- 1 | #ifndef __M5GFX_LVGL_H__ 2 | #define __M5GFX_LVGL_H__ 3 | 4 | #include "lvgl.h" 5 | #include "M5Unified.h" 6 | #include "M5GFX.h" 7 | 8 | void m5gfx_lvgl_init(void); 9 | 10 | #endif // __M5GFX_LVGL_H__ -------------------------------------------------------------------------------- /partitions_ffat.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | nvs, data, nvs, 0x9000, 0x5000, 3 | otadata, data, ota, 0xe000, 0x2000, 4 | factory, app, factory, 0x10000, 7M, 5 | #ffat, data, fat, , 1M, 6 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env] 12 | platform = espressif32@6.1.0 13 | board = esp32-s3-devkitc-1 14 | framework = arduino 15 | board_build.f_cpu = 240000000L 16 | board_build.f_flash = 80000000L 17 | board_build.flash_mode = qio 18 | board_build.flash_size = 16MB 19 | board_build.partitions = ./partitions_ffat.csv 20 | ; platform_packages = 21 | ; platformio/framework-arduinoespressif32@^3.20007.0 22 | build_flags = 23 | -std=c++11 24 | -DBOARD_HAS_PSRAM 25 | -DCORE_DEBUG_LEVEL=0 26 | -Iinclude 27 | -DLV_CONF_INCLUDE_SIMPLE 28 | -DLV_LVGL_H_INCLUDE_SIMPLE 29 | -DLCD_HEIGHT=240 30 | -DLCD_WIDTH=320 31 | -DLV_TICK_PERIOD_MS=10 32 | -DMONKEY_TEST_ENABLE=0 33 | lib_deps = 34 | m5stack/M5GFX@^0.1.6 35 | m5stack/M5Unified@^0.1.6 36 | lvgl/lvgl@^8.3.4 37 | espressif/esp32-camera@^2.0.0 38 | arduino-libraries/Madgwick@^1.2.0 39 | 40 | [env:M5CoreS3] 41 | build_flags = 42 | ${env.build_flags} 43 | -DM5CORES3 44 | 45 | [env:M5CoreS3SE] 46 | build_flags = 47 | ${env.build_flags} 48 | -DM5CORES3SE -------------------------------------------------------------------------------- /src/App.cpp: -------------------------------------------------------------------------------- 1 | #include "PageManager.h" 2 | #include "res/ResourcePool.h" 3 | #include "pages/AppFactory.h" 4 | 5 | void App_Init() { 6 | static AppFactory factory; 7 | static PageManager manager(&factory); 8 | 9 | /* Make sure the default group exists */ 10 | if (!lv_group_get_default()) { 11 | lv_group_t* group = lv_group_create(); 12 | lv_group_set_default(group); 13 | } 14 | 15 | #if MONKEY_TEST_ENABLE 16 | lv_monkey_config_t config; 17 | lv_monkey_config_init(&config); 18 | config.type = LV_INDEV_TYPE_POINTER; 19 | config.period_range.min = 20; 20 | config.period_range.max = 50; 21 | config.input_range.min = 0; 22 | config.input_range.max = 320; 23 | lv_monkey_t* monkey = lv_monkey_create(&config); 24 | lv_monkey_set_enable(monkey, true); 25 | 26 | lv_group_t* group = lv_group_create(); 27 | lv_indev_set_group(lv_monkey_get_indev(monkey), group); 28 | lv_group_set_default(group); 29 | 30 | LV_LOG_USER("lv_monkey test started!"); 31 | #endif 32 | /* Set screen style */ 33 | lv_obj_t* scr = lv_scr_act(); 34 | lv_obj_remove_style_all(scr); 35 | lv_obj_set_style_bg_opa(lv_scr_act(), LV_OPA_TRANSP, 0); 36 | lv_obj_clear_flag(scr, LV_OBJ_FLAG_SCROLLABLE); 37 | lv_obj_clear_flag(scr, LV_OBJ_FLAG_GESTURE_BUBBLE); 38 | lv_disp_set_bg_color(lv_disp_get_default(), lv_color_white()); 39 | 40 | /* Set root default style */ 41 | static lv_style_t rootStyle; 42 | lv_style_init(&rootStyle); 43 | lv_style_set_width(&rootStyle, LV_HOR_RES); 44 | lv_style_set_height(&rootStyle, LV_VER_RES); 45 | lv_style_set_border_color(&rootStyle, lv_color_make(238, 238, 238)); 46 | lv_style_set_border_width(&rootStyle, 0); 47 | lv_style_set_outline_width(&rootStyle, 0); 48 | lv_style_set_pad_all(&rootStyle, 0); 49 | manager.SetRootDefaultStyle(&rootStyle); 50 | 51 | /* Initialize resource pool */ 52 | ResourcePool::Init(); 53 | 54 | /* Initialize pages */ 55 | manager.Install("StartUp", "Pages/StartUp"); 56 | manager.Install("HomeMenu", "Pages/HomeMenu"); 57 | manager.Install("AppWiFi", "Pages/AppWiFi"); 58 | manager.Install("AppCamera", "Pages/AppCamera"); 59 | manager.Install("AppMic", "Pages/AppMic"); 60 | manager.Install("AppPower", "Pages/AppPower"); 61 | manager.Install("AppIMU", "Pages/AppIMU"); 62 | manager.Install("AppSD", "Pages/AppSD"); 63 | manager.Install("AppTouch", "Pages/AppTouch"); 64 | manager.Install("AppI2C", "Pages/AppI2C"); 65 | manager.Install("AppRTC", "Pages/AppRTC"); 66 | 67 | manager.SetGlobalLoadAnimType(PageManager::LOAD_ANIM_NONE); 68 | 69 | manager.Push("Pages/StartUp"); 70 | } 71 | 72 | void App_Uninit() { 73 | } 74 | -------------------------------------------------------------------------------- /src/App.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #ifndef __APP_H 24 | #define __APP_H 25 | 26 | void App_Init(void); 27 | void App_Uninit(void); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "config.h" 8 | #include "M5GFX.h" 9 | #include "M5Unified.h" 10 | #include "lvgl.h" 11 | #include "m5gfx_lvgl.h" 12 | #include "esp_camera.h" 13 | 14 | #include "App.h" 15 | 16 | void setup() { 17 | esp_err_t ret = nvs_flash_init(); 18 | if (ret == ESP_ERR_NVS_NO_FREE_PAGES || 19 | ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { 20 | ESP_ERROR_CHECK(nvs_flash_erase()); 21 | ret = nvs_flash_init(); 22 | } 23 | 24 | USBSerial.begin(15200); 25 | M5.begin(); 26 | 27 | #if defined(M5CORES3) 28 | USBSerial.printf("M5CoreS3 User Demo, Version: %s\r\n", DEMO_VERSION); 29 | #elif defined(M5CORES3SE) 30 | USBSerial.printf("M5CoreS3SE User Demo, Version: %s\r\n", DEMO_VERSION); 31 | #endif 32 | 33 | // BM8563 Init (clear INT) 34 | M5.In_I2C.writeRegister8(0x51, 0x00, 0x00, 100000L); 35 | M5.In_I2C.writeRegister8(0x51, 0x01, 0x00, 100000L); 36 | M5.In_I2C.writeRegister8(0x51, 0x0D, 0x00, 100000L); 37 | 38 | // AW9523 Control BOOST 39 | M5.In_I2C.bitOn(AW9523_ADDR, 0x03, 0b10000000, 100000L); // BOOST_EN 40 | 41 | #if MONKEY_TEST_ENABLE 42 | M5.Speaker.setAllChannelVolume(0); 43 | #endif 44 | M5.Display.setBrightness(60); 45 | 46 | lv_init(); 47 | m5gfx_lvgl_init(); 48 | 49 | App_Init(); 50 | } 51 | 52 | void loop() { 53 | 54 | lv_timer_handler(); 55 | delay(10); 56 | } 57 | -------------------------------------------------------------------------------- /src/pages/AppCamera/AppCamera.cpp: -------------------------------------------------------------------------------- 1 | #include "AppCamera.h" 2 | 3 | using namespace Page; 4 | 5 | AppCamera::AppCamera() : timer(nullptr) { 6 | } 7 | 8 | AppCamera::~AppCamera() { 9 | } 10 | 11 | void AppCamera::onCustomAttrConfig() { 12 | LV_LOG_USER(__func__); 13 | } 14 | 15 | void AppCamera::onViewLoad() { 16 | LV_LOG_USER(__func__); 17 | View.Create(_root); 18 | 19 | Model.LTR553Init(); 20 | Model.CameraInit(); 21 | 22 | AttachEvent(_root); 23 | AttachEvent(View.ui.imgbtn_home, LV_EVENT_CLICKED); 24 | AttachEvent(View.ui.imgbtn_next, LV_EVENT_CLICKED); 25 | } 26 | 27 | void AppCamera::onViewDidLoad() { 28 | LV_LOG_USER(__func__); 29 | } 30 | 31 | void AppCamera::onViewWillAppear() { 32 | LV_LOG_USER(__func__); 33 | 34 | timer = lv_timer_create(onTimerUpdate, 30, this); 35 | } 36 | 37 | void AppCamera::onViewDidAppear() { 38 | LV_LOG_USER(__func__); 39 | } 40 | 41 | void AppCamera::onViewWillDisappear() { 42 | LV_LOG_USER(__func__); 43 | } 44 | 45 | void AppCamera::onViewDidDisappear() { 46 | LV_LOG_USER(__func__); 47 | lv_timer_del(timer); 48 | } 49 | 50 | void AppCamera::onViewUnload() { 51 | LV_LOG_USER(__func__); 52 | 53 | View.Delete(); 54 | Model.ReleaseFramebuffer(); 55 | Model.CameraDeinit(); 56 | } 57 | 58 | void AppCamera::onViewDidUnload() { 59 | LV_LOG_USER(__func__); 60 | } 61 | 62 | void AppCamera::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 63 | lv_obj_set_user_data(obj, this); 64 | lv_obj_add_event_cb(obj, onEvent, code, this); 65 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 66 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 67 | } 68 | 69 | void AppCamera::Update() { 70 | if (Model.GetFramebuffer()) { 71 | M5.Display.startWrite(); 72 | M5.Display.setAddrWindow(25, 90, 160, 120); 73 | M5.Display.writePixels((uint16_t*)Model.fb->buf, 74 | int(Model.fb->len / 2)); 75 | M5.Display.endWrite(); 76 | } 77 | Model.ReleaseFramebuffer(); 78 | 79 | uint32_t als_ch0 = Model.GetLTR553AlsCh0Value(); 80 | uint32_t als_ch1 = Model.GetLTR553AlsCh1Value(); 81 | uint16_t ps = Model.GetLTR553PsValue(); 82 | 83 | // USBSerial.printf("als ch0: %d, als ch1: %d, ps: %d\r\n", als_ch0, als_ch1, 84 | // ps); 85 | 86 | uint8_t als_num = map(als_ch0, 0, 0x50, 0, 9); 87 | uint8_t ps_num = map(ps, 0, 0x800, 0, 9); 88 | 89 | // USBSerial.printf("als num: %d, ps num: %d\r\n", als_num, ps_num); 90 | 91 | for (size_t i = 0; i < 8; i++) { 92 | lv_obj_add_flag(View.ui.obj_ltr553_als_list[i], LV_OBJ_FLAG_HIDDEN); 93 | lv_obj_add_flag(View.ui.obj_ltr553_ps_list[i], LV_OBJ_FLAG_HIDDEN); 94 | } 95 | 96 | for (size_t i = 0; i < (als_num > 8 ? 8 : als_num); i++) { 97 | lv_obj_clear_flag(View.ui.obj_ltr553_als_list[i], LV_OBJ_FLAG_HIDDEN); 98 | } 99 | 100 | for (size_t i = 0; i < (ps_num > 8 ? 8 : ps_num); i++) { 101 | lv_obj_clear_flag(View.ui.obj_ltr553_ps_list[i], LV_OBJ_FLAG_HIDDEN); 102 | } 103 | } 104 | 105 | void AppCamera::onTimerUpdate(lv_timer_t* timer) { 106 | AppCamera* instance = (AppCamera*)timer->user_data; 107 | 108 | instance->Update(); 109 | } 110 | 111 | void AppCamera::onEvent(lv_event_t* event) { 112 | AppCamera* instance = (AppCamera*)lv_event_get_user_data(event); 113 | LV_ASSERT_NULL(instance); 114 | 115 | lv_obj_t* obj = lv_event_get_current_target(event); 116 | lv_event_code_t code = lv_event_get_code(event); 117 | 118 | if (obj == instance->_root) { 119 | if (code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LEAVE) { 120 | // instance->_Manager->Pop(); 121 | } 122 | } else { 123 | if (code == LV_EVENT_CLICKED) { 124 | if (obj == instance->View.ui.imgbtn_home) { 125 | M5.Speaker.playWav( 126 | (const uint8_t*)ResourcePool::GetWav("select_0_5s"), ~0u, 1, 127 | 1); 128 | instance->_Manager->Replace("Pages/HomeMenu"); 129 | } else if (obj == instance->View.ui.imgbtn_next) { 130 | USBSerial.print("AppCamera -> AppMic\r\n"); 131 | instance->_Manager->Replace("Pages/AppMic"); 132 | } 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/pages/AppCamera/AppCamera.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPCAMERA_PRESENTER_H 2 | #define __APPCAMERA_PRESENTER_H 3 | 4 | #include "AppCameraView.h" 5 | #include "AppCameraModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppCamera : public PageBase { 10 | public: 11 | AppCamera(); 12 | virtual ~AppCamera(); 13 | 14 | virtual void onCustomAttrConfig(); 15 | virtual void onViewLoad(); 16 | virtual void onViewDidLoad(); 17 | virtual void onViewWillAppear(); 18 | virtual void onViewDidAppear(); 19 | virtual void onViewWillDisappear(); 20 | virtual void onViewDidDisappear(); 21 | virtual void onViewUnload(); 22 | virtual void onViewDidUnload(); 23 | 24 | private: 25 | void Update(); 26 | void AttachEvent(lv_obj_t* obj) { 27 | AttachEvent(obj, LV_EVENT_ALL); 28 | } 29 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 30 | static void onTimerUpdate(lv_timer_t* timer); 31 | static void onEvent(lv_event_t* event); 32 | 33 | private: 34 | AppCameraView View; 35 | AppCameraModel Model; 36 | lv_timer_t* timer; 37 | }; 38 | 39 | } // namespace Page 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/pages/AppCamera/AppCameraModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppCameraModel.h" 2 | 3 | using namespace Page; 4 | 5 | static camera_config_t camera_config = { 6 | .pin_pwdn = -1, 7 | .pin_reset = -1, 8 | .pin_xclk = 2, 9 | .pin_sscb_sda = 12, 10 | .pin_sscb_scl = 11, 11 | 12 | .pin_d7 = 47, 13 | .pin_d6 = 48, 14 | .pin_d5 = 16, 15 | .pin_d4 = 15, 16 | .pin_d3 = 42, 17 | .pin_d2 = 41, 18 | .pin_d1 = 40, 19 | .pin_d0 = 39, 20 | 21 | .pin_vsync = 46, 22 | .pin_href = 38, 23 | .pin_pclk = 45, 24 | 25 | .xclk_freq_hz = 20000000, 26 | .ledc_timer = LEDC_TIMER_0, 27 | .ledc_channel = LEDC_CHANNEL_0, 28 | 29 | .pixel_format = PIXFORMAT_RGB565, 30 | .frame_size = FRAMESIZE_QQVGA, 31 | .jpeg_quality = 0, 32 | .fb_count = 2, 33 | .fb_location = CAMERA_FB_IN_PSRAM, 34 | .grab_mode = CAMERA_GRAB_WHEN_EMPTY, 35 | }; 36 | 37 | bool AppCameraModel::CameraInit(void) { 38 | M5.In_I2C.release(); 39 | esp_err_t err = esp_camera_init(&camera_config); 40 | if (err != ESP_OK) { 41 | Serial.printf("Camera Init Failed in AppCameraModel\r\n"); 42 | return false; 43 | } 44 | return true; 45 | } 46 | 47 | void AppCameraModel::CameraDeinit(void) { 48 | esp_camera_deinit(); 49 | } 50 | 51 | bool AppCameraModel::GetFramebuffer(void) { 52 | fb = esp_camera_fb_get(); 53 | if (!fb) { 54 | Serial.printf("Camera capture failed in AppCameraModel\r\n"); 55 | return false; 56 | } 57 | return true; 58 | } 59 | 60 | void AppCameraModel::ReleaseFramebuffer(void) { 61 | esp_camera_fb_return(fb); 62 | } 63 | 64 | bool AppCameraModel::LTR553Init() { 65 | // soft reset 66 | uint8_t value_r = M5.In_I2C.readRegister8(LTR553_ADDR, 0x80, 100000L); 67 | value_r &= (~0x02); 68 | uint8_t value_w = value_r | 0x02; 69 | M5.In_I2C.writeRegister8(LTR553_ADDR, 0x80, value_w, 100000L); 70 | 71 | // PS Led Pluse 72 | M5.In_I2C.writeRegister8(LTR553_ADDR, 0x83, 0x0F, 100000L); 73 | // ALS Active Mode 74 | value_r = M5.In_I2C.readRegister8(LTR553_ADDR, 0x80, 100000L); 75 | value_r &= (~0x01); 76 | value_w = value_r | 0x01; 77 | M5.In_I2C.writeRegister8(LTR553_ADDR, 0x80, value_w, 100000L); 78 | // PS Active Mode 79 | value_r = M5.In_I2C.readRegister8(LTR553_ADDR, 0x81, 100000L); 80 | value_r &= (~0x03); 81 | value_w = value_r | 0x03; 82 | M5.In_I2C.writeRegister8(LTR553_ADDR, 0x81, value_w, 100000L); 83 | return true; 84 | } 85 | 86 | uint32_t AppCameraModel::GetLTR553AlsCh0Value() { 87 | uint8_t buffer[2]; 88 | uint32_t result; 89 | M5.In_I2C.readRegister(LTR553_ADDR, 0x8A, buffer, 2, 100000L); 90 | result = (buffer[1] << 8) | buffer[0]; 91 | return result; 92 | } 93 | 94 | uint32_t AppCameraModel::GetLTR553AlsCh1Value() { 95 | uint8_t buffer[2]; 96 | uint32_t result; 97 | M5.In_I2C.readRegister(LTR553_ADDR, 0x88, buffer, 2, 100000L); 98 | result = (buffer[1] << 8) | buffer[0]; 99 | return result; 100 | } 101 | 102 | uint16_t AppCameraModel::GetLTR553PsValue() { 103 | uint8_t buffer[2]; 104 | uint16_t result; 105 | M5.In_I2C.readRegister(LTR553_ADDR, 0x8D, buffer, 2, 100000L); 106 | buffer[0] &= 0xFF; 107 | buffer[1] &= 0x07; 108 | result = (buffer[1] << 8) | buffer[0]; 109 | return result; 110 | } 111 | -------------------------------------------------------------------------------- /src/pages/AppCamera/AppCameraModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPCAMERA_MODEL_H 2 | #define __APPCAMERA_MODEL_H 3 | 4 | #include "lvgl.h" 5 | #include "../Page.h" 6 | 7 | namespace Page { 8 | 9 | class AppCameraModel { 10 | public: 11 | camera_fb_t *fb; 12 | 13 | public: 14 | bool CameraInit(void); 15 | void CameraDeinit(void); 16 | bool GetFramebuffer(void); 17 | void ReleaseFramebuffer(void); 18 | 19 | bool LTR553Init(); 20 | uint32_t GetLTR553AlsCh0Value(); 21 | uint32_t GetLTR553AlsCh1Value(); 22 | uint16_t GetLTR553PsValue(); 23 | 24 | private: 25 | }; 26 | 27 | } // namespace Page 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/pages/AppCamera/AppCameraView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppCameraView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppCameraView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_camera")); 10 | 11 | ui.imgbtn_home = lv_imgbtn_create(root); 12 | lv_obj_set_size(ui.imgbtn_home, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 13 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("home_r"), NULL); 14 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("home_p"), NULL); 15 | lv_obj_align(ui.imgbtn_home, LV_ALIGN_TOP_LEFT, 0, 0); 16 | 17 | ui.imgbtn_next = lv_imgbtn_create(root); 18 | lv_obj_set_size(ui.imgbtn_next, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 19 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("next_r"), NULL); 20 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("next_p"), NULL); 21 | lv_obj_align(ui.imgbtn_next, LV_ALIGN_TOP_RIGHT, 5, 0); 22 | 23 | // static lv_style_t style; 24 | // lv_style_init(&style); 25 | // lv_style_set_border_color(&style, lv_color_hex(0xff931e)); 26 | // lv_style_set_border_side(&style, LV_BORDER_SIDE_FULL); 27 | // lv_style_set_border_width(&style, 2); 28 | // lv_style_set_border_post(&style, true); 29 | 30 | // ui.img_camera = lv_img_create(root); 31 | // lv_obj_set_pos(ui.img_camera, 25, 90); 32 | // lv_obj_add_style(ui.img_camera, &style, 0); 33 | 34 | for (size_t i = 0; i < 8; i++) 35 | { 36 | ui.obj_ltr553_als_list[i] = lv_obj_create(root); 37 | lv_obj_remove_style_all(ui.obj_ltr553_als_list[i]); 38 | lv_obj_set_size(ui.obj_ltr553_als_list[i], 20, 10); 39 | lv_obj_set_pos(ui.obj_ltr553_als_list[i], 226, 197 - i * 15); 40 | 41 | lv_obj_set_style_bg_opa(ui.obj_ltr553_als_list[i], LV_OPA_COVER, 0); 42 | lv_obj_set_style_bg_color(ui.obj_ltr553_als_list[i], lv_color_hex(0x008fd7), 0); 43 | lv_obj_add_flag(ui.obj_ltr553_als_list[i], LV_OBJ_FLAG_HIDDEN); 44 | } 45 | 46 | for (size_t i = 0; i < 8; i++) 47 | { 48 | ui.obj_ltr553_ps_list[i] = lv_obj_create(root); 49 | lv_obj_remove_style_all(ui.obj_ltr553_ps_list[i]); 50 | lv_obj_set_size(ui.obj_ltr553_ps_list[i], 20, 10); 51 | lv_obj_set_pos(ui.obj_ltr553_ps_list[i], 266, 197 - i * 15); 52 | 53 | lv_obj_set_style_bg_opa(ui.obj_ltr553_ps_list[i], LV_OPA_COVER, 0); 54 | lv_obj_set_style_bg_color(ui.obj_ltr553_ps_list[i], lv_color_hex(0xe95a6f), 0); 55 | lv_obj_add_flag(ui.obj_ltr553_ps_list[i], LV_OBJ_FLAG_HIDDEN); 56 | } 57 | 58 | ui.btn_top_center = lv_btn_create(root); 59 | lv_obj_remove_style_all(ui.btn_top_center); 60 | lv_obj_set_size(ui.btn_top_center, 170, 68); 61 | lv_obj_align(ui.btn_top_center, LV_ALIGN_TOP_MID, 0, 0); 62 | 63 | // lv_obj_set_style_border_color(ui.btn_top_center, lv_color_hex(0xff00ff), 0); 64 | // lv_obj_set_style_border_side(ui.btn_top_center, LV_BORDER_SIDE_FULL, 0); 65 | // lv_obj_set_style_border_width(ui.btn_top_center, 1, 0); 66 | // lv_obj_set_style_radius(ui.btn_top_center, 0, 0); 67 | // lv_obj_set_style_border_post(ui.btn_top_center, true, 0); 68 | } 69 | 70 | void AppCameraView::Delete() { 71 | } 72 | -------------------------------------------------------------------------------- /src/pages/AppCamera/AppCameraView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPCAMERA_VIEW_H 2 | #define __APPCAMERA_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppCameraView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* img_bg; 16 | lv_obj_t* imgbtn_home; 17 | lv_obj_t* imgbtn_next; 18 | lv_obj_t* btn_top_center; 19 | 20 | lv_obj_t* obj_ltr553_als_list[8]; 21 | lv_obj_t* obj_ltr553_ps_list[8]; 22 | 23 | // lv_img_dsc_t img_dsc; 24 | // lv_obj_t* img_camera; 25 | } ui; 26 | 27 | private: 28 | }; 29 | 30 | } // namespace Page 31 | 32 | #endif // !__VIEW_H 33 | -------------------------------------------------------------------------------- /src/pages/AppFactory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #include "AppFactory.h" 24 | #include "StartUp/StartUp.h" 25 | #include "HomeMenu/HomeMenu.h" 26 | #include "AppWiFi/AppWiFi.h" 27 | #include "AppCamera/AppCamera.h" 28 | #include "AppMic/AppMic.h" 29 | #include "AppPower/AppPower.h" 30 | #include "AppIMU/AppIMU.h" 31 | #include "AppSD/AppSD.h" 32 | #include "AppTouch/AppTouch.h" 33 | #include "AppI2C/AppI2C.h" 34 | #include "AppRTC/AppRTC.h" 35 | 36 | #define APP_CLASS_MATCH(className) \ 37 | do { \ 38 | if (strcmp(name, #className) == 0) { \ 39 | return new Page::className; \ 40 | } \ 41 | } while (0) 42 | 43 | PageBase* AppFactory::CreatePage(const char* name) { 44 | APP_CLASS_MATCH(StartUp); 45 | APP_CLASS_MATCH(HomeMenu); 46 | APP_CLASS_MATCH(AppWiFi); 47 | APP_CLASS_MATCH(AppCamera); 48 | APP_CLASS_MATCH(AppMic); 49 | APP_CLASS_MATCH(AppPower); 50 | APP_CLASS_MATCH(AppIMU); 51 | APP_CLASS_MATCH(AppSD); 52 | APP_CLASS_MATCH(AppTouch); 53 | APP_CLASS_MATCH(AppI2C); 54 | APP_CLASS_MATCH(AppRTC); 55 | 56 | return nullptr; 57 | } 58 | -------------------------------------------------------------------------------- /src/pages/AppFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #include "PageManager.h" 24 | 25 | class AppFactory : public PageFactory 26 | { 27 | public: 28 | virtual PageBase* CreatePage(const char* name); 29 | private: 30 | 31 | }; 32 | 33 | -------------------------------------------------------------------------------- /src/pages/AppI2C/AppI2C.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPI2C_PRESENTER_H 2 | #define __APPI2C_PRESENTER_H 3 | 4 | #include "AppI2CView.h" 5 | #include "AppI2CModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppI2C : public PageBase { 10 | public: 11 | uint8_t port_index = 0; 12 | bool scan_flag = false; 13 | public: 14 | AppI2C(); 15 | virtual ~AppI2C(); 16 | 17 | virtual void onCustomAttrConfig(); 18 | virtual void onViewLoad(); 19 | virtual void onViewDidLoad(); 20 | virtual void onViewWillAppear(); 21 | virtual void onViewDidAppear(); 22 | virtual void onViewWillDisappear(); 23 | virtual void onViewDidDisappear(); 24 | virtual void onViewUnload(); 25 | virtual void onViewDidUnload(); 26 | 27 | private: 28 | void Update(); 29 | void AttachEvent(lv_obj_t* obj) { 30 | AttachEvent(obj, LV_EVENT_ALL); 31 | } 32 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 33 | static void onTimerUpdate(lv_timer_t* timer); 34 | static void onEvent(lv_event_t* event); 35 | 36 | private: 37 | AppI2CView View; 38 | AppI2CModel Model; 39 | lv_timer_t* timer; 40 | }; 41 | 42 | } // namespace Page 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/pages/AppI2C/AppI2CModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppI2CModel.h" 2 | 3 | using namespace Page; 4 | -------------------------------------------------------------------------------- /src/pages/AppI2C/AppI2CModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPI2C_MODEL_H 2 | #define __APPI2C_MODEL_H 3 | 4 | #include "lvgl.h" 5 | #include "config.h" 6 | 7 | namespace Page { 8 | 9 | class AppI2CModel { 10 | public: 11 | private: 12 | }; 13 | 14 | } // namespace Page 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/pages/AppI2C/AppI2CView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppI2CView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppI2CView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_i2c_internal")); 10 | 11 | ui.imgbtn_home = lv_imgbtn_create(root); 12 | lv_obj_set_size(ui.imgbtn_home, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 13 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("home_r"), NULL); 14 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("home_p"), NULL); 15 | lv_obj_align(ui.imgbtn_home, LV_ALIGN_TOP_LEFT, 0, 0); 16 | 17 | ui.imgbtn_next = lv_imgbtn_create(root); 18 | lv_obj_set_size(ui.imgbtn_next, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 19 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("next_r"), NULL); 20 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("next_p"), NULL); 21 | lv_obj_align(ui.imgbtn_next, LV_ALIGN_TOP_RIGHT, 5, 0); 22 | 23 | ui.btn_top_center = lv_btn_create(root); 24 | lv_obj_remove_style_all(ui.btn_top_center); 25 | lv_obj_set_size(ui.btn_top_center, 170, 68); 26 | lv_obj_align(ui.btn_top_center, LV_ALIGN_TOP_MID, 0, 0); 27 | 28 | // lv_obj_set_style_border_color(ui.btn_top_center, lv_color_hex(0xff00ff), 0); 29 | // lv_obj_set_style_border_side(ui.btn_top_center, LV_BORDER_SIDE_FULL, 0); 30 | // lv_obj_set_style_border_width(ui.btn_top_center, 1, 0); 31 | // lv_obj_set_style_radius(ui.btn_top_center, 0, 0); 32 | // lv_obj_set_style_border_post(ui.btn_top_center, true, 0); 33 | 34 | ui.cont_addr = lv_obj_create(root); 35 | lv_obj_remove_style_all(ui.cont_addr); 36 | lv_obj_set_size(ui.cont_addr, 320, 172); 37 | lv_obj_clear_flag(ui.cont_addr, LV_OBJ_FLAG_SCROLLABLE); 38 | lv_obj_set_pos(ui.cont_addr, 0, 68); 39 | 40 | // lv_obj_set_style_border_color(ui.cont_addr, lv_color_hex(0xff00ff), 0); 41 | // lv_obj_set_style_border_side(ui.cont_addr, LV_BORDER_SIDE_FULL, 0); 42 | // lv_obj_set_style_border_width(ui.cont_addr, 1, 0); 43 | // lv_obj_set_style_radius(ui.cont_addr, 0, 0); 44 | // lv_obj_set_style_border_post(ui.cont_addr, true, 0); 45 | 46 | ui.btn_scan_again = lv_btn_create(root); 47 | lv_obj_remove_style_all(ui.btn_scan_again); 48 | lv_obj_set_size(ui.btn_scan_again, 320, 172); 49 | lv_obj_clear_flag(ui.btn_scan_again, LV_OBJ_FLAG_SCROLLABLE); 50 | lv_obj_set_pos(ui.btn_scan_again, 0, 68); 51 | 52 | ui.label_notice = lv_label_create(root); 53 | lv_label_set_text(ui.label_notice, "Scan I2C Devices..."); 54 | lv_obj_align(ui.label_notice, LV_ALIGN_CENTER, 15, 40); 55 | } 56 | 57 | void AppI2CView::Delete() { 58 | } 59 | 60 | void AppI2CView::ChangeBgImg(uint8_t index) { 61 | switch (index) { 62 | case 0: 63 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_i2c_internal")); 64 | break; 65 | case 1: 66 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_i2c_pa")); 67 | break; 68 | case 2: 69 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_i2c_pb")); 70 | break; 71 | case 3: 72 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_i2c_pc")); 73 | break; 74 | default: 75 | break; 76 | } 77 | } -------------------------------------------------------------------------------- /src/pages/AppI2C/AppI2CView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPI2C_VIEW_H 2 | #define __APPI2C_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppI2CView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | void ChangeBgImg(uint8_t index); 13 | 14 | public: 15 | struct { 16 | lv_obj_t* img_bg; 17 | lv_obj_t* imgbtn_home; 18 | lv_obj_t* imgbtn_next; 19 | lv_obj_t* btn_top_center; 20 | 21 | lv_obj_t* cont_addr; 22 | lv_obj_t* label_notice; 23 | lv_obj_t* btn_scan_again; 24 | } ui; 25 | 26 | private: 27 | }; 28 | 29 | } // namespace Page 30 | 31 | #endif // !__VIEW_H 32 | -------------------------------------------------------------------------------- /src/pages/AppIMU/AppIMU.cpp: -------------------------------------------------------------------------------- 1 | #include "AppIMU.h" 2 | 3 | using namespace Page; 4 | 5 | AppIMU::AppIMU() : timer(nullptr) { 6 | Model.Init(); 7 | Model.filter.begin(20); // 20hz 8 | } 9 | 10 | AppIMU::~AppIMU() { 11 | } 12 | 13 | void AppIMU::onCustomAttrConfig() { 14 | LV_LOG_USER(__func__); 15 | } 16 | 17 | void AppIMU::onViewLoad() { 18 | LV_LOG_USER(__func__); 19 | View.Create(_root); 20 | 21 | AttachEvent(_root); 22 | AttachEvent(View.ui.imgbtn_home, LV_EVENT_CLICKED); 23 | AttachEvent(View.ui.imgbtn_next, LV_EVENT_CLICKED); 24 | AttachEvent(View.ui.btn_top_center, LV_EVENT_CLICKED); 25 | 26 | if (!Model.ReadCalibration()) { 27 | lv_obj_clear_flag(View.ui.label_notice, LV_OBJ_FLAG_HIDDEN); 28 | } 29 | } 30 | 31 | void AppIMU::onViewDidLoad() { 32 | LV_LOG_USER(__func__); 33 | } 34 | 35 | void AppIMU::onViewWillAppear() { 36 | LV_LOG_USER(__func__); 37 | 38 | timer = lv_timer_create(onTimerUpdate, 30, this); 39 | } 40 | 41 | void AppIMU::onViewDidAppear() { 42 | LV_LOG_USER(__func__); 43 | } 44 | 45 | void AppIMU::onViewWillDisappear() { 46 | LV_LOG_USER(__func__); 47 | } 48 | 49 | void AppIMU::onViewDidDisappear() { 50 | LV_LOG_USER(__func__); 51 | lv_timer_del(timer); 52 | } 53 | 54 | void AppIMU::onViewUnload() { 55 | LV_LOG_USER(__func__); 56 | 57 | View.Delete(); 58 | } 59 | 60 | void AppIMU::onViewDidUnload() { 61 | LV_LOG_USER(__func__); 62 | } 63 | 64 | void AppIMU::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 65 | lv_obj_set_user_data(obj, this); 66 | lv_obj_add_event_cb(obj, onEvent, code, this); 67 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 68 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 69 | } 70 | 71 | void AppIMU::Update() { 72 | Model.Update(); 73 | 74 | float dir = Model.CalcuDir(); 75 | 76 | if (calibration_flag) { 77 | Model.MagCalibration(); 78 | calibration_flag = false; 79 | lv_label_set_text(View.ui.label_notice, 80 | "Calibration is complete, if you need to calibrate " 81 | "again, please click the top icon again."); 82 | Model.SaveCalibration(); 83 | } 84 | 85 | Model.filter.updateIMU(Model.gyro_data.x, Model.gyro_data.y, 86 | Model.gyro_data.z, Model.accel_data.x, 87 | Model.accel_data.y, Model.accel_data.z); 88 | 89 | float roll = Model.filter.getRoll(); 90 | float pitch = Model.filter.getPitch(); 91 | float yaw = Model.filter.getYaw(); 92 | 93 | if (abs(roll) > 90) { 94 | if (roll < -90) { 95 | roll = -90; 96 | } else { 97 | roll = 90; 98 | } 99 | } 100 | if (abs(pitch) > 90) { 101 | if (pitch < -90) { 102 | pitch = -90; 103 | } else { 104 | pitch = 90; 105 | } 106 | } 107 | 108 | uint16_t x = (uint16_t)map(pitch, -90.0f, 90.0f, -48, 48); 109 | uint16_t y = (uint16_t)map(roll, -90.0f, 90.0f, -48, 48); 110 | 111 | lv_obj_align_to(View.ui.img_ball, View.ui.img_compass, LV_ALIGN_CENTER, x, 112 | y); 113 | 114 | float angle = ((360 - dir) + 90) * 10; 115 | lv_img_set_angle(View.ui.img_compass, angle); 116 | } 117 | 118 | void AppIMU::onTimerUpdate(lv_timer_t* timer) { 119 | AppIMU* instance = (AppIMU*)timer->user_data; 120 | 121 | instance->Update(); 122 | } 123 | 124 | void AppIMU::onEvent(lv_event_t* event) { 125 | AppIMU* instance = (AppIMU*)lv_event_get_user_data(event); 126 | LV_ASSERT_NULL(instance); 127 | 128 | lv_obj_t* obj = lv_event_get_current_target(event); 129 | lv_event_code_t code = lv_event_get_code(event); 130 | 131 | if (obj == instance->_root) { 132 | if (code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LEAVE) { 133 | // instance->_Manager->Pop(); 134 | } 135 | } else { 136 | if (code == LV_EVENT_CLICKED) { 137 | if (obj == instance->View.ui.btn_top_center) { 138 | instance->calibration_flag = true; 139 | return; 140 | } 141 | M5.Speaker.playWav( 142 | (const uint8_t*)ResourcePool::GetWav("select_0_5s"), ~0u, 1, 1); 143 | if (obj == instance->View.ui.imgbtn_home) { 144 | instance->_Manager->Replace("Pages/HomeMenu"); 145 | } else if (obj == instance->View.ui.imgbtn_next) { 146 | USBSerial.print("AppIMU -> AppSD\r\n"); 147 | instance->_Manager->Replace("Pages/AppSD"); 148 | } 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/pages/AppIMU/AppIMU.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPIMU_PRESENTER_H 2 | #define __APPIMU_PRESENTER_H 3 | 4 | #include "AppIMUView.h" 5 | #include "AppIMUModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppIMU : public PageBase { 10 | public: 11 | struct ball_t { 12 | uint16_t x = 0; 13 | uint16_t y = 0; 14 | uint16_t r = 0; 15 | float dir = 0; 16 | }ball; 17 | bool calibration_flag = false; 18 | public: 19 | AppIMU(); 20 | virtual ~AppIMU(); 21 | 22 | virtual void onCustomAttrConfig(); 23 | virtual void onViewLoad(); 24 | virtual void onViewDidLoad(); 25 | virtual void onViewWillAppear(); 26 | virtual void onViewDidAppear(); 27 | virtual void onViewWillDisappear(); 28 | virtual void onViewDidDisappear(); 29 | virtual void onViewUnload(); 30 | virtual void onViewDidUnload(); 31 | 32 | private: 33 | void Update(); 34 | void AttachEvent(lv_obj_t* obj) { 35 | AttachEvent(obj, LV_EVENT_ALL); 36 | } 37 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 38 | static void onTimerUpdate(lv_timer_t* timer); 39 | static void onEvent(lv_event_t* event); 40 | 41 | float CalcuDir(void); 42 | void MagCalibration(void); 43 | 44 | private: 45 | AppIMUView View; 46 | AppIMUModel Model; 47 | lv_timer_t* timer; 48 | 49 | M5Canvas canvas; 50 | }; 51 | 52 | } // namespace Page 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/pages/AppIMU/AppIMUModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPIMU_MODEL_H 2 | #define __APPIMU_MODEL_H 3 | 4 | #include 5 | #include "lvgl.h" 6 | #include "config.h" 7 | #include "M5Unified.h" 8 | #include "bmi270.h" 9 | #include "bmm150.h" 10 | #include "MadgwickAHRS.h" 11 | 12 | #define ACCEL UINT8_C(0x00) 13 | #define GYRO UINT8_C(0x01) 14 | #define AUX UINT8_C(0x02) 15 | 16 | #define GRAVITY_EARTH (9.80665f) 17 | 18 | namespace Page { 19 | 20 | class AppIMUModel { 21 | public: 22 | struct Accel { 23 | float x; 24 | float y; 25 | float z; 26 | } accel_data; 27 | struct Gyro { 28 | float x; 29 | float y; 30 | float z; 31 | } gyro_data; 32 | struct Mag { 33 | int16_t x; 34 | int16_t y; 35 | int16_t z; 36 | struct Raw { 37 | int16_t x; 38 | int16_t y; 39 | int16_t z; 40 | } raw; 41 | struct Offset { 42 | int16_t x; 43 | int16_t y; 44 | int16_t z; 45 | } offset; 46 | } mag_data; 47 | Madgwick filter; 48 | 49 | public: 50 | AppIMUModel(); 51 | ~AppIMUModel(); 52 | 53 | void Init(); 54 | void Update(); 55 | float CalcuDir(); 56 | void MagCalibration(); 57 | bool ReadCalibration(); 58 | bool SaveCalibration(); 59 | 60 | private: 61 | const uint8_t bmi270_addr = BMI270_ADDR; 62 | const uint8_t bmm150_addr = BMM150_ADDR; 63 | uint8_t sensor_list[3] = {BMI2_ACCEL, BMI2_GYRO, BMI2_AUX}; 64 | uint16_t bmi_bmm_init_status; 65 | 66 | bmi2_sens_config config[3]; 67 | bmi2_sens_data bmi_sensor_data = {{0}}; 68 | 69 | bmm150_settings bmm_settings; 70 | bmm150_mag_data bmm_mag_data; 71 | bmm150_raw_mag_data bmm_raw_mag_data; 72 | 73 | static int8_t bmi2_i2c_read(uint8_t reg_addr, uint8_t *reg_data, 74 | uint32_t len, void *intf_ptr); 75 | static int8_t bmi2_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, 76 | uint32_t len, void *intf_ptr); 77 | static void bmi2_delay_us(uint32_t period, void *intf_ptr); 78 | 79 | static int8_t aux_i2c_read(uint8_t reg_addr, uint8_t *reg_data, 80 | uint32_t length, void *intf_ptr); 81 | static int8_t aux_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, 82 | uint32_t length, void *intf_ptr); 83 | 84 | float lsb_to_mps2(int16_t val, float g_range, uint8_t bit_width) { 85 | float half_scale = ((float)(1 << bit_width) / 2.0f); 86 | 87 | return (GRAVITY_EARTH * val * g_range) / half_scale; 88 | } 89 | 90 | float lsb_to_dps(int16_t val, float dps, uint8_t bit_width) { 91 | float half_scale = ((float)(1 << bit_width) / 2.0f); 92 | 93 | return (dps / ((half_scale))) * (val); 94 | } 95 | }; 96 | 97 | } // namespace Page 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /src/pages/AppIMU/AppIMUView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppIMUView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppIMUView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_imu_graphic")); 10 | 11 | ui.imgbtn_home = lv_imgbtn_create(root); 12 | lv_obj_set_size(ui.imgbtn_home, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 13 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_RELEASED, NULL, 14 | ResourcePool::GetImage("home_r"), NULL); 15 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_PRESSED, NULL, 16 | ResourcePool::GetImage("home_p"), NULL); 17 | lv_obj_align(ui.imgbtn_home, LV_ALIGN_TOP_LEFT, 0, 0); 18 | 19 | ui.imgbtn_next = lv_imgbtn_create(root); 20 | lv_obj_set_size(ui.imgbtn_next, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 21 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_RELEASED, NULL, 22 | ResourcePool::GetImage("next_r"), NULL); 23 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_PRESSED, NULL, 24 | ResourcePool::GetImage("next_p"), NULL); 25 | lv_obj_align(ui.imgbtn_next, LV_ALIGN_TOP_RIGHT, 5, 0); 26 | 27 | ui.btn_top_center = lv_btn_create(root); 28 | lv_obj_remove_style_all(ui.btn_top_center); 29 | lv_obj_set_size(ui.btn_top_center, 170, 68); 30 | lv_obj_align(ui.btn_top_center, LV_ALIGN_TOP_MID, 0, 0); 31 | 32 | // lv_obj_set_style_border_color(ui.btn_top_center, lv_color_hex(0xff00ff), 33 | // 0); lv_obj_set_style_border_side(ui.btn_top_center, LV_BORDER_SIDE_FULL, 34 | // 0); lv_obj_set_style_border_width(ui.btn_top_center, 1, 0); 35 | // lv_obj_set_style_radius(ui.btn_top_center, 0, 0); 36 | // lv_obj_set_style_border_post(ui.btn_top_center, true, 0); 37 | 38 | ui.img_compass = lv_img_create(root); 39 | lv_img_set_src(ui.img_compass, ResourcePool::GetImage("compass_face")); 40 | lv_obj_align(ui.img_compass, LV_ALIGN_BOTTOM_MID, 0, -25); 41 | 42 | ui.img_cross = lv_img_create(root); 43 | lv_img_set_src(ui.img_cross, ResourcePool::GetImage("cross")); 44 | lv_obj_align_to(ui.img_cross, ui.img_compass, LV_ALIGN_CENTER, 0, -24); 45 | 46 | ui.img_ball = lv_img_create(root); 47 | lv_img_set_src(ui.img_ball, ResourcePool::GetImage("ball")); 48 | lv_obj_align_to(ui.img_ball, ui.img_compass, LV_ALIGN_CENTER, 0, 0); 49 | 50 | ui.label_notice = lv_label_create(root); 51 | lv_obj_set_width(ui.label_notice, 310); 52 | lv_label_set_text( 53 | ui.label_notice, 54 | "Sorry, the calibration data of the compass is not found. Please click " 55 | "the icon in the middle of the top to calibrate. The calibration takes " 56 | "a total of 10s. It starts after the beep sounds and ends after the " 57 | "beep sounds again. Please use the standard figure-8 method for " 58 | "calibration."); 59 | lv_obj_align(ui.label_notice, LV_ALIGN_BOTTOM_MID, 0, 0); 60 | lv_label_set_long_mode(ui.label_notice, LV_LABEL_LONG_SCROLL_CIRCULAR); 61 | lv_obj_add_flag(ui.label_notice, LV_OBJ_FLAG_HIDDEN); 62 | } 63 | 64 | void AppIMUView::Delete() { 65 | } -------------------------------------------------------------------------------- /src/pages/AppIMU/AppIMUView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPIMU_VIEW_H 2 | #define __APPIMU_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppIMUView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* img_bg; 16 | lv_obj_t* imgbtn_home; 17 | lv_obj_t* imgbtn_next; 18 | lv_obj_t* btn_top_center; 19 | 20 | lv_obj_t* btn_calibration; 21 | lv_obj_t* label_notice; 22 | lv_obj_t* img_compass; 23 | lv_obj_t* img_cross; 24 | lv_obj_t* img_ball; 25 | } ui; 26 | 27 | private: 28 | }; 29 | 30 | } // namespace Page 31 | 32 | #endif // !__VIEW_H 33 | -------------------------------------------------------------------------------- /src/pages/AppMic/AppMic.cpp: -------------------------------------------------------------------------------- 1 | #include "AppMic.h" 2 | 3 | using namespace Page; 4 | 5 | AppMic::AppMic() : timer(nullptr) { 6 | canvas[0].setPsram(true); 7 | canvas[0].setColorDepth(1); 8 | canvas[0].createSprite(128, 120); 9 | canvas[0].clear(0xeeeeef); 10 | 11 | canvas[1].setPsram(true); 12 | canvas[1].setColorDepth(1); 13 | canvas[1].createSprite(128, 120); 14 | canvas[1].clear(0xeeeeef); 15 | } 16 | 17 | AppMic::~AppMic() { 18 | canvas[0].deleteSprite(); 19 | canvas[1].deleteSprite(); 20 | } 21 | 22 | void AppMic::onCustomAttrConfig() { 23 | LV_LOG_USER(__func__); 24 | } 25 | 26 | void AppMic::onViewLoad() { 27 | LV_LOG_USER(__func__); 28 | View.Create(_root); 29 | 30 | AttachEvent(_root); 31 | AttachEvent(View.ui.imgbtn_home, LV_EVENT_CLICKED); 32 | AttachEvent(View.ui.imgbtn_next, LV_EVENT_CLICKED); 33 | 34 | Model.MicBegin(); 35 | } 36 | 37 | void AppMic::onViewDidLoad() { 38 | LV_LOG_USER(__func__); 39 | } 40 | 41 | void AppMic::onViewWillAppear() { 42 | LV_LOG_USER(__func__); 43 | 44 | timer = lv_timer_create(onTimerUpdate, 30, this); 45 | } 46 | 47 | void AppMic::onViewDidAppear() { 48 | LV_LOG_USER(__func__); 49 | } 50 | 51 | void AppMic::onViewWillDisappear() { 52 | LV_LOG_USER(__func__); 53 | } 54 | 55 | void AppMic::onViewDidDisappear() { 56 | LV_LOG_USER(__func__); 57 | 58 | lv_timer_del(timer); 59 | } 60 | 61 | void AppMic::onViewUnload() { 62 | LV_LOG_USER(__func__); 63 | 64 | View.Delete(); 65 | Model.MicEnd(); 66 | } 67 | 68 | void AppMic::onViewDidUnload() { 69 | LV_LOG_USER(__func__); 70 | } 71 | 72 | void AppMic::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 73 | lv_obj_set_user_data(obj, this); 74 | lv_obj_add_event_cb(obj, onEvent, code, this); 75 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 76 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 77 | } 78 | 79 | void AppMic::Update() { 80 | if (Model.IsMicEnable()) { 81 | Model.ReadMicData(); 82 | for (size_t lr = 0; lr < 2; ++lr) { 83 | int x = 0; 84 | auto rec_buf = 85 | Model.buf_index == 0 ? Model.mic_buf[1] : Model.mic_buf[0]; 86 | int py = 64 + (rec_buf[lr] >> 8); 87 | canvas[lr].clear(TFT_WHITE); 88 | for (size_t i = 2 + lr; i < MIC_BUF_SIZE; i += 2) { 89 | int y = 64 + (rec_buf[i] >> 8); 90 | canvas[lr].drawFastVLine(x, y, py - y + 1, TFT_BLACK); 91 | py = y; 92 | ++x; 93 | } 94 | canvas[lr].pushSprite(&M5.Display, lr * 160 + 16, 78); 95 | } 96 | Model.buf_index = (Model.buf_index + 1) % 2; 97 | } 98 | } 99 | 100 | void AppMic::onTimerUpdate(lv_timer_t* timer) { 101 | AppMic* instance = (AppMic*)timer->user_data; 102 | 103 | instance->Update(); 104 | } 105 | 106 | extern const unsigned char select_0_5s[88738]; 107 | 108 | void AppMic::onEvent(lv_event_t* event) { 109 | AppMic* instance = (AppMic*)lv_event_get_user_data(event); 110 | LV_ASSERT_NULL(instance); 111 | 112 | lv_obj_t* obj = lv_event_get_current_target(event); 113 | lv_event_code_t code = lv_event_get_code(event); 114 | 115 | if (obj == instance->_root) { 116 | if (code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LEAVE) { 117 | // instance->_Manager->Pop(); 118 | } 119 | } else { 120 | if (code == LV_EVENT_CLICKED) { 121 | if (obj == instance->View.ui.imgbtn_home) { 122 | instance->_Manager->Replace("Pages/HomeMenu"); 123 | } else if (obj == instance->View.ui.imgbtn_next) { 124 | USBSerial.print("AppMic -> AppPower\r\n"); 125 | instance->_Manager->Replace("Pages/AppPower"); 126 | } else if (obj == instance->View.ui.btn_top_center) { 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/pages/AppMic/AppMic.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPMIC_PRESENTER_H 2 | #define __APPMIC_PRESENTER_H 3 | 4 | #include "AppMicView.h" 5 | #include "AppMicModel.h" 6 | #include "M5Unified.h" 7 | 8 | namespace Page { 9 | 10 | class AppMic : public PageBase { 11 | public: 12 | AppMic(); 13 | virtual ~AppMic(); 14 | 15 | virtual void onCustomAttrConfig(); 16 | virtual void onViewLoad(); 17 | virtual void onViewDidLoad(); 18 | virtual void onViewWillAppear(); 19 | virtual void onViewDidAppear(); 20 | virtual void onViewWillDisappear(); 21 | virtual void onViewDidDisappear(); 22 | virtual void onViewUnload(); 23 | virtual void onViewDidUnload(); 24 | 25 | private: 26 | void Update(); 27 | void AttachEvent(lv_obj_t* obj) { 28 | AttachEvent(obj, LV_EVENT_ALL); 29 | } 30 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 31 | static void onTimerUpdate(lv_timer_t* timer); 32 | static void onEvent(lv_event_t* event); 33 | static void draw_mic_wave_event(lv_event_t* event); 34 | 35 | private: 36 | AppMicView View; 37 | AppMicModel Model; 38 | lv_timer_t* timer; 39 | 40 | M5Canvas canvas[2]; 41 | }; 42 | 43 | } // namespace Page 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/pages/AppMic/AppMicModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppMicModel.h" 2 | #include "M5Unified.h" 3 | 4 | using namespace Page; 5 | 6 | bool AppMicModel::ReadMicData() { 7 | return M5.Mic.record(mic_buf[buf_index], MIC_BUF_SIZE, 16000); 8 | } 9 | 10 | bool AppMicModel::IsMicEnable() { 11 | return M5.Mic.isEnabled(); 12 | } 13 | 14 | bool AppMicModel::IsSpeakerEnable() { 15 | return M5.Speaker.isEnabled(); 16 | } 17 | 18 | void AppMicModel::MicEnd() { 19 | M5.Mic.end(); 20 | M5.Speaker.begin(); 21 | } 22 | 23 | void AppMicModel::MicBegin() { 24 | M5.Speaker.end(); 25 | M5.Mic.begin(); 26 | } 27 | -------------------------------------------------------------------------------- /src/pages/AppMic/AppMicModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPMIC_MODEL_H 2 | #define __APPMIC_MODEL_H 3 | 4 | #include "lvgl.h" 5 | #include "config.h" 6 | 7 | namespace Page { 8 | 9 | class AppMicModel { 10 | public: 11 | int16_t mic_buf[2][MIC_BUF_SIZE]; 12 | int16_t prev_y[MIC_BUF_SIZE]; 13 | uint8_t buf_index = 0; 14 | public: 15 | bool ReadMicData(); 16 | bool IsMicEnable(); 17 | bool IsSpeakerEnable(); 18 | void MicBegin(); 19 | void MicEnd(); 20 | private: 21 | }; 22 | 23 | } // namespace Page 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/pages/AppMic/AppMicView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppMicView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppMicView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_mic")); 10 | 11 | ui.imgbtn_home = lv_imgbtn_create(root); 12 | lv_obj_set_size(ui.imgbtn_home, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 13 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("home_r"), NULL); 14 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("home_p"), NULL); 15 | lv_obj_align(ui.imgbtn_home, LV_ALIGN_TOP_LEFT, 0, 0); 16 | 17 | ui.imgbtn_next = lv_imgbtn_create(root); 18 | lv_obj_set_size(ui.imgbtn_next, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 19 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("next_r"), NULL); 20 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("next_p"), NULL); 21 | lv_obj_align(ui.imgbtn_next, LV_ALIGN_TOP_RIGHT, 5, 0); 22 | 23 | ui.btn_top_center = lv_btn_create(root); 24 | lv_obj_remove_style_all(ui.btn_top_center); 25 | lv_obj_set_size(ui.btn_top_center, 170, 68); 26 | lv_obj_align(ui.btn_top_center, LV_ALIGN_TOP_MID, 0, 0); 27 | 28 | // lv_obj_set_style_border_color(ui.btn_top_center, lv_color_hex(0xff00ff), 0); 29 | // lv_obj_set_style_border_side(ui.btn_top_center, LV_BORDER_SIDE_FULL, 0); 30 | // lv_obj_set_style_border_width(ui.btn_top_center, 1, 0); 31 | // lv_obj_set_style_radius(ui.btn_top_center, 0, 0); 32 | // lv_obj_set_style_border_post(ui.btn_top_center, true, 0); 33 | } 34 | 35 | void AppMicView::Delete() { 36 | } 37 | -------------------------------------------------------------------------------- /src/pages/AppMic/AppMicView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPMIC_VIEW_H 2 | #define __APPMIC_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppMicView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* img_bg; 16 | lv_obj_t* imgbtn_home; 17 | lv_obj_t* imgbtn_next; 18 | 19 | lv_obj_t* btn_top_center; 20 | } ui; 21 | 22 | private: 23 | }; 24 | 25 | } // namespace Page 26 | 27 | #endif // !__VIEW_H 28 | -------------------------------------------------------------------------------- /src/pages/AppPower/AppPower.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPPOWER_PRESENTER_H 2 | #define __APPPOWER_PRESENTER_H 3 | 4 | #include "AppPowerView.h" 5 | #include "AppPowerModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppPower : public PageBase { 10 | public: 11 | uint8_t mode_index = 0; 12 | 13 | public: 14 | AppPower(); 15 | virtual ~AppPower(); 16 | 17 | virtual void onCustomAttrConfig(); 18 | virtual void onViewLoad(); 19 | virtual void onViewDidLoad(); 20 | virtual void onViewWillAppear(); 21 | virtual void onViewDidAppear(); 22 | virtual void onViewWillDisappear(); 23 | virtual void onViewDidDisappear(); 24 | virtual void onViewUnload(); 25 | virtual void onViewDidUnload(); 26 | 27 | private: 28 | void Update(); 29 | void AttachEvent(lv_obj_t* obj) { 30 | AttachEvent(obj, LV_EVENT_ALL); 31 | } 32 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 33 | static void onTimerUpdate(lv_timer_t* timer); 34 | static void onEvent(lv_event_t* event); 35 | 36 | private: 37 | AppPowerView View; 38 | AppPowerModel Model; 39 | lv_timer_t* timer; 40 | }; 41 | 42 | } // namespace Page 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/pages/AppPower/AppPowerModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppPowerModel.h" 2 | 3 | using namespace Page; 4 | 5 | // P0.2 BUS LOW[IN] HIGH[OUT] 6 | // P0.5 USB LOW[IN] HIGH[OUT] 7 | // P1.7 BOOST_EN LOW[OFF] HIGH[ON] 8 | 9 | void AppPowerModel::SetPowerMode(uint8_t mode) { 10 | switch (mode) { 11 | case POWER_MODE_USB_IN_BUS_IN: 12 | M5.In_I2C.bitOff(AW9523_ADDR, 0x02, 0b100010, 100000L); 13 | M5.In_I2C.bitOff(AW9523_ADDR, 0x03, 0b10000000, 100000L); // BOOST_DIS 14 | break; 15 | case POWER_MODE_USB_IN_BUS_OUT: 16 | M5.In_I2C.bitOff(AW9523_ADDR, 0x02, 0b100000, 100000L); 17 | M5.In_I2C.bitOn(AW9523_ADDR, 0x02, 0b000010, 100000L); 18 | M5.In_I2C.bitOn(AW9523_ADDR, 0x03, 0b10000000, 100000L); // BOOST_EN 19 | break; 20 | case POWER_MODE_USB_OUT_BUS_IN: 21 | M5.In_I2C.bitOn(AW9523_ADDR, 0x02, 0b100000, 100000L); 22 | M5.In_I2C.bitOff(AW9523_ADDR, 0x02, 0b000010, 100000L); 23 | M5.In_I2C.bitOff(AW9523_ADDR, 0x03, 0b10000000, 24 | 100000L); // BOOST_DIS 25 | break; 26 | case POWER_MODE_USB_OUT_BUS_OUT: 27 | M5.In_I2C.bitOn(AW9523_ADDR, 0x02, 0b100010, 100000L); 28 | M5.In_I2C.bitOn(AW9523_ADDR, 0x03, 0b10000000, 100000L); // BOOST_EN 29 | break; 30 | default: 31 | break; 32 | } 33 | 34 | GetPowerMode(); 35 | } 36 | 37 | uint8_t AppPowerModel::GetPowerMode() { 38 | uint8_t data = 0; 39 | M5.In_I2C.readRegister(AW9523_ADDR, 0x02, &data, 1, 100000L); 40 | mode_bit.bus = ((data >> 1) & 0b1); 41 | mode_bit.usb = ((data >> 5) & 0b1); 42 | // Serial.printf("power mode data raw: %d bus: %d usb: %d mode: %d\r\n", 43 | // data, mode_bit.bus, mode_bit.usb, power_mode); 44 | return power_mode; 45 | } 46 | 47 | void AppPowerModel::AxpCHGLedEnable() { 48 | M5.In_I2C.writeRegister8(AXP2101_ADDR, 0x69, 0b00110101, 100000L); 49 | } 50 | 51 | void AppPowerModel::AxpCHGLedDisable() { 52 | M5.In_I2C.bitOff(AXP2101_ADDR, 0x69, 0b01, 100000L); 53 | } 54 | 55 | void AppPowerModel::AxpAdcEnable() { 56 | M5.In_I2C.writeRegister8(AXP2101_ADDR, 0x30, 0b111111, 100000L); 57 | } 58 | 59 | void AppPowerModel::AxpAdcSampling() { 60 | uint8_t reg = 0x34; 61 | uint8_t data[2] = {0}; 62 | M5.In_I2C.readRegister(AXP2101_ADDR, reg, data, 2, 100000L); 63 | vbat = ((data[0] & 0x3f) << 8) | data[1]; 64 | reg += 2; 65 | M5.In_I2C.readRegister(AXP2101_ADDR, reg, data, 2, 100000L); 66 | ts = (((data[0] & 0x3f) << 8) | data[1]) * 0.5f; 67 | reg += 2; 68 | M5.In_I2C.readRegister(AXP2101_ADDR, reg, data, 2, 100000L); 69 | vbus = ((data[0] & 0x3f) << 8) | data[1]; 70 | reg += 2; 71 | M5.In_I2C.readRegister(AXP2101_ADDR, reg, data, 2, 100000L); 72 | vsys = (((data[0] & 0x3f) << 8) | data[1]); 73 | 74 | reg += 2; 75 | M5.In_I2C.readRegister(AXP2101_ADDR, reg, data, 2, 100000L); 76 | tdie = 22 + ((7274 - ((data[0] << 8) | data[1])) / 20); 77 | 78 | data[0] = M5.In_I2C.readRegister8(AXP2101_ADDR, 0x00, 100000L); 79 | 80 | if (!(data[0] & 0b100000)) { 81 | vbus = 0.0f; 82 | } 83 | 84 | if (vbus >= 16375) { 85 | vbus = 0.0f; 86 | } 87 | } 88 | 89 | uint8_t AppPowerModel::AxpBatIsCharging() { 90 | uint8_t reg = 0x01; 91 | uint8_t data[1] = {0}; 92 | M5.In_I2C.readRegister(AXP2101_ADDR, reg, data, 1, 100000L); 93 | return (data[0] >> 5) & 0b11; 94 | } 95 | -------------------------------------------------------------------------------- /src/pages/AppPower/AppPowerModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPPOWER_MODEL_H 2 | #define __APPPOWER_MODEL_H 3 | 4 | #include "lvgl.h" 5 | #include "M5Unified.h" 6 | #include "config.h" 7 | 8 | namespace Page { 9 | 10 | class AppPowerModel { 11 | public: 12 | union { 13 | struct { 14 | uint8_t bus : 1; 15 | uint8_t usb : 1; 16 | uint8_t reserve : 6; 17 | } mode_bit; 18 | uint8_t power_mode = 0x00; 19 | }; 20 | 21 | float vbat, ts, vbus, vsys, tdie; 22 | 23 | public: 24 | void SetPowerMode(uint8_t mode); 25 | uint8_t GetPowerMode(); 26 | void AxpCHGLedEnable(); 27 | void AxpCHGLedDisable(); 28 | void AxpAdcEnable();; 29 | void AxpAdcSampling(); 30 | uint8_t AxpBatIsCharging(); // 0: not charging, 1: charge 2: discharg 31 | private: 32 | }; 33 | 34 | } // namespace Page 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/pages/AppPower/AppPowerView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPPOWER_VIEW_H 2 | #define __APPPOWER_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppPowerView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | void ChangeBgImg(uint8_t mode); 13 | void ChangeBatImg(uint8_t index); 14 | void ChangeUsbImg(bool usb_in); 15 | void ChangeBusImg(bool bus_in); 16 | 17 | public: 18 | struct { 19 | lv_obj_t* img_bg; 20 | lv_obj_t* imgbtn_home; 21 | lv_obj_t* imgbtn_next; 22 | lv_obj_t* btn_top_center; 23 | 24 | lv_obj_t* label_tdie; 25 | lv_obj_t* label_vbat; 26 | lv_obj_t* label_vbus; 27 | lv_obj_t* label_vmbus; 28 | lv_obj_t* img_bat; 29 | lv_obj_t* imgbtn_usb; 30 | lv_obj_t* imgbtn_bus; 31 | } ui; 32 | 33 | private: 34 | }; 35 | 36 | } // namespace Page 37 | 38 | #endif // !__VIEW_H 39 | -------------------------------------------------------------------------------- /src/pages/AppRTC/AppRTC.cpp: -------------------------------------------------------------------------------- 1 | #include "AppRTC.h" 2 | 3 | using namespace Page; 4 | 5 | AppRTC::AppRTC() : timer(nullptr) { 6 | } 7 | 8 | AppRTC::~AppRTC() { 9 | } 10 | 11 | void AppRTC::onCustomAttrConfig() { 12 | LV_LOG_USER(__func__); 13 | } 14 | 15 | void AppRTC::onViewLoad() { 16 | LV_LOG_USER(__func__); 17 | 18 | View.Create(_root); 19 | 20 | for (size_t i = 0; i < 6; i++) { 21 | AttachEvent(View.ui.btn_list[i], LV_EVENT_CLICKED); 22 | } 23 | } 24 | 25 | void AppRTC::onViewDidLoad() { 26 | LV_LOG_USER(__func__); 27 | } 28 | 29 | void AppRTC::onViewWillAppear() { 30 | LV_LOG_USER(__func__); 31 | 32 | timer = lv_timer_create(onTimerUpdate, 1000, this); 33 | } 34 | 35 | void AppRTC::onViewDidAppear() { 36 | LV_LOG_USER(__func__); 37 | } 38 | 39 | void AppRTC::onViewWillDisappear() { 40 | LV_LOG_USER(__func__); 41 | M5.Speaker.playWav((const uint8_t*)ResourcePool::GetWav("select_0_5s"), ~0u, 42 | 1, 1); 43 | } 44 | 45 | void AppRTC::onViewDidDisappear() { 46 | LV_LOG_USER(__func__); 47 | lv_timer_del(timer); 48 | } 49 | 50 | void AppRTC::onViewUnload() { 51 | LV_LOG_USER(__func__); 52 | 53 | View.Delete(); 54 | } 55 | 56 | void AppRTC::onViewDidUnload() { 57 | LV_LOG_USER(__func__); 58 | } 59 | 60 | void AppRTC::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 61 | lv_obj_set_user_data(obj, this); 62 | lv_obj_add_event_cb(obj, onEvent, code, this); 63 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 64 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 65 | } 66 | 67 | void AppRTC::Update() { 68 | } 69 | 70 | void AppRTC::onTimerUpdate(lv_timer_t* timer) { 71 | AppRTC* instance = (AppRTC*)timer->user_data; 72 | 73 | instance->Update(); 74 | } 75 | 76 | void AppRTC::onEvent(lv_event_t* event) { 77 | AppRTC* instance = (AppRTC*)lv_event_get_user_data(event); 78 | LV_ASSERT_NULL(instance); 79 | 80 | lv_obj_t* obj = lv_event_get_current_target(event); 81 | lv_event_code_t code = lv_event_get_code(event); 82 | 83 | if (code == LV_EVENT_CLICKED) { 84 | if (obj == instance->View.ui.btn_list[2]) { 85 | instance->_Manager->Replace("Pages/HomeMenu"); 86 | return; 87 | } 88 | M5.Speaker.playWav((const uint8_t*)ResourcePool::GetWav("select_0_5s"), 89 | ~0u, 1, 1); 90 | if (obj == instance->View.ui.btn_list[0]) { 91 | #if MONKEY_TEST_ENABLE 92 | // ... 93 | #else 94 | instance->Model.ShutDown(); 95 | #endif 96 | } else if (obj == instance->View.ui.btn_list[1]) { 97 | instance->Model.UpdateBrightness(); 98 | } else if (obj == instance->View.ui.btn_list[3]) { 99 | instance->Model.StartDeepSleep(); 100 | } else if (obj == instance->View.ui.btn_list[4]) { 101 | USBSerial.print("Sleep & Wakeup after 5s\r\n"); 102 | instance->Model.SetRtcTimer(5); 103 | instance->Model.ShutDown(); 104 | } else if (obj == instance->View.ui.btn_list[5]) { 105 | USBSerial.print("Sleep & Wakeup after 1min\r\n"); 106 | instance->Model.SetRtcTimer(60); 107 | instance->Model.ShutDown(); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/pages/AppRTC/AppRTC.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPRTC_PRESENTER_H 2 | #define __APPRTC_PRESENTER_H 3 | 4 | #include "AppRTCView.h" 5 | #include "AppRTCModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppRTC : public PageBase { 10 | public: 11 | AppRTC(); 12 | virtual ~AppRTC(); 13 | 14 | virtual void onCustomAttrConfig(); 15 | virtual void onViewLoad(); 16 | virtual void onViewDidLoad(); 17 | virtual void onViewWillAppear(); 18 | virtual void onViewDidAppear(); 19 | virtual void onViewWillDisappear(); 20 | virtual void onViewDidDisappear(); 21 | virtual void onViewUnload(); 22 | virtual void onViewDidUnload(); 23 | 24 | private: 25 | void Update(); 26 | void AttachEvent(lv_obj_t* obj) { 27 | AttachEvent(obj, LV_EVENT_ALL); 28 | } 29 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 30 | static void onTimerUpdate(lv_timer_t* timer); 31 | static void onEvent(lv_event_t* event); 32 | 33 | private: 34 | AppRTCView View; 35 | AppRTCModel Model; 36 | lv_timer_t* timer; 37 | bool brightness_flag = false; 38 | }; 39 | 40 | } // namespace Page 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/pages/AppRTC/AppRTCModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppRTCModel.h" 2 | 3 | using namespace Page; 4 | 5 | void AppRTCModel::SetRtcTimer(uint8_t seconds) { 6 | M5.In_I2C.writeRegister8(BM8563_ADDR, 0x0e, 0b10000010, 100000L); 7 | M5.In_I2C.writeRegister8(BM8563_ADDR, 0x0f, seconds, 100000L); 8 | M5.In_I2C.writeRegister8(BM8563_ADDR, 0x01, 0b01, 100000L); 9 | } 10 | 11 | void AppRTCModel::ShutDown() { 12 | M5.In_I2C.bitOn(AXP2101_ADDR, 0x41, 1 << 1, 100000L); 13 | M5.In_I2C.writeRegister8(AXP2101_ADDR, 0x25, 0b00011011, 100000L); 14 | M5.In_I2C.writeRegister8(AXP2101_ADDR, 0x10, 0b00110001, 100000L); 15 | } 16 | 17 | void AppRTCModel::StartDeepSleep() { 18 | // INTEN_P0 TF_DETECT ES7210 EN[0] DIS[1] 19 | M5.In_I2C.writeRegister8(AW9523_ADDR, 0x06, 0b11111111, 100000L); 20 | // INTEN_P1 AW88298 FT6336 EN[0] DIS[1] Clear INT 21 | M5.In_I2C.writeRegister8(AW9523_ADDR, 0x07, 0b11111011, 100000L); 22 | M5.In_I2C.readRegister8(AW9523_ADDR, 0x00, 100000L); 23 | M5.In_I2C.readRegister8(AW9523_ADDR, 0x01, 100000L); 24 | pinMode(21, INPUT_PULLUP); 25 | time_t start = millis(); 26 | while (true) { 27 | delay(10); 28 | if (millis() - start > 1000) { 29 | Serial.println("Touch INT Timeout"); 30 | break; 31 | } 32 | M5.update(); 33 | } 34 | delay(300); 35 | // GPIO21 <- AW9523 INT <- AW9523 P1.2 <- Touch INT 36 | esp_sleep_enable_ext0_wakeup(GPIO_NUM_21, 0); 37 | M5.Lcd.fillScreen(TFT_BLACK); 38 | M5.Lcd.sleep(); 39 | M5.Lcd.waitDisplay(); 40 | esp_deep_sleep_start(); 41 | } 42 | 43 | void AppRTCModel::UpdateBrightness() { 44 | if (brightness_increase) { 45 | M5.Display.setBrightness(M5.Display.getBrightness() + 15); 46 | if (M5.Display.getBrightness() >= 100) { 47 | brightness_increase = false; 48 | } 49 | } else { 50 | M5.Display.setBrightness(M5.Display.getBrightness() - 15); 51 | if (M5.Display.getBrightness() <= 55) { 52 | brightness_increase = true; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/pages/AppRTC/AppRTCModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPRTC_MODEL_H 2 | #define __APPRTC_MODEL_H 3 | 4 | #include "lvgl.h" 5 | #include "M5Unified.h" 6 | #include "config.h" 7 | 8 | namespace Page { 9 | 10 | class AppRTCModel { 11 | public: 12 | AppRTCModel() {}; 13 | ~AppRTCModel() {}; 14 | void SetRtcTimer(uint8_t seconds); 15 | void ShutDown(); 16 | void StartDeepSleep(); 17 | void UpdateBrightness(); 18 | private: 19 | bool brightness_increase = false; 20 | }; 21 | 22 | } // namespace Page 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/pages/AppRTC/AppRTCView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppRTCView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppRTCView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_rtc")); 10 | 11 | for (size_t i = 0; i < 6; i++) 12 | { 13 | ui.btn_list[i] = lv_btn_create(root); 14 | lv_obj_remove_style_all(ui.btn_list[i]); 15 | lv_obj_set_size(ui.btn_list[i], 102, 118); 16 | lv_obj_set_pos(ui.btn_list[i], 109 * (i % 3), 122 * (i / 3)); 17 | 18 | // lv_obj_set_style_border_color(ui.btn_list[i], lv_color_hex(0xff00ff), 0); 19 | // lv_obj_set_style_border_side(ui.btn_list[i], LV_BORDER_SIDE_FULL, 0); 20 | // lv_obj_set_style_border_width(ui.btn_list[i], 1, 0); 21 | // lv_obj_set_style_radius(ui.btn_list[i], 0, 0); 22 | // lv_obj_set_style_border_post(ui.btn_list[i], true, 0); 23 | } 24 | } 25 | 26 | void AppRTCView::Delete() { 27 | } -------------------------------------------------------------------------------- /src/pages/AppRTC/AppRTCView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPRTC_VIEW_H 2 | #define __APPRTC_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppRTCView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* img_bg; 16 | lv_obj_t* btn_list[6]; 17 | } ui; 18 | 19 | private: 20 | }; 21 | 22 | } // namespace Page 23 | 24 | #endif // !__VIEW_H 25 | -------------------------------------------------------------------------------- /src/pages/AppSD/AppSD.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPSD_PRESENTER_H 2 | #define __APPSD_PRESENTER_H 3 | 4 | #include "AppSDView.h" 5 | #include "AppSDModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppSD : public PageBase { 10 | public: 11 | bool scan_flag = true; 12 | 13 | public: 14 | AppSD(); 15 | virtual ~AppSD(); 16 | 17 | virtual void onCustomAttrConfig(); 18 | virtual void onViewLoad(); 19 | virtual void onViewDidLoad(); 20 | virtual void onViewWillAppear(); 21 | virtual void onViewDidAppear(); 22 | virtual void onViewWillDisappear(); 23 | virtual void onViewDidDisappear(); 24 | virtual void onViewUnload(); 25 | virtual void onViewDidUnload(); 26 | 27 | private: 28 | void Update(); 29 | void AttachEvent(lv_obj_t* obj) { 30 | AttachEvent(obj, LV_EVENT_ALL); 31 | } 32 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 33 | static void onTimerUpdate(lv_timer_t* timer); 34 | static void onEvent(lv_event_t* event); 35 | 36 | void ListSDCard(fs::FS& fs, const char* dirname, uint8_t levels); 37 | 38 | private: 39 | AppSDView View; 40 | AppSDModel Model; 41 | lv_timer_t* timer; 42 | }; 43 | 44 | } // namespace Page 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/pages/AppSD/AppSDModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppSDModel.h" 2 | 3 | using namespace Page; 4 | 5 | bool AppSDModel::SDInit() { 6 | init_flag = SD.begin(GPIO_NUM_4, SPI, 25000000); 7 | return init_flag; 8 | } 9 | 10 | void AppSDModel::SDDeinit() { 11 | SD.end(); 12 | init_flag = false; 13 | } 14 | 15 | bool AppSDModel::GetInitFlag() { 16 | return init_flag; 17 | } 18 | 19 | void AppSDModel::ClearInitFlag() { 20 | init_flag = false; 21 | } 22 | 23 | bool AppSDModel::IsSDCardExist() { 24 | return (bool)!((M5.In_I2C.readRegister8(AW9523_ADDR, 0x00, 100000L) >> 4) & 0x01); 25 | } 26 | -------------------------------------------------------------------------------- /src/pages/AppSD/AppSDModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPSD_MODEL_H 2 | #define __APPSD_MODEL_H 3 | 4 | #include 5 | #include "lvgl.h" 6 | #include "M5Unified.h" 7 | #include "config.h" 8 | 9 | // TF Detect AW9523 P0.4 10 | 11 | namespace Page { 12 | 13 | class AppSDModel { 14 | public: 15 | bool SDInit(); 16 | void SDDeinit(); 17 | bool GetInitFlag(); 18 | void ClearInitFlag(); 19 | bool IsSDCardExist(); 20 | private: 21 | bool init_flag = false; 22 | }; 23 | 24 | } // namespace Page 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/pages/AppSD/AppSDView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppSDView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppSDView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_sd")); 10 | 11 | ui.imgbtn_home = lv_imgbtn_create(root); 12 | lv_obj_set_size(ui.imgbtn_home, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 13 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("home_r"), NULL); 14 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("home_p"), NULL); 15 | lv_obj_align(ui.imgbtn_home, LV_ALIGN_TOP_LEFT, 0, 0); 16 | 17 | ui.imgbtn_next = lv_imgbtn_create(root); 18 | lv_obj_set_size(ui.imgbtn_next, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 19 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("next_r"), NULL); 20 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("next_p"), NULL); 21 | lv_obj_align(ui.imgbtn_next, LV_ALIGN_TOP_RIGHT, 5, 0); 22 | 23 | ui.btn_top_center = lv_btn_create(root); 24 | lv_obj_remove_style_all(ui.btn_top_center); 25 | lv_obj_set_size(ui.btn_top_center, 170, 68); 26 | lv_obj_align(ui.btn_top_center, LV_ALIGN_TOP_MID, 0, 0); 27 | 28 | // lv_obj_set_style_border_color(ui.btn_top_center, lv_color_hex(0xff00ff), 0); 29 | // lv_obj_set_style_border_side(ui.btn_top_center, LV_BORDER_SIDE_FULL, 0); 30 | // lv_obj_set_style_border_width(ui.btn_top_center, 1, 0); 31 | // lv_obj_set_style_radius(ui.btn_top_center, 0, 0); 32 | // lv_obj_set_style_border_post(ui.btn_top_center, true, 0); 33 | 34 | ui.cont_file = lv_obj_create(root); 35 | lv_obj_remove_style_all(ui.cont_file); 36 | lv_obj_set_size(ui.cont_file, 320, 172); 37 | lv_obj_clear_flag(ui.cont_file, LV_OBJ_FLAG_SCROLLABLE); 38 | lv_obj_set_pos(ui.cont_file, 0, 68); 39 | 40 | // lv_obj_set_style_border_color(ui.cont_file, lv_color_hex(0xff00ff), 0); 41 | // lv_obj_set_style_border_side(ui.cont_file, LV_BORDER_SIDE_FULL, 0); 42 | // lv_obj_set_style_border_width(ui.cont_file, 1, 0); 43 | // lv_obj_set_style_radius(ui.cont_file, 0, 0); 44 | // lv_obj_set_style_border_post(ui.cont_file, true, 0); 45 | 46 | ui.file_list = lv_list_create(ui.cont_file); 47 | lv_obj_set_style_radius(ui.file_list, 0, 0); 48 | lv_obj_set_size(ui.file_list, 300, 160); 49 | lv_obj_set_pos(ui.file_list, 10, 6); 50 | 51 | ui.label_notice = lv_label_create(root); 52 | lv_label_set_text(ui.label_notice, "Please insert SD card..."); 53 | lv_obj_align(ui.label_notice, LV_ALIGN_CENTER, 0, 30); 54 | lv_label_set_long_mode(ui.label_notice, LV_LABEL_LONG_SCROLL); 55 | lv_obj_set_size(ui.label_notice, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 56 | // lv_obj_add_flag(ui.label_notice, LV_OBJ_FLAG_HIDDEN); 57 | } 58 | 59 | void AppSDView::Delete() { 60 | } -------------------------------------------------------------------------------- /src/pages/AppSD/AppSDView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPSD_VIEW_H 2 | #define __APPSD_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppSDView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* img_bg; 16 | lv_obj_t* imgbtn_home; 17 | lv_obj_t* imgbtn_next; 18 | lv_obj_t* btn_top_center; 19 | 20 | lv_obj_t* cont_file; 21 | lv_obj_t* file_list; 22 | lv_obj_t* label_notice; 23 | } ui; 24 | 25 | private: 26 | }; 27 | 28 | } // namespace Page 29 | 30 | #endif // !__VIEW_H 31 | -------------------------------------------------------------------------------- /src/pages/AppTouch/AppTouch.cpp: -------------------------------------------------------------------------------- 1 | #include "AppTouch.h" 2 | 3 | using namespace Page; 4 | 5 | AppTouch::AppTouch() : timer(nullptr) { 6 | } 7 | 8 | AppTouch::~AppTouch() { 9 | } 10 | 11 | void AppTouch::onCustomAttrConfig() { 12 | LV_LOG_USER(__func__); 13 | } 14 | 15 | void AppTouch::onViewLoad() { 16 | LV_LOG_USER(__func__); 17 | View.Create(_root); 18 | 19 | AttachEvent(View.ui.imgbtn_home, LV_EVENT_CLICKED); 20 | AttachEvent(View.ui.imgbtn_next, LV_EVENT_CLICKED); 21 | AttachEvent(View.ui.btn_top_center, LV_EVENT_CLICKED); 22 | 23 | M5.Touch.getCount(); 24 | M5.Touch.getTouchPointRaw(0); 25 | ClearTouchPoint(); 26 | } 27 | 28 | void AppTouch::onViewDidLoad() { 29 | LV_LOG_USER(__func__); 30 | } 31 | 32 | void AppTouch::onViewWillAppear() { 33 | LV_LOG_USER(__func__); 34 | 35 | timer = lv_timer_create(onTimerUpdate, 10, this); 36 | } 37 | 38 | void AppTouch::onViewDidAppear() { 39 | LV_LOG_USER(__func__); 40 | } 41 | 42 | void AppTouch::onViewWillDisappear() { 43 | LV_LOG_USER(__func__); 44 | } 45 | 46 | void AppTouch::onViewDidDisappear() { 47 | LV_LOG_USER(__func__); 48 | lv_timer_del(timer); 49 | } 50 | 51 | void AppTouch::onViewUnload() { 52 | LV_LOG_USER(__func__); 53 | 54 | View.Delete(); 55 | } 56 | 57 | void AppTouch::onViewDidUnload() { 58 | LV_LOG_USER(__func__); 59 | } 60 | 61 | void AppTouch::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 62 | lv_obj_set_user_data(obj, this); 63 | lv_obj_add_event_cb(obj, onEvent, code, this); 64 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 65 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 66 | } 67 | 68 | void AppTouch::Update() { 69 | static std::uint32_t color = 0; 70 | auto count = M5.Touch.getCount(); 71 | if (!count) { 72 | ClearTouchPoint(); 73 | return; 74 | } 75 | auto t = M5.Touch.getTouchPointRaw(0); 76 | if (t.y > 68 && t.y < 240) { 77 | M5.Display.fillRect(t.x - 1, t.y - 1, 2, 2, color); 78 | if (t_prev.x != 0 && t_prev.y != 0) { 79 | M5.Display.drawLine(t_prev.x, t_prev.y, t.x, t.y, color); 80 | } 81 | t_prev = t; 82 | } 83 | if (color % 65536 == 0) { 84 | M5.Display.fillRect(0, 68, 320, 172, TFT_WHITE); 85 | ClearTouchPoint(); 86 | } 87 | color += 32; 88 | } 89 | 90 | void AppTouch::onTimerUpdate(lv_timer_t* timer) { 91 | AppTouch* instance = (AppTouch*)timer->user_data; 92 | 93 | instance->Update(); 94 | } 95 | 96 | void AppTouch::onEvent(lv_event_t* event) { 97 | AppTouch* instance = (AppTouch*)lv_event_get_user_data(event); 98 | LV_ASSERT_NULL(instance); 99 | 100 | lv_obj_t* obj = lv_event_get_current_target(event); 101 | lv_event_code_t code = lv_event_get_code(event); 102 | 103 | if (code == LV_EVENT_CLICKED) { 104 | M5.Speaker.playWav( 105 | (const uint8_t*)ResourcePool::GetWav("select_0_5s"), ~0u, 1, 1); 106 | if (obj == instance->View.ui.imgbtn_home) { 107 | instance->_Manager->Replace("Pages/HomeMenu"); 108 | } else if (obj == instance->View.ui.imgbtn_next) { 109 | USBSerial.print("AppTouch -> AppI2C\r\n"); 110 | instance->_Manager->Replace("Pages/AppI2C"); 111 | } else if (obj == instance->View.ui.btn_top_center) { 112 | M5.Display.fillRect(0, 68, 320, 172, TFT_WHITE); 113 | instance->ClearTouchPoint(); 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/pages/AppTouch/AppTouch.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPTOUCH_PRESENTER_H 2 | #define __APPTOUCH_PRESENTER_H 3 | 4 | #include "AppTouchView.h" 5 | #include "AppTouchModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppTouch : public PageBase { 10 | public: 11 | AppTouch(); 12 | virtual ~AppTouch(); 13 | 14 | virtual void onCustomAttrConfig(); 15 | virtual void onViewLoad(); 16 | virtual void onViewDidLoad(); 17 | virtual void onViewWillAppear(); 18 | virtual void onViewDidAppear(); 19 | virtual void onViewWillDisappear(); 20 | virtual void onViewDidDisappear(); 21 | virtual void onViewUnload(); 22 | virtual void onViewDidUnload(); 23 | 24 | private: 25 | void Update(); 26 | void AttachEvent(lv_obj_t* obj) { 27 | AttachEvent(obj, LV_EVENT_ALL); 28 | } 29 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 30 | static void onTimerUpdate(lv_timer_t* timer); 31 | static void onEvent(lv_event_t* event); 32 | 33 | void ClearTouchPoint(void) { 34 | t_prev.x = 0; 35 | t_prev.y = 0; 36 | } 37 | 38 | private: 39 | AppTouchView View; 40 | AppTouchModel Model; 41 | lv_timer_t* timer; 42 | m5gfx::touch_point_t t_prev; 43 | }; 44 | 45 | } // namespace Page 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/pages/AppTouch/AppTouchModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppTouchModel.h" 2 | 3 | using namespace Page; 4 | -------------------------------------------------------------------------------- /src/pages/AppTouch/AppTouchModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPTOUCH_MODEL_H 2 | #define __APPTOUCH_MODEL_H 3 | 4 | #include "lvgl.h" 5 | 6 | namespace Page { 7 | 8 | class AppTouchModel { 9 | public: 10 | private: 11 | }; 12 | 13 | } // namespace Page 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/pages/AppTouch/AppTouchView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppTouchView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppTouchView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_touch_min")); 10 | 11 | ui.imgbtn_home = lv_imgbtn_create(root); 12 | lv_obj_set_size(ui.imgbtn_home, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 13 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("home_r"), NULL); 14 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("home_p"), NULL); 15 | lv_obj_align(ui.imgbtn_home, LV_ALIGN_TOP_LEFT, 0, 0); 16 | 17 | ui.imgbtn_next = lv_imgbtn_create(root); 18 | lv_obj_set_size(ui.imgbtn_next, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 19 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("next_r"), NULL); 20 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("next_p"), NULL); 21 | lv_obj_align(ui.imgbtn_next, LV_ALIGN_TOP_RIGHT, 5, 0); 22 | 23 | ui.btn_top_center = lv_btn_create(root); 24 | lv_obj_remove_style_all(ui.btn_top_center); 25 | lv_obj_set_size(ui.btn_top_center, 170, 68); 26 | lv_obj_align(ui.btn_top_center, LV_ALIGN_TOP_MID, 0, 0); 27 | 28 | // lv_obj_set_style_border_color(ui.btn_top_center, lv_color_hex(0xff00ff), 0); 29 | // lv_obj_set_style_border_side(ui.btn_top_center, LV_BORDER_SIDE_FULL, 0); 30 | // lv_obj_set_style_border_width(ui.btn_top_center, 1, 0); 31 | // lv_obj_set_style_radius(ui.btn_top_center, 0, 0); 32 | // lv_obj_set_style_border_post(ui.btn_top_center, true, 0); 33 | } 34 | 35 | void AppTouchView::Delete() { 36 | } -------------------------------------------------------------------------------- /src/pages/AppTouch/AppTouchView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPTOUCH_VIEW_H 2 | #define __APPTOUCH_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppTouchView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* img_bg; 16 | lv_obj_t* imgbtn_home; 17 | lv_obj_t* imgbtn_next; 18 | 19 | lv_obj_t* canvas; 20 | 21 | lv_obj_t* btn_top_center; 22 | } ui; 23 | 24 | private: 25 | }; 26 | 27 | } // namespace Page 28 | 29 | #endif // !__VIEW_H 30 | -------------------------------------------------------------------------------- /src/pages/AppWiFi/AppWiFi.cpp: -------------------------------------------------------------------------------- 1 | #include "AppWiFi.h" 2 | 3 | using namespace Page; 4 | 5 | AppWiFi::AppWiFi() : timer(nullptr) { 6 | } 7 | 8 | AppWiFi::~AppWiFi() { 9 | } 10 | 11 | void AppWiFi::onCustomAttrConfig() { 12 | LV_LOG_USER(__func__); 13 | } 14 | 15 | void AppWiFi::onViewLoad() { 16 | LV_LOG_USER(__func__); 17 | View.Create(_root); 18 | 19 | Model.Init(); 20 | 21 | AttachEvent(View.ui.imgbtn_home, LV_EVENT_CLICKED); 22 | AttachEvent(View.ui.imgbtn_next, LV_EVENT_CLICKED); 23 | AttachEvent(View.ui.btn_top_center, LV_EVENT_CLICKED); 24 | } 25 | 26 | void AppWiFi::onViewDidLoad() { 27 | LV_LOG_USER(__func__); 28 | } 29 | 30 | void AppWiFi::onViewWillAppear() { 31 | LV_LOG_USER(__func__); 32 | timer = lv_timer_create(onTimerUpdate, 100, this); 33 | 34 | Model.Scan(); 35 | lv_obj_clear_flag(View.ui.label_scaning, LV_OBJ_FLAG_HIDDEN); 36 | } 37 | 38 | void AppWiFi::onViewDidAppear() { 39 | LV_LOG_USER(__func__); 40 | } 41 | 42 | void AppWiFi::onViewWillDisappear() { 43 | LV_LOG_USER(__func__); 44 | } 45 | 46 | void AppWiFi::onViewDidDisappear() { 47 | LV_LOG_USER(__func__); 48 | lv_timer_del(timer); 49 | } 50 | 51 | void AppWiFi::onViewUnload() { 52 | LV_LOG_USER(__func__); 53 | 54 | View.Delete(); 55 | scan_done = false; 56 | WiFi.scanDelete(); 57 | } 58 | 59 | void AppWiFi::onViewDidUnload() { 60 | LV_LOG_USER(__func__); 61 | } 62 | 63 | void AppWiFi::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 64 | lv_obj_set_user_data(obj, this); 65 | lv_obj_add_event_cb(obj, onEvent, code, this); 66 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 67 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 68 | } 69 | 70 | void AppWiFi::Update() { 71 | if (Model.GetScanCount() >= 0 && !scan_done) { 72 | lv_obj_add_flag(View.ui.label_scaning, LV_OBJ_FLAG_HIDDEN); 73 | scan_done = true; 74 | 75 | for (size_t i = 0; i < Model.GetScanCount(); i++) { 76 | lv_obj_t* label = lv_label_create(View.ui.wifi_ssid_list); 77 | lv_label_set_text_fmt(label, "%02d. %-27.27s [%-4d]", i + 1, 78 | Model.GetSSID(i), Model.GetRSSI(i)); 79 | } 80 | } 81 | } 82 | 83 | void AppWiFi::onTimerUpdate(lv_timer_t* timer) { 84 | AppWiFi* instance = (AppWiFi*)timer->user_data; 85 | 86 | instance->Update(); 87 | } 88 | 89 | void AppWiFi::onEvent(lv_event_t* event) { 90 | AppWiFi* instance = (AppWiFi*)lv_event_get_user_data(event); 91 | LV_ASSERT_NULL(instance); 92 | 93 | lv_obj_t* obj = lv_event_get_current_target(event); 94 | lv_event_code_t code = lv_event_get_code(event); 95 | 96 | if (code == LV_EVENT_CLICKED) { 97 | M5.Speaker.playWav( 98 | (const uint8_t*)ResourcePool::GetWav("select_0_5s"), ~0u, 1, 1); 99 | if (obj == instance->View.ui.imgbtn_home) { 100 | instance->_Manager->Replace("Pages/HomeMenu"); 101 | } 102 | #if defined(M5CORES3) 103 | else if (obj == instance->View.ui.imgbtn_next) { 104 | USBSerial.print("AppWiFi -> AppCamera\r\n"); 105 | instance->_Manager->Replace("Pages/AppCamera"); 106 | } 107 | #elif defined(M5CORES3SE) 108 | else if (obj == instance->View.ui.imgbtn_next) { 109 | Serial.print("AppCamera -> AppMic\r\n"); 110 | instance->_Manager->Replace("Pages/AppMic"); 111 | } 112 | #endif 113 | else if (obj == instance->View.ui.btn_top_center) { 114 | instance->Model.Scan(); 115 | instance->scan_done = false; 116 | lv_obj_clear_flag(instance->View.ui.label_scaning, 117 | LV_OBJ_FLAG_HIDDEN); 118 | lv_obj_clean(instance->View.ui.wifi_ssid_list); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/pages/AppWiFi/AppWiFi.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPWIFI_PRESENTER_H 2 | #define __APPWIFI_PRESENTER_H 3 | 4 | #include "AppWiFiView.h" 5 | #include "AppWiFiModel.h" 6 | 7 | namespace Page { 8 | 9 | class AppWiFi : public PageBase { 10 | public: 11 | bool scan_done = false; 12 | 13 | public: 14 | AppWiFi(); 15 | virtual ~AppWiFi(); 16 | 17 | virtual void onCustomAttrConfig(); 18 | virtual void onViewLoad(); 19 | virtual void onViewDidLoad(); 20 | virtual void onViewWillAppear(); 21 | virtual void onViewDidAppear(); 22 | virtual void onViewWillDisappear(); 23 | virtual void onViewDidDisappear(); 24 | virtual void onViewUnload(); 25 | virtual void onViewDidUnload(); 26 | 27 | private: 28 | void Update(); 29 | void AttachEvent(lv_obj_t* obj) { 30 | AttachEvent(obj, LV_EVENT_ALL); 31 | } 32 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 33 | static void onTimerUpdate(lv_timer_t* timer); 34 | static void onEvent(lv_event_t* event); 35 | 36 | private: 37 | AppWiFiView View; 38 | AppWiFiModel Model; 39 | lv_timer_t* timer; 40 | }; 41 | 42 | } // namespace Page 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/pages/AppWiFi/AppWiFiModel.cpp: -------------------------------------------------------------------------------- 1 | #include "AppWiFiModel.h" 2 | 3 | using namespace Page; 4 | 5 | void AppWiFiModel::Init() { 6 | WiFi.mode(WIFI_STA); 7 | WiFi.disconnect(); 8 | } 9 | 10 | void AppWiFiModel::Scan() { 11 | WiFi.scanNetworks(true); 12 | } 13 | 14 | int16_t AppWiFiModel::GetScanCount() { 15 | return WiFi.scanComplete(); 16 | } 17 | 18 | char* AppWiFiModel::GetSSID(uint8_t index) { 19 | static char ssid[27]; 20 | ssid[26] = '\0'; 21 | strncpy(ssid, WiFi.SSID(index).c_str(), 26); 22 | return ssid; 23 | } 24 | 25 | int32_t AppWiFiModel::GetRSSI(uint8_t index) { 26 | return WiFi.RSSI(index); 27 | } 28 | -------------------------------------------------------------------------------- /src/pages/AppWiFi/AppWiFiModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPWIFI_MODEL_H 2 | #define __APPWIFI_MODEL_H 3 | 4 | #include 5 | #include "lvgl.h" 6 | 7 | namespace Page { 8 | 9 | class AppWiFiModel { 10 | public: 11 | void Init(); 12 | void Scan(); 13 | int16_t GetScanCount(); 14 | char* GetSSID(uint8_t index); 15 | int32_t GetRSSI(uint8_t index); 16 | 17 | private: 18 | uint8_t scan_count = 0; 19 | }; 20 | 21 | } // namespace Page 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/pages/AppWiFi/AppWiFiView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AppWiFiView.h" 4 | 5 | using namespace Page; 6 | 7 | void AppWiFiView::Create(lv_obj_t* root) { 8 | ui.img_bg = lv_img_create(root); 9 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("app_wifi")); 10 | 11 | ui.imgbtn_home = lv_imgbtn_create(root); 12 | lv_obj_set_size(ui.imgbtn_home, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 13 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("home_r"), NULL); 14 | lv_imgbtn_set_src(ui.imgbtn_home, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("home_p"), NULL); 15 | lv_obj_align(ui.imgbtn_home, LV_ALIGN_TOP_LEFT, 0, 0); 16 | 17 | ui.imgbtn_next = lv_imgbtn_create(root); 18 | lv_obj_set_size(ui.imgbtn_next, LV_SIZE_CONTENT, LV_SIZE_CONTENT); 19 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_RELEASED, NULL, ResourcePool::GetImage("next_r"), NULL); 20 | lv_imgbtn_set_src(ui.imgbtn_next, LV_IMGBTN_STATE_PRESSED, NULL, ResourcePool::GetImage("next_p"), NULL); 21 | lv_obj_align(ui.imgbtn_next, LV_ALIGN_TOP_RIGHT, 5, 0); 22 | 23 | ui.btn_top_center = lv_btn_create(root); 24 | lv_obj_remove_style_all(ui.btn_top_center); 25 | lv_obj_set_size(ui.btn_top_center, 170, 68); 26 | lv_obj_align(ui.btn_top_center, LV_ALIGN_TOP_MID, 0, 0); 27 | 28 | // lv_obj_set_style_border_color(ui.btn_top_center, lv_color_hex(0xff00ff), 0); 29 | // lv_obj_set_style_border_side(ui.btn_top_center, LV_BORDER_SIDE_FULL, 0); 30 | // lv_obj_set_style_border_width(ui.btn_top_center, 1, 0); 31 | // lv_obj_set_style_radius(ui.btn_top_center, 0, 0); 32 | // lv_obj_set_style_border_post(ui.btn_top_center, true, 0); 33 | 34 | ui.cont_wifi = lv_obj_create(root); 35 | lv_obj_remove_style_all(ui.cont_wifi); 36 | lv_obj_set_size(ui.cont_wifi, 320, 172); 37 | lv_obj_clear_flag(ui.cont_wifi, LV_OBJ_FLAG_SCROLLABLE); 38 | lv_obj_set_pos(ui.cont_wifi, 0, 68); 39 | 40 | // lv_obj_set_style_border_color(ui.cont_wifi, lv_color_hex(0xff00ff), 0); 41 | // lv_obj_set_style_border_side(ui.cont_wifi, LV_BORDER_SIDE_FULL, 0); 42 | // lv_obj_set_style_border_width(ui.cont_wifi, 1, 0); 43 | // lv_obj_set_style_radius(ui.cont_wifi, 0, 0); 44 | // lv_obj_set_style_border_post(ui.cont_wifi, true, 0); 45 | 46 | ui.wifi_ssid_list = lv_list_create(ui.cont_wifi); 47 | lv_obj_set_style_radius(ui.wifi_ssid_list, 0, 0); 48 | lv_obj_set_size(ui.wifi_ssid_list, 300, 160); 49 | lv_obj_set_pos(ui.wifi_ssid_list, 10, 6); 50 | 51 | ui.label_scaning = lv_label_create(root); 52 | lv_label_set_text(ui.label_scaning, "Scanning..."); 53 | lv_obj_align(ui.label_scaning, LV_ALIGN_CENTER, 0, 30); 54 | lv_obj_add_flag(ui.label_scaning, LV_OBJ_FLAG_HIDDEN); 55 | } 56 | 57 | void AppWiFiView::Delete() { 58 | } 59 | -------------------------------------------------------------------------------- /src/pages/AppWiFi/AppWiFiView.h: -------------------------------------------------------------------------------- 1 | #ifndef __APPWIFI_VIEW_H 2 | #define __APPWIFI_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class AppWiFiView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* img_bg; 16 | lv_obj_t* imgbtn_home; 17 | lv_obj_t* imgbtn_next; 18 | 19 | lv_obj_t* btn_top_center; 20 | 21 | lv_obj_t* cont_wifi; 22 | lv_obj_t* wifi_ssid_list; 23 | 24 | lv_obj_t* label_scaning; 25 | } ui; 26 | 27 | private: 28 | }; 29 | 30 | } // namespace Page 31 | 32 | #endif // !__VIEW_H 33 | -------------------------------------------------------------------------------- /src/pages/HomeMenu/HomeMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "HomeMenu.h" 2 | 3 | using namespace Page; 4 | 5 | HomeMenu::HomeMenu() : timer(nullptr) { 6 | } 7 | 8 | HomeMenu::~HomeMenu() { 9 | } 10 | 11 | void HomeMenu::onCustomAttrConfig() { 12 | LV_LOG_USER(__func__); 13 | } 14 | 15 | void HomeMenu::onViewLoad() { 16 | LV_LOG_USER(__func__); 17 | 18 | View.Create(_root); 19 | 20 | for (size_t i = 0; i < 9; i++) { 21 | AttachEvent(View.ui.imgbtn_list[i], LV_EVENT_CLICKED); 22 | } 23 | } 24 | 25 | void HomeMenu::onViewDidLoad() { 26 | LV_LOG_USER(__func__); 27 | } 28 | 29 | void HomeMenu::onViewWillAppear() { 30 | LV_LOG_USER(__func__); 31 | 32 | timer = lv_timer_create(onTimerUpdate, 1000, this); 33 | } 34 | 35 | void HomeMenu::onViewDidAppear() { 36 | LV_LOG_USER(__func__); 37 | } 38 | 39 | void HomeMenu::onViewWillDisappear() { 40 | LV_LOG_USER(__func__); 41 | } 42 | 43 | void HomeMenu::onViewDidDisappear() { 44 | LV_LOG_USER(__func__); 45 | lv_timer_del(timer); 46 | } 47 | 48 | void HomeMenu::onViewUnload() { 49 | LV_LOG_USER(__func__); 50 | } 51 | 52 | void HomeMenu::onViewDidUnload() { 53 | LV_LOG_USER(__func__); 54 | } 55 | 56 | void HomeMenu::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 57 | lv_obj_set_user_data(obj, this); 58 | lv_obj_add_event_cb(obj, onEvent, code, this); 59 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 60 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 61 | } 62 | 63 | void HomeMenu::Update() { 64 | } 65 | 66 | void HomeMenu::onTimerUpdate(lv_timer_t* timer) { 67 | HomeMenu* instance = (HomeMenu*)timer->user_data; 68 | 69 | instance->Update(); 70 | } 71 | 72 | void HomeMenu::onEvent(lv_event_t* event) { 73 | HomeMenu* instance = (HomeMenu*)lv_event_get_user_data(event); 74 | LV_ASSERT_NULL(instance); 75 | 76 | lv_obj_t* obj = lv_event_get_current_target(event); 77 | lv_event_code_t code = lv_event_get_code(event); 78 | 79 | if (code == LV_EVENT_CLICKED) { 80 | if (obj == instance->View.ui.imgbtn_list[2]) { 81 | USBSerial.println("HomeMenu -> AppMic"); 82 | instance->_Manager->Replace("Pages/AppMic"); 83 | return; 84 | } 85 | USBSerial.print("HomeMenu -> "); 86 | M5.Speaker.playWav((const uint8_t*)ResourcePool::GetWav("select_0_5s"), 87 | ~0u, 1, 1); 88 | if (obj == instance->View.ui.imgbtn_list[0]) { 89 | USBSerial.println("AppWiFi"); 90 | instance->_Manager->Replace("Pages/AppWiFi"); 91 | } 92 | #if defined(M5CORES3) 93 | else if (obj == instance->View.ui.imgbtn_list[1]) { 94 | USBSerial.println("AppCamera"); 95 | instance->_Manager->Replace("Pages/AppCamera"); 96 | }else if (obj == instance->View.ui.imgbtn_list[4]) { 97 | USBSerial.println("AppIMU"); 98 | instance->_Manager->Replace("Pages/AppIMU"); 99 | } 100 | #elif defined(M5CORES3SE) 101 | 102 | #endif 103 | 104 | else if (obj == instance->View.ui.imgbtn_list[3]) { 105 | USBSerial.println("AppPower"); 106 | instance->_Manager->Replace("Pages/AppPower"); 107 | } else if (obj == instance->View.ui.imgbtn_list[5]) { 108 | USBSerial.println("AppSD"); 109 | instance->_Manager->Replace("Pages/AppSD"); 110 | } else if (obj == instance->View.ui.imgbtn_list[6]) { 111 | USBSerial.println("AppTouch"); 112 | instance->_Manager->Replace("Pages/AppTouch"); 113 | } else if (obj == instance->View.ui.imgbtn_list[7]) { 114 | USBSerial.println("AppI2C"); 115 | instance->_Manager->Replace("Pages/AppI2C"); 116 | } else if (obj == instance->View.ui.imgbtn_list[8]) { 117 | USBSerial.println("AppRTC"); 118 | instance->_Manager->Replace("Pages/AppRTC"); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/pages/HomeMenu/HomeMenu.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOMEMENU_PRESENTER_H 2 | #define __HOMEMENU_PRESENTER_H 3 | 4 | #include "HomeMenuView.h" 5 | #include "HomeMenuModel.h" 6 | 7 | namespace Page { 8 | 9 | class HomeMenu : public PageBase { 10 | public: 11 | HomeMenu(); 12 | virtual ~HomeMenu(); 13 | 14 | virtual void onCustomAttrConfig(); 15 | virtual void onViewLoad(); 16 | virtual void onViewDidLoad(); 17 | virtual void onViewWillAppear(); 18 | virtual void onViewDidAppear(); 19 | virtual void onViewWillDisappear(); 20 | virtual void onViewDidDisappear(); 21 | virtual void onViewUnload(); 22 | virtual void onViewDidUnload(); 23 | 24 | private: 25 | void Update(); 26 | void AttachEvent(lv_obj_t* obj) { 27 | AttachEvent(obj, LV_EVENT_ALL); 28 | } 29 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 30 | static void onTimerUpdate(lv_timer_t* timer); 31 | static void onEvent(lv_event_t* event); 32 | 33 | private: 34 | HomeMenuView View; 35 | HomeMenuModel Model; 36 | lv_timer_t* timer; 37 | }; 38 | 39 | } // namespace Page 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/pages/HomeMenu/HomeMenuModel.cpp: -------------------------------------------------------------------------------- 1 | #include "HomeMenuModel.h" 2 | 3 | using namespace Page; 4 | -------------------------------------------------------------------------------- /src/pages/HomeMenu/HomeMenuModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOMEMENU_MODEL_H 2 | #define __HOMEMENU_MODEL_H 3 | 4 | #include "lvgl.h" 5 | 6 | namespace Page { 7 | 8 | class HomeMenuModel { 9 | public: 10 | private: 11 | }; 12 | 13 | } // namespace Page 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/pages/HomeMenu/HomeMenuView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "HomeMenuView.h" 4 | 5 | using namespace Page; 6 | 7 | /* 8 | width: 60px 9 | height: 73px 10 | */ 11 | 12 | 13 | 14 | 15 | LV_IMG_DECLARE(menu_wifi); 16 | 17 | #if defined(M5CORES3) 18 | LV_IMG_DECLARE(menu_cam); 19 | #elif defined(M5CORES3SE) 20 | LV_IMG_DECLARE(menu_cam_se); 21 | #endif 22 | 23 | LV_IMG_DECLARE(menu_mic); 24 | LV_IMG_DECLARE(menu_power); 25 | 26 | #if defined(M5CORES3) 27 | LV_IMG_DECLARE(menu_imu); 28 | #elif defined(M5CORES3SE) 29 | LV_IMG_DECLARE(menu_imu_se); 30 | #endif 31 | LV_IMG_DECLARE(menu_sd); 32 | LV_IMG_DECLARE(menu_touch); 33 | LV_IMG_DECLARE(menu_i2c); 34 | LV_IMG_DECLARE(menu_sys); 35 | 36 | static const lv_img_dsc_t* menu_img_pressed_list[] = { 37 | &menu_wifi, 38 | #if defined(M5CORES3) 39 | &menu_cam, 40 | #elif defined(M5CORES3SE) 41 | &menu_cam_se, 42 | #endif 43 | &menu_mic, 44 | &menu_power, 45 | #if defined(M5CORES3) 46 | &menu_imu, 47 | #elif defined(M5CORES3SE) 48 | &menu_imu_se, 49 | #endif 50 | &menu_sd, 51 | &menu_touch, 52 | &menu_i2c, 53 | &menu_sys, 54 | }; 55 | 56 | void HomeMenuView::Create(lv_obj_t* root) { 57 | #if defined(M5CORES3) 58 | ui.img_bg = lv_img_create(root); 59 | lv_img_set_src(ui.img_bg, ResourcePool::GetImage("menu_bg")); 60 | #elif defined(M5CORES3SE) 61 | ui.img_bg_se = lv_img_create(root); 62 | lv_img_set_src(ui.img_bg_se, ResourcePool::GetImage("menu_bg_se")); 63 | #endif 64 | 65 | 66 | for (size_t i = 0; i < 8; i++) 67 | { 68 | ui.imgbtn_list[i] = lv_imgbtn_create(root); 69 | // lv_obj_remove_style_all(ui.imgbtn_list[i]); 70 | lv_obj_set_size(ui.imgbtn_list[i], 60, 73); 71 | lv_obj_set_pos(ui.imgbtn_list[i], 10 + 80 * (i % 4), 75 + 80 * (i / 4)); 72 | 73 | 74 | lv_imgbtn_set_src(ui.imgbtn_list[i], LV_IMGBTN_STATE_PRESSED, NULL, menu_img_pressed_list[i], NULL); 75 | lv_imgbtn_set_src(ui.imgbtn_list[i], LV_IMGBTN_STATE_RELEASED, NULL, menu_img_pressed_list[i], NULL); 76 | 77 | // lv_obj_set_style_border_color(ui.imgbtn_list[i], lv_color_hex(0xff00ff), 0); 78 | // lv_obj_set_style_border_side(ui.imgbtn_list[i], LV_BORDER_SIDE_FULL, 0); 79 | // lv_obj_set_style_border_width(ui.imgbtn_list[i], 1, 0); 80 | // lv_obj_set_style_radius(ui.imgbtn_list[i], 0, 0); 81 | // lv_obj_set_style_border_post(ui.imgbtn_list[i], true, 0); 82 | } 83 | 84 | ui.imgbtn_list[8] = lv_imgbtn_create(root); 85 | lv_obj_set_size(ui.imgbtn_list[8], 60, 73); 86 | lv_obj_set_pos(ui.imgbtn_list[8], 250, 10); 87 | 88 | lv_imgbtn_set_src(ui.imgbtn_list[8], LV_IMGBTN_STATE_PRESSED, NULL, menu_img_pressed_list[8], NULL); 89 | lv_imgbtn_set_src(ui.imgbtn_list[8], LV_IMGBTN_STATE_RELEASED, NULL, menu_img_pressed_list[8], NULL); 90 | 91 | // lv_obj_set_style_border_color(ui.imgbtn_list[8], lv_color_hex(0xff00ff), 0); 92 | // lv_obj_set_style_border_side(ui.imgbtn_list[8], LV_BORDER_SIDE_FULL, 0); 93 | // lv_obj_set_style_border_width(ui.imgbtn_list[8], 1, 0); 94 | // lv_obj_set_style_radius(ui.imgbtn_list[8], 0, 0); 95 | // lv_obj_set_style_border_post(ui.imgbtn_list[8], true, 0); 96 | } 97 | 98 | void HomeMenuView::Delete() { 99 | } 100 | -------------------------------------------------------------------------------- /src/pages/HomeMenu/HomeMenuView.h: -------------------------------------------------------------------------------- 1 | #ifndef __HOMEMENU_VIEW_H 2 | #define __HOMEMENU_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class HomeMenuView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | #if defined(M5CORES3) 16 | lv_obj_t* img_bg; 17 | #elif defined(M5CORES3SE) 18 | lv_obj_t* img_bg_se; 19 | #endif 20 | 21 | lv_obj_t* imgbtn_list[9]; 22 | } ui; 23 | 24 | private: 25 | }; 26 | 27 | } // namespace Page 28 | 29 | #endif // !__VIEW_H 30 | -------------------------------------------------------------------------------- /src/pages/Page.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * Copyright (c) 2021 _VIFEXTech 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | #ifndef __PAGE_H 24 | #define __PAGE_H 25 | 26 | #include 27 | #include 28 | #include "esp_camera.h" 29 | #include "M5Unified.h" 30 | #include "M5GFX.h" 31 | #include "lvgl.h" 32 | #include "config.h" 33 | 34 | #include "PageManager.h" 35 | #include "lv_obj_ext_func.h" 36 | #include "lv_anim_timeline_wrapper.h" 37 | #include "lv_anim_label.h" 38 | 39 | #include "res/ResourcePool.h" 40 | 41 | #define ANIM_DEF(start_time, obj, attr, start, end, time) \ 42 | { \ 43 | start_time, obj, LV_ANIM_EXEC(attr), start, end, time, \ 44 | lv_anim_path_ease_out, true \ 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/pages/StartUp/StartUp.cpp: -------------------------------------------------------------------------------- 1 | #include "StartUp.h" 2 | 3 | using namespace Page; 4 | 5 | StartUp::StartUp() : timer(nullptr) { 6 | } 7 | 8 | StartUp::~StartUp() { 9 | } 10 | 11 | void StartUp::onCustomAttrConfig() { 12 | LV_LOG_USER(__func__); 13 | } 14 | 15 | void StartUp::onViewLoad() { 16 | LV_LOG_USER(__func__); 17 | 18 | View.Create(_root); 19 | AttachEvent(_root); 20 | } 21 | 22 | void StartUp::onViewDidLoad() { 23 | LV_LOG_USER(__func__); 24 | } 25 | 26 | void StartUp::onViewWillAppear() { 27 | LV_LOG_USER(__func__); 28 | 29 | M5.Speaker.playWav((const uint8_t*)ResourcePool::GetWav("poweron_2_5s"), 30 | ~0u, 1, 1); 31 | 32 | timer = lv_timer_create(onTimerUpdate, 50, this); 33 | lv_anim_timeline_start(View.ui.anim_timeline); 34 | } 35 | 36 | void StartUp::onViewDidAppear() { 37 | LV_LOG_USER(__func__); 38 | } 39 | 40 | void StartUp::onViewWillDisappear() { 41 | LV_LOG_USER(__func__); 42 | } 43 | 44 | void StartUp::onViewDidDisappear() { 45 | LV_LOG_USER(__func__); 46 | lv_timer_del(timer); 47 | } 48 | 49 | void StartUp::onViewUnload() { 50 | LV_LOG_USER(__func__); 51 | 52 | View.Delete(); 53 | } 54 | 55 | void StartUp::onViewDidUnload() { 56 | LV_LOG_USER(__func__); 57 | } 58 | 59 | void StartUp::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 60 | lv_obj_set_user_data(obj, this); 61 | lv_obj_add_event_cb(obj, onEvent, code, this); 62 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 63 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 64 | } 65 | 66 | void StartUp::Update() { 67 | if (M5.Display.getBrightness() < 100) { 68 | M5.Display.setBrightness(M5.Display.getBrightness() + 5); 69 | } 70 | #if defined(M5CORES3) 71 | if (count > 50) { 72 | lv_obj_clear_flag(View.ui.img_cores3_diagram, LV_OBJ_FLAG_HIDDEN); 73 | } 74 | #elif defined(M5CORES3SE) 75 | if (count > 50) { 76 | lv_obj_clear_flag(View.ui.img_cores3_diagram_se, LV_OBJ_FLAG_HIDDEN); 77 | } 78 | #endif 79 | 80 | count++; 81 | } 82 | 83 | void StartUp::onTimerUpdate(lv_timer_t* timer) { 84 | StartUp* instance = (StartUp*)timer->user_data; 85 | 86 | instance->Update(); 87 | } 88 | 89 | void StartUp::onEvent(lv_event_t* event) { 90 | StartUp* instance = (StartUp*)lv_event_get_user_data(event); 91 | LV_ASSERT_NULL(instance); 92 | 93 | lv_obj_t* obj = lv_event_get_current_target(event); 94 | lv_event_code_t code = lv_event_get_code(event); 95 | 96 | if (obj == instance->_root) { 97 | if (code == LV_EVENT_GESTURE) { 98 | lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act()); 99 | if (dir == LV_DIR_TOP) { 100 | // lv_obj_clear_flag(instance->View.ui.img_cores3_diagram, 101 | // LV_OBJ_FLAG_HIDDEN); 102 | } 103 | #if MONKEY_TEST_ENABLE 104 | } else if (code == LV_EVENT_LONG_PRESSED || code == LV_EVENT_CLICKED) { 105 | #else 106 | } else if (code == LV_EVENT_CLICKED) { 107 | #endif 108 | M5.Speaker.playWav( 109 | (const uint8_t*)ResourcePool::GetWav("select_0_5s"), ~0u, 1, 1); 110 | instance->_Manager->Replace("Pages/HomeMenu"); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/pages/StartUp/StartUp.h: -------------------------------------------------------------------------------- 1 | #ifndef __STARTUP_PRESENTER_H 2 | #define __STARTUP_PRESENTER_H 3 | 4 | #include "StartUpView.h" 5 | #include "StartUpModel.h" 6 | 7 | namespace Page { 8 | 9 | class StartUp : public PageBase { 10 | public: 11 | StartUp(); 12 | virtual ~StartUp(); 13 | 14 | virtual void onCustomAttrConfig(); 15 | virtual void onViewLoad(); 16 | virtual void onViewDidLoad(); 17 | virtual void onViewWillAppear(); 18 | virtual void onViewDidAppear(); 19 | virtual void onViewWillDisappear(); 20 | virtual void onViewDidDisappear(); 21 | virtual void onViewUnload(); 22 | virtual void onViewDidUnload(); 23 | 24 | private: 25 | void Update(); 26 | void AttachEvent(lv_obj_t* obj) { 27 | AttachEvent(obj, LV_EVENT_ALL); 28 | } 29 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 30 | static void onTimerUpdate(lv_timer_t* timer); 31 | static void onEvent(lv_event_t* event); 32 | 33 | private: 34 | StartUpView View; 35 | StartUpModel Model; 36 | lv_timer_t* timer; 37 | 38 | uint8_t count = 0; 39 | }; 40 | 41 | } // namespace Page 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/pages/StartUp/StartUpModel.cpp: -------------------------------------------------------------------------------- 1 | #include "StartUpModel.h" 2 | 3 | using namespace Page; 4 | -------------------------------------------------------------------------------- /src/pages/StartUp/StartUpModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __STARTUP_MODEL_H 2 | #define __STARTUP_MODEL_H 3 | 4 | #include "lvgl.h" 5 | 6 | namespace Page { 7 | 8 | class StartUpModel { 9 | public: 10 | private: 11 | }; 12 | 13 | } // namespace Page 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/pages/StartUp/StartUpView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "StartUpView.h" 4 | 5 | using namespace Page; 6 | 7 | void StartUpView::Create(lv_obj_t* root) { 8 | #if defined(M5CORES3) 9 | ui.img_core_text = lv_img_create(root); 10 | lv_img_set_src(ui.img_core_text, ResourcePool::GetImage("core_text")); 11 | // lv_obj_align(ui.img_core_text, LV_ALIGN_CENTER, 0, -40); 12 | lv_obj_set_pos(ui.img_core_text, 78, -40); 13 | ui.img_s3_text = lv_img_create(root); 14 | lv_img_set_src(ui.img_s3_text, ResourcePool::GetImage("s3_text")); 15 | // lv_obj_align(ui.img_s3_text, LV_ALIGN_CENTER, 0, 340); 16 | lv_obj_set_pos(ui.img_s3_text, 78, 340); 17 | 18 | ui.anim_timeline = lv_anim_timeline_create(); 19 | lv_anim_timeline_wrapper_t wrapper[] = { 20 | ANIM_DEF(0, ui.img_core_text, y, -40, 45, 800), 21 | ANIM_DEF(0, ui.img_s3_text, y, 340, 90, 800), 22 | LV_ANIM_TIMELINE_WRAPPER_END}; 23 | lv_anim_timeline_add_wrapper(ui.anim_timeline, wrapper); 24 | ui.img_cores3_diagram = lv_img_create(root); 25 | lv_img_set_src(ui.img_cores3_diagram, 26 | ResourcePool::GetImage("cores3_diagram")); 27 | lv_obj_align(ui.img_cores3_diagram, LV_ALIGN_CENTER, 0, 0); 28 | lv_obj_add_flag(ui.img_cores3_diagram, LV_OBJ_FLAG_HIDDEN); 29 | #elif defined(M5CORES3SE) 30 | ui.img_core_text_se = lv_img_create(root); 31 | lv_img_set_src(ui.img_core_text_se, ResourcePool::GetImage("core_text_se")); 32 | // lv_obj_align(ui.img_core_text, LV_ALIGN_CENTER, 0, -40); 33 | lv_obj_set_pos(ui.img_core_text_se, 78, -40); 34 | ui.img_s3_text_se = lv_img_create(root); 35 | lv_img_set_src(ui.img_s3_text_se, ResourcePool::GetImage("s3_text_se")); 36 | // lv_obj_align(ui.img_s3_text, LV_ALIGN_CENTER, 0, 340); 37 | lv_obj_set_pos(ui.img_s3_text_se, 78, 340); 38 | 39 | ui.anim_timeline = lv_anim_timeline_create(); 40 | lv_anim_timeline_wrapper_t wrapper[] = { 41 | ANIM_DEF(0, ui.img_core_text_se, y, -40, 45, 800), 42 | ANIM_DEF(0, ui.img_s3_text_se, y, 340, 90, 800), 43 | LV_ANIM_TIMELINE_WRAPPER_END}; 44 | 45 | lv_anim_timeline_add_wrapper(ui.anim_timeline, wrapper); 46 | ui.img_cores3_diagram_se = lv_img_create(root); 47 | lv_img_set_src(ui.img_cores3_diagram_se, 48 | ResourcePool::GetImage("cores3_diagram_se")); 49 | lv_obj_align(ui.img_cores3_diagram_se, LV_ALIGN_CENTER, 0, 0); 50 | lv_obj_add_flag(ui.img_cores3_diagram_se, LV_OBJ_FLAG_HIDDEN); 51 | #endif 52 | } 53 | 54 | void StartUpView::Delete() 55 | { 56 | if(ui.anim_timeline) 57 | { 58 | lv_anim_timeline_del(ui.anim_timeline); 59 | ui.anim_timeline = nullptr; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/pages/StartUp/StartUpView.h: -------------------------------------------------------------------------------- 1 | #ifndef __STARTUP_VIEW_H 2 | #define __STARTUP_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class StartUpView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | #if defined(M5CORES3) 16 | lv_obj_t* img_s3_text; 17 | lv_obj_t* img_core_text; 18 | lv_obj_t* img_cores3_diagram; 19 | #elif defined(M5CORES3SE) 20 | lv_obj_t* img_s3_text_se; 21 | lv_obj_t* img_core_text_se; 22 | lv_obj_t* img_cores3_diagram_se; 23 | #endif 24 | // lv_obj_t* btn_next; 25 | 26 | lv_anim_timeline_t* anim_timeline; 27 | } ui; 28 | 29 | private: 30 | }; 31 | 32 | } // namespace Page 33 | 34 | #endif // !__VIEW_H 35 | -------------------------------------------------------------------------------- /src/pages/_Template/Template.cpp: -------------------------------------------------------------------------------- 1 | #include "Template.h" 2 | 3 | using namespace Page; 4 | 5 | Template::Template() : timer(nullptr) { 6 | } 7 | 8 | Template::~Template() { 9 | } 10 | 11 | void Template::onCustomAttrConfig() { 12 | LV_LOG_USER(__func__); 13 | // SetCustomCacheEnable(true); 14 | // SetCustomLoadAnimType(PageManager::LOAD_ANIM_OVER_BOTTOM, 1000, 15 | // lv_anim_path_bounce); 16 | } 17 | 18 | void Template::onViewLoad() { 19 | LV_LOG_USER(__func__); 20 | View.Create(_root); 21 | lv_label_set_text(View.ui.labelTitle, _Name); 22 | 23 | AttachEvent(_root); 24 | 25 | Model.TickSave = Model.GetData(); 26 | } 27 | 28 | void Template::onViewDidLoad() { 29 | LV_LOG_USER(__func__); 30 | } 31 | 32 | void Template::onViewWillAppear() { 33 | LV_LOG_USER(__func__); 34 | Param_t param; 35 | param.color = lv_color_white(); 36 | param.time = 1000; 37 | 38 | PAGE_STASH_POP(param); 39 | 40 | lv_obj_set_style_bg_color(_root, param.color, LV_PART_MAIN); 41 | lv_obj_set_style_bg_opa(_root, LV_OPA_COVER, LV_PART_MAIN); 42 | timer = lv_timer_create(onTimerUpdate, param.time, this); 43 | } 44 | 45 | void Template::onViewDidAppear() { 46 | LV_LOG_USER(__func__); 47 | } 48 | 49 | void Template::onViewWillDisappear() { 50 | LV_LOG_USER(__func__); 51 | } 52 | 53 | void Template::onViewDidDisappear() { 54 | LV_LOG_USER(__func__); 55 | lv_timer_del(timer); 56 | } 57 | 58 | void Template::onViewUnload() { 59 | LV_LOG_USER(__func__); 60 | 61 | View.Delete(); 62 | } 63 | 64 | void Template::onViewDidUnload() { 65 | LV_LOG_USER(__func__); 66 | } 67 | 68 | void Template::AttachEvent(lv_obj_t* obj, lv_event_code_t code) { 69 | lv_obj_set_user_data(obj, this); 70 | lv_obj_add_event_cb(obj, onEvent, code, this); 71 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE); 72 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); 73 | } 74 | 75 | void Template::Update() { 76 | lv_label_set_text_fmt(View.ui.labelTick, "tick = %d save = %d", 77 | Model.GetData(), Model.TickSave); 78 | } 79 | 80 | void Template::onTimerUpdate(lv_timer_t* timer) { 81 | Template* instance = (Template*)timer->user_data; 82 | 83 | instance->Update(); 84 | } 85 | 86 | void Template::onEvent(lv_event_t* event) { 87 | Template* instance = (Template*)lv_event_get_user_data(event); 88 | LV_ASSERT_NULL(instance); 89 | 90 | lv_obj_t* obj = lv_event_get_current_target(event); 91 | lv_event_code_t code = lv_event_get_code(event); 92 | 93 | if (obj == instance->_root) { 94 | if (code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LEAVE) { 95 | // instance->_Manager->Pop(); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/pages/_Template/Template.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEMPLATE_PRESENTER_H 2 | #define __TEMPLATE_PRESENTER_H 3 | 4 | #include "TemplateView.h" 5 | #include "TemplateModel.h" 6 | 7 | namespace Page { 8 | 9 | class Template : public PageBase { 10 | public: 11 | typedef struct { 12 | uint16_t time; 13 | lv_color_t color; 14 | } Param_t; 15 | 16 | public: 17 | Template(); 18 | virtual ~Template(); 19 | 20 | virtual void onCustomAttrConfig(); 21 | virtual void onViewLoad(); 22 | virtual void onViewDidLoad(); 23 | virtual void onViewWillAppear(); 24 | virtual void onViewDidAppear(); 25 | virtual void onViewWillDisappear(); 26 | virtual void onViewDidDisappear(); 27 | virtual void onViewUnload(); 28 | virtual void onViewDidUnload(); 29 | 30 | private: 31 | void Update(); 32 | void AttachEvent(lv_obj_t* obj) { 33 | AttachEvent(obj, LV_EVENT_ALL); 34 | } 35 | void AttachEvent(lv_obj_t* obj, lv_event_code_t code); 36 | static void onTimerUpdate(lv_timer_t* timer); 37 | static void onEvent(lv_event_t* event); 38 | 39 | private: 40 | TemplateView View; 41 | TemplateModel Model; 42 | lv_timer_t* timer; 43 | }; 44 | 45 | } // namespace Page 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/pages/_Template/TemplateModel.cpp: -------------------------------------------------------------------------------- 1 | #include "TemplateModel.h" 2 | 3 | using namespace Page; 4 | 5 | uint32_t TemplateModel::GetData() { 6 | return lv_tick_get(); 7 | } 8 | -------------------------------------------------------------------------------- /src/pages/_Template/TemplateModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEMPLATE_MODEL_H 2 | #define __TEMPLATE_MODEL_H 3 | 4 | #include "lvgl.h" 5 | 6 | namespace Page { 7 | 8 | class TemplateModel { 9 | public: 10 | uint32_t TickSave; 11 | uint32_t GetData(); 12 | 13 | private: 14 | }; 15 | 16 | } // namespace Page 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/pages/_Template/TemplateView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "TemplateView.h" 4 | 5 | using namespace Page; 6 | 7 | void TemplateView::Create(lv_obj_t* root) { 8 | lv_obj_t* label = lv_label_create(root); 9 | lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 20); 10 | lv_label_set_text(label, ""); 11 | ui.labelTitle = label; 12 | 13 | label = lv_label_create(root); 14 | lv_label_set_text(label, ""); 15 | lv_obj_center(label); 16 | ui.labelTick = label; 17 | } 18 | 19 | void TemplateView::Delete() { 20 | } -------------------------------------------------------------------------------- /src/pages/_Template/TemplateView.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEMPLATE_VIEW_H 2 | #define __TEMPLATE_VIEW_H 3 | 4 | #include "../Page.h" 5 | 6 | namespace Page { 7 | 8 | class TemplateView { 9 | public: 10 | void Create(lv_obj_t* root); 11 | void Delete(); 12 | 13 | public: 14 | struct { 15 | lv_obj_t* labelTitle; 16 | lv_obj_t* labelTick; 17 | } ui; 18 | 19 | private: 20 | }; 21 | 22 | } // namespace Page 23 | 24 | #endif // !__VIEW_H 25 | -------------------------------------------------------------------------------- /src/res/ResourcePool.cpp: -------------------------------------------------------------------------------- 1 | #include "ResourcePool.h" 2 | #include "ResourceManager.h" 3 | 4 | static ResourceManager Font_; 5 | static ResourceManager Image_; 6 | static ResourceManager Wav_; 7 | 8 | extern "C" { 9 | #define IMPORT_FONT(name) \ 10 | do { \ 11 | LV_FONT_DECLARE(name) \ 12 | Font_.AddResource(#name, (void*)&name); \ 13 | } while (0) 14 | 15 | #define IMPORT_IMG(name) \ 16 | do { \ 17 | LV_IMG_DECLARE(name) \ 18 | Image_.AddResource(#name, (void*)&name); \ 19 | } while (0) 20 | 21 | #define IMPORT_WAV(name, size) \ 22 | do { \ 23 | extern const unsigned char name[size]; \ 24 | Wav_.AddResource(#name, (void*)&name); \ 25 | } while (0) 26 | 27 | static void Resource_Init() { 28 | /* Import Fonts */ 29 | IMPORT_FONT(ubuntu_mono_8); 30 | IMPORT_FONT(alibaba_pht_26); 31 | 32 | /* Import Images */ 33 | IMPORT_IMG(app_i2c_internal); 34 | IMPORT_IMG(app_i2c_pa); 35 | IMPORT_IMG(app_i2c_pb); 36 | IMPORT_IMG(app_i2c_pc); 37 | IMPORT_IMG(app_mic); 38 | IMPORT_IMG(app_power_ii); 39 | IMPORT_IMG(app_power_io); 40 | IMPORT_IMG(app_power_oi); 41 | IMPORT_IMG(app_power_oo); 42 | IMPORT_IMG(app_power_bat0); 43 | IMPORT_IMG(app_power_bat1); 44 | IMPORT_IMG(app_power_bat2); 45 | IMPORT_IMG(app_power_busin); 46 | IMPORT_IMG(app_power_busout); 47 | IMPORT_IMG(app_power_usbin); 48 | IMPORT_IMG(app_power_usbout); 49 | IMPORT_IMG(app_rtc); 50 | IMPORT_IMG(app_sd); 51 | IMPORT_IMG(app_touch_min); 52 | IMPORT_IMG(app_touch); 53 | IMPORT_IMG(app_wifi); 54 | IMPORT_IMG(background); 55 | IMPORT_IMG(ball); 56 | IMPORT_IMG(compass_face); 57 | IMPORT_IMG(cross); 58 | IMPORT_IMG(failed); 59 | IMPORT_IMG(home_p); 60 | IMPORT_IMG(home_r); 61 | IMPORT_IMG(info_text); 62 | IMPORT_IMG(next_p); 63 | IMPORT_IMG(next_r); 64 | IMPORT_IMG(pass); 65 | 66 | #if defined(M5CORES3) 67 | IMPORT_IMG(s3_text); 68 | IMPORT_IMG(app_camera); 69 | IMPORT_IMG(app_camera_als); 70 | IMPORT_IMG(app_camera_als_ps); 71 | IMPORT_IMG(app_camera_ps); 72 | IMPORT_IMG(app_imu_graphic); 73 | IMPORT_IMG(app_imu_raw); 74 | IMPORT_IMG(core_text); 75 | IMPORT_IMG(cores3_diagram); 76 | IMPORT_IMG(menu_bg); 77 | IMPORT_IMG(menu); 78 | #elif defined(M5CORES3SE) 79 | IMPORT_IMG(s3_text_se); 80 | IMPORT_IMG(menu_se); 81 | IMPORT_IMG(menu_bg_se); 82 | IMPORT_IMG(cores3_diagram_se); 83 | IMPORT_IMG(core_text_se); 84 | #endif 85 | /* Import WAV */ 86 | IMPORT_WAV(poweron_2_5s, 441538); 87 | IMPORT_WAV(select_0_5s, 88738); 88 | } 89 | 90 | } /* extern "C" */ 91 | 92 | void ResourcePool::Init() { 93 | Resource_Init(); 94 | Font_.SetDefault((void*)LV_FONT_DEFAULT); 95 | } 96 | 97 | lv_font_t* ResourcePool::GetFont(const char* name) { 98 | return (lv_font_t*)Font_.GetResource(name); 99 | } 100 | const void* ResourcePool::GetImage(const char* name) { 101 | return Image_.GetResource(name); 102 | } 103 | const void* ResourcePool::GetWav(const char* name) { 104 | return Wav_.GetResource(name); 105 | } 106 | -------------------------------------------------------------------------------- /src/res/ResourcePool.h: -------------------------------------------------------------------------------- 1 | #ifndef __RESOURCE_POOL 2 | #define __RESOURCE_POOL 3 | 4 | #include "lvgl.h" 5 | 6 | namespace ResourcePool { 7 | 8 | void Init(); 9 | lv_font_t* GetFont(const char* name); 10 | const void* GetImage(const char* name); 11 | const void* GetWav(const char* name); 12 | 13 | } // namespace ResourcePool 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/res/font/alibaba_pht_list.txt: -------------------------------------------------------------------------------- 1 | 上下一步通过完成失败工厂产测模式返回退出开始步骤摄像头电源按键屏幕测试红绿蓝黑内部设备测试结果0123456789PORTABCLEDI2CPSRAMFLASHWIFIi灯闪烁是否扫描中麦克风触摸进入流程等待连接中成功不/?,. -------------------------------------------------------------------------------- /src/res/img/raw/app_camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_camera.png -------------------------------------------------------------------------------- /src/res/img/raw/app_camera_als.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_camera_als.png -------------------------------------------------------------------------------- /src/res/img/raw/app_camera_als_ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_camera_als_ps.png -------------------------------------------------------------------------------- /src/res/img/raw/app_camera_ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_camera_ps.png -------------------------------------------------------------------------------- /src/res/img/raw/app_i2c_internal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_i2c_internal.png -------------------------------------------------------------------------------- /src/res/img/raw/app_i2c_pa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_i2c_pa.png -------------------------------------------------------------------------------- /src/res/img/raw/app_i2c_pb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_i2c_pb.png -------------------------------------------------------------------------------- /src/res/img/raw/app_i2c_pc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_i2c_pc.png -------------------------------------------------------------------------------- /src/res/img/raw/app_imu_graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_imu_graphic.png -------------------------------------------------------------------------------- /src/res/img/raw/app_imu_raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_imu_raw.png -------------------------------------------------------------------------------- /src/res/img/raw/app_mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_mic.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_bat0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_bat0.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_bat1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_bat1.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_bat2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_bat2.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_busin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_busin.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_busout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_busout.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_ii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_ii.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_io.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_io.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_oi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_oi.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_oo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_oo.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_usbin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_usbin.png -------------------------------------------------------------------------------- /src/res/img/raw/app_power_usbout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_power_usbout.png -------------------------------------------------------------------------------- /src/res/img/raw/app_rtc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_rtc.png -------------------------------------------------------------------------------- /src/res/img/raw/app_sd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_sd.png -------------------------------------------------------------------------------- /src/res/img/raw/app_touch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_touch.png -------------------------------------------------------------------------------- /src/res/img/raw/app_touch_min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_touch_min.png -------------------------------------------------------------------------------- /src/res/img/raw/app_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/app_wifi.png -------------------------------------------------------------------------------- /src/res/img/raw/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/background.png -------------------------------------------------------------------------------- /src/res/img/raw/ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/ball.png -------------------------------------------------------------------------------- /src/res/img/raw/compass_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/compass_face.png -------------------------------------------------------------------------------- /src/res/img/raw/core_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/core_text.png -------------------------------------------------------------------------------- /src/res/img/raw/core_text_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/core_text_se.png -------------------------------------------------------------------------------- /src/res/img/raw/cores3_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/cores3_diagram.png -------------------------------------------------------------------------------- /src/res/img/raw/cores3_diagram_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/cores3_diagram_se.png -------------------------------------------------------------------------------- /src/res/img/raw/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/cross.png -------------------------------------------------------------------------------- /src/res/img/raw/cursor_hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/cursor_hand.png -------------------------------------------------------------------------------- /src/res/img/raw/failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/failed.png -------------------------------------------------------------------------------- /src/res/img/raw/home_p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/home_p.png -------------------------------------------------------------------------------- /src/res/img/raw/home_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/home_r.png -------------------------------------------------------------------------------- /src/res/img/raw/info_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/info_text.png -------------------------------------------------------------------------------- /src/res/img/raw/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_bg.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_bg_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_bg_se.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_cam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_cam.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_cam_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_cam_se.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_i2c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_i2c.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_imu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_imu.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_imu_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_imu_se.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_mic.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_power.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_power.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_sd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_sd.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_se.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_sys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_sys.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_touch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_touch.png -------------------------------------------------------------------------------- /src/res/img/raw/menu_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/menu_wifi.png -------------------------------------------------------------------------------- /src/res/img/raw/next_p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/next_p.png -------------------------------------------------------------------------------- /src/res/img/raw/next_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/next_r.png -------------------------------------------------------------------------------- /src/res/img/raw/pass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/pass.png -------------------------------------------------------------------------------- /src/res/img/raw/s3_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/s3_text.png -------------------------------------------------------------------------------- /src/res/img/raw/s3_text_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/img/raw/s3_text_se.png -------------------------------------------------------------------------------- /src/res/wav/raw/poweron_2_5s.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/wav/raw/poweron_2_5s.wav -------------------------------------------------------------------------------- /src/res/wav/raw/select_0_5s.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/CoreS3-UserDemo/90cbcc6ca40c2404de05d3f9fdb01223ae19d3f0/src/res/wav/raw/select_0_5s.wav -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Test Runner and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/en/latest/advanced/unit-testing/index.html 12 | --------------------------------------------------------------------------------