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 uPlot from 'uplot';
|
||||||
import {
|
import {
|
||||||
colorHsl,
|
colorHsl,
|
||||||
formatNumber,
|
formatNumberMs,
|
||||||
} from '../../utils/numbers';
|
} from '../../utils/numbers';
|
||||||
import LandscapeNotice from '../Tune/Dialog/LandscapeNotice';
|
import LandscapeNotice from '../Tune/Dialog/LandscapeNotice';
|
||||||
import { Colors } from '../../utils/colors';
|
import { Colors } from '../../utils/colors';
|
||||||
|
@ -88,7 +88,7 @@ const LogCanvas = ({ data, width, height, selectedFields1, selectedFields2, show
|
||||||
stroke: hsl(index, selectedFieldsLength),
|
stroke: hsl(index, selectedFieldsLength),
|
||||||
scale: field.units,
|
scale: field.units,
|
||||||
width: 2,
|
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) => {
|
data.forEach((entry) => {
|
||||||
|
|
|
@ -145,6 +145,11 @@ const Dialog = ({
|
||||||
const y = tune.constants[table.yBins[0]];
|
const y = tune.constants[table.yBins[0]];
|
||||||
const z = tune.constants[table.zBins[0]];
|
const z = tune.constants[table.zBins[0]];
|
||||||
|
|
||||||
|
if (!x || !y) {
|
||||||
|
// TODO: handle this (rusEFI: fuel/lambdaTableTbl)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
{renderHelp(table.help)}
|
{renderHelp(table.help)}
|
||||||
<Map
|
<Map
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {
|
||||||
InputNumber,
|
InputNumber,
|
||||||
Slider,
|
Slider,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
|
import { formatNumber } from '../../../utils/numbers';
|
||||||
|
|
||||||
const SmartNumber = ({
|
const SmartNumber = ({
|
||||||
defaultValue,
|
defaultValue,
|
||||||
|
@ -22,6 +23,7 @@ const SmartNumber = ({
|
||||||
.includes(`${u}`.toUpperCase());
|
.includes(`${u}`.toUpperCase());
|
||||||
const sliderMarks: { [value: number]: string } = {};
|
const sliderMarks: { [value: number]: string } = {};
|
||||||
const step = digits ? 10**-digits : 1;
|
const step = digits ? 10**-digits : 1;
|
||||||
|
const value = formatNumber(defaultValue, digits);
|
||||||
sliderMarks[min] = `${min}${units}`;
|
sliderMarks[min] = `${min}${units}`;
|
||||||
|
|
||||||
if (min <= 0) {
|
if (min <= 0) {
|
||||||
|
@ -35,7 +37,7 @@ const SmartNumber = ({
|
||||||
if (isSlider(units || '')) {
|
if (isSlider(units || '')) {
|
||||||
return (
|
return (
|
||||||
<Slider
|
<Slider
|
||||||
value={defaultValue}
|
value={value as unknown as number}
|
||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
step={step}
|
step={step}
|
||||||
|
@ -50,7 +52,7 @@ const SmartNumber = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InputNumber
|
<InputNumber
|
||||||
value={defaultValue}
|
value={value as unknown as number}
|
||||||
precision={digits}
|
precision={digits}
|
||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
|
|
|
@ -47,8 +47,7 @@ export const colorHsl = (min: number, max: number, value: number): HslType => {
|
||||||
// eslint-disable-next-line prefer-template
|
// eslint-disable-next-line prefer-template
|
||||||
export const round = (value: number, digits: number | string = 0) => +(Math.round(value + `e+${digits}` as any) + `e-${digits}`);
|
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 formatNumberMs = (value: number, format: string): string => {
|
||||||
export const formatNumber = (value: number, format: string): string => {
|
|
||||||
if (format === '%d') {
|
if (format === '%d') {
|
||||||
return `${Math.round(value)}`;
|
return `${Math.round(value)}`;
|
||||||
}
|
}
|
||||||
|
@ -60,5 +59,7 @@ export const formatNumber = (value: number, format: string): string => {
|
||||||
|
|
||||||
const { digits } = match.groups!;
|
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
|
// escape string values
|
||||||
if (typeof val === 'string') {
|
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
|
// 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
|
export const parseXy = (value: string) => value
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((val) => val.trim())
|
.map((val) => val.trim())
|
||||||
.filter((val) => val !== '')
|
.filter((val) => val !== '')
|
||||||
.map(Number);
|
.map((val) => round(Number(val), 2));
|
||||||
|
|
||||||
export const parseZ = (value: string) => value
|
export const parseZ = (value: string) => value
|
||||||
.trim()
|
.trim()
|
||||||
|
|
Loading…
Reference in New Issue