kopia lustrzana https://github.com/dettus/oledtest
Found a wiring for the buttons that works.
rodzic
de9335c57d
commit
2105667509
|
@ -14,11 +14,10 @@ is the result.
|
|||
# COMPILING
|
||||
Please have a look at the sourcecode. It is imperative that the GPIO numbering from the
|
||||
(deprecated) sysfs is being reflected in the physicalmapping[] array. Thus, the first time you
|
||||
try to compile it, it will fail.
|
||||
Find the #if 0 line which reflects your board, or find the correct sysfs mapping for your board.
|
||||
Really really sorry, this is what happens when you become a maker.
|
||||
try to compile it, it will fail. You need to configure lines 21-26. I am really really sorry.
|
||||
(Yes, both files. oledtest.c as well as keytest.c)
|
||||
|
||||
Once you changed one of the #if 0 to #if 1, you can compile it with
|
||||
Once you have done this, please run
|
||||
|
||||
gcc -O3 -o oledtest.app oledtest.c
|
||||
gcc -O3 -o keytest.app keytest.c
|
||||
|
|
82
keytest.c
82
keytest.c
|
@ -17,6 +17,15 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
// Configuration starts here
|
||||
//#define PATCHED_WIRING // comment in if you did the EXACT SAME wiring as I did ;)
|
||||
//#define PINOUT_JETSONNANO // comment in if you connected the SH1106 directly to a Jetson Nano
|
||||
//#define PINOUT_BANANAPI // comment in if you connected the SH1106 directly to a Banana Pi Zero
|
||||
//#define PINOUT_RASPBERRYPI // comment in if you connected the SH1106 directly to a Raspberry Pi (Zero)
|
||||
// Configuration ends here
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
@ -47,40 +56,39 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define BITMAP_HEIGHT 64
|
||||
#define BITMAP_WIDTH 128
|
||||
|
||||
|
||||
//// depends on the development board
|
||||
|
||||
// the way I understand this is, that the physical pins are mapped into
|
||||
// the system memory. to accces those, there is some sort of memory
|
||||
// offset maybe
|
||||
#if 0
|
||||
#if defined(PINOUT_JETSONNANO)
|
||||
#warning "This mapping is for the Jetson Nano board."
|
||||
// Jetson Nano
|
||||
// source: https://maker.pro/nvidia-jetson/tutorial/how-to-use-gpio-pins-on-jetson-nano-developer-kit
|
||||
const short physicalmapping[41]={
|
||||
0, // placeholder. there is no PIN0
|
||||
-1, -1,// PIN1 =3.3V DC, PIN2 =5V DC
|
||||
-1, -1,
|
||||
-1, -1,
|
||||
-1, -1,// 3,4
|
||||
-1, -1,// 5,6
|
||||
216, -1, //PIN7 = AUDIO_MCLK
|
||||
-1, -1,
|
||||
-1, -1, //9,10
|
||||
50, 79, //PIN11=UART_2_RTS,PIN12=I2S_4_CLK
|
||||
14, -1,
|
||||
194,232,
|
||||
-1, 15,
|
||||
16, -1,
|
||||
17, 13,
|
||||
18, 19,
|
||||
-1, 20,
|
||||
-1, -1,
|
||||
149, -1,
|
||||
200,168,
|
||||
38, -1,
|
||||
76, 51,
|
||||
12, 77,
|
||||
-1, 78
|
||||
14, -1, //13,14
|
||||
194,232, //15,16
|
||||
-1, 15, //17,18
|
||||
16, -1, //19,20
|
||||
17, 13, //21,22
|
||||
18, 19, //23,24
|
||||
-1, 20, //25,26
|
||||
-1, -1, //27,28
|
||||
149, -1, //29,30
|
||||
200,168, //31,32
|
||||
38, -1, //33,34
|
||||
76, 51, //35,36
|
||||
12, 77, //37,38
|
||||
-1, 78 //39,40
|
||||
};
|
||||
#elif 0
|
||||
#elif defined(PINOUT_BANANAPI)
|
||||
#warning "This mapping is for the Banana Pi board."
|
||||
// source: https://wiki.fw-web.de/doku.php?id=en:bpi-r64:gpio
|
||||
const short physicalmapping[41]={
|
||||
|
@ -106,8 +114,8 @@ const short physicalmapping[41]={
|
|||
86, -1, //37,38
|
||||
-1, -1 //39,40
|
||||
};
|
||||
#elif 1
|
||||
#warning "This mapping is for the Raspberry Pi Zero W 1.1 board"
|
||||
#elif defined(PINOUT_RASPBERRYPI)
|
||||
#warning "This mapping is for the Raspberry Pi (Zero) board"
|
||||
// source: https://www.theengineeringprojects.com/wp-content/uploads/2021/03/raspberry-pi-zero-5.png
|
||||
// NOTE: GPIO16 was actually missing in the diagram.
|
||||
const short physicalmapping[41]={
|
||||
|
@ -134,11 +142,36 @@ const short physicalmapping[41]={
|
|||
-1, 21 //39,40
|
||||
};
|
||||
#else
|
||||
#error "Please have a look at the source code and select one of the mappings from the sysfs numbering to the physical pins"
|
||||
#error "The physical pins need to be mapped to the GPIO numbers. For some reason, those numbers are different for each board out there. So please have a look at the sourcecode, lines 21-26, and select the one that works best for you."
|
||||
const int physicalmapping[41]={0};
|
||||
#endif
|
||||
|
||||
// this is the GPIO pinout for the waveshare OLED 1.3 SH1106 hat
|
||||
// source: https://www.waveshare.com/1.3inch-oled-hat.htm
|
||||
|
||||
#ifdef PATCHED_WIRING
|
||||
// Apparently, not every Key was mapped to a working GPIO pin.
|
||||
// So I did some rewiring. This is a setup that works
|
||||
#define PIN_LEFT (physicalmapping[ 3]) // OLED pin 29
|
||||
#define PIN_UP (physicalmapping[ 5]) // OLED pin 31
|
||||
#define PIN_FIRE (physicalmapping[ 7]) // OLED pin 33
|
||||
#define PIN_DOWN (physicalmapping[29]) // OLED pin 35
|
||||
#define PIN_RIGHT (physicalmapping[31]) // OLED pin 37
|
||||
|
||||
#define PIN_KEY1 (physicalmapping[27]) // OLED pin 36
|
||||
#define PIN_KEY2 (physicalmapping[24]) // OLED pin 38
|
||||
#define PIN_KEY3 (physicalmapping[26]) // OLED pin 40
|
||||
|
||||
#define PIN_BL (physicalmapping[16]) // OLED pin 12
|
||||
#define PIN_DC (physicalmapping[18])
|
||||
#define PIN_RST (physicalmapping[22])
|
||||
#define PIN_CS (physicalmapping[28]) // OLED pin 24
|
||||
|
||||
#define PIN_MOSI (physicalmapping[19])
|
||||
#define PIN_MISO (physicalmapping[21])
|
||||
#define PIN_SCLK (physicalmapping[23])
|
||||
|
||||
#else
|
||||
#define PIN_LEFT (physicalmapping[29])
|
||||
#define PIN_UP (physicalmapping[31])
|
||||
#define PIN_FIRE (physicalmapping[33])
|
||||
|
@ -157,6 +190,9 @@ const short physicalmapping[41]={
|
|||
#define PIN_MOSI (physicalmapping[19])
|
||||
#define PIN_MISO (physicalmapping[21])
|
||||
#define PIN_SCLK (physicalmapping[23])
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
int gpio_export(int pin)
|
||||
|
|
45
oledtest.c
45
oledtest.c
|
@ -17,6 +17,15 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
// Configuration starts here
|
||||
//#define PATCHED_WIRING // comment in if you did the EXACT SAME wiring as I did ;)
|
||||
//#define PINOUT_JETSONNANO // comment in if you connected the SH1106 directly to a Jetson Nano
|
||||
//#define PINOUT_BANANAPI // comment in if you connected the SH1106 directly to a Banana Pi Zero
|
||||
//#define PINOUT_RASPBERRYPI // comment in if you connected the SH1106 directly to a Raspberry Pi (Zero)
|
||||
// Configuration ends here
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
@ -53,7 +62,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// the way I understand this is, that the physical pins are mapped into
|
||||
// the system memory. to accces those, there is some sort of memory
|
||||
// offset maybe
|
||||
#if 0
|
||||
#if defined(PINOUT_JETSONNANO)
|
||||
#warning "This mapping is for the Jetson Nano board."
|
||||
// Jetson Nano
|
||||
// source: https://maker.pro/nvidia-jetson/tutorial/how-to-use-gpio-pins-on-jetson-nano-developer-kit
|
||||
|
@ -80,7 +89,7 @@ const short physicalmapping[41]={
|
|||
12, 77, //37,38
|
||||
-1, 78 //39,40
|
||||
};
|
||||
#elif 0
|
||||
#elif defined(PINOUT_BANANAPI)
|
||||
#warning "This mapping is for the Banana Pi board."
|
||||
// source: https://wiki.fw-web.de/doku.php?id=en:bpi-r64:gpio
|
||||
const short physicalmapping[41]={
|
||||
|
@ -106,8 +115,8 @@ const short physicalmapping[41]={
|
|||
86, -1, //37,38
|
||||
-1, -1 //39,40
|
||||
};
|
||||
#elif 0
|
||||
#warning "This mapping is for the Raspberry Pi Zero W 1.1 board"
|
||||
#elif defined(PINOUT_RASPBERRYPI)
|
||||
#warning "This mapping is for the Raspberry Pi (Zero) board"
|
||||
// source: https://www.theengineeringprojects.com/wp-content/uploads/2021/03/raspberry-pi-zero-5.png
|
||||
// NOTE: GPIO16 was actually missing in the diagram.
|
||||
const short physicalmapping[41]={
|
||||
|
@ -134,11 +143,36 @@ const short physicalmapping[41]={
|
|||
-1, 21 //39,40
|
||||
};
|
||||
#else
|
||||
#error "Please have a look at the source code and select one of the mappings from the sysfs numbering to the physical pins"
|
||||
#error "The physical pins need to be mapped to the GPIO numbers. For some reason, those numbers are different for each board out there. So please have a look at the sourcecode, lines 21-26, and select the one that works best for you."
|
||||
const int physicalmapping[41]={0};
|
||||
#endif
|
||||
|
||||
// this is the GPIO pinout for the waveshare OLED 1.3 SH1106 hat
|
||||
// source: https://www.waveshare.com/1.3inch-oled-hat.htm
|
||||
|
||||
#ifdef PATCHED_WIRING
|
||||
// Apparently, not every Key was mapped to a working GPIO pin.
|
||||
// So I did some rewiring. This is a setup that works
|
||||
#define PIN_LEFT (physicalmapping[ 3]) // OLED pin 29
|
||||
#define PIN_UP (physicalmapping[ 5]) // OLED pin 31
|
||||
#define PIN_FIRE (physicalmapping[ 7]) // OLED pin 33
|
||||
#define PIN_DOWN (physicalmapping[29]) // OLED pin 35
|
||||
#define PIN_RIGHT (physicalmapping[31]) // OLED pin 37
|
||||
|
||||
#define PIN_KEY1 (physicalmapping[27]) // OLED pin 36
|
||||
#define PIN_KEY2 (physicalmapping[24]) // OLED pin 38
|
||||
#define PIN_KEY3 (physicalmapping[26]) // OLED pin 40
|
||||
|
||||
#define PIN_BL (physicalmapping[16]) // OLED pin 12
|
||||
#define PIN_DC (physicalmapping[18])
|
||||
#define PIN_RST (physicalmapping[22])
|
||||
#define PIN_CS (physicalmapping[28]) // OLED pin 24
|
||||
|
||||
#define PIN_MOSI (physicalmapping[19])
|
||||
#define PIN_MISO (physicalmapping[21])
|
||||
#define PIN_SCLK (physicalmapping[23])
|
||||
|
||||
#else
|
||||
#define PIN_LEFT (physicalmapping[29])
|
||||
#define PIN_UP (physicalmapping[31])
|
||||
#define PIN_FIRE (physicalmapping[33])
|
||||
|
@ -157,6 +191,7 @@ const short physicalmapping[41]={
|
|||
#define PIN_MOSI (physicalmapping[19])
|
||||
#define PIN_MISO (physicalmapping[21])
|
||||
#define PIN_SCLK (physicalmapping[23])
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue