Compare commits

...

3 Commits

Author SHA1 Message Date
Christian Kroll e304b78c0d Merge branch 'master' into flipdots 2014-08-10 06:30:43 +02:00
Christian Kroll 5715292237 fpmath_patterns.c: workaround to disable the faulty 32 bit path 2014-07-22 23:53:10 +02:00
Christian Kroll 4583c0fbbb awful but somehow working implementation of flipdot control in the simulator - fire and forget... 2014-07-16 01:25:46 +02:00
2 changed files with 81 additions and 2 deletions

View File

@ -45,9 +45,9 @@
// low precision for displays where each dimension is less than or equal to 16 // low precision for displays where each dimension is less than or equal to 16
#if NUM_COLS <= 16 && NUM_ROWS <= 16 //#if NUM_COLS <= 16 && NUM_ROWS <= 16
#define FP_LOW_PRECISION #define FP_LOW_PRECISION
#endif //#endif
#ifdef FP_LOW_PRECISION #ifdef FP_LOW_PRECISION

View File

@ -27,6 +27,13 @@
#include "../display_loop.h" #include "../display_loop.h"
#include "trackball.h" #include "trackball.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
int sockfd;
struct addrinfo *servinfo, *p;
/** Number of bytes per row. */ /** Number of bytes per row. */
#define LINEBYTES (((NUM_COLS - 1) / 8) + 1) #define LINEBYTES (((NUM_COLS - 1) / 8) + 1)
@ -116,6 +123,35 @@ void display(void) {
glPopMatrix(); glPopMatrix();
glutSwapBuffers(); glutSwapBuffers();
static uint8_t buffer[160] = {0};
/* {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa};*/
static unsigned int divider = 0;
if (++divider == 10) {
for (unsigned int y = 0; y < NUM_ROWS; ++y) {
for (unsigned int lb = 0; lb < LINEBYTES; ++lb) {
unsigned int offset = y * 10 + LINEBYTES - lb - 1;
buffer[offset] = pixmap[0][y][lb];
}
}
sendto(sockfd, buffer, 160, 0, p->ai_addr, p->ai_addrlen);
divider = 0;
}
usleep(20000); usleep(20000);
} }
@ -251,6 +287,46 @@ static void special(int k, int x, int y) {
glutPostRedisplay(); glutPostRedisplay();
} }
int init_socket() {
struct addrinfo hints = {.ai_family = AF_UNSPEC, .ai_socktype = SOCK_DGRAM};
int rv;
int numbytes;
if ((rv = getaddrinfo("flipdot", "2323", &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
return 1;
}
// loop through all the results and make a socket
for(p = servinfo; p != NULL; p = p->ai_next) {
if ((sockfd = socket(p->ai_family, p->ai_socktype,
p->ai_protocol)) == -1) {
perror("talker: socket");
continue;
}
break;
}
if (p == NULL) {
fprintf(stderr, "talker: failed to bind socket\n");
return 2;
}
/*
if ((numbytes = sendto(sockfd, argv[2], strlen(argv[2]), 0,
p->ai_addr, p->ai_addrlen)) == -1) {
perror("talker: sendto");
exit(1);
}
*/
return 0;
}
void free_socket() {
freeaddrinfo(servinfo);
close(sockfd);
}
/** /**
* Entry point for starting the display loop thread. * Entry point for starting the display loop thread.
@ -269,6 +345,7 @@ void *display_loop_run(void * unused) {
* @return Exit codem, always zero. * @return Exit codem, always zero.
*/ */
int main(int argc, char **argv) { int main(int argc, char **argv) {
init_socket();
WindHeight = 700; WindHeight = 700;
WindWidth = 700; WindWidth = 700;
glutInit(&argc, argv); glutInit(&argc, argv);
@ -318,6 +395,8 @@ int main(int argc, char **argv) {
pthread_create(&simthread, NULL, display_loop_run, NULL); pthread_create(&simthread, NULL, display_loop_run, NULL);
glutMainLoop(); glutMainLoop();
free_socket();
return 0; return 0;
} }