public void setup_dir_pin(PinParams pin_parameters) { if (pin_parameters.chip != this._mcu) { throw new PinsException("Stepper dir pin must be on same mcu as step pin"); } this._dir_pin = pin_parameters.pin; this._invert_dir = pin_parameters.invert; }
public Mcu_adc(Mcu mcu, PinParams pin_parameters) { this._mcu = mcu; this._pin = pin_parameters.pin; this._min_sample = 0.0; this._sample_time = 0.0; this._sample_count = 0; this._report_clock = 0; this._oid = 0; this._mcu.register_config_callback(this._build_config); this._inv_max_adc = 0.0; }
public Mcu_digital_out(Mcu mcu, PinParams pin_params) { _mcu = mcu; _oid = 0; _mcu.register_config_callback(_build_config); _pin = pin_params.pin; _invert = pin_params.invert; _start_value = _invert; _is_static = false; _max_duration = 2.0; _last_clock = 0; }
public Mcu_endstop(Mcu mcu, PinParams pin_parameters) { _mcu = mcu; _steppers = new List <Mcu_stepper>(); _pin = pin_parameters.pin; _pullup = pin_parameters.pullup; _invert = pin_parameters.invert; _oid = 0; _mcu.register_config_callback(_build_config); _homing = false; _min_query_time = 0.0; _next_query_print_time = 0.0; _last_state = new Dictionary <string, object>(); }
public Mcu_pwm(Mcu mcu, PinParams pin_params) { _mcu = mcu; _hardware_pwm = false; _cycle_time = 0.1; _max_duration = 2.0; _oid = 0; _mcu.register_config_callback(this._build_config); _pin = pin_params.pin; _invert = pin_params.invert; _start_value = this._shutdown_value = pin_params.invert ? 1 : 0; _is_static = false; _last_clock = 0; _pwm_max = 0.0; _set_cmd = null; }
// Config creation helpers public T setup_pin <T>(string pin_type, PinParams pin_params) where T : class { switch (pin_type) { case "stepper": return((T)(object)new Mcu_stepper(this, pin_params)); case "endstop": return((T)(object)new Mcu_endstop(this, pin_params)); case "digital_out": return((T)(object)new Mcu_digital_out(this, pin_params)); case "pwm": return((T)(object)new Mcu_pwm(this, pin_params)); case "adc": return((T)(object)new Mcu_adc(this, pin_params)); default: throw new PinsException($"pin type {pin_type} not supported on mcu"); } }
public Mcu_stepper(Mcu mcu, PinParams pin_parameters) { this._mcu = mcu; this._oid = this._mcu.create_oid(); this._mcu.register_config_callback(this._build_config); this._step_pin = pin_parameters.pin; this._invert_step = pin_parameters.invert; this._dir_pin = null; this._mcu_position_offset = 0.0; this._step_dist = 0.0; this._min_stop_interval = 0.0; this._reset_cmd_id = 0; this._get_position_cmd = null; //var _tup_1 = chelper.get_ffi(); //var ffi_main = _tup_1.Item1; //this._ffi_lib = _tup_1.Item2; //this._stepqueue = ffi_main.gc(this._ffi_lib.stepcompress_alloc(this._oid), this._ffi_lib.stepcompress_free); this._stepqueue = new stepcompress((uint)this._oid); this._mcu.register_stepqueue(this._stepqueue); this._stepper_kinematics = null; this.set_ignore_move(false); }