123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /*******************************************************************************
- *
- * SW AS
- * Soft version:
- * File Name: GLOBAL.c
- * Author : zzw (zhangzw_3@163.com)
- * creation date: 2022-07-20
- * module description:定义系统中的全局变量
- * Copyright (C)
- *
- ********************************************************************************/
- #include "GLOBAL.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- ///////////////////////////////////////////
- volatile DBit _BitParament0;
- volatile word tickcount; /* Timer tick count */
- volatile byte sysTickfor10ms; /* 10millisecond timer */
- volatile byte sysTickfor100ms;/* 100millisecond timer */
- volatile byte sysTickfor1000ms;/* 100millisecond timer */
- SWParameters switchState;//面板状态
- unsigned long data_dp_add_ele[3] = 0;
- unsigned long data_dp_cur_current[3] = 0;
- unsigned long data_dp_cur_power[3] = 0;
- unsigned long data_dp_cur_voltage = 0;
- unsigned long Flash_dp_add_ele[3]={0};
- unsigned long Flash_dp_add_ele_backups[3] = {0};
- unsigned char Save_data_ele_flag = 0;
- unsigned long Save_data_nun = 0;
- unsigned char gRelayOnOff=0;//继电器状态
- byte gLedState = 0;//按键灯状态
- byte gRelayState = 0; // 4bit 继电器值
- byte ZG_Joining;//模块进入配网模式, 指示灯快速闪烁10秒
- WORD ZG_JoinCounter;//模块进入配网计数器,倒计时开始
- byte ZG_Joining_S;//模块进入配网模式
- byte Brightflag; //强光标志位,1:白天,0,夜晚
- byte BrightPWMH=6; //强光灯强光PWM占空比
- byte NightPWMH=1; //暗光PWM占空比
- byte Light_Intensity;//光强度
- //byte mKeyLedWeakLight;//背光最大亮度值,根据光感设置
- byte mBLedWeakLight;//背光最大亮度值,根据光感设置
- unsigned int gRadarKeepTimer=0;//有人存在时,LED灯等相关动作保持时间
- byte gRadarCheckNull;//雷达监测,1为无人,0为有人
- byte shockCounter;//震动计数器
- byte shockStart;//按键按下震动触发
- byte appControlLedEnable = 0; // app控制背光灯点亮使能位,0:忽略,1:强制点亮10秒
- byte burn_in_test_start=0;//产测标志位
- u32 burn_in_test_counter=0;//产测计数器
- u32 burn_in_test_timeout=0;//产测开机30秒内收到信标才有效
- u32 IAPUpdateFlag = 0;
- u32 OTA_Reciv_Datalen;
- static const char g_sas8Base64digits[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- //编码
- void Base64Encode(char *ps8Dest, const char *ps8Source, int s32InLen)
- {
- if (ps8Dest==NULL || ps8Source==NULL || s32InLen<=0)
- {
- return;
- }
-
- for (; s32InLen >= 3; s32InLen -= 3)
- {
- *ps8Dest++ = g_sas8Base64digits[ps8Source[0] >> 2];
- *ps8Dest++ = g_sas8Base64digits[((ps8Source[0] << 4) & 0x30) | (ps8Source[1] >> 4)];
- *ps8Dest++ = g_sas8Base64digits[((ps8Source[1] << 2) & 0x3c) | (ps8Source[2] >> 6)];
- *ps8Dest++ = g_sas8Base64digits[ps8Source[2] & 0x3f];
- ps8Source += 3;
- }
-
- if (s32InLen > 0)
- {
- unsigned char fragment;
-
- *ps8Dest++ = g_sas8Base64digits[ps8Source[0] >> 2];
- fragment = (ps8Source[0] << 4) & 0x30;
-
- if (s32InLen > 1)
- fragment |= ps8Source[1] >> 4;
-
- *ps8Dest++ = g_sas8Base64digits[fragment];
- *ps8Dest++ = (s32InLen < 2) ? '=' : g_sas8Base64digits[(ps8Source[1] << 2) & 0x3c];
- *ps8Dest++ = '=';
- }
-
- *ps8Dest = '\0';
- }
- //解码
- void Base64Decode(char *ps8Dest, const char *ps8Source, int s32InLen)
- {
- int s32Num = 64;
- int i,j;
- char as8ValuePre[4];
- char s8Temp;
- int s32Flag = 0;
-
- if (ps8Dest==NULL || ps8Source==NULL || s32InLen<=0)
- {
- return;
- }
- for (i=0; i<s32InLen; i++)
- {
- s32Flag = 0;
- for (j=0; j<64; j++)
- {
- if (ps8Source[i] == g_sas8Base64digits[j])
- {
- as8ValuePre[i%4] = j;
- s32Flag = 1;
- break;
- }
- }
- if (s32Flag == 0)
- {
- break;
- }
- if (i%4 == 3)
- {
- s8Temp = (as8ValuePre[1]>>4)&0x3;
- *ps8Dest++ = (as8ValuePre[0]<<2) | s8Temp ;
- s8Temp = (as8ValuePre[2]>>2)&0xF;
- *ps8Dest++ = (as8ValuePre[1]<<4) | s8Temp ;
- s8Temp = (as8ValuePre[3])&0x3F;
- *ps8Dest++ = (as8ValuePre[2]<<6) | s8Temp ;
- }
- }
- i--;
- if (i%4==1)
- {
- s8Temp = (as8ValuePre[1]>>4)&0x3;
- *ps8Dest++ = (as8ValuePre[0]<<2) | s8Temp ;
- }
- else if (i%4==2)
- {
- s8Temp = (as8ValuePre[1]>>4)&0x3;
- *ps8Dest++ = (as8ValuePre[0]<<2) | s8Temp ;
- s8Temp = (as8ValuePre[2]>>2)&0xF;
- *ps8Dest++ = (as8ValuePre[1]<<4) | s8Temp ;
- }
-
- *ps8Dest = '\0';
- }
- //float FF_AC_V; // 电压有效值
- /* EOF */
|