Skip to content

Commit

Permalink
Add to interrupt example
Browse files Browse the repository at this point in the history
- Fix colors on connection pad
- Add to interrupt example
  • Loading branch information
TMRh20 committed May 23, 2022
1 parent 28002fb commit 6c11bff
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 22 deletions.
3 changes: 2 additions & 1 deletion examples/ncurses/RF24Gateway_ncurses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@ void drawConnPad()
drawTopology();
return;
}
int ctr = 2;
wattroff(connPad, COLOR_PAIR(2));
int ctr = 0;
size_t lCtr = 1;
std::string line;
wclear(connPad);
Expand Down
128 changes: 107 additions & 21 deletions examples/ncursesInt/RF24Gateway_ncursesInt.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* RF24Gateway NCurses interface - TMRh20 2015
* RF24Gateway NCurses interface - TMRh20 2015-2022
* This is a generic tool for nodes supporting or combining with RF24Ethernet and/or RF24Network.
*
* The tool provides a simple interface for monitoring information and activity regarding the RF24Gateway: <br>
Expand Down Expand Up @@ -69,6 +69,7 @@ void drawDevPad(void);
void drawMeshPad(void);
void drawConnPad(void);
void drawRF24Pad(void);
void drawTopology();

int maxX, maxY;
int padSelection = 0;
Expand All @@ -85,6 +86,7 @@ size_t networkPacketsRX = 0;
std::string subIP;
std::string tunStr("tun_nrf24");
bool showConnPad;
bool topo = true;

size_t bRX;
size_t bTX;
Expand Down Expand Up @@ -119,7 +121,9 @@ int main()
start_color();
curs_set(0);
init_pair(1, COLOR_GREEN, COLOR_BLACK);
init_pair(2, COLOR_RED, COLOR_BLACK);
init_pair(2, COLOR_MAGENTA, COLOR_BLACK);
init_pair(3, COLOR_YELLOW, COLOR_BLACK);
init_pair(4, COLOR_CYAN, COLOR_BLACK);

/** Setup Pads**/
/*******************************/
Expand Down Expand Up @@ -241,7 +245,7 @@ int main()
{
drawConnPad();
wscrl(connPad, connScroll);
prefresh(connPad, 0, 0, 15, 1, maxX - 1, maxY - 2);
prefresh(connPad, 0, 0, 16, 1, maxX - 1, maxY - 2);
}
} //MeshInfo Timer

Expand All @@ -256,7 +260,12 @@ int main()
{
// a: En/Disable display of active connections
case 'a':
showConnPad = !showConnPad;
if(topo){
showConnPad = true;
}else{
showConnPad = !showConnPad;
}
topo = false;
if (!showConnPad)
{
wclear(connPad);
Expand Down Expand Up @@ -328,6 +337,10 @@ int main()
meshScroll = std::max(meshScroll, 0);
connScroll = std::max(connScroll, 0);
meshInfoTimer = 0;
case 't':
topo = true;
showConnPad = true;
break;
}
}

Expand Down Expand Up @@ -365,13 +378,94 @@ int main()
/******************************************************************/
/******************Main Drawing Functions**************************/


void drawTopology(){
wclear(connPad);
wattroff(connPad, COLOR_PAIR(1));
mvwhline(win, 15, 1, ACS_HLINE, maxY - 2);
mvwprintw(win,15,10,"Mesh Topology");

wattron(connPad,COLOR_PAIR(1));
int connPadmaxX;
connPadmaxX = getmaxx(connPad);

for (int i = 01; i < 06; i++){

for (int j = 0; j < mesh.addrListTop; j++){
if(mesh.addrList[j].address == i){
wprintw(connPad,"0%o[%d] | ", mesh.addrList[j].address, mesh.addrList[j].nodeID);
}

}
}
wprintw(connPad,"\n");
wattron(connPad,COLOR_PAIR(3));
uint16_t g = 051;
for(int h = 011; h <= 015; h++){

for (int i = h; i <= g; i+=010){

for (int j = 0; j < mesh.addrListTop; j++){
if(mesh.addrList[j].address == i){
int y=0; int x=0;
getyx(connPad,y,x);
if(x > connPadmaxX-77){ wprintw(connPad,"\n"); }
wprintw(connPad,"0%o[%d] ", mesh.addrList[j].address, mesh.addrList[j].nodeID);
}
}
}
g++;
wprintw(connPad, "| ");
}
wprintw(connPad,"\n");
wattron(connPad,COLOR_PAIR(4));
g = 0411;
for(int h = 0111; h <= 0145; h++){

for (int i = h; i <= g; i+=0100){

for (int j = 0; j < mesh.addrListTop; j++){
if(mesh.addrList[j].address == i){
int y=0; int x=0;
getyx(connPad, y, x);
if(x > connPadmaxX-77){ wprintw(connPad,"\n"); }
wprintw(connPad, "0%o[%d] ", mesh.addrList[j].address, mesh.addrList[j].nodeID);
}
}
}
g++;

}
wprintw(connPad,"\n");
wattron(connPad,COLOR_PAIR(2));
g = 04111;

for(int h = 01111; h <= 01445; h++){

for (int i = h; i <= g; i+=01000){

for (int j = 0; j < mesh.addrListTop; j++){
if(mesh.addrList[j].address == i){
int y=0; int x=0;
getyx(connPad,y,x);
if(x > connPadmaxX-77){ wprintw(connPad,"\n"); }
wprintw(connPad,"0%o[%d] ", mesh.addrList[j].address, mesh.addrList[j].nodeID);
}
}
}
g++;

}

}

void drawMain()
{

clear();

attron(COLOR_PAIR(1));
wprintw(win, "RF24Gateway Ncurses Interface by TMRh20 - 2015\n");
wprintw(win, "RF24Gateway Ncurses Interface by TMRh20 - 2015-2022\n");
whline(win, ACS_HLINE, maxY - 2);
attroff(COLOR_PAIR(1));
refresh();
Expand Down Expand Up @@ -620,8 +714,12 @@ void drawRF24Pad()

void drawConnPad()
{

int ctr = 2;
if( topo ){
drawTopology();
return;
}
wattroff(connPad, COLOR_PAIR(2));
int ctr = 0;
size_t lCtr = 1;
std::string line;
wclear(connPad);
Expand Down Expand Up @@ -652,20 +750,8 @@ void drawConnPad()
}

inFile.close();

if (padSelection == 2)
{
wattron(connPad, COLOR_PAIR(1));
mvwhline(connPad, connScroll, 0, ACS_HLINE, maxY);
wattroff(connPad, COLOR_PAIR(1));
mvwprintw(connPad, connScroll, 5, " Active IP Connections: ");
}
else
{
wattroff(connPad, COLOR_PAIR(1));
mvwhline(connPad, connScroll, 0, ACS_HLINE, maxY);
mvwprintw(connPad, connScroll, 5, " Active IP Connections: ");
}
mvwhline(win, 15, 1, ACS_HLINE, maxY - 2);
mvwprintw(win,15,10,"Active IP Connections:");
}

/******************************************************************/

0 comments on commit 6c11bff

Please # to comment.