环境监测终端
作者:John
- 作品简介(100-200字)
- (设计名称、作品照片、功能介绍等。)
本项目为环境监测终端,可以监测当前环境空气质量、温湿度等数据,可以作为无尘车间监控设备,本产品可连接服务器将监控数据发送到后台。本产品由10.1寸全贴合触摸屏、STM32F7系列微控制器、以太网、RS485、无线传输模块组成,所有配置操作做都可以通过触摸屏实现,并实时显示时钟、监控0.5um、5um粒子数量,当粒子数超标时会显示红色,同时可以显示温湿度度值,根据温度湿度值显示对应颜色,本产品可接三路传感器实现三路数据监测。
- 硬件框图
- 软件框图
应用层
|
显示任务、RTC任务、sensor任务、Touch任务
|
中间层、协议
|
Jason、TouchGFX、Modebus、Socket
|
操作系统层
|
FreeRTOS
|
硬件驱动层
|
LCD驱动、RTC驱动、I2C驱动、UART驱动、PWM驱动、GPIO驱动
|
三、各部分功能说明(图文结合)
(各部分实现的功能说明及讲解,以图文结合的展示。)
- 实时时钟,显示当前时钟
- 传感器状态,待机、工作、离线三种状态
- 粒子计数,单位为浓度/ft3,显示0.5um和5.0um粒子计数数量
- 温度显示,显示实时采集温度值
- 湿度显示,显示实时采集湿度值
- 数据同步按钮,按下同步按钮立即采集粒子传感器数据
- 设置传感器地址,可设置本机地址,可连接多个终端到系统中
- 设置传感器寻址,一个主机可以连接6个传感器,可以配置开启或关闭。
int main(void){
/* USER CODE BEGIN 1 */
uint32_t i=0,temp;
uint16_t index;
__IO uint8_t step = 0,Spi_Flag;
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CRC_Init();
// MX_I2C4_Init();
MX_QUADSPI_Init();
MX_TIM3_Init();
//MX_UART4_Init();
//MX_UART5_Init();
//HAL_UART_Receive_IT(&huart5,(uint8_t*)aRxBuffer5,1);
//MX_USART1_UART_Init();
//MX_USART3_UART_Init();
MX_DMA2D_Init();
MX_FMC_Init();
BSP_SDRAM_Initialization_Sequence(&hsdram1, &command);
MX_LTDC_Init();
MX_TIM7_Init();
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_3, GPIO_PIN_SET);
BSP_QSPI_Init();
RTC_Init_All();
//RGB_SPI_Init();
RGB_SPI_Init021();
BSP_SD_Init();
HAL_Delay(300);
//BSP_LCD_LayerRgb565Init(LTDC_ACTIVE_LAYER, SDRAM_DEVICE_ADDR);
//Display_DemoDescription();
OpenSDCard();
Findallascfile();
Can_init(0);
//printf("Flash operation Start¡£¡£¡£¡£¡£¡\\r\n");
BSP_QSPI_EnableMemoryMappedMode();
GRAPHICS_Init();
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 10*1024);//4096);
/* xTaskCreate( uSDTask, "uSDTask",
4096,
NULL,
osPriorityNormal - 1,
NULL);*/
xTaskCreate( RTCTask, "RTCTask",
256,
NULL,
osPriorityBelowNormal,
NULL);
xTaskCreate( CANTask, "CANTask",
256,
NULL,
osPriorityRealtime,//osPriorityHigh,
NULL);
//osPriorityNormal osPriorityHigh
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
osKernelStart();
/* USER CODE BEGIN WHILE */
while (1)
{
}
/* USER CODE END 3 */
#include "stm32f7xx_it.h"
#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"
#include "rtc.h"
#include "main.h"
//////////////////////////////////////////////////////////////////////////////////
unsigned char DataStr[]=__DATE__;
unsigned char TimeStr[]=__TIME__;
RTC_HandleTypeDef RTC_Handler; //RTC¾ä±ú
RTC_TimeTypeDef Displytime;
RTC_DateTypeDef Displydatat;
uint8_t CompanyDispFlag;
char* Month[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug","Sep","Oct","Nov","Dec" };
static const char * getWeekdayBybin(uint8_t iWeekDay )
{
if(iWeekDay != 0 && iWeekDay < 8)
{
switch(iWeekDay )
{
case 7 : return "Sun"; break;
case 1 : return "Mon"; break;
case 2 : return "Tue"; break;
case 3 : return "Wed"; break;
case 4 : return "Thu"; break;
case 5 : return "Fri"; break;
case 6 : return "Sat"; break;
default : return NULL; break;
}
}
return NULL;
}
static const char * getMonthBybin(uint8_t MonthDade )
{
if(MonthDade != 0 && MonthDade < 13)
{
return Month[MonthDade-1];
}
return NULL;
}
static const char * getampmBybin(uint8_t ampmdata )
{
switch(ampmdata )
{
case RTC_HOURFORMAT12_PM : return "pm"; break;
case RTC_HOURFORMAT12_AM : return "am"; break;
default : return NULL; break;
}
return NULL;
}
//RTCʱ¼äÉèÖÃ
//hour,min,sec:Сʱ,·ÖÖÓ,ÃëÖÓ
//ampm:@RTC_AM_PM_Definitions:RTC_HOURFORMAT12_AM/RTC_HOURFORMAT12_PM
//·µ»ØÖµ:SUCEE(1),³É¹¦
// ERROR(0),½øÈë³õʼ»¯Ä£Ê½Ê§°Ü
HAL_StatusTypeDef RTC_Set_Time(uint8_t hour,uint8_t min,uint8_t sec,uint8_t ampm)
{
RTC_TimeTypeDef RTC_TimeStructure;
RTC_TimeStructure.Hours=hour;
RTC_TimeStructure.Minutes=min;
RTC_TimeStructure.Seconds=sec;
RTC_TimeStructure.TimeFormat=ampm;
RTC_TimeStructure.DayLightSaving=RTC_DAYLIGHTSAVING_NONE;
RTC_TimeStructure.StoreOperation=RTC_STOREOPERATION_RESET;
return HAL_RTC_SetTime(&RTC_Handler,&RTC_TimeStructure,RTC_FORMAT_BIN);
}
//RTCÈÕÆÚÉèÖÃ
//year,month,date:Äê(0~99),ÔÂ(1~12),ÈÕ(0~31)
//week:ÐÇÆÚ(1~7,0,·Ç·¨!)
//·µ»ØÖµ:SUCEE(1),³É¹¦
// ERROR(0),½øÈë³õʼ»¯Ä£Ê½Ê§°Ü
HAL_StatusTypeDef RTC_Set_Date(uint8_t year,uint8_t month,uint8_t date,uint8_t week)
{
RTC_DateTypeDef RTC_DateStructure;
RTC_DateStructure.Date=date;
RTC_DateStructure.Month=month;
RTC_DateStructure.WeekDay=week;
RTC_DateStructure.Year=year;
return HAL_RTC_SetDate(&RTC_Handler,&RTC_DateStructure,RTC_FORMAT_BIN);
}
//RTC³õʼ»¯
//·µ»ØÖµ:0,³õʼ»¯³É¹¦;
// 2,½øÈë³õʼ»¯Ä£Ê½Ê§°Ü;
uint8_t RTC_Init(void)
{
RTC_Handler.Instance=RTC;
RTC_Handler.Init.HourFormat=RTC_HOURFORMAT_24;//RTCÉèÖÃΪ24Сʱ¸ñʽ
RTC_Handler.Init.AsynchPrediv=0x7F; //RTCÒì²½·ÖƵϵÊý(1~0X7F)
RTC_Handler.Init.SynchPrediv=0xFF; //RTCͬ²½·ÖƵϵÊý(0~7FFF)
RTC_Handler.Init.OutPut=RTC_OUTPUT_DISABLE;
RTC_Handler.Init.OutPutPolarity=RTC_OUTPUT_POLARITY_HIGH;
RTC_Handler.Init.OutPutType=RTC_OUTPUT_TYPE_OPENDRAIN;
if(HAL_RTC_Init(&RTC_Handler)!=HAL_OK) return 2;
if(HAL_RTCEx_BKUPRead(&RTC_Handler,RTC_BKP_DR0)!=0X55aa)//ÊÇ·ñµÚÒ»´ÎÅäÖÃ
{
RTC_Set_Time(22,12,00,RTC_HOURFORMAT12_PM); //ÉèÖÃʱ¼ä ,¸ù¾Ýʵ¼Êʱ¼äÐÞ¸Ä
RTC_Set_Date(20,6,16,2); //ÉèÖÃÈÕÆÚ
HAL_RTCEx_BKUPWrite(&RTC_Handler,RTC_BKP_DR0,0X55aa);//±ê¼ÇÒѾ³õʼ»¯¹ýÁË
}
CompanyDispFlag = ReadCompanyBku();
return 0;
}
void WriteCompanyBku(uint8_t Val)
{
HAL_RTCEx_BKUPWrite(&RTC_Handler,RTC_BKP_DR1,Val);
}
uint8_t ReadCompanyBku(void)
{
uint8_t i;
i = HAL_RTCEx_BKUPRead(&RTC_Handler,RTC_BKP_DR1);
if(i > 1)
{
HAL_RTCEx_BKUPWrite(&RTC_Handler,RTC_BKP_DR1,1);
return 1;
}
return i;
}
//RTCµ×²ãÇý¶¯£¬Ê±ÖÓÅäÖÃ
//´Ëº¯Êý»á±»HAL_RTC_Init()µ÷ÓÃ
//hrtc:RTC¾ä±ú
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
__HAL_RCC_PWR_CLK_ENABLE();//ʹÄܵçԴʱÖÓPWR
HAL_PWR_EnableBkUpAccess();//È¡Ïû±¸·ÝÇøÓòд±£»¤
RCC_OscInitStruct.OscillatorType=RCC_OSCILLATORTYPE_LSE;//LSEÅäÖÃ
RCC_OscInitStruct.PLL.PLLState=RCC_PLL_NONE;
RCC_OscInitStruct.LSEState=RCC_LSE_ON; //RTCʹÓÃLSE
HAL_RCC_OscConfig(&RCC_OscInitStruct);
PeriphClkInitStruct.PeriphClockSelection=RCC_PERIPHCLK_RTC;//ÍâÉèΪRTC
PeriphClkInitStruct.RTCClockSelection=RCC_RTCCLKSOURCE_LSE;//RTCʱÖÓԴΪLSE
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
__HAL_RCC_RTC_ENABLE();//RTCʱÖÓʹÄÜ
}
//ÉèÖÃÄÖÖÓʱ¼ä(°´ÐÇÆÚÄÖÁå,24СʱÖÆ)
//week:ÐÇÆÚ¼¸(1~7) @ref RTC_WeekDay_Definitions
//hour,min,sec:Сʱ,·ÖÖÓ,ÃëÖÓ
void RTC_Set_AlarmA(uint8_t week,uint8_t hour,uint8_t min,uint8_t sec)
{
RTC_AlarmTypeDef RTC_AlarmSturuct;
RTC_AlarmSturuct.AlarmTime.Hours=hour; //Сʱ
RTC_AlarmSturuct.AlarmTime.Minutes=min; //·ÖÖÓ
RTC_AlarmSturuct.AlarmTime.Seconds=sec; //Ãë
RTC_AlarmSturuct.AlarmTime.SubSeconds=0;
RTC_AlarmSturuct.AlarmTime.TimeFormat=RTC_HOURFORMAT12_AM;
RTC_AlarmSturuct.AlarmMask=RTC_ALARMMASK_NONE;//¾«È·Æ¥ÅäÐÇÆÚ£¬Ê±·ÖÃë
RTC_AlarmSturuct.AlarmSubSecondMask=RTC_ALARMSUBSECONDMASK_NONE;
RTC_AlarmSturuct.AlarmDateWeekDaySel=RTC_ALARMDATEWEEKDAYSEL_WEEKDAY;//°´ÐÇÆÚ
RTC_AlarmSturuct.AlarmDateWeekDay=week; //ÐÇÆÚ
RTC_AlarmSturuct.Alarm=RTC_ALARM_A; //ÄÖÖÓA
HAL_RTC_SetAlarm_IT(&RTC_Handler,&RTC_AlarmSturuct,RTC_FORMAT_BIN);
HAL_NVIC_SetPriority(RTC_Alarm_IRQn,0x01,0x02); //ÇÀÕ¼ÓÅÏȼ¶1,×ÓÓÅÏȼ¶2
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
}
//ÖÜÆÚÐÔ»½ÐѶ¨Ê±Æ÷ÉèÖÃ
/*wksel: @ref RTCEx_Wakeup_Timer_Definitions
#define RTC_WAKEUPCLOCK_RTCCLK_DIV16 ((uint32_t)0x00000000)
#define RTC_WAKEUPCLOCK_RTCCLK_DIV8 ((uint32_t)0x00000001)
#define RTC_WAKEUPCLOCK_RTCCLK_DIV4 ((uint32_t)0x00000002)
#define RTC_WAKEUPCLOCK_RTCCLK_DIV2 ((uint32_t)0x00000003)
#define RTC_WAKEUPCLOCK_CK_SPRE_16BITS ((uint32_t)0x00000004)
#define RTC_WAKEUPCLOCK_CK_SPRE_17BITS ((uint32_t)0x00000006)
*/
//cnt:×Ô¶¯ÖØ×°ÔØÖµ.¼õµ½0,²úÉúÖжÏ.
void RTC_Set_WakeUp(uint32_t wksel,uint16_t cnt)
{
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&RTC_Handler, RTC_FLAG_WUTF);//Çå³ýRTC WAKE UPµÄ±êÖ¾
HAL_RTCEx_SetWakeUpTimer_IT(&RTC_Handler,cnt,wksel); //ÉèÖÃÖØ×°ÔØÖµºÍʱÖÓ
HAL_NVIC_SetPriority(RTC_WKUP_IRQn,0x02,0x02); //ÇÀÕ¼ÓÅÏȼ¶1,×ÓÓÅÏȼ¶2
HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);
}
//RTCÄÖÖÓÖжϷþÎñº¯Êý
void RTC_Alarm_IRQHandler(void)
{
HAL_RTC_AlarmIRQHandler(&RTC_Handler);
}
//RTCÄÖÖÓAÖжϴ¦Àí»Øµ÷º¯Êý
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
{
// printf("ALARM A!\r\n");
}
//RTC WAKE UPÖжϷþÎñº¯Êý
void RTC_WKUP_IRQHandler(void)
{
HAL_RTCEx_WakeUpTimerIRQHandler(&RTC_Handler);
}
//RTC WAKE UPÖжϴ¦Àí
void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
{
}
xQueueHandle rtc_msg_q = 0;
extern xQueueHandle gui_msg_q;
/**
* @brief RTC Set time.
* @param Time: Pointer to Time structure
* @retval None
*/
/*
void RTC_SetTime( RTC_TimeTypeDef *Time)
{
Time->StoreOperation = 0;
Time->SubSeconds = 0;
Time->DayLightSaving = 0;
HAL_RTC_SetTime(&RTC_Handler, Time, FORMAT_BIN);
}*/
/**
* @brief RTC Get time.
* @param Time: Pointer to Time structure
* @retval None
*/
void RTC_GetTime( RTC_TimeTypeDef *Time)
{
RTC_DateTypeDef dummy;
HAL_RTC_GetTime(&RTC_Handler, Time, FORMAT_BIN);
/* We need to get Date after getting Time
* in order to unlock the update of the RTC Calendar
*/
HAL_RTC_GetDate(&RTC_Handler, &dummy, RTC_FORMAT_BIN);
}
/**
* @brief RTC Get date
* @param Date: Pointer to Date structure
* @retval None
*/
void RTC_GetDate( RTC_DateTypeDef *Date)
{
HAL_RTC_GetDate(&RTC_Handler, Date, FORMAT_BIN);
if((Date->Date == 0) || (Date->Month == 0))
{
Date->Date = Date->Month = 1;
}
}
void RTC_Get_Ascll(char* addr)
{
uint8_t strlen;
RTC_GetTime(&Displytime);
RTC_GetDate(&Displydatat);
strlen = sprintf(addr,"%s %s %02d %02d:%02d:%02d.%03d %s %04d\r\n",getWeekdayBybin(Displydatat.WeekDay),getMonthBybin(Displydatat.Month)
,Displydatat.Date,Displytime.Hours,Displytime.Minutes,Displytime.Seconds
,Displytime.SubSeconds,getampmBybin(Displytime.TimeFormat),2000+Displydatat.Year
);
}
/**
* @brief RTC Set date
* @param Date: Pointer to Date structure
* @retval None
*/
/*
void RTC_SetDate( RTC_DateTypeDef *Date)
{
HAL_RTC_SetDate(&RTC_Handler, Date, FORMAT_BIN);
}
*/
//extern uint8_t Time_Seconds;
extern uint8_t PwmDisplayVal,TurnoffBackup;
void RTCTask(void* params)
{
(void) params;
static uint8_t Seconds_Old,BootOnConter,PwmDisplayValOld;
uint16_t TestCounter = 0;
RTCMessage msg;
// rtc_msg_q = xQueueCreate( 1, sizeof( struct RTCMessage * ) );
while(1)
{
//Time_Seconds++;
RTC_GetTime(&Displytime);
RTC_GetDate(&Displydatat);
if(Seconds_Old != Displytime.Seconds)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_2);
Seconds_Old = Displytime.Seconds;
if(BootOnConter < 5)
BootOnConter++;
if(BootOnConter >= 2)
{
if(TurnoffBackup == 1)
{
SetPwm(0);
PwmDisplayValOld = 0xff;
}
else if(PwmDisplayVal != PwmDisplayValOld)
{
SetPwm(PwmDisplayVal);
PwmDisplayValOld = PwmDisplayVal;
}
}
}
//vTaskDelay(500);
vTaskDelay(10);
/* if(xQueueReceive(rtc_msg_q, &msg, portMAX_DELAY) == pdTRUE)
{
uint8_t rtcMsg = 0;
RTC_SetTime(&msg.RTC_Time);
RTC_SetDate(&msg.RTC_Date);
// xQueueSend(gui_msg_q, &rtcMsg, 0);
}*/
}
}
#include "stm32f7xx_hal.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "uart.h"
#include "FreeRTOS.h"
#include "queue.h"
extern UART_HandleTypeDef huart1,huart3;
void Serial_Write(UART_HandleTypeDef *huart,uint8_t *pStr)
{
while(*pStr != 0)
{
HAL_UART_Transmit(huart,pStr,1,0xFFFF);
pStr++;
}
}
void Str_Serial_Write(char *ptr, UART_HandleTypeDef *huart)
{
while( *ptr != 0)
{
//Serial_Write(huart,ptr);
HAL_UART_Transmit(huart,ptr,1,0xFFFF);
ptr++;
}
}
void Str_Serial_Write_Len(uint8_t *pStr,uint16_t len,UART_HandleTypeDef *huart)
{
do
{
HAL_UART_Transmit(huart,pStr,1,0xFFFF);
pStr++;
}while(--len);
}
}
#include <gui/homescreen_screen/HomeScreenView.hpp>
#include <touchgfx/Color.hpp>
#include <gui/common/FrontendApplication.hpp>
#include <gui_generated/common/FrontendApplicationBase.hpp>
touchgfx::Unicode::UnicodeChar speedtext[20],SWC_Whiangtext[20],StrgWhlAngtext[20],Racktraveltext[20],\
rackforcetext[12],SWC_clutchtext[40],EPTRdy_h1HSCtext[20],SBW_SWC_TAStorquetext[20],\
SBW_SWC_Handsoffstatustext[20],SBW_SWC_Steeringtext[20],SBW_SWC_steeringratiotext[20],\
EPSRxAngleDisText[20];
extern unsigned short VehSpdAvgDrvnHSC1Old,SBW_SWC_SBWTrgtStrgWhlAngOld;
extern unsigned short SBW_SWC_SBWTrgtStrgWhlAngOld,StrgWhlAngHSC1Old,SBW_EPS_rackforceOld;
extern unsigned char Communication,SBW_SWC_steeringratioOld,SBW_SWC_clutchOld,EPTRdy_h1HSC1Old,SBW_SWC_TAStorqueOld,SBW_SWC_HandsoffstatusOld;
extern unsigned char SBW_EPS_ADASstatusOld,SBW_SWC_ADASstatusdOld,SBW_SWC_SteeringModeOld,ESW_4DPos_EndOld,SBW_Touchpad_QuietSWOld;
extern short SBW_Touchpad_TrgtStrgwhlAngToCan,EPSRxAngleOld;
extern unsigned char SBW_SteerRatioToCan,SBW_Touchpad_ADASstatusToCan,SBW_Touchpad_SteerModeToCan,\
SBW_Touchpad_SteerRatio_validityToCan,SBW_Touchpad_SteerMode_validityToCan,SBW_Touchpad_QuietSWToCan,\
SBW_Touchpad_4DPosCtrl_ToCan;
extern unsigned char MenuSelDisplayFlag,TurnoffBackup;
//static uint8_t MenuSelDisplayFlagOld;//,ESW_4DPos_EndOldSave;
static short TouchPadAngleOld;//,ButtonpressOld;
static int SBW_SWC_SBW_oldangle;//,oldangleL;
static uint8_t ScreenFlag = 0;
HomeScreenView::HomeScreenView():
jogWheelratio(INITIAL_CFACTOR, 1,80,40),
//onJogWheelValueChanged(this, &HomeScreenView::jogWheelValueChanged),
onJogWheelEndDragEvent(this, &HomeScreenView::jogWheelEndDragEvent),
angeljogwheel(INITIAL_WHEELANGEL,JOGWHEELANGLE_DELTA,MAX_ANGLE,MIN_ANGLE),
onJogWheelAngleValueChanged(this, &HomeScreenView::jogWheelangleValueChanged),
onJogWheelAngleEndDragEvent(this, &HomeScreenView::jogWheelangleEndDragEvent),
angeljoglarge(INITIAL_WHEELANGEL,1,470,-470),
onJogWheelAngleValueLargeChanged(this, &HomeScreenView::jogWheelangleLargeValueChanged),
onJogWheelAngleLargeEndDragEvent(this, &HomeScreenView::jogWheelangleLargeEndDragEvent)
{
}
void HomeScreenView::setupScreen()
{
HomeScreenViewBase::setupScreen();
angeljogwheellargecontainer.remove(imageagnlelarge);
angeljoglarge.setBitmaps(Bitmap(BITMAP_ANGLE_INDICATOR_WHEELLAGE_ID), Bitmap(BITMAP_ANGLE_INDICATOR_WHEELLAGE_ID));
angeljoglarge.setXY(0, 0);
angeljoglarge.setValueUpdatedCallback(onJogWheelAngleValueLargeChanged);
angeljoglarge.setEndDragEventCallback(onJogWheelAngleLargeEndDragEvent);
angeljoglarge.invalidate();
angeljogwheellargecontainer.add(angeljoglarge);
angeljogwheellargecontainer.invalidate();
angeljogwheel.setBitmaps(Bitmap(BITMAP_ANGLE_INDICATOR_WHEEL_ID), Bitmap(BITMAP_ANGLE_INDICATOR_WHEEL_ID));
angeljogwheel.setXY(3, 3);
angeljogwheel.setValueUpdatedCallback(onJogWheelAngleValueChanged);
angeljogwheel.setEndDragEventCallback(onJogWheelAngleEndDragEvent);
if(TouchPadAngleOld == 0)
jogWheelangleValueChanged(INITIAL_WHEELANGEL);
// Fix z-order and add jogWheel
arrowangel.setXY(15, 14);
arrowangel.setBitmap(touchgfx::Bitmap(BITMAP_VALUE_INDICATOR_ARROW_ID));
arrowangel.setWidth(250);
arrowangel.setHeight(250);
arrowangel.setBitmapPosition(111.8f, 29.100f);
arrowangel.setScale(1.000f);
arrowangel.setCameraDistance(300.000f);
arrowangel.setOrigo(125.000f, 125.000f, 300.000f);
arrowangel.setCamera(125.000f, 125.000f);
arrowangel.updateAngles(0.000f, 0.000f, 0.000f);
//arrowangel.setVisible(false);
arrowangel.setRenderingAlgorithm(touchgfx::TextureMapper::BILINEAR_INTERPOLATION);
angeljogwheel.add(arrowangel);
angeljogwheelcontainer.add(angeljogwheel);
angeljogwheelcontainer.invalidate();
EPSRxAngleOld = 0;
/*
jogWheelratio.setBitmaps(Bitmap(BITMAP_ANGLE_INDICATOR_WHEEL_ID), Bitmap(BITMAP_ANGLE_INDICATOR_WHEEL_ID));
jogWheelratio.setXY(0, 0);
jogWheelratio.setValueUpdatedCallback(onJogWheelValueChanged);
jogWheelratio.setEndDragEventCallback(onJogWheelEndDragEvent);
arrowcf.setXY(19, 19);
arrowcf.setBitmap(touchgfx::Bitmap(BITMAP_VALUE_INDICATOR_ARROW_ID));
arrowcf.setWidth(235);
arrowcf.setHeight(235);
arrowcf.setBitmapPosition(101.900f, 22.600f);
arrowcf.setScale(1.000f);
arrowcf.setCameraDistance(300.000f);
arrowcf.setOrigo(117.500f, 117.500f, 300.000f);
arrowcf.setCamera(117.500f, 117.500f);
arrowcf.updateAngles(0.000f, 0.000f, -2.400f);
arrowcf.setRenderingAlgorithm(touchgfx::TextureMapper::BILINEAR_INTERPOLATION);
jogWheelratio.add(arrowcf);
jogWheelValueChanged(SBW_SteerRatioToCan);
// Fix z-order and add jogWheel
jogWheelContainer.remove(CFactorValText);
jogWheelContainer.add(jogWheelratio);
jogWheelContainer.add(CFactorValText);
jogWheelContainer.invalidate();
updateVehSpdAvgDrvn(VehSpdAvgDrvnHSC1Old);
updateSBW_SWC_SBWTrgtStrgWhlAng(SBW_SWC_SBWTrgtStrgWhlAngOld);
updateStrgWhlAngHSC(StrgWhlAngHSC1Old);
angeljogwheel.setValue(TouchPadAngleOld);
jogWheelratio.setValue(SBW_SteerRatioToCan); //C-factor
drivermodeSaveDis(SBW_Touchpad_SteerModeToCan);
if(SBW_Touchpad_SteerRatio_validityToCan)
flexButtontsradio.setBoxWithBorderColors(touchgfx::Color::getColorFrom24BitRGB(26, 173, 25), touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(18, 87, 160));
else
flexButtontsradio.setBoxWithBorderColors(touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(18, 87, 160));
flexButtontsradio.invalidate();
MenuSelDisplayFlagOld = 0xff;
swipeContainerControlMenu.setTouchable(false);
swipeContainerControlMenu.invalidate();
ESW_4DPos_EndOldSave = 0xff;
oldangleL = 0xffff;
if(ScreenFlag == 2)
{
ScreenFlag = 1;
flexButtonback.setVisible(true);
swipeContainerControlMenu.setSelectedPage(1);
swipeContainerControlMenu.invalidate();
flexButtonback.invalidate();
}
HideMeunDis();*/
/*.invalidate();
#ifndef SIMULATOR
imageSWAngle.setXY(200, 191);
imageSWAngle.setBitmap(touchgfx::Bitmap(BITMAP_STEERINGWHEEL5_ID));
containerSWstatus.remove(textureMapperSteeringwheel);
//containerSWstatus.remove(textureMapperrighttire);
//containerSWstatus.remove(textureMapperlefttire);
containerSWstatus.add(imageSWAngle);
containerSWstatus.invalidate();
#endif*/
}
void HomeScreenView::tearDownScreen()
{
HomeScreenViewBase::tearDownScreen();
}
void HomeScreenView::handleTickEvent()
{
static unsigned char speedval;
CommunicationLed();
/*BW_SWC_steeringratioDis();
EPTRdy_h1HSC1Dis();
if(buttonPower.getAlpha() == 255)
{
buttonPower.setAlpha(80);
buttonPower.invalidate();
}
ButtonPressed();*/
/* float displayangle = 0 - (value*0.0625); //
Unicode::snprintfFloat(anglewheelTextBuffer, 15, "% 3.1f", displayangle);*/
speedval++;
if(speedval >= 130)
speedval = 0;
updateVehSpdAvgDrvn(speedval);
for(uint8_t i = 0; i < 20; i++) //arrowcf
EPSRxAngleDisText = ' ';
Unicode::snprintf(EPSRxAngleDisText, 10, "%d", EPSRxAngleOld);
CANangle.setWildcard(EPSRxAngleDisText);
CANangle.invalidate();
}
void HomeScreenView::drivermodeSaveDis(uint8_t val)
{
}
void HomeScreenView::AdasControl()
{
if(SBW_Touchpad_ADASstatusToCan == 0)
SBW_Touchpad_ADASstatusToCan = 1;
else
SBW_Touchpad_ADASstatusToCan = 0;
}
void HomeScreenView::SWMuteSet()
{
if(SBW_Touchpad_QuietSWToCan == 0)
SBW_Touchpad_QuietSWToCan = 1;
else
SBW_Touchpad_QuietSWToCan = 0;
}
void HomeScreenView::Steeringwheeladjustright()
{
//SBW_Touchpad_4DPosCtrl_ToCan = 4;
}
void HomeScreenView::SteeringwheelAdjustdown()
{
//SBW_Touchpad_4DPosCtrl_ToCan = 3;
}
void HomeScreenView::SteeringwheelAdjustleft()
{
//SBW_Touchpad_4DPosCtrl_ToCan = 5;
}
void HomeScreenView::SteeringwheelAdjustup()
{
//SBW_Touchpad_4DPosCtrl_ToCan = 2;
}
void HomeScreenView::SWzero()
{
//SBW_Touchpad_4DPosCtrl_ToCan = 1;
}
void HomeScreenView::SWrecovery()
{
//SBW_Touchpad_4DPosCtrl_ToCan = 6;
}
void HomeScreenView::jogWheelangleLargeValueChanged(int16_t value)
{
int16_t angleval = value/0.0625;
if(angeljogwheel.getValue() != angleval)
angeljogwheel.setValue(angleval);
}
void HomeScreenView::jogWheelangleValueChanged(int16_t value)
{
int arcEnd = (((MAX_DEGREE - MIN_DEGREE) * value) / 15040);
float a = arcEnd * (3.1415f / 180);
if(value > MAX_ANGLE)
{
value = MAX_ANGLE;
}
else if(value < MIN_ANGLE)
value = MIN_ANGLE;
arrowangel.updateAngles(0, 0, a);
arrowangel.invalidate();
for(uint8_t i = 0; i < 7; i++)
anglewheelTextBuffer = ' ';
float displayangle = 0 - (value*0.0625); //
Unicode::snprintfFloat(anglewheelTextBuffer, 15, "% 3.1f", displayangle);
Steeringanglevaltext.setWildcard(anglewheelTextBuffer);
Steeringanglevaltext.invalidate();
SBW_Touchpad_TrgtStrgwhlAngToCan = 0 - (value*0.0625); //value+(2048/0.0625);
EPSRxAngleOld = displayangle; //20211107
TouchPadAngleOld = value;
}
void HomeScreenView::jogWheelangleLargeEndDragEvent(int16_t value)
{
//presenter->newRoomTemperature(value);
}
void HomeScreenView::jogWheelEndDragEvent(int16_t value)
{
//presenter->newRoomTemperature(value);
}
void HomeScreenView::jogWheelangleEndDragEvent(int16_t value)
{
//presenter->newRoomTemperature(value);
}
void HomeScreenView::SBW_SWC_SteeringModeDis(void)
{
}
void HomeScreenView::SBW_SWC_HandsoffstatusDis(void)
{
}
void HomeScreenView::SBW_SWC_steeringratioDis(void)
{
}
void HomeScreenView::CommunicationLed(void)
{
if(Communication)
{
circlecommunicationPainter.setColor(touchgfx::Color::getColorFrom24BitRGB(11, 255, 0));
}
else
{
circlecommunicationPainter.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 0));
}
circlecommunication.setPainter(circlecommunicationPainter);
circlecommunication.invalidate();
}
void HomeScreenView::updateSBW_SWC_SBWTrgtStrgWhlAng(unsigned short angval)
{
int arcEnd,AngleDisVal;
float a = 0;
AngleDisVal = (angval*0.0625)-2048;
for(uint8_t i = 0; i < 10; i++)
SWC_Whiangtext = ' ';
a = (angval*0.0625)-2048;
if(a >-10 && a<100)
Unicode::snprintfFloat(SWC_Whiangtext, 17, " %3.1f", a);
else if(a > 100)
Unicode::snprintfFloat(SWC_Whiangtext, 17, " %3.1f", a);
else
Unicode::snprintfFloat(SWC_Whiangtext, 15, " %3.1f", a);
textAreaSWangelval.setWildcard(SWC_Whiangtext);
textAreaSWangelval.invalidate();
angval = 0 - angval;
AngleDisVal = (angval*0.0625)-2048;
if(SBW_SWC_SBW_oldangle != AngleDisVal)
{
arcEnd = ((470 - -470) * ((angval*0.0625)-2048)) / 940;
a = arcEnd * (3.14f / 180);//(3.1415f / 180);
textureMapperSteeringwheel.updateAngles(0,0,a);
textureMapperSteeringwheel.invalidate();
SBW_SWC_SBW_oldangle = AngleDisVal;
}
//#endif
}
void HomeScreenView::updateVehSpdAvgDrvn(unsigned short speedval)
{
//float a = (2.5- -2.5)*speedval/240;
//textureMapperneedle.setXY(109, 27);
//textureMapperneedle.updateAngles(0,0,a-2.5);
#ifdef SIMULATOR
if(speedval == 0)
speedval =1;
#endif
circleProgressspeedPainter.setColor(touchgfx::Color::getColorFrom24BitRGB(21, 221, 193));
if(speedval < 80)
{
//textureMapperneedle.setBitmap(touchgfx::Bitmap(BITMAP_SPEEDNEEDLE_ID));
circleProgressspeedPainter.setColor(touchgfx::Color::getColorFrom24BitRGB(21, 221, 193));
}
else
{
//textureMapperneedle.setBitmap(touchgfx::Bitmap(BITMAP_SPEEDNEEDLERED_ID));
circleProgressspeedPainter.setColor(touchgfx::Color::getColorFrom24BitRGB(231, 35, 103));
}
int progressEnd = ((50 - -139) * speedval) / 120;
circleProgressspeed.setStartEndAngle(-139, (progressEnd - 139));
circleProgressspeed.invalidate();
/*textureMapperneedle.setWidth(193);
textureMapperneedle.setHeight(193);
textureMapperneedle.setBitmapPosition(84.000f, -10.000f);
textureMapperneedle.setScale(1.000f);
textureMapperneedle.setCameraDistance(300.000f);
textureMapperneedle.setOrigo(96.500f, 96.500f, 300.000f);
textureMapperneedle.setCamera(96.500f, 96.500f);
textureMapperneedle.setRenderingAlgorithm(touchgfx::TextureMapper::BILINEAR_INTERPOLATION);
textureMapperneedle.invalidate();*/
for(uint8_t i = 0; i < 10; i++)
speedtext = ' ';
if(speedval > 99)
Unicode::snprintf(speedtext,9, "%02d",speedval);
else
Unicode::snprintf(speedtext,7, " %02d",speedval);
textAreaSpeedVal.setWildcard(speedtext);
textAreaSpeedVal.invalidate();
}
void HomeScreenView::updateStrgWhlAngHSC(unsigned short val)
{
#ifndef SIMULATOR
int AngleDisVal;
for(uint8_t i = 0; i < 11; i++)
StrgWhlAngtext = ' ';
float arcEnd = (val*0.0625)-2048;
Unicode::snprintfFloat(StrgWhlAngtext, 11, "%3.1f", arcEnd);
textAreaStrgWhlAng.setWildcard(StrgWhlAngtext);
textAreaStrgWhlAng.invalidate();
val = 0 - val;
AngleDisVal = ((val*0.0625)-2048)/10;
// if(oldangleL != AngleDisVal)
{
arcEnd = ((45 - -45) * ((val*0.0625)-2048)) / 1000;
float a = arcEnd * (3.1415f / 180);
textureMapperrighttire.updateAngles(0,0,a-0.25);
textureMapperrighttire.invalidate();
textureMapperlefttire.updateAngles(0,0,a-0.25);
textureMapperlefttire.invalidate();
//oldangleL = AngleDisVal;
}
#endif
}
void HomeScreenView::setTagetAngel0(void)
{
angeljogwheel.setValue(0);
}
void HomeScreenView::Setadasascontrol(void)
{
static uint8_t Setflag;
if(Setflag == 0)
{
Setflag = 1;
flexButtonAdasControl.setBoxWithBorderColors(touchgfx::Color::getColorFrom24BitRGB(26, 173, 25), touchgfx::Color::getColorFrom24BitRGB(8, 235, 33), touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(18, 87, 160));
}
else
{
flexButtonAdasControl.setBoxWithBorderColors(touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(8, 235, 33), touchgfx::Color::getColorFrom24BitRGB(165, 165, 165), touchgfx::Color::getColorFrom24BitRGB(18, 87, 160));
Setflag = 0;
}
flexButtonAdasControl.invalidate();
}
void HomeScreenView::TurnBackground(void)
{
buttonPower.setAlpha(255);
buttonPower.invalidate();
TurnoffBackup = 1;
}
void HomeScreenView::setscreenback()
{
ScreenFlag = 0;
flexButtonback.setVisible(false);
flexButtonback.invalidate();
swipeContainerControlMenu.setSelectedPage(0);
swipeContainerControlMenu.invalidate();
}
void HomeScreenView::setscreennext()
{
if(ScreenFlag == 0)
{
ScreenFlag = 1;
flexButtonback.setVisible(true);
swipeContainerControlMenu.setSelectedPage(1);
swipeContainerControlMenu.invalidate();
flexButtonback.invalidate();
}
else
{
ScreenFlag = 2;
application().gotoSETScreenNoTransition();
}
}
//
//application().gotoHomeScreenScreenNoTransition();
//
五、作品功能演示视频
(视频简介+链接)
六、项目总结
(项目文字总结+帖子分享链接汇总)
本项目使用STM32F开发板实现软件测试,为了实现软、硬件完整性,重新设计PCB,实现了整体功能,本项目稍作优化和测试即可量产。
七、其他
补充内容 (2022-10-14 13:36):
https://training.eeworld.com.cn/ ... view=1#lesson/34575
补充内容 (2022-10-14 13:42):
https://training.eeworld.com.cn/video/34575
|