pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
LiquidPressure.cpp
00001 #include "LiquidPressure.hpp" 00002 00003 LiquidPressure::LiquidPressure() 00004 { 00005 ain = new AnalogIn((PinName)PINS::LIQUID::AIN); 00006 read(); 00007 } 00008 00009 LiquidPressure::~LiquidPressure() 00010 { 00011 delete ain; 00012 ain = NULL; 00013 } 00014 00015 float LiquidPressure::calc() 00016 { 00017 SERIAL_PRINT_DBG_FUNCNAME(); 00018 float &v_ref = SENSORS::GP_M010_KEYENCE::V_REF; 00019 float &shut_r = SENSORS::GP_M010_KEYENCE::SHUNT_R; 00020 float &lowest_cur = SENSORS::GP_M010_KEYENCE::LOWEST_CUR; 00021 float &pressure_coef = SENSORS::GP_M010_KEYENCE::PRESSURE_COEF; 00022 float &val = packet.pressure.val; 00023 float ret; 00024 short ret_s; 00025 ret = (v_ref * val / shut_r - lowest_cur) * pressure_coef; 00026 ret_s = ret *= 4096; 00027 ret /= ret_s / 4096; 00028 return ret < 0 ? 0 : ret; 00029 } 00030 00031 void LiquidPressure::toJSON(char* buf) 00032 { 00033 char* &fmt = SENSORS::GP_M010_KEYENCE::JSON_FMT; 00034 char* &type = SENSORS::GP_M010_KEYENCE::TYPE; 00035 char* &pn = SENSORS::GP_M010_KEYENCE::PN; 00036 char* &unit = SENSORS::GP_M010_KEYENCE::UNIT; 00037 SERIAL_PRINT_DBG_FUNCNAME(); 00038 time_t &time = packet.pressure.timeStamp; 00039 SERIAL_PRINT_DBG_FUNCNAME(); 00040 float f = calc(); 00041 SERIAL_PRINT_DBG("%f\n", f); 00042 // sprintf(buf,fmt,type,pn,time,f,unit); 00043 sprintf(buf,fmt,type,pn,f); 00044 } 00045 00046 void LiquidPressure::getBytes(uint8_t*) 00047 { 00048 } 00049 00050 void 00051 LiquidPressure::go() 00052 { 00053 SERIAL_PRINT_DBG_FUNCNAME(); 00054 timeout->attach(callback(this,&LiquidPressure::read), PREFERENCES::SENSING_INTERVAL[SENSORS::PRESSURE]); 00055 packet.pressure.val = ain->read(); 00056 SERIAL_PRINT_DBG_FUNCNAME(); 00057 RTC_GET_UTC(packet.pressure.timeStamp); 00058 ToDoQ::queuePut(this); 00059 backToNOP(); 00060 }
Generated on Thu Jul 14 2022 06:24:36 by 1.7.2