void reply(DBusMessage *msg, DBusConnection *conn) { DBusMessage *reply; DBusMessageIter args; long t_response = -1; double d_response = -1; if (dbus_message_is_method_call(msg, DBUS_NAMESPACE, "Sunrise")) { t_response = sunrise(msg); } if (dbus_message_is_method_call(msg, DBUS_NAMESPACE, "Sunset")) { t_response = sunset(msg); } if (dbus_message_is_method_call(msg, DBUS_NAMESPACE, "Brightness")) { d_response = brightness(msg); } reply = dbus_message_new_method_return(msg); dbus_message_iter_init_append(reply, &args); if (t_response >= 0) { sendT(conn, reply, &args, t_response); } if (d_response >= 0) { sendD(conn, reply, &args, d_response); } dbus_connection_flush(conn); dbus_message_unref(reply); }
void handleKeydown (SDLKey key) { float tempin; // printf("keydown: %d\n", key); if (inputmode > 0 && key != 13) { userinputbuffer[userinputbufferpos] = (uint8_t)key; userinputbufferpos ++; if (userinputbufferpos == 128) { printf("\nuser input buffer overflow\n"); userinputbufferpos = 0; } } switch (key) { case SDLK_ESCAPE: break; case 112: /* P */ printf("\nType new P value: "); inputmode = 1; break; case 105: /* I */ printf("\nType new I value: "); inputmode = 2; break; case 100: /* D */ printf("\nType new D value: "); inputmode = 3; break; case 115: /* S */ printf("\nCurrent PID values: "); printf("P = %f, ", KPin); printf("I = %f, ", KIin); printf("D = %f\n", KDin); printf(" New PID values: "); printf("P = %f, ", KPout); printf("I = %f, ", KIout); printf("D = %f\n", KDout); fflush(stdout); break; case 103: /* G */ getPID(); break; case 13: /* enter */ parseuserinput(); break; case 113: /* Q */ sendP(); break; case 119: /* W */ sendI(); break; case 101: /* E */ sendD(); break; case 108: /* L */ startlog(); break; case 107: /* K */ printlog(); break; } }