From 649c7aa4669924d5fedbbc8dc574b7935db083f1 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 5 Sep 2017 09:41:46 +0000 Subject: [PATCH] added wiringPi exit button, compiler and SDL fixed for PI (need to add defines to allow compiling on PC again Former-commit-id: 36897ec253d2711781deb41c8a94b67274e7603e Former-commit-id: 3ed29801dd012902e04581194b606575cf2a94dc --- sdl1090/Makefile | 4 ++-- sdl1090/init.c | 17 +++++++++++++++-- sdl1090/input.c | 10 +++++++++- sdl1090/view1090.REMOVED.git-id | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sdl1090/Makefile b/sdl1090/Makefile index 3560a07..a8772db 100644 --- a/sdl1090/Makefile +++ b/sdl1090/Makefile @@ -10,8 +10,8 @@ SHAREDIR=$(PREFIX)/share/$(PROGNAME) EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\" endif -CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr` -LIBS=`pkg-config --libs librtlsdr` -lpthread -lm `sdl-config --libs` -lSDL -lSDL_ttf -lSDL_gfx +CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr` -std=c99 +LIBS=`pkg-config --libs librtlsdr` -lpthread -lm `sdl-config --libs` -lSDL -lSDL_ttf -lSDL_gfx -lwiringPi CC=gcc diff --git a/sdl1090/init.c b/sdl1090/init.c index 463b37f..ae30a36 100644 --- a/sdl1090/init.c +++ b/sdl1090/init.c @@ -1,10 +1,22 @@ #include "init.h" +#include "SDL/SDL_getenv.h" +#include extern void closeFont(TTF_Font *); void init(char *title) { + + wiringPiSetupGpio() ; + + pinMode(23, INPUT); + pullUpDnControl (23, PUD_UP); + pinMode(22, INPUT); + pullUpDnControl (22, PUD_UP); + + putenv((char*)"FRAMEBUFFER=/dev/fb1"); + putenv((char*)"SDL_FBDEV=/dev/fb1"); /* Initialise SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) @@ -22,9 +34,10 @@ void init(char *title) exit(1); } - - game.screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_HWPALETTE|SDL_DOUBLEBUF); + SDL_ShowCursor(SDL_DISABLE); + + game.screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_HWPALETTE|SDL_DOUBLEBUF); if (game.screen == NULL) { diff --git a/sdl1090/input.c b/sdl1090/input.c index 30cf050..2ae62e9 100644 --- a/sdl1090/input.c +++ b/sdl1090/input.c @@ -1,13 +1,21 @@ #include "input.h" +#include void getInput() { + + if(!digitalRead(23) || !digitalRead(22)) { + exit(0); + } + SDL_Event event; /* Loop through waiting messages and process them */ while (SDL_PollEvent(&event)) { + fprintf(stderr,"key: %d\n", event.key.keysym.sym); + switch (event.type) { /* Closing the Window or pressing Escape will exit the program */ @@ -29,4 +37,4 @@ void getInput() break; } } -} \ No newline at end of file +} diff --git a/sdl1090/view1090.REMOVED.git-id b/sdl1090/view1090.REMOVED.git-id index d86e759..7ea65f8 100644 --- a/sdl1090/view1090.REMOVED.git-id +++ b/sdl1090/view1090.REMOVED.git-id @@ -1 +1 @@ -dd9da3d4441175ab67ca8209c4dc330f48cf6590 \ No newline at end of file +07b6d82450c0a8be87c3ff832b90537a06e9cb20 \ No newline at end of file