Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bdb72a0ac |
@@ -1,3 +1,6 @@
|
||||
[submodule "src/gilles/simulatorapi/simapi"]
|
||||
path = src/gilles/simulatorapi/simapi
|
||||
url = https://github.com/Spacefreak18/simapi
|
||||
[submodule "src/gilles/GUIslice"]
|
||||
path = src/gilles/GUIslice
|
||||
url = https://github.com/spacefreak18/GUIslice.git
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ add_subdirectory(src/gilles/helper)
|
||||
add_subdirectory(src/gilles/slog)
|
||||
|
||||
add_executable(gilles src/gilles/gilles.c)
|
||||
target_link_libraries(gilles m ncursesw argtable2 config gameloop helper slog simulatorapi eclipse-paho-mqtt-c::paho-mqtt3c pthread json-c)
|
||||
target_link_libraries(gilles m ncursesw argtable2 config gameloop helper slog simulatorapi eclipse-paho-mqtt-c::paho-mqtt3c pthread json-c SDL SDL_ttf SDL_gfx)
|
||||
|
||||
# used for enabling additional compiler options if supported
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
Submodule
+1
Submodule src/gilles/GUIslice added at 8899915eff
@@ -1,10 +1,16 @@
|
||||
set(gameloop_source_files
|
||||
gameloop.c
|
||||
gameloop.h
|
||||
wheeldash.c
|
||||
wheeldash.h
|
||||
|
||||
../GUIslice/src/GUIslice.c
|
||||
../GUIslice/src/GUIslice.h
|
||||
../GUIslice/src/GUIslice_config.h
|
||||
../GUIslice/src/GUIslice_drv_sdl.h
|
||||
../GUIslice/src/GUIslice_drv_sdl.c
|
||||
)
|
||||
|
||||
set(LIBXML_INCLUDE_DIR /usr/include/libxml2)
|
||||
include_directories("." ${LIBXML_INCLUDE_DIR})
|
||||
|
||||
|
||||
add_library(gameloop STATIC ${gameloop_source_files})
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL/SDL_getenv.h"
|
||||
|
||||
// Define the primary surface for display
|
||||
SDL_Surface* scrMain = NULL;
|
||||
//<File !Start!>
|
||||
// FILE: [FerrariF1Wheel.c]
|
||||
// Created by GUIslice Builder version: [0.17.b20]
|
||||
//
|
||||
// GUIslice Builder Generated File
|
||||
//
|
||||
// For the latest guides, updates and support view:
|
||||
// https://github.com/ImpulseAdventure/GUIslice
|
||||
//
|
||||
//<File !End!>
|
||||
//
|
||||
|
||||
// ------------------------------------------------
|
||||
// Headers to include
|
||||
// ------------------------------------------------
|
||||
#include "../GUIslice/src/GUIslice.h"
|
||||
#include "../GUIslice/src/GUIslice_drv.h"
|
||||
|
||||
// Include any extended elements
|
||||
//<Includes !Start!>
|
||||
//<Includes !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Defines for resources
|
||||
// ------------------------------------------------
|
||||
#define MAX_PATH 255
|
||||
//<PathStorage !Start!>
|
||||
//<PathStorage !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Headers and Defines for fonts
|
||||
// ------------------------------------------------
|
||||
//<Fonts !Start!>
|
||||
#define FONT_FREE_MONOB96 "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
|
||||
//<Fonts !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Defines for resources
|
||||
// ------------------------------------------------
|
||||
//<Resources !Start!>
|
||||
//<Resources !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Enumerations for pages, elements, fonts, images
|
||||
// ------------------------------------------------
|
||||
//<Enum !Start!>
|
||||
enum {E_PG_MAIN};
|
||||
enum {E_GEAR_TEXT};
|
||||
// Must use separate enum for fonts with MAX_FONT at end to use gslc_FontSet.
|
||||
enum {E_FREEMONOBOLD96PT,MAX_FONT};
|
||||
//<Enum !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Instantiate the GUI
|
||||
// ------------------------------------------------
|
||||
|
||||
// ------------------------------------------------
|
||||
// Define the maximum number of elements and pages
|
||||
// ------------------------------------------------
|
||||
//<ElementDefines !Start!>
|
||||
#define MAX_PAGE 1
|
||||
|
||||
#define MAX_ELEM_PG_MAIN 1 // # Elems total on page
|
||||
#define MAX_ELEM_PG_MAIN_RAM MAX_ELEM_PG_MAIN // # Elems in RAM
|
||||
//<ElementDefines !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Create element storage
|
||||
// ------------------------------------------------
|
||||
// GUI Elements
|
||||
gslc_tsGui m_gui;
|
||||
gslc_tsDriver m_drv;
|
||||
gslc_tsFont m_asFont[MAX_FONT];
|
||||
gslc_tsPage m_asPage[MAX_PAGE];
|
||||
|
||||
//<GUI_Extra_Elements !Start!>
|
||||
gslc_tsElem m_asPage1Elem[MAX_ELEM_PG_MAIN_RAM];
|
||||
gslc_tsElemRef m_asPage1ElemRef[MAX_ELEM_PG_MAIN];
|
||||
|
||||
|
||||
gslc_tsElemRef* pElemRef = NULL;
|
||||
|
||||
#define MAX_STR 100
|
||||
|
||||
//<GUI_Extra_Elements !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Program Globals
|
||||
// ------------------------------------------------
|
||||
bool m_bQuit = false;
|
||||
|
||||
// Save some element references for direct access
|
||||
//<Save_References !Start!>
|
||||
//<Save_References !End!>
|
||||
|
||||
|
||||
// Configure environment variables suitable for display
|
||||
// - These may need modification to match your system
|
||||
// environment and display type
|
||||
// - Defaults for GSLC_DEV_FB and GSLC_DEV_TOUCH are in GUIslice_config.h
|
||||
// - Note that the environment variable settings can
|
||||
// also be set directly within the shell via export
|
||||
// (or init script).
|
||||
// - eg. export TSLIB_FBDEVICE=/dev/fb1
|
||||
void UserInitEnv()
|
||||
{
|
||||
#if defined(DRV_DISP_SDL1) || defined(DRV_DISP_SDL2)
|
||||
setenv((char*)"FRAMEBUFFER",GSLC_DEV_FB,1);
|
||||
setenv((char*)"SDL_FBDEV",GSLC_DEV_FB,1);
|
||||
setenv((char*)"SDL_VIDEODRIVER",GSLC_DEV_VID_DRV,1);
|
||||
#endif
|
||||
|
||||
#if defined(DRV_TOUCH_TSLIB)
|
||||
setenv((char*)"TSLIB_FBDEVICE",GSLC_DEV_FB,1);
|
||||
setenv((char*)"TSLIB_TSDEVICE",GSLC_DEV_TOUCH,1);
|
||||
setenv((char*)"TSLIB_CALIBFILE",(char*)"/etc/pointercal",1);
|
||||
setenv((char*)"TSLIB_CONFFILE",(char*)"/etc/ts.conf",1);
|
||||
setenv((char*)"TSLIB_PLUGINDIR",(char*)"/usr/local/lib/ts",1);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Define debug message function
|
||||
static int16_t DebugOut(char ch) { fputc(ch,stderr); return 0; }
|
||||
|
||||
// ------------------------------------------------
|
||||
// Callback Methods
|
||||
// ------------------------------------------------
|
||||
//<Button Callback !Start!>
|
||||
//<Button Callback !End!>
|
||||
//<Checkbox Callback !Start!>
|
||||
//<Checkbox Callback !End!>
|
||||
//<Keypad Callback !Start!>
|
||||
//<Keypad Callback !End!>
|
||||
//<Spinner Callback !Start!>
|
||||
//<Spinner Callback !End!>
|
||||
//<Listbox Callback !Start!>
|
||||
//<Listbox Callback !End!>
|
||||
//<Draw Callback !Start!>
|
||||
//<Draw Callback !End!>
|
||||
//<Slider Callback !Start!>
|
||||
//<Slider Callback !End!>
|
||||
//<Tick Callback !Start!>
|
||||
//<Tick Callback !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Create page elements
|
||||
// - strPath: Path to executable passed in to locate resource files
|
||||
// ------------------------------------------------
|
||||
bool InitGUI(char *strPath)
|
||||
{
|
||||
//gslc_tsElemRef* pElemRef = NULL;
|
||||
|
||||
//<InitGUI !Start!>
|
||||
gslc_PageAdd(&m_gui,E_PG_MAIN,m_asPage1Elem,MAX_ELEM_PG_MAIN_RAM,m_asPage1ElemRef,MAX_ELEM_PG_MAIN);
|
||||
// NOTE: The current page defaults to the first page added. Here we explicitly
|
||||
// ensure that the main page is the correct page no matter the add order.
|
||||
gslc_SetPageCur(&m_gui,E_PG_MAIN);
|
||||
|
||||
|
||||
// Set Background to a flat color
|
||||
gslc_SetBkgndColor(&m_gui,GSLC_COL_BLACK);
|
||||
|
||||
// -----------------------------------
|
||||
// PAGE: E_PG_MAIN
|
||||
|
||||
// Create E_GEAR_TEXT text label
|
||||
pElemRef = gslc_ElemCreateTxt(&m_gui,E_GEAR_TEXT,E_PG_MAIN,(gslc_tsRect){140,90,33,49},
|
||||
(char*)"N",0,E_FREEMONOBOLD96PT);
|
||||
|
||||
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
|
||||
//<InitGUI !End!>
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void* wheel()
|
||||
{
|
||||
// --------------------------------------
|
||||
// Initialization
|
||||
// --------------------------------------
|
||||
|
||||
// Update the environment variables for SDL to
|
||||
// work correctly with the external display on
|
||||
// LINUX frame buffer 1 (fb1).
|
||||
putenv((char*) "FRAMEBUFFER=/dev/fb1");
|
||||
putenv((char*) "SDL_FBDEV=/dev/fb1");
|
||||
|
||||
// Initialize SDL
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
fprintf(stderr, "ERROR in SDL_Init(): %s\n", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
|
||||
// Fetch the best video mode
|
||||
// - Note that the Raspberry Pi generally defaults
|
||||
// to a 16bits/pixel framebuffer
|
||||
const SDL_VideoInfo* vInfo = SDL_GetVideoInfo();
|
||||
if (!vInfo) {
|
||||
fprintf(stderr, "ERROR in SDL_GetVideoInfo(): %s\n", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
int nResX = vInfo->current_w;
|
||||
int nResY = vInfo->current_h;
|
||||
int nDepth = vInfo->vfmt->BitsPerPixel;
|
||||
|
||||
// Configure the video mode
|
||||
// - SDL_SWSURFACE appears to be most robust mode
|
||||
int nFlags = SDL_SWSURFACE | SDL_FULLSCREEN;
|
||||
scrMain = SDL_SetVideoMode(nResX, nResY, nDepth, nFlags);
|
||||
if (scrMain == 0) {
|
||||
fprintf(stderr, "ERROR in SDL_SetVideoMode(): %s\n", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool bOk = true;
|
||||
char acTxt[MAX_STR];
|
||||
|
||||
// ------------------------------------------------
|
||||
// Initialize
|
||||
// ------------------------------------------------
|
||||
gslc_InitDebug(&DebugOut);
|
||||
UserInitEnv();
|
||||
|
||||
if (!gslc_Init(&m_gui,&m_drv,m_asPage,MAX_PAGE,m_asFont,MAX_FONT)) { exit(1); }
|
||||
|
||||
// ------------------------------------------------
|
||||
// Load Fonts
|
||||
// ------------------------------------------------
|
||||
//<Load_Fonts !Start!>
|
||||
//
|
||||
bOk = gslc_FontSet(&m_gui,E_FREEMONOBOLD96PT,GSLC_FONTREF_FNAME,FONT_FREE_MONOB96,96);
|
||||
if (!bOk) { fprintf(stderr,"ERROR: FontAdd failed: %s\n",FONT_FREE_MONOB96); exit(1); }
|
||||
//<Load_Fonts !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
// Create graphic elements
|
||||
// ------------------------------------------------
|
||||
InitGUI("."); // Pass executable path to find resource files
|
||||
|
||||
// ------------------------------------------------
|
||||
// Start up display on main page
|
||||
// ------------------------------------------------
|
||||
//<Startup !Start!>
|
||||
//<Startup !End!>
|
||||
// ------------------------------------------------
|
||||
// Main event loop
|
||||
// ------------------------------------------------
|
||||
|
||||
m_bQuit = false;
|
||||
while (!m_bQuit) {
|
||||
|
||||
// ----------------------------------------------
|
||||
// Update GUI Elements
|
||||
// ----------------------------------------------
|
||||
|
||||
//TODO - Add update code for any text, gauges, or sliders
|
||||
|
||||
// ----------------------------------------------
|
||||
// Periodically call GUIslice update function
|
||||
// ----------------------------------------------
|
||||
gslc_Update(&m_gui);
|
||||
sleep(2);
|
||||
gslc_ElemSetTxtStr(&m_gui, pElemRef, "2");
|
||||
|
||||
gslc_Update(&m_gui);
|
||||
sleep(2);
|
||||
m_bQuit = true;
|
||||
} // bQuit
|
||||
|
||||
// ------------------------------------------------
|
||||
// Close down display
|
||||
// ------------------------------------------------
|
||||
|
||||
gslc_Quit(&m_gui);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
void* wheel(void* params);
|
||||
Reference in New Issue
Block a user