Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PeMod_UV370.cpp
00001 #include "SysConfig.h" 00002 00003 #define UV_LV_MAX 11 00004 #define UV_SMP_AVG 5 00005 const int UvLvTable[] = {50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170}; 00006 00007 #define i2c_uv i2c_sen 00008 //#define uart_db uart_pc 00009 00010 int UV_Init(void) 00011 { 00012 return 0; 00013 } 00014 00015 float UV_ReadVolt(void) 00016 { 00017 return(adc_ch10.read() * 3300); 00018 } 00019 00020 float UV_ReadLv(void) 00021 { 00022 int i; 00023 float volt = 0, level; 00024 for(i=0; i<UV_SMP_AVG; i++) 00025 volt += UV_ReadVolt(); 00026 volt = volt / UV_SMP_AVG ; 00027 00028 if(volt < (float)UvLvTable[0]) 00029 { 00030 level = 0; 00031 return level; 00032 } 00033 00034 if(volt > (float)UvLvTable[UV_LV_MAX]) 00035 { 00036 level = 11; 00037 return level; 00038 } 00039 00040 for(i=0; i<UV_LV_MAX; i++) 00041 { 00042 if(volt > (float)UvLvTable[i] && volt < (float)UvLvTable[i+1]) 00043 { 00044 level = i + (volt - UvLvTable[i]) / (UvLvTable[i+1] - UvLvTable[i]); 00045 return level; 00046 } 00047 } 00048 00049 return -1; 00050 }
Generated on Fri Jul 15 2022 14:37:21 by
1.7.2