Add MOSFET support to Wiegand app.
This commit is contained in:
@@ -14,6 +14,7 @@ void wiegand_instructions_scene_on_enter(void* context) {
|
||||
"Connect D0 (Green) to pin A4\n"
|
||||
"Connect D1 (White) to pin A7\n"
|
||||
"Connect GND (Black) to GND\n"
|
||||
"\nOption 1 (no mosfet):\n"
|
||||
"Add a 10K inline resistor on D0\n"
|
||||
"between keypad and door.\n"
|
||||
"Connect Flipper on door\n"
|
||||
@@ -22,6 +23,21 @@ void wiegand_instructions_scene_on_enter(void* context) {
|
||||
"door. Connect Flipper on\n"
|
||||
"door side. Do not inturrupt\n"
|
||||
"the D0/D1 connections while\n"
|
||||
"adding the resistors.");
|
||||
"adding the resistors."
|
||||
"\n\nOption 2 (mosfet):\n"
|
||||
"Connect pin A6 to gate of\n"
|
||||
"mosfet for D1. Connect 5K\n"
|
||||
"resistor from gate to GND.\n"
|
||||
"Connect pin A7 to drain of\n"
|
||||
"mosfet for D1. Connect source\n"
|
||||
"of mosfet for D1 to GND.\n"
|
||||
"Connect pin B3 to gate of\n"
|
||||
"mosfet for D0. Connect 5K\n"
|
||||
"resistor from gate to GND.\n"
|
||||
"Connect pin A4 to drain of\n"
|
||||
"mosfet for D0. Connect\n"
|
||||
"source of mosfet for D0 to\n"
|
||||
"GND.\n"
|
||||
);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WiegandWidgetView);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,12 @@ void wiegand_play() {
|
||||
|
||||
furi_hal_gpio_write(pinD0, true);
|
||||
furi_hal_gpio_init(pinD0, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
|
||||
furi_hal_gpio_write(pinD0mosfet, false);
|
||||
furi_hal_gpio_init(pinD0mosfet, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
furi_hal_gpio_write(pinD1, true);
|
||||
furi_hal_gpio_init(pinD1, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
|
||||
furi_hal_gpio_write(pinD1mosfet, false);
|
||||
furi_hal_gpio_init(pinD1mosfet, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
|
||||
single_vibro();
|
||||
furi_delay_ms(500);
|
||||
@@ -33,18 +37,24 @@ void wiegand_play() {
|
||||
int j = 0;
|
||||
for(int i = 0; i < bit_count; i++) {
|
||||
if(data[i]) {
|
||||
furi_hal_gpio_write(pinD1, false);
|
||||
furi_hal_gpio_write(pinD1mosfet, true); // Activate the mosfet to ground wire
|
||||
furi_hal_gpio_write(pinD1, false); // Ground the open-drain wire
|
||||
furi_delay_us(delays[j++]);
|
||||
furi_hal_gpio_write(pinD1, true);
|
||||
furi_hal_gpio_write(pinD1, true); // Float the wire
|
||||
furi_hal_gpio_write(pinD1mosfet, false); // Deactivate the mosfet
|
||||
furi_delay_us(delays[j++]);
|
||||
} else {
|
||||
furi_hal_gpio_write(pinD0, false);
|
||||
furi_hal_gpio_write(pinD0mosfet, true); // Activate the mosfet to ground wire
|
||||
furi_hal_gpio_write(pinD0, false); // Ground the open-drain wire
|
||||
furi_delay_us(delays[j++]);
|
||||
furi_hal_gpio_write(pinD0, true);
|
||||
furi_hal_gpio_write(pinD0, true); // Float the wire
|
||||
furi_hal_gpio_write(pinD0mosfet, false); // Deactivate the mosfet
|
||||
furi_delay_us(delays[j++]);
|
||||
}
|
||||
}
|
||||
|
||||
furi_hal_gpio_init_simple(pinD0, GpioModeAnalog);
|
||||
furi_hal_gpio_init_simple(pinD1, GpioModeAnalog);
|
||||
furi_hal_gpio_init_simple(pinD0mosfet, GpioModeAnalog);
|
||||
furi_hal_gpio_init_simple(pinD1mosfet, GpioModeAnalog);
|
||||
}
|
||||
Reference in New Issue
Block a user