Small rusEFI fixes
This commit is contained in:
parent
d5d05f9ba4
commit
9a98499cbc
|
@ -8,7 +8,7 @@ import UplotReact from 'uplot-react';
|
|||
import uPlot from 'uplot';
|
||||
import {
|
||||
colorHsl,
|
||||
formatNumber,
|
||||
formatNumberMs,
|
||||
} from '../../utils/numbers';
|
||||
import LandscapeNotice from '../Tune/Dialog/LandscapeNotice';
|
||||
import { Colors } from '../../utils/colors';
|
||||
|
@ -88,7 +88,7 @@ const LogCanvas = ({ data, width, height, selectedFields1, selectedFields2, show
|
|||
stroke: hsl(index, selectedFieldsLength),
|
||||
scale: field.units,
|
||||
width: 2,
|
||||
value: (_self, val) => `${(isNumber(val) ? formatNumber(val, field.format) : 0)}${field.units}`,
|
||||
value: (_self, val) => `${(isNumber(val) ? formatNumberMs(val, field.format) : 0)}${field.units}`,
|
||||
});
|
||||
|
||||
data.forEach((entry) => {
|
||||
|
|
|
@ -145,6 +145,11 @@ const Dialog = ({
|
|||
const y = tune.constants[table.yBins[0]];
|
||||
const z = tune.constants[table.zBins[0]];
|
||||
|
||||
if (!x || !y) {
|
||||
// TODO: handle this (rusEFI: fuel/lambdaTableTbl)
|
||||
return null;
|
||||
}
|
||||
|
||||
return <div>
|
||||
{renderHelp(table.help)}
|
||||
<Map
|
||||
|
|
|
@ -2,6 +2,7 @@ import {
|
|||
InputNumber,
|
||||
Slider,
|
||||
} from 'antd';
|
||||
import { formatNumber } from '../../../utils/numbers';
|
||||
|
||||
const SmartNumber = ({
|
||||
defaultValue,
|
||||
|
@ -22,6 +23,7 @@ const SmartNumber = ({
|
|||
.includes(`${u}`.toUpperCase());
|
||||
const sliderMarks: { [value: number]: string } = {};
|
||||
const step = digits ? 10**-digits : 1;
|
||||
const value = formatNumber(defaultValue, digits);
|
||||
sliderMarks[min] = `${min}${units}`;
|
||||
|
||||
if (min <= 0) {
|
||||
|
@ -35,7 +37,7 @@ const SmartNumber = ({
|
|||
if (isSlider(units || '')) {
|
||||
return (
|
||||
<Slider
|
||||
value={defaultValue}
|
||||
value={value as unknown as number}
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
|
@ -50,7 +52,7 @@ const SmartNumber = ({
|
|||
|
||||
return (
|
||||
<InputNumber
|
||||
value={defaultValue}
|
||||
value={value as unknown as number}
|
||||
precision={digits}
|
||||
min={min}
|
||||
max={max}
|
||||
|
|
|
@ -47,8 +47,7 @@ export const colorHsl = (min: number, max: number, value: number): HslType => {
|
|||
// eslint-disable-next-line prefer-template
|
||||
export const round = (value: number, digits: number | string = 0) => +(Math.round(value + `e+${digits}` as any) + `e-${digits}`);
|
||||
|
||||
// TODO: move this or rename to MS
|
||||
export const formatNumber = (value: number, format: string): string => {
|
||||
export const formatNumberMs = (value: number, format: string): string => {
|
||||
if (format === '%d') {
|
||||
return `${Math.round(value)}`;
|
||||
}
|
||||
|
@ -60,5 +59,7 @@ export const formatNumber = (value: number, format: string): string => {
|
|||
|
||||
const { digits } = match.groups!;
|
||||
|
||||
return round(value, digits).toFixed(digits as any);
|
||||
return round(value, digits).toFixed(digits as unknown as number);
|
||||
};
|
||||
|
||||
export const formatNumber = (value: number, digits: number): string => round(value, digits).toFixed(digits);
|
||||
|
|
|
@ -36,7 +36,8 @@ export const prepareConstDeclarations = (tuneConstants: TuneConstantsType, confi
|
|||
|
||||
// escape string values
|
||||
if (typeof val === 'string') {
|
||||
val = `'${val}'`;
|
||||
// eslint-disable-next-line quotes
|
||||
val = `'${val.replaceAll("'", "\\'")}'`;
|
||||
}
|
||||
|
||||
// some names may have invalid characters, we can fix it or skip it
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { round } from '../numbers';
|
||||
|
||||
export const parseXy = (value: string) => value
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map((val) => val.trim())
|
||||
.filter((val) => val !== '')
|
||||
.map(Number);
|
||||
.map((val) => round(Number(val), 2));
|
||||
|
||||
export const parseZ = (value: string) => value
|
||||
.trim()
|
||||
|
|
Loading…
Reference in New Issue