diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 6a553a6c0..b61417dc2 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -46,32 +46,45 @@ jobs: additional-sketch-paths: | - libraries/PDM - libraries/ThreadDebug + - libraries/USBHID + - libraries/USBMSD/examples/Nano33BLE_FlashMassStorage - board: fqbn: arduino:mbed:envie_m4 + additional-libraries: | + - name: lvgl additional-sketch-paths: | - libraries/doom - libraries/KernelDebug - libraries/Portenta_SDCARD + - libraries/Portenta_SDRAM - libraries/Portenta_Video - libraries/RPC - board: fqbn: arduino:mbed:envie_m7 + additional-libraries: | + - name: lvgl + version: 7.11.0 additional-sketch-paths: | - libraries/PDM - libraries/doom - libraries/KernelDebug - libraries/Portenta_Camera/examples + - libraries/Portenta_lvgl/examples/Portenta_lvgl - libraries/Portenta_SDCARD + - libraries/Portenta_SDRAM - libraries/Portenta_System - libraries/Portenta_Video - libraries/RPC - libraries/ThreadDebug + - libraries/USBHID - libraries/USBHOST + - libraries/USBMSD/examples/AccessFlashAsUSBDisk - libraries/WiFi - board: fqbn: arduino:mbed:nanorp2040connect additional-sketch-paths: | - libraries/PDM + - libraries/USBHID - ~/Arduino/libraries/WiFiNINA - board: fqbn: arduino:mbed:nicla_sense @@ -99,6 +112,7 @@ jobs: fqbn: ${{ matrix.board.fqbn }} libraries: | - name: WiFiNINA + ${{ matrix.additional-libraries }} platforms: | # Use Board Manager to install the latest release of Arduino mbed Boards to get the toolchain - name: "arduino:mbed" diff --git a/libraries/LittleVGL/examples/Portenta_lvgl/Portenta_lvgl.ino b/libraries/LittleVGL/examples/Portenta_lvgl/Portenta_lvgl.ino deleted file mode 100644 index 896771df7..000000000 --- a/libraries/LittleVGL/examples/Portenta_lvgl/Portenta_lvgl.ino +++ /dev/null @@ -1,176 +0,0 @@ -#include -#include "mbed.h" - -#include "Portenta_Video.h" -#include "SDRAM.h" -#include "lv_demo_widgets.h" - -static uint32_t lcd_x_size = 0; -static uint32_t lcd_y_size = 0; - -static uint16_t * fb; -static lv_disp_drv_t disp_drv; - -/* Display flushing */ -static void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) -{ - -#if ARDUINO_PORTENTA_H7_M7 - SCB_CleanInvalidateDCache(); - SCB_InvalidateICache(); -#endif - - DMA2D_HandleTypeDef * dma2d = stm32_get_DMA2D(); - - lv_color_t * pDst = (lv_color_t*)fb; - pDst += area->y1 * lcd_x_size + area->x1; - - uint32_t w = lv_area_get_width(area); - uint32_t h = lv_area_get_height(area); - /*##-1- Configure the DMA2D Mode, Color Mode and output offset #############*/ - dma2d->Init.Mode = DMA2D_M2M; - dma2d->Init.ColorMode = DMA2D_OUTPUT_RGB565; - dma2d->Init.OutputOffset = lcd_x_size - w; - dma2d->Init.AlphaInverted = DMA2D_REGULAR_ALPHA; /* No Output Alpha Inversion*/ - dma2d->Init.RedBlueSwap = DMA2D_RB_REGULAR; /* No Output Red & Blue swap */ - - /*##-2- DMA2D Callbacks Configuration ######################################*/ - dma2d->XferCpltCallback = NULL; - - /*##-3- Foreground Configuration ###########################################*/ - dma2d->LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; - dma2d->LayerCfg[1].InputAlpha = 0xFF; - dma2d->LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565; - dma2d->LayerCfg[1].InputOffset = 0; - dma2d->LayerCfg[1].RedBlueSwap = DMA2D_RB_REGULAR; /* No ForeGround Red/Blue swap */ - dma2d->LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA; /* No ForeGround Alpha inversion */ - - /* DMA2D Initialization */ - if (HAL_DMA2D_Init(dma2d) == HAL_OK) { - if (HAL_DMA2D_ConfigLayer(dma2d, 1) == HAL_OK) { - HAL_DMA2D_Start(dma2d, (uint32_t)color_p, (uint32_t)pDst, w, h); - HAL_DMA2D_PollForTransfer(dma2d, 1000); - } - } - - lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */ -} - - -/* If your MCU has hardware accelerator (GPU) then you can use it to blend to memories using opacity - It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ -static void gpu_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa) -{ - -#if ARDUINO_PORTENTA_H7_M7 - SCB_CleanInvalidateDCache(); -#endif - - DMA2D_HandleTypeDef * dma2d = stm32_get_DMA2D(); - - dma2d->Instance = DMA2D; - dma2d->Init.Mode = DMA2D_M2M_BLEND; - dma2d->Init.OutputOffset = 0; - - /* Foreground layer */ - dma2d->LayerCfg[1].AlphaMode = DMA2D_REPLACE_ALPHA; - dma2d->LayerCfg[1].InputAlpha = opa; - dma2d->LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565; - dma2d->LayerCfg[1].InputOffset = 0; - dma2d->LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA; - - /* Background layer */ - dma2d->LayerCfg[0].AlphaMode = DMA2D_NO_MODIF_ALPHA; - dma2d->LayerCfg[0].InputColorMode = DMA2D_INPUT_RGB565; - dma2d->LayerCfg[0].InputOffset = 0; - - /* DMA2D Initialization */ - if (HAL_DMA2D_Init(dma2d) == HAL_OK) { - if (HAL_DMA2D_ConfigLayer(dma2d, 0) == HAL_OK && HAL_DMA2D_ConfigLayer(dma2d, 1) == HAL_OK) { - HAL_DMA2D_BlendingStart(dma2d, (uint32_t) src, (uint32_t) dest, (uint32_t) dest, length, 1); - HAL_DMA2D_PollForTransfer(dma2d, 1000); - } - } -} - -/* If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color */ -static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, - const lv_area_t * fill_area, lv_color_t color) -{ -#if ARDUINO_PORTENTA_H7_M7 - SCB_CleanInvalidateDCache(); -#endif - - DMA2D_HandleTypeDef * dma2d = stm32_get_DMA2D(); - - lv_color_t * destination = dest_buf + (dest_width * fill_area->y1 + fill_area->x1); - - uint32_t w = fill_area->x2 - fill_area->x1 + 1; - dma2d->Instance = DMA2D; - dma2d->Init.Mode = DMA2D_R2M; - dma2d->Init.ColorMode = DMA2D_OUTPUT_RGB565; - dma2d->Init.OutputOffset = dest_width - w; - dma2d->LayerCfg[1].InputAlpha = DMA2D_NO_MODIF_ALPHA; - dma2d->LayerCfg[1].InputColorMode = DMA2D_OUTPUT_RGB565; - - /* DMA2D Initialization */ - if (HAL_DMA2D_Init(dma2d) == HAL_OK) { - if (HAL_DMA2D_ConfigLayer(dma2d, 1) == HAL_OK) { - lv_coord_t h = lv_area_get_height(fill_area); - if (HAL_DMA2D_BlendingStart(dma2d, lv_color_to32(color), (uint32_t)destination, (uint32_t)destination, w, h) == HAL_OK) { - HAL_DMA2D_PollForTransfer(dma2d, 1000); - } - } - } -} - -struct edid recognized_edid; - -void setup() { - // put your setup code here, to run once: - int ret = -1; - - ret = anx7625_init(0); - if(ret < 0) { - printf("Cannot continue, anx7625 init failed.\n"); - while(1); - } - - anx7625_wait_hpd_event(0); - anx7625_dp_get_edid(0, &recognized_edid); - anx7625_dp_start(0, &recognized_edid, EDID_MODE_720x480_60Hz); - SDRAM.begin(getFramebufferEnd()); - - lv_init(); - - lcd_x_size = stm32_getXSize(); - lcd_y_size = stm32_getYSize(); - - fb = (uint16_t *)getNextFrameBuffer(); - getNextFrameBuffer(); - - static lv_color_t buf[LV_HOR_RES_MAX * LV_VER_RES_MAX / 6]; - static lv_disp_buf_t disp_buf; - lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * LV_VER_RES_MAX / 6); - - /*Initialize the display*/ - lv_disp_drv_init(&disp_drv); - disp_drv.flush_cb = my_disp_flush; - disp_drv.gpu_fill_cb = gpu_fill; - disp_drv.gpu_blend_cb = gpu_blend; - disp_drv.buffer = &disp_buf; - lv_disp_drv_register(&disp_drv); - - /*Hell world label*/ - //lv_obj_t * label = lv_label_create(lv_scr_act(), NULL); - //lv_label_set_text(label, "Hello Arduino! Dev-7,0"); - //lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); - - lv_demo_widgets(); - -} - -void loop() { - lv_task_handler(); - delay(3); -} diff --git a/libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/MBR.h b/libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/MBR.h similarity index 100% rename from libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/MBR.h rename to libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/MBR.h diff --git a/libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/Nano33_updateBLandSoftDevice.ino b/libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/Nano33_updateBLandSoftDevice.ino similarity index 100% rename from libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/Nano33_updateBLandSoftDevice.ino rename to libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/Nano33_updateBLandSoftDevice.ino diff --git a/libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/SoftDevice.h b/libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/SoftDevice.h similarity index 100% rename from libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/SoftDevice.h rename to libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/SoftDevice.h diff --git a/libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/bootloader.h b/libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/bootloader.h similarity index 100% rename from libraries/Nano33_System/examples/Nano33_updateBLandSoftDevice/bootloader.h rename to libraries/Nano33BLE_System/examples/Nano33_updateBLandSoftDevice/bootloader.h diff --git a/libraries/Nano33BLE_System/library.properties b/libraries/Nano33BLE_System/library.properties new file mode 100644 index 000000000..0a49883ae --- /dev/null +++ b/libraries/Nano33BLE_System/library.properties @@ -0,0 +1,9 @@ +name=Nano33BLE_System +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Utility library for Nano 33 BLE +paragraph= +category=Other +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Nano33BLE_System +architectures=mbed,mbed_nano diff --git a/libraries/Nano33_System/Nano33BLE_System.h b/libraries/Nano33BLE_System/src/Nano33BLE_System.h similarity index 100% rename from libraries/Nano33_System/Nano33BLE_System.h rename to libraries/Nano33BLE_System/src/Nano33BLE_System.h diff --git a/libraries/Nicla_System/library.properties b/libraries/Nicla_System/library.properties new file mode 100644 index 000000000..b408a2426 --- /dev/null +++ b/libraries/Nicla_System/library.properties @@ -0,0 +1,9 @@ +name=Nicla_System +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Utility library for Nicla Sense ME +paragraph= +category=Other +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Nicla_System +architectures=mbed,mbed_nicla diff --git a/libraries/Nicla_System/BQ25120A.h b/libraries/Nicla_System/src/BQ25120A.h similarity index 100% rename from libraries/Nicla_System/BQ25120A.h rename to libraries/Nicla_System/src/BQ25120A.h diff --git a/libraries/Nicla_System/Nicla_System.cpp b/libraries/Nicla_System/src/Nicla_System.cpp similarity index 100% rename from libraries/Nicla_System/Nicla_System.cpp rename to libraries/Nicla_System/src/Nicla_System.cpp diff --git a/libraries/Nicla_System/Nicla_System.h b/libraries/Nicla_System/src/Nicla_System.h similarity index 100% rename from libraries/Nicla_System/Nicla_System.h rename to libraries/Nicla_System/src/Nicla_System.h diff --git a/libraries/Nicla_System/RGBled.cpp b/libraries/Nicla_System/src/RGBled.cpp similarity index 100% rename from libraries/Nicla_System/RGBled.cpp rename to libraries/Nicla_System/src/RGBled.cpp diff --git a/libraries/Nicla_System/RGBled.h b/libraries/Nicla_System/src/RGBled.h similarity index 100% rename from libraries/Nicla_System/RGBled.h rename to libraries/Nicla_System/src/RGBled.h diff --git a/libraries/Nicla_System/pmic_driver.cpp b/libraries/Nicla_System/src/pmic_driver.cpp similarity index 100% rename from libraries/Nicla_System/pmic_driver.cpp rename to libraries/Nicla_System/src/pmic_driver.cpp diff --git a/libraries/Portenta_Camera/library.properties b/libraries/Portenta_Camera/library.properties new file mode 100644 index 000000000..3191423c9 --- /dev/null +++ b/libraries/Portenta_Camera/library.properties @@ -0,0 +1,9 @@ +name=Portenta_Camera +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Camera library for Portenta H7 Vision Shield +paragraph= +category=Other +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Portenta_Camera +architectures=mbed,mbed_portenta diff --git a/libraries/Portenta_Camera/camera.cpp b/libraries/Portenta_Camera/src/camera.cpp similarity index 100% rename from libraries/Portenta_Camera/camera.cpp rename to libraries/Portenta_Camera/src/camera.cpp diff --git a/libraries/Portenta_Camera/camera.h b/libraries/Portenta_Camera/src/camera.h similarity index 100% rename from libraries/Portenta_Camera/camera.h rename to libraries/Portenta_Camera/src/camera.h diff --git a/libraries/Portenta_SDCARD/library.properties b/libraries/Portenta_SDCARD/library.properties new file mode 100644 index 000000000..9707ea2b4 --- /dev/null +++ b/libraries/Portenta_SDCARD/library.properties @@ -0,0 +1,9 @@ +name=Portenta_SDCARD +version=1.0 +author=Arduino +maintainer=Arduino +sentence=SDCARD library for Portenta H7 +paragraph= +category=Data Storage +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Portenta_SDCARD +architectures=mbed,mbed_portenta diff --git a/libraries/Portenta_SDCARD/BSP.c b/libraries/Portenta_SDCARD/src/BSP.c similarity index 100% rename from libraries/Portenta_SDCARD/BSP.c rename to libraries/Portenta_SDCARD/src/BSP.c diff --git a/libraries/Portenta_SDCARD/BSP.h b/libraries/Portenta_SDCARD/src/BSP.h similarity index 100% rename from libraries/Portenta_SDCARD/BSP.h rename to libraries/Portenta_SDCARD/src/BSP.h diff --git a/libraries/Portenta_SDCARD/SDMMCBlockDevice.cpp b/libraries/Portenta_SDCARD/src/SDMMCBlockDevice.cpp similarity index 100% rename from libraries/Portenta_SDCARD/SDMMCBlockDevice.cpp rename to libraries/Portenta_SDCARD/src/SDMMCBlockDevice.cpp diff --git a/libraries/Portenta_SDCARD/SDMMCBlockDevice.h b/libraries/Portenta_SDCARD/src/SDMMCBlockDevice.h similarity index 100% rename from libraries/Portenta_SDCARD/SDMMCBlockDevice.h rename to libraries/Portenta_SDCARD/src/SDMMCBlockDevice.h diff --git a/libraries/Portenta_SDRAM/examples/SDRAM_operations/SDRAM_operations.ino b/libraries/Portenta_SDRAM/examples/SDRAM_operations/SDRAM_operations.ino new file mode 100644 index 000000000..f6e0081f7 --- /dev/null +++ b/libraries/Portenta_SDRAM/examples/SDRAM_operations/SDRAM_operations.ino @@ -0,0 +1,70 @@ +/* + How to interact with external SDRAM on Portenta H7 + + The board comes with an hefty 8MB of external fast RAM, which can be used: + - as a framebuffer (raw mode) + - as an expansion of on-chip RAM to store "standard" data + + This example shows both the usages +*/ + +#include "SDRAM.h" + +REDIRECT_STDOUT_TO(Serial); + +void nonFrameBuffer() { + // Initilize SDRAM for non-framebuffer operations + SDRAM.begin(); // is the same as SDRAM.begin(SDRAM_START_ADDRESS); + + // Now we can malloc() and free() in the whole RAM space + // For example, let's create a 7MB array + uint8_t* myVeryBigArray = (uint8_t*)SDRAM.malloc(7 * 1024 * 1024); + + // and a small one + uint8_t* mySmallArray = (uint8_t*)SDRAM.malloc(128); + + // and use then as usual + for (int i = 0; i<128; i++) { + myVeryBigArray[i] = i; + mySmallArray[i] = i*2; + } + + // free the memory when you don't need them anymore + SDRAM.free(myVeryBigArray); +} + +void frameBuffer() { + // In case we want a framebuffer-like area at the beginning of the flash, + // simply initialize the memory as + + SDRAM.begin(SDRAM_START_ADDRESS + 2 * 1024 * 1024); + // 2MB of contiguous memory available at the beginning + + uint32_t* framebuffer = (uint32_t*)SDRAM_START_ADDRESS; + + // We can't allocate anymore the huge 7MB array + + uint8_t* myVeryBigArray = (uint8_t*)SDRAM.malloc(7 * 1024 * 1024); + if (myVeryBigArray == NULL) { + Serial.println("Oops, too big :)"); + } + +} + +void setup() { + Serial.begin(115200); + while (!Serial); + + frameBuffer(); + // Uncomment to test the other functionality + // nonFrameBuffer(); + + // Sort of memtest for stability, useful for testing when overclocking + if (SDRAM.test()) { + Serial.println("SDRAM completely functional"); + } +} + +void loop() { + +} \ No newline at end of file diff --git a/libraries/Portenta_SDRAM/library.properties b/libraries/Portenta_SDRAM/library.properties new file mode 100644 index 000000000..2362db0c1 --- /dev/null +++ b/libraries/Portenta_SDRAM/library.properties @@ -0,0 +1,9 @@ +name=Portenta_SDRAM +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Interact with external SDRAM chip on Portenta H7 +paragraph= +category=Other +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Portenta_SDRAM +architectures=mbed,mbed_portenta diff --git a/libraries/Portenta_SDRAM/SDRAM.cpp b/libraries/Portenta_SDRAM/src/SDRAM.cpp similarity index 100% rename from libraries/Portenta_SDRAM/SDRAM.cpp rename to libraries/Portenta_SDRAM/src/SDRAM.cpp diff --git a/libraries/Portenta_SDRAM/SDRAM.h b/libraries/Portenta_SDRAM/src/SDRAM.h similarity index 100% rename from libraries/Portenta_SDRAM/SDRAM.h rename to libraries/Portenta_SDRAM/src/SDRAM.h diff --git a/libraries/Portenta_SDRAM/ram_internal.c b/libraries/Portenta_SDRAM/src/ram_internal.c similarity index 100% rename from libraries/Portenta_SDRAM/ram_internal.c rename to libraries/Portenta_SDRAM/src/ram_internal.c diff --git a/libraries/Portenta_SDRAM/ram_internal.h b/libraries/Portenta_SDRAM/src/ram_internal.h similarity index 100% rename from libraries/Portenta_SDRAM/ram_internal.h rename to libraries/Portenta_SDRAM/src/ram_internal.h diff --git a/libraries/Portenta_System/Portenta_System.h b/libraries/Portenta_System/Portenta_System.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/libraries/Portenta_System/library.properties b/libraries/Portenta_System/library.properties new file mode 100644 index 000000000..4ab879f9e --- /dev/null +++ b/libraries/Portenta_System/library.properties @@ -0,0 +1,9 @@ +name=Portenta_System +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Utility library for Portenta H7 +paragraph= +category=Other +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Portenta_System +architectures=mbed,mbed_portenta diff --git a/libraries/Portenta_System/src/Portenta_System.h b/libraries/Portenta_System/src/Portenta_System.h new file mode 100644 index 000000000..07eaebc1c --- /dev/null +++ b/libraries/Portenta_System/src/Portenta_System.h @@ -0,0 +1 @@ +// placeholder to display the library examples \ No newline at end of file diff --git a/libraries/Portenta_Video/.development b/libraries/Portenta_Video/.development deleted file mode 100644 index e69de29bb..000000000 diff --git a/libraries/Portenta_Video/examples/ArduinoLogo/ArduinoLogo.ino b/libraries/Portenta_Video/examples/ArduinoLogo/ArduinoLogo.ino new file mode 100644 index 000000000..b675117bf --- /dev/null +++ b/libraries/Portenta_Video/examples/ArduinoLogo/ArduinoLogo.ino @@ -0,0 +1,27 @@ +#include "Portenta_lvgl.h" +#include "Portenta_Video.h" +#include "image.h" + +// Alternatively, any raw RGB565 image can be included on demand using this macro +/* +#define INCBIN_PREFIX +#include "incbin.h" +INCBIN(test, "/home/user/Downloads/test.bin"); +*/ + +int offset; + +void setup() { + portenta_init_video(); + + stm32_LCD_Clear(0); + stm32_LCD_Clear(0); + + offset = ((stm32_getXSize() - 300)) + (stm32_getXSize() * (stm32_getYSize() - 300) / 2) * sizeof(uint16_t); +} + +void loop() { + // Replace texture_raw with testData if using the INCBIN method + // Also, replace 300x300 resolution with the actual one + stm32_LCD_DrawImage((void*)texture_raw, (void *)(getNextFrameBuffer() + offset), 300, 300, DMA2D_INPUT_RGB565); +} diff --git a/libraries/Portenta_Video/examples/Envie_video_coreboot/image_320x240_argb8888.h b/libraries/Portenta_Video/examples/ArduinoLogo/image.h similarity index 99% rename from libraries/Portenta_Video/examples/Envie_video_coreboot/image_320x240_argb8888.h rename to libraries/Portenta_Video/examples/ArduinoLogo/image.h index 26742ec51..1f8007348 100644 --- a/libraries/Portenta_Video/examples/Envie_video_coreboot/image_320x240_argb8888.h +++ b/libraries/Portenta_Video/examples/ArduinoLogo/image.h @@ -1,4 +1,4 @@ -const unsigned char texture_raw[] = { +const unsigned char texture_raw[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libraries/Portenta_Video/examples/ArduinoLogo/incbin.h b/libraries/Portenta_Video/examples/ArduinoLogo/incbin.h new file mode 100644 index 000000000..c19684d72 --- /dev/null +++ b/libraries/Portenta_Video/examples/ArduinoLogo/incbin.h @@ -0,0 +1,368 @@ +/** + * @file incbin.h + * @author Dale Weiler + * @brief Utility for including binary files + * + * Facilities for including binary files into the current translation unit and + * making use from them externally in other translation units. + */ +#ifndef INCBIN_HDR +#define INCBIN_HDR +#include +#if defined(__AVX512BW__) || \ + defined(__AVX512CD__) || \ + defined(__AVX512DQ__) || \ + defined(__AVX512ER__) || \ + defined(__AVX512PF__) || \ + defined(__AVX512VL__) || \ + defined(__AVX512F__) +# define INCBIN_ALIGNMENT_INDEX 6 +#elif defined(__AVX__) || \ + defined(__AVX2__) +# define INCBIN_ALIGNMENT_INDEX 5 +#elif defined(__SSE__) || \ + defined(__SSE2__) || \ + defined(__SSE3__) || \ + defined(__SSSE3__) || \ + defined(__SSE4_1__) || \ + defined(__SSE4_2__) || \ + defined(__neon__) +# define INCBIN_ALIGNMENT_INDEX 4 +#elif ULONG_MAX != 0xffffffffu +# define INCBIN_ALIGNMENT_INDEX 3 +# else +# define INCBIN_ALIGNMENT_INDEX 2 +#endif + +/* Lookup table of (1 << n) where `n' is `INCBIN_ALIGNMENT_INDEX' */ +#define INCBIN_ALIGN_SHIFT_0 1 +#define INCBIN_ALIGN_SHIFT_1 2 +#define INCBIN_ALIGN_SHIFT_2 4 +#define INCBIN_ALIGN_SHIFT_3 8 +#define INCBIN_ALIGN_SHIFT_4 16 +#define INCBIN_ALIGN_SHIFT_5 32 +#define INCBIN_ALIGN_SHIFT_6 64 + +/* Actual alignment value */ +#define INCBIN_ALIGNMENT \ + INCBIN_CONCATENATE( \ + INCBIN_CONCATENATE(INCBIN_ALIGN_SHIFT, _), \ + INCBIN_ALIGNMENT_INDEX) + +/* Stringize */ +#define INCBIN_STR(X) \ + #X +#define INCBIN_STRINGIZE(X) \ + INCBIN_STR(X) +/* Concatenate */ +#define INCBIN_CAT(X, Y) \ + X ## Y +#define INCBIN_CONCATENATE(X, Y) \ + INCBIN_CAT(X, Y) +/* Deferred macro expansion */ +#define INCBIN_EVAL(X) \ + X +#define INCBIN_INVOKE(N, ...) \ + INCBIN_EVAL(N(__VA_ARGS__)) + +/* Green Hills uses a different directive for including binary data */ +#if defined(__ghs__) +# if (__ghs_asm == 2) +# define INCBIN_MACRO ".file" +/* Or consider the ".myrawdata" entry in the ld file */ +# else +# define INCBIN_MACRO "\tINCBIN" +# endif +#else +# define INCBIN_MACRO ".incbin" +#endif + +#ifndef _MSC_VER +# define INCBIN_ALIGN \ + __attribute__((aligned(INCBIN_ALIGNMENT))) +#else +# define INCBIN_ALIGN __declspec(align(INCBIN_ALIGNMENT)) +#endif + +#if defined(__arm__) || /* GNU C and RealView */ \ + defined(__arm) || /* Diab */ \ + defined(_ARM) /* ImageCraft */ +# define INCBIN_ARM +#endif + +#ifdef __GNUC__ +/* Utilize .balign where supported */ +# define INCBIN_ALIGN_HOST ".balign " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n" +# define INCBIN_ALIGN_BYTE ".balign 1\n" +#elif defined(INCBIN_ARM) +/* + * On arm assemblers, the alignment value is calculated as (1 << n) where `n' is + * the shift count. This is the value passed to `.align' + */ +# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT_INDEX) "\n" +# define INCBIN_ALIGN_BYTE ".align 0\n" +#else +/* We assume other inline assembler's treat `.align' as `.balign' */ +# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n" +# define INCBIN_ALIGN_BYTE ".align 1\n" +#endif + +/* INCBIN_CONST is used by incbin.c generated files */ +#if defined(__cplusplus) +# define INCBIN_EXTERNAL extern "C" +# define INCBIN_CONST extern const +#else +# define INCBIN_EXTERNAL extern +# define INCBIN_CONST const +#endif + +/** + * @brief Optionally override the linker section into which data is emitted. + * + * @warning If you use this facility, you'll have to deal with platform-specific linker output + * section naming on your own + * + * Overriding the default linker output section, e.g for esp8266/Arduino: + * @code + * #define INCBIN_OUTPUT_SECTION ".irom.text" + * #include "incbin.h" + * INCBIN(Foo, "foo.txt"); + * // Data is emitted into program memory that never gets copied to RAM + * @endcode + */ +#if !defined(INCBIN_OUTPUT_SECTION) +# if defined(__APPLE__) +# define INCBIN_OUTPUT_SECTION ".const_data" +# else +# define INCBIN_OUTPUT_SECTION ".rodata" +# endif +#endif + +#if defined(__APPLE__) +/* The directives are different for Apple branded compilers */ +# define INCBIN_SECTION INCBIN_OUTPUT_SECTION "\n" +# define INCBIN_GLOBAL(NAME) ".globl " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n" +# define INCBIN_INT ".long " +# define INCBIN_MANGLE "_" +# define INCBIN_BYTE ".byte " +# define INCBIN_TYPE(...) +#else +# define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n" +# define INCBIN_GLOBAL(NAME) ".global " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n" +# if defined(__ghs__) +# define INCBIN_INT ".word " +# else +# define INCBIN_INT ".int " +# endif +# if defined(__USER_LABEL_PREFIX__) +# define INCBIN_MANGLE INCBIN_STRINGIZE(__USER_LABEL_PREFIX__) +# else +# define INCBIN_MANGLE "" +# endif +# if defined(INCBIN_ARM) +/* On arm assemblers, `@' is used as a line comment token */ +# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", %object\n" +# elif defined(__MINGW32__) || defined(__MINGW64__) +/* Mingw doesn't support this directive either */ +# define INCBIN_TYPE(NAME) +# else +/* It's safe to use `@' on other architectures */ +# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n" +# endif +# define INCBIN_BYTE ".byte " +#endif + +/* List of style types used for symbol names */ +#define INCBIN_STYLE_CAMEL 0 +#define INCBIN_STYLE_SNAKE 1 + +/** + * @brief Specify the prefix to use for symbol names. + * + * By default this is `g', producing symbols of the form: + * @code + * #include "incbin.h" + * INCBIN(Foo, "foo.txt"); + * + * // Now you have the following symbols: + * // const unsigned char gFooData[]; + * // const unsigned char *const gFooEnd; + * // const unsigned int gFooSize; + * @endcode + * + * If however you specify a prefix before including: e.g: + * @code + * #define INCBIN_PREFIX incbin + * #include "incbin.h" + * INCBIN(Foo, "foo.txt"); + * + * // Now you have the following symbols instead: + * // const unsigned char incbinFooData[]; + * // const unsigned char *const incbinFooEnd; + * // const unsigned int incbinFooSize; + * @endcode + */ +#if !defined(INCBIN_PREFIX) +# define INCBIN_PREFIX g +#endif + +/** + * @brief Specify the style used for symbol names. + * + * Possible options are + * - INCBIN_STYLE_CAMEL "CamelCase" + * - INCBIN_STYLE_SNAKE "snake_case" + * + * Default option is *INCBIN_STYLE_CAMEL* producing symbols of the form: + * @code + * #include "incbin.h" + * INCBIN(Foo, "foo.txt"); + * + * // Now you have the following symbols: + * // const unsigned char FooData[]; + * // const unsigned char *const FooEnd; + * // const unsigned int FooSize; + * @endcode + * + * If however you specify a style before including: e.g: + * @code + * #define INCBIN_STYLE INCBIN_STYLE_SNAKE + * #include "incbin.h" + * INCBIN(foo, "foo.txt"); + * + * // Now you have the following symbols: + * // const unsigned char foo_data[]; + * // const unsigned char *const foo_end; + * // const unsigned int foo_size; + * @endcode + */ +#if !defined(INCBIN_STYLE) +# define INCBIN_STYLE INCBIN_STYLE_CAMEL +#endif + +/* Style lookup tables */ +#define INCBIN_STYLE_0_DATA Data +#define INCBIN_STYLE_0_END End +#define INCBIN_STYLE_0_SIZE Size +#define INCBIN_STYLE_1_DATA _data +#define INCBIN_STYLE_1_END _end +#define INCBIN_STYLE_1_SIZE _size + +/* Style lookup: returning identifier */ +#define INCBIN_STYLE_IDENT(TYPE) \ + INCBIN_CONCATENATE( \ + INCBIN_STYLE_, \ + INCBIN_CONCATENATE( \ + INCBIN_EVAL(INCBIN_STYLE), \ + INCBIN_CONCATENATE(_, TYPE))) + +/* Style lookup: returning string literal */ +#define INCBIN_STYLE_STRING(TYPE) \ + INCBIN_STRINGIZE( \ + INCBIN_STYLE_IDENT(TYPE)) \ + +/* Generate the global labels by indirectly invoking the macro with our style + * type and concatenating the name against them. */ +#define INCBIN_GLOBAL_LABELS(NAME, TYPE) \ + INCBIN_INVOKE( \ + INCBIN_GLOBAL, \ + INCBIN_CONCATENATE( \ + NAME, \ + INCBIN_INVOKE( \ + INCBIN_STYLE_IDENT, \ + TYPE))) \ + INCBIN_INVOKE( \ + INCBIN_TYPE, \ + INCBIN_CONCATENATE( \ + NAME, \ + INCBIN_INVOKE( \ + INCBIN_STYLE_IDENT, \ + TYPE))) + +/** + * @brief Externally reference binary data included in another translation unit. + * + * Produces three external symbols that reference the binary data included in + * another translation unit. + * + * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with + * "Data", as well as "End" and "Size" after. An example is provided below. + * + * @param NAME The name given for the binary data + * + * @code + * INCBIN_EXTERN(Foo); + * + * // Now you have the following symbols: + * // extern const unsigned char FooData[]; + * // extern const unsigned char *const FooEnd; + * // extern const unsigned int FooSize; + * @endcode + */ +#define INCBIN_EXTERN(NAME) \ + INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char \ + INCBIN_CONCATENATE( \ + INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \ + INCBIN_STYLE_IDENT(DATA))[]; \ + INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char *const \ + INCBIN_CONCATENATE( \ + INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \ + INCBIN_STYLE_IDENT(END)); \ + INCBIN_EXTERNAL const unsigned int \ + INCBIN_CONCATENATE( \ + INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \ + INCBIN_STYLE_IDENT(SIZE)) + +/** + * @brief Include a binary file into the current translation unit. + * + * Includes a binary file into the current translation unit, producing three symbols + * for objects that encode the data and size respectively. + * + * The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with + * "Data", as well as "End" and "Size" after. An example is provided below. + * + * @param NAME The name to associate with this binary data (as an identifier.) + * @param FILENAME The file to include (as a string literal.) + * + * @code + * INCBIN(Icon, "icon.png"); + * + * // Now you have the following symbols: + * // const unsigned char IconData[]; + * // const unsigned char *const IconEnd; + * // const unsigned int IconSize; + * @endcode + * + * @warning This must be used in global scope + * @warning The identifiers may be different if INCBIN_STYLE is not default + * + * To externally reference the data included by this in another translation unit + * please @see INCBIN_EXTERN. + */ +#ifdef _MSC_VER +#define INCBIN(NAME, FILENAME) \ + INCBIN_EXTERN(NAME) +#else +#define INCBIN(NAME, FILENAME) \ + __asm__(INCBIN_SECTION \ + INCBIN_GLOBAL_LABELS(NAME, DATA) \ + INCBIN_ALIGN_HOST \ + INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) ":\n" \ + INCBIN_MACRO " \"" FILENAME "\"\n" \ + INCBIN_GLOBAL_LABELS(NAME, END) \ + INCBIN_ALIGN_BYTE \ + INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) ":\n" \ + INCBIN_BYTE "1\n" \ + INCBIN_GLOBAL_LABELS(NAME, SIZE) \ + INCBIN_ALIGN_HOST \ + INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE) ":\n" \ + INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) " - " \ + INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) "\n" \ + INCBIN_ALIGN_HOST \ + ".text\n" \ + ); \ + INCBIN_EXTERN(NAME) + +#endif +#endif diff --git a/libraries/Portenta_Video/examples/Envie_video_coreboot/Envie_video_coreboot.ino b/libraries/Portenta_Video/examples/Envie_video_coreboot/Envie_video_coreboot.ino deleted file mode 100644 index 1fe2d8f4c..000000000 --- a/libraries/Portenta_Video/examples/Envie_video_coreboot/Envie_video_coreboot.ino +++ /dev/null @@ -1,35 +0,0 @@ -#include "Portenta_Video.h" -#include "image_320x240_argb8888.h" -#include "SDRAM.h" -#include "mbed.h" - -struct edid recognized_edid; - -void setup() { - // put your setup code here, to run once: - int ret = -1; - - ret = anx7625_init(0); - if(ret < 0) { - printf("Cannot continue, anx7625 init failed.\n"); - while(1); - } - - anx7625_wait_hpd_event(0); - anx7625_dp_get_edid(0, &recognized_edid); - anx7625_dp_start(0, &recognized_edid, EDID_MODE_640x480_60Hz); - - SDRAM.begin(getFramebufferEnd()); - while (1) { - stm32_LCD_DrawImage((void*)texture_raw, (void *)getNextFrameBuffer(), 300, 300, DMA2D_INPUT_RGB565); - stm32_LCD_DrawImage((void*)texture_raw, (void *)getNextFrameBuffer(), 300, 300, DMA2D_INPUT_RGB565); - } -} - -int i = 0; - -void loop() { - printf("Now: %d\n", millis()); - - delay(1000); -} diff --git a/libraries/Portenta_Video/library.properties b/libraries/Portenta_Video/library.properties new file mode 100644 index 000000000..a42caf813 --- /dev/null +++ b/libraries/Portenta_Video/library.properties @@ -0,0 +1,9 @@ +name=Portenta_Video +version=1.0 +author=Arduino +maintainer=Arduino +sentence=video primitives for Portenta H7 via USBC (to HDMI adapter) +paragraph= +category=Display +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Portenta_Video +architectures=mbed,mbed_portenta diff --git a/libraries/Portenta_Video/Portenta_Video.h b/libraries/Portenta_Video/src/Portenta_Video.h similarity index 100% rename from libraries/Portenta_Video/Portenta_Video.h rename to libraries/Portenta_Video/src/Portenta_Video.h diff --git a/libraries/Portenta_Video/anx7625.cpp b/libraries/Portenta_Video/src/anx7625.cpp similarity index 100% rename from libraries/Portenta_Video/anx7625.cpp rename to libraries/Portenta_Video/src/anx7625.cpp diff --git a/libraries/Portenta_Video/anx7625.h b/libraries/Portenta_Video/src/anx7625.h similarity index 100% rename from libraries/Portenta_Video/anx7625.h rename to libraries/Portenta_Video/src/anx7625.h diff --git a/libraries/Portenta_Video/coreboot_tables.h b/libraries/Portenta_Video/src/coreboot_tables.h similarity index 100% rename from libraries/Portenta_Video/coreboot_tables.h rename to libraries/Portenta_Video/src/coreboot_tables.h diff --git a/libraries/Portenta_Video/edid.c b/libraries/Portenta_Video/src/edid.c similarity index 100% rename from libraries/Portenta_Video/edid.c rename to libraries/Portenta_Video/src/edid.c diff --git a/libraries/Portenta_Video/edid.h b/libraries/Portenta_Video/src/edid.h similarity index 100% rename from libraries/Portenta_Video/edid.h rename to libraries/Portenta_Video/src/edid.h diff --git a/libraries/Portenta_Video/helpers.h b/libraries/Portenta_Video/src/helpers.h similarity index 100% rename from libraries/Portenta_Video/helpers.h rename to libraries/Portenta_Video/src/helpers.h diff --git a/libraries/Portenta_Video/video_modes.c b/libraries/Portenta_Video/src/video_modes.c similarity index 100% rename from libraries/Portenta_Video/video_modes.c rename to libraries/Portenta_Video/src/video_modes.c diff --git a/libraries/Portenta_Video/video_modes.h b/libraries/Portenta_Video/src/video_modes.h similarity index 100% rename from libraries/Portenta_Video/video_modes.h rename to libraries/Portenta_Video/src/video_modes.h diff --git a/libraries/LittleVGL/examples/KeyboardMouseController_rpc_m4/KeyboardMouseController_rpc_m4.ino b/libraries/Portenta_lvgl/examples/KeyboardMouseController_rpc_m4/KeyboardMouseController_rpc_m4.ino similarity index 100% rename from libraries/LittleVGL/examples/KeyboardMouseController_rpc_m4/KeyboardMouseController_rpc_m4.ino rename to libraries/Portenta_lvgl/examples/KeyboardMouseController_rpc_m4/KeyboardMouseController_rpc_m4.ino diff --git a/libraries/Portenta_lvgl/examples/Portenta_lvgl/Portenta_lvgl.ino b/libraries/Portenta_lvgl/examples/Portenta_lvgl/Portenta_lvgl.ino new file mode 100644 index 000000000..5cdbc6ae8 --- /dev/null +++ b/libraries/Portenta_lvgl/examples/Portenta_lvgl/Portenta_lvgl.ino @@ -0,0 +1,15 @@ +#include "Portenta_lvgl.h" +#include "lv_demo_widgets.h" + +void setup() { + portenta_init_video(); + lv_demo_widgets(); +} + +void loop() { +#if LVGL_VERSION_MAJOR > 7 + lv_timer_handler(); +#else + lv_task_handler(); +#endif +} diff --git a/libraries/LittleVGL/examples/Portenta_lvgl/lv_demo_widgets.c b/libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets.c similarity index 98% rename from libraries/LittleVGL/examples/Portenta_lvgl/lv_demo_widgets.c rename to libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets.c index ef20085cc..c8d3552da 100644 --- a/libraries/LittleVGL/examples/Portenta_lvgl/lv_demo_widgets.c +++ b/libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets.c @@ -9,6 +9,8 @@ #include "lvgl.h" #include "lv_demo_widgets.h" +#if LVGL_VERSION_MAJOR == 7 + /********************* * DEFINES *********************/ @@ -89,7 +91,7 @@ static void controls_create(lv_obj_t * parent) /*Add some extra top padding to make space for the box titles.*/ - lv_obj_set_style_local_pad_top(parent, LV_PAGE_PART_SCRL, LV_STATE_DEFAULT, LV_DPI/3); + lv_obj_set_style_local_pad_top(parent, LV_PAGE_PART_SCROLLABLE, LV_STATE_DEFAULT, LV_DPI/3); lv_obj_t * h = lv_cont_create(parent, NULL); lv_cont_set_layout(h, LV_LAYOUT_COLUMN_LEFT); @@ -226,7 +228,7 @@ static void visuals_create(lv_obj_t * parent) lv_obj_set_size(page, LV_HOR_RES / 3, LV_DPI * 2); lv_page_set_scroll_propagation(page, true); lv_cont_set_fit2(page, LV_FIT_TIGHT, LV_FIT_NONE); - lv_page_set_scrl_fit(page, LV_FIT_TIGHT); + lv_page_set_scrollable_fit(page, LV_FIT_TIGHT); lv_obj_t * table1 = lv_table_create(page, NULL); lv_obj_set_click(table1, false); @@ -408,3 +410,5 @@ static void tab_changer_task_cb(lv_task_t * task) lv_tabview_set_tab_act(tv, act, LV_ANIM_ON); } + +#endif \ No newline at end of file diff --git a/libraries/LittleVGL/examples/Portenta_lvgl/lv_demo_widgets.h b/libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets.h similarity index 100% rename from libraries/LittleVGL/examples/Portenta_lvgl/lv_demo_widgets.h rename to libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets.h diff --git a/libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets_v8.c b/libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets_v8.c new file mode 100644 index 000000000..1b5dc7eca --- /dev/null +++ b/libraries/Portenta_lvgl/examples/Portenta_lvgl/lv_demo_widgets_v8.c @@ -0,0 +1,1528 @@ +/********************* + * INCLUDES + *********************/ +#include "lvgl.h" +#include "lv_demo_widgets.h" +/********************* + * DEFINES + *********************/ + +#if LVGL_VERSION_MAJOR == 8 + +/********************** + * TYPEDEFS + **********************/ +typedef enum { + DISP_SMALL, + DISP_MEDIUM, + DISP_LARGE, +}disp_size_t; + +/********************** + * STATIC PROTOTYPES + **********************/ +static void profile_create(lv_obj_t * parent); +static void analytics_create(lv_obj_t * parent); +static void shop_create(lv_obj_t * parent); +static void color_changer_create(lv_obj_t * parent); + +static lv_obj_t * create_meter_box(lv_obj_t * parent, const char * title, const char * text1, const char * text2, const char * text3); + + +static void color_changer_event_cb(lv_event_t * e); +static void color_event_cb(lv_event_t * e); +static void ta_event_cb(lv_event_t * e); +static void birthday_event_cb(lv_event_t * e); +static void calendar_event_cb(lv_event_t * e); +static void slider_event_cb(lv_event_t * e); +static void chart_event_cb(lv_event_t * e); +static void shop_chart_event_cb(lv_event_t * e); +static void meter1_indic1_anim_cb(void * var, int32_t v); +static void meter1_indic2_anim_cb(void * var, int32_t v); +static void meter1_indic3_anim_cb(void * var, int32_t v); +static void meter2_timer_cb(lv_timer_t * timer); +static void meter3_anim_cb(void * var, int32_t v); + +lv_timer_t * tab_timer; +static void tab_changer_task_cb(lv_timer_t * timer); + +/********************** + * STATIC VARIABLES + **********************/ +static disp_size_t disp_size; + +static lv_obj_t * tv; +static lv_obj_t * calendar; +static lv_obj_t * calendar_header; +static lv_style_t style_text_muted; +static lv_style_t style_title; +static lv_style_t style_icon; +static lv_style_t style_bullet; + +static lv_obj_t * meter1; +static lv_obj_t * meter2; +static lv_obj_t * meter3; + +static lv_obj_t * chart1; +static lv_obj_t * chart2; +static lv_obj_t * chart3; + +static lv_chart_series_t * ser1; +static lv_chart_series_t * ser2; +static lv_chart_series_t * ser3; +static lv_chart_series_t * ser4; + +static const lv_font_t * font_large; +static const lv_font_t * font_normal; + +static uint32_t session_desktop = 1000; +static uint32_t session_tablet = 1000; +static uint32_t session_mobile = 1000; + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +void lv_demo_widgets(void) +{ + if(LV_HOR_RES <= 320) disp_size = DISP_SMALL; + else if(LV_HOR_RES < 720) disp_size = DISP_MEDIUM; + else disp_size = DISP_LARGE; + + font_large = LV_FONT_DEFAULT; + font_normal = LV_FONT_DEFAULT; + + lv_coord_t tab_h; + if(disp_size == DISP_LARGE) { + tab_h = 70; +#if LV_FONT_MONTSERRAT_24 + font_large = &lv_font_montserrat_24; +#else + LV_LOG_WARN("LV_FONT_MONTSERRAT_24 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead."); +#endif +#if LV_FONT_MONTSERRAT_16 + font_normal = &lv_font_montserrat_16; +#else + LV_LOG_WARN("LV_FONT_MONTSERRAT_16 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead."); +#endif + } else if(disp_size == DISP_MEDIUM) { + tab_h = 45; +#if LV_FONT_MONTSERRAT_20 + font_large = &lv_font_montserrat_20; +#else + LV_LOG_WARN("LV_FONT_MONTSERRAT_20 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead."); +#endif +#if LV_FONT_MONTSERRAT_14 + font_normal = &lv_font_montserrat_14; +#else + LV_LOG_WARN("LV_FONT_MONTSERRAT_14 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead."); +#endif + } else { /* disp_size == DISP_SMALL */ + tab_h = 45; +#if LV_FONT_MONTSERRAT_18 + font_large = &lv_font_montserrat_18; +#else + LV_LOG_WARN("LV_FONT_MONTSERRAT_18 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead."); +#endif +#if LV_FONT_MONTSERRAT_12 + font_normal = &lv_font_montserrat_12; +#else + LV_LOG_WARN("LV_FONT_MONTSERRAT_12 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead."); +#endif + } + +#if LV_USE_THEME_DEFAULT + lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), LV_THEME_DEFAULT_DARK, font_normal); +#endif + + lv_style_init(&style_text_muted); + lv_style_set_text_opa(&style_text_muted, LV_OPA_50); + + lv_style_init(&style_title); + lv_style_set_text_font(&style_title, font_large); + + lv_style_init(&style_icon); + lv_style_set_text_color(&style_icon, lv_theme_get_color_primary(NULL)); + lv_style_set_text_font(&style_icon, font_large); + + lv_style_init(&style_bullet); + lv_style_set_border_width(&style_bullet, 0); + lv_style_set_radius(&style_bullet, LV_RADIUS_CIRCLE); + + tv = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, tab_h); + + lv_obj_set_style_text_font(lv_scr_act(), font_normal, 0); + + if(disp_size == DISP_LARGE) { + lv_obj_t * tab_btns = lv_tabview_get_tab_btns(tv); + lv_obj_set_style_pad_left(tab_btns, LV_HOR_RES / 2, 0); + + + lv_obj_t * label = lv_label_create(tab_btns); + lv_obj_add_style(label, &style_title, 0); + lv_label_set_text(label, "LVGL v8"); + + + label = lv_label_create(tab_btns); + lv_label_set_text(label, "Widgets demo"); + lv_obj_add_style(label, &style_text_muted, 0); + + } + + lv_obj_t * t1 = lv_tabview_add_tab(tv, "Profile"); + lv_obj_t * t2 = lv_tabview_add_tab(tv, "Analytics"); + lv_obj_t * t3 = lv_tabview_add_tab(tv, "Shop"); + tab_timer = lv_timer_create(tab_changer_task_cb, 3500, NULL); + profile_create(t1); + analytics_create(t2); + shop_create(t3); + + color_changer_create(tv); +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void profile_create(lv_obj_t * parent) +{ + lv_obj_t * panel1 = lv_obj_create(parent); + lv_obj_set_height(panel1, LV_SIZE_CONTENT); + + + lv_obj_t * name = lv_label_create(panel1); + lv_label_set_text(name, "Elena Smith"); + lv_obj_add_style(name, &style_title, 0); + + lv_obj_t * dsc = lv_label_create(panel1); + lv_obj_add_style(dsc, &style_text_muted, 0); + lv_label_set_text(dsc, "This is a short description of me. Take a look at my profile!" ); + lv_label_set_long_mode(dsc, LV_LABEL_LONG_WRAP); + + lv_obj_t * email_icn = lv_label_create(panel1); + lv_obj_add_style(email_icn, &style_icon, 0); + lv_label_set_text(email_icn, LV_SYMBOL_ENVELOPE); + + lv_obj_t * email_label = lv_label_create(panel1); + lv_label_set_text(email_label, "elena@smith.com"); + + lv_obj_t * call_icn = lv_label_create(panel1); + lv_obj_add_style(call_icn, &style_icon, 0); + lv_label_set_text(call_icn, LV_SYMBOL_CALL); + + lv_obj_t * call_label = lv_label_create(panel1); + lv_label_set_text(call_label, "+79 246 123 4567"); + + lv_obj_t * log_out_btn = lv_btn_create(panel1); + lv_obj_set_height(log_out_btn, LV_SIZE_CONTENT); + + lv_obj_t * label = lv_label_create(log_out_btn); + lv_label_set_text(label, "Log out"); + lv_obj_center(label); + + lv_obj_t * invite_btn = lv_btn_create(panel1); + lv_obj_add_state(invite_btn, LV_STATE_DISABLED); + lv_obj_set_height(invite_btn, LV_SIZE_CONTENT); + + label = lv_label_create(invite_btn); + lv_label_set_text(label, "Invite"); + lv_obj_center(label); + + /*Create a keyboard*/ + lv_obj_t * kb = lv_keyboard_create(lv_scr_act()); + lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); + + /*Create the second panel*/ + lv_obj_t * panel2 = lv_obj_create(parent); + lv_obj_set_height(panel2, LV_SIZE_CONTENT); + + lv_obj_t * panel2_title = lv_label_create(panel2); + lv_label_set_text(panel2_title, "Your profile"); + lv_obj_add_style(panel2_title, &style_title, 0); + + lv_obj_t * user_name_label = lv_label_create(panel2); + lv_label_set_text(user_name_label, "User name"); + lv_obj_add_style(user_name_label, &style_text_muted, 0); + + lv_obj_t * user_name = lv_textarea_create(panel2); + lv_textarea_set_one_line(user_name, true); + lv_textarea_set_placeholder_text(user_name, "Your name"); + lv_obj_add_event_cb(user_name, ta_event_cb, LV_EVENT_ALL, kb); + + lv_obj_t * password_label = lv_label_create(panel2); + lv_label_set_text(password_label, "Password"); + lv_obj_add_style(password_label, &style_text_muted, 0); + + lv_obj_t * password = lv_textarea_create(panel2); + lv_textarea_set_one_line(password, true); + lv_textarea_set_password_mode(password, true); + lv_textarea_set_placeholder_text(password, "Min. 8 chars."); + lv_obj_add_event_cb(password, ta_event_cb, LV_EVENT_ALL, kb); + + lv_obj_t * gender_label = lv_label_create(panel2); + lv_label_set_text(gender_label, "Gender"); + lv_obj_add_style(gender_label, &style_text_muted, 0); + + lv_obj_t * gender = lv_dropdown_create(panel2); + lv_dropdown_set_options_static(gender, "Male\nFemale\nOther"); + + lv_obj_t * birthday_label = lv_label_create(panel2); + lv_label_set_text(birthday_label, "Birthday"); + lv_obj_add_style(birthday_label, &style_text_muted, 0); + + lv_obj_t * birthdate = lv_textarea_create(panel2); + lv_textarea_set_one_line(birthdate, true); + lv_obj_add_event_cb(birthdate, birthday_event_cb, LV_EVENT_ALL, NULL); + + /*Create the third panel*/ + lv_obj_t * panel3 = lv_obj_create(parent); + lv_obj_t * panel3_title = lv_label_create(panel3); + lv_label_set_text(panel3_title, "Your skills"); + lv_obj_add_style(panel3_title, &style_title, 0); + + lv_obj_t * experience_label = lv_label_create(panel3); + lv_label_set_text(experience_label, "Experience"); + lv_obj_add_style(experience_label, &style_text_muted, 0); + + lv_obj_t * slider1 = lv_slider_create(panel3); + lv_obj_set_width(slider1, LV_PCT(95)); + lv_obj_add_event_cb(slider1, slider_event_cb, LV_EVENT_ALL, NULL); + lv_obj_refresh_ext_draw_size(slider1); + + lv_obj_t * team_player_label = lv_label_create(panel3); + lv_label_set_text(team_player_label, "Team player"); + lv_obj_add_style(team_player_label, &style_text_muted, 0); + + lv_obj_t * sw1 = lv_switch_create(panel3); + + lv_obj_t * hard_working_label = lv_label_create(panel3); + lv_label_set_text(hard_working_label, "Hard-working"); + lv_obj_add_style(hard_working_label, &style_text_muted, 0); + + lv_obj_t * sw2 = lv_switch_create(panel3); + + if(disp_size == DISP_LARGE) { + static lv_coord_t grid_main_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_main_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; + + /*Create the top panel*/ + static lv_coord_t grid_1_col_dsc[] = {LV_GRID_CONTENT, 5, LV_GRID_CONTENT, LV_GRID_FR(2), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_1_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, 10, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; + + static lv_coord_t grid_2_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_2_row_dsc[] = { + LV_GRID_CONTENT, /*Title*/ + 5, /*Separator*/ + LV_GRID_CONTENT, /*Box title*/ + 30, /*Boxes*/ + 5, /*Separator*/ + LV_GRID_CONTENT, /*Box title*/ + 30, /*Boxes*/ + LV_GRID_TEMPLATE_LAST + }; + + + lv_obj_set_grid_dsc_array(parent, grid_main_col_dsc, grid_main_row_dsc); + + lv_obj_set_grid_cell(panel1, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + + lv_obj_set_grid_dsc_array(panel1, grid_1_col_dsc, grid_1_row_dsc); + lv_obj_set_grid_cell(name, LV_GRID_ALIGN_START, 2, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(dsc, LV_GRID_ALIGN_STRETCH, 2, 4, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_cell(email_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(email_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(call_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 4, 1); + lv_obj_set_grid_cell(call_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 4, 1); + lv_obj_set_grid_cell(log_out_btn, LV_GRID_ALIGN_STRETCH, 4, 1, LV_GRID_ALIGN_CENTER, 3, 2); + lv_obj_set_grid_cell(invite_btn, LV_GRID_ALIGN_STRETCH, 5, 1, LV_GRID_ALIGN_CENTER, 3, 2); + + lv_obj_set_grid_cell(panel2, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_dsc_array(panel2, grid_2_col_dsc, grid_2_row_dsc); + lv_obj_set_grid_cell(panel2_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(user_name, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(user_name_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(password, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(password_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(birthdate, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 6, 1); + lv_obj_set_grid_cell(birthday_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 5, 1); + lv_obj_set_grid_cell(gender, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 6, 1); + lv_obj_set_grid_cell(gender_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1); + + + lv_obj_set_grid_cell(panel3, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 1, 1); + lv_obj_set_grid_dsc_array(panel3, grid_2_col_dsc, grid_2_row_dsc); + lv_obj_set_grid_cell(panel3_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(slider1, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(experience_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(sw2, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 6, 1); + lv_obj_set_grid_cell(hard_working_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1); + lv_obj_set_grid_cell(sw1, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_CENTER, 6, 1); + lv_obj_set_grid_cell(team_player_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 5, 1); + } + else if(disp_size == DISP_MEDIUM) { + static lv_coord_t grid_main_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_main_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; + + + /*Create the top panel*/ + static lv_coord_t grid_1_col_dsc[] = {LV_GRID_CONTENT, 1, LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_1_row_dsc[] = { + LV_GRID_CONTENT, /*Name*/ + LV_GRID_CONTENT, /*Description*/ + LV_GRID_CONTENT, /*Email*/ + -20, + LV_GRID_CONTENT, /*Phone*/ + LV_GRID_CONTENT, /*Buttons*/ + LV_GRID_TEMPLATE_LAST}; + + static lv_coord_t grid_2_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_2_row_dsc[] = { + LV_GRID_CONTENT, /*Title*/ + 5, /*Separator*/ + LV_GRID_CONTENT, /*Box title*/ + 40, /*Box*/ + LV_GRID_CONTENT, /*Box title*/ + 40, /*Box*/ + LV_GRID_CONTENT, /*Box title*/ + 40, /*Box*/ + LV_GRID_CONTENT, /*Box title*/ + 40, /*Box*/ + LV_GRID_TEMPLATE_LAST + }; + + + lv_obj_set_grid_dsc_array(parent, grid_main_col_dsc, grid_main_row_dsc); + lv_obj_set_grid_cell(panel1, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + + lv_obj_set_width(log_out_btn, 120); + lv_obj_set_width(invite_btn, 120); + + + lv_obj_set_grid_dsc_array(panel1, grid_1_col_dsc, grid_1_row_dsc); + + lv_obj_set_grid_cell(name, LV_GRID_ALIGN_START, 2, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(dsc, LV_GRID_ALIGN_STRETCH, 2, 2, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_cell(email_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 2, 1); + lv_obj_set_grid_cell(email_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 2, 1); + lv_obj_set_grid_cell(call_icn, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 4, 1); + lv_obj_set_grid_cell(call_label, LV_GRID_ALIGN_START, 3, 1, LV_GRID_ALIGN_CENTER, 4, 1); + lv_obj_set_grid_cell(log_out_btn, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 5, 1); + lv_obj_set_grid_cell(invite_btn, LV_GRID_ALIGN_END, 3, 1, LV_GRID_ALIGN_CENTER, 5, 1); + + lv_obj_set_grid_cell(panel2, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_dsc_array(panel2, grid_2_col_dsc, grid_2_row_dsc); + lv_obj_set_grid_cell(panel2_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(user_name_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(user_name, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 3, 1); + lv_obj_set_grid_cell(password_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 4, 1); + lv_obj_set_grid_cell(password, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 5, 1); + lv_obj_set_grid_cell(birthday_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 6, 1); + lv_obj_set_grid_cell(birthdate, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 7, 1); + lv_obj_set_grid_cell(gender_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 8, 1); + lv_obj_set_grid_cell(gender, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 9, 1); + + lv_obj_set_grid_cell(panel3, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 1, 1); + lv_obj_set_grid_dsc_array(panel3, grid_2_col_dsc, grid_2_row_dsc); + lv_obj_set_grid_cell(panel3_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(slider1, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(experience_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(hard_working_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 4, 1); + lv_obj_set_grid_cell(sw2, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1); + lv_obj_set_grid_cell(team_player_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 6, 1); + lv_obj_set_grid_cell(sw1, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 7, 1); + } + else if(disp_size == DISP_SMALL) { + static lv_coord_t grid_main_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_main_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; + lv_obj_set_grid_dsc_array(parent, grid_main_col_dsc, grid_main_row_dsc); + + + /*Create the top panel*/ + static lv_coord_t grid_1_col_dsc[] = {LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_1_row_dsc[] = {LV_GRID_CONTENT, /*Avatar*/ + LV_GRID_CONTENT, /*Name*/ + LV_GRID_CONTENT, /*Description*/ + LV_GRID_CONTENT, /*Email*/ + LV_GRID_CONTENT, /*Phone number*/ + LV_GRID_CONTENT, /*Button1*/ + LV_GRID_CONTENT, /*Button2*/ + LV_GRID_TEMPLATE_LAST}; + + lv_obj_set_grid_dsc_array(panel1, grid_1_col_dsc, grid_1_row_dsc); + + + static lv_coord_t grid_2_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_2_row_dsc[] = { + LV_GRID_CONTENT, /*Title*/ + 5, /*Separator*/ + LV_GRID_CONTENT, /*Box title*/ + 40, /*Box*/ + LV_GRID_CONTENT, /*Box title*/ + 40, /*Box*/ + LV_GRID_CONTENT, /*Box title*/ + 40, /*Box*/ + LV_GRID_CONTENT, /*Box title*/ + 40, LV_GRID_TEMPLATE_LAST /*Box*/ + }; + + lv_obj_set_grid_dsc_array(panel2, grid_2_col_dsc, grid_2_row_dsc); + lv_obj_set_grid_dsc_array(panel3, grid_2_col_dsc, grid_2_row_dsc); + + lv_obj_set_grid_cell(panel1, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1); + + lv_obj_set_style_text_align(dsc, LV_TEXT_ALIGN_CENTER, 0); + + lv_obj_set_grid_cell(name, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 1, 1); + lv_obj_set_grid_cell(dsc, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(email_icn, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(email_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(call_icn, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 4, 1); + lv_obj_set_grid_cell(call_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 4, 1); + lv_obj_set_grid_cell(log_out_btn, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 5, 1); + lv_obj_set_grid_cell(invite_btn, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 6, 1); + + lv_obj_set_grid_cell(panel2, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_cell(panel2_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(user_name_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(user_name, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 3, 1); + lv_obj_set_grid_cell(password_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 4, 1); + lv_obj_set_grid_cell(password, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 5, 1); + lv_obj_set_grid_cell(birthday_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 6, 1); + lv_obj_set_grid_cell(birthdate, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 7, 1); + lv_obj_set_grid_cell(gender_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 8, 1); + lv_obj_set_grid_cell(gender, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_START, 9, 1); + + lv_obj_set_height(panel3, LV_SIZE_CONTENT); + lv_obj_set_grid_cell(panel3, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(panel3_title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(experience_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(slider1, LV_GRID_ALIGN_CENTER, 0, 2, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(hard_working_label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 4, 1); + lv_obj_set_grid_cell(sw1, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 5, 1); + lv_obj_set_grid_cell(team_player_label, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 4, 1); + lv_obj_set_grid_cell(sw2, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_START, 5, 1); + } +} + + +static void analytics_create(lv_obj_t * parent) +{ + lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_ROW_WRAP); + + static lv_coord_t grid_chart_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_FR(1), 10, LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_chart_col_dsc[] = {20, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + + lv_obj_t * chart1_cont = lv_obj_create(parent); + lv_obj_set_flex_grow(chart1_cont, 1); + lv_obj_set_grid_dsc_array(chart1_cont, grid_chart_col_dsc, grid_chart_row_dsc); + + lv_obj_set_height(chart1_cont, LV_PCT(100)); + lv_obj_set_style_max_height(chart1_cont, 300, 0); + + lv_obj_t * title = lv_label_create(chart1_cont); + lv_label_set_text(title, "Unique visitors"); + lv_obj_add_style(title, &style_title, 0); + lv_obj_set_grid_cell(title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 0, 1); + + chart1 = lv_chart_create(chart1_cont); + lv_group_add_obj(lv_group_get_default(), chart1); + lv_obj_add_flag(chart1, LV_OBJ_FLAG_SCROLL_ON_FOCUS); + lv_obj_set_grid_cell(chart1, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 1, 1); + lv_chart_set_axis_tick(chart1, LV_CHART_AXIS_PRIMARY_Y, 0, 0, 5, 1, true, 80); + lv_chart_set_axis_tick(chart1, LV_CHART_AXIS_PRIMARY_X, 0, 0, 12, 1, true, 50); + lv_chart_set_div_line_count(chart1, 0, 12); + lv_chart_set_point_count(chart1, 12); + lv_obj_add_event_cb(chart1, chart_event_cb, LV_EVENT_ALL, NULL); + if(disp_size == DISP_SMALL) lv_chart_set_zoom_x(chart1, 256 * 3); + else if(disp_size == DISP_MEDIUM) lv_chart_set_zoom_x(chart1, 256 * 2); + + lv_obj_set_style_border_side(chart1, LV_BORDER_SIDE_LEFT | LV_BORDER_SIDE_BOTTOM, 0); + lv_obj_set_style_radius(chart1, 0, 0); + + ser1 = lv_chart_add_series(chart1, lv_theme_get_color_primary(chart1), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + lv_chart_set_next_value(chart1, ser1, lv_rand(10, 80)); + + lv_obj_t * chart2_cont = lv_obj_create(parent); + lv_obj_add_flag(chart2_cont, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); + lv_obj_set_flex_grow(chart2_cont, 1); + + lv_obj_set_height(chart2_cont, LV_PCT(100)); + lv_obj_set_style_max_height(chart2_cont, 300, 0); + + lv_obj_set_grid_dsc_array(chart2_cont, grid_chart_col_dsc, grid_chart_row_dsc); + + title = lv_label_create(chart2_cont); + lv_label_set_text(title, "Monthly revenue"); + lv_obj_add_style(title, &style_title, 0); + lv_obj_set_grid_cell(title, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 0, 1); + + chart2 = lv_chart_create(chart2_cont); + lv_group_add_obj(lv_group_get_default(), chart2); + lv_obj_add_flag(chart2, LV_OBJ_FLAG_SCROLL_ON_FOCUS); + + lv_obj_set_grid_cell(chart2, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 1, 1); + lv_chart_set_axis_tick(chart2, LV_CHART_AXIS_PRIMARY_Y, 0, 0, 5, 1, true, 80); + lv_chart_set_axis_tick(chart2, LV_CHART_AXIS_PRIMARY_X, 0, 0, 12, 1, true, 50); + lv_obj_set_size(chart2, LV_PCT(100), LV_PCT(100)); + lv_chart_set_type(chart2, LV_CHART_TYPE_BAR); + lv_chart_set_div_line_count(chart2, 6, 0); + lv_chart_set_point_count(chart2, 12); + lv_obj_add_event_cb(chart2, chart_event_cb, LV_EVENT_ALL, NULL); + lv_chart_set_zoom_x(chart2, 256 * 2); + lv_obj_set_style_border_side(chart2, LV_BORDER_SIDE_LEFT | LV_BORDER_SIDE_BOTTOM, 0); + lv_obj_set_style_radius(chart2, 0, 0); + + if(disp_size == DISP_SMALL) { + lv_obj_set_style_pad_gap(chart2, 0, LV_PART_ITEMS); + lv_obj_set_style_pad_gap(chart2, 2, LV_PART_MAIN); + } + else if(disp_size == DISP_LARGE) { + lv_obj_set_style_pad_gap(chart2, 16, 0); + } + + ser2 = lv_chart_add_series(chart2, lv_palette_lighten(LV_PALETTE_GREY, 1), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser2, lv_rand(10, 80)); + + ser3 = lv_chart_add_series(chart2, lv_theme_get_color_primary(chart1), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + lv_chart_set_next_value(chart2, ser3, lv_rand(10, 80)); + + lv_meter_scale_t * scale; + lv_meter_indicator_t *indic; + meter1 = create_meter_box(parent, "Monthly Target", "Revenue: 63%", "Sales: 44%", "Costs: 58%"); + lv_obj_add_flag(lv_obj_get_parent(meter1), LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); + scale = lv_meter_add_scale(meter1); + lv_meter_set_scale_range(meter1, scale, 0, 100, 270, 90); + lv_meter_set_scale_ticks(meter1, scale, 0, 0, 0, lv_color_black()); + + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_values(&a, 20, 100); + lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); + + indic = lv_meter_add_arc(meter1, scale, 15, lv_palette_main(LV_PALETTE_BLUE), 0); + lv_anim_set_exec_cb(&a, meter1_indic1_anim_cb); + lv_anim_set_var(&a, indic); + lv_anim_set_time(&a, 4100); + lv_anim_set_playback_time(&a, 2700); + lv_anim_start(&a); + + indic = lv_meter_add_arc(meter1, scale, 15, lv_palette_main(LV_PALETTE_RED), -20); + lv_anim_set_exec_cb(&a, meter1_indic2_anim_cb); + lv_anim_set_var(&a, indic); + lv_anim_set_time(&a, 2600); + lv_anim_set_playback_time(&a, 3200); + //a.user_data = indic; + lv_anim_start(&a); + + indic = lv_meter_add_arc(meter1, scale, 15, lv_palette_main(LV_PALETTE_GREEN), -40); + lv_anim_set_exec_cb(&a, meter1_indic3_anim_cb); + lv_anim_set_var(&a, indic); + lv_anim_set_time(&a, 2800); + lv_anim_set_playback_time(&a, 1800); + lv_anim_start(&a); + + meter2 = create_meter_box(parent, "Sessions", "Desktop: ", "Tablet: ", "Mobile: "); + if(disp_size < DISP_LARGE) lv_obj_add_flag(lv_obj_get_parent(meter2), LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); + scale = lv_meter_add_scale(meter2); + lv_meter_set_scale_range(meter2, scale, 0, 100, 360, 90); + lv_meter_set_scale_ticks(meter2, scale, 0, 0, 0, lv_color_black()); + + static lv_meter_indicator_t * meter2_indic[3]; + meter2_indic[0] = lv_meter_add_arc(meter2, scale, 20, lv_palette_main(LV_PALETTE_RED), -10); + lv_meter_set_indicator_start_value(meter2, meter2_indic[0], 0); + lv_meter_set_indicator_end_value(meter2, meter2_indic[0], 39); + + meter2_indic[1] = lv_meter_add_arc(meter2, scale, 30, lv_palette_main(LV_PALETTE_BLUE), 0); + lv_meter_set_indicator_start_value(meter2, meter2_indic[1], 40); + lv_meter_set_indicator_end_value(meter2, meter2_indic[1], 69); + + meter2_indic[2] = lv_meter_add_arc(meter2, scale, 10, lv_palette_main(LV_PALETTE_GREEN), -20); + lv_meter_set_indicator_start_value(meter2, meter2_indic[2], 70); + lv_meter_set_indicator_end_value(meter2, meter2_indic[2], 99); + + lv_timer_create(meter2_timer_cb, 100, meter2_indic); + + meter3 = create_meter_box(parent, "Network Speed", "Low speed", "Normal Speed", "High Speed"); + if(disp_size < DISP_LARGE) lv_obj_add_flag(lv_obj_get_parent(meter3), LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); + + /*Add a special circle to the needle's pivot*/ + lv_obj_set_style_pad_hor(meter3, 10, 0); + lv_obj_set_style_size(meter3, 10, LV_PART_INDICATOR); + lv_obj_set_style_radius(meter3, LV_RADIUS_CIRCLE, LV_PART_INDICATOR); + lv_obj_set_style_bg_opa(meter3, LV_OPA_COVER, LV_PART_INDICATOR); + lv_obj_set_style_bg_color(meter3, lv_palette_darken(LV_PALETTE_GREY, 4), LV_PART_INDICATOR); + lv_obj_set_style_outline_color(meter3, lv_color_white(), LV_PART_INDICATOR); + lv_obj_set_style_outline_width(meter3, 3, LV_PART_INDICATOR); + lv_obj_set_style_text_color(meter3, lv_palette_darken(LV_PALETTE_GREY, 1), LV_PART_TICKS); + + scale = lv_meter_add_scale(meter3); + lv_meter_set_scale_range(meter3, scale, 10, 60, 220, 360 - 220); + lv_meter_set_scale_ticks(meter3, scale, 21, 3, 17, lv_color_white()); + lv_meter_set_scale_major_ticks(meter3, scale, 4, 4, 22, lv_color_white(), 15); + + indic = lv_meter_add_arc(meter3, scale, 10, lv_palette_main(LV_PALETTE_RED), 0); + lv_meter_set_indicator_start_value(meter3, indic, 0); + lv_meter_set_indicator_end_value(meter3, indic, 20); + + indic = lv_meter_add_scale_lines(meter3, scale, lv_palette_darken(LV_PALETTE_RED, 3), lv_palette_darken(LV_PALETTE_RED, 3), true, 0); + lv_meter_set_indicator_start_value(meter3, indic, 0); + lv_meter_set_indicator_end_value(meter3, indic, 20); + + indic = lv_meter_add_arc(meter3, scale, 12, lv_palette_main(LV_PALETTE_BLUE), 0); + lv_meter_set_indicator_start_value(meter3, indic, 20); + lv_meter_set_indicator_end_value(meter3, indic, 40); + + indic = lv_meter_add_scale_lines(meter3, scale, lv_palette_darken(LV_PALETTE_BLUE, 3), lv_palette_darken(LV_PALETTE_BLUE, 3), true, 0); + lv_meter_set_indicator_start_value(meter3, indic, 20); + lv_meter_set_indicator_end_value(meter3, indic, 40); + + indic = lv_meter_add_arc(meter3, scale, 10, lv_palette_main(LV_PALETTE_GREEN), 0); + lv_meter_set_indicator_start_value(meter3, indic, 40); + lv_meter_set_indicator_end_value(meter3, indic, 60); + + indic = lv_meter_add_scale_lines(meter3, scale, lv_palette_darken(LV_PALETTE_GREEN, 3), lv_palette_darken(LV_PALETTE_GREEN, 3), true, 0); + lv_meter_set_indicator_start_value(meter3, indic, 40); + lv_meter_set_indicator_end_value(meter3, indic, 60); + + indic = lv_meter_add_needle_line(meter3, scale, 4, lv_palette_darken(LV_PALETTE_GREY, 4), -25); + + lv_obj_t * mbps_label = lv_label_create(meter3); + lv_label_set_text(mbps_label, "-"); + lv_obj_add_style(mbps_label, &style_title, 0); + + lv_obj_t * mbps_unit_label = lv_label_create(meter3); + lv_label_set_text(mbps_unit_label, "Mbps"); + + lv_anim_init(&a); + lv_anim_set_values(&a, 10, 60); + lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); + lv_anim_set_exec_cb(&a, meter3_anim_cb); + lv_anim_set_var(&a, indic); + lv_anim_set_time(&a, 4100); + lv_anim_set_playback_time(&a, 800); + lv_anim_start(&a); + + lv_obj_update_layout(parent); + if(disp_size == DISP_MEDIUM) { + lv_obj_set_size(meter1, 200, 200); + lv_obj_set_size(meter2, 200, 200); + lv_obj_set_size(meter3, 200, 200); + } else { + lv_coord_t meter_w = lv_obj_get_width(meter1); + lv_obj_set_height(meter1, meter_w); + lv_obj_set_height(meter2, meter_w); + lv_obj_set_height(meter3, meter_w); + } + + lv_obj_align(mbps_label, LV_ALIGN_TOP_MID, 10, lv_pct(55)); + lv_obj_align_to(mbps_unit_label, mbps_label, LV_ALIGN_OUT_RIGHT_BOTTOM, 10, 0); +} + +void shop_create(lv_obj_t * parent) +{ + lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_ROW_WRAP); + + lv_obj_t * panel1 = lv_obj_create(parent); + lv_obj_set_size(panel1, lv_pct(100), LV_SIZE_CONTENT); + lv_obj_set_style_pad_bottom(panel1, 30, 0); + + lv_obj_t * title = lv_label_create(panel1); + lv_label_set_text(title, "Monthly Summary"); + lv_obj_add_style(title, &style_title, 0); + + lv_obj_t * date = lv_label_create(panel1); + lv_label_set_text(date, "8-15 July, 2021"); + lv_obj_add_style(date, &style_text_muted, 0); + + lv_obj_t * amount = lv_label_create(panel1); + lv_label_set_text(amount, "$27,123.25"); + lv_obj_add_style(amount, &style_title, 0); + + lv_obj_t * hint = lv_label_create(panel1); + lv_label_set_text(hint, LV_SYMBOL_UP" 17% growth this week"); + lv_obj_set_style_text_color(hint, lv_palette_main(LV_PALETTE_GREEN), 0); + + chart3 = lv_chart_create(panel1); + lv_chart_set_axis_tick(chart3, LV_CHART_AXIS_PRIMARY_Y, 0, 0, 6, 1, true, 80); + lv_chart_set_axis_tick(chart3, LV_CHART_AXIS_PRIMARY_X, 0, 0, 7, 1, true, 50); + lv_chart_set_type(chart3, LV_CHART_TYPE_BAR); + lv_chart_set_div_line_count(chart3, 6, 0); + lv_chart_set_point_count(chart3, 7); + lv_obj_add_event_cb(chart3, shop_chart_event_cb, LV_EVENT_ALL, NULL); + + ser4 = lv_chart_add_series(chart3, lv_theme_get_color_primary(chart3), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90)); + + if(disp_size == DISP_LARGE) { + static lv_coord_t grid1_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid1_row_dsc[] = { + LV_GRID_CONTENT, /*Title*/ + LV_GRID_CONTENT, /*Sub title*/ + 20, /*Spacer*/ + LV_GRID_CONTENT, /*Amount*/ + LV_GRID_CONTENT, /*Hint*/ + LV_GRID_TEMPLATE_LAST + }; + + lv_obj_set_size(chart3, lv_pct(100), lv_pct(100)); + lv_obj_set_style_pad_column(chart3, LV_DPX(30), 0); + + + lv_obj_set_grid_dsc_array(panel1, grid1_col_dsc, grid1_row_dsc); + lv_obj_set_grid_cell(title, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 0, 1); + lv_obj_set_grid_cell(date, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_cell(amount, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 3, 1); + lv_obj_set_grid_cell(hint, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 4, 1); + lv_obj_set_grid_cell(chart3, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 0, 5); + } else if(disp_size == DISP_MEDIUM) { + static lv_coord_t grid1_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid1_row_dsc[] = { + LV_GRID_CONTENT, /*Title + Date*/ + LV_GRID_CONTENT, /*Amount + Hint*/ + 200, /*Chart*/ + LV_GRID_TEMPLATE_LAST + }; + + lv_obj_update_layout(panel1); + lv_obj_set_width(chart3, lv_obj_get_content_width(panel1) - 20); + lv_obj_set_style_pad_column(chart3, LV_DPX(30), 0); + + lv_obj_set_grid_dsc_array(panel1, grid1_col_dsc, grid1_row_dsc); + lv_obj_set_grid_cell(title, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(date, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1); + lv_obj_set_grid_cell(amount, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_CENTER, 1, 1); + lv_obj_set_grid_cell(hint, LV_GRID_ALIGN_START, 1, 1, LV_GRID_ALIGN_CENTER, 1, 1); + lv_obj_set_grid_cell(chart3, LV_GRID_ALIGN_END, 0, 2, LV_GRID_ALIGN_STRETCH, 2, 1); + } else if(disp_size == DISP_SMALL) { + static lv_coord_t grid1_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid1_row_dsc[] = { + LV_GRID_CONTENT, /*Title*/ + LV_GRID_CONTENT, /*Date*/ + LV_GRID_CONTENT, /*Amount*/ + LV_GRID_CONTENT, /*Hint*/ + LV_GRID_CONTENT, /*Chart*/ + LV_GRID_TEMPLATE_LAST + }; + + lv_obj_set_width(chart3, LV_PCT(95)); + lv_obj_set_height(chart3, LV_VER_RES - 70); + lv_obj_set_style_max_height(chart3, 300, 0); + lv_chart_set_zoom_x(chart3, 512); + + lv_obj_set_grid_dsc_array(panel1, grid1_col_dsc, grid1_row_dsc); + lv_obj_set_grid_cell(title, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 0, 1); + lv_obj_set_grid_cell(date, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_cell(amount, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(hint, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 3, 1); + lv_obj_set_grid_cell(chart3, LV_GRID_ALIGN_END, 0, 1, LV_GRID_ALIGN_START, 4, 1); + } + + lv_obj_t * list = lv_obj_create(parent); + if(disp_size == DISP_SMALL) { + lv_obj_add_flag(list, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); + lv_obj_set_height(list, LV_PCT(100)); + } else { + lv_obj_set_height(list, LV_PCT(100)); + lv_obj_set_style_max_height(list, 300, 0); + } + + lv_obj_set_flex_flow(list, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_grow(list, 1); + lv_obj_add_flag(list, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); + + title = lv_label_create(list); + lv_label_set_text(title, "Top products"); + lv_obj_add_style(title, &style_title, 0); + + + lv_obj_t * notifications = lv_obj_create(parent); + if(disp_size == DISP_SMALL) { + lv_obj_add_flag(notifications, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); + lv_obj_set_height(notifications, LV_PCT(100)); + } else { + lv_obj_set_height(notifications, LV_PCT(100)); + lv_obj_set_style_max_height(notifications, 300, 0); + } + + lv_obj_set_flex_flow(notifications, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_grow(notifications, 1); + + title = lv_label_create(notifications); + lv_label_set_text(title, "Notification"); + lv_obj_add_style(title, &style_title, 0); + + lv_obj_t * cb; + cb = lv_checkbox_create(notifications); + lv_checkbox_set_text(cb, "Item purchased"); + + cb = lv_checkbox_create(notifications); + lv_checkbox_set_text(cb, "New connection"); + + cb = lv_checkbox_create(notifications); + lv_checkbox_set_text(cb, "New subscriber"); + lv_obj_add_state(cb, LV_STATE_CHECKED); + + cb = lv_checkbox_create(notifications); + lv_checkbox_set_text(cb, "New message"); + lv_obj_add_state(cb, LV_STATE_DISABLED); + + cb = lv_checkbox_create(notifications); + lv_checkbox_set_text(cb, "Milestone reached"); + lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); + + cb = lv_checkbox_create(notifications); + lv_checkbox_set_text(cb, "Out of stock"); + + +} + +static void color_changer_create(lv_obj_t * parent) +{ + static lv_palette_t palette[] = { + LV_PALETTE_BLUE, LV_PALETTE_GREEN, LV_PALETTE_BLUE_GREY, LV_PALETTE_ORANGE, + LV_PALETTE_RED, LV_PALETTE_PURPLE, LV_PALETTE_TEAL, _LV_PALETTE_LAST }; + + lv_obj_t * color_cont = lv_obj_create(parent); + lv_obj_remove_style_all(color_cont); + lv_obj_set_flex_flow(color_cont, LV_FLEX_FLOW_ROW); + lv_obj_set_flex_align(color_cont, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + lv_obj_add_flag(color_cont, LV_OBJ_FLAG_FLOATING); + + lv_obj_set_style_bg_color(color_cont, lv_color_white(), 0); + lv_obj_set_style_pad_right(color_cont, disp_size == DISP_SMALL ? LV_DPX(47) : LV_DPX(55), 0); + lv_obj_set_style_bg_opa(color_cont, LV_OPA_COVER, 0); + lv_obj_set_style_radius(color_cont, LV_RADIUS_CIRCLE, 0); + + if(disp_size == DISP_SMALL) lv_obj_set_size(color_cont, LV_DPX(52), LV_DPX(52)); + else lv_obj_set_size(color_cont, LV_DPX(60), LV_DPX(60)); + + lv_obj_align(color_cont, LV_ALIGN_BOTTOM_RIGHT, - LV_DPX(10), - LV_DPX(10)); + + uint32_t i; + for(i = 0; palette[i] != _LV_PALETTE_LAST; i++) { + lv_obj_t * c = lv_btn_create(color_cont); + lv_obj_set_style_bg_color(c, lv_palette_main(palette[i]), 0); + lv_obj_set_style_radius(c, LV_RADIUS_CIRCLE, 0); + lv_obj_set_style_opa(c, LV_OPA_TRANSP, 0); + lv_obj_set_size(c, 20, 20); + lv_obj_add_event_cb(c, color_event_cb, LV_EVENT_ALL, &palette[i]); + lv_obj_clear_flag(c, LV_OBJ_FLAG_SCROLL_ON_FOCUS); + } + + lv_obj_t * btn = lv_btn_create(parent); + lv_obj_add_flag(btn, LV_OBJ_FLAG_FLOATING | LV_OBJ_FLAG_CLICKABLE); + lv_obj_set_style_bg_color(btn, lv_color_white(), LV_STATE_CHECKED); + lv_obj_set_style_pad_all(btn, 10, 0); + lv_obj_set_style_radius(btn, LV_RADIUS_CIRCLE, 0); + lv_obj_add_event_cb(btn, color_changer_event_cb, LV_EVENT_ALL, color_cont); + lv_obj_set_style_shadow_width(btn, 0, 0); + + + if(disp_size == DISP_SMALL) { + lv_obj_set_size(btn, LV_DPX(42), LV_DPX(42)); + lv_obj_align(btn, LV_ALIGN_BOTTOM_RIGHT, -LV_DPX(15), -LV_DPX(15)); + } else { + lv_obj_set_size(btn, LV_DPX(50), LV_DPX(50)); + lv_obj_align(btn, LV_ALIGN_BOTTOM_RIGHT, -LV_DPX(15), -LV_DPX(15)); + } +} + +static void color_changer_anim_cb(void * var, int32_t v) +{ + lv_obj_t * obj = var; + lv_coord_t max_w = lv_obj_get_width(lv_obj_get_parent(obj)) - LV_DPX(20); + lv_coord_t w; + + if(disp_size == DISP_SMALL) { + w = lv_map(v, 0, 256, LV_DPX(52), max_w); + lv_obj_set_width(obj, w); + lv_obj_align(obj, LV_ALIGN_BOTTOM_RIGHT, - LV_DPX(10), - LV_DPX(10)); + } else { + w = lv_map(v, 0, 256, LV_DPX(60), max_w); + lv_obj_set_width(obj, w); + lv_obj_align(obj, LV_ALIGN_BOTTOM_RIGHT, - LV_DPX(10), - LV_DPX(10)); + } + + if(v > LV_OPA_COVER) v = LV_OPA_COVER; + + uint32_t i; + for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { + lv_obj_set_style_opa(lv_obj_get_child(obj, i), v, 0); + } + +} + +static void color_changer_event_cb(lv_event_t *e) +{ + if(lv_event_get_code(e) == LV_EVENT_CLICKED) { + lv_obj_t * color_cont = lv_event_get_user_data(e); + if(lv_obj_get_width(color_cont) < LV_HOR_RES / 2) { + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, color_cont); + lv_anim_set_exec_cb(&a, color_changer_anim_cb); + lv_anim_set_values(&a, 0, 256); + lv_anim_set_time(&a, 200); + lv_anim_start(&a); + } else { + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, color_cont); + lv_anim_set_exec_cb(&a, color_changer_anim_cb); + lv_anim_set_values(&a, 256, 0); + lv_anim_set_time(&a, 200); + lv_anim_start(&a); + } + } +} +static void color_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * obj = lv_event_get_target(e); + + if(code == LV_EVENT_FOCUSED) { + lv_obj_t * color_cont = lv_obj_get_parent(obj); + if(lv_obj_get_width(color_cont) < LV_HOR_RES / 2) { + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, color_cont); + lv_anim_set_exec_cb(&a, color_changer_anim_cb); + lv_anim_set_values(&a, 0, 256); + lv_anim_set_time(&a, 200); + lv_anim_start(&a); + } + } + else if(code == LV_EVENT_CLICKED) { + lv_palette_t * palette_primary = lv_event_get_user_data(e); + lv_palette_t palette_secondary = (*palette_primary) + 3; /*Use an other palette as secondary*/ + if(palette_secondary >= _LV_PALETTE_LAST) palette_secondary = 0; + + lv_theme_default_init(NULL, lv_palette_main(*palette_primary), lv_palette_main(palette_secondary), LV_THEME_DEFAULT_DARK, font_normal); + + lv_color_t color = lv_palette_main(*palette_primary); + lv_style_set_text_color(&style_icon, color); + lv_chart_set_series_color(chart1, ser1, color); + lv_chart_set_series_color(chart2, ser3, color); + } +} + +static lv_obj_t * create_meter_box(lv_obj_t * parent, const char * title, const char * text1, const char * text2, const char * text3) +{ + lv_obj_t * cont = lv_obj_create(parent); + lv_obj_set_height(cont, LV_SIZE_CONTENT); + lv_obj_set_flex_grow(cont, 1); + + lv_obj_t * title_label = lv_label_create(cont); + lv_label_set_text(title_label, title); + lv_obj_add_style(title_label, &style_title, 0); + + lv_obj_t * meter = lv_meter_create(cont); + lv_obj_remove_style(meter, NULL, LV_PART_MAIN); + lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR); + lv_obj_set_width(meter, LV_PCT(100)); + + lv_obj_t * bullet1 = lv_obj_create(cont); + lv_obj_set_size(bullet1, 13, 13); + lv_obj_remove_style(bullet1, NULL, LV_PART_SCROLLBAR); + lv_obj_add_style(bullet1, &style_bullet, 0); + lv_obj_set_style_bg_color(bullet1, lv_palette_main(LV_PALETTE_RED), 0); + lv_obj_t * label1 = lv_label_create(cont); + lv_label_set_text(label1, text1); + + lv_obj_t * bullet2 = lv_obj_create(cont); + lv_obj_set_size(bullet2, 13, 13); + lv_obj_remove_style(bullet2, NULL, LV_PART_SCROLLBAR); + lv_obj_add_style(bullet2, &style_bullet, 0); + lv_obj_set_style_bg_color(bullet2, lv_palette_main(LV_PALETTE_BLUE), 0); + lv_obj_t * label2 = lv_label_create(cont); + lv_label_set_text(label2, text2); + + lv_obj_t * bullet3 = lv_obj_create(cont); + lv_obj_set_size(bullet3, 13, 13); + lv_obj_remove_style(bullet3, NULL, LV_PART_SCROLLBAR); + lv_obj_add_style(bullet3, &style_bullet, 0); + lv_obj_set_style_bg_color(bullet3, lv_palette_main(LV_PALETTE_GREEN), 0); + lv_obj_t * label3 = lv_label_create(cont); + lv_label_set_text(label3, text3); + + if(disp_size == DISP_MEDIUM) { + static lv_coord_t grid_col_dsc[] = {LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_CONTENT,LV_GRID_FR(8), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + + lv_obj_set_grid_dsc_array(cont, grid_col_dsc, grid_row_dsc); + lv_obj_set_grid_cell(title_label, LV_GRID_ALIGN_START, 0, 4, LV_GRID_ALIGN_START, 0, 1); + lv_obj_set_grid_cell(meter, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 1, 3); + lv_obj_set_grid_cell(bullet1, LV_GRID_ALIGN_START, 2, 1, LV_GRID_ALIGN_CENTER, 2, 1); + lv_obj_set_grid_cell(bullet2, LV_GRID_ALIGN_START, 2, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(bullet3, LV_GRID_ALIGN_START, 2, 1, LV_GRID_ALIGN_CENTER, 4, 1); + lv_obj_set_grid_cell(label1, LV_GRID_ALIGN_STRETCH, 3, 1, LV_GRID_ALIGN_CENTER, 2, 1); + lv_obj_set_grid_cell(label2, LV_GRID_ALIGN_STRETCH, 3, 1, LV_GRID_ALIGN_CENTER, 3, 1); + lv_obj_set_grid_cell(label3, LV_GRID_ALIGN_STRETCH, 3, 1, LV_GRID_ALIGN_CENTER, 4, 1); + } + else { + static lv_coord_t grid_col_dsc[] = {LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static lv_coord_t grid_row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; + lv_obj_set_grid_dsc_array(cont, grid_col_dsc, grid_row_dsc); + lv_obj_set_grid_cell(title_label, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 0, 1); + lv_obj_set_grid_cell(meter, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 1, 1); + lv_obj_set_grid_cell(bullet1, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(bullet2, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 3, 1); + lv_obj_set_grid_cell(bullet3, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 4, 1); + lv_obj_set_grid_cell(label1, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_START, 2, 1); + lv_obj_set_grid_cell(label2, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_START, 3, 1); + lv_obj_set_grid_cell(label3, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_START, 4, 1); + } + + + return meter; + +} + +static void ta_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * ta = lv_event_get_target(e); + lv_obj_t * kb = lv_event_get_user_data(e); + if(code == LV_EVENT_FOCUSED) { + if(lv_indev_get_type(lv_indev_get_act()) != LV_INDEV_TYPE_KEYPAD) { + lv_keyboard_set_textarea(kb, ta); + lv_obj_set_style_max_height(kb, LV_HOR_RES * 2 / 3, 0); + lv_obj_update_layout(tv); /*Be sure the sizes are recalculated*/ + lv_obj_set_height(tv, LV_VER_RES - lv_obj_get_height(kb)); + lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN); + lv_obj_scroll_to_view_recursive(ta, LV_ANIM_OFF); + } + } + else if(code == LV_EVENT_DEFOCUSED) { + lv_keyboard_set_textarea(kb, NULL); + lv_obj_set_height(tv, LV_VER_RES); + lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); + } + else if(code == LV_EVENT_READY || code == LV_EVENT_CANCEL) { + lv_obj_set_height(tv, LV_VER_RES); + lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); + lv_obj_clear_state(ta, LV_STATE_FOCUSED); + lv_indev_reset(NULL, ta); /*To forget the last clicked object to make it focusable again*/ + } +} + +static void birthday_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * ta = lv_event_get_target(e); + + if(code == LV_EVENT_FOCUSED) { + if(lv_indev_get_type(lv_indev_get_act()) == LV_INDEV_TYPE_POINTER) { + if(calendar == NULL) { + lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); + calendar = lv_calendar_create(lv_layer_top()); + lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_50, 0); + lv_obj_set_style_bg_color(lv_layer_top(), lv_palette_main(LV_PALETTE_GREY), 0); + if(disp_size == DISP_SMALL) lv_obj_set_size(calendar, 180, 180); + else if(disp_size == DISP_MEDIUM) lv_obj_set_size(calendar, 200, 200); + else lv_obj_set_size(calendar, 300, 300); + lv_calendar_set_showed_date(calendar, 1990, 01); + lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 30); + lv_obj_add_event_cb(calendar, calendar_event_cb, LV_EVENT_ALL, ta); + + calendar_header = lv_calendar_header_dropdown_create(lv_layer_top(), calendar); + } + } + } +} + +static void calendar_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * ta = lv_event_get_user_data(e); + lv_obj_t * obj = lv_event_get_target(e); + if(code == LV_EVENT_VALUE_CHANGED) { + lv_calendar_date_t d; + lv_calendar_get_pressed_date(obj, &d); + char buf[32]; + lv_snprintf(buf, sizeof(buf), "%02d.%02d.%d", d.day, d.month, d.year); + lv_textarea_set_text(ta, buf); + + lv_obj_del(calendar); + lv_obj_del(calendar_header); + calendar = NULL; + calendar_header = NULL; + lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); + lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0); + } +} + +static void slider_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * obj = lv_event_get_target(e); + + if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) { + lv_coord_t *s = lv_event_get_param(e); + *s = LV_MAX(*s, 60); + } else if(code == LV_EVENT_DRAW_PART_END) { + lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e); + if(dsc->part == LV_PART_KNOB && lv_obj_has_state(obj, LV_STATE_PRESSED)) { + char buf[8]; + lv_snprintf(buf, sizeof(buf), "%d", lv_slider_get_value(obj)); + + lv_point_t text_size; + lv_txt_get_size(&text_size, buf, font_normal, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE); + + lv_area_t txt_area; + txt_area.x1 = dsc->draw_area->x1 + lv_area_get_width(dsc->draw_area) / 2 - text_size.x / 2; + txt_area.x2 = txt_area.x1 + text_size.x; + txt_area.y2 = dsc->draw_area->y1 - 10; + txt_area.y1 = txt_area.y2 - text_size.y; + + lv_area_t bg_area; + bg_area.x1 = txt_area.x1 - LV_DPX(8); + bg_area.x2 = txt_area.x2 + LV_DPX(8); + bg_area.y1 = txt_area.y1 - LV_DPX(8); + bg_area.y2 = txt_area.y2 + LV_DPX(8); + + lv_draw_rect_dsc_t rect_dsc; + lv_draw_rect_dsc_init(&rect_dsc); + rect_dsc.bg_color = lv_palette_darken(LV_PALETTE_GREY, 3); + rect_dsc.radius = LV_DPX(5); + lv_draw_rect(&bg_area, dsc->clip_area, &rect_dsc); + + lv_draw_label_dsc_t label_dsc; + lv_draw_label_dsc_init(&label_dsc); + label_dsc.color = lv_color_white(); + label_dsc.font = font_normal; + lv_draw_label(&txt_area, dsc->clip_area, &label_dsc, buf, NULL); + } + } +} + +static void chart_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * obj = lv_event_get_target(e); + + if(code == LV_EVENT_PRESSED || code == LV_EVENT_RELEASED) { + lv_obj_invalidate(obj); /*To make the value boxes visible*/ + } + else if(code == LV_EVENT_DRAW_PART_BEGIN) { + lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e); + /*Set the markers' text*/ + if(dsc->part == LV_PART_TICKS && dsc->id == LV_CHART_AXIS_PRIMARY_X) { + if(lv_chart_get_type(obj) == LV_CHART_TYPE_BAR) { + const char * month[] = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"}; + lv_snprintf(dsc->text, sizeof(dsc->text), "%s", month[dsc->value]); + } else { + const char * month[] = {"Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"}; + lv_snprintf(dsc->text, sizeof(dsc->text), "%s", month[dsc->value]); + } + } + + /*Add the faded area before the lines are drawn */ + else if(dsc->part == LV_PART_ITEMS) { +#if LV_DRAW_COMPLEX + /*Add a line mask that keeps the area below the line*/ + if(dsc->p1 && dsc->p2) { + lv_draw_mask_line_param_t line_mask_param; + lv_draw_mask_line_points_init(&line_mask_param, dsc->p1->x, dsc->p1->y, dsc->p2->x, dsc->p2->y, LV_DRAW_MASK_LINE_SIDE_BOTTOM); + int16_t line_mask_id = lv_draw_mask_add(&line_mask_param, NULL); + + /*Add a fade effect: transparent bottom covering top*/ + lv_coord_t h = lv_obj_get_height(obj); + lv_draw_mask_fade_param_t fade_mask_param; + lv_draw_mask_fade_init(&fade_mask_param, &obj->coords, LV_OPA_COVER, obj->coords.y1 + h / 8, LV_OPA_TRANSP, obj->coords.y2); + int16_t fade_mask_id = lv_draw_mask_add(&fade_mask_param, NULL); + + /*Draw a rectangle that will be affected by the mask*/ + lv_draw_rect_dsc_t draw_rect_dsc; + lv_draw_rect_dsc_init(&draw_rect_dsc); + draw_rect_dsc.bg_opa = LV_OPA_50; + draw_rect_dsc.bg_color = dsc->line_dsc->color; + + lv_area_t obj_clip_area; + _lv_area_intersect(&obj_clip_area, dsc->clip_area, &obj->coords); + + lv_area_t a; + a.x1 = dsc->p1->x; + a.x2 = dsc->p2->x - 1; + a.y1 = LV_MIN(dsc->p1->y, dsc->p2->y); + a.y2 = obj->coords.y2; + lv_draw_rect(&a, &obj_clip_area, &draw_rect_dsc); + + /*Remove the masks*/ + lv_draw_mask_remove_id(line_mask_id); + lv_draw_mask_remove_id(fade_mask_id); + } +#endif + + + const lv_chart_series_t * ser = dsc->sub_part_ptr; + + if(lv_chart_get_pressed_point(obj) == dsc->id) { + if(lv_chart_get_type(obj) == LV_CHART_TYPE_LINE) { + dsc->rect_dsc->outline_color = lv_color_white(); + dsc->rect_dsc->outline_width = 2; + } else { + dsc->rect_dsc->shadow_color = ser->color; + dsc->rect_dsc->shadow_width = 15; + dsc->rect_dsc->shadow_spread = 0; + } + + char buf[8]; + lv_snprintf(buf, sizeof(buf), "%d", dsc->value); + + lv_point_t text_size; + lv_txt_get_size(&text_size, buf, font_normal, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE); + + lv_area_t txt_area; + if(lv_chart_get_type(obj) == LV_CHART_TYPE_BAR) { + txt_area.y2 = dsc->draw_area->y1 - LV_DPX(15); + txt_area.y1 = txt_area.y2 - text_size.y; + if(ser == lv_chart_get_series_next(obj, NULL)) { + txt_area.x1 = dsc->draw_area->x1 + lv_area_get_width(dsc->draw_area) / 2; + txt_area.x2 = txt_area.x1 + text_size.x; + } else { + txt_area.x2 = dsc->draw_area->x1 + lv_area_get_width(dsc->draw_area) / 2; + txt_area.x1 = txt_area.x2 - text_size.x; + } + } else { + txt_area.x1 = dsc->draw_area->x1 + lv_area_get_width(dsc->draw_area) / 2 - text_size.x / 2; + txt_area.x2 = txt_area.x1 + text_size.x; + txt_area.y2 = dsc->draw_area->y1 - LV_DPX(15); + txt_area.y1 = txt_area.y2 - text_size.y; + } + + lv_area_t bg_area; + bg_area.x1 = txt_area.x1 - LV_DPX(8); + bg_area.x2 = txt_area.x2 + LV_DPX(8); + bg_area.y1 = txt_area.y1 - LV_DPX(8); + bg_area.y2 = txt_area.y2 + LV_DPX(8); + + lv_draw_rect_dsc_t rect_dsc; + lv_draw_rect_dsc_init(&rect_dsc); + rect_dsc.bg_color = ser->color; + rect_dsc.radius = LV_DPX(5); + lv_draw_rect(&bg_area, dsc->clip_area, &rect_dsc); + + lv_draw_label_dsc_t label_dsc; + lv_draw_label_dsc_init(&label_dsc); + label_dsc.color = lv_color_white(); + label_dsc.font = font_normal; + lv_draw_label(&txt_area, dsc->clip_area, &label_dsc, buf, NULL); + } else { + dsc->rect_dsc->outline_width = 0; + dsc->rect_dsc->shadow_width = 0; + } + } + } +} + + +static void shop_chart_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + if(code == LV_EVENT_DRAW_PART_BEGIN) { + lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e); + /*Set the markers' text*/ + if(dsc->part == LV_PART_TICKS && dsc->id == LV_CHART_AXIS_PRIMARY_X) { + const char * month[] = {"Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"}; + lv_snprintf(dsc->text, sizeof(dsc->text), "%s", month[dsc->value]); + } + if(dsc->part == LV_PART_ITEMS) { + dsc->rect_dsc->bg_opa = LV_OPA_TRANSP; /*We will draw it later*/ + } + } + if(code == LV_EVENT_DRAW_PART_END) { + lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e); + /*Add the faded area before the lines are drawn */ + if(dsc->part == LV_PART_ITEMS) { + static const uint32_t devices[10] = {32, 43, 21, 56, 29, 36, 19, 25, 62, 35}; + static const uint32_t clothes[10] = {12, 19, 23, 31, 27, 32, 32, 11, 21, 32}; + static const uint32_t services[10] = {56, 38, 56, 13, 44, 32, 49, 64, 17, 33}; + + lv_draw_rect_dsc_t draw_rect_dsc; + lv_draw_rect_dsc_init(&draw_rect_dsc); + + lv_coord_t h = lv_area_get_height(dsc->draw_area); + + lv_area_t a; + a.x1 = dsc->draw_area->x1; + a.x2 = dsc->draw_area->x2; + + a.y1 = dsc->draw_area->y1; + a.y2 = a.y1 + 4 + (devices[dsc->id] * h) / 100; /*+4 to overlap the radius*/ + draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_RED); + draw_rect_dsc.radius = 4; + lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc); + + a.y1 = a.y2 - 4; /*-4 to overlap the radius*/ + a.y2 = a.y1 + (clothes[dsc->id] * h) / 100; + draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_BLUE); + draw_rect_dsc.radius = 0; + lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc); + + a.y1 = a.y2; + a.y2 = a.y1 + (services[dsc->id] * h) / 100; + draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_GREEN); + lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc); + } + } +} + + +static void meter1_indic1_anim_cb(void * var, int32_t v) +{ + lv_meter_set_indicator_end_value(meter1, var, v); + + lv_obj_t * card = lv_obj_get_parent(meter1); + lv_obj_t * label = lv_obj_get_child(card, -5); + lv_label_set_text_fmt(label, "Revenue: %d %%", v); +} + +static void meter1_indic2_anim_cb(void * var, int32_t v) +{ + lv_meter_set_indicator_end_value(meter1, var, v); + + lv_obj_t * card = lv_obj_get_parent(meter1); + lv_obj_t * label = lv_obj_get_child(card, -3); + lv_label_set_text_fmt(label, "Sales: %d %%", v); + +} + +static void meter1_indic3_anim_cb(void * var, int32_t v) +{ + lv_meter_set_indicator_end_value(meter1, var, v); + + lv_obj_t * card = lv_obj_get_parent(meter1); + lv_obj_t * label = lv_obj_get_child(card, -1); + lv_label_set_text_fmt(label, "Costs: %d %%", v); +} + +static void meter2_timer_cb(lv_timer_t * timer) +{ + lv_meter_indicator_t ** indics = timer->user_data; + + static bool down1 = false; + static bool down2 = false; + static bool down3 = false; + + + if(down1) { + session_desktop -= 137; + if(session_desktop < 1400) down1 = false; + } else { + session_desktop += 116; + if(session_desktop > 4500) down1 = true; + } + + if(down2) { + session_tablet -= 3; + if(session_tablet < 1400) down2 = false; + } else { + session_tablet += 9; + if(session_tablet > 4500) down2 = true; + } + + if(down3) { + session_mobile -= 57; + if(session_mobile < 1400) down3 = false; + } else { + session_mobile += 76; + if(session_mobile > 4500) down3 = true; + } + + uint32_t all = session_desktop + session_tablet + session_mobile; + uint32_t pct1 = (session_desktop * 97) / all; + uint32_t pct2 = (session_tablet * 97) / all; + + lv_meter_set_indicator_start_value(meter2, indics[0], 0); + lv_meter_set_indicator_end_value(meter2, indics[0], pct1); + + lv_meter_set_indicator_start_value(meter2, indics[1], pct1 + 1); + lv_meter_set_indicator_end_value(meter2, indics[1], pct1 + 1 + pct2); + + lv_meter_set_indicator_start_value(meter2, indics[2], pct1 + 1 + pct2 + 1); + lv_meter_set_indicator_end_value(meter2, indics[2], 99); + + lv_obj_t * card = lv_obj_get_parent(meter2); + lv_obj_t * label; + + label = lv_obj_get_child(card, -5); + lv_label_set_text_fmt(label, "Desktop: %d", session_desktop); + + label = lv_obj_get_child(card, -3); + lv_label_set_text_fmt(label, "Tablet: %d", session_tablet); + + label = lv_obj_get_child(card, -1); + lv_label_set_text_fmt(label, "Mobile: %d", session_mobile); +} + +static void meter3_anim_cb(void * var, int32_t v) +{ + lv_meter_set_indicator_value(meter3, var, v); + + lv_obj_t * label = lv_obj_get_child(meter3, 0); + lv_label_set_text_fmt(label, "%d", v); +} + + +static void tab_changer_task_cb(lv_timer_t * timer) +{ + uint16_t act = lv_tabview_get_tab_act(tv); + act++; + if(act >= 3) act = 0; + + lv_tabview_set_act(tv, act, LV_ANIM_ON); +} + +#endif \ No newline at end of file diff --git a/libraries/LittleVGL/examples/lvgl_rpc_usb_mouse/lvgl_rpc_usb_mouse.ino b/libraries/Portenta_lvgl/examples/lvgl_rpc_usb_mouse/lvgl_rpc_usb_mouse.ino similarity index 99% rename from libraries/LittleVGL/examples/lvgl_rpc_usb_mouse/lvgl_rpc_usb_mouse.ino rename to libraries/Portenta_lvgl/examples/lvgl_rpc_usb_mouse/lvgl_rpc_usb_mouse.ino index 07b5ac8c3..c58fa2eee 100644 --- a/libraries/LittleVGL/examples/lvgl_rpc_usb_mouse/lvgl_rpc_usb_mouse.ino +++ b/libraries/Portenta_lvgl/examples/lvgl_rpc_usb_mouse/lvgl_rpc_usb_mouse.ino @@ -1,4 +1,4 @@ -#include "Portenta_LittleVGL.h" +#include "Portenta_lvgl.h" #include "RPC_internal.h" #include "USBHost.h" diff --git a/libraries/Portenta_lvgl/library.properties b/libraries/Portenta_lvgl/library.properties new file mode 100644 index 000000000..0f7dc545b --- /dev/null +++ b/libraries/Portenta_lvgl/library.properties @@ -0,0 +1,9 @@ +name=Portenta_lvgl +version=1.0 +author=Arduino +maintainer=Arduino +sentence=lvgl porting for Portenta H7 via USBC (to HDMI adapter) +paragraph= +category=Display +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Portenta_lvgl +architectures=mbed,mbed_portenta diff --git a/libraries/Portenta_lvgl/src/Portenta_LittleVGL.h b/libraries/Portenta_lvgl/src/Portenta_LittleVGL.h new file mode 100644 index 000000000..e0f8666b7 --- /dev/null +++ b/libraries/Portenta_lvgl/src/Portenta_LittleVGL.h @@ -0,0 +1,3 @@ +// Old header, kept for backwards compatibility + +#include "Portenta_lvgl.h" \ No newline at end of file diff --git a/libraries/LittleVGL/Portenta_LittleVGL.h b/libraries/Portenta_lvgl/src/Portenta_lvgl.h similarity index 100% rename from libraries/LittleVGL/Portenta_LittleVGL.h rename to libraries/Portenta_lvgl/src/Portenta_lvgl.h diff --git a/libraries/LittleVGL/lv_conf.h b/libraries/Portenta_lvgl/src/lv_conf.h similarity index 100% rename from libraries/LittleVGL/lv_conf.h rename to libraries/Portenta_lvgl/src/lv_conf.h diff --git a/libraries/LittleVGL/porting.cpp b/libraries/Portenta_lvgl/src/porting.cpp similarity index 84% rename from libraries/LittleVGL/porting.cpp rename to libraries/Portenta_lvgl/src/porting.cpp index c4e9508d7..0bbcd1fec 100644 --- a/libraries/LittleVGL/porting.cpp +++ b/libraries/Portenta_lvgl/src/porting.cpp @@ -1,4 +1,4 @@ -#include "Portenta_LittleVGL.h" +#include "Portenta_lvgl.h" #include "lv_conf.h" #include #include "mbed.h" @@ -151,24 +151,36 @@ void portenta_init_video() { getNextFrameBuffer(); static lv_color_t buf[LV_HOR_RES_MAX * LV_VER_RES_MAX / 6]; - static lv_disp_buf_t disp_buf; - lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * LV_VER_RES_MAX / 6); - - /*Initialize the display*/ - lv_disp_drv_init(&disp_drv); - disp_drv.flush_cb = my_disp_flush; - disp_drv.gpu_fill_cb = gpu_fill; - disp_drv.gpu_blend_cb = gpu_blend; - disp_drv.buffer = &disp_buf; - lv_disp_drv_register(&disp_drv); - - // lv_obj_t * myCustomLabel = lv_label_create(lv_scr_act(), NULL); - // lv_label_set_text(myCustomLabel, "Hello Arduino! Dev-7,0"); - // lv_obj_align(myCustomLabel, NULL, LV_ALIGN_CENTER, 0, 0); - // lv_label_set_text_fmt(myCustomLabel, "%d", 1999); - //lv_label_set_text_fmt(myCustomLabel, "hola"); - - //lv_task_create(label_refresher_task, 1000, LV_TASK_PRIO_MID, NULL); + + // Compatibility with v7 and v8 APIs + #if LVGL_VERSION_MAJOR > 7 + static lv_disp_draw_buf_t disp_buf; + lv_disp_draw_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * LV_VER_RES_MAX / 6); + + /*Initialize the display*/ + lv_disp_drv_init(&disp_drv); + disp_drv.flush_cb = my_disp_flush; + disp_drv.gpu_fill_cb = gpu_fill; + disp_drv.draw_buf = &disp_buf; + disp_drv.hor_res = LV_HOR_RES_MAX; + disp_drv.ver_res = LV_VER_RES_MAX; + + lv_disp_drv_register(&disp_drv); + + #else + static lv_disp_buf_t disp_buf; + lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * LV_VER_RES_MAX / 6); + + /*Initialize the display*/ + lv_disp_drv_init(&disp_drv); + disp_drv.flush_cb = my_disp_flush; + disp_drv.gpu_fill_cb = gpu_fill; + disp_drv.gpu_blend_cb = gpu_blend; + disp_drv.buffer = &disp_buf; + + lv_disp_drv_register(&disp_drv); + + #endif } diff --git a/libraries/RPC/examples/BootM4_from_SDRAM/BootM4_from_SDRAM.ino b/libraries/RPC/examples/BootM4_from_SDRAM/BootM4_from_SDRAM.ino index 47df0dc5a..c5deca69b 100644 --- a/libraries/RPC/examples/BootM4_from_SDRAM/BootM4_from_SDRAM.ino +++ b/libraries/RPC/examples/BootM4_from_SDRAM/BootM4_from_SDRAM.ino @@ -6,7 +6,7 @@ #include "FATFileSystem.h" #include "PluggableUSBMSD.h" -QSPIFBlockDevice root(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000); +QSPIFBlockDevice root; mbed::MBRBlockDevice ota_data(&root, 2); mbed::FATFileSystem ota_data_fs("fs"); diff --git a/libraries/RPC/library.properties b/libraries/RPC/library.properties new file mode 100644 index 000000000..60361639d --- /dev/null +++ b/libraries/RPC/library.properties @@ -0,0 +1,9 @@ +name=RPC +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Enables the communication between Portenta H7 cores +paragraph= +category=Communication +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/RPC +architectures=mbed,mbed_portenta diff --git a/libraries/RPC/RPC.cpp b/libraries/RPC/src/RPC.cpp similarity index 100% rename from libraries/RPC/RPC.cpp rename to libraries/RPC/src/RPC.cpp diff --git a/libraries/RPC/RPC_client.h b/libraries/RPC/src/RPC_client.h similarity index 100% rename from libraries/RPC/RPC_client.h rename to libraries/RPC/src/RPC_client.h diff --git a/libraries/RPC/RPC_internal.h b/libraries/RPC/src/RPC_internal.h similarity index 100% rename from libraries/RPC/RPC_internal.h rename to libraries/RPC/src/RPC_internal.h diff --git a/libraries/RPC/SerialRPC.cpp b/libraries/RPC/src/SerialRPC.cpp similarity index 100% rename from libraries/RPC/SerialRPC.cpp rename to libraries/RPC/src/SerialRPC.cpp diff --git a/libraries/RPC/SerialRPC.h b/libraries/RPC/src/SerialRPC.h similarity index 100% rename from libraries/RPC/SerialRPC.h rename to libraries/RPC/src/SerialRPC.h diff --git a/libraries/SFU/library.properties b/libraries/SFU/library.properties index ac6db9273..e8a097ad5 100644 --- a/libraries/SFU/library.properties +++ b/libraries/SFU/library.properties @@ -2,8 +2,8 @@ name=SFU version=1.0.0 author=Arduino maintainer=Arduino -sentence=Update the sketch on your board from a Arduino MKRMEM Shield. -paragraph=Requires a Arduino MKRMEM Shield. +sentence=Second stage bootloader for RP2040 boards +paragraph= category=Other url=https://www.arduino.cc/en/Reference/SFU -architectures=mbed +architectures=mbed,mbed_nano,mbed_rp2040 diff --git a/libraries/Scheduler/library.properties b/libraries/Scheduler/library.properties index 62f6695df..2c0942ac1 100644 --- a/libraries/Scheduler/library.properties +++ b/libraries/Scheduler/library.properties @@ -2,8 +2,8 @@ name=Scheduler version=0.4.4 author=Arduino maintainer=Arduino -sentence=Allows multiple tasks to run at the same time, without interrupting each other. For Arduino sam and samd architectures only (Due, Zero...). +sentence=Allows multiple tasks to run at the same time, without interrupting each other. paragraph=The Scheduler library enables the Arduino to run multiple functions at the same time. This allows tasks to happen without interrupting each other.
This is a cooperative scheduler in that the CPU switches from one task to another. The library includes methods for passing control between tasks. category=Other url=http://www.arduino.cc/en/Reference/Scheduler -architectures=mbed +architectures=mbed,mbed_portenta,mbed_nano,mbed_edge,mbed_rp2040,mbed_nicla diff --git a/libraries/ThreadDebug/library.properties b/libraries/ThreadDebug/library.properties index 8c8b0e271..248a59fe4 100644 --- a/libraries/ThreadDebug/library.properties +++ b/libraries/ThreadDebug/library.properties @@ -6,4 +6,4 @@ sentence=The GDB compatible thread debug monitor for Cortex-M devices. paragraph=ThreadDebug is a debug monitor which allows the GNU debugger, GDB, to debug application threads using a full featured source level debugger with no extra hardware. category=Communication url= -architectures=mbed +architectures=mbed,mbed_portenta,mbed_nano diff --git a/libraries/USBHID/examples/Keyboard/Keyboard.ino b/libraries/USBHID/examples/Keyboard/Keyboard.ino new file mode 100644 index 000000000..6b00d5083 --- /dev/null +++ b/libraries/USBHID/examples/Keyboard/Keyboard.ino @@ -0,0 +1,15 @@ +#include "PluggableUSBHID.h" +#include "USBKeyboard.h" + +USBKeyboard Keyboard; + +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + delay(1000); + Keyboard.printf("Hello world\n\r"); +} diff --git a/libraries/USBHID/examples/Mouse/Mouse.ino b/libraries/USBHID/examples/Mouse/Mouse.ino new file mode 100644 index 000000000..253b19633 --- /dev/null +++ b/libraries/USBHID/examples/Mouse/Mouse.ino @@ -0,0 +1,17 @@ +#include "PluggableUSBHID.h" +#include "USBMouse.h" + +USBMouse Mouse; + +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + delay(1000); + Mouse.move(100,100); + delay(1000); + Mouse.move(-100,-100); +} diff --git a/libraries/USBHID/library.properties b/libraries/USBHID/library.properties new file mode 100644 index 000000000..94d0d0f87 --- /dev/null +++ b/libraries/USBHID/library.properties @@ -0,0 +1,9 @@ +name=USBHID +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Mouse/Keyboard/HID support for mbed enabled boards +paragraph= +category=Communication +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/USBHID +architectures=mbed,mbed_portenta,mbed_nano,mbed_rp2040 diff --git a/libraries/USBHID/PluggableUSBHID.h b/libraries/USBHID/src/PluggableUSBHID.h similarity index 100% rename from libraries/USBHID/PluggableUSBHID.h rename to libraries/USBHID/src/PluggableUSBHID.h diff --git a/libraries/USBHID/USBHID.cpp b/libraries/USBHID/src/USBHID.cpp similarity index 100% rename from libraries/USBHID/USBHID.cpp rename to libraries/USBHID/src/USBHID.cpp diff --git a/libraries/USBHID/USBHID_Types.h b/libraries/USBHID/src/USBHID_Types.h similarity index 100% rename from libraries/USBHID/USBHID_Types.h rename to libraries/USBHID/src/USBHID_Types.h diff --git a/libraries/USBHID/USBKeyboard.cpp b/libraries/USBHID/src/USBKeyboard.cpp similarity index 100% rename from libraries/USBHID/USBKeyboard.cpp rename to libraries/USBHID/src/USBKeyboard.cpp diff --git a/libraries/USBHID/USBKeyboard.h b/libraries/USBHID/src/USBKeyboard.h similarity index 100% rename from libraries/USBHID/USBKeyboard.h rename to libraries/USBHID/src/USBKeyboard.h diff --git a/libraries/USBHID/USBMouse.cpp b/libraries/USBHID/src/USBMouse.cpp similarity index 100% rename from libraries/USBHID/USBMouse.cpp rename to libraries/USBHID/src/USBMouse.cpp diff --git a/libraries/USBHID/USBMouse.h b/libraries/USBHID/src/USBMouse.h similarity index 100% rename from libraries/USBHID/USBMouse.h rename to libraries/USBHID/src/USBMouse.h diff --git a/libraries/USBHID/USBMouseKeyboard.cpp b/libraries/USBHID/src/USBMouseKeyboard.cpp similarity index 100% rename from libraries/USBHID/USBMouseKeyboard.cpp rename to libraries/USBHID/src/USBMouseKeyboard.cpp diff --git a/libraries/USBHID/USBMouseKeyboard.h b/libraries/USBHID/src/USBMouseKeyboard.h similarity index 100% rename from libraries/USBHID/USBMouseKeyboard.h rename to libraries/USBHID/src/USBMouseKeyboard.h diff --git a/libraries/USBHOST/library.properties b/libraries/USBHOST/library.properties index 6a013655e..8ca428cbb 100644 --- a/libraries/USBHOST/library.properties +++ b/libraries/USBHOST/library.properties @@ -2,8 +2,8 @@ name=USBHOST version=1.0 author=Arduino maintainer=Arduino -sentence=Enables the communication between H747 cores via shared memory and openAMP library. -paragraph= +sentence=USB Host support for Portenta H7 boards +paragraph=If using the Full Speed, non-USBC port, refer to https://github.com/facchinm/USBHostMbed5 category=Communication -url= +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/USBHOST architectures=mbed,mbed_portenta diff --git a/libraries/USBMSD/examples/AccessFlashAsUSBDisk/AccessFlashAsUSBDisk.ino b/libraries/USBMSD/examples/AccessFlashAsUSBDisk/AccessFlashAsUSBDisk.ino new file mode 100644 index 000000000..35cc26702 --- /dev/null +++ b/libraries/USBMSD/examples/AccessFlashAsUSBDisk/AccessFlashAsUSBDisk.ino @@ -0,0 +1,62 @@ +/* + QSPI as USB Mass Storage + This example shows how to expose a QSPIF BlockDevice (16MB external flash on the Portenta H7) + as an USB stick. It can be adapted to any kind of BlockDevice (FlashIAP or either RAM via HeapBlockDevice) + Before loading this example, make sure you execute PortentaWiFiFirmwareUpdater sketch + to create and format the proper partitions. +*/ + +#include "PluggableUSBMSD.h" +#include "QSPIFBlockDevice.h" +#include "MBRBlockDevice.h" +#include "FATFileSystem.h" + +static QSPIFBlockDevice root; +mbed::MBRBlockDevice wifi_data(&root, 1); +mbed::MBRBlockDevice ota_data(&root, 2); +static mbed::FATFileSystem wifi("wifi"); +static mbed::FATFileSystem ota("ota"); + +void USBMSD::begin() +{ + int err = wifi.mount(&wifi_data); + if (err) { + while (!Serial); + Serial.println("Please run PortentaWiFiFirmwareUpdater before"); + return; + } + ota.mount(&ota_data); +} + + +USBMSD MassStorage(&root); + +void setup() { + Serial.begin(115200); + MassStorage.begin(); +} + +void printDirectory(char* name) { + DIR *d; + struct dirent *p; + + d = opendir(name); + if (d != NULL) { + while ((p = readdir(d)) != NULL) { + Serial.println(p->d_name); + } + } + closedir(d); +} + +void loop() { + if (MassStorage.media_removed()) { + // list the content of the partitions + // you may need to restart the board for the list to update if you copied new files + Serial.println("Content of WiFi partition:"); + printDirectory("/wifi"); + Serial.println("Content of OTA partition:"); + printDirectory("/ota"); + } + delay(1000); +} diff --git a/libraries/USBMSD/examples/Nano33BLE_FlashMassStorage/Nano33BLE_FlashMassStorage.ino b/libraries/USBMSD/examples/Nano33BLE_FlashMassStorage/Nano33BLE_FlashMassStorage.ino new file mode 100644 index 000000000..ca201e87a --- /dev/null +++ b/libraries/USBMSD/examples/Nano33BLE_FlashMassStorage/Nano33BLE_FlashMassStorage.ino @@ -0,0 +1,24 @@ +/* + This example exposes the second half (512KB) of Nano 33 BLE flash + as a USB disk. + The user can interact with this disk as a bidirectional communication with the board + For example, the board could save data in a file to be retrieved later with a drag and drop +*/ + +#include "PluggableUSBMSD.h" + +void setup() { + Serial.begin(115200); + MassStorage.begin(); + + // write a file with some data + // a+ means append, so every time the board is rebooted the file will grow by a new line + FILE *f = fopen("/fs/data.txt", "a+"); + String hello = "Hello from Nano33BLE Filesystem\n"; + fwrite(hello.c_str(), hello.length(), 1, f); + fclose(f); +} + +void loop() { + delay(1000); +} diff --git a/libraries/USBMSD/library.properties b/libraries/USBMSD/library.properties new file mode 100644 index 000000000..7fc4cfdf4 --- /dev/null +++ b/libraries/USBMSD/library.properties @@ -0,0 +1,9 @@ +name=USB Mass Storage +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Allow exposing block devices as USB disk when connected to a PC +paragraph= +category=Data Storage +url=https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/USBMSD +architectures=mbed,mbed_portenta,mbed_nano,mbed_edge,mbed_rp2040 diff --git a/libraries/USBMSD/PluggableUSBMSD.h b/libraries/USBMSD/src/PluggableUSBMSD.h similarity index 100% rename from libraries/USBMSD/PluggableUSBMSD.h rename to libraries/USBMSD/src/PluggableUSBMSD.h diff --git a/libraries/USBMSD/Singleton.cpp b/libraries/USBMSD/src/Singleton.cpp similarity index 100% rename from libraries/USBMSD/Singleton.cpp rename to libraries/USBMSD/src/Singleton.cpp diff --git a/libraries/USBMSD/USBMSD.cpp b/libraries/USBMSD/src/USBMSD.cpp similarity index 100% rename from libraries/USBMSD/USBMSD.cpp rename to libraries/USBMSD/src/USBMSD.cpp diff --git a/libraries/WiFiESP8266/library.properties b/libraries/WiFiESP8266/library.properties deleted file mode 100644 index f30e54260..000000000 --- a/libraries/WiFiESP8266/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=WiFiESP8266 -version=1.0 -author=Arduino -maintainer=Arduino -sentence=WiFi wrapper for mbed ESP8266WIFi class -paragraph= -category=Other -url=http://www.arduino.cc/en/Reference/WiFi -architectures=mbed,ArduinoCore-mbed diff --git a/libraries/WiFiESP8266/src/WiFiESP8266.cpp b/libraries/WiFiESP8266/src/WiFiESP8266.cpp deleted file mode 100644 index 9c6989965..000000000 --- a/libraries/WiFiESP8266/src/WiFiESP8266.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "Arduino.h" -#include "WiFi.h" - -using namespace mbed; - -#include "ESP8266Interface.h" - -static ESP8266Interface wifi_if(PD_8, PD_9); -arduino::WiFiClass WiFi(&wifi_if); diff --git a/libraries/WiFiESP8266/src/WiFiESP8266.h b/libraries/WiFiESP8266/src/WiFiESP8266.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/libraries/WiFiODINW2/library.properties b/libraries/WiFiODINW2/library.properties deleted file mode 100644 index 82a84e89a..000000000 --- a/libraries/WiFiODINW2/library.properties +++ /dev/null @@ -1,11 +0,0 @@ -name=WiFiODINW2 -version=1.0 -author=Arduino -maintainer=Arduino -sentence=WiFi wrapper for mbed ODINW2 class -paragraph= -category=Other -url=http://www.arduino.cc/en/Reference/WiFi -architectures=mbed,ArduinoCore-mbed -precompiled=true -ldflags=-lublox-odin-w2-driver diff --git a/libraries/WiFiODINW2/src/WiFiODINW2.cpp b/libraries/WiFiODINW2/src/WiFiODINW2.cpp deleted file mode 100644 index 156af8b37..000000000 --- a/libraries/WiFiODINW2/src/WiFiODINW2.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Arduino.h" -#include "WiFi.h" - -using namespace mbed; - -#include "OdinWiFiInterface.h" - -#if 0 -static OdinWiFiInterface* wifi_if; -void* cb() { - wifi_if = new OdinWiFiInterface(); - return wifi_if; -} - -arduino::WiFiClass WiFi(cb); -#else -static OdinWiFiInterface wifi_if; -arduino::WiFiClass WiFi(&wifi_if); -#endif \ No newline at end of file diff --git a/libraries/WiFiODINW2/src/WiFiODINW2.h b/libraries/WiFiODINW2/src/WiFiODINW2.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/libraries/WiFiODINW2/src/cortex-m4/libublox-odin-w2-driver.a b/libraries/WiFiODINW2/src/cortex-m4/libublox-odin-w2-driver.a deleted file mode 100644 index e0554567d..000000000 Binary files a/libraries/WiFiODINW2/src/cortex-m4/libublox-odin-w2-driver.a and /dev/null differ diff --git a/libraries/doom/examples/Doom/Doom.ino b/libraries/doom/examples/Doom/Doom.ino index 4e00f35c4..17ff5c43e 100644 --- a/libraries/doom/examples/Doom/Doom.ino +++ b/libraries/doom/examples/Doom/Doom.ino @@ -1,36 +1,39 @@ -/* Arduino wrapper for DoomGeneric - * Mouse and keyboard controls are not implemented at the moment; - * to use the internal QSPI flash as storage, force the board in bootloader mode - * by double clicking the reset button and upload doom.fat.dump (from doom/utils folder) - * with this command - * - * dfu-util -a1 --device 0x2341:0x035b -D doom.fat.dump --dfuse-address=0x90000000 - */ +/* + Arduino wrapper for DoomGeneric + Mouse and keyboard controls are not implemented at the moment. + + To use the internal QSPI flash as storage, run PortentaWiFiFirmwareUpdater + sketch once to create the partitions, AccessFlashAsUSBDisk to expose the QSPI flash + as a USB disk, copy DOOM1.WAD in the biggest partition, flash this sketch and you are ready to go :) +*/ #include "QSPIFBlockDevice.h" #include "FATFileSystem.h" +#include "MBRBlockDevice.h" #include "doomgeneric.h" -QSPIFBlockDevice block_device(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000); +QSPIFBlockDevice block_device; // Comment previous line and uncomment these two if you want to store DOOM.WAD in an external SD card (FAT32 formatted) // #include "SDMMCBlockDevice.h" // SDMMCBlockDevice block_device; -mbed::FATFileSystem fs("fs"); +mbed::MBRBlockDevice fs_data(&block_device, 2); +static mbed::FATFileSystem fs("fs"); extern "C" int main_wrapper(int argc, char **argv); char*argv[] = {"/fs/doom", "-iwad", "/fs/DOOM1.WAD"}; void setup() { - // put your setup code here, to run once: - delay(2000); - int err = fs.mount(&block_device); + int err = fs.mount(&fs_data); if (err) { - // Reformat if we can't mount the filesystem - // this should only happen on the first boot - printf("No filesystem found, formatting... "); - fflush(stdout); - err = fs.reformat(&block_device); + printf("No filesystem found, please run AccessFlashAsUSBDisk sketch and copy DOOM1.WAD in the big partition"); + pinMode(LEDB, OUTPUT); + while (1) { + digitalWrite(LEDB, LOW); + delay(100); + digitalWrite(LEDB, HIGH); + delay(100); + } } DIR *dir; struct dirent *ent; @@ -51,4 +54,4 @@ void setup() { void loop() { // put your main code here, to run repeatedly: -} \ No newline at end of file +} diff --git a/libraries/doom/library.properties b/libraries/doom/library.properties new file mode 100644 index 000000000..8d4761350 --- /dev/null +++ b/libraries/doom/library.properties @@ -0,0 +1,9 @@ +name=Doom +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Porting of Doom engine to Portenta H7 +paragraph= +category=Display +url=https://github.com/arduino/ArduinoCore-mbed +architectures=mbed,mbed_portenta diff --git a/libraries/doom/am_map.c b/libraries/doom/src/am_map.c similarity index 100% rename from libraries/doom/am_map.c rename to libraries/doom/src/am_map.c diff --git a/libraries/doom/am_map.h b/libraries/doom/src/am_map.h similarity index 100% rename from libraries/doom/am_map.h rename to libraries/doom/src/am_map.h diff --git a/libraries/doom/config.h b/libraries/doom/src/config.h similarity index 100% rename from libraries/doom/config.h rename to libraries/doom/src/config.h diff --git a/libraries/doom/d_englsh.h b/libraries/doom/src/d_englsh.h similarity index 100% rename from libraries/doom/d_englsh.h rename to libraries/doom/src/d_englsh.h diff --git a/libraries/doom/d_event.c b/libraries/doom/src/d_event.c similarity index 100% rename from libraries/doom/d_event.c rename to libraries/doom/src/d_event.c diff --git a/libraries/doom/d_event.h b/libraries/doom/src/d_event.h similarity index 100% rename from libraries/doom/d_event.h rename to libraries/doom/src/d_event.h diff --git a/libraries/doom/d_items.c b/libraries/doom/src/d_items.c similarity index 100% rename from libraries/doom/d_items.c rename to libraries/doom/src/d_items.c diff --git a/libraries/doom/d_items.h b/libraries/doom/src/d_items.h similarity index 100% rename from libraries/doom/d_items.h rename to libraries/doom/src/d_items.h diff --git a/libraries/doom/d_iwad.c b/libraries/doom/src/d_iwad.c similarity index 100% rename from libraries/doom/d_iwad.c rename to libraries/doom/src/d_iwad.c diff --git a/libraries/doom/d_iwad.h b/libraries/doom/src/d_iwad.h similarity index 100% rename from libraries/doom/d_iwad.h rename to libraries/doom/src/d_iwad.h diff --git a/libraries/doom/d_loop.c b/libraries/doom/src/d_loop.c similarity index 100% rename from libraries/doom/d_loop.c rename to libraries/doom/src/d_loop.c diff --git a/libraries/doom/d_loop.h b/libraries/doom/src/d_loop.h similarity index 100% rename from libraries/doom/d_loop.h rename to libraries/doom/src/d_loop.h diff --git a/libraries/doom/d_main.c b/libraries/doom/src/d_main.c similarity index 100% rename from libraries/doom/d_main.c rename to libraries/doom/src/d_main.c diff --git a/libraries/doom/d_main.h b/libraries/doom/src/d_main.h similarity index 100% rename from libraries/doom/d_main.h rename to libraries/doom/src/d_main.h diff --git a/libraries/doom/d_mode.c b/libraries/doom/src/d_mode.c similarity index 100% rename from libraries/doom/d_mode.c rename to libraries/doom/src/d_mode.c diff --git a/libraries/doom/d_mode.h b/libraries/doom/src/d_mode.h similarity index 100% rename from libraries/doom/d_mode.h rename to libraries/doom/src/d_mode.h diff --git a/libraries/doom/d_net.c b/libraries/doom/src/d_net.c similarity index 100% rename from libraries/doom/d_net.c rename to libraries/doom/src/d_net.c diff --git a/libraries/doom/d_player.h b/libraries/doom/src/d_player.h similarity index 100% rename from libraries/doom/d_player.h rename to libraries/doom/src/d_player.h diff --git a/libraries/doom/d_textur.h b/libraries/doom/src/d_textur.h similarity index 100% rename from libraries/doom/d_textur.h rename to libraries/doom/src/d_textur.h diff --git a/libraries/doom/d_think.h b/libraries/doom/src/d_think.h similarity index 100% rename from libraries/doom/d_think.h rename to libraries/doom/src/d_think.h diff --git a/libraries/doom/d_ticcmd.h b/libraries/doom/src/d_ticcmd.h similarity index 100% rename from libraries/doom/d_ticcmd.h rename to libraries/doom/src/d_ticcmd.h diff --git a/libraries/doom/deh_main.h b/libraries/doom/src/deh_main.h similarity index 100% rename from libraries/doom/deh_main.h rename to libraries/doom/src/deh_main.h diff --git a/libraries/doom/deh_misc.h b/libraries/doom/src/deh_misc.h similarity index 100% rename from libraries/doom/deh_misc.h rename to libraries/doom/src/deh_misc.h diff --git a/libraries/doom/deh_str.h b/libraries/doom/src/deh_str.h similarity index 100% rename from libraries/doom/deh_str.h rename to libraries/doom/src/deh_str.h diff --git a/libraries/doom/doom.h b/libraries/doom/src/doom.h similarity index 100% rename from libraries/doom/doom.h rename to libraries/doom/src/doom.h diff --git a/libraries/doom/doomdata.h b/libraries/doom/src/doomdata.h similarity index 100% rename from libraries/doom/doomdata.h rename to libraries/doom/src/doomdata.h diff --git a/libraries/doom/doomdef.c b/libraries/doom/src/doomdef.c similarity index 100% rename from libraries/doom/doomdef.c rename to libraries/doom/src/doomdef.c diff --git a/libraries/doom/doomdef.h b/libraries/doom/src/doomdef.h similarity index 100% rename from libraries/doom/doomdef.h rename to libraries/doom/src/doomdef.h diff --git a/libraries/doom/doomfeatures.h b/libraries/doom/src/doomfeatures.h similarity index 100% rename from libraries/doom/doomfeatures.h rename to libraries/doom/src/doomfeatures.h diff --git a/libraries/doom/doomgeneric.c b/libraries/doom/src/doomgeneric.c similarity index 100% rename from libraries/doom/doomgeneric.c rename to libraries/doom/src/doomgeneric.c diff --git a/libraries/doom/doomgeneric.h b/libraries/doom/src/doomgeneric.h similarity index 100% rename from libraries/doom/doomgeneric.h rename to libraries/doom/src/doomgeneric.h diff --git a/libraries/doom/doomgeneric_arduino.cpp b/libraries/doom/src/doomgeneric_arduino.cpp similarity index 100% rename from libraries/doom/doomgeneric_arduino.cpp rename to libraries/doom/src/doomgeneric_arduino.cpp diff --git a/libraries/doom/doomkeys.h b/libraries/doom/src/doomkeys.h similarity index 100% rename from libraries/doom/doomkeys.h rename to libraries/doom/src/doomkeys.h diff --git a/libraries/doom/doomstat.c b/libraries/doom/src/doomstat.c similarity index 100% rename from libraries/doom/doomstat.c rename to libraries/doom/src/doomstat.c diff --git a/libraries/doom/doomstat.h b/libraries/doom/src/doomstat.h similarity index 100% rename from libraries/doom/doomstat.h rename to libraries/doom/src/doomstat.h diff --git a/libraries/doom/doomtype.h b/libraries/doom/src/doomtype.h similarity index 100% rename from libraries/doom/doomtype.h rename to libraries/doom/src/doomtype.h diff --git a/libraries/doom/dstrings.c b/libraries/doom/src/dstrings.c similarity index 100% rename from libraries/doom/dstrings.c rename to libraries/doom/src/dstrings.c diff --git a/libraries/doom/dstrings.h b/libraries/doom/src/dstrings.h similarity index 100% rename from libraries/doom/dstrings.h rename to libraries/doom/src/dstrings.h diff --git a/libraries/doom/dummy.c b/libraries/doom/src/dummy.c similarity index 100% rename from libraries/doom/dummy.c rename to libraries/doom/src/dummy.c diff --git a/libraries/doom/f_finale.c b/libraries/doom/src/f_finale.c similarity index 100% rename from libraries/doom/f_finale.c rename to libraries/doom/src/f_finale.c diff --git a/libraries/doom/f_finale.h b/libraries/doom/src/f_finale.h similarity index 100% rename from libraries/doom/f_finale.h rename to libraries/doom/src/f_finale.h diff --git a/libraries/doom/f_wipe.c b/libraries/doom/src/f_wipe.c similarity index 100% rename from libraries/doom/f_wipe.c rename to libraries/doom/src/f_wipe.c diff --git a/libraries/doom/f_wipe.h b/libraries/doom/src/f_wipe.h similarity index 100% rename from libraries/doom/f_wipe.h rename to libraries/doom/src/f_wipe.h diff --git a/libraries/doom/g_game.c b/libraries/doom/src/g_game.c similarity index 100% rename from libraries/doom/g_game.c rename to libraries/doom/src/g_game.c diff --git a/libraries/doom/g_game.h b/libraries/doom/src/g_game.h similarity index 100% rename from libraries/doom/g_game.h rename to libraries/doom/src/g_game.h diff --git a/libraries/doom/gusconf.c b/libraries/doom/src/gusconf.c similarity index 100% rename from libraries/doom/gusconf.c rename to libraries/doom/src/gusconf.c diff --git a/libraries/doom/gusconf.h b/libraries/doom/src/gusconf.h similarity index 100% rename from libraries/doom/gusconf.h rename to libraries/doom/src/gusconf.h diff --git a/libraries/doom/hu_lib.c b/libraries/doom/src/hu_lib.c similarity index 100% rename from libraries/doom/hu_lib.c rename to libraries/doom/src/hu_lib.c diff --git a/libraries/doom/hu_lib.h b/libraries/doom/src/hu_lib.h similarity index 100% rename from libraries/doom/hu_lib.h rename to libraries/doom/src/hu_lib.h diff --git a/libraries/doom/hu_stuff.c b/libraries/doom/src/hu_stuff.c similarity index 100% rename from libraries/doom/hu_stuff.c rename to libraries/doom/src/hu_stuff.c diff --git a/libraries/doom/hu_stuff.h b/libraries/doom/src/hu_stuff.h similarity index 100% rename from libraries/doom/hu_stuff.h rename to libraries/doom/src/hu_stuff.h diff --git a/libraries/doom/i_cdmus.c b/libraries/doom/src/i_cdmus.c similarity index 100% rename from libraries/doom/i_cdmus.c rename to libraries/doom/src/i_cdmus.c diff --git a/libraries/doom/i_cdmus.h b/libraries/doom/src/i_cdmus.h similarity index 100% rename from libraries/doom/i_cdmus.h rename to libraries/doom/src/i_cdmus.h diff --git a/libraries/doom/i_endoom.c b/libraries/doom/src/i_endoom.c similarity index 100% rename from libraries/doom/i_endoom.c rename to libraries/doom/src/i_endoom.c diff --git a/libraries/doom/i_endoom.h b/libraries/doom/src/i_endoom.h similarity index 100% rename from libraries/doom/i_endoom.h rename to libraries/doom/src/i_endoom.h diff --git a/libraries/doom/i_input.c b/libraries/doom/src/i_input.c similarity index 100% rename from libraries/doom/i_input.c rename to libraries/doom/src/i_input.c diff --git a/libraries/doom/i_joystick.c b/libraries/doom/src/i_joystick.c similarity index 100% rename from libraries/doom/i_joystick.c rename to libraries/doom/src/i_joystick.c diff --git a/libraries/doom/i_joystick.h b/libraries/doom/src/i_joystick.h similarity index 100% rename from libraries/doom/i_joystick.h rename to libraries/doom/src/i_joystick.h diff --git a/libraries/doom/i_main.c b/libraries/doom/src/i_main.c similarity index 100% rename from libraries/doom/i_main.c rename to libraries/doom/src/i_main.c diff --git a/libraries/doom/i_scale.c b/libraries/doom/src/i_scale.c similarity index 100% rename from libraries/doom/i_scale.c rename to libraries/doom/src/i_scale.c diff --git a/libraries/doom/i_scale.h b/libraries/doom/src/i_scale.h similarity index 100% rename from libraries/doom/i_scale.h rename to libraries/doom/src/i_scale.h diff --git a/libraries/doom/i_sound.c b/libraries/doom/src/i_sound.c similarity index 100% rename from libraries/doom/i_sound.c rename to libraries/doom/src/i_sound.c diff --git a/libraries/doom/i_sound.h b/libraries/doom/src/i_sound.h similarity index 100% rename from libraries/doom/i_sound.h rename to libraries/doom/src/i_sound.h diff --git a/libraries/doom/i_swap.h b/libraries/doom/src/i_swap.h similarity index 100% rename from libraries/doom/i_swap.h rename to libraries/doom/src/i_swap.h diff --git a/libraries/doom/i_system.c b/libraries/doom/src/i_system.c similarity index 100% rename from libraries/doom/i_system.c rename to libraries/doom/src/i_system.c diff --git a/libraries/doom/i_system.h b/libraries/doom/src/i_system.h similarity index 100% rename from libraries/doom/i_system.h rename to libraries/doom/src/i_system.h diff --git a/libraries/doom/i_timer.c b/libraries/doom/src/i_timer.c similarity index 100% rename from libraries/doom/i_timer.c rename to libraries/doom/src/i_timer.c diff --git a/libraries/doom/i_timer.h b/libraries/doom/src/i_timer.h similarity index 100% rename from libraries/doom/i_timer.h rename to libraries/doom/src/i_timer.h diff --git a/libraries/doom/i_video.c b/libraries/doom/src/i_video.c similarity index 100% rename from libraries/doom/i_video.c rename to libraries/doom/src/i_video.c diff --git a/libraries/doom/i_video.h b/libraries/doom/src/i_video.h similarity index 100% rename from libraries/doom/i_video.h rename to libraries/doom/src/i_video.h diff --git a/libraries/doom/icon.c b/libraries/doom/src/icon.c similarity index 100% rename from libraries/doom/icon.c rename to libraries/doom/src/icon.c diff --git a/libraries/doom/info.c b/libraries/doom/src/info.c similarity index 100% rename from libraries/doom/info.c rename to libraries/doom/src/info.c diff --git a/libraries/doom/info.h b/libraries/doom/src/info.h similarity index 100% rename from libraries/doom/info.h rename to libraries/doom/src/info.h diff --git a/libraries/doom/m_argv.c b/libraries/doom/src/m_argv.c similarity index 100% rename from libraries/doom/m_argv.c rename to libraries/doom/src/m_argv.c diff --git a/libraries/doom/m_argv.h b/libraries/doom/src/m_argv.h similarity index 100% rename from libraries/doom/m_argv.h rename to libraries/doom/src/m_argv.h diff --git a/libraries/doom/m_bbox.c b/libraries/doom/src/m_bbox.c similarity index 100% rename from libraries/doom/m_bbox.c rename to libraries/doom/src/m_bbox.c diff --git a/libraries/doom/m_bbox.h b/libraries/doom/src/m_bbox.h similarity index 100% rename from libraries/doom/m_bbox.h rename to libraries/doom/src/m_bbox.h diff --git a/libraries/doom/m_cheat.c b/libraries/doom/src/m_cheat.c similarity index 100% rename from libraries/doom/m_cheat.c rename to libraries/doom/src/m_cheat.c diff --git a/libraries/doom/m_cheat.h b/libraries/doom/src/m_cheat.h similarity index 100% rename from libraries/doom/m_cheat.h rename to libraries/doom/src/m_cheat.h diff --git a/libraries/doom/m_config.c b/libraries/doom/src/m_config.c similarity index 100% rename from libraries/doom/m_config.c rename to libraries/doom/src/m_config.c diff --git a/libraries/doom/m_config.h b/libraries/doom/src/m_config.h similarity index 100% rename from libraries/doom/m_config.h rename to libraries/doom/src/m_config.h diff --git a/libraries/doom/m_controls.c b/libraries/doom/src/m_controls.c similarity index 100% rename from libraries/doom/m_controls.c rename to libraries/doom/src/m_controls.c diff --git a/libraries/doom/m_controls.h b/libraries/doom/src/m_controls.h similarity index 100% rename from libraries/doom/m_controls.h rename to libraries/doom/src/m_controls.h diff --git a/libraries/doom/m_fixed.c b/libraries/doom/src/m_fixed.c similarity index 100% rename from libraries/doom/m_fixed.c rename to libraries/doom/src/m_fixed.c diff --git a/libraries/doom/m_fixed.h b/libraries/doom/src/m_fixed.h similarity index 100% rename from libraries/doom/m_fixed.h rename to libraries/doom/src/m_fixed.h diff --git a/libraries/doom/m_menu.c b/libraries/doom/src/m_menu.c similarity index 100% rename from libraries/doom/m_menu.c rename to libraries/doom/src/m_menu.c diff --git a/libraries/doom/m_menu.h b/libraries/doom/src/m_menu.h similarity index 100% rename from libraries/doom/m_menu.h rename to libraries/doom/src/m_menu.h diff --git a/libraries/doom/m_misc.c b/libraries/doom/src/m_misc.c similarity index 100% rename from libraries/doom/m_misc.c rename to libraries/doom/src/m_misc.c diff --git a/libraries/doom/m_misc.h b/libraries/doom/src/m_misc.h similarity index 100% rename from libraries/doom/m_misc.h rename to libraries/doom/src/m_misc.h diff --git a/libraries/doom/m_random.c b/libraries/doom/src/m_random.c similarity index 100% rename from libraries/doom/m_random.c rename to libraries/doom/src/m_random.c diff --git a/libraries/doom/m_random.h b/libraries/doom/src/m_random.h similarity index 100% rename from libraries/doom/m_random.h rename to libraries/doom/src/m_random.h diff --git a/libraries/doom/memio.c b/libraries/doom/src/memio.c similarity index 100% rename from libraries/doom/memio.c rename to libraries/doom/src/memio.c diff --git a/libraries/doom/memio.h b/libraries/doom/src/memio.h similarity index 100% rename from libraries/doom/memio.h rename to libraries/doom/src/memio.h diff --git a/libraries/doom/net_client.h b/libraries/doom/src/net_client.h similarity index 100% rename from libraries/doom/net_client.h rename to libraries/doom/src/net_client.h diff --git a/libraries/doom/net_dedicated.h b/libraries/doom/src/net_dedicated.h similarity index 100% rename from libraries/doom/net_dedicated.h rename to libraries/doom/src/net_dedicated.h diff --git a/libraries/doom/net_defs.h b/libraries/doom/src/net_defs.h similarity index 100% rename from libraries/doom/net_defs.h rename to libraries/doom/src/net_defs.h diff --git a/libraries/doom/net_gui.h b/libraries/doom/src/net_gui.h similarity index 100% rename from libraries/doom/net_gui.h rename to libraries/doom/src/net_gui.h diff --git a/libraries/doom/net_io.h b/libraries/doom/src/net_io.h similarity index 100% rename from libraries/doom/net_io.h rename to libraries/doom/src/net_io.h diff --git a/libraries/doom/net_loop.h b/libraries/doom/src/net_loop.h similarity index 100% rename from libraries/doom/net_loop.h rename to libraries/doom/src/net_loop.h diff --git a/libraries/doom/net_packet.h b/libraries/doom/src/net_packet.h similarity index 100% rename from libraries/doom/net_packet.h rename to libraries/doom/src/net_packet.h diff --git a/libraries/doom/net_query.h b/libraries/doom/src/net_query.h similarity index 100% rename from libraries/doom/net_query.h rename to libraries/doom/src/net_query.h diff --git a/libraries/doom/net_sdl.h b/libraries/doom/src/net_sdl.h similarity index 100% rename from libraries/doom/net_sdl.h rename to libraries/doom/src/net_sdl.h diff --git a/libraries/doom/net_server.h b/libraries/doom/src/net_server.h similarity index 100% rename from libraries/doom/net_server.h rename to libraries/doom/src/net_server.h diff --git a/libraries/doom/p_ceilng.c b/libraries/doom/src/p_ceilng.c similarity index 100% rename from libraries/doom/p_ceilng.c rename to libraries/doom/src/p_ceilng.c diff --git a/libraries/doom/p_doors.c b/libraries/doom/src/p_doors.c similarity index 100% rename from libraries/doom/p_doors.c rename to libraries/doom/src/p_doors.c diff --git a/libraries/doom/p_enemy.c b/libraries/doom/src/p_enemy.c similarity index 100% rename from libraries/doom/p_enemy.c rename to libraries/doom/src/p_enemy.c diff --git a/libraries/doom/p_floor.c b/libraries/doom/src/p_floor.c similarity index 100% rename from libraries/doom/p_floor.c rename to libraries/doom/src/p_floor.c diff --git a/libraries/doom/p_inter.c b/libraries/doom/src/p_inter.c similarity index 100% rename from libraries/doom/p_inter.c rename to libraries/doom/src/p_inter.c diff --git a/libraries/doom/p_inter.h b/libraries/doom/src/p_inter.h similarity index 100% rename from libraries/doom/p_inter.h rename to libraries/doom/src/p_inter.h diff --git a/libraries/doom/p_lights.c b/libraries/doom/src/p_lights.c similarity index 100% rename from libraries/doom/p_lights.c rename to libraries/doom/src/p_lights.c diff --git a/libraries/doom/p_local.h b/libraries/doom/src/p_local.h similarity index 100% rename from libraries/doom/p_local.h rename to libraries/doom/src/p_local.h diff --git a/libraries/doom/p_map.c b/libraries/doom/src/p_map.c similarity index 100% rename from libraries/doom/p_map.c rename to libraries/doom/src/p_map.c diff --git a/libraries/doom/p_maputl.c b/libraries/doom/src/p_maputl.c similarity index 100% rename from libraries/doom/p_maputl.c rename to libraries/doom/src/p_maputl.c diff --git a/libraries/doom/p_mobj.c b/libraries/doom/src/p_mobj.c similarity index 100% rename from libraries/doom/p_mobj.c rename to libraries/doom/src/p_mobj.c diff --git a/libraries/doom/p_mobj.h b/libraries/doom/src/p_mobj.h similarity index 100% rename from libraries/doom/p_mobj.h rename to libraries/doom/src/p_mobj.h diff --git a/libraries/doom/p_plats.c b/libraries/doom/src/p_plats.c similarity index 100% rename from libraries/doom/p_plats.c rename to libraries/doom/src/p_plats.c diff --git a/libraries/doom/p_pspr.c b/libraries/doom/src/p_pspr.c similarity index 100% rename from libraries/doom/p_pspr.c rename to libraries/doom/src/p_pspr.c diff --git a/libraries/doom/p_pspr.h b/libraries/doom/src/p_pspr.h similarity index 100% rename from libraries/doom/p_pspr.h rename to libraries/doom/src/p_pspr.h diff --git a/libraries/doom/p_saveg.c b/libraries/doom/src/p_saveg.c similarity index 100% rename from libraries/doom/p_saveg.c rename to libraries/doom/src/p_saveg.c diff --git a/libraries/doom/p_saveg.h b/libraries/doom/src/p_saveg.h similarity index 100% rename from libraries/doom/p_saveg.h rename to libraries/doom/src/p_saveg.h diff --git a/libraries/doom/p_setup.c b/libraries/doom/src/p_setup.c similarity index 100% rename from libraries/doom/p_setup.c rename to libraries/doom/src/p_setup.c diff --git a/libraries/doom/p_setup.h b/libraries/doom/src/p_setup.h similarity index 100% rename from libraries/doom/p_setup.h rename to libraries/doom/src/p_setup.h diff --git a/libraries/doom/p_sight.c b/libraries/doom/src/p_sight.c similarity index 100% rename from libraries/doom/p_sight.c rename to libraries/doom/src/p_sight.c diff --git a/libraries/doom/p_spec.c b/libraries/doom/src/p_spec.c similarity index 100% rename from libraries/doom/p_spec.c rename to libraries/doom/src/p_spec.c diff --git a/libraries/doom/p_spec.h b/libraries/doom/src/p_spec.h similarity index 100% rename from libraries/doom/p_spec.h rename to libraries/doom/src/p_spec.h diff --git a/libraries/doom/p_switch.c b/libraries/doom/src/p_switch.c similarity index 100% rename from libraries/doom/p_switch.c rename to libraries/doom/src/p_switch.c diff --git a/libraries/doom/p_telept.c b/libraries/doom/src/p_telept.c similarity index 100% rename from libraries/doom/p_telept.c rename to libraries/doom/src/p_telept.c diff --git a/libraries/doom/p_tick.c b/libraries/doom/src/p_tick.c similarity index 100% rename from libraries/doom/p_tick.c rename to libraries/doom/src/p_tick.c diff --git a/libraries/doom/p_tick.h b/libraries/doom/src/p_tick.h similarity index 100% rename from libraries/doom/p_tick.h rename to libraries/doom/src/p_tick.h diff --git a/libraries/doom/p_user.c b/libraries/doom/src/p_user.c similarity index 100% rename from libraries/doom/p_user.c rename to libraries/doom/src/p_user.c diff --git a/libraries/doom/r_bsp.c b/libraries/doom/src/r_bsp.c similarity index 100% rename from libraries/doom/r_bsp.c rename to libraries/doom/src/r_bsp.c diff --git a/libraries/doom/r_bsp.h b/libraries/doom/src/r_bsp.h similarity index 100% rename from libraries/doom/r_bsp.h rename to libraries/doom/src/r_bsp.h diff --git a/libraries/doom/r_data.c b/libraries/doom/src/r_data.c similarity index 100% rename from libraries/doom/r_data.c rename to libraries/doom/src/r_data.c diff --git a/libraries/doom/r_data.h b/libraries/doom/src/r_data.h similarity index 100% rename from libraries/doom/r_data.h rename to libraries/doom/src/r_data.h diff --git a/libraries/doom/r_defs.h b/libraries/doom/src/r_defs.h similarity index 100% rename from libraries/doom/r_defs.h rename to libraries/doom/src/r_defs.h diff --git a/libraries/doom/r_draw.c b/libraries/doom/src/r_draw.c similarity index 100% rename from libraries/doom/r_draw.c rename to libraries/doom/src/r_draw.c diff --git a/libraries/doom/r_draw.h b/libraries/doom/src/r_draw.h similarity index 100% rename from libraries/doom/r_draw.h rename to libraries/doom/src/r_draw.h diff --git a/libraries/doom/r_local.h b/libraries/doom/src/r_local.h similarity index 100% rename from libraries/doom/r_local.h rename to libraries/doom/src/r_local.h diff --git a/libraries/doom/r_main.c b/libraries/doom/src/r_main.c similarity index 100% rename from libraries/doom/r_main.c rename to libraries/doom/src/r_main.c diff --git a/libraries/doom/r_main.h b/libraries/doom/src/r_main.h similarity index 100% rename from libraries/doom/r_main.h rename to libraries/doom/src/r_main.h diff --git a/libraries/doom/r_plane.c b/libraries/doom/src/r_plane.c similarity index 100% rename from libraries/doom/r_plane.c rename to libraries/doom/src/r_plane.c diff --git a/libraries/doom/r_plane.h b/libraries/doom/src/r_plane.h similarity index 100% rename from libraries/doom/r_plane.h rename to libraries/doom/src/r_plane.h diff --git a/libraries/doom/r_segs.c b/libraries/doom/src/r_segs.c similarity index 100% rename from libraries/doom/r_segs.c rename to libraries/doom/src/r_segs.c diff --git a/libraries/doom/r_segs.h b/libraries/doom/src/r_segs.h similarity index 100% rename from libraries/doom/r_segs.h rename to libraries/doom/src/r_segs.h diff --git a/libraries/doom/r_sky.c b/libraries/doom/src/r_sky.c similarity index 100% rename from libraries/doom/r_sky.c rename to libraries/doom/src/r_sky.c diff --git a/libraries/doom/r_sky.h b/libraries/doom/src/r_sky.h similarity index 100% rename from libraries/doom/r_sky.h rename to libraries/doom/src/r_sky.h diff --git a/libraries/doom/r_state.h b/libraries/doom/src/r_state.h similarity index 100% rename from libraries/doom/r_state.h rename to libraries/doom/src/r_state.h diff --git a/libraries/doom/r_things.c b/libraries/doom/src/r_things.c similarity index 100% rename from libraries/doom/r_things.c rename to libraries/doom/src/r_things.c diff --git a/libraries/doom/r_things.h b/libraries/doom/src/r_things.h similarity index 100% rename from libraries/doom/r_things.h rename to libraries/doom/src/r_things.h diff --git a/libraries/doom/s_sound.c b/libraries/doom/src/s_sound.c similarity index 100% rename from libraries/doom/s_sound.c rename to libraries/doom/src/s_sound.c diff --git a/libraries/doom/s_sound.h b/libraries/doom/src/s_sound.h similarity index 100% rename from libraries/doom/s_sound.h rename to libraries/doom/src/s_sound.h diff --git a/libraries/doom/sha1.c b/libraries/doom/src/sha1.c similarity index 100% rename from libraries/doom/sha1.c rename to libraries/doom/src/sha1.c diff --git a/libraries/doom/sha1.h b/libraries/doom/src/sha1.h similarity index 100% rename from libraries/doom/sha1.h rename to libraries/doom/src/sha1.h diff --git a/libraries/doom/sounds.c b/libraries/doom/src/sounds.c similarity index 100% rename from libraries/doom/sounds.c rename to libraries/doom/src/sounds.c diff --git a/libraries/doom/sounds.h b/libraries/doom/src/sounds.h similarity index 100% rename from libraries/doom/sounds.h rename to libraries/doom/src/sounds.h diff --git a/libraries/doom/st_lib.c b/libraries/doom/src/st_lib.c similarity index 100% rename from libraries/doom/st_lib.c rename to libraries/doom/src/st_lib.c diff --git a/libraries/doom/st_lib.h b/libraries/doom/src/st_lib.h similarity index 100% rename from libraries/doom/st_lib.h rename to libraries/doom/src/st_lib.h diff --git a/libraries/doom/st_stuff.c b/libraries/doom/src/st_stuff.c similarity index 100% rename from libraries/doom/st_stuff.c rename to libraries/doom/src/st_stuff.c diff --git a/libraries/doom/st_stuff.h b/libraries/doom/src/st_stuff.h similarity index 100% rename from libraries/doom/st_stuff.h rename to libraries/doom/src/st_stuff.h diff --git a/libraries/doom/statdump.c b/libraries/doom/src/statdump.c similarity index 100% rename from libraries/doom/statdump.c rename to libraries/doom/src/statdump.c diff --git a/libraries/doom/statdump.h b/libraries/doom/src/statdump.h similarity index 100% rename from libraries/doom/statdump.h rename to libraries/doom/src/statdump.h diff --git a/libraries/doom/tables.c b/libraries/doom/src/tables.c similarity index 100% rename from libraries/doom/tables.c rename to libraries/doom/src/tables.c diff --git a/libraries/doom/tables.h b/libraries/doom/src/tables.h similarity index 100% rename from libraries/doom/tables.h rename to libraries/doom/src/tables.h diff --git a/libraries/doom/v_patch.h b/libraries/doom/src/v_patch.h similarity index 100% rename from libraries/doom/v_patch.h rename to libraries/doom/src/v_patch.h diff --git a/libraries/doom/v_video.c b/libraries/doom/src/v_video.c similarity index 100% rename from libraries/doom/v_video.c rename to libraries/doom/src/v_video.c diff --git a/libraries/doom/v_video.h b/libraries/doom/src/v_video.h similarity index 100% rename from libraries/doom/v_video.h rename to libraries/doom/src/v_video.h diff --git a/libraries/doom/w_checksum.c b/libraries/doom/src/w_checksum.c similarity index 100% rename from libraries/doom/w_checksum.c rename to libraries/doom/src/w_checksum.c diff --git a/libraries/doom/w_checksum.h b/libraries/doom/src/w_checksum.h similarity index 100% rename from libraries/doom/w_checksum.h rename to libraries/doom/src/w_checksum.h diff --git a/libraries/doom/w_file.c b/libraries/doom/src/w_file.c similarity index 100% rename from libraries/doom/w_file.c rename to libraries/doom/src/w_file.c diff --git a/libraries/doom/w_file.h b/libraries/doom/src/w_file.h similarity index 100% rename from libraries/doom/w_file.h rename to libraries/doom/src/w_file.h diff --git a/libraries/doom/w_file_stdc.c b/libraries/doom/src/w_file_stdc.c similarity index 100% rename from libraries/doom/w_file_stdc.c rename to libraries/doom/src/w_file_stdc.c diff --git a/libraries/doom/w_main.c b/libraries/doom/src/w_main.c similarity index 100% rename from libraries/doom/w_main.c rename to libraries/doom/src/w_main.c diff --git a/libraries/doom/w_main.h b/libraries/doom/src/w_main.h similarity index 100% rename from libraries/doom/w_main.h rename to libraries/doom/src/w_main.h diff --git a/libraries/doom/w_merge.h b/libraries/doom/src/w_merge.h similarity index 100% rename from libraries/doom/w_merge.h rename to libraries/doom/src/w_merge.h diff --git a/libraries/doom/w_wad.c b/libraries/doom/src/w_wad.c similarity index 100% rename from libraries/doom/w_wad.c rename to libraries/doom/src/w_wad.c diff --git a/libraries/doom/w_wad.h b/libraries/doom/src/w_wad.h similarity index 100% rename from libraries/doom/w_wad.h rename to libraries/doom/src/w_wad.h diff --git a/libraries/doom/wi_stuff.c b/libraries/doom/src/wi_stuff.c similarity index 100% rename from libraries/doom/wi_stuff.c rename to libraries/doom/src/wi_stuff.c diff --git a/libraries/doom/wi_stuff.h b/libraries/doom/src/wi_stuff.h similarity index 100% rename from libraries/doom/wi_stuff.h rename to libraries/doom/src/wi_stuff.h diff --git a/libraries/doom/z_zone.c b/libraries/doom/src/z_zone.c similarity index 100% rename from libraries/doom/z_zone.c rename to libraries/doom/src/z_zone.c diff --git a/libraries/doom/z_zone.h b/libraries/doom/src/z_zone.h similarity index 100% rename from libraries/doom/z_zone.h rename to libraries/doom/src/z_zone.h diff --git a/libraries/doom/utils/DOOM1.WAD b/libraries/doom/utils/DOOM1.WAD deleted file mode 100644 index 1a58f6627..000000000 Binary files a/libraries/doom/utils/DOOM1.WAD and /dev/null differ diff --git a/libraries/doom/utils/doom.fat b/libraries/doom/utils/doom.fat deleted file mode 100644 index 6706da0be..000000000 Binary files a/libraries/doom/utils/doom.fat and /dev/null differ diff --git a/libraries/doom/utils/doom.fat.dump b/libraries/doom/utils/doom.fat.dump deleted file mode 100644 index d5cabe30e..000000000 Binary files a/libraries/doom/utils/doom.fat.dump and /dev/null differ diff --git a/libraries/doom/utils/doom.littlefs b/libraries/doom/utils/doom.littlefs deleted file mode 100644 index 43a67e580..000000000 Binary files a/libraries/doom/utils/doom.littlefs and /dev/null differ