12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #pragma once
- #include <inttypes.h>
- #include <AP_Common/AP_Common.h>
- #include <AP_Param/AP_Param.h>
- #define AC_SPRAYER_DEFAULT_PUMP_RATE 10.0f
- #define AC_SPRAYER_DEFAULT_PUMP_MIN 0
- #define AC_SPRAYER_DEFAULT_SPINNER_PWM 1300
- #define AC_SPRAYER_DEFAULT_SPEED_MIN 100
- #define AC_SPRAYER_DEFAULT_TURN_ON_DELAY 100
- #define AC_SPRAYER_DEFAULT_SHUT_OFF_DELAY 1000
- class AC_Sprayer {
- public:
- AC_Sprayer();
-
- AC_Sprayer(const AC_Sprayer &other) = delete;
- AC_Sprayer &operator=(const AC_Sprayer&) = delete;
- static AC_Sprayer *get_singleton();
- static AC_Sprayer *_singleton;
-
- void run(bool true_false);
-
- bool running() const { return _flags.running; }
-
- bool spraying() const { return _flags.spraying; }
-
- void test_pump(bool true_false) { _flags.testing = true_false; }
-
-
- void set_pump_rate(float pct_at_1ms) { _pump_pct_1ms.set(pct_at_1ms); }
-
- void update();
- static const struct AP_Param::GroupInfo var_info[];
- private:
-
- AP_Int8 _enabled;
- AP_Float _pump_pct_1ms;
- AP_Int8 _pump_min_pct;
- AP_Int16 _spinner_pwm;
- AP_Float _speed_min;
-
- struct sprayer_flags_type {
- uint8_t spraying : 1;
- uint8_t testing : 1;
- uint8_t running : 1;
- } _flags;
-
- uint32_t _speed_over_min_time;
- uint32_t _speed_under_min_time;
- void stop_spraying();
- };
- namespace AP {
- AC_Sprayer *sprayer();
- };
|