Compare commits
1
Commits
0e96eb27ae
..
test1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e87dd06996 |
@@ -7,16 +7,6 @@
|
||||
#define NUM_LEDS 6
|
||||
#define BRIGHTNESS 40
|
||||
|
||||
#define COLOR1A 0
|
||||
#define COLOR1B 0
|
||||
#define COLOR1C 255
|
||||
#define COLOR2A 0
|
||||
#define COLOR2B 255
|
||||
#define COLOR2C 0
|
||||
#define COLOR3A 255
|
||||
#define COLOR3B 0
|
||||
#define COLOR3C 0
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
SimData sd;
|
||||
int maxrpm = 0;
|
||||
@@ -85,15 +75,15 @@ void loop()
|
||||
|
||||
if (l >= numlights / 2)
|
||||
{
|
||||
leds[l] = CRGB ( COLOR1A, COLOR1B, COLOR1C);
|
||||
leds[l] = CRGB ( 0, 0, 255);
|
||||
}
|
||||
if (l < numlights / 2)
|
||||
{
|
||||
leds[l] = CRGB ( COLOR2A, COLOR2B, COLOR2C);
|
||||
leds[l] = CRGB ( 0, 255, 0);
|
||||
}
|
||||
if (l == numlights - 1)
|
||||
{
|
||||
leds[l] = CRGB ( COLOR3A, COLOR3B, COLOR3C);
|
||||
leds[l] = CRGB ( 255, 0, 0);
|
||||
}
|
||||
if (lights[l] <= 0)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#define BYTE_SIZE sizeof(SimData)
|
||||
#define KPHTOMPH .621317
|
||||
#define FANPOWER .6
|
||||
|
||||
|
||||
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
|
||||
|
||||
@@ -46,6 +46,6 @@ void loop() {
|
||||
{
|
||||
v = 255;
|
||||
}
|
||||
myMotor1->setSpeed(v*FANPOWER);
|
||||
myMotor2->setSpeed(v*FANPOWER);
|
||||
myMotor1->setSpeed(v);
|
||||
myMotor2->setSpeed(v);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <poll.h>
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "gameloop.h"
|
||||
#include "../helper/parameters.h"
|
||||
@@ -18,19 +17,6 @@
|
||||
|
||||
#define DEFAULT_UPDATE_RATE 240.0
|
||||
#define SIM_CHECK_RATE 1.0
|
||||
bool go = false;
|
||||
bool go2 = false;
|
||||
struct sigaction act;
|
||||
|
||||
void sighandler(int signum, siginfo_t* info, void* ptr)
|
||||
{
|
||||
sloge("caught signal");
|
||||
go = false;
|
||||
go2 = false;
|
||||
//gfx_clear(pixels, pixels_len);
|
||||
//gfx_swapbuffers();
|
||||
//gfx_close();
|
||||
}
|
||||
|
||||
int showstats(SimData* simdata)
|
||||
{
|
||||
@@ -184,13 +170,16 @@ int showstats(SimData* simdata)
|
||||
|
||||
int clilooper(SimDevice* devices, int numdevices, Parameters* p, SimData* simdata, SimMap* simmap)
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct pollfd mypoll = { STDIN_FILENO, POLLIN|POLLPRI };
|
||||
double update_rate = DEFAULT_UPDATE_RATE;
|
||||
char ch;
|
||||
int t=0;
|
||||
int s=0;
|
||||
go2 = true;
|
||||
while (go2 == true && simdata->simstatus > 1)
|
||||
bool go = true;
|
||||
while (go == true && simdata->simstatus > 1)
|
||||
{
|
||||
simdatamap(simdata, simmap, p->sim);
|
||||
showstats(simdata);
|
||||
@@ -210,7 +199,7 @@ int clilooper(SimDevice* devices, int numdevices, Parameters* p, SimData* simdat
|
||||
scanf("%c", &ch);
|
||||
if(ch == 'q')
|
||||
{
|
||||
go2 = false;
|
||||
go = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,12 +218,6 @@ int clilooper(SimDevice* devices, int numdevices, Parameters* p, SimData* simdat
|
||||
|
||||
int looper(SimDevice* devices, int numdevices, Parameters* p)
|
||||
{
|
||||
memset(&act, 0, sizeof(act));
|
||||
act.sa_sigaction = sighandler;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
sigaction(SIGTERM, &act, NULL);
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
sigaction(SIGTSTP, &act, NULL);
|
||||
|
||||
SimData* simdata = malloc(sizeof(SimData));
|
||||
SimMap* simmap = malloc(sizeof(SimMap));
|
||||
@@ -250,28 +233,18 @@ int looper(SimDevice* devices, int numdevices, Parameters* p)
|
||||
struct pollfd mypoll = { STDIN_FILENO, POLLIN|POLLPRI };
|
||||
|
||||
fprintf(stdout, "Searching for sim data... Press q to quit...\n");
|
||||
|
||||
p->simon = false;
|
||||
double update_rate = SIM_CHECK_RATE;
|
||||
go = true;
|
||||
int go = true;
|
||||
while (go == true)
|
||||
{
|
||||
p->simon = false;
|
||||
|
||||
getSim(simdata, simmap, &p->simon, &p->sim);
|
||||
|
||||
if (p->simon == true && simdata->simstatus > 1)
|
||||
{
|
||||
slogi("preparing game loop with %i devices...", numdevices);
|
||||
|
||||
|
||||
slogi("sending initial data to devices");
|
||||
simdata->velocity = 16;
|
||||
simdata->rpms = 100;
|
||||
for (int x = 0; x < numdevices; x++)
|
||||
{
|
||||
devices[x].update(&devices[x], simdata);
|
||||
}
|
||||
sleep(3);
|
||||
|
||||
clilooper(devices, numdevices, p, simdata, simmap);
|
||||
}
|
||||
if (p->simon == true)
|
||||
@@ -281,15 +254,12 @@ int looper(SimDevice* devices, int numdevices, Parameters* p)
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
if (poll(&mypoll, 1, 1000.0/update_rate) )
|
||||
if( poll(&mypoll, 1, 1000.0/update_rate) )
|
||||
{
|
||||
if (go != false )
|
||||
scanf("%c", &ch);
|
||||
if(ch == 'q')
|
||||
{
|
||||
scanf("%c", &ch);
|
||||
if(ch == 'q')
|
||||
{
|
||||
go = false;
|
||||
}
|
||||
go = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Submodule src/monocoque/simulatorapi/simapi updated: f8c4a167dd...c77e96339c
Reference in New Issue
Block a user