diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cameras/uca-mock-camera.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/cameras/uca-mock-camera.c b/src/cameras/uca-mock-camera.c index da186a8..d27423e 100644 --- a/src/cameras/uca-mock-camera.c +++ b/src/cameras/uca-mock-camera.c @@ -71,6 +71,7 @@ struct _UcaMockCameraPrivate { gfloat frame_rate; gfloat max_frame_rate; guint8 *dummy_data; + guint current_frame; gboolean thread_running; @@ -78,6 +79,94 @@ struct _UcaMockCameraPrivate { GValueArray *binnings; }; +static const char g_digits[10][20] = { + /* 0 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 1 */ + { 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0xff, 0x00, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0x00, 0xff, 0x00 }, + /* 2 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff }, + /* 3 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 4 */ + { 0xff, 0x00, 0x00, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff }, + /* 5 */ + { 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0x00 }, + /* 6 */ + { 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 7 */ + { 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, 0x00, + 0xff, 0x00, 0x00, 0x00 }, + /* 8 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 9 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0x00 } +}; + +const guint DIGIT_WIDTH = 4; +const guint DIGIT_HEIGHT = 5; + +static void print_number(gchar *buffer, guint number, guint x, guint y, guint width) +{ + for (int i = 0; i < DIGIT_WIDTH; i++) { + for (int j = 0; j < DIGIT_HEIGHT; j++) { + buffer[(y+j)*width + (x+i)] = g_digits[number][j*DIGIT_WIDTH+i]; + } + } +} + +static void print_current_frame(UcaMockCameraPrivate *priv, gchar *buffer) +{ + guint number = priv->current_frame; + guint divisor = 100000000; + int x = 10; + while (divisor > 1) { + print_number(buffer, number / divisor, x, 10, priv->width); + number = number % divisor; + divisor = divisor / 10; + x += DIGIT_WIDTH + 1; + } +} + /** * uca_mock_camera_new: * @error: Location for error @@ -163,6 +252,8 @@ static void uca_mock_camera_grab(UcaCamera *camera, gpointer *data, GError **err *data = g_malloc0(priv->width * priv->height); g_memmove(*data, priv->dummy_data, priv->width * priv->height); + print_current_frame(priv, *data); + priv->current_frame++; } static void uca_mock_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) @@ -290,6 +381,7 @@ static void uca_mock_camera_init(UcaMockCamera *self) self->priv->frame_rate = self->priv->max_frame_rate = 100000.0f; self->priv->dummy_data = (guint8 *) g_malloc0(self->priv->width * self->priv->height); self->priv->grab_thread = NULL; + self->priv->current_frame = 0; self->priv->binnings = g_value_array_new(1); GValue val = {0}; |