#include "delay.h"
#include "hal_motor.h"
#include "hal_rgb_led.h"
#include "hal_temp_hum.h"
#include "hal_infrared.h"
void userInit(void)
{
memset((uint8_t*)¤tDataPoint, 0, sizeof(dataPoint_t));
/** Warning !!! DataPoint Variables Init , Must Within The Data Range **/
delay_init(72); // 延时 初始化
rgbLedInit(); // RGB LED 初始化
dht11Init(); // 温湿度初始化
irInit(); // 红外初始化
motorInit(); // 电机初始化
motorStatus(0); // 电机转速初始化
currentDataPoint.valueHeat = 0;
currentDataPoint.valueInfrared = 0;
currentDataPoint.valueMotor_Speed = 0;
currentDataPoint.valueTemperature = 0;
currentDataPoint.valueHumidity = 0;
currentDataPoint.valueLED_R = 0;
currentDataPoint.valueLED_G = 0;
currentDataPoint.valueLED_B = 0;
}
int8_t gizwitsEventProcess(eventInfo_t *info, uint8_t *gizdata, uint32_t len)
{
uint8_t i = 0;
dataPoint_t *dataPointPtr = (dataPoint_t *)gizdata;
moduleStatusInfo_t *wifiData = (moduleStatusInfo_t *)gizdata;
protocolTime_t *ptime = (protocolTime_t *)gizdata;
#if MODULE_TYPE
gprsInfo_t *gprsInfoData = (gprsInfo_t *)gizdata;
#else
moduleInfo_t *ptModuleInfo = (moduleInfo_t *)gizdata;
#endif
if((NULL == info) || (NULL == gizdata))
{
return -1;
}
for(i=0; inum; i++)
{
switch(info->event)
{
case EVENT_Heat:
currentDataPoint.valueHeat = dataPointPtr->valueHeat;
GIZWITS_LOG("Evt: EVENT_Heat %d \n", currentDataPoint.valueHeat);
if(0x01 == currentDataPoint.valueHeat)
{
HAL_GPIO_WritePin(heat_GPIO_Port, heat_Pin, GPIO_PIN_RESET);//加热开
}
else
{
HAL_GPIO_WritePin(heat_GPIO_Port, heat_Pin, GPIO_PIN_SET); //加热关
}
break;
case EVENT_Motor_Speed:
currentDataPoint.valueMotor_Speed = dataPointPtr->valueMotor_Speed;
GIZWITS_LOG("Evt: EVENT_Motor_Speed %d\n", currentDataPoint.valueMotor_Speed);
switch(currentDataPoint.valueMotor_Speed)
{
case Motor_Speed_VALUE0:
motorStatus(0);//关闭
break;
case Motor_Speed_VALUE1:
motorStatus(1);//低速
break;
case Motor_Speed_VALUE2:
motorStatus(3);//中速
break;
case Motor_Speed_VALUE3:
motorStatus(5);//高速
break;
default:
break;
}
break;
case EVENT_LED_R:
currentDataPoint.valueLED_R = dataPointPtr->valueLED_R;
GIZWITS_LOG("Evt:EVENT_LED_R %d\n",currentDataPoint.valueLED_R);
ledRgbControl(currentDataPoint.valueLED_R,currentDataPoint.valueLED_G,currentDataPoint.valueLED_B);
break;
case EVENT_LED_G:
currentDataPoint.valueLED_G = dataPointPtr->valueLED_G;
GIZWITS_LOG("Evt:EVENT_LED_G %d\n",currentDataPoint.valueLED_G);
ledRgbControl(currentDataPoint.valueLED_R,currentDataPoint.valueLED_G,currentDataPoint.valueLED_B);
break;
case EVENT_LED_B:
currentDataPoint.valueLED_B = dataPointPtr->valueLED_B;
GIZWITS_LOG("Evt:EVENT_LED_B %d\n",currentDataPoint.valueLED_B);
ledRgbControl(currentDataPoint.valueLED_R,currentDataPoint.valueLED_G,currentDataPoint.valueLED_B);
break;
case WIFI_SOFTAP:
break;
case WIFI_AIRLINK:
break;
case WIFI_STATION:
break;
case WIFI_CON_ROUTER:
ledRgbControl(0,0,0);//连接路由器过后关闭路由器
break;
case WIFI_DISCON_ROUTER:
break;
case WIFI_CON_M2M:
break;
case WIFI_DISCON_M2M:
break;
case WIFI_RSSI:
GIZWITS_LOG("RSSI %d\n", wifiData->rssi);
break;
case TRANSPARENT_DATA:
GIZWITS_LOG("TRANSPARENT_DATA \n");
//user handle , Fetch data from [data] , size is [len]
break;
case WIFI_NTP:
GIZWITS_LOG("WIFI_NTP : [%d-%d-%d %02d:%02d:%02d][%d] \n",ptime->year,ptime->month,ptime->day,ptime->hour,ptime->minute,ptime->second,ptime->ntp);
break;
case MODULE_INFO:
GIZWITS_LOG("MODULE INFO ...\n");
#if MODULE_TYPE
GIZWITS_LOG("GPRS MODULE ...\n");
//Format By gprsInfo_t
#else
GIZWITS_LOG("WIF MODULE ...\n");
//Format By moduleInfo_t
GIZWITS_LOG("moduleType : [%d] \n",ptModuleInfo->moduleType);
#endif
break;
default:
break;
}
}
return 0;
}
点击上图查看视频
点击免费下载资料(含源代码,固件以及程序)
链接:https://pan.baidu.com/s/1AHT0s-ABRaBg96gAyOirDA?pwd=93yl
提取码:93yl
文章评论(0条评论)
登录后参与讨论