Skip to content

Commit

Permalink
Signed-off-by: wefcdse <3371348169@qq.com>
Browse files Browse the repository at this point in the history
  • Loading branch information
wefcdse committed Aug 5, 2024
1 parent cb06c09 commit 0e8c464
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,29 @@ protected void init() {
int slide_start = chart_left_padding + chart_height_width + padding;

float start_a = 2;
float start_dz = 0;
float start_b = 2;

Controller controller1 = Fpv20Client.controller;
if (controller1 != null) {
start_dz = controller1.calibrations[channel].dead_zone;
start_a = controller1.calibrations[channel].rate_a;
start_b = controller1.calibrations[channel].rate_b;
} else {
return;
}

addDrawableChild(new Slider1(slide_start,
30 - (padding + height), this.width - slide_start - padding, height, Text.translatable(TranslateKeys.DEAD_ZONE, start_dz), start_dz,
slider -> {
slider.setMessage(Text.translatable(TranslateKeys.DEAD_ZONE, slider.value()));
},
slider -> {
Controller controller = Fpv20Client.controller;
if (controller != null) {
controller.calibrations[channel].dead_zone = slider.value();
}
}
));
addDrawableChild(new Slider1(slide_start,
30, this.width - slide_start - padding, height, Text.translatable(TranslateKeys.RATE_1, start_a), start_a,
slider -> {
Expand Down Expand Up @@ -158,7 +171,7 @@ protected void init() {
if (controller != null) {
controller.calibrations[channel].reversed = false;
}
} else {
} else {
btn.setMessage(Texts.BTN_REVERSED);
Controller controller = Fpv20Client.controller;
if (controller != null) {
Expand Down
9 changes: 8 additions & 1 deletion src/client/java/com/iung/fpv20/utils/Calibration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Calibration {
// public RateMapper rate;
public float rate_a;
public float rate_b;
public float dead_zone;
public CalibrateMethod calibrateMethod;

public boolean reversed = false;
Expand All @@ -22,7 +23,8 @@ public Calibration() {
this.mid = 0;
this.rate_a = 0.3f;
this.rate_b = 0.5f;
Fpv20.LOGGER.info("?????");
this.dead_zone = 0;
// Fpv20.LOGGER.info("?????");
this.calibrateMethod = CalibrateMethod.MaxMidMin;
}

Expand All @@ -45,6 +47,7 @@ public Calibration(float min, float max, float mid, float rate_a, float rate_b,
this.rate_a = rate_a;
this.rate_b = rate_b;
this.calibrateMethod = calibrateMethod;
this.dead_zone = 0;
}

public float map(float value) {
Expand Down Expand Up @@ -82,6 +85,10 @@ public float map(float value) {
}

public float rate_map(float v) {
float dead_zone_fix_offs = v > 0.02 ? dead_zone :
v < -0.01 ? -dead_zone : 0;
v = v + dead_zone_fix_offs;
v = v / (1 + dead_zone);
return LocalMath.bfRate(v, 1f, rate_a, rate_b) / LocalMath.bfRate(1f, 1f, rate_a, rate_b);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/generated/assets/fpv20/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"fpv20.btn.select_controller": "select controller",
"fpv20.btn.show_input": "show input",
"fpv20.btn.start": "start",
"fpv20.dead_zone": "dead zone:%s",
"fpv20.keybind.osd": "Toggle OSD",
"fpv20.keybinds.category": "fpv20",
"fpv20.rate.1": "rate:%s",
Expand Down
1 change: 1 addition & 0 deletions src/main/generated/assets/fpv20/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"fpv20.btn.select_controller": "选择控制器",
"fpv20.btn.show_input": "显示输入信号",
"fpv20.btn.start": "开始",
"fpv20.dead_zone": "死区:%s",
"fpv20.keybind.osd": "切换OSD",
"fpv20.keybinds.category": "fpv20",
"fpv20.rate.1": "rate:%s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:quartz"
]
"items": "minecraft:quartz"
}
]
},
Expand All @@ -17,9 +15,7 @@
"conditions": {
"items": [
{
"items": [
"fpv20:receiver_block"
]
"items": "fpv20:receiver_block"
}
]
},
Expand All @@ -29,9 +25,7 @@
"conditions": {
"items": [
{
"items": [
"minecraft:redstone_block"
]
"items": "minecraft:redstone_block"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
],
"result": {
"item": "fpv20:receiver_block"
"count": 1,
"id": "fpv20:receiver_block"
}
}
1 change: 1 addition & 0 deletions src/main/java/com/iung/fpv20/consts/TranslateKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public final class TranslateKeys {
public static final String BTN_SELECT = "fpv20.btn.select";

public static final String RATE_1 = "fpv20.rate.1";
public static final String DEAD_ZONE = "fpv20.dead_zone";

public static final String BTN_CALIBRATE = "fpv20.btn.calibrate";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void generateTranslations(RegistryWrapper.WrapperLookup wrapperLookup, Tr
translationBuilder.add(TranslateKeys.BTN_OSD_OFF, "显示OSD: 不");
translationBuilder.add(TranslateKeys.KEYBINDS_CATEGORY, "fpv20");
translationBuilder.add(TranslateKeys.KEYBIND_OSD, "切换OSD");
translationBuilder.add(TranslateKeys.DEAD_ZONE, "死区:%s");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ public void generateTranslations(RegistryWrapper.WrapperLookup wrapperLookup, Tr
translationBuilder.add(TranslateKeys.BTN_OSD_OFF, "show osd: no");
translationBuilder.add(TranslateKeys.KEYBINDS_CATEGORY, "fpv20");
translationBuilder.add(TranslateKeys.KEYBIND_OSD, "Toggle OSD");
translationBuilder.add(TranslateKeys.DEAD_ZONE, "dead zone:%s");
}
}

0 comments on commit 0e8c464

Please sign in to comment.