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.
Sensor/TweLite_Sensors.cpp
- Committer:
- naoya1687
- Date:
- 2017-02-13
- Revision:
- 31:cef6ee7af014
- Parent:
- 30:6d3a78bc1925
- Child:
- 33:d939479e7b13
File content as of revision 31:cef6ee7af014:
#include "mbed.h" #include "Global.h" #include "TweLite_Sensors.h" #include <string> #define CADENCE 0 #define ULTSONIC 1 /* *要変更 *バッテリーチェッカー用の電圧も取得する必要あり。 */ TweLite_Sensors::TweLite_Sensors(PinName tx, PinName rx) : _twelite_serial(tx,rx){ _twelite_serial.baud(115200); } double TweLite_Sensors::scandouble(){ for(int i=0;i<=7;i++){ while(!_twelite_serial.readable()); data[i] = _twelite_serial.getc(); } return *(double*)data; } void TweLite_Sensors::update(int sensor){ if(sensor == CADENCE){ _twelite_serial.putc(CADENCE); cadencevalu = scandouble(); cadenceBattery = scandouble(); Global::setcadence(cadencevalu); Global::setcadencevolt(cadenceBattery); }else if(sensor == ULTSONIC){ _twelite_serial.putc(ULTSONIC); ultsonicvalu = scandouble(); ultsonicBattery = scandouble(); Global::setultsonic(ultsonicvalu); Global::setultsonicvolt(ultsonicBattery); } }