kopia lustrzana https://github.com/PiInTheSky/lora-gateway
Half way there with the help screen
rodzic
20ae9016e1
commit
47ec677639
13
gateway.c
13
gateway.c
|
@ -33,6 +33,7 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "gateway.h"
|
#include "gateway.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
#define VERSION "V1.8.6"
|
#define VERSION "V1.8.6"
|
||||||
bool run = TRUE;
|
bool run = TRUE;
|
||||||
|
@ -161,6 +162,9 @@ struct TBandwidth
|
||||||
};
|
};
|
||||||
|
|
||||||
int LEDCounts[2];
|
int LEDCounts[2];
|
||||||
|
|
||||||
|
int help_win_displayed = 0;
|
||||||
|
|
||||||
pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
@ -367,7 +371,10 @@ void ChannelPrintf(int Channel, int row, int column, const char *format, ... )
|
||||||
|
|
||||||
mvwaddstr( Config.LoRaDevices[Channel].Window, row, column, Buffer );
|
mvwaddstr( Config.LoRaDevices[Channel].Window, row, column, Buffer );
|
||||||
|
|
||||||
wrefresh( Config.LoRaDevices[Channel].Window );
|
if (! help_win_displayed)
|
||||||
|
{
|
||||||
|
wrefresh( Config.LoRaDevices[Channel].Window );
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock( &var ); // unlock once you are done
|
pthread_mutex_unlock( &var ); // unlock once you are done
|
||||||
|
|
||||||
|
@ -1773,6 +1780,10 @@ ProcessKeyPress( int ch )
|
||||||
case 'c':
|
case 'c':
|
||||||
ReTune( Channel, -0.001 );
|
ReTune( Channel, -0.001 );
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
help_win_displayed = 1;
|
||||||
|
gui_show_help();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
//LogMessage("KeyPress %d\n", ch);
|
//LogMessage("KeyPress %d\n", ch);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
|
extern int help_win_displayed;
|
||||||
|
|
||||||
|
WINDOW *create_help_win(int height, int width, int starty, int startx);
|
||||||
|
void destroy_help_win(WINDOW *local_win);
|
||||||
|
|
||||||
|
WINDOW *create_help_win(int height, int width, int starty, int startx)
|
||||||
|
{ WINDOW *local_win;
|
||||||
|
|
||||||
|
local_win = newwin(height, width, starty, startx);
|
||||||
|
box(local_win, 0 , 0); /* 0, 0 gives default characters
|
||||||
|
* for the vertical and horizontal
|
||||||
|
* lines */
|
||||||
|
wbkgd( local_win, COLOR_PAIR( 2 ) );
|
||||||
|
wrefresh(local_win); /* Show that box */
|
||||||
|
|
||||||
|
return local_win;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_help_win(WINDOW *local_win)
|
||||||
|
{
|
||||||
|
/* box(local_win, ' ', ' '); : This won't produce the desired
|
||||||
|
* result of erasing the window. It will leave it's four corners
|
||||||
|
* and so an ugly remnant of window.
|
||||||
|
*/
|
||||||
|
wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
|
||||||
|
/* The parameters taken are
|
||||||
|
* 1. win: the window on which to operate
|
||||||
|
* 2. ls: character to be used for the left side of the window
|
||||||
|
* 3. rs: character to be used for the right side of the window
|
||||||
|
* 4. ts: character to be used for the top side of the window
|
||||||
|
* 5. bs: character to be used for the bottom side of the window
|
||||||
|
* 6. tl: character to be used for the top left corner of the window
|
||||||
|
* 7. tr: character to be used for the top right corner of the window
|
||||||
|
* 8. bl: character to be used for the bottom left corner of the window
|
||||||
|
* 9. br: character to be used for the bottom right corner of the window
|
||||||
|
*/
|
||||||
|
wrefresh(local_win);
|
||||||
|
delwin(local_win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_show_help ()
|
||||||
|
{
|
||||||
|
|
||||||
|
WINDOW *help_win;
|
||||||
|
|
||||||
|
int startx, starty, width, height;
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
height = 14;
|
||||||
|
width = 76;
|
||||||
|
starty = 1; /* Calculating for a center placement */
|
||||||
|
startx = 2; /* of the window */
|
||||||
|
help_win = create_help_win(height, width, starty, startx);
|
||||||
|
|
||||||
|
while((ch = getch()) != 'c')
|
||||||
|
{
|
||||||
|
switch(ch)
|
||||||
|
{ case KEY_LEFT:
|
||||||
|
destroy_help_win(help_win);
|
||||||
|
help_win = create_help_win(height, width, starty,--startx);
|
||||||
|
break;
|
||||||
|
case KEY_RIGHT:
|
||||||
|
destroy_help_win(help_win);
|
||||||
|
help_win = create_help_win(height, width, starty,++startx);
|
||||||
|
break;
|
||||||
|
case KEY_UP:
|
||||||
|
destroy_help_win(help_win);
|
||||||
|
help_win = create_help_win(height, width, --starty,startx);
|
||||||
|
break;
|
||||||
|
case KEY_DOWN:
|
||||||
|
destroy_help_win(help_win);
|
||||||
|
help_win = create_help_win(height, width, ++starty,startx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
help_win_displayed = 0;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef _GUI_H
|
||||||
|
#define _GUI_H
|
||||||
|
|
||||||
|
#include <ncurses.h>
|
||||||
|
|
||||||
|
void gui_show_help ();
|
||||||
|
|
||||||
|
#endif
|
Ładowanie…
Reference in New Issue