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