Browse Source

Merge pull request #513 from Hunter275/position-precision-fix

Position Precision Rework
pull/518/head
Hunter Thornsberry 1 year ago
committed by GitHub
parent
commit
be0fe08f2f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/components/Form/DynamicForm.tsx
  2. 66
      src/components/PageComponents/Channel.tsx

2
src/components/Form/DynamicForm.tsx

@ -124,7 +124,7 @@ export function DynamicForm<T extends FieldValues>({
})} })}
</div> </div>
))} ))}
{hasSubmitButton && <Button type="submit">Submit</Button>} {hasSubmitButton && <Button type="submit" variant="outline">Submit</Button>}
</form> </form>
); );
} }

66
src/components/PageComponents/Channel.tsx

@ -34,13 +34,9 @@ export const Channel = ({ channel }: SettingsPanelProps) => {
settings: { settings: {
...data.settings, ...data.settings,
psk: toByteArray(pass), psk: toByteArray(pass),
// moduleSettings: { moduleSettings: {...data.settings.moduleSettings,
// positionPrecision: data.settings.positionEnabled positionPrecision: data.settings.moduleSettings.positionPrecision,
// ? data.settings.preciseLocation },
// ? 32
// : data.settings.positionPrecision
// : 0,
// },
}, },
}); });
connection?.setChannel(channel).then(() => { connection?.setChannel(channel).then(() => {
@ -100,17 +96,9 @@ export const Channel = ({ channel }: SettingsPanelProps) => {
settings: { settings: {
...channel?.settings, ...channel?.settings,
psk: pass, psk: pass,
positionEnabled: moduleSettings: {...channel?.settings?.moduleSettings,
channel?.settings?.moduleSettings?.positionPrecision !== positionPrecision: channel?.settings?.moduleSettings?.positionPrecision === undefined ? 10 : channel?.settings?.moduleSettings?.positionPrecision,
undefined && }
channel?.settings?.moduleSettings?.positionPrecision > 0,
preciseLocation:
channel?.settings?.moduleSettings?.positionPrecision === 32,
positionPrecision:
channel?.settings?.moduleSettings?.positionPrecision ===
undefined
? 10
: channel?.settings?.moduleSettings?.positionPrecision,
}, },
}, },
}} }}
@ -174,39 +162,30 @@ export const Channel = ({ channel }: SettingsPanelProps) => {
label: "Downlink Enabled", label: "Downlink Enabled",
description: "Send messages from MQTT to the local mesh", description: "Send messages from MQTT to the local mesh",
}, },
{
type: "toggle",
name: "settings.positionEnabled",
label: "Allow Position Requests",
description: "Send position to channel",
},
{
type: "toggle",
name: "settings.preciseLocation",
label: "Precise Location",
description: "Send precise location to channel",
},
{ {
type: "select", type: "select",
name: "settings.positionPrecision", name: "settings.moduleSettings.positionPrecision",
label: "Approximate Location", label: "Location",
description: description:
"If not sharing precise location, position shared on channel will be accurate within this distance", "The precision of the location to share with the channel. Can be disabled.",
properties: { properties: {
enumValue: config.display?.units === 0 enumValue: config.display?.units === 0
? { ? {
"Within 23 km": 10, "Do not share location": 0,
"Within 12 km": 11, "Within 23 kilometers": 10,
"Within 5.8 km": 12, "Within 12 kilometers": 11,
"Within 2.9 km": 13, "Within 5.8 kilometers": 12,
"Within 1.5 km": 14, "Within 2.9 kilometers": 13,
"Within 700 m": 15, "Within 1.5 kilometers": 14,
"Within 350 m": 16, "Within 700 meters": 15,
"Within 200 m": 17, "Within 350 meters": 16,
"Within 90 m": 18, "Within 200 meters": 17,
"Within 50 m": 19, "Within 90 meters": 18,
"Within 50 meters": 19,
"Precise Location": 32,
} }
: { : {
"Do not share location": 0,
"Within 15 miles": 10, "Within 15 miles": 10,
"Within 7.3 miles": 11, "Within 7.3 miles": 11,
"Within 3.6 miles": 12, "Within 3.6 miles": 12,
@ -217,6 +196,7 @@ export const Channel = ({ channel }: SettingsPanelProps) => {
"Within 600 feet": 17, "Within 600 feet": 17,
"Within 300 feet": 18, "Within 300 feet": 18,
"Within 150 feet": 19, "Within 150 feet": 19,
"Precise Location": 32,
}, },
}, },
}, },

Loading…
Cancel
Save