Skip to content

Commit

Permalink
Feat: Enable TouchGFX and add test button
Browse files Browse the repository at this point in the history
TODO: Forward touch data
  • Loading branch information
qqq89513 committed Jan 3, 2021
1 parent 77154cd commit e00792b
Show file tree
Hide file tree
Showing 574 changed files with 104,854 additions and 49 deletions.
113 changes: 104 additions & 9 deletions .cproject

Large diffs are not rendered by default.

73 changes: 46 additions & 27 deletions .mxproject

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<nature>com.st.stm32cube.ide.mcu.MCURootProjectNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
</natures>
</projectDescription>
4 changes: 2 additions & 2 deletions .settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="142380509657301636" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="22156171628728075" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -18,7 +18,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="142380509657301636" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="22156171628728075" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
16 changes: 7 additions & 9 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "app_touchgfx.h"
#include "usb_device.h"

/* Private includes ----------------------------------------------------------*/
Expand Down Expand Up @@ -174,7 +175,12 @@ int main(void)
MX_TIM12_Init();
MX_USART1_UART_Init();
MX_USB_DEVICE_Init();
MX_TouchGFX_Init();
/* USER CODE BEGIN 2 */
if(BSP_SDRAM_Init() == SDRAM_OK)
printf("SDRAM Initialized.\r\n");
else
printf("SDRAM Init failed. @line:%d\r\n", __LINE__);
printf("MX initialized.\r\n");
printf("Initializing BSP...\r\n");

Expand All @@ -184,15 +190,6 @@ int main(void)
// else
// printf("BSP_AUDIO failed to initailized. @line:%d\r\n", __LINE__);

// BSP LCD initialization
BSP_LCD_Init();
BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
BSP_LCD_SelectLayer(0);
BSP_LCD_Clear(LCD_COLOR_BLACK);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
BSP_LCD_SetFont(&Font12);

// BSP touch screen initializtion
BSP_TS_Init(LCD_MAX_X, LCD_MAX_Y);

Expand All @@ -205,6 +202,7 @@ int main(void)
{
/* USER CODE END WHILE */

MX_TouchGFX_Process();
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
Expand Down
227 changes: 227 additions & 0 deletions Middlewares/ST/touchgfx/framework/include/common/AbstractPartition.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
/**
******************************************************************************
* This file is part of the TouchGFX 4.15.0 distribution.
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/

/**
* @file common/AbstractPartition.hpp
*
* Declares the touchgfx::AbstractPartition class.
*/
#ifndef ABSTRACTPARTITION_HPP
#define ABSTRACTPARTITION_HPP

#include <touchgfx/hal/Types.hpp>

namespace touchgfx
{
/**
* This type defines an abstract interface to a storage partition for allocating memory slots of
* equal size. The "partition" is not aware of the actual types stored in the partition
* memory, hence it provides no mechanism for deleting C++ objects when clear()'ed.
*/
class AbstractPartition
{
public:
/** Finalizes an instance of the AbstractPartition class. */
virtual ~AbstractPartition();

/**
* Gets the address of the next available storage slot. The slot size is compared with
* the specified size.
*
* @param size The size.
*
* @return The address of an empty storage slot which contains minimum 'size' bytes.
*
* @note Asserts if 'size' is too large, or the storage is depleted.
*/
virtual void* allocate(uint16_t size);

/**
* Gets the address of the specified index.
*
* @param index Zero-based index of the.
* @param size The size.
*
* @return The address of the appropriate storage slot which contains minimum 'size'
* bytes.
*
* @note Asserts if 'size' is too large.
*/
virtual void* allocateAt(uint16_t index, uint16_t size);

/**
* Gets allocation count.
*
* @return The currently allocated storage slots.
*/
virtual uint16_t getAllocationCount() const;

/**
* Determines index of previously allocated location. Since the Partition concept is
* loosely typed this method shall be used with care. The method does not guarantee that
* the found object at the returned index is a valid object. It only tests whether or
* not the object is within the bounds of the current partition allocations.
*
* @param address The location address to lookup.
*
* @return An uint16_t.
*/
virtual uint16_t indexOf(const void* address);

/**
* Prepares the Partition for new allocations. Any objects present in the Partition
* shall not be used after invoking this method.
*/
virtual void clear();

/**
* Gets the capacity, i.e. the maximum allocation count.
*
* @return The maximum allocation count.
*/
virtual uint16_t capacity() const = 0;

/**
* Gets the address of the next available storage slot. The slot size is determined from
* the size of type T.
*
* @tparam T Generic type parameter.
*
* @return The address of an empty storage slot.
*
* @note Asserts if T is too large, or the storage is depleted.
*/
template <typename T>
void* allocate()
{
return allocate(static_cast<uint16_t>(sizeof(T)));
}

/**
* Gets the address of the specified storage slot. The slot size is determined from the
* size of type T.
*
* @tparam T Generic type parameter.
* @param index Zero-based index of the.
*
* @return The address of the appropriate storage slot.
*
* @note Asserts if T is too large.
*/
template <typename T>
void* allocateAt(uint16_t index)
{
return allocateAt(index, static_cast<uint16_t>(sizeof(T)));
}

/**
* Gets the object at the specified index.
*
* @tparam T Generic type parameter.
* @param index The index into the Partition storage where the returned object is located.
*
* @return A typed reference to the object at the specified index.
*/
template <typename T>
T& at(const uint16_t index)
{
return *static_cast<T*>(element(index));
}

/**
* const version of at().
*
* @tparam T Generic type parameter.
* @param index Zero-based index of the.
*
* @return A T&amp;
*/
template <typename T>
const T& at(const uint16_t index) const
{
return *static_cast<const T*>(element(index));
}

/**
* Determines if the specified object could have been previously allocated in the
* partition. Since the Partition concept is loosely typed this method shall be used
* with care. The method does not guarantee that the found object at the returned index
* is a valid object. It only tests whether or not the object is within the bounds of
* the current partition allocations.
*
* @tparam T Generic type parameter.
* @param pT Pointer to the object to look up.
*
* @return If the object seems to be allocated in the Partition, a Pair object
* containing a typed pointer to the object and an index into the Partition
* storage is returned. Otherwise, a Pair<0, 0> is returned.
*/
template <class T>
Pair<T*, uint16_t> find(const void* pT)
{
uint16_t index = indexOf(pT);
if (0 < getAllocationCount() && index < getAllocationCount())
{
return Pair<T*, uint16_t>(&at<T>(index), index);
}

return Pair<T*, uint16_t>(0, (uint16_t) -1);
}

/** Decreases number of allocations. */
void dec()
{
if (allocations)
{
allocations--;
}
}

/**
* Access to concrete element-size. Used internally.
*
* @return An uint32_t.
*/
virtual uint32_t element_size() = 0;

protected:
/**
* Access to stored element. Used internally.
*
* @param index Zero-based index of the.
*
* @return null if it fails, else a void*.
*/
virtual void* element(uint16_t index) = 0;

/**
* Access to stored element, const version.
*
* @param index Zero-based index of the.
*
* @return null if it fails, else a void*.
*/
virtual const void* element(uint16_t index) const = 0;

/** Initializes a new instance of the AbstractPartition class. */
AbstractPartition();

private:
uint16_t allocations;
};

} // namespace touchgfx

#endif // ABSTRACTPARTITION_HPP
Loading

0 comments on commit e00792b

Please sign in to comment.