Farmbot-Web-App/frontend/devices/components/hardware_settings/encoders.tsx

114 lines
4.1 KiB
TypeScript
Raw Normal View History

2017-06-29 12:54:02 -06:00
import * as React from "react";
import { BooleanMCUInputGroup } from "../boolean_mcu_input_group";
2020-02-18 12:21:09 -07:00
import { ToolTips, DeviceSetting } from "../../../constants";
2017-06-29 12:54:02 -06:00
import { NumericMCUInputGroup } from "../numeric_mcu_input_group";
import { EncodersProps } from "../interfaces";
import { Header } from "./header";
import { Collapse } from "@blueprintjs/core";
2020-02-26 11:10:59 -07:00
import { hasEncoders } from "../firmware_hardware_support";
2020-02-18 12:21:09 -07:00
import { Highlight } from "../maybe_highlight";
2020-02-28 09:50:14 -07:00
import { SpacePanelHeader } from "./space_panel_header";
2017-06-29 12:54:02 -06:00
2020-02-15 11:29:09 -07:00
export function Encoders(props: EncodersProps) {
2017-06-29 12:54:02 -06:00
2020-02-15 11:29:09 -07:00
const { encoders } = props.controlPanelState;
const { dispatch, sourceFwConfig, firmwareHardware } = props;
2018-01-29 13:53:24 -07:00
const encodersDisabled = {
2018-03-09 02:34:24 -07:00
x: !sourceFwConfig("encoder_enabled_x").value,
y: !sourceFwConfig("encoder_enabled_y").value,
z: !sourceFwConfig("encoder_enabled_z").value
2018-01-29 13:53:24 -07:00
};
2020-02-26 11:10:59 -07:00
const showEncoders = hasEncoders(firmwareHardware);
2017-06-29 12:54:02 -06:00
2020-02-18 12:21:09 -07:00
return <Highlight className={"section"}
settingName={DeviceSetting.encoders}>
2017-06-29 12:54:02 -06:00
<Header
2020-02-15 11:29:09 -07:00
expanded={encoders}
2020-02-26 11:10:59 -07:00
title={!showEncoders
2020-02-18 12:21:09 -07:00
? DeviceSetting.stallDetection
: DeviceSetting.encoders}
panel={"encoders"}
2017-08-23 16:26:09 -06:00
dispatch={dispatch} />
2020-02-15 11:29:09 -07:00
<Collapse isOpen={!!encoders}>
2020-03-13 15:06:40 -06:00
<SpacePanelHeader />
2017-06-29 12:54:02 -06:00
<BooleanMCUInputGroup
2020-02-26 11:10:59 -07:00
label={!showEncoders
2020-02-18 12:21:09 -07:00
? DeviceSetting.enableStallDetection
: DeviceSetting.enableEncoders}
2020-02-26 11:10:59 -07:00
tooltip={!showEncoders
2020-02-15 11:29:09 -07:00
? ToolTips.ENABLE_STALL_DETECTION
: ToolTips.ENABLE_ENCODERS}
2017-06-29 12:54:02 -06:00
x={"encoder_enabled_x"}
y={"encoder_enabled_y"}
z={"encoder_enabled_z"}
dispatch={dispatch}
2018-03-09 02:34:24 -07:00
sourceFwConfig={sourceFwConfig} />
2020-02-26 11:10:59 -07:00
{!showEncoders &&
2020-02-15 11:29:09 -07:00
<NumericMCUInputGroup
2020-02-18 12:21:09 -07:00
label={DeviceSetting.stallSensitivity}
2020-02-15 11:29:09 -07:00
tooltip={ToolTips.STALL_SENSITIVITY}
x={"movement_stall_sensitivity_x"}
y={"movement_stall_sensitivity_y"}
z={"movement_stall_sensitivity_z"}
gray={encodersDisabled}
dispatch={dispatch}
sourceFwConfig={sourceFwConfig} />}
2020-02-26 11:10:59 -07:00
{showEncoders &&
2020-02-07 16:06:40 -07:00
<BooleanMCUInputGroup
2020-02-18 12:21:09 -07:00
label={DeviceSetting.useEncodersForPositioning}
2020-02-07 16:06:40 -07:00
tooltip={ToolTips.ENCODER_POSITIONING}
x={"encoder_use_for_pos_x"}
y={"encoder_use_for_pos_y"}
z={"encoder_use_for_pos_z"}
grayscale={encodersDisabled}
dispatch={dispatch}
sourceFwConfig={sourceFwConfig} />}
2020-02-26 11:10:59 -07:00
{showEncoders &&
2020-02-07 16:06:40 -07:00
<BooleanMCUInputGroup
2020-02-18 12:21:09 -07:00
label={DeviceSetting.invertEncoders}
2020-02-07 16:06:40 -07:00
tooltip={ToolTips.INVERT_ENCODERS}
x={"encoder_invert_x"}
y={"encoder_invert_y"}
z={"encoder_invert_z"}
grayscale={encodersDisabled}
dispatch={dispatch}
sourceFwConfig={sourceFwConfig} />}
2017-06-29 12:54:02 -06:00
<NumericMCUInputGroup
2020-02-18 12:21:09 -07:00
label={DeviceSetting.maxMissedSteps}
2020-02-26 11:10:59 -07:00
tooltip={!showEncoders
2020-02-15 11:29:09 -07:00
? ToolTips.MAX_MISSED_STEPS_STALL_DETECTION
: ToolTips.MAX_MISSED_STEPS_ENCODERS}
2017-06-29 12:54:02 -06:00
x={"encoder_missed_steps_max_x"}
y={"encoder_missed_steps_max_y"}
z={"encoder_missed_steps_max_z"}
2018-01-29 13:53:24 -07:00
gray={encodersDisabled}
2018-03-09 02:34:24 -07:00
sourceFwConfig={sourceFwConfig}
2017-08-23 16:26:09 -06:00
dispatch={dispatch} />
2017-06-29 12:54:02 -06:00
<NumericMCUInputGroup
2020-02-18 12:21:09 -07:00
label={DeviceSetting.missedStepDecay}
2020-02-15 11:29:09 -07:00
tooltip={ToolTips.MISSED_STEP_DECAY}
2017-06-29 12:54:02 -06:00
x={"encoder_missed_steps_decay_x"}
y={"encoder_missed_steps_decay_y"}
z={"encoder_missed_steps_decay_z"}
2018-01-29 13:53:24 -07:00
gray={encodersDisabled}
2018-03-09 02:34:24 -07:00
sourceFwConfig={sourceFwConfig}
2017-08-23 16:26:09 -06:00
dispatch={dispatch} />
2020-02-26 11:10:59 -07:00
{showEncoders &&
2020-02-07 16:06:40 -07:00
<NumericMCUInputGroup
2020-02-18 12:21:09 -07:00
label={DeviceSetting.encoderScaling}
2020-02-07 16:06:40 -07:00
tooltip={ToolTips.ENCODER_SCALING}
x={"encoder_scaling_x"}
y={"encoder_scaling_y"}
z={"encoder_scaling_z"}
xScale={sourceFwConfig("movement_microsteps_x").value}
yScale={sourceFwConfig("movement_microsteps_y").value}
zScale={sourceFwConfig("movement_microsteps_z").value}
2020-02-15 11:29:09 -07:00
intSize={"long"}
2020-02-07 16:06:40 -07:00
gray={encodersDisabled}
sourceFwConfig={sourceFwConfig}
dispatch={dispatch} />}
2017-06-29 12:54:02 -06:00
</Collapse>
2020-02-18 12:21:09 -07:00
</Highlight>;
2017-06-29 12:54:02 -06:00
}