I have previously used a ESP32 development module, but that was quite large. Looking around aroound I found a Wemos ESP 32 mini that looked like it would do nicely.
It gets much of its size from having the IO pins as two rows of 2 wide headers .
Fortunatly the SPI and I2c pins are all located on the inside rows of pins, and there are enough extra pins available for the every thing else I need.
I can also put right angle headers in the outside row of pins and connect directly to them without having to have additional connectors on the circuit board.
I had neen very happy using a joystick for the user input device, but they are a little large for what I had in mind, and also they used 3 IO pins. I also wanted a couple extra control buttons available for the UI. I decided to go to keypad made up of a resistor divider string with switches to ground at each intersection. This can be read using a single ADC input.
Using surface mount components, the entire keypad can be layed out on the top side of the PCB, without taking up any extra space in he cabinet. I designed and 3D printed a small case, and the buttons for the keypad.
The software to read the keypad is quite easy. First you have to find out what ADC vlue is returned with no keys pressed and when each key is pressed. These values are reduced about 10% to prevent false readings. These values are put into an array.
The keypad function checks to see if a keyis pressed ( reading lower than none pressed value). If it is a short delay to debounce and another reading is taken ,then simple for loop compares this to the values in the array. The value of the last array item lower then the read value is returned to the calling program.
int readKeypad() {
int i;
int key;
// analog value for each key press measured and adjusted down about 10% to prevent
// wrong readings 0 position is no key pressed
int key_val[] = {3500, 3200, 2900, 2600, 2200, 1700, 900, -1};
if (analogRead(keyPadPin) > key_val[0]) // No key pressed
return 0; // just return
else
delay(5); // debounce
i = analogRead(keyPadPin); // get pressed key reading
for (int n = 0; n < 8; n++) { // check to see which key is pressed
if (i <= key_val[n]) // compare against array of measured values
key = n + 1; // bump up so you can use simple if test for a pressed key
}
if (key > 7 )key = 0; // helps to clean up clean up extended switch bounce
return key;
delay(25); // set max repeat rate
}
Now I need to grab some of the si4432 code from the TinySA on the HBTE group and see if I can get it working in the receive mode, then write some sweep and display functions.
No comments:
Post a Comment