implement printer led stripe, change some debug levels
This commit is contained in:
parent
eb7fa7347a
commit
57a05a2447
3 changed files with 30 additions and 9 deletions
14
photobooth.c
14
photobooth.c
|
@ -1891,16 +1891,24 @@ static void photo_booth_print_done (GtkPrintOperation *operation, GtkPrintOperat
|
|||
pb = PHOTO_BOOTH (user_data);
|
||||
priv = photo_booth_get_instance_private (pb);
|
||||
|
||||
priv->photos_printed++;
|
||||
GST_INFO_OBJECT (user_data, "print_done photos_printed=%i", priv->photos_printed);
|
||||
|
||||
GError *print_error;
|
||||
if (result == GTK_PRINT_OPERATION_RESULT_ERROR)
|
||||
{
|
||||
gtk_print_operation_get_error (operation, &print_error);
|
||||
photo_booth_printing_error_dialog (priv->win, print_error);
|
||||
GST_ERROR_OBJECT (user_data, "print_done photos_printed GTK_PRINT_OPERATION_RESULT_ERROR: %s", print_error->message);
|
||||
g_error_free (print_error);
|
||||
}
|
||||
else if (result == GTK_PRINT_OPERATION_RESULT_APPLY)
|
||||
{
|
||||
gint copies = gtk_print_settings_get_n_copies (priv->printer_settings);
|
||||
priv->photos_printed += copies;
|
||||
GST_INFO_OBJECT (user_data, "print_done photos_printed copies=%i total=%i", copies, priv->photos_printed);
|
||||
photo_booth_led_printer (priv->led, copies);
|
||||
}
|
||||
else
|
||||
GST_INFO_OBJECT (user_data, "print_done photos_printed unhandled result %i", result);
|
||||
|
||||
g_timeout_add_seconds (15, (GSourceFunc) photo_booth_get_printer_status, pb);
|
||||
|
||||
if (priv->facebook_put_uri)
|
||||
|
|
|
@ -45,7 +45,7 @@ static void photo_booth_led_init (PhotoBoothLed *led)
|
|||
for (int i=0; i < 10; i++)
|
||||
{
|
||||
gchar *devicename = g_strdup_printf ("%s%d", LED_DEVICENAME, i);
|
||||
GST_INFO_OBJECT (led, "trying to open device %s... ", devicename);
|
||||
GST_DEBUG_OBJECT (led, "trying to open device %s... ", devicename);
|
||||
gboolean exists = g_file_test ((const char*) devicename, G_FILE_TEST_EXISTS);
|
||||
if (exists)
|
||||
{
|
||||
|
@ -82,10 +82,10 @@ static void photo_booth_led_init (PhotoBoothLed *led)
|
|||
tcsetattr(led->fd, TCSAFLUSH, &tty);
|
||||
char tempbuf[32];
|
||||
int n = read (led->fd, tempbuf, sizeof(tempbuf)-1);
|
||||
GST_WARNING_OBJECT(led, "read %i bytes: '%s'", n, tempbuf);
|
||||
GST_DEBUG_OBJECT(led, "read %i bytes: '%s'", n, tempbuf);
|
||||
if (g_ascii_strncasecmp ("Photobooth-LED ready", tempbuf, 20) == 0)
|
||||
{
|
||||
GST_WARNING_OBJECT (led, "initialized!");
|
||||
GST_DEBUG_OBJECT (led, "initialized!");
|
||||
photo_booth_led_black (led);
|
||||
}
|
||||
else
|
||||
|
@ -115,7 +115,7 @@ void photo_booth_led_black (PhotoBoothLed *led)
|
|||
if (led->fd > 0)
|
||||
{
|
||||
char cmd = LED_BLACK;
|
||||
GST_INFO_OBJECT(led, "turning off leds");
|
||||
GST_DEBUG_OBJECT(led, "turning off leds");
|
||||
write (led->fd, &cmd, 1);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ void photo_booth_led_countdown (PhotoBoothLed *led, gint seconds)
|
|||
if (led->fd > 0)
|
||||
{
|
||||
char cmd = LED_COUNTDOWN;
|
||||
GST_INFO_OBJECT(led, "countdown %i seconds", seconds);
|
||||
GST_DEBUG_OBJECT(led, "countdown %i seconds", seconds);
|
||||
write (led->fd, &cmd, 1);
|
||||
}
|
||||
}
|
||||
|
@ -135,11 +135,22 @@ void photo_booth_led_flash (PhotoBoothLed *led)
|
|||
if (led->fd > 0)
|
||||
{
|
||||
char cmd = LED_FLASH;
|
||||
GST_INFO_OBJECT(led, "flashing leds");
|
||||
GST_DEBUG_OBJECT(led, "flashing leds");
|
||||
write (led->fd, &cmd, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void photo_booth_led_printer (PhotoBoothLed *led, gint copies)
|
||||
{
|
||||
if (led->fd > 0)
|
||||
{
|
||||
char *cmd = g_strdup_printf ("%c%d", LED_PRINT, copies);
|
||||
GST_DEBUG_OBJECT(led, "turning on printer leds '%s'", cmd);
|
||||
write (led->fd, &cmd, strlen(cmd));
|
||||
g_free (cmd);
|
||||
}
|
||||
}
|
||||
|
||||
PhotoBoothLed * photo_booth_led_new ()
|
||||
{
|
||||
return g_object_new (PHOTO_BOOTH_LED_TYPE, NULL);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#define LED_BLACK 'b'
|
||||
#define LED_COUNTDOWN 'c'
|
||||
#define LED_FLASH 'f'
|
||||
#define LED_PRINT 'p'
|
||||
#define LED_DEVICENAME "/dev/ttyACM"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -51,6 +52,7 @@ PhotoBoothLed *photo_booth_led_new (void);
|
|||
void photo_booth_led_black (PhotoBoothLed *led);
|
||||
void photo_booth_led_countdown (PhotoBoothLed *led, gint seconds);
|
||||
void photo_booth_led_flash (PhotoBoothLed *led);
|
||||
void photo_booth_led_printer (PhotoBoothLed *led, gint copies);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue