fix btn/led pin numbers

pull/916/head
gabrielburnworth 2018-07-18 11:14:10 -07:00
parent 40df43dbe5
commit d576c92be6
4 changed files with 36 additions and 16 deletions

View File

@ -2,10 +2,10 @@ import { sortByNameAndPin } from "../list_and_label_support";
describe("sortByNameAndPin()", () => {
it("sorts", () => {
expect(sortByNameAndPin(17, 10)).toEqual(-1); // Button 1 < GPIO 10
expect(sortByNameAndPin(16, 10)).toEqual(-1); // Button 1 < GPIO 10
expect(sortByNameAndPin(2, 10)).toEqual(-1); // GPIO 2 < GPIO 10
expect(sortByNameAndPin(17, 23)).toEqual(-1); // Button 1 < Button 2
expect(sortByNameAndPin(23, 17)).toEqual(1); // Button 2 > Button 1
expect(sortByNameAndPin(16, 22)).toEqual(-1); // Button 1 < Button 2
expect(sortByNameAndPin(22, 16)).toEqual(1); // Button 2 > Button 1
expect(sortByNameAndPin(1, 1)).toEqual(0); // GPIO 1 == GPIO 1
});
});

View File

@ -151,8 +151,8 @@ describe("<PinBindingInputGroup/>", () => {
expect(wrapper.instance().state.pinNumberInput).toEqual(undefined);
instance.setSelectedPin(99); // invalid pin
expect(wrapper.instance().state.pinNumberInput).toEqual(undefined);
instance.setSelectedPin(6); // available pin
expect(wrapper.instance().state.pinNumberInput).toEqual(6);
instance.setSelectedPin(5); // available pin
expect(wrapper.instance().state.pinNumberInput).toEqual(5);
instance.setSelectedPin(1); // reserved pin
expect(wrapper.instance().state.pinNumberInput).toEqual(1);
expect(warning).toHaveBeenCalledWith(

View File

@ -66,8 +66,8 @@ describe("<PinBindings/>", () => {
const wrapper = mount(<PinBindings {...p} />);
["pin bindings", "pin number", "none", "bind"].map(string =>
expect(wrapper.text().toLowerCase()).toContain(string));
["1", "17", "e-stop",
"2", "23", "unlock",
["1", "16", "e-stop",
"2", "22", "unlock",
"26", "action"].map(string =>
expect(wrapper.text().toLowerCase()).toContain(string));
const buttons = wrapper.find("button");

View File

@ -27,19 +27,39 @@ export const specialActionList: DropDownItem[] =
.map((action: PinBindingSpecialAction) =>
({ label: specialActionLabelLookup[action], value: action }));
const sysLedBindings = [5, 12, 13, 16, 20, 22, 24, 25];
export const sysBtnBindings = [17, 23];
enum ButtonPin {
estop = 16,
unlock = 22,
btn3 = 26,
btn4 = 5,
btn5 = 20,
}
enum LEDPin {
sync = 24,
connection = 25,
led3 = 12,
led4 = 13,
estop = 17,
unlock = 23,
btn3 = 27,
btn4 = 6,
btn5 = 21,
}
const sysLedBindings = Object.values(LEDPin);
export const sysBtnBindings = [ButtonPin.estop, ButtonPin.unlock];
export const sysBindings = sysLedBindings.concat(sysBtnBindings);
const piI2cPins = [0, 1, 2, 3];
export const reservedPiGPIO = piI2cPins;
const LabeledGpioPins: { [x: number]: string } = {
17: "Button 1: E-STOP",
23: "Button 2: UNLOCK",
27: "Button 3",
6: "Button 4",
21: "Button 5",
[ButtonPin.estop]: "Button 1: E-STOP",
[ButtonPin.unlock]: "Button 2: UNLOCK",
[ButtonPin.btn3]: "Button 3",
[ButtonPin.btn4]: "Button 4",
[ButtonPin.btn5]: "Button 5",
};
export const generatePinLabel = (pin: number) =>
@ -75,14 +95,14 @@ export const RpiPinList = (taken: number[]): DropDownItem[] =>
export const sysBtnBindingData = [
{
pin_number: 17,
pin_number: ButtonPin.estop,
sequence_id: undefined,
special_action: PinBindingSpecialAction.emergency_lock,
binding_type: PinBindingType.special,
uuid: "FBOS built-in binding: emergency_lock"
},
{
pin_number: 23,
pin_number: ButtonPin.unlock,
sequence_id: undefined,
special_action: PinBindingSpecialAction.emergency_unlock,
binding_type: PinBindingType.special,