summaryrefslogtreecommitdiff
path: root/src/scanout.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scanout.c')
-rw-r--r--src/scanout.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/scanout.c b/src/scanout.c
index cbb990f..1c5823b 100644
--- a/src/scanout.c
+++ b/src/scanout.c
@@ -23,31 +23,49 @@
#include <string.h>
#include <stdlib.h>
-#include <ctype.h>
#include <libsoup/soup.h>
#include "nanolight.h"
-gboolean scanout_all(struct nanolight *nl)
+int scanout_all(struct nanolight *nl)
{
SoupSession *sess;
SoupMessage *msg;
int i;
+ int dmx[512];
char str[8200];
- strcpy(str, "u=0, d=");
+ /* Start from zero */
+ for ( i=0; i<512; i++ ) dmx[i] = 0;
+
+ /* Loop over fixtures and set values */
+ for ( i=0; i<nl->n_fixtures; i++ ) {
+ int j;
+ struct fixture *fix = &nl->fixtures[i];
+ for ( j=0; j<fix->cls->n_attrs; j++ ) {
+ int pos = fix->base_addr + fix->cls->attrs[j].addr_offset;
+ if ( fix->cls->attrs[j].props & ATTR_16BIT ) {
+ dmx[pos] = (fix->attr_vals[j] & 0xff00) >> 8;
+ dmx[pos+1] = fix->attr_vals[j] & 0xff;
+ } else {
+ dmx[pos] = fix->attr_vals[j];
+ }
+ }
+ }
+
+ /* Loop over DMX channels and prepare request */
+ strcpy(str, "u=1&d=");
for ( i=0; i<512; i++ ) {
char tmp[6];
- snprintf(tmp, 5, "%i,", 255);
+ snprintf(tmp, 5, "%i,", dmx[i]);
strcat(str, tmp);
}
- printf("req='%s'\n", str);
+ /* Send request to OLA */
sess = soup_session_new();
msg = soup_message_new("POST", "http://127.0.0.1:9090/set_dmx");
- soup_message_set_request(msg, "text/plain", SOUP_MEMORY_TEMPORARY, str,
- strlen(str));
-
+ soup_message_set_request(msg, "application/x-www-form-urlencoded",
+ SOUP_MEMORY_TEMPORARY, str, strlen(str));
soup_session_send_message(sess, msg);
g_object_unref(msg);