├── App.config ├── App.xaml ├── App.xaml.cs ├── Application_icon.ico ├── AssemblyInfo.cs ├── BitmapDataSource.cs ├── BitmapPreviewDestination.cs ├── Channel.cs ├── CodeExport.cs ├── ColorComponentChannel.cs ├── Compressor.cs ├── DataSource.cs ├── Decompression ├── Decompression.cpp ├── Decompression.h ├── Mods │ ├── Fast+pixel_support │ │ ├── AVR_ESP │ │ │ ├── Decompression.cpp │ │ │ └── Decompression.h │ │ ├── README.md │ │ └── STM │ │ │ ├── decompression.c │ │ │ └── decompression.h │ ├── Fast │ │ ├── Decompression.cpp │ │ ├── Decompression.h │ │ └── README.md │ └── Tyny+pixel_support │ │ ├── Decompression.cpp │ │ ├── Decompression.h │ │ └── README.md └── README.md ├── DeltaComp.csproj ├── DeltaComp.csproj.user ├── DeltaComp.sln ├── Examples ├── AVR │ ├── ATtiny85 │ │ ├── ASCII.h │ │ ├── ASCII_Girl.txt │ │ ├── ATtiny85.ino │ │ ├── Decompression.cpp │ │ └── Decompression.h │ └── Arduino_boards │ │ ├── Mega2560_ILI9486 │ │ ├── Decompression.cpp │ │ ├── Decompression.h │ │ ├── Mega2560_ILI9486.ino │ │ └── Slides.h │ │ ├── Mega2560_ILI9486_Fast │ │ ├── Decompression.cpp │ │ ├── Decompression.h │ │ ├── Mega2560_ILI9486_Fast.ino │ │ └── Slides.h │ │ ├── Nano_ST7789 │ │ ├── Decompression.cpp │ │ ├── Decompression.h │ │ ├── Icons.h │ │ ├── Nano_ST7789.ino │ │ ├── ST7789.cpp │ │ └── ST7789.h │ │ └── Nano_ST7789_Tiny │ │ ├── Decompression.cpp │ │ ├── Decompression.h │ │ ├── Icons.h │ │ ├── Nano_ST7789_Tiny.ino │ │ ├── ST7789.cpp │ │ └── ST7789.h ├── ESP32 │ └── Wroom_ST7789 │ │ ├── Decompression.cpp │ │ ├── Decompression.h │ │ ├── Icons.h │ │ ├── Logo.h │ │ ├── ST7789.cpp │ │ ├── ST7789.h │ │ └── Wroom_ST7789.ino └── STM32 │ ├── F070CB_ST7789_DMA │ ├── .cproject │ ├── .mxproject │ ├── .project │ ├── Core │ │ ├── Inc │ │ │ ├── decompression.h │ │ │ ├── icons.h │ │ │ ├── logo.h │ │ │ ├── main.h │ │ │ ├── stm32f0xx_hal_conf.h │ │ │ └── stm32f0xx_it.h │ │ ├── Src │ │ │ ├── decompression.c │ │ │ ├── main.c │ │ │ ├── stm32f0xx_hal_msp.c │ │ │ ├── stm32f0xx_it.c │ │ │ ├── syscalls.c │ │ │ ├── sysmem.c │ │ │ └── system_stm32f0xx.c │ │ └── Startup │ │ │ └── startup_stm32f070cbtx.s │ ├── Drivers │ │ ├── CMSIS │ │ │ ├── Device │ │ │ │ └── ST │ │ │ │ │ └── STM32F0xx │ │ │ │ │ ├── Include │ │ │ │ │ ├── stm32f070xb.h │ │ │ │ │ ├── stm32f0xx.h │ │ │ │ │ └── system_stm32f0xx.h │ │ │ │ │ └── LICENSE.txt │ │ │ ├── Include │ │ │ │ ├── cmsis_armcc.h │ │ │ │ ├── cmsis_armclang.h │ │ │ │ ├── cmsis_compiler.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── cmsis_iccarm.h │ │ │ │ ├── cmsis_version.h │ │ │ │ ├── core_armv8mbl.h │ │ │ │ ├── core_armv8mml.h │ │ │ │ ├── core_cm0.h │ │ │ │ ├── core_cm0plus.h │ │ │ │ ├── core_cm1.h │ │ │ │ ├── core_cm23.h │ │ │ │ ├── core_cm3.h │ │ │ │ ├── core_cm33.h │ │ │ │ ├── core_cm4.h │ │ │ │ ├── core_cm7.h │ │ │ │ ├── core_sc000.h │ │ │ │ ├── core_sc300.h │ │ │ │ ├── mpu_armv7.h │ │ │ │ ├── mpu_armv8.h │ │ │ │ └── tz_context.h │ │ │ └── LICENSE.txt │ │ ├── ST7789 │ │ │ ├── ST7789.c │ │ │ └── ST7789.h │ │ └── STM32F0xx_HAL_Driver │ │ │ ├── Inc │ │ │ ├── Legacy │ │ │ │ └── stm32_hal_legacy.h │ │ │ ├── stm32f0xx_hal.h │ │ │ ├── stm32f0xx_hal_cortex.h │ │ │ ├── stm32f0xx_hal_def.h │ │ │ ├── stm32f0xx_hal_dma.h │ │ │ ├── stm32f0xx_hal_dma_ex.h │ │ │ ├── stm32f0xx_hal_exti.h │ │ │ ├── stm32f0xx_hal_flash.h │ │ │ ├── stm32f0xx_hal_flash_ex.h │ │ │ ├── stm32f0xx_hal_gpio.h │ │ │ ├── stm32f0xx_hal_gpio_ex.h │ │ │ ├── stm32f0xx_hal_i2c.h │ │ │ ├── stm32f0xx_hal_i2c_ex.h │ │ │ ├── stm32f0xx_hal_pwr.h │ │ │ ├── stm32f0xx_hal_pwr_ex.h │ │ │ ├── stm32f0xx_hal_rcc.h │ │ │ ├── stm32f0xx_hal_rcc_ex.h │ │ │ ├── stm32f0xx_hal_spi.h │ │ │ ├── stm32f0xx_hal_spi_ex.h │ │ │ ├── stm32f0xx_hal_tim.h │ │ │ ├── stm32f0xx_hal_tim_ex.h │ │ │ ├── stm32f0xx_ll_bus.h │ │ │ ├── stm32f0xx_ll_cortex.h │ │ │ ├── stm32f0xx_ll_crs.h │ │ │ ├── stm32f0xx_ll_dma.h │ │ │ ├── stm32f0xx_ll_exti.h │ │ │ ├── stm32f0xx_ll_gpio.h │ │ │ ├── stm32f0xx_ll_pwr.h │ │ │ ├── stm32f0xx_ll_rcc.h │ │ │ ├── stm32f0xx_ll_spi.h │ │ │ ├── stm32f0xx_ll_system.h │ │ │ └── stm32f0xx_ll_utils.h │ │ │ ├── LICENSE.txt │ │ │ └── Src │ │ │ ├── stm32f0xx_hal.c │ │ │ ├── stm32f0xx_hal_cortex.c │ │ │ ├── stm32f0xx_hal_dma.c │ │ │ ├── stm32f0xx_hal_exti.c │ │ │ ├── stm32f0xx_hal_flash.c │ │ │ ├── stm32f0xx_hal_flash_ex.c │ │ │ ├── stm32f0xx_hal_gpio.c │ │ │ ├── stm32f0xx_hal_i2c.c │ │ │ ├── stm32f0xx_hal_i2c_ex.c │ │ │ ├── stm32f0xx_hal_pwr.c │ │ │ ├── stm32f0xx_hal_pwr_ex.c │ │ │ ├── stm32f0xx_hal_rcc.c │ │ │ ├── stm32f0xx_hal_rcc_ex.c │ │ │ ├── stm32f0xx_hal_spi.c │ │ │ ├── stm32f0xx_hal_spi_ex.c │ │ │ ├── stm32f0xx_hal_tim.c │ │ │ └── stm32f0xx_hal_tim_ex.c │ ├── F070CB_ST7789 Debug.launch │ ├── F070CB_ST7789_DMA Debug.launch │ ├── F070CB_ST7789_DMA.ioc │ ├── Release │ │ └── F070CB_ST7789_DMA.elf │ └── STM32F070CBTX_FLASH.ld │ └── F407ZGT6_NT35510_FSMC_DMA │ ├── .cproject │ ├── .mxproject │ ├── .project │ ├── Core │ ├── Inc │ │ ├── decompression.h │ │ ├── main.h │ │ ├── slide1.h │ │ ├── slide2.h │ │ ├── slide3.h │ │ ├── stm32f4xx_hal_conf.h │ │ └── stm32f4xx_it.h │ ├── Src │ │ ├── decompression.c │ │ ├── main.c │ │ ├── stm32f4xx_hal_msp.c │ │ ├── stm32f4xx_it.c │ │ ├── syscalls.c │ │ ├── sysmem.c │ │ └── system_stm32f4xx.c │ └── Startup │ │ └── startup_stm32f407zgtx.s │ ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F4xx │ │ │ │ ├── Include │ │ │ │ ├── stm32f407xx.h │ │ │ │ ├── stm32f4xx.h │ │ │ │ └── system_stm32f4xx.h │ │ │ │ └── LICENSE.txt │ │ ├── Include │ │ │ ├── cachel1_armv7.h │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_armclang_ltm.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv81mml.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm35p.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm55.h │ │ │ ├── core_cm7.h │ │ │ ├── core_cm85.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── core_starmc1.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ ├── pac_armv81.h │ │ │ ├── pmu_armv8.h │ │ │ └── tz_context.h │ │ └── LICENSE.txt │ ├── NT35510 │ │ ├── NT35510.c │ │ └── NT35510.h │ └── STM32F4xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f4xx_hal.h │ │ ├── stm32f4xx_hal_cortex.h │ │ ├── stm32f4xx_hal_def.h │ │ ├── stm32f4xx_hal_dma.h │ │ ├── stm32f4xx_hal_dma_ex.h │ │ ├── stm32f4xx_hal_exti.h │ │ ├── stm32f4xx_hal_flash.h │ │ ├── stm32f4xx_hal_flash_ex.h │ │ ├── stm32f4xx_hal_flash_ramfunc.h │ │ ├── stm32f4xx_hal_gpio.h │ │ ├── stm32f4xx_hal_gpio_ex.h │ │ ├── stm32f4xx_hal_pwr.h │ │ ├── stm32f4xx_hal_pwr_ex.h │ │ ├── stm32f4xx_hal_rcc.h │ │ ├── stm32f4xx_hal_rcc_ex.h │ │ ├── stm32f4xx_hal_sram.h │ │ ├── stm32f4xx_hal_tim.h │ │ ├── stm32f4xx_hal_tim_ex.h │ │ ├── stm32f4xx_ll_bus.h │ │ ├── stm32f4xx_ll_cortex.h │ │ ├── stm32f4xx_ll_dma.h │ │ ├── stm32f4xx_ll_exti.h │ │ ├── stm32f4xx_ll_fsmc.h │ │ ├── stm32f4xx_ll_gpio.h │ │ ├── stm32f4xx_ll_pwr.h │ │ ├── stm32f4xx_ll_rcc.h │ │ ├── stm32f4xx_ll_system.h │ │ └── stm32f4xx_ll_utils.h │ │ ├── LICENSE.txt │ │ └── Src │ │ ├── stm32f4xx_hal.c │ │ ├── stm32f4xx_hal_cortex.c │ │ ├── stm32f4xx_hal_dma.c │ │ ├── stm32f4xx_hal_dma_ex.c │ │ ├── stm32f4xx_hal_exti.c │ │ ├── stm32f4xx_hal_flash.c │ │ ├── stm32f4xx_hal_flash_ex.c │ │ ├── stm32f4xx_hal_flash_ramfunc.c │ │ ├── stm32f4xx_hal_gpio.c │ │ ├── stm32f4xx_hal_pwr.c │ │ ├── stm32f4xx_hal_pwr_ex.c │ │ ├── stm32f4xx_hal_rcc.c │ │ ├── stm32f4xx_hal_rcc_ex.c │ │ ├── stm32f4xx_hal_sram.c │ │ ├── stm32f4xx_hal_tim.c │ │ ├── stm32f4xx_hal_tim_ex.c │ │ └── stm32f4xx_ll_fsmc.c │ ├── F407ZGT6_NT35510_FSMC_DMA.ioc │ ├── Release │ └── F407ZGT6_NT35510_FSMC_DMA.elf │ ├── STM32F407ZGTX_FLASH.ld │ └── STM32F407ZGTX_RAM.ld ├── FileDataChannel.cs ├── FileDataSource.cs ├── FilePreviewDestination.cs ├── GrayscaleMixerChannel.cs ├── Header_Source.xml ├── Header_Transformation.xslt ├── LICENSE ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── PreviewDestination.cs ├── README.md ├── README.ru.md └── Release ├── DeltaComp.deps.json ├── DeltaComp.dll ├── DeltaComp.dll.config ├── DeltaComp.exe ├── DeltaComp.pdb ├── DeltaComp.runtimeconfig.json ├── Header_Source.xml └── Header_Transformation.xslt /App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 104857600 12 | 13 | 14 | AVR,STM32,ESP32 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 2 13 | 3 14 | 4 15 | 5 16 | 6 17 | 7 18 | 8 19 | 9 20 | 10 21 | 11 22 | 12 23 | 13 24 | 14 25 | 15 26 | 16 27 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Data; 3 | using System.Drawing; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | using System.Windows.Media; 8 | 9 | namespace DeltaComp 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | 18 | 19 | // Value converter used to change the color of the icon (System.Windows.Shapes.Path) 20 | // in cases when the control is enabled or disabled. 21 | [ValueConversion(typeof(Boolean?), typeof(SolidColorBrush))] 22 | public class EnabledToColorConverter : IValueConverter 23 | { 24 | public EnabledToColorConverter() 25 | { 26 | } 27 | 28 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 29 | { 30 | if (System.Convert.ToBoolean(value)) 31 | { 32 | return new SolidColorBrush(Colors.Black); 33 | } 34 | return new SolidColorBrush(Colors.LightGray); 35 | } 36 | 37 | 38 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 39 | { 40 | return Binding.DoNothing; 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Application_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DmitryMuravyev/Delta-Compression/73aa6cec60975ad5c3fa254d52c63dc84176e8eb/Application_icon.ico -------------------------------------------------------------------------------- /AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /Channel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Text; 31 | using System.Threading.Tasks; 32 | 33 | namespace DeltaComp 34 | { 35 | // Main types of channels (later the list can be completed with audio channels, etc.) 36 | // It is important that the Red, Green and Blue channels go exactly in this sequence starting from 0 37 | // (e.g. see GrayscaleMixerChannel Class implementation). 38 | public enum ChannelType 39 | { 40 | Red = 0, 41 | Green = 1, 42 | Blue = 2, 43 | Alpha = 3, 44 | Grayscale = 4, 45 | Data = 5, 46 | Unknown = 1000 47 | } 48 | 49 | 50 | // Сhannel order in pixel 51 | public enum ChannelOrder 52 | { 53 | ChannelOrderBGRA = 0, 54 | ChannelOrderRGBA = 1 55 | } 56 | 57 | 58 | // An abstract class representing an image/audio/data channel (component). 59 | public abstract class Channel 60 | { 61 | //////////////////////////////////////////////////////////////////////////////////////////////////// 62 | // Public attributes/methods 63 | //////////////////////////////////////////////////////////////////////////////////////////////////// 64 | 65 | // Сhannel indexes in pixel depending on channel order. 66 | // They must match the values declared in ChannelOrder and ChannelType enumerated types. 67 | public static readonly int[][] colorComponentPosition = [ [ 2, 1, 0, 3, 0, 0, 0 ], 68 | [ 0, 1, 2, 3, 0, 0, 0 ] ]; 69 | 70 | // Channel bit depth 71 | public int BitsPerChannel = 0; 72 | 73 | 74 | // Get the maximum number that can be written to a specified number of bits 75 | public static double GetMaxNumberForBitDepth(int bitDepth) 76 | { 77 | int maxNumber = (1 << bitDepth) - 1; 78 | return ((double)maxNumber); 79 | } 80 | 81 | 82 | // Channel type attribute 83 | public ChannelType ChannelType { get; set; } = ChannelType.Unknown; 84 | 85 | 86 | // The name of the channel derived from its type. 87 | public string Name 88 | { 89 | get 90 | { 91 | return (ChannelType.ToString()); 92 | } 93 | } 94 | 95 | 96 | // The list of acceptable bit depth for this channel. 97 | public List? BitDepthList { get; set; } = null; 98 | 99 | 100 | // Target bit depth to which the data format should be reduced. 101 | public int TargetBitDepth { get; set; } = 0; 102 | 103 | 104 | // An abstract method for getting channel value for a given pixel/frame/symbol, etc. 105 | public abstract UInt32 GetOriginalValueForFrame(int frameNumber); 106 | 107 | 108 | // The same, but returns the double result 0.0 - 1.0 109 | public virtual double GetFloatValueForFrame(int frameNumber) 110 | { 111 | return ((double)GetOriginalValueForFrame(frameNumber) / 112 | GetMaxNumberForBitDepth(BitsPerChannel)); 113 | } 114 | 115 | 116 | // The same, but returns scaled to the target bit depth result. 117 | public virtual UInt32 GetTargetValueForFrame(int frameNumber) 118 | { 119 | if (BitsPerChannel == TargetBitDepth) 120 | { 121 | return (GetOriginalValueForFrame(frameNumber)); 122 | } 123 | 124 | return ((UInt32)Math.Round(GetFloatValueForFrame(frameNumber) * 125 | GetMaxNumberForBitDepth(TargetBitDepth))); 126 | } 127 | 128 | 129 | // The same, but returns scaled to any specified bit depth result. 130 | public virtual UInt32 GetCustomScaledValueForFrame(int frameNumber, int bitDepth) 131 | { 132 | if (BitsPerChannel == bitDepth) 133 | { 134 | return (GetOriginalValueForFrame(frameNumber)); 135 | } 136 | 137 | return ((UInt32)Math.Round(GetFloatValueForFrame(frameNumber) * 138 | GetMaxNumberForBitDepth(bitDepth))); 139 | } 140 | 141 | 142 | // Returns the result for previewing the pixel (audio sample or whatever) 143 | // value as it should look at the Target bit depth. 144 | // The result is scaled to any specified bit depth which is selected for the preview image. 145 | public virtual UInt32 GetPreviewValueForFrame(int frameNumber, int bitDepth) 146 | { 147 | if (TargetBitDepth == bitDepth) 148 | { 149 | return (GetTargetValueForFrame(frameNumber)); 150 | } 151 | 152 | double value = ((double)GetTargetValueForFrame(frameNumber) / 153 | GetMaxNumberForBitDepth(TargetBitDepth) * 154 | GetMaxNumberForBitDepth(bitDepth)); 155 | 156 | return ((UInt32)Math.Round(value)); 157 | } 158 | 159 | } 160 | } 161 | 162 | // END-OF-FILE 163 | -------------------------------------------------------------------------------- /ColorComponentChannel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Diagnostics; 30 | using System.Linq; 31 | using System.Text; 32 | using System.Threading.Tasks; 33 | using System.Windows.Media; 34 | using System.Windows.Media.Imaging; 35 | 36 | namespace DeltaComp 37 | { 38 | 39 | // Image component (R/G/B/A/Grayscale channel) class. 40 | public class ColorComponentChannel : Channel 41 | { 42 | //////////////////////////////////////////////////////////////////////////////////////////////////// 43 | // Private attributes/variables 44 | //////////////////////////////////////////////////////////////////////////////////////////////////// 45 | 46 | // Source data 47 | private BitmapDataSource _source; 48 | 49 | // Component index in pixel 50 | private readonly int _channelIndex = 0; 51 | 52 | // Component mask in pixel data 53 | private readonly UInt64 _mask = 0; 54 | 55 | // Component shift in pixel data 56 | private readonly int _shift = 0; 57 | 58 | 59 | //////////////////////////////////////////////////////////////////////////////////////////////////// 60 | // Implementation 61 | //////////////////////////////////////////////////////////////////////////////////////////////////// 62 | 63 | // Constructor 64 | public ColorComponentChannel(BitmapDataSource theSource, ChannelType channelType, ChannelOrder order) 65 | { 66 | Trace.Assert(theSource != null); 67 | 68 | // Init base variables 69 | ChannelType = channelType; 70 | _source = theSource; 71 | _channelIndex = Channel.colorComponentPosition[(int)order][(int)channelType]; 72 | 73 | // Get channel mask list 74 | IList formatMaskCollection = _source.Format.Masks; 75 | PixelFormatChannelMask channelMask = formatMaskCollection[_channelIndex]; 76 | IList maskBytesCollection = channelMask.Mask; 77 | 78 | // Get mask 79 | foreach (byte myByte in maskBytesCollection.Reverse()) 80 | { 81 | _mask <<= 8; 82 | _mask |= myByte; 83 | } 84 | 85 | // Calculate the channel shift inside a pixel 86 | UInt64 mask = _mask; 87 | while ((mask & 1) == 0) 88 | { 89 | _shift++; 90 | mask >>= 1; 91 | } 92 | 93 | // Calculate channel bit depth 94 | while ((mask & 1) != 0) 95 | { 96 | BitsPerChannel++; 97 | mask >>= 1; 98 | } 99 | 100 | // Init UI properties 101 | BitDepthList = Enumerable.Range(1, BitsPerChannel).Select(i => (int)i).ToList(); 102 | TargetBitDepth = BitsPerChannel; 103 | 104 | } 105 | 106 | 107 | // Destructor 108 | /* 109 | ~ComponentChannel() 110 | { 111 | } 112 | */ 113 | 114 | 115 | // Base class method's implementation 116 | public override UInt32 GetOriginalValueForFrame(int frameNumber) 117 | { 118 | return ((UInt32)((_source.GetPixel(frameNumber) & _mask) >> _shift)); 119 | } 120 | 121 | 122 | } 123 | } 124 | 125 | // END-OF-FILE 126 | -------------------------------------------------------------------------------- /DataSource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Text; 31 | using System.Threading.Tasks; 32 | 33 | namespace DeltaComp 34 | { 35 | // An abstract class that serves as a data source for channel subclasses 36 | public abstract class DataSource 37 | { 38 | //////////////////////////////////////////////////////////////////////////////////////////////////// 39 | // Public attributes/methods 40 | //////////////////////////////////////////////////////////////////////////////////////////////////// 41 | 42 | public int BitsPerFrame = 0; 43 | public int ChannelsCount = 0; 44 | 45 | // We will not return an error message while reading data (for the sake of speed), 46 | // so we will save it in a separate variable to obtain it later. 47 | public string? LastErrorMessage = null; 48 | public bool ErrorOccurred = false; 49 | 50 | } 51 | } 52 | 53 | // END-OF-FILE 54 | -------------------------------------------------------------------------------- /Decompression/Mods/Fast+pixel_support/README.md: -------------------------------------------------------------------------------- 1 | High-speed with pixel support: 2 | - focusing on the low-bit-length operations, 3 | - supported image size is up to 255x255px, 4 | - up to 8 bits per data channel, 5 | - up to 16 bits per frame, 6 | - colorizing pixels during decompression (if used), 7 | - direct use of the RGB565 pixel buffer (if needed), 8 | - AVR "far" memory access support*, 9 | - splitting compressed data into memory chunks (up to 32767 bytes)**, 10 | - high performance+. 11 | 12 | Examples: 13 | [Arduino Nano + ST7789 240x240 display](/Examples/AVR/Arduino_boards/Nano_ST7789), 14 | [ESP32 DEVKIT board + ST7789 240x240 display](/Examples/ESP32/Wroom_ST7789), 15 | [STM32F070CB chip + ST7789 240x240 display](/Examples/STM32/F070CB_ST7789_DMA), 16 | [DevEBox board by mcudev + NT35510 800x480 display](/Examples/STM32/F407ZGT6_NT35510_FSMC_DMA). 17 | 18 | 19 | \* Relevant only for the AVR platform. 20 | ** To do this, a pointer to an array of far pointers should be passed to the decompression procedure instead of a direct pointer to a data array: 21 | 22 | ```C 23 | static uint_farptr_t dataChunks[n]; 24 | decompressNextFrames(dc, dataChunks, decompressedData, framesCount); 25 | ``` 26 | -------------------------------------------------------------------------------- /Decompression/Mods/Fast/README.md: -------------------------------------------------------------------------------- 1 | High-speed adaptation: 2 | - focusing on the low-bit-length operations, 3 | - supported image size is up to 255x255px, 4 | - up to 8 bits per data channel, 5 | - up to 16 bits per frame, 6 | - decompression of 1-2-4 bits frames, 7 | - AVR "far" memory access support*, 8 | - splitting compressed data into memory chunks (up to 32767 bytes)**, 9 | - high performance. 10 | 11 | Example: [ATMega2560 + ILI9486 480x320 display](/Examples/AVR/Arduino_boards/Mega2560_ILI9486_Fast). 12 | 13 | 14 | \* Relevant only for the AVR platform. 15 | ** To do this, a pointer to an array of far pointers should be passed to the decompression procedure instead of a direct pointer to a data array: 16 | 17 | ```C 18 | static uint_farptr_t dataChunks[n]; 19 | decompressNextFrames(dc, dataChunks, decompressedData, framesCount); 20 | ``` 21 | -------------------------------------------------------------------------------- /Decompression/Mods/Tyny+pixel_support/README.md: -------------------------------------------------------------------------------- 1 | Tiny adaptation: 2 | - focusing on the 8-bit operations, 3 | - supported image size is up to 255x255px, 4 | - up to 8 bits per data channel, 5 | - up to 8 bits per frame supported, 6 | - colorizing pixels during decompression (if used), 7 | - direct use of the RGB565 pixel buffer (if needed), 8 | - high performance++. 9 | 10 | Examples: 11 | [Arduino Nano + ST7789 240x240 display](/Examples/AVR/Arduino_boards/Nano_ST7789_Tiny), 12 | [ATtiny85 chip + SPI output](/Examples/AVR/ATtiny85). 13 | -------------------------------------------------------------------------------- /Decompression/README.md: -------------------------------------------------------------------------------- 1 | The original class - maximum features: 2 | - supported image size up to 65535 x 65535px, 3 | - up to 32 bits per data channel, 4 | - up to 64 bits per frame (modification is required for a larger frame width), 5 | - decompression per 1 request: up to 2^32 frames (pixels), up to 2^32 compressed/decompressed data size, 6 | - decompression of 1-2-4 bits frames, 7 | - AVR "far" memory access support*, 8 | - splitting compressed data into memory chunks (up to 32767 bytes)**. 9 | 10 | Example: [ATMega2560 + ILI9486 480x320 display](/Examples/AVR/Arduino_boards/Mega2560_ILI9486). 11 | 12 | \* Relevant only for the AVR platform. 13 | ** To do this, a pointer to an array of far pointers should be passed to the decompression procedure instead of a direct pointer to a data array: 14 | 15 | ```C 16 | static uint_farptr_t dataChunks[n]; 17 | decompressNextFrames(dc, dataChunks, decompressedData, framesCount); 18 | ``` 19 | -------------------------------------------------------------------------------- /DeltaComp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net8.0-windows 6 | enable 7 | enable 8 | true 9 | True 10 | Application_icon.ico 11 | Dmitry Muravyev 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Always 22 | 23 | 24 | Always 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /DeltaComp.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_LastSelectedProfileId>C:\Work\Programming\repos\DeltArch\DeltaComp\Properties\PublishProfiles\Publish X86.pubxml 5 | 6 | 7 | 8 | Designer 9 | 10 | 11 | 12 | 13 | Designer 14 | 15 | 16 | 17 | 18 | Designer 19 | 20 | 21 | -------------------------------------------------------------------------------- /DeltaComp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.10.35013.160 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeltaComp", "DeltaComp.csproj", "{5D8E756E-2773-4DB5-AC74-D4EF1632CC61}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {5D8E756E-2773-4DB5-AC74-D4EF1632CC61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {5D8E756E-2773-4DB5-AC74-D4EF1632CC61}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {5D8E756E-2773-4DB5-AC74-D4EF1632CC61}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {5D8E756E-2773-4DB5-AC74-D4EF1632CC61}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {C178BFE7-067B-4E0E-A230-764481DDE5BA} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Examples/AVR/ATtiny85/ATtiny85.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // The example outputs an ASCII ART image over the SPI bus. 28 | // It is based on a tiny version of the decompression class, which has 29 | // rather modest but sufficient capabilities and very high performance. 30 | 31 | // To run this example you have to: 32 | // install the ATTinyCore boards library, 33 | // select the ATtiny25/45/86 (No bootloader) board 34 | // and enable the LTO option. 35 | #include "ASCII.h" 36 | #include 37 | 38 | static Decompression decomp; 39 | 40 | void setup() { 41 | // put your setup code here, to run once: 42 | SPI.begin(); 43 | } 44 | 45 | void loop() { 46 | // put your main code here, to run repeatedly: 47 | // Decompress all data at once 48 | decomp.resetDecompression(); 49 | SPI.beginTransaction(SPISettings()); 50 | decomp.decompressNextFrames(&asciiDC, asciiData, NULL, ASCII_NUMBER_OF_FRAMES, false); 51 | SPI.endTransaction(); 52 | delay(10000); 53 | } 54 | 55 | // Frame decompressed delegate (can be used if the image is not divided into squares and the buffer is not used) 56 | void frameDecompressed(uint8_t frame) { 57 | SPI.transfer(frame); 58 | } 59 | 60 | // END-OF-FILE 61 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Mega2560_ILI9486/Mega2560_ILI9486.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // This example demonstrates the use of a memory area beyond 64K 28 | // on the AVR platform. It's a little bit tricky and works slower 29 | // than the "near" memory, but it works nonetheless. 30 | // This example also uses the most complete decompression class, 31 | // whose performance can (and should) be significantly increased by 32 | // further modifications, simplification, and reduction of variables bit length. 33 | // 34 | // ATTENTION!!! To run this example, you need an Arduino Mega2560 board, 35 | // an ILI9486 320x480 TFT color display shield, 36 | // and the UTFT library installed into the Arduino IDE. 37 | 38 | #include 39 | #include "Slides.h" 40 | 41 | #define DISPLAY_WIDTH 320 42 | #define DISPLAY_HEIGHT 480 43 | #define FRAMES_PER_BUFFER SLIDE_IMAGE_WIDTH * SLIDE_SQUARE_SIDE 44 | #define BUFFERS_PER_SLIDE SLIDE_IMAGE_HEIGHT / SLIDE_SQUARE_SIDE 45 | 46 | // Display 47 | UTFT myGLCD(CTE40, 38, 39, 40, 41); 48 | 49 | // Decompression instance 50 | static Decompression decomp; 51 | // And buffer 52 | static uint16_t decompressedData[FRAMES_PER_BUFFER]; 53 | // Far data sddresses 54 | static uint_farptr_t slide1DataChunks[6]; 55 | static uint_farptr_t slide2DataChunks[7]; 56 | // Current slide 57 | static bool currentSlide = true; 58 | 59 | 60 | void setup() { 61 | // put your setup code here, to run once: 62 | myGLCD.InitLCD(PORTRAIT); 63 | // Some strange commands to mirror displayed characters... 64 | // ...we don't need them for the moment. 65 | //myGLCD.LCD_Write_COM(0x36); 66 | //myGLCD.LCD_Write_DATA(0x4A); 67 | decomp.bufferWidth = SLIDE_IMAGE_WIDTH; // Set the width of our buffer for correct decompression 68 | 69 | // We have to save the far addresses of the data chunks 70 | // in order to use them during decompression. 71 | // This can only be done at runtime. 72 | slide1DataChunks[0] = pgm_get_far_address(slide1Data1); 73 | slide1DataChunks[1] = pgm_get_far_address(slide1Data2); 74 | slide1DataChunks[2] = pgm_get_far_address(slide1Data3); 75 | slide1DataChunks[3] = pgm_get_far_address(slide1Data4); 76 | slide1DataChunks[4] = pgm_get_far_address(slide1Data5); 77 | slide1DataChunks[5] = pgm_get_far_address(slide1Data6); 78 | // For both slides 79 | slide2DataChunks[0] = pgm_get_far_address(slide2Data1); 80 | slide2DataChunks[1] = pgm_get_far_address(slide2Data2); 81 | slide2DataChunks[2] = pgm_get_far_address(slide2Data3); 82 | slide2DataChunks[3] = pgm_get_far_address(slide2Data4); 83 | slide2DataChunks[4] = pgm_get_far_address(slide2Data5); 84 | slide2DataChunks[5] = pgm_get_far_address(slide2Data6); 85 | slide2DataChunks[6] = pgm_get_far_address(slide2Data7); 86 | } 87 | 88 | 89 | void loop() { 90 | // put your main code here, to run repeatedly: 91 | 92 | decomp.resetDecompression(); 93 | 94 | cbi(myGLCD.P_CS, myGLCD.B_CS); 95 | myGLCD.setXY(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); 96 | sbi(myGLCD.P_RS, myGLCD.B_RS); 97 | 98 | // Draw single slide 99 | for (uint8_t i = 0; i < BUFFERS_PER_SLIDE; i++) 100 | { 101 | // Decompress one buffer 102 | decomp.decompressNextFrames(&photoDC, currentSlide ? slide1DataChunks : slide2DataChunks, (uint8_t *)decompressedData, FRAMES_PER_BUFFER); 103 | // And display it 104 | for (uint16_t pixel = 0; pixel < FRAMES_PER_BUFFER; pixel++) { 105 | myGLCD.setPixel(__builtin_bswap16(decompressedData[pixel])); 106 | } 107 | } 108 | sbi(myGLCD.P_CS, myGLCD.B_CS); 109 | 110 | // Swap slide 111 | currentSlide = !currentSlide; 112 | // Wait 113 | delay(10000); 114 | } 115 | 116 | // END-OF-FILE 117 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Mega2560_ILI9486_Fast/Mega2560_ILI9486_Fast.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // This example uses a modified decompression class, 28 | // which has higher performance, but fewer features 29 | // (which, nevertheless, are more than enough for our task). 30 | 31 | // ATTENTION!!! To run this example, you need an Arduino Mega2560 board, 32 | // an ILI9486 320x480 TFT color display shield, 33 | // and the UTFT library installed into the Arduino IDE. 34 | 35 | #include 36 | #include "Slides.h" 37 | 38 | #define DISPLAY_WIDTH 320 39 | #define DISPLAY_HEIGHT 480 40 | #define FRAMES_PER_BUFFER SLIDE_IMAGE_WIDTH * SLIDE_SQUARE_SIDE 41 | #define BUFFERS_PER_SLIDE SLIDE_IMAGE_HEIGHT / SLIDE_SQUARE_SIDE 42 | 43 | // Display 44 | UTFT myGLCD(CTE40, 38, 39, 40, 41); 45 | 46 | // Decompression instance 47 | static Decompression decomp; 48 | // And buffer 49 | static uint16_t decompressedData[FRAMES_PER_BUFFER]; 50 | // Far data sddresses 51 | static uint_farptr_t slide1DataChunks[6]; 52 | static uint_farptr_t slide2DataChunks[7]; 53 | // Current slide 54 | static bool currentSlide = true; 55 | 56 | 57 | void setup() { 58 | // put your setup code here, to run once: 59 | myGLCD.InitLCD(PORTRAIT); 60 | // Some strange commands to mirror displayed characters... 61 | // ...we don't need them for the moment. 62 | //myGLCD.LCD_Write_COM(0x36); 63 | //myGLCD.LCD_Write_DATA(0x4A); 64 | decomp.bufferWidth = SLIDE_IMAGE_WIDTH; // Set the width of our buffer for correct decompression 65 | 66 | // We have to save the far addresses of the data chunks 67 | // in order to use them during decompression. 68 | // This can only be done at runtime. 69 | slide1DataChunks[0] = pgm_get_far_address(slide1Data1); 70 | slide1DataChunks[1] = pgm_get_far_address(slide1Data2); 71 | slide1DataChunks[2] = pgm_get_far_address(slide1Data3); 72 | slide1DataChunks[3] = pgm_get_far_address(slide1Data4); 73 | slide1DataChunks[4] = pgm_get_far_address(slide1Data5); 74 | slide1DataChunks[5] = pgm_get_far_address(slide1Data6); 75 | // For both slides 76 | slide2DataChunks[0] = pgm_get_far_address(slide2Data1); 77 | slide2DataChunks[1] = pgm_get_far_address(slide2Data2); 78 | slide2DataChunks[2] = pgm_get_far_address(slide2Data3); 79 | slide2DataChunks[3] = pgm_get_far_address(slide2Data4); 80 | slide2DataChunks[4] = pgm_get_far_address(slide2Data5); 81 | slide2DataChunks[5] = pgm_get_far_address(slide2Data6); 82 | slide2DataChunks[6] = pgm_get_far_address(slide2Data7); 83 | } 84 | 85 | 86 | void loop() { 87 | // put your main code here, to run repeatedly: 88 | 89 | decomp.resetDecompression(); 90 | 91 | cbi(myGLCD.P_CS, myGLCD.B_CS); 92 | myGLCD.setXY(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); 93 | sbi(myGLCD.P_RS, myGLCD.B_RS); 94 | 95 | // Draw single slide 96 | for (uint8_t i = 0; i < BUFFERS_PER_SLIDE; i++) 97 | { 98 | // Decompress one buffer 99 | decomp.decompressNextFrames(&photoDC, currentSlide ? slide1DataChunks : slide2DataChunks, (uint8_t *)decompressedData, FRAMES_PER_BUFFER); 100 | // And display it 101 | for (uint16_t pixel = 0; pixel < FRAMES_PER_BUFFER; pixel++) { 102 | myGLCD.setPixel(__builtin_bswap16(decompressedData[pixel])); 103 | } 104 | } 105 | sbi(myGLCD.P_CS, myGLCD.B_CS); 106 | 107 | // Swap slide 108 | currentSlide = !currentSlide; 109 | // Wait 110 | delay(10000); 111 | } 112 | 113 | // END-OF-FILE 114 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Nano_ST7789/Nano_ST7789.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // The example is based on a modified decompression class that allows 28 | // to colorize pixels right during decompression and put them into a pixel buffer. 29 | // In addition, it uses a minimalistic library which can draw images 30 | // or individual pixels on a display based on the ST7789 controller. 31 | // You don't need any extra libraries for this example to work. 32 | 33 | // ATTENTION!!! To run this example, you need an Arduino Nano board, 34 | // and a 240x240 pixel IPS color display (on the ST7789 controller). 35 | // To configure the connection pins, please refer to ST7789.h. 36 | 37 | #include "ST7789.h" 38 | #include "Icons.h" 39 | 40 | #define FRAMES_PER_BUFFER ICONS_IMAGE_WIDTH * ICONS_SQUARE_SIDE 41 | #define BUFFERS_PER_ICON ICONS_IMAGE_HEIGHT / ICONS_SQUARE_SIDE 42 | 43 | // Icons list 44 | static const uint8_t * icons[25] = { accessData, 45 | bluetoothData, 46 | bugData, 47 | buildData, 48 | cableData, 49 | checkData, 50 | cloudData, 51 | editData, 52 | emojiData, 53 | errorData, 54 | handData, 55 | lightbulbData, 56 | memoryData, 57 | notificationsData, 58 | personData, 59 | phoneData, 60 | powerData, 61 | sdData, 62 | smsData, 63 | starData, 64 | syncData, 65 | thermostatData, 66 | thumbData, 67 | warningData, 68 | wifiData }; 69 | 70 | // Color gradients for smoothing edges 71 | static const uint16_t colors[7][3] = { { 0x5000, 0xA800, 0xF800 }, // Red 72 | { 0x02A0, 0x0540, 0x07E0 }, // Green 73 | { 0x000A, 0x0015, 0x001F }, // Blue 74 | { 0x52A0, 0xAD40, 0xFFE0 }, // Yellow 75 | { 0x02AA, 0x0555, 0x7FFF }, // Cyan 76 | { 0x500A, 0xA815, 0xF81F }, // Magenta 77 | { 0x52AA, 0xAD55, 0xFFFF } }; // White 78 | 79 | 80 | uint8_t currentColor; 81 | uint8_t x = 0; 82 | uint8_t y = 0; 83 | 84 | // Decompression instance 85 | static Decompression decomp; 86 | // And buffer 87 | static uint16_t decompressedData[FRAMES_PER_BUFFER]; 88 | 89 | 90 | void setup() { 91 | // put your setup code here, to run once: 92 | // Initialize display 93 | ST7789.init(DEFAULT_SPI_SPEED, DEFAULT_SPI_MODE, DEFAULT_ROTATION, LITTLE_ENDIAN); 94 | // If the display does not initialize, then try this: 95 | //ST7789.init(DEFAULT_SPI_SPEED, SPI_MODE0, DEFAULT_ROTATION, LITTLE_ENDIAN); 96 | // Set the width of our buffer for correct decompression 97 | decomp.bufferWidth = ICONS_IMAGE_WIDTH; 98 | } 99 | 100 | void loop() { 101 | // put your main code here, to run repeatedly: 102 | 103 | // Display 30 random icons 104 | for (uint8_t i = 0; i < 30; i++) 105 | { 106 | ST7789.begin(); 107 | ST7789.setWindow(x, y, ICONS_IMAGE_WIDTH, ICONS_IMAGE_HEIGHT); 108 | decomp.resetDecompression(); 109 | uint8_t * currentIcon = icons[random(25)]; 110 | currentColor = random(7); 111 | 112 | // Draw single icon 113 | for (uint8_t j = 0; j < BUFFERS_PER_ICON; j++) 114 | { 115 | // Decompress one buffer 116 | decomp.decompressNextFrames(&iconsDC, currentIcon, decompressedData, FRAMES_PER_BUFFER, true); 117 | // And display it 118 | ST7789.writePixels(decompressedData, FRAMES_PER_BUFFER, LITTLE_ENDIAN); 119 | } 120 | ST7789.end(); 121 | delay(10); 122 | } 123 | 124 | // Finally move to the next icon position 125 | x += ICONS_IMAGE_WIDTH; 126 | if (x >= DISPLAY_WIDTH) { 127 | x = 0; 128 | y += ICONS_IMAGE_HEIGHT; 129 | if (y >= DISPLAY_HEIGHT) y = 0; 130 | } 131 | } 132 | 133 | // Delegate method for coloring a pixel in the current color 134 | uint16_t colorizePixel(uint16_t frame) { 135 | uint16_t pixelColor = (frame == 0) ? 0 : colors[currentColor][frame - 1]; 136 | return (pixelColor); 137 | } 138 | 139 | // END-OF-FILE 140 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Nano_ST7789/ST7789.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // Includes 28 | #include "ST7789.h" 29 | 30 | // Instantiate class 31 | ST7789_Class ST7789; 32 | 33 | // Static variables references 34 | long ST7789_Class::spiSpeed; 35 | uint8_t ST7789_Class::spiMode; 36 | bool ST7789_Class::isDisplayLE = DEFAULT_ENDIANNESS; 37 | uint8_t ST7789_Class::xShift = 0; 38 | uint8_t ST7789_Class::yShift = 0; 39 | 40 | // Init w/o parameters 41 | void ST7789_Class::init(void) 42 | { 43 | init(DEFAULT_SPI_SPEED, DEFAULT_SPI_MODE, DEFAULT_ROTATION, DEFAULT_ENDIANNESS); 44 | } 45 | 46 | // Init with parameters 47 | void ST7789_Class::init(uint32_t speed, uint8_t mode, uint8_t rotation, bool littleEndian) { 48 | // Configure pins 49 | pinMode(DISPLAY_RST, OUTPUT); 50 | pinMode(DISPLAY_DC, OUTPUT); 51 | #if defined(DISPLAY_CS_USED) 52 | pinMode(DISPLAY_CS, OUTPUT); 53 | #endif 54 | 55 | // Init SPI 56 | spiSpeed = speed; 57 | spiMode = mode; 58 | isDisplayLE = littleEndian; 59 | SPI.begin(); 60 | 61 | // Reset display 62 | digitalWrite(DISPLAY_RST, LOW); 63 | delay(25); 64 | digitalWrite(DISPLAY_RST, HIGH); 65 | delay(50); 66 | 67 | begin(); 68 | 69 | // Set color mode to RGB565 70 | writeCommand(ST7789_COLORMODE); 71 | writeDataByte(ST7789_COLOR_MODE_16bit); 72 | 73 | // Set display RAM control to Little Endian mode 74 | if (littleEndian) { 75 | writeCommand(ST7789_RAMCTRL); 76 | writeData((uint8_t *)ST7789_RAMCTRL_PARAMETERS, sizeof(ST7789_RAMCTRL_PARAMETERS)); 77 | } 78 | 79 | // Sleep mode Off 80 | writeCommand(ST7789_SLPOUT); 81 | // Set display rotation 82 | setRotation(rotation); 83 | // Turn on the color inversion 84 | writeCommand(ST7789_INVON); 85 | // Normal Display Mode On 86 | writeCommand(ST7789_NORON); 87 | // Clear screen 88 | fillColor(0); 89 | // Display On 90 | writeCommand (ST7789_DISPON); 91 | 92 | end(); 93 | } 94 | 95 | // Begin SPI transaction and select the display 96 | void ST7789_Class::begin() { 97 | SPI.beginTransaction(SPISettings(spiSpeed, MSBFIRST, spiMode)); 98 | selectDisplay(true); 99 | } 100 | 101 | // End SPI transaction and deselect the display 102 | void ST7789_Class::end() { 103 | SPI.endTransaction(); 104 | selectDisplay(false); 105 | } 106 | 107 | // Configure screen rotation 108 | void ST7789_Class::setRotation(uint8_t rotation) { 109 | writeCommand(ST7789_MADCTL); 110 | writeDataByte(ST7789_ROTATION_PARAMETERS[rotation][0]); 111 | xShift = ST7789_ROTATION_PARAMETERS[rotation][1]; 112 | yShift = ST7789_ROTATION_PARAMETERS[rotation][2]; 113 | } 114 | 115 | // Set target window 116 | void ST7789_Class::setWindow(uint8_t x, uint8_t y, uint8_t width, uint8_t height) { 117 | uint16_t address; 118 | // Column Address set 119 | writeCommand(ST7789_CASET); 120 | // Write X coordinates 121 | selectDataMode(true); 122 | address = x + xShift; 123 | SPI.transfer16(address); 124 | address += (width -1); 125 | SPI.transfer16(address); 126 | 127 | // Row Address set 128 | writeCommand(ST7789_RASET); 129 | // Write Y coordinates 130 | selectDataMode(true); 131 | address = y + yShift; 132 | SPI.transfer16(address); 133 | address += (height - 1); 134 | SPI.transfer16(address); 135 | 136 | // Write to RAM 137 | writeCommand(ST7789_RAMWR); 138 | selectDataMode(true); 139 | } 140 | 141 | // Fill with solid color 142 | void ST7789_Class::fillColor(uint16_t color) { 143 | setWindow(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); 144 | for (uint16_t pixel = 0; pixel < DISPLAY_WIDTH * DISPLAY_HEIGHT; pixel++) { 145 | writePixel(color); 146 | } 147 | } 148 | 149 | // Write next pixel 150 | void ST7789_Class::writePixel(uint16_t color) { 151 | if (isDisplayLE) color = __builtin_bswap16(color); 152 | SPI.transfer16(color); 153 | } 154 | 155 | // Write a chunk of pixels 156 | void ST7789_Class::writePixels(uint16_t * pixels, uint16_t size, bool littleEndian) { 157 | if (isDisplayLE == littleEndian) { 158 | writeData((uint8_t *)pixels, size << 1); 159 | } 160 | else 161 | { 162 | for (uint16_t i = 0; i < size; i++) SPI.transfer16(pixels[i]); 163 | } 164 | } 165 | 166 | // Write command 167 | void ST7789_Class::writeCommand(uint8_t command) { 168 | selectDataMode(false); 169 | SPI.transfer(command); 170 | } 171 | 172 | // Write one byte of data 173 | void ST7789_Class::writeDataByte(uint8_t data) { 174 | selectDataMode(true); 175 | SPI.transfer(data); 176 | } 177 | 178 | // Write one word of data 179 | // (for pixel use writePixel). 180 | void ST7789_Class::writeDataWord(uint16_t data) { 181 | selectDataMode(true); 182 | SPI.transfer16(data); 183 | } 184 | 185 | // Write a chunk of data 186 | // (for pixels use writePixels). 187 | void ST7789_Class::writeData(uint8_t * data, uint16_t size) { 188 | selectDataMode(true); 189 | #if defined(ESP32) || defined(ESP8266) 190 | SPI.writeBytes(data, size); 191 | #else 192 | SPI.transfer(data, size); 193 | #endif 194 | } 195 | 196 | // END-OF-FILE 197 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Nano_ST7789/ST7789.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // Very simple class which allows you to output images 28 | // or individual pixels on a display based on the ST7789 controller. 29 | // It is designed only for use with 240x240 pixel displays. 30 | // Some extra modifications required for other displays. 31 | 32 | // ATTENTION! For better perfomance it is necessary that the 33 | // display byte order corresponds to the byte order of the transmitted pixels. 34 | 35 | // Includes 36 | #include 37 | #include 38 | 39 | #ifndef _ST7789_ 40 | #define _ST7789_ 41 | 42 | // Global definitions 43 | #define BIG_ENDIAN 0 44 | #define LITTLE_ENDIAN 1 45 | 46 | // Default SPI clock speed 47 | #define DEFAULT_SPI_SPEED 8000000L 48 | #define DEFAULT_SPI_MODE SPI_MODE3 49 | 50 | // Display configuration 51 | #define DEFAULT_ROTATION 2 // 0-3, 2 - normal top to bottom 52 | #define DEFAULT_ENDIANNESS BIG_ENDIAN 53 | #define DISPLAY_RST 8 // Reset pin 54 | #define DISPLAY_DC 9 // Data/command pin 55 | #define DISPLAY_CS 5 // If your display has CS pin 56 | //#define DISPLAY_CS_USED 57 | // SCK 13 58 | // SDA 11 59 | 60 | #define DISPLAY_WIDTH 240 61 | #define DISPLAY_HEIGHT 240 62 | 63 | // Display commands 64 | #define ST7789_COLORMODE 0x3A 65 | #define ST7789_RAMCTRL 0xB0 66 | #define ST7789_MADCTL 0x36 67 | #define ST7789_INVON 0x21 68 | #define ST7789_SLPOUT 0x11 69 | #define ST7789_NORON 0x13 70 | #define ST7789_DISPON 0x29 71 | #define ST7789_CASET 0x2A 72 | #define ST7789_RASET 0x2B 73 | #define ST7789_RAMWR 0x2C 74 | 75 | // Command arguments 76 | // Page Address Order: 0 = Top to Bottom, 1 = Bottom to Top. 77 | #define ST7789_MADCTL_MY 0x80 78 | // Column Address Order: 0 = Left to Right, 1 = Right to Left. 79 | #define ST7789_MADCTL_MX 0x40 80 | // Page/Column Order: 0 = Normal Mode, 1 = Reverse Mode. 81 | #define ST7789_MADCTL_MV 0x20 82 | // Line Address Order: 0 = LCD Refresh Top to Bottom, 1 = LCD Refresh Bottom to Top. 83 | #define ST7789_MADCTL_ML 0x10 84 | // RGB/BGR Order: 0 = RGB, 1 = BGR. 85 | #define ST7789_MADCTL_RGB 0x00 86 | // Display Data Latch Data Order: 0 = LCD Refresh Left to Right, 1 = LCD Refresh Right to Left. 87 | #define ST7789_MADCTL_MH 0x00 88 | 89 | static const uint8_t ST7789_COLOR_MODE_16bit = 0x55; 90 | static const uint8_t ST7789_RAMCTRL_PARAMETERS[2] = { 0x00, 0xE8 }; 91 | static const uint8_t ST7789_ROTATION_PARAMETERS[4][3] = { { ST7789_MADCTL_MX | ST7789_MADCTL_MY | ST7789_MADCTL_RGB, 0, 80 }, 92 | { ST7789_MADCTL_MY | ST7789_MADCTL_MV | ST7789_MADCTL_RGB, 80, 0 }, 93 | { ST7789_MADCTL_RGB, 0, 0}, 94 | { ST7789_MADCTL_MX | ST7789_MADCTL_MV | ST7789_MADCTL_RGB, 0, 0 } }; 95 | 96 | 97 | //////////////////////////////////////////////////////////////////////////////////////// 98 | //////////////////////////////////////////////////////////////////////////////////////// 99 | //////////////////////////////////////////////////////////////////////////////////////// 100 | 101 | class ST7789_Class { 102 | 103 | public: 104 | 105 | static void init(); 106 | static void init(uint32_t speed, uint8_t mode, uint8_t rotation, bool littleEndian); 107 | 108 | static void begin(); 109 | static void end(); 110 | 111 | static void setRotation(uint8_t rotation); 112 | static void setWindow(uint8_t x, uint8_t y, uint8_t width, uint8_t height); 113 | 114 | static void fillColor(uint16_t color); 115 | static void writePixel(uint16_t color); 116 | static void writePixels(uint16_t * pixels, uint16_t size, bool littleEndian); 117 | 118 | static void writeCommand(uint8_t command); 119 | static void writeDataByte(uint8_t data); 120 | static void writeDataWord(uint16_t data); 121 | static void writeData(uint8_t * data, uint16_t size); 122 | 123 | private: 124 | 125 | static long spiSpeed; 126 | static uint8_t spiMode; 127 | static bool isDisplayLE; // 0 - big endian, 1 - little endian 128 | static uint8_t xShift; 129 | static uint8_t yShift; 130 | 131 | inline static void selectDisplay(bool val) { 132 | #if defined(DISPLAY_CS_USED) 133 | digitalWrite(DISPLAY_CS, !val); 134 | #endif 135 | } 136 | 137 | inline static void selectDataMode(bool val) { 138 | digitalWrite(DISPLAY_DC, val); 139 | } 140 | 141 | }; 142 | 143 | extern ST7789_Class ST7789; 144 | 145 | #endif // end _ST7789_ 146 | 147 | // END-OF-FILE 148 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Nano_ST7789_Tiny/Nano_ST7789_Tiny.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // The example is based on a tiny version of the decompression class, 28 | // which has rather modest but sufficient capabilities and very high performance. 29 | // In addition, it uses a minimalistic library which can draw images 30 | // or individual pixels on a display based on the ST7789 controller. 31 | // You don't need any extra libraries for this example to work. 32 | 33 | // ATTENTION!!! To run this example, you need an Arduino Nano board, 34 | // and a 240x240 pixel IPS color display (on the ST7789 controller). 35 | // To configure the connection pins, please refer to ST7789.h. 36 | 37 | #include "ST7789.h" 38 | #include "Icons.h" 39 | 40 | #define FRAMES_PER_BUFFER ICONS_IMAGE_WIDTH * ICONS_SQUARE_SIDE 41 | #define BUFFERS_PER_ICON ICONS_IMAGE_HEIGHT / ICONS_SQUARE_SIDE 42 | 43 | // Icons list 44 | static const uint8_t * icons[25] = { accessData, 45 | bluetoothData, 46 | bugData, 47 | buildData, 48 | cableData, 49 | checkData, 50 | cloudData, 51 | editData, 52 | emojiData, 53 | errorData, 54 | handData, 55 | lightbulbData, 56 | memoryData, 57 | notificationsData, 58 | personData, 59 | phoneData, 60 | powerData, 61 | sdData, 62 | smsData, 63 | starData, 64 | syncData, 65 | thermostatData, 66 | thumbData, 67 | warningData, 68 | wifiData }; 69 | 70 | // Color gradients for smoothing edges 71 | static const uint16_t colors[7][3] = { { 0x5000, 0xA800, 0xF800 }, // Red 72 | { 0x02A0, 0x0540, 0x07E0 }, // Green 73 | { 0x000A, 0x0015, 0x001F }, // Blue 74 | { 0x52A0, 0xAD40, 0xFFE0 }, // Yellow 75 | { 0x02AA, 0x0555, 0x7FFF }, // Cyan 76 | { 0x500A, 0xA815, 0xF81F }, // Magenta 77 | { 0x52AA, 0xAD55, 0xFFFF } }; // White 78 | 79 | 80 | uint8_t currentColor; 81 | uint8_t x = 0; 82 | uint8_t y = 0; 83 | 84 | // Decompression instance 85 | static Decompression decomp; 86 | // And buffer 87 | static uint16_t decompressedData[FRAMES_PER_BUFFER]; 88 | 89 | 90 | void setup() { 91 | // put your setup code here, to run once: 92 | // Initialize display 93 | ST7789.init(DEFAULT_SPI_SPEED, DEFAULT_SPI_MODE, DEFAULT_ROTATION, LITTLE_ENDIAN); 94 | // If the display does not initialize, then try this: 95 | //ST7789.init(DEFAULT_SPI_SPEED, SPI_MODE0, DEFAULT_ROTATION, LITTLE_ENDIAN); 96 | // Set the width of our buffer for correct decompression 97 | decomp.bufferWidth = ICONS_IMAGE_WIDTH; 98 | } 99 | 100 | void loop() { 101 | // put your main code here, to run repeatedly: 102 | 103 | // Display 30 random icons 104 | for (uint8_t i = 0; i < 30; i++) 105 | { 106 | ST7789.begin(); 107 | ST7789.setWindow(x, y, ICONS_IMAGE_WIDTH, ICONS_IMAGE_HEIGHT); 108 | decomp.resetDecompression(); 109 | uint8_t * currentIcon = icons[random(25)]; 110 | currentColor = random(7); 111 | 112 | // Draw single icon 113 | for (uint8_t j = 0; j < BUFFERS_PER_ICON; j++) 114 | { 115 | // Decompress one buffer 116 | decomp.decompressNextFrames(&iconsDC, currentIcon, decompressedData, FRAMES_PER_BUFFER, true); 117 | // And display it 118 | ST7789.writePixels(decompressedData, FRAMES_PER_BUFFER, LITTLE_ENDIAN); 119 | } 120 | ST7789.end(); 121 | delay(10); 122 | } 123 | 124 | // Finally move to the next icon position 125 | x += ICONS_IMAGE_WIDTH; 126 | if (x >= DISPLAY_WIDTH) { 127 | x = 0; 128 | y += ICONS_IMAGE_HEIGHT; 129 | if (y >= DISPLAY_HEIGHT) y = 0; 130 | } 131 | } 132 | 133 | // Delegate method for coloring a pixel in the current color 134 | uint16_t colorizePixel(uint8_t frame) { 135 | uint16_t pixelColor = (frame == 0) ? 0 : colors[currentColor][frame - 1]; 136 | return (pixelColor); 137 | } 138 | 139 | // END-OF-FILE 140 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Nano_ST7789_Tiny/ST7789.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // Includes 28 | #include "ST7789.h" 29 | 30 | // Instantiate class 31 | ST7789_Class ST7789; 32 | 33 | // Static variables references 34 | long ST7789_Class::spiSpeed; 35 | uint8_t ST7789_Class::spiMode; 36 | bool ST7789_Class::isDisplayLE = DEFAULT_ENDIANNESS; 37 | uint8_t ST7789_Class::xShift = 0; 38 | uint8_t ST7789_Class::yShift = 0; 39 | 40 | // Init w/o parameters 41 | void ST7789_Class::init(void) 42 | { 43 | init(DEFAULT_SPI_SPEED, DEFAULT_SPI_MODE, DEFAULT_ROTATION, DEFAULT_ENDIANNESS); 44 | } 45 | 46 | // Init with parameters 47 | void ST7789_Class::init(uint32_t speed, uint8_t mode, uint8_t rotation, bool littleEndian) { 48 | // Configure pins 49 | pinMode(DISPLAY_RST, OUTPUT); 50 | pinMode(DISPLAY_DC, OUTPUT); 51 | #if defined(DISPLAY_CS_USED) 52 | pinMode(DISPLAY_CS, OUTPUT); 53 | #endif 54 | 55 | // Init SPI 56 | spiSpeed = speed; 57 | spiMode = mode; 58 | isDisplayLE = littleEndian; 59 | SPI.begin(); 60 | 61 | // Reset display 62 | digitalWrite(DISPLAY_RST, LOW); 63 | delay(25); 64 | digitalWrite(DISPLAY_RST, HIGH); 65 | delay(50); 66 | 67 | begin(); 68 | 69 | // Set color mode to RGB565 70 | writeCommand(ST7789_COLORMODE); 71 | writeDataByte(ST7789_COLOR_MODE_16bit); 72 | 73 | // Set display RAM control to Little Endian mode 74 | if (littleEndian) { 75 | writeCommand(ST7789_RAMCTRL); 76 | writeData((uint8_t *)ST7789_RAMCTRL_PARAMETERS, sizeof(ST7789_RAMCTRL_PARAMETERS)); 77 | } 78 | 79 | // Sleep mode Off 80 | writeCommand(ST7789_SLPOUT); 81 | // Set display rotation 82 | setRotation(rotation); 83 | // Turn on the color inversion 84 | writeCommand(ST7789_INVON); 85 | // Normal Display Mode On 86 | writeCommand(ST7789_NORON); 87 | // Clear screen 88 | fillColor(0); 89 | // Display On 90 | writeCommand (ST7789_DISPON); 91 | 92 | end(); 93 | } 94 | 95 | // Begin SPI transaction and select the display 96 | void ST7789_Class::begin() { 97 | SPI.beginTransaction(SPISettings(spiSpeed, MSBFIRST, spiMode)); 98 | selectDisplay(true); 99 | } 100 | 101 | // End SPI transaction and deselect the display 102 | void ST7789_Class::end() { 103 | SPI.endTransaction(); 104 | selectDisplay(false); 105 | } 106 | 107 | // Configure screen rotation 108 | void ST7789_Class::setRotation(uint8_t rotation) { 109 | writeCommand(ST7789_MADCTL); 110 | writeDataByte(ST7789_ROTATION_PARAMETERS[rotation][0]); 111 | xShift = ST7789_ROTATION_PARAMETERS[rotation][1]; 112 | yShift = ST7789_ROTATION_PARAMETERS[rotation][2]; 113 | } 114 | 115 | // Set target window 116 | void ST7789_Class::setWindow(uint8_t x, uint8_t y, uint8_t width, uint8_t height) { 117 | uint16_t address; 118 | // Column Address set 119 | writeCommand(ST7789_CASET); 120 | // Write X coordinates 121 | selectDataMode(true); 122 | address = x + xShift; 123 | SPI.transfer16(address); 124 | address += (width -1); 125 | SPI.transfer16(address); 126 | 127 | // Row Address set 128 | writeCommand(ST7789_RASET); 129 | // Write Y coordinates 130 | selectDataMode(true); 131 | address = y + yShift; 132 | SPI.transfer16(address); 133 | address += (height - 1); 134 | SPI.transfer16(address); 135 | 136 | // Write to RAM 137 | writeCommand(ST7789_RAMWR); 138 | selectDataMode(true); 139 | } 140 | 141 | // Fill with solid color 142 | void ST7789_Class::fillColor(uint16_t color) { 143 | setWindow(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); 144 | for (uint16_t pixel = 0; pixel < DISPLAY_WIDTH * DISPLAY_HEIGHT; pixel++) { 145 | writePixel(color); 146 | } 147 | } 148 | 149 | // Write next pixel 150 | void ST7789_Class::writePixel(uint16_t color) { 151 | if (isDisplayLE) color = __builtin_bswap16(color); 152 | SPI.transfer16(color); 153 | } 154 | 155 | // Write a chunk of pixels 156 | void ST7789_Class::writePixels(uint16_t * pixels, uint16_t size, bool littleEndian) { 157 | if (isDisplayLE == littleEndian) { 158 | writeData((uint8_t *)pixels, size << 1); 159 | } 160 | else 161 | { 162 | for (uint16_t i = 0; i < size; i++) SPI.transfer16(pixels[i]); 163 | } 164 | } 165 | 166 | // Write command 167 | void ST7789_Class::writeCommand(uint8_t command) { 168 | selectDataMode(false); 169 | SPI.transfer(command); 170 | } 171 | 172 | // Write one byte of data 173 | void ST7789_Class::writeDataByte(uint8_t data) { 174 | selectDataMode(true); 175 | SPI.transfer(data); 176 | } 177 | 178 | // Write one word of data 179 | // (for pixel use writePixel). 180 | void ST7789_Class::writeDataWord(uint16_t data) { 181 | selectDataMode(true); 182 | SPI.transfer16(data); 183 | } 184 | 185 | // Write a chunk of data 186 | // (for pixels use writePixels). 187 | void ST7789_Class::writeData(uint8_t * data, uint16_t size) { 188 | selectDataMode(true); 189 | #if defined(ESP32) || defined(ESP8266) 190 | SPI.writeBytes(data, size); 191 | #else 192 | SPI.transfer(data, size); 193 | #endif 194 | } 195 | 196 | // END-OF-FILE 197 | -------------------------------------------------------------------------------- /Examples/AVR/Arduino_boards/Nano_ST7789_Tiny/ST7789.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // Very simple class which allows you to output images 28 | // or individual pixels on a display based on the ST7789 controller. 29 | // It is designed only for use with 240x240 pixel displays. 30 | // Some extra modifications required for other displays. 31 | 32 | // ATTENTION! For better perfomance it is necessary that the 33 | // display byte order corresponds to the byte order of the transmitted pixels. 34 | 35 | // Includes 36 | #include 37 | #include 38 | 39 | #ifndef _ST7789_ 40 | #define _ST7789_ 41 | 42 | // Global definitions 43 | #define BIG_ENDIAN 0 44 | #define LITTLE_ENDIAN 1 45 | 46 | // Default SPI clock speed 47 | #define DEFAULT_SPI_SPEED 8000000L 48 | #define DEFAULT_SPI_MODE SPI_MODE3 49 | 50 | // Display configuration 51 | #define DEFAULT_ROTATION 2 // 0-3, 2 - normal top to bottom 52 | #define DEFAULT_ENDIANNESS BIG_ENDIAN 53 | #define DISPLAY_RST 8 // Reset pin 54 | #define DISPLAY_DC 9 // Data/command pin 55 | #define DISPLAY_CS 5 // If your display has CS pin 56 | //#define DISPLAY_CS_USED 57 | // SCK 13 58 | // SDA 11 59 | 60 | #define DISPLAY_WIDTH 240 61 | #define DISPLAY_HEIGHT 240 62 | 63 | // Display commands 64 | #define ST7789_COLORMODE 0x3A 65 | #define ST7789_RAMCTRL 0xB0 66 | #define ST7789_MADCTL 0x36 67 | #define ST7789_INVON 0x21 68 | #define ST7789_SLPOUT 0x11 69 | #define ST7789_NORON 0x13 70 | #define ST7789_DISPON 0x29 71 | #define ST7789_CASET 0x2A 72 | #define ST7789_RASET 0x2B 73 | #define ST7789_RAMWR 0x2C 74 | 75 | // Command arguments 76 | // Page Address Order: 0 = Top to Bottom, 1 = Bottom to Top. 77 | #define ST7789_MADCTL_MY 0x80 78 | // Column Address Order: 0 = Left to Right, 1 = Right to Left. 79 | #define ST7789_MADCTL_MX 0x40 80 | // Page/Column Order: 0 = Normal Mode, 1 = Reverse Mode. 81 | #define ST7789_MADCTL_MV 0x20 82 | // Line Address Order: 0 = LCD Refresh Top to Bottom, 1 = LCD Refresh Bottom to Top. 83 | #define ST7789_MADCTL_ML 0x10 84 | // RGB/BGR Order: 0 = RGB, 1 = BGR. 85 | #define ST7789_MADCTL_RGB 0x00 86 | // Display Data Latch Data Order: 0 = LCD Refresh Left to Right, 1 = LCD Refresh Right to Left. 87 | #define ST7789_MADCTL_MH 0x00 88 | 89 | static const uint8_t ST7789_COLOR_MODE_16bit = 0x55; 90 | static const uint8_t ST7789_RAMCTRL_PARAMETERS[2] = { 0x00, 0xE8 }; 91 | static const uint8_t ST7789_ROTATION_PARAMETERS[4][3] = { { ST7789_MADCTL_MX | ST7789_MADCTL_MY | ST7789_MADCTL_RGB, 0, 80 }, 92 | { ST7789_MADCTL_MY | ST7789_MADCTL_MV | ST7789_MADCTL_RGB, 80, 0 }, 93 | { ST7789_MADCTL_RGB, 0, 0}, 94 | { ST7789_MADCTL_MX | ST7789_MADCTL_MV | ST7789_MADCTL_RGB, 0, 0 } }; 95 | 96 | 97 | //////////////////////////////////////////////////////////////////////////////////////// 98 | //////////////////////////////////////////////////////////////////////////////////////// 99 | //////////////////////////////////////////////////////////////////////////////////////// 100 | 101 | class ST7789_Class { 102 | 103 | public: 104 | 105 | static void init(); 106 | static void init(uint32_t speed, uint8_t mode, uint8_t rotation, bool littleEndian); 107 | 108 | static void begin(); 109 | static void end(); 110 | 111 | static void setRotation(uint8_t rotation); 112 | static void setWindow(uint8_t x, uint8_t y, uint8_t width, uint8_t height); 113 | 114 | static void fillColor(uint16_t color); 115 | static void writePixel(uint16_t color); 116 | static void writePixels(uint16_t * pixels, uint16_t size, bool littleEndian); 117 | 118 | static void writeCommand(uint8_t command); 119 | static void writeDataByte(uint8_t data); 120 | static void writeDataWord(uint16_t data); 121 | static void writeData(uint8_t * data, uint16_t size); 122 | 123 | private: 124 | 125 | static long spiSpeed; 126 | static uint8_t spiMode; 127 | static bool isDisplayLE; // 0 - big endian, 1 - little endian 128 | static uint8_t xShift; 129 | static uint8_t yShift; 130 | 131 | inline static void selectDisplay(bool val) { 132 | #if defined(DISPLAY_CS_USED) 133 | digitalWrite(DISPLAY_CS, !val); 134 | #endif 135 | } 136 | 137 | inline static void selectDataMode(bool val) { 138 | digitalWrite(DISPLAY_DC, val); 139 | } 140 | 141 | }; 142 | 143 | extern ST7789_Class ST7789; 144 | 145 | #endif // end _ST7789_ 146 | 147 | // END-OF-FILE 148 | -------------------------------------------------------------------------------- /Examples/ESP32/Wroom_ST7789/ST7789.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // Includes 28 | #include "ST7789.h" 29 | 30 | // Instantiate class 31 | ST7789_Class ST7789; 32 | 33 | // Static variables references 34 | long ST7789_Class::spiSpeed; 35 | uint8_t ST7789_Class::spiMode; 36 | bool ST7789_Class::isDisplayLE = DEFAULT_ENDIANNESS; 37 | uint8_t ST7789_Class::xShift = 0; 38 | uint8_t ST7789_Class::yShift = 0; 39 | 40 | // Init w/o parameters 41 | void ST7789_Class::init(void) 42 | { 43 | init(DEFAULT_SPI_SPEED, DEFAULT_SPI_MODE, DEFAULT_ROTATION, DEFAULT_ENDIANNESS); 44 | } 45 | 46 | // Init with parameters 47 | void ST7789_Class::init(uint32_t speed, uint8_t mode, uint8_t rotation, bool littleEndian) { 48 | // Configure pins 49 | pinMode(DISPLAY_RST, OUTPUT); 50 | pinMode(DISPLAY_DC, OUTPUT); 51 | #if defined(DISPLAY_CS_USED) 52 | pinMode(DISPLAY_CS, OUTPUT); 53 | #endif 54 | 55 | // Init SPI 56 | spiSpeed = speed; 57 | spiMode = mode; 58 | isDisplayLE = littleEndian; 59 | SPI.begin(); 60 | 61 | // Reset display 62 | digitalWrite(DISPLAY_RST, LOW); 63 | delay(25); 64 | digitalWrite(DISPLAY_RST, HIGH); 65 | delay(50); 66 | 67 | begin(); 68 | 69 | // Set color mode to RGB565 70 | writeCommand(ST7789_COLORMODE); 71 | writeDataByte(ST7789_COLOR_MODE_16bit); 72 | 73 | // Set display RAM control to Little Endian mode 74 | if (littleEndian) { 75 | writeCommand(ST7789_RAMCTRL); 76 | writeData((uint8_t *)ST7789_RAMCTRL_PARAMETERS, sizeof(ST7789_RAMCTRL_PARAMETERS)); 77 | } 78 | 79 | // Sleep mode Off 80 | writeCommand(ST7789_SLPOUT); 81 | // Set display rotation 82 | setRotation(rotation); 83 | // Turn on the color inversion 84 | writeCommand(ST7789_INVON); 85 | // Normal Display Mode On 86 | writeCommand(ST7789_NORON); 87 | // Clear screen 88 | fillColor(0); 89 | // Display On 90 | writeCommand (ST7789_DISPON); 91 | 92 | end(); 93 | } 94 | 95 | // Begin SPI transaction and select the display 96 | void ST7789_Class::begin() { 97 | SPI.beginTransaction(SPISettings(spiSpeed, MSBFIRST, spiMode)); 98 | selectDisplay(true); 99 | } 100 | 101 | // End SPI transaction and deselect the display 102 | void ST7789_Class::end() { 103 | SPI.endTransaction(); 104 | selectDisplay(false); 105 | } 106 | 107 | // Configure screen rotation 108 | void ST7789_Class::setRotation(uint8_t rotation) { 109 | writeCommand(ST7789_MADCTL); 110 | writeDataByte(ST7789_ROTATION_PARAMETERS[rotation][0]); 111 | xShift = ST7789_ROTATION_PARAMETERS[rotation][1]; 112 | yShift = ST7789_ROTATION_PARAMETERS[rotation][2]; 113 | } 114 | 115 | // Set target window 116 | void ST7789_Class::setWindow(uint8_t x, uint8_t y, uint8_t width, uint8_t height) { 117 | uint16_t address; 118 | // Column Address set 119 | writeCommand(ST7789_CASET); 120 | // Write X coordinates 121 | selectDataMode(true); 122 | address = x + xShift; 123 | SPI.transfer16(address); 124 | address += (width -1); 125 | SPI.transfer16(address); 126 | 127 | // Row Address set 128 | writeCommand(ST7789_RASET); 129 | // Write Y coordinates 130 | selectDataMode(true); 131 | address = y + yShift; 132 | SPI.transfer16(address); 133 | address += (height - 1); 134 | SPI.transfer16(address); 135 | 136 | // Write to RAM 137 | writeCommand(ST7789_RAMWR); 138 | selectDataMode(true); 139 | } 140 | 141 | // Fill with solid color 142 | void ST7789_Class::fillColor(uint16_t color) { 143 | setWindow(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); 144 | for (uint16_t pixel = 0; pixel < DISPLAY_WIDTH * DISPLAY_HEIGHT; pixel++) { 145 | writePixel(color); 146 | } 147 | } 148 | 149 | // Write next pixel 150 | void ST7789_Class::writePixel(uint16_t color) { 151 | if (isDisplayLE) color = __builtin_bswap16(color); 152 | SPI.transfer16(color); 153 | } 154 | 155 | // Write a chunk of pixels 156 | void ST7789_Class::writePixels(uint16_t * pixels, uint16_t size, bool littleEndian) { 157 | if (isDisplayLE == littleEndian) { 158 | writeData((uint8_t *)pixels, size << 1); 159 | } 160 | else 161 | { 162 | for (uint16_t i = 0; i < size; i++) SPI.transfer16(pixels[i]); 163 | } 164 | } 165 | 166 | // Write command 167 | void ST7789_Class::writeCommand(uint8_t command) { 168 | selectDataMode(false); 169 | SPI.transfer(command); 170 | } 171 | 172 | // Write one byte of data 173 | void ST7789_Class::writeDataByte(uint8_t data) { 174 | selectDataMode(true); 175 | SPI.transfer(data); 176 | } 177 | 178 | // Write one word of data 179 | // (for pixel use writePixel). 180 | void ST7789_Class::writeDataWord(uint16_t data) { 181 | selectDataMode(true); 182 | SPI.transfer16(data); 183 | } 184 | 185 | // Write a chunk of data 186 | // (for pixels use writePixels). 187 | void ST7789_Class::writeData(uint8_t * data, uint16_t size) { 188 | selectDataMode(true); 189 | #if defined(ESP32) || defined(ESP8266) 190 | SPI.writeBytes(data, size); 191 | #else 192 | SPI.transfer(data, size); 193 | #endif 194 | } 195 | 196 | // END-OF-FILE 197 | -------------------------------------------------------------------------------- /Examples/ESP32/Wroom_ST7789/ST7789.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | // Very simple class which allows you to output images 28 | // or individual pixels on a display based on the ST7789 controller. 29 | // It is designed only for use with 240x240 pixel displays. 30 | // Some extra modifications required for other displays. 31 | 32 | // ATTENTION! For better perfomance it is necessary that the 33 | // display byte order corresponds to the byte order of the transmitted pixels. 34 | 35 | // Includes 36 | #include 37 | #include 38 | 39 | #ifndef _ST7789_ 40 | #define _ST7789_ 41 | 42 | // Global definitions 43 | #define BIG_ENDIAN 0 44 | #define LITTLE_ENDIAN 1 45 | 46 | // Default SPI clock speed 47 | #define DEFAULT_SPI_SPEED 8000000L 48 | #define DEFAULT_SPI_MODE SPI_MODE3 49 | 50 | // Display configuration 51 | #define DEFAULT_ROTATION 2 // 0-3, 2 - normal top to bottom 52 | #define DEFAULT_ENDIANNESS BIG_ENDIAN 53 | #define DISPLAY_RST 22 // Reset pin 54 | #define DISPLAY_DC 21 // Data/command pin 55 | #define DISPLAY_CS 5 // If your display has CS pin 56 | //#define DISPLAY_CS_USED 57 | // SCK 13 58 | // SDA 11 59 | 60 | #define DISPLAY_WIDTH 240 61 | #define DISPLAY_HEIGHT 240 62 | 63 | // Display commands 64 | #define ST7789_COLORMODE 0x3A 65 | #define ST7789_RAMCTRL 0xB0 66 | #define ST7789_MADCTL 0x36 67 | #define ST7789_INVON 0x21 68 | #define ST7789_SLPOUT 0x11 69 | #define ST7789_NORON 0x13 70 | #define ST7789_DISPON 0x29 71 | #define ST7789_CASET 0x2A 72 | #define ST7789_RASET 0x2B 73 | #define ST7789_RAMWR 0x2C 74 | 75 | // Command arguments 76 | // Page Address Order: 0 = Top to Bottom, 1 = Bottom to Top. 77 | #define ST7789_MADCTL_MY 0x80 78 | // Column Address Order: 0 = Left to Right, 1 = Right to Left. 79 | #define ST7789_MADCTL_MX 0x40 80 | // Page/Column Order: 0 = Normal Mode, 1 = Reverse Mode. 81 | #define ST7789_MADCTL_MV 0x20 82 | // Line Address Order: 0 = LCD Refresh Top to Bottom, 1 = LCD Refresh Bottom to Top. 83 | #define ST7789_MADCTL_ML 0x10 84 | // RGB/BGR Order: 0 = RGB, 1 = BGR. 85 | #define ST7789_MADCTL_RGB 0x00 86 | // Display Data Latch Data Order: 0 = LCD Refresh Left to Right, 1 = LCD Refresh Right to Left. 87 | #define ST7789_MADCTL_MH 0x00 88 | 89 | static const uint8_t ST7789_COLOR_MODE_16bit = 0x55; 90 | static const uint8_t ST7789_RAMCTRL_PARAMETERS[2] = { 0x00, 0xE8 }; 91 | static const uint8_t ST7789_ROTATION_PARAMETERS[4][3] = { { ST7789_MADCTL_MX | ST7789_MADCTL_MY | ST7789_MADCTL_RGB, 0, 80 }, 92 | { ST7789_MADCTL_MY | ST7789_MADCTL_MV | ST7789_MADCTL_RGB, 80, 0 }, 93 | { ST7789_MADCTL_RGB, 0, 0}, 94 | { ST7789_MADCTL_MX | ST7789_MADCTL_MV | ST7789_MADCTL_RGB, 0, 0 } }; 95 | 96 | 97 | //////////////////////////////////////////////////////////////////////////////////////// 98 | //////////////////////////////////////////////////////////////////////////////////////// 99 | //////////////////////////////////////////////////////////////////////////////////////// 100 | 101 | class ST7789_Class { 102 | 103 | public: 104 | 105 | static void init(); 106 | static void init(uint32_t speed, uint8_t mode, uint8_t rotation, bool littleEndian); 107 | 108 | static void begin(); 109 | static void end(); 110 | 111 | static void setRotation(uint8_t rotation); 112 | static void setWindow(uint8_t x, uint8_t y, uint8_t width, uint8_t height); 113 | 114 | static void fillColor(uint16_t color); 115 | static void writePixel(uint16_t color); 116 | static void writePixels(uint16_t * pixels, uint16_t size, bool littleEndian); 117 | 118 | static void writeCommand(uint8_t command); 119 | static void writeDataByte(uint8_t data); 120 | static void writeDataWord(uint16_t data); 121 | static void writeData(uint8_t * data, uint16_t size); 122 | 123 | private: 124 | 125 | static long spiSpeed; 126 | static uint8_t spiMode; 127 | static bool isDisplayLE; // 0 - big endian, 1 - little endian 128 | static uint8_t xShift; 129 | static uint8_t yShift; 130 | 131 | inline static void selectDisplay(bool val) { 132 | #if defined(DISPLAY_CS_USED) 133 | digitalWrite(DISPLAY_CS, !val); 134 | #endif 135 | } 136 | 137 | inline static void selectDataMode(bool val) { 138 | digitalWrite(DISPLAY_DC, val); 139 | } 140 | 141 | }; 142 | 143 | extern ST7789_Class ST7789; 144 | 145 | #endif // end _ST7789_ 146 | 147 | // END-OF-FILE 148 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | F070CB_ST7789_DMA 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | org.eclipse.cdt.core.cnature 24 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 25 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 28 | com.st.stm32cube.ide.mcu.MCURootProjectNature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | 32 | 33 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f0xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | #define LCD_RESET_Pin GPIO_PIN_4 61 | #define LCD_RESET_GPIO_Port GPIOA 62 | #define LCD_DC_Pin GPIO_PIN_2 63 | #define LCD_DC_GPIO_Port GPIOB 64 | 65 | /* USER CODE BEGIN Private defines */ 66 | 67 | /* USER CODE END Private defines */ 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __MAIN_H */ 74 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Core/Inc/stm32f0xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f0xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F0xx_IT_H 22 | #define __STM32F0xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void SVC_Handler(void); 52 | void PendSV_Handler(void); 53 | void SysTick_Handler(void); 54 | void DMA1_Channel2_3_IRQHandler(void); 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* __STM32F0xx_IT_H */ 64 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Core/Src/stm32f0xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | 2 | /* USER CODE BEGIN Header */ 3 | /** 4 | ****************************************************************************** 5 | * @file stm32f0xx_hal_msp.c 6 | * @brief This file provides code for the MSP Initialization 7 | * and de-Initialization codes. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2024 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "main.h" 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | extern DMA_HandleTypeDef hdma_spi1_tx; 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* USER CODE BEGIN TD */ 31 | 32 | /* USER CODE END TD */ 33 | 34 | /* Private define ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN Define */ 36 | 37 | /* USER CODE END Define */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN Macro */ 41 | 42 | /* USER CODE END Macro */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | /* USER CODE BEGIN PV */ 46 | 47 | /* USER CODE END PV */ 48 | 49 | /* Private function prototypes -----------------------------------------------*/ 50 | /* USER CODE BEGIN PFP */ 51 | 52 | /* USER CODE END PFP */ 53 | 54 | /* External functions --------------------------------------------------------*/ 55 | /* USER CODE BEGIN ExternalFunctions */ 56 | 57 | /* USER CODE END ExternalFunctions */ 58 | 59 | /* USER CODE BEGIN 0 */ 60 | 61 | /* USER CODE END 0 */ 62 | /** 63 | * Initializes the Global MSP. 64 | */ 65 | void HAL_MspInit(void) 66 | { 67 | 68 | /* USER CODE BEGIN MspInit 0 */ 69 | 70 | /* USER CODE END MspInit 0 */ 71 | 72 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 73 | __HAL_RCC_PWR_CLK_ENABLE(); 74 | 75 | /* System interrupt init*/ 76 | 77 | /* USER CODE BEGIN MspInit 1 */ 78 | 79 | /* USER CODE END MspInit 1 */ 80 | } 81 | 82 | /** 83 | * @brief SPI MSP Initialization 84 | * This function configures the hardware resources used in this example 85 | * @param hspi: SPI handle pointer 86 | * @retval None 87 | */ 88 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) 89 | { 90 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 91 | if(hspi->Instance==SPI1) 92 | { 93 | /* USER CODE BEGIN SPI1_MspInit 0 */ 94 | 95 | /* USER CODE END SPI1_MspInit 0 */ 96 | /* Peripheral clock enable */ 97 | __HAL_RCC_SPI1_CLK_ENABLE(); 98 | 99 | __HAL_RCC_GPIOA_CLK_ENABLE(); 100 | /**SPI1 GPIO Configuration 101 | PA5 ------> SPI1_SCK 102 | PA7 ------> SPI1_MOSI 103 | */ 104 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; 105 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 106 | GPIO_InitStruct.Pull = GPIO_NOPULL; 107 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; 108 | GPIO_InitStruct.Alternate = GPIO_AF0_SPI1; 109 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 110 | 111 | /* SPI1 DMA Init */ 112 | /* SPI1_TX Init */ 113 | hdma_spi1_tx.Instance = DMA1_Channel3; 114 | hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; 115 | hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE; 116 | hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE; 117 | hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; 118 | hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; 119 | hdma_spi1_tx.Init.Mode = DMA_NORMAL; 120 | hdma_spi1_tx.Init.Priority = DMA_PRIORITY_HIGH; 121 | if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK) 122 | { 123 | Error_Handler(); 124 | } 125 | 126 | __HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx); 127 | 128 | /* USER CODE BEGIN SPI1_MspInit 1 */ 129 | 130 | /* USER CODE END SPI1_MspInit 1 */ 131 | 132 | } 133 | 134 | } 135 | 136 | /** 137 | * @brief SPI MSP De-Initialization 138 | * This function freeze the hardware resources used in this example 139 | * @param hspi: SPI handle pointer 140 | * @retval None 141 | */ 142 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) 143 | { 144 | if(hspi->Instance==SPI1) 145 | { 146 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ 147 | 148 | /* USER CODE END SPI1_MspDeInit 0 */ 149 | /* Peripheral clock disable */ 150 | __HAL_RCC_SPI1_CLK_DISABLE(); 151 | 152 | /**SPI1 GPIO Configuration 153 | PA5 ------> SPI1_SCK 154 | PA7 ------> SPI1_MOSI 155 | */ 156 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7); 157 | 158 | /* SPI1 DMA DeInit */ 159 | HAL_DMA_DeInit(hspi->hdmatx); 160 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ 161 | 162 | /* USER CODE END SPI1_MspDeInit 1 */ 163 | } 164 | 165 | } 166 | 167 | /* USER CODE BEGIN 1 */ 168 | 169 | /* USER CODE END 1 */ 170 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Core/Src/stm32f0xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f0xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f0xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | extern DMA_HandleTypeDef hdma_spi1_tx; 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M0 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles System service call via SWI instruction. 98 | */ 99 | void SVC_Handler(void) 100 | { 101 | /* USER CODE BEGIN SVC_IRQn 0 */ 102 | 103 | /* USER CODE END SVC_IRQn 0 */ 104 | /* USER CODE BEGIN SVC_IRQn 1 */ 105 | 106 | /* USER CODE END SVC_IRQn 1 */ 107 | } 108 | 109 | /** 110 | * @brief This function handles Pendable request for system service. 111 | */ 112 | void PendSV_Handler(void) 113 | { 114 | /* USER CODE BEGIN PendSV_IRQn 0 */ 115 | 116 | /* USER CODE END PendSV_IRQn 0 */ 117 | /* USER CODE BEGIN PendSV_IRQn 1 */ 118 | 119 | /* USER CODE END PendSV_IRQn 1 */ 120 | } 121 | 122 | /** 123 | * @brief This function handles System tick timer. 124 | */ 125 | void SysTick_Handler(void) 126 | { 127 | /* USER CODE BEGIN SysTick_IRQn 0 */ 128 | 129 | /* USER CODE END SysTick_IRQn 0 */ 130 | HAL_IncTick(); 131 | /* USER CODE BEGIN SysTick_IRQn 1 */ 132 | 133 | /* USER CODE END SysTick_IRQn 1 */ 134 | } 135 | 136 | /******************************************************************************/ 137 | /* STM32F0xx Peripheral Interrupt Handlers */ 138 | /* Add here the Interrupt Handlers for the used peripherals. */ 139 | /* For the available peripheral interrupt handler names, */ 140 | /* please refer to the startup file (startup_stm32f0xx.s). */ 141 | /******************************************************************************/ 142 | 143 | /** 144 | * @brief This function handles DMA1 channel 2 and 3 interrupts. 145 | */ 146 | void DMA1_Channel2_3_IRQHandler(void) 147 | { 148 | /* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */ 149 | 150 | /* USER CODE END DMA1_Channel2_3_IRQn 0 */ 151 | HAL_DMA_IRQHandler(&hdma_spi1_tx); 152 | /* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */ 153 | 154 | /* USER CODE END DMA1_Channel2_3_IRQn 1 */ 155 | } 156 | 157 | /* USER CODE BEGIN 1 */ 158 | 159 | /* USER CODE END 1 */ 160 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2020-2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* Variables */ 35 | extern int __io_putchar(int ch) __attribute__((weak)); 36 | extern int __io_getchar(void) __attribute__((weak)); 37 | 38 | 39 | char *__env[1] = { 0 }; 40 | char **environ = __env; 41 | 42 | 43 | /* Functions */ 44 | void initialise_monitor_handles() 45 | { 46 | } 47 | 48 | int _getpid(void) 49 | { 50 | return 1; 51 | } 52 | 53 | int _kill(int pid, int sig) 54 | { 55 | (void)pid; 56 | (void)sig; 57 | errno = EINVAL; 58 | return -1; 59 | } 60 | 61 | void _exit (int status) 62 | { 63 | _kill(status, -1); 64 | while (1) {} /* Make sure we hang here */ 65 | } 66 | 67 | __attribute__((weak)) int _read(int file, char *ptr, int len) 68 | { 69 | (void)file; 70 | int DataIdx; 71 | 72 | for (DataIdx = 0; DataIdx < len; DataIdx++) 73 | { 74 | *ptr++ = __io_getchar(); 75 | } 76 | 77 | return len; 78 | } 79 | 80 | __attribute__((weak)) int _write(int file, char *ptr, int len) 81 | { 82 | (void)file; 83 | int DataIdx; 84 | 85 | for (DataIdx = 0; DataIdx < len; DataIdx++) 86 | { 87 | __io_putchar(*ptr++); 88 | } 89 | return len; 90 | } 91 | 92 | int _close(int file) 93 | { 94 | (void)file; 95 | return -1; 96 | } 97 | 98 | 99 | int _fstat(int file, struct stat *st) 100 | { 101 | (void)file; 102 | st->st_mode = S_IFCHR; 103 | return 0; 104 | } 105 | 106 | int _isatty(int file) 107 | { 108 | (void)file; 109 | return 1; 110 | } 111 | 112 | int _lseek(int file, int ptr, int dir) 113 | { 114 | (void)file; 115 | (void)ptr; 116 | (void)dir; 117 | return 0; 118 | } 119 | 120 | int _open(char *path, int flags, ...) 121 | { 122 | (void)path; 123 | (void)flags; 124 | /* Pretend like we always fail */ 125 | return -1; 126 | } 127 | 128 | int _wait(int *status) 129 | { 130 | (void)status; 131 | errno = ECHILD; 132 | return -1; 133 | } 134 | 135 | int _unlink(char *name) 136 | { 137 | (void)name; 138 | errno = ENOENT; 139 | return -1; 140 | } 141 | 142 | int _times(struct tms *buf) 143 | { 144 | (void)buf; 145 | return -1; 146 | } 147 | 148 | int _stat(char *file, struct stat *st) 149 | { 150 | (void)file; 151 | st->st_mode = S_IFCHR; 152 | return 0; 153 | } 154 | 155 | int _link(char *old, char *new) 156 | { 157 | (void)old; 158 | (void)new; 159 | errno = EMLINK; 160 | return -1; 161 | } 162 | 163 | int _fork(void) 164 | { 165 | errno = EAGAIN; 166 | return -1; 167 | } 168 | 169 | int _execve(char *name, char **argv, char **env) 170 | { 171 | (void)name; 172 | (void)argv; 173 | (void)env; 174 | errno = ENOMEM; 175 | return -1; 176 | } 177 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeIDE 5 | * @brief STM32CubeIDE System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DmitryMuravyev/Delta-Compression/73aa6cec60975ad5c3fa254d52c63dc84176e8eb/Examples/STM32/F070CB_ST7789_DMA/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/CMSIS/Device/ST/STM32F0xx/Include/system_stm32f0xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f0xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M0 Device System Source File for STM32F0xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /** @addtogroup CMSIS 19 | * @{ 20 | */ 21 | 22 | /** @addtogroup stm32f0xx_system 23 | * @{ 24 | */ 25 | 26 | /** 27 | * @brief Define to prevent recursive inclusion 28 | */ 29 | #ifndef __SYSTEM_STM32F0XX_H 30 | #define __SYSTEM_STM32F0XX_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** @addtogroup STM32F0xx_System_Includes 37 | * @{ 38 | */ 39 | 40 | /** 41 | * @} 42 | */ 43 | 44 | 45 | /** @addtogroup STM32F0xx_System_Exported_types 46 | * @{ 47 | */ 48 | /* This variable is updated in three ways: 49 | 1) by calling CMSIS function SystemCoreClockUpdate() 50 | 3) by calling HAL API function HAL_RCC_GetHCLKFreq() 51 | 3) by calling HAL API function HAL_RCC_ClockConfig() 52 | Note: If you use this function to configure the system clock; then there 53 | is no need to call the 2 first functions listed above, since SystemCoreClock 54 | variable is updated automatically. 55 | */ 56 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 57 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 58 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @addtogroup STM32F0xx_System_Exported_Constants 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @addtogroup STM32F0xx_System_Exported_Macros 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @addtogroup STM32F0xx_System_Exported_Functions 81 | * @{ 82 | */ 83 | 84 | extern void SystemInit(void); 85 | extern void SystemCoreClockUpdate(void); 86 | /** 87 | * @} 88 | */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /*__SYSTEM_STM32F0XX_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/CMSIS/Device/ST/STM32F0xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_cortex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_cortex.h 4 | * @author MCD Application Team 5 | * @brief Header file of CORTEX HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F0xx_HAL_CORTEX_H 21 | #define __STM32F0xx_HAL_CORTEX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f0xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F0xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup CORTEX CORTEX 35 | * @{ 36 | */ 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported constants --------------------------------------------------------*/ 39 | 40 | /** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants 41 | * @{ 42 | */ 43 | 44 | /** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source 45 | * @{ 46 | */ 47 | #define SYSTICK_CLKSOURCE_HCLK_DIV8 (0x00000000U) 48 | #define SYSTICK_CLKSOURCE_HCLK (0x00000004U) 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /* Exported Macros -----------------------------------------------------------*/ 59 | 60 | /* Exported functions --------------------------------------------------------*/ 61 | /** @addtogroup CORTEX_Exported_Functions CORTEX Exported Functions 62 | * @{ 63 | */ 64 | /** @addtogroup CORTEX_Exported_Functions_Group1 Initialization and de-initialization functions 65 | * @brief Initialization and Configuration functions 66 | * @{ 67 | */ 68 | /* Initialization and de-initialization functions *******************************/ 69 | void HAL_NVIC_SetPriority(IRQn_Type IRQn,uint32_t PreemptPriority, uint32_t SubPriority); 70 | void HAL_NVIC_EnableIRQ(IRQn_Type IRQn); 71 | void HAL_NVIC_DisableIRQ(IRQn_Type IRQn); 72 | void HAL_NVIC_SystemReset(void); 73 | uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb); 74 | /** 75 | * @} 76 | */ 77 | 78 | /** @addtogroup CORTEX_Exported_Functions_Group2 Peripheral Control functions 79 | * @brief Cortex control functions 80 | * @{ 81 | */ 82 | 83 | /* Peripheral Control functions *************************************************/ 84 | uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn); 85 | uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn); 86 | void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn); 87 | void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); 88 | void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource); 89 | void HAL_SYSTICK_IRQHandler(void); 90 | void HAL_SYSTICK_Callback(void); 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Private types -------------------------------------------------------------*/ 100 | /* Private variables ---------------------------------------------------------*/ 101 | /* Private constants ---------------------------------------------------------*/ 102 | /* Private macros ------------------------------------------------------------*/ 103 | /** @defgroup CORTEX_Private_Macros CORTEX Private Macros 104 | * @{ 105 | */ 106 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x4) 107 | 108 | #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= 0x00) 109 | 110 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \ 111 | ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8)) 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif /* __STM32F0xx_HAL_CORTEX_H */ 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_pwr.h 4 | * @author MCD Application Team 5 | * @brief Header file of PWR HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F0xx_HAL_PWR_H 21 | #define __STM32F0xx_HAL_PWR_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f0xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F0xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup PWR PWR 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | 41 | /** @defgroup PWR_Exported_Constants PWR Exported Constants 42 | * @{ 43 | */ 44 | 45 | /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode 46 | * @{ 47 | */ 48 | #define PWR_MAINREGULATOR_ON (0x00000000U) 49 | #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS 50 | 51 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ 52 | ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) 53 | /** 54 | * @} 55 | */ 56 | 57 | /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry 58 | * @{ 59 | */ 60 | #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01U) 61 | #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02U) 62 | #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry 68 | * @{ 69 | */ 70 | #define PWR_STOPENTRY_WFI ((uint8_t)0x01U) 71 | #define PWR_STOPENTRY_WFE ((uint8_t)0x02U) 72 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE)) 73 | /** 74 | * @} 75 | */ 76 | 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /* Exported macro ------------------------------------------------------------*/ 83 | /** @defgroup PWR_Exported_Macro PWR Exported Macro 84 | * @{ 85 | */ 86 | 87 | /** @brief Check PWR flag is set or not. 88 | * @param __FLAG__ specifies the flag to check. 89 | * This parameter can be one of the following values: 90 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event 91 | * was received from the WKUP pin or from the RTC alarm (Alarm A), 92 | * RTC Tamper event, RTC TimeStamp event or RTC Wakeup. 93 | * An additional wakeup event is detected if the WKUP pin is enabled 94 | * (by setting the EWUP bit) when the WKUP pin level is already high. 95 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was 96 | * resumed from StandBy mode. 97 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled 98 | * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode 99 | * For this reason, this bit is equal to 0 after Standby or reset 100 | * until the PVDE bit is set. 101 | * Warning: this Flag is not available on STM32F030x8 products 102 | * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference 103 | * voltage VREFINT is ready. 104 | * Warning: this Flag is not available on STM32F030x8 products 105 | * @retval The new state of __FLAG__ (TRUE or FALSE). 106 | */ 107 | #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__)) 108 | 109 | /** @brief Clear the PWR's pending flags. 110 | * @param __FLAG__ specifies the flag to clear. 111 | * This parameter can be one of the following values: 112 | * @arg PWR_FLAG_WU: Wake Up flag 113 | * @arg PWR_FLAG_SB: StandBy flag 114 | */ 115 | #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U) 116 | 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Include PWR HAL Extension module */ 123 | #include "stm32f0xx_hal_pwr_ex.h" 124 | 125 | /* Exported functions --------------------------------------------------------*/ 126 | 127 | /** @addtogroup PWR_Exported_Functions PWR Exported Functions 128 | * @{ 129 | */ 130 | 131 | /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions 132 | * @{ 133 | */ 134 | 135 | /* Initialization and de-initialization functions *****************************/ 136 | void HAL_PWR_DeInit(void); 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions 143 | * @{ 144 | */ 145 | 146 | /* Peripheral Control functions **********************************************/ 147 | void HAL_PWR_EnableBkUpAccess(void); 148 | void HAL_PWR_DisableBkUpAccess(void); 149 | 150 | /* WakeUp pins configuration functions ****************************************/ 151 | void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx); 152 | void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); 153 | 154 | /* Low Power modes configuration functions ************************************/ 155 | void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); 156 | void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); 157 | void HAL_PWR_EnterSTANDBYMode(void); 158 | 159 | void HAL_PWR_EnableSleepOnExit(void); 160 | void HAL_PWR_DisableSleepOnExit(void); 161 | void HAL_PWR_EnableSEVOnPend(void); 162 | void HAL_PWR_DisableSEVOnPend(void); 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | /** 173 | * @} 174 | */ 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | #ifdef __cplusplus 181 | } 182 | #endif 183 | 184 | 185 | #endif /* __STM32F0xx_HAL_PWR_H */ 186 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_spi_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_spi_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of SPI HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F0xx_HAL_SPI_EX_H 21 | #define STM32F0xx_HAL_SPI_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f0xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F0xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup SPIEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup SPIEx_Exported_Functions 43 | * @{ 44 | */ 45 | 46 | /* Initialization and de-initialization functions ****************************/ 47 | /* IO operation functions *****************************************************/ 48 | /** @addtogroup SPIEx_Exported_Functions_Group1 49 | * @{ 50 | */ 51 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(const SPI_HandleTypeDef *hspi); 52 | /** 53 | * @} 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* STM32F0xx_HAL_SPI_EX_H */ 73 | 74 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/STM32F0xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f0xx_hal_spi_ex.c 4 | * @author MCD Application Team 5 | * @brief Extended SPI HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * SPI peripheral extended functionalities : 8 | * + IO operation functions 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2016 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "stm32f0xx_hal.h" 25 | 26 | /** @addtogroup STM32F0xx_HAL_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup SPIEx SPIEx 31 | * @brief SPI Extended HAL module driver 32 | * @{ 33 | */ 34 | #ifdef HAL_SPI_MODULE_ENABLED 35 | 36 | /* Private typedef -----------------------------------------------------------*/ 37 | /* Private defines -----------------------------------------------------------*/ 38 | /** @defgroup SPIEx_Private_Constants SPIEx Private Constants 39 | * @{ 40 | */ 41 | #define SPI_FIFO_SIZE 4UL 42 | /** 43 | * @} 44 | */ 45 | 46 | /* Private macros ------------------------------------------------------------*/ 47 | /* Private variables ---------------------------------------------------------*/ 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* Exported functions --------------------------------------------------------*/ 50 | 51 | /** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions 52 | * @{ 53 | */ 54 | 55 | /** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions 56 | * @brief Data transfers functions 57 | * 58 | @verbatim 59 | ============================================================================== 60 | ##### IO operation functions ##### 61 | =============================================================================== 62 | [..] 63 | This subsection provides a set of extended functions to manage the SPI 64 | data transfers. 65 | 66 | (#) Rx data flush function: 67 | (++) HAL_SPIEx_FlushRxFifo() 68 | 69 | @endverbatim 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @brief Flush the RX fifo. 75 | * @param hspi pointer to a SPI_HandleTypeDef structure that contains 76 | * the configuration information for the specified SPI module. 77 | * @retval HAL status 78 | */ 79 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(const SPI_HandleTypeDef *hspi) 80 | { 81 | __IO uint32_t tmpreg; 82 | uint8_t count = 0U; 83 | while ((hspi->Instance->SR & SPI_FLAG_FRLVL) != SPI_FRLVL_EMPTY) 84 | { 85 | count++; 86 | tmpreg = hspi->Instance->DR; 87 | UNUSED(tmpreg); /* To avoid GCC warning */ 88 | if (count == SPI_FIFO_SIZE) 89 | { 90 | return HAL_TIMEOUT; 91 | } 92 | } 93 | return HAL_OK; 94 | } 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | #endif /* HAL_SPI_MODULE_ENABLED */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/F070CB_ST7789_DMA.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | CAD.formats= 3 | CAD.pinconfig= 4 | CAD.provider= 5 | Dma.Request0=SPI1_TX 6 | Dma.RequestsNb=1 7 | Dma.SPI1_TX.0.Direction=DMA_MEMORY_TO_PERIPH 8 | Dma.SPI1_TX.0.Instance=DMA1_Channel3 9 | Dma.SPI1_TX.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD 10 | Dma.SPI1_TX.0.MemInc=DMA_MINC_ENABLE 11 | Dma.SPI1_TX.0.Mode=DMA_NORMAL 12 | Dma.SPI1_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD 13 | Dma.SPI1_TX.0.PeriphInc=DMA_PINC_DISABLE 14 | Dma.SPI1_TX.0.Priority=DMA_PRIORITY_HIGH 15 | Dma.SPI1_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority 16 | File.Version=6 17 | GPIO.groupedBy=Group By Peripherals 18 | KeepUserPlacement=false 19 | Mcu.CPN=STM32F070CBT6 20 | Mcu.Family=STM32F0 21 | Mcu.IP0=DMA 22 | Mcu.IP1=NVIC 23 | Mcu.IP2=RCC 24 | Mcu.IP3=SPI1 25 | Mcu.IP4=SYS 26 | Mcu.IPNb=5 27 | Mcu.Name=STM32F070CBTx 28 | Mcu.Package=LQFP48 29 | Mcu.Pin0=PA4 30 | Mcu.Pin1=PA5 31 | Mcu.Pin2=PA7 32 | Mcu.Pin3=PB2 33 | Mcu.Pin4=PA13 34 | Mcu.Pin5=PA14 35 | Mcu.Pin6=VP_SYS_VS_Systick 36 | Mcu.PinsNb=7 37 | Mcu.ThirdPartyNb=0 38 | Mcu.UserConstants= 39 | Mcu.UserName=STM32F070CBTx 40 | MxCube.Version=6.12.0 41 | MxDb.Version=DB.6.0.120 42 | NVIC.DMA1_Channel2_3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true 43 | NVIC.ForceEnableDMAVector=true 44 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 45 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 46 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 47 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true 48 | NVIC.SysTick_IRQn=true\:3\:0\:false\:false\:true\:false\:true\:false 49 | PA13.Mode=Serial_Wire 50 | PA13.Signal=SYS_SWDIO 51 | PA14.Locked=true 52 | PA14.Mode=Serial_Wire 53 | PA14.Signal=SYS_SWCLK 54 | PA4.GPIOParameters=GPIO_Speed,PinState,GPIO_Label 55 | PA4.GPIO_Label=LCD_RESET 56 | PA4.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM 57 | PA4.Locked=true 58 | PA4.PinState=GPIO_PIN_SET 59 | PA4.Signal=GPIO_Output 60 | PA5.Mode=TX_Only_Simplex_Unidirect_Master 61 | PA5.Signal=SPI1_SCK 62 | PA7.Mode=TX_Only_Simplex_Unidirect_Master 63 | PA7.Signal=SPI1_MOSI 64 | PB2.GPIOParameters=GPIO_Speed,GPIO_Label 65 | PB2.GPIO_Label=LCD_DC 66 | PB2.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM 67 | PB2.Locked=true 68 | PB2.Signal=GPIO_Output 69 | PinOutPanel.RotationAngle=0 70 | ProjectManager.AskForMigrate=true 71 | ProjectManager.BackupPrevious=false 72 | ProjectManager.CompilerOptimize=6 73 | ProjectManager.ComputerToolchain=false 74 | ProjectManager.CoupleFile=false 75 | ProjectManager.CustomerFirmwarePackage= 76 | ProjectManager.DefaultFWLocation=true 77 | ProjectManager.DeletePrevious=true 78 | ProjectManager.DeviceId=STM32F070CBTx 79 | ProjectManager.FirmwarePackage=STM32Cube FW_F0 V1.11.5 80 | ProjectManager.FreePins=true 81 | ProjectManager.HalAssertFull=false 82 | ProjectManager.HeapSize=0x200 83 | ProjectManager.KeepUserCode=true 84 | ProjectManager.LastFirmware=true 85 | ProjectManager.LibraryCopy=1 86 | ProjectManager.MainLocation=Core/Src 87 | ProjectManager.NoMain=false 88 | ProjectManager.PreviousToolchain=STM32CubeIDE 89 | ProjectManager.ProjectBuild=false 90 | ProjectManager.ProjectFileName=F070CB_ST7789.ioc 91 | ProjectManager.ProjectName=F070CB_ST7789 92 | ProjectManager.ProjectStructure= 93 | ProjectManager.RegisterCallBack= 94 | ProjectManager.StackSize=0x400 95 | ProjectManager.TargetToolchain=STM32CubeIDE 96 | ProjectManager.ToolChainLocation= 97 | ProjectManager.UAScriptAfterPath= 98 | ProjectManager.UAScriptBeforePath= 99 | ProjectManager.UnderRoot=true 100 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_SPI1_Init-SPI1-false-HAL-true 101 | RCC.AHBFreq_Value=48000000 102 | RCC.APB1Freq_Value=48000000 103 | RCC.APB1TimFreq_Value=48000000 104 | RCC.FCLKCortexFreq_Value=48000000 105 | RCC.FamilyName=M 106 | RCC.HCLKFreq_Value=48000000 107 | RCC.IPParameters=AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USART1Freq_Value,USBOutputFreqValue,VCOOutput2Freq_Value 108 | RCC.MCOFreq_Value=48000000 109 | RCC.PLLCLKFreq_Value=48000000 110 | RCC.PLLMCOFreq_Value=48000000 111 | RCC.PLLMUL=RCC_PLL_MUL6 112 | RCC.SYSCLKFreq_VALUE=48000000 113 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 114 | RCC.TimSysFreq_Value=48000000 115 | RCC.USART1Freq_Value=48000000 116 | RCC.USBOutputFreqValue=48000000 117 | RCC.VCOOutput2Freq_Value=8000000 118 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4 119 | SPI1.CLKPhase=SPI_PHASE_2EDGE 120 | SPI1.CLKPolarity=SPI_POLARITY_HIGH 121 | SPI1.CalculateBaudRate=12.0 MBits/s 122 | SPI1.DataSize=SPI_DATASIZE_8BIT 123 | SPI1.Direction=SPI_DIRECTION_2LINES 124 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,CLKPolarity,CLKPhase 125 | SPI1.Mode=SPI_MODE_MASTER 126 | SPI1.VirtualType=VM_MASTER 127 | VP_SYS_VS_Systick.Mode=SysTick 128 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 129 | board=custom 130 | -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/Release/F070CB_ST7789_DMA.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DmitryMuravyev/Delta-Compression/73aa6cec60975ad5c3fa254d52c63dc84176e8eb/Examples/STM32/F070CB_ST7789_DMA/Release/F070CB_ST7789_DMA.elf -------------------------------------------------------------------------------- /Examples/STM32/F070CB_ST7789_DMA/STM32F070CBTX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32F070CBTx Device from STM32F0 series 9 | ** 128KBytes FLASH 10 | ** 16KBytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is, without any warranty 20 | ** of any kind. 21 | ** 22 | ****************************************************************************** 23 | ** @attention 24 | ** 25 | ** Copyright (c) 2024 STMicroelectronics. 26 | ** All rights reserved. 27 | ** 28 | ** This software is licensed under terms that can be found in the LICENSE file 29 | ** in the root directory of this software component. 30 | ** If no LICENSE file comes with this software, it is provided AS-IS. 31 | ** 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Entry Point */ 36 | ENTRY(Reset_Handler) 37 | 38 | /* Highest address of the user mode stack */ 39 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 40 | 41 | _Min_Heap_Size = 0x200; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400; /* required amount of stack */ 43 | 44 | /* Memories definition */ 45 | MEMORY 46 | { 47 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K 48 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K 49 | } 50 | 51 | /* Sections */ 52 | SECTIONS 53 | { 54 | /* The startup code into "FLASH" Rom type memory */ 55 | .isr_vector : 56 | { 57 | . = ALIGN(4); 58 | KEEP(*(.isr_vector)) /* Startup code */ 59 | . = ALIGN(4); 60 | } >FLASH 61 | 62 | /* The program code and other data into "FLASH" Rom type memory */ 63 | .text : 64 | { 65 | . = ALIGN(4); 66 | *(.text) /* .text sections (code) */ 67 | *(.text*) /* .text* sections (code) */ 68 | *(.glue_7) /* glue arm to thumb code */ 69 | *(.glue_7t) /* glue thumb to arm code */ 70 | *(.eh_frame) 71 | 72 | KEEP (*(.init)) 73 | KEEP (*(.fini)) 74 | 75 | . = ALIGN(4); 76 | _etext = .; /* define a global symbols at end of code */ 77 | } >FLASH 78 | 79 | /* Constant data into "FLASH" Rom type memory */ 80 | .rodata : 81 | { 82 | . = ALIGN(4); 83 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 84 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 85 | . = ALIGN(4); 86 | } >FLASH 87 | 88 | .ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 89 | { 90 | . = ALIGN(4); 91 | *(.ARM.extab* .gnu.linkonce.armextab.*) 92 | . = ALIGN(4); 93 | } >FLASH 94 | 95 | .ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 96 | { 97 | . = ALIGN(4); 98 | __exidx_start = .; 99 | *(.ARM.exidx*) 100 | __exidx_end = .; 101 | . = ALIGN(4); 102 | } >FLASH 103 | 104 | .preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 105 | { 106 | . = ALIGN(4); 107 | PROVIDE_HIDDEN (__preinit_array_start = .); 108 | KEEP (*(.preinit_array*)) 109 | PROVIDE_HIDDEN (__preinit_array_end = .); 110 | . = ALIGN(4); 111 | } >FLASH 112 | 113 | .init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 114 | { 115 | . = ALIGN(4); 116 | PROVIDE_HIDDEN (__init_array_start = .); 117 | KEEP (*(SORT(.init_array.*))) 118 | KEEP (*(.init_array*)) 119 | PROVIDE_HIDDEN (__init_array_end = .); 120 | . = ALIGN(4); 121 | } >FLASH 122 | 123 | .fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 124 | { 125 | . = ALIGN(4); 126 | PROVIDE_HIDDEN (__fini_array_start = .); 127 | KEEP (*(SORT(.fini_array.*))) 128 | KEEP (*(.fini_array*)) 129 | PROVIDE_HIDDEN (__fini_array_end = .); 130 | . = ALIGN(4); 131 | } >FLASH 132 | 133 | /* Used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections into "RAM" Ram type memory */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | *(.RamFunc) /* .RamFunc sections */ 144 | *(.RamFunc*) /* .RamFunc* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM AT> FLASH 150 | 151 | /* Uninitialized data section into "RAM" Ram type memory */ 152 | . = ALIGN(4); 153 | .bss : 154 | { 155 | /* This is used by the startup in order to initialize the .bss section */ 156 | _sbss = .; /* define a global symbol at bss start */ 157 | __bss_start__ = _sbss; 158 | *(.bss) 159 | *(.bss*) 160 | *(COMMON) 161 | 162 | . = ALIGN(4); 163 | _ebss = .; /* define a global symbol at bss end */ 164 | __bss_end__ = _ebss; 165 | } >RAM 166 | 167 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 168 | ._user_heap_stack : 169 | { 170 | . = ALIGN(8); 171 | PROVIDE ( end = . ); 172 | PROVIDE ( _end = . ); 173 | . = . + _Min_Heap_Size; 174 | . = . + _Min_Stack_Size; 175 | . = ALIGN(8); 176 | } >RAM 177 | 178 | /* Remove information from the compiler libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | F407ZGT6_NT35510_FSMC_DMA 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | org.eclipse.cdt.core.cnature 24 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 25 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 28 | com.st.stm32cube.ide.mcu.MCURootProjectNature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | 32 | 33 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f4xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | 61 | /* USER CODE BEGIN Private defines */ 62 | 63 | /* USER CODE END Private defines */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __MAIN_H */ 70 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Core/Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F4xx_IT_H 22 | #define __STM32F4xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void MemManage_Handler(void); 52 | void BusFault_Handler(void); 53 | void UsageFault_Handler(void); 54 | void SVC_Handler(void); 55 | void DebugMon_Handler(void); 56 | void PendSV_Handler(void); 57 | void SysTick_Handler(void); 58 | void DMA2_Stream0_IRQHandler(void); 59 | /* USER CODE BEGIN EFP */ 60 | 61 | /* USER CODE END EFP */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __STM32F4xx_IT_H */ 68 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Core/Src/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f4xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | extern DMA_HandleTypeDef hdma_memtomem_dma2_stream0; 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles Non maskable interrupt. 68 | */ 69 | void NMI_Handler(void) 70 | { 71 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 72 | 73 | /* USER CODE END NonMaskableInt_IRQn 0 */ 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 75 | while (1) 76 | { 77 | } 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles Memory management fault. 98 | */ 99 | void MemManage_Handler(void) 100 | { 101 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 102 | 103 | /* USER CODE END MemoryManagement_IRQn 0 */ 104 | while (1) 105 | { 106 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 107 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 108 | } 109 | } 110 | 111 | /** 112 | * @brief This function handles Pre-fetch fault, memory access fault. 113 | */ 114 | void BusFault_Handler(void) 115 | { 116 | /* USER CODE BEGIN BusFault_IRQn 0 */ 117 | 118 | /* USER CODE END BusFault_IRQn 0 */ 119 | while (1) 120 | { 121 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 122 | /* USER CODE END W1_BusFault_IRQn 0 */ 123 | } 124 | } 125 | 126 | /** 127 | * @brief This function handles Undefined instruction or illegal state. 128 | */ 129 | void UsageFault_Handler(void) 130 | { 131 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 132 | 133 | /* USER CODE END UsageFault_IRQn 0 */ 134 | while (1) 135 | { 136 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 137 | /* USER CODE END W1_UsageFault_IRQn 0 */ 138 | } 139 | } 140 | 141 | /** 142 | * @brief This function handles System service call via SWI instruction. 143 | */ 144 | void SVC_Handler(void) 145 | { 146 | /* USER CODE BEGIN SVCall_IRQn 0 */ 147 | 148 | /* USER CODE END SVCall_IRQn 0 */ 149 | /* USER CODE BEGIN SVCall_IRQn 1 */ 150 | 151 | /* USER CODE END SVCall_IRQn 1 */ 152 | } 153 | 154 | /** 155 | * @brief This function handles Debug monitor. 156 | */ 157 | void DebugMon_Handler(void) 158 | { 159 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 160 | 161 | /* USER CODE END DebugMonitor_IRQn 0 */ 162 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 163 | 164 | /* USER CODE END DebugMonitor_IRQn 1 */ 165 | } 166 | 167 | /** 168 | * @brief This function handles Pendable request for system service. 169 | */ 170 | void PendSV_Handler(void) 171 | { 172 | /* USER CODE BEGIN PendSV_IRQn 0 */ 173 | 174 | /* USER CODE END PendSV_IRQn 0 */ 175 | /* USER CODE BEGIN PendSV_IRQn 1 */ 176 | 177 | /* USER CODE END PendSV_IRQn 1 */ 178 | } 179 | 180 | /** 181 | * @brief This function handles System tick timer. 182 | */ 183 | void SysTick_Handler(void) 184 | { 185 | /* USER CODE BEGIN SysTick_IRQn 0 */ 186 | 187 | /* USER CODE END SysTick_IRQn 0 */ 188 | HAL_IncTick(); 189 | /* USER CODE BEGIN SysTick_IRQn 1 */ 190 | 191 | /* USER CODE END SysTick_IRQn 1 */ 192 | } 193 | 194 | /******************************************************************************/ 195 | /* STM32F4xx Peripheral Interrupt Handlers */ 196 | /* Add here the Interrupt Handlers for the used peripherals. */ 197 | /* For the available peripheral interrupt handler names, */ 198 | /* please refer to the startup file (startup_stm32f4xx.s). */ 199 | /******************************************************************************/ 200 | 201 | /** 202 | * @brief This function handles DMA2 stream0 global interrupt. 203 | */ 204 | void DMA2_Stream0_IRQHandler(void) 205 | { 206 | /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ 207 | 208 | /* USER CODE END DMA2_Stream0_IRQn 0 */ 209 | HAL_DMA_IRQHandler(&hdma_memtomem_dma2_stream0); 210 | /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ 211 | 212 | /* USER CODE END DMA2_Stream0_IRQn 1 */ 213 | } 214 | 215 | /* USER CODE BEGIN 1 */ 216 | 217 | /* USER CODE END 1 */ 218 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2020-2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* Variables */ 35 | extern int __io_putchar(int ch) __attribute__((weak)); 36 | extern int __io_getchar(void) __attribute__((weak)); 37 | 38 | 39 | char *__env[1] = { 0 }; 40 | char **environ = __env; 41 | 42 | 43 | /* Functions */ 44 | void initialise_monitor_handles() 45 | { 46 | } 47 | 48 | int _getpid(void) 49 | { 50 | return 1; 51 | } 52 | 53 | int _kill(int pid, int sig) 54 | { 55 | (void)pid; 56 | (void)sig; 57 | errno = EINVAL; 58 | return -1; 59 | } 60 | 61 | void _exit (int status) 62 | { 63 | _kill(status, -1); 64 | while (1) {} /* Make sure we hang here */ 65 | } 66 | 67 | __attribute__((weak)) int _read(int file, char *ptr, int len) 68 | { 69 | (void)file; 70 | int DataIdx; 71 | 72 | for (DataIdx = 0; DataIdx < len; DataIdx++) 73 | { 74 | *ptr++ = __io_getchar(); 75 | } 76 | 77 | return len; 78 | } 79 | 80 | __attribute__((weak)) int _write(int file, char *ptr, int len) 81 | { 82 | (void)file; 83 | int DataIdx; 84 | 85 | for (DataIdx = 0; DataIdx < len; DataIdx++) 86 | { 87 | __io_putchar(*ptr++); 88 | } 89 | return len; 90 | } 91 | 92 | int _close(int file) 93 | { 94 | (void)file; 95 | return -1; 96 | } 97 | 98 | 99 | int _fstat(int file, struct stat *st) 100 | { 101 | (void)file; 102 | st->st_mode = S_IFCHR; 103 | return 0; 104 | } 105 | 106 | int _isatty(int file) 107 | { 108 | (void)file; 109 | return 1; 110 | } 111 | 112 | int _lseek(int file, int ptr, int dir) 113 | { 114 | (void)file; 115 | (void)ptr; 116 | (void)dir; 117 | return 0; 118 | } 119 | 120 | int _open(char *path, int flags, ...) 121 | { 122 | (void)path; 123 | (void)flags; 124 | /* Pretend like we always fail */ 125 | return -1; 126 | } 127 | 128 | int _wait(int *status) 129 | { 130 | (void)status; 131 | errno = ECHILD; 132 | return -1; 133 | } 134 | 135 | int _unlink(char *name) 136 | { 137 | (void)name; 138 | errno = ENOENT; 139 | return -1; 140 | } 141 | 142 | int _times(struct tms *buf) 143 | { 144 | (void)buf; 145 | return -1; 146 | } 147 | 148 | int _stat(char *file, struct stat *st) 149 | { 150 | (void)file; 151 | st->st_mode = S_IFCHR; 152 | return 0; 153 | } 154 | 155 | int _link(char *old, char *new) 156 | { 157 | (void)old; 158 | (void)new; 159 | errno = EMLINK; 160 | return -1; 161 | } 162 | 163 | int _fork(void) 164 | { 165 | errno = EAGAIN; 166 | return -1; 167 | } 168 | 169 | int _execve(char *name, char **argv, char **env) 170 | { 171 | (void)name; 172 | (void)argv; 173 | (void)env; 174 | errno = ENOMEM; 175 | return -1; 176 | } 177 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeIDE 5 | * @brief STM32CubeIDE System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f4xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F4XX_H 31 | #define __SYSTEM_STM32F4XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F4xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F4xx_System_Exported_types 47 | * @{ 48 | */ 49 | /* This variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32F4xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F4xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F4xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /*__SYSTEM_STM32F4XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Drivers/CMSIS/Device/ST/STM32F4xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.5 5 | * @date 02. February 2022 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2022 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_DMA_EX_H 21 | #define __STM32F4xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U /*!< Memory 1 */ 51 | }HAL_DMA_MemoryTypeDef; 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /* Exported functions --------------------------------------------------------*/ 58 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 59 | * @brief DMAEx Exported functions 60 | * @{ 61 | */ 62 | 63 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 64 | * @brief Extended features functions 65 | * @{ 66 | */ 67 | 68 | /* IO operation functions *******************************************************/ 69 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 70 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 71 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 72 | 73 | /** 74 | * @} 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /* Private functions ---------------------------------------------------------*/ 81 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 82 | * @brief DMAEx Private functions 83 | * @{ 84 | */ 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 102 | 103 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 20 | #define __STM32F4xx_FLASH_RAMFUNC_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 26 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FLASH_RAMFUNC 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported macro ------------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 43 | * @{ 44 | */ 45 | 46 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 47 | * @{ 48 | */ 49 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void); 50 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void); 51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void); 52 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void); 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | 75 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 76 | 77 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Drivers/STM32F4xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Release/F407ZGT6_NT35510_FSMC_DMA.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DmitryMuravyev/Delta-Compression/73aa6cec60975ad5c3fa254d52c63dc84176e8eb/Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/Release/F407ZGT6_NT35510_FSMC_DMA.elf -------------------------------------------------------------------------------- /Examples/STM32/F407ZGT6_NT35510_FSMC_DMA/STM32F407ZGTX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld (debug in RAM dedicated) 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32F407ZGTx Device from STM32F4 series 9 | ** 1024KBytes FLASH 10 | ** 64KBytes CCMRAM 11 | ** 128KBytes RAM 12 | ** 13 | ** Set heap size, stack size and stack location according 14 | ** to application requirements. 15 | ** 16 | ** Set memory bank area and size if external memory is used 17 | ** 18 | ** Target : STMicroelectronics STM32 19 | ** 20 | ** Distribution: The file is distributed as is, without any warranty 21 | ** of any kind. 22 | ** 23 | ****************************************************************************** 24 | ** @attention 25 | ** 26 | ** Copyright (c) 2024 STMicroelectronics. 27 | ** All rights reserved. 28 | ** 29 | ** This software is licensed under terms that can be found in the LICENSE file 30 | ** in the root directory of this software component. 31 | ** If no LICENSE file comes with this software, it is provided AS-IS. 32 | ** 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Entry Point */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Highest address of the user mode stack */ 40 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 41 | 42 | _Min_Heap_Size = 0x200; /* required amount of heap */ 43 | _Min_Stack_Size = 0x400; /* required amount of stack */ 44 | 45 | /* Memories definition */ 46 | MEMORY 47 | { 48 | CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K 49 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 50 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 51 | } 52 | 53 | /* Sections */ 54 | SECTIONS 55 | { 56 | /* The startup code into "RAM" Ram type memory */ 57 | .isr_vector : 58 | { 59 | . = ALIGN(4); 60 | KEEP(*(.isr_vector)) /* Startup code */ 61 | . = ALIGN(4); 62 | } >RAM 63 | 64 | /* The program code and other data into "RAM" Ram type memory */ 65 | .text : 66 | { 67 | . = ALIGN(4); 68 | *(.text) /* .text sections (code) */ 69 | *(.text*) /* .text* sections (code) */ 70 | *(.glue_7) /* glue arm to thumb code */ 71 | *(.glue_7t) /* glue thumb to arm code */ 72 | *(.eh_frame) 73 | *(.RamFunc) /* .RamFunc sections */ 74 | *(.RamFunc*) /* .RamFunc* sections */ 75 | 76 | KEEP (*(.init)) 77 | KEEP (*(.fini)) 78 | 79 | . = ALIGN(4); 80 | _etext = .; /* define a global symbols at end of code */ 81 | } >RAM 82 | 83 | /* Constant data into "RAM" Ram type memory */ 84 | .rodata : 85 | { 86 | . = ALIGN(4); 87 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 88 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 89 | . = ALIGN(4); 90 | } >RAM 91 | 92 | .ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 93 | { 94 | . = ALIGN(4); 95 | *(.ARM.extab* .gnu.linkonce.armextab.*) 96 | . = ALIGN(4); 97 | } >RAM 98 | 99 | .ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 100 | { 101 | . = ALIGN(4); 102 | __exidx_start = .; 103 | *(.ARM.exidx*) 104 | __exidx_end = .; 105 | . = ALIGN(4); 106 | } >RAM 107 | 108 | .preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 109 | { 110 | . = ALIGN(4); 111 | PROVIDE_HIDDEN (__preinit_array_start = .); 112 | KEEP (*(.preinit_array*)) 113 | PROVIDE_HIDDEN (__preinit_array_end = .); 114 | . = ALIGN(4); 115 | } >RAM 116 | 117 | .init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 118 | { 119 | . = ALIGN(4); 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | . = ALIGN(4); 125 | } >RAM 126 | 127 | .fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ 128 | { 129 | . = ALIGN(4); 130 | PROVIDE_HIDDEN (__fini_array_start = .); 131 | KEEP (*(SORT(.fini_array.*))) 132 | KEEP (*(.fini_array*)) 133 | PROVIDE_HIDDEN (__fini_array_end = .); 134 | . = ALIGN(4); 135 | } >RAM 136 | 137 | /* Used by the startup to initialize data */ 138 | _sidata = LOADADDR(.data); 139 | 140 | /* Initialized data sections into "RAM" Ram type memory */ 141 | .data : 142 | { 143 | . = ALIGN(4); 144 | _sdata = .; /* create a global symbol at data start */ 145 | *(.data) /* .data sections */ 146 | *(.data*) /* .data* sections */ 147 | 148 | . = ALIGN(4); 149 | _edata = .; /* define a global symbol at data end */ 150 | 151 | } >RAM 152 | 153 | _siccmram = LOADADDR(.ccmram); 154 | 155 | /* CCM-RAM section 156 | * 157 | * IMPORTANT NOTE! 158 | * If initialized variables will be placed in this section, 159 | * the startup code needs to be modified to copy the init-values. 160 | */ 161 | .ccmram : 162 | { 163 | . = ALIGN(4); 164 | _sccmram = .; /* create a global symbol at ccmram start */ 165 | *(.ccmram) 166 | *(.ccmram*) 167 | 168 | . = ALIGN(4); 169 | _eccmram = .; /* create a global symbol at ccmram end */ 170 | } >CCMRAM AT> RAM 171 | 172 | /* Uninitialized data section into "RAM" Ram type memory */ 173 | . = ALIGN(4); 174 | .bss : 175 | { 176 | /* This is used by the startup in order to initialize the .bss section */ 177 | _sbss = .; /* define a global symbol at bss start */ 178 | __bss_start__ = _sbss; 179 | *(.bss) 180 | *(.bss*) 181 | *(COMMON) 182 | 183 | . = ALIGN(4); 184 | _ebss = .; /* define a global symbol at bss end */ 185 | __bss_end__ = _ebss; 186 | } >RAM 187 | 188 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 189 | ._user_heap_stack : 190 | { 191 | . = ALIGN(8); 192 | PROVIDE ( end = . ); 193 | PROVIDE ( _end = . ); 194 | . = . + _Min_Heap_Size; 195 | . = . + _Min_Stack_Size; 196 | . = ALIGN(8); 197 | } >RAM 198 | 199 | /* Remove information from the compiler libraries */ 200 | /DISCARD/ : 201 | { 202 | libc.a ( * ) 203 | libm.a ( * ) 204 | libgcc.a ( * ) 205 | } 206 | 207 | .ARM.attributes 0 : { *(.ARM.attributes) } 208 | } 209 | -------------------------------------------------------------------------------- /FileDataChannel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Diagnostics; 30 | using System.Linq; 31 | using System.Text; 32 | using System.Threading.Tasks; 33 | using System.Windows.Media; 34 | 35 | namespace DeltaComp 36 | { 37 | // The class is designed to represent raw file data as a stream 38 | // of alternating channels (color components/audio channels etc.) 39 | public class FileDataChannel : Channel 40 | { 41 | //////////////////////////////////////////////////////////////////////////////////////////////////// 42 | // Private attributes/variables 43 | //////////////////////////////////////////////////////////////////////////////////////////////////// 44 | 45 | // Source data 46 | private FileDataSource _source; 47 | 48 | // Channel index in frame 49 | private readonly int _channelIndex = 0; 50 | 51 | 52 | //////////////////////////////////////////////////////////////////////////////////////////////////// 53 | // Implementation 54 | //////////////////////////////////////////////////////////////////////////////////////////////////// 55 | 56 | // Constructor 57 | public FileDataChannel(FileDataSource theSource, int index) 58 | { 59 | Trace.Assert((theSource != null) && (index >= 0)); 60 | 61 | // Init base variables 62 | _source = theSource; 63 | _channelIndex = index; 64 | ChannelType = ChannelType.Data; 65 | UpdateBitDepth(); 66 | } 67 | 68 | 69 | // Destructor 70 | /* 71 | ~CustomDataChannel() 72 | { 73 | } 74 | */ 75 | 76 | 77 | // Calculate channel bit depth 78 | public void UpdateBitDepth() 79 | { 80 | BitsPerChannel = _source.BytesPerChannel << 3; 81 | BitDepthList = new List { BitsPerChannel }; 82 | TargetBitDepth = BitsPerChannel; 83 | } 84 | 85 | 86 | // Base class method's implementation 87 | public override UInt32 GetOriginalValueForFrame(int frameNumber) 88 | { 89 | return (_source.GetFrameForChannel(frameNumber, _channelIndex)); 90 | } 91 | 92 | 93 | // And another one 94 | public override UInt32 GetTargetValueForFrame(int frameNumber) 95 | { 96 | return (GetOriginalValueForFrame(frameNumber)); 97 | } 98 | 99 | } 100 | } 101 | 102 | // END-OF-FILE 103 | -------------------------------------------------------------------------------- /FilePreviewDestination.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Text; 31 | using System.Threading.Tasks; 32 | using System.Diagnostics; 33 | using System.Windows.Controls; 34 | using System.Reflection; 35 | 36 | namespace DeltaComp 37 | { 38 | // The class generates a text representation of streaming data 39 | // divided into frames and channels in each frame. 40 | // The text is displayed in the textbox. 41 | public class FilePreviewDestination : PreviewDestination 42 | { 43 | //////////////////////////////////////////////////////////////////////////////////////////////////// 44 | // Private attributes/variables 45 | //////////////////////////////////////////////////////////////////////////////////////////////////// 46 | 47 | // Some static constants 48 | private static class Constants 49 | { 50 | // The approximate line height for the 12pt Courier New font. 51 | public const double DefaultLineHeight = 13.6d; 52 | } 53 | 54 | // Source and destination 55 | private readonly List _sourceChannels; 56 | private readonly FileDataSource _fileDataSource; 57 | private readonly TextBox _textBox; 58 | 59 | 60 | //////////////////////////////////////////////////////////////////////////////////////////////////// 61 | // Implementation 62 | //////////////////////////////////////////////////////////////////////////////////////////////////// 63 | 64 | // Constructor 65 | public FilePreviewDestination(List sourceChannels, FileDataSource fileDataSource, TextBox textBox) 66 | { 67 | Trace.Assert((sourceChannels != null) && (textBox != null)); 68 | 69 | // Init base variables 70 | _sourceChannels = sourceChannels; 71 | _fileDataSource = fileDataSource; 72 | _textBox = textBox; 73 | //UpdatePreview(); // There's no need to do it immediately 74 | } 75 | 76 | 77 | // Destructor 78 | /* 79 | ~PreviewDataDestination() 80 | { 81 | } 82 | */ 83 | 84 | 85 | // Update the preview TextBox according to the bit depth of channels. 86 | public override void UpdatePreview() 87 | { 88 | _textBox.Text = ""; 89 | int currentFrame = 0; 90 | 91 | // Since the LineHeight is a private method of TextBox, 92 | // let's apply some undocumented magic... 93 | MethodInfo? method = _textBox.GetType().GetMethod("GetLineHeight", BindingFlags.NonPublic | BindingFlags.Instance); 94 | object? value = method?.Invoke(_textBox, null); 95 | double lineHeight = (value != null) ? (double)value : Constants.DefaultLineHeight; 96 | int visibleLines = (int)Math.Truncate(_textBox.ActualHeight / lineHeight); 97 | int totalFrames = _fileDataSource.FramesCount; 98 | 99 | // Fill our preview TextBox only to the height of the visible lines 100 | while ((currentFrame < totalFrames) && (_textBox.LineCount < visibleLines)) 101 | { 102 | string frameString = ""; 103 | for (int i = 0; i < _sourceChannels.Count; i++) 104 | { 105 | Channel channel = _sourceChannels[i]; 106 | string channelValuePreviewFormat; 107 | 108 | if (channel.TargetBitDepth <= 8) 109 | { 110 | channelValuePreviewFormat = "0x{0:X2}"; 111 | } 112 | else if (channel.TargetBitDepth <= 16) 113 | { 114 | channelValuePreviewFormat = "0x{0:X4}"; 115 | } 116 | else if (channel.TargetBitDepth <= 24) 117 | { 118 | channelValuePreviewFormat = "0x{0:X6}"; 119 | } 120 | else 121 | { 122 | channelValuePreviewFormat = "0x{0:X8}"; 123 | } 124 | 125 | if (i != 0) frameString += "\u00A0"; // "\xA0" - non-breaking space 126 | frameString += String.Format(channelValuePreviewFormat, channel.GetTargetValueForFrame(currentFrame)); 127 | 128 | } 129 | 130 | frameString += "; "; // Regular space for wrapping by frames (not by channels) 131 | _textBox.AppendText(frameString); 132 | 133 | currentFrame++; 134 | } 135 | 136 | if (currentFrame < totalFrames) _textBox.AppendText("..."); 137 | 138 | } 139 | } 140 | } 141 | 142 | // END-OF-FILE 143 | -------------------------------------------------------------------------------- /GrayscaleMixerChannel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Diagnostics; 30 | using System.Linq; 31 | using System.Text; 32 | using System.Threading.Tasks; 33 | using System.Windows.Media; 34 | 35 | namespace DeltaComp 36 | { 37 | // A class that converts three R/G/B channels to a Grayscale channel 38 | // (I didn't like how FormatConvertedBitmap does it). 39 | internal class GrayscaleMixerChannel : Channel 40 | { 41 | //////////////////////////////////////////////////////////////////////////////////////////////////// 42 | // Private attributes/variables 43 | //////////////////////////////////////////////////////////////////////////////////////////////////// 44 | 45 | // Grayscale conversion coefficients (I prefer the first set, but you 46 | // can use the second one, which takes into account gamma compression). 47 | // Coefficients declared in the same order as in ChannelType enum (Channel class). 48 | private static readonly double[] _coefficients = [ 0.2126f, 0.7152f, 0.0722f ]; 49 | //private static readonly double[] _coefficients = [ 0.299f, 0.587f, 0.114f ]; 50 | 51 | // List of source RGB channels 52 | private readonly List _sourceChannels; 53 | 54 | // Target Grayscale pixel format 55 | private readonly PixelFormat _targetPixelFormat; 56 | 57 | 58 | //////////////////////////////////////////////////////////////////////////////////////////////////// 59 | // Implementation 60 | //////////////////////////////////////////////////////////////////////////////////////////////////// 61 | 62 | // Constructor 63 | public GrayscaleMixerChannel(List sourceChannels, PixelFormat targetPixelFormat) 64 | { 65 | // Some Assertions to check if all ok. 66 | Trace.Assert(sourceChannels.Count >= 3, "GrayscaleMixerChannel, wrong channels count: " + 67 | sourceChannels.Count.ToString()); 68 | 69 | Trace.Assert( (targetPixelFormat == PixelFormats.BlackWhite) || 70 | (targetPixelFormat == PixelFormats.Gray2) || 71 | (targetPixelFormat == PixelFormats.Gray4) || 72 | (targetPixelFormat == PixelFormats.Gray8) || 73 | (targetPixelFormat == PixelFormats.Gray16), 74 | "GrayscaleMixerChannel, wrong pixel format: " + targetPixelFormat.ToString()); 75 | 76 | // Init base variables 77 | ChannelType = ChannelType.Grayscale; 78 | _sourceChannels = sourceChannels; 79 | _targetPixelFormat = targetPixelFormat; 80 | BitsPerChannel = _targetPixelFormat.BitsPerPixel; // We can use BitsPerPixel attribute because 81 | // there's only 1 channel in Grayscale. 82 | 83 | // Init UI properties 84 | BitDepthList = Enumerable.Range(1, BitsPerChannel).Select(i => (int)i).ToList(); 85 | TargetBitDepth = BitsPerChannel; 86 | } 87 | 88 | 89 | // Destructor 90 | /* 91 | ~GrayscaleMixerChannel() 92 | { 93 | } 94 | */ 95 | 96 | 97 | // Base class method's implementation 98 | public override UInt32 GetOriginalValueForFrame(int frameNumber) 99 | { 100 | double value = 0; 101 | foreach (ColorComponentChannel cc in _sourceChannels) 102 | { 103 | value += (_coefficients[(int)cc.ChannelType] * cc.GetFloatValueForFrame(frameNumber)); 104 | } 105 | 106 | return ((UInt32)Math.Round(value * GetMaxNumberForBitDepth(BitsPerChannel))); 107 | } 108 | 109 | 110 | } 111 | } 112 | 113 | // END-OF-FILE 114 | -------------------------------------------------------------------------------- /Header_Source.xml: -------------------------------------------------------------------------------- 1 |  2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | IMAGE_WIDTH 22 | / 23 | SQUARE_SIDE 24 | 25 | 26 | IMAGE_WIDTH 27 | * 28 | SQUARE_SIDE 29 | 30 | 31 | 32 | 33 | 34 | NUMBER_OF_CHANNELS 35 | BITS_PER_CHANNELS 36 | BLOCK_SIZE_BITS 37 | BITS_PER_METHOD_DECLARATION 38 | BITS_PER_FRAME 39 | 40 | SPLIT_TO_SQUARES 41 | IMAGE_WIDTH 42 | SQUARE_SIDE 43 | SQUARES_PER_WIDTH 44 | SQUARES_PER_WIDTH_SIZE 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
-------------------------------------------------------------------------------- /Header_Transformation.xslt: -------------------------------------------------------------------------------- 1 |  2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | // 20 | // Includes 21 | 22 | #include 23 | 24 | 25 | 26 | // definitions (you can get rid of this section if all other packaged data have the same parameters) 27 | 28 | 29 | 30 | #define _ 31 | 32 | 33 | 34 | _ 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | #define _ 45 | // 46 | 47 | 48 | 49 | 50 | 51 | 52 | // A set of constants defining the initial conditions for decompression 53 | 54 | static const = { 55 | }; 56 | 57 | 58 | 59 | // End of definitions 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | _, 68 | 69 | 70 | 71 | #if !defined() 72 | #endif 73 | 74 | 75 | 82 | 83 | 84 | 85 | 86 | static const [] PROGMEM = 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PreviewDestination.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | MIT License 4 | 5 | Copyright (c) 2024 Dmitry Muravyev (youtube.com/@DmitryMuravyev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Text; 31 | using System.Threading.Tasks; 32 | 33 | namespace DeltaComp 34 | { 35 | // An abstract class representing a data destination for previewing various data types. 36 | public abstract class PreviewDestination 37 | { 38 | //////////////////////////////////////////////////////////////////////////////////////////////////// 39 | // Public attributes/methods 40 | //////////////////////////////////////////////////////////////////////////////////////////////////// 41 | 42 | // An abstract method for updating UI preview element or its data source. 43 | public abstract void UpdatePreview(); 44 | 45 | } 46 | } 47 | 48 | // END-OF-FILE 49 | -------------------------------------------------------------------------------- /Release/DeltaComp.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeTarget": { 3 | "name": ".NETCoreApp,Version=v8.0", 4 | "signature": "" 5 | }, 6 | "compilationOptions": {}, 7 | "targets": { 8 | ".NETCoreApp,Version=v8.0": { 9 | "DeltaComp/1.0.0": { 10 | "runtime": { 11 | "DeltaComp.dll": {} 12 | } 13 | } 14 | } 15 | }, 16 | "libraries": { 17 | "DeltaComp/1.0.0": { 18 | "type": "project", 19 | "serviceable": false, 20 | "sha512": "" 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Release/DeltaComp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DmitryMuravyev/Delta-Compression/73aa6cec60975ad5c3fa254d52c63dc84176e8eb/Release/DeltaComp.dll -------------------------------------------------------------------------------- /Release/DeltaComp.dll.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 104857600 12 | 13 | 14 | AVR,STM32,ESP32 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Release/DeltaComp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DmitryMuravyev/Delta-Compression/73aa6cec60975ad5c3fa254d52c63dc84176e8eb/Release/DeltaComp.exe -------------------------------------------------------------------------------- /Release/DeltaComp.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DmitryMuravyev/Delta-Compression/73aa6cec60975ad5c3fa254d52c63dc84176e8eb/Release/DeltaComp.pdb -------------------------------------------------------------------------------- /Release/DeltaComp.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "net8.0", 4 | "frameworks": [ 5 | { 6 | "name": "Microsoft.NETCore.App", 7 | "version": "8.0.0" 8 | }, 9 | { 10 | "name": "Microsoft.WindowsDesktop.App", 11 | "version": "8.0.0" 12 | } 13 | ], 14 | "configProperties": { 15 | "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, 16 | "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Release/Header_Source.xml: -------------------------------------------------------------------------------- 1 |  2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | IMAGE_WIDTH 22 | / 23 | SQUARE_SIDE 24 | 25 | 26 | IMAGE_WIDTH 27 | * 28 | SQUARE_SIDE 29 | 30 | 31 | 32 | 33 | 34 | NUMBER_OF_CHANNELS 35 | BITS_PER_CHANNELS 36 | BLOCK_SIZE_BITS 37 | BITS_PER_METHOD_DECLARATION 38 | BITS_PER_FRAME 39 | 40 | SPLIT_TO_SQUARES 41 | IMAGE_WIDTH 42 | SQUARE_SIDE 43 | SQUARES_PER_WIDTH 44 | SQUARES_PER_WIDTH_SIZE 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
-------------------------------------------------------------------------------- /Release/Header_Transformation.xslt: -------------------------------------------------------------------------------- 1 |  2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | // 20 | // Includes 21 | 22 | #include 23 | 24 | 25 | 26 | // definitions (you can get rid of this section if all other packaged data have the same parameters) 27 | 28 | 29 | 30 | #define _ 31 | 32 | 33 | 34 | _ 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | #define _ 45 | // 46 | 47 | 48 | 49 | 50 | 51 | 52 | // A set of constants defining the initial conditions for decompression 53 | 54 | static const = { 55 | }; 56 | 57 | 58 | 59 | // End of definitions 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | _, 68 | 69 | 70 | 71 | #if !defined() 72 | #endif 73 | 74 | 75 | 82 | 83 | 84 | 85 | 86 | static const [] PROGMEM = 87 | 88 | 89 | 90 | --------------------------------------------------------------------------------