- Posts: 1433
Adding switches to Devo8
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
Less
More
09 Feb 2014 20:13 - 09 Feb 2014 20:20 #20026
by rbe2012
Adding switches to Devo8 was created by rbe2012
Sorry, I was not able to find the threat were we lastly discussed that.
After fighting with my brain which tried to confuse my fingers I finally got it working. It is not really hard (if you can distinguish GPIOE from GPIOB...).
The code from Devo7e can be used with some minor changes.
I had to switch columns and rows for optimized soldering. Now the new switches can be soldered at the soldering points of the upper trims which can be reached without screwing the board off (grey, orange, yellow, violet and black wires going out through the antenna hole):
I have to make the code nicer and will publish it.
If this shall be integrated in the main code I would propose to find new places for CHAN_SwitchCfg() and for the "#define SWITCH_*" to avoid keeping them multiple times in the sources.
And the assignment of the 3x1-switch is sub-optimal, I believe. Actually the lines are connected where A0 and B0 are for the 2x2 and 3x2 configurations. It would make things easier when they would be connected at A0 and A2 instead.
In the 7e code seems to be a bug (line 108):Edit: (port>>6)&0x5 = ((~port)>>6)&0xa, so obviously no bug but a simplification.
After fighting with my brain which tried to confuse my fingers I finally got it working. It is not really hard (if you can distinguish GPIOE from GPIOB...).
The code from Devo7e can be used with some minor changes.
I had to switch columns and rows for optimized soldering. Now the new switches can be soldered at the soldering points of the upper trims which can be reached without screwing the board off (grey, orange, yellow, violet and black wires going out through the antenna hole):
I have to make the code nicer and will publish it.
If this shall be integrated in the main code I would propose to find new places for CHAN_SwitchCfg() and for the "#define SWITCH_*" to avoid keeping them multiple times in the sources.
And the assignment of the 3x1-switch is sub-optimal, I believe. Actually the lines are connected where A0 and B0 are for the 2x2 and 3x2 configurations. It would make things easier when they would be connected at A0 and A2 instead.
} else if (Transmitter.ignore_src == SWITCH_2x2) {
global_extra_switches = (port>>6)&0x05;
// ((~port) >> 6) & 0x05;
Last edit: 09 Feb 2014 20:20 by rbe2012.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
Less
More
- Posts: 4402
10 Feb 2014 14:38 - 10 Feb 2014 14:39 #20072
by PhracturedBlue
Replied by PhracturedBlue on topic Adding switches to Devo8
I'll accept the code when it is ready, but the devo7e is right as is i think. The way the 2x2 switches are wired is reversed compared to the 3x1 and 3x2.
On the 3-way switch position 1 occurs when there is no connection. but on the 2-way, position 1 occurs when there is a connection. So we need to invert the signal from the 3-way (and thus we use 'port' instead of '~port')
On the 3-way switch position 1 occurs when there is no connection. but on the 2-way, position 1 occurs when there is a connection. So we need to invert the signal from the 3-way (and thus we use 'port' instead of '~port')
Last edit: 10 Feb 2014 14:39 by PhracturedBlue.
Please Log in or Create an account to join the conversation.
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
Less
More
- Posts: 1433
10 Feb 2014 16:23 #20083
by rbe2012
Replied by rbe2012 on topic Adding switches to Devo8
Understood. I had the same thought after I have written the post yesterday.
I solved it slightly different because it was better to see for me, but I am not sure if it will take more code than your solution:Why don't you need to initialize the ports (GPIOB) as inputs? I didn't get it working without on my Devo8.
I solved it slightly different because it was better to see for me, but I am not sure if it will take more code than your solution:
// B.8 to E.3-E.6 (= TRIM_L+, L-, R+, R-)
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO8);
gpio_set(GPIOB, GPIO6 | GPIO7 | GPIO8 | GPIO9);
gpio_set_mode(GPIOE, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO3 | GPIO4 | GPIO5 | GPIO6);
gpio_set(GPIOE, GPIO3 | GPIO4 | GPIO5 | GPIO6);
gpio_clear(GPIOB, GPIO8);
u32 port = ((~ gpio_port_read(GPIOE)) & ( GPIO3 | GPIO4 | GPIO5 | GPIO6)) >> 3;
// reset all ports to ButtonMatrix defaults
_set_ButtonMatrixPorts();
if (Transmitter.ignore_src == SWITCH_3x1) {
global_extra_switches = (port & 0x01) << 2 |
(port & 0x04) << 1;
} else if (Transmitter.ignore_src == SWITCH_2x2) {
global_extra_switches = port & 0x0a;
} else {
global_extra_switches = port & 0x0f;
}
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
Less
More
- Posts: 4402
10 Feb 2014 20:53 #20097
by PhracturedBlue
Replied by PhracturedBlue on topic Adding switches to Devo8
did you change the mode to output open-drain with pullup resistors (as in the devo7e). Since an open-drain isn't strongly driven when off, you can pull the line low and read it without setting it to an input (at least that is my understanding of why it works)
Please Log in or Create an account to join the conversation.
- rbe2012
- Topic Author
- Offline
- So much to do, so little time...
Less
More
- Posts: 1433
11 Feb 2014 12:03 #20125
by rbe2012
Replied by rbe2012 on topic Adding switches to Devo8
You might have seen dianjing's problems here:
http://www.deviationtx.com/forum/builds/2661-7e-telem-layout-ed-perm-timer-weekly-updates?start=40#20114
.
Yesterday I described some strange phenomena I have seen after doing some hardware mods.
I have to read more about open drain outputs. But I could imagine that there might be a connection between "not strongly driven" outputs and influences due to unskillful/unlucky wire placing.
Yesterday I described some strange phenomena I have seen after doing some hardware mods.
I have to read more about open drain outputs. But I could imagine that there might be a connection between "not strongly driven" outputs and influences due to unskillful/unlucky wire placing.
Please Log in or Create an account to join the conversation.
Time to create page: 0.055 seconds
- Home
- Forum
- Development
- Development
- Adding switches to Devo8