| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import 'ffi.dart' as ffi;
- export 'ffi.dart' show Sex;
- class Exercise {
- ffi.RwLockExercise? ptr;
- Future<void> init() async {
- ptr = await ffi.api.newExercise();
- }
- Future<void> set({
- required int age,
- required ffi.Sex sex,
- required double weightKg,
- required double heightCm,
- required double rhr,
- }) {
- return ffi.api.runExerciseSet(
- exercise: ptr!,
- age: age,
- sex: sex,
- weightKg: weightKg,
- heightCm: heightCm,
- rhr: rhr);
- }
- Future<void> hrPush(int hr, DateTime ts)async{
- if(ptr != null){
- await ffi.api.runExerciseHrPush(
- exercise: ptr!,
- hr: ffi.HR(hr: hr, timeMs: ts.millisecondsSinceEpoch));
- }
- }
- Future<double> hrPercent(int hr){
- return ffi.api.runExerciseHrPercent(
- exercise: ptr!,
- hr: hr);
- }
- Future<double> ei(){
- return ffi.api.runExerciseEi(exercise: ptr!);
- }
- Future<double> ck(){
- return ffi.api.runExerciseCk(exercise: ptr!);
- }
- Future<double> kCal(){
- return ffi.api.runExerciseKcal(exercise: ptr!);
- }
- Future<double> exerciseKcal(){
- return ffi.api.runExerciseExerciseKcal(exercise: ptr!);
- }
- Future<int> hrMean(){
- return ffi.api.runExerciseHrMean(exercise: ptr!);
- }
- Future<int> hrMax(){
- return ffi.api.runExerciseHrMax(exercise: ptr!);
- }
- void close() {
- ptr?.dispose();
- ptr = null;
- }
- }
|