gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] Additional programs and language bindings branch, master, updated.


From: Daniele Forsi
Subject: [SCM] Additional programs and language bindings branch, master, updated. d27fcbe73aa4f4e0d8d9b119e8dc04f8c92e9a53
Date: Mon, 13 Jan 2014 14:54:23 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Additional programs and language bindings".

The branch, master has been updated
       via  d27fcbe73aa4f4e0d8d9b119e8dc04f8c92e9a53 (commit)
      from  149f5659f31530b27f5b455a56622ebbbff39da7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii/gnokii-extras.git/commit/?id=d27fcbe73aa4f4e0d8d9b119e8dc04f8c92e9a53


commit d27fcbe73aa4f4e0d8d9b119e8dc04f8c92e9a53
Author: Daniele Forsi <address@hidden>
Date:   Mon Jan 13 15:50:54 2014 +0100

    Use the new GN_KEY_* definitions to make it more generic

diff --git a/snippets/misc/photo.c b/snippets/misc/photo.c
index e1f8d77..428ecd9 100644
--- a/snippets/misc/photo.c
+++ b/snippets/misc/photo.c
@@ -25,7 +25,7 @@
   Copyright (C) 2014 by Daniele Forsi
 
   Takes a photo with the camera built into the phone.
-  This will work ONLY with Series 40 phones (see include/phones/nk6510.h for 
key values).
+  This will likely work only with Series 40 3rd phones (see include/common.h 
for key values).
 
   compile with
   gcc -Wall -o photo battery_level.c `pkg-config --libs gnokii`
@@ -74,19 +74,33 @@ void signal_handler(int signal) {
        exit(-2);
 }
 
-/* Definitions copied from private includes */
-#define FBUS_FRAME_HEADER 0x00, 0x01, 0x00
-#define NK6510_MSG_KEYPRESS 0x0c
+/* Definition copied from gnokii/gnokii-other.c */
+static gn_error presskey(gn_data *data, struct gn_statemachine *state)
+{
+       gn_error error;
+       error = gn_sm_functions(GN_OP_PressPhoneKey, data, state);
+       if (error == GN_ERR_NONE)
+               error = gn_sm_functions(GN_OP_ReleasePhoneKey, data, state);
+       if (error != GN_ERR_NONE)
+               fprintf(stderr, _("Failed to press key: %s\n"), 
gn_error_print(error));
+       return error;
+}
+
+static gn_error press_camera_key(gn_data *data, struct gn_statemachine *state)
+{
+       data->key_code = GN_KEY_CAMERA;
+       return presskey(data, state);
+}
+
+static gn_error press_red_phone_key(gn_data *data, struct gn_statemachine 
*state)
+{
+       data->key_code = GN_KEY_RED;
+       return presskey(data, state);
+}
 
 int main(int argc, char *argv[]) {
-       gn_data         data;
-       gn_error        error;
-       unsigned char req[] = {FBUS_FRAME_HEADER, 0x11, 0,
-                              2, /* number of blocks */
-                              1, 0x08 /* block length */, 0xe0, 0x5c, 1 /* 
press */, 0, 0, 0,
-                              1, 0x08 /* block length */, 0xe0, 0x5c, 0 /* 
release */, 0, 0, 0};
-       gn_raw_buffer write_buffer = {NK6510_MSG_KEYPRESS, sizeof(req), req};
-       gn_raw_buffer read_buffer = {0, 0, NULL};
+       gn_data data;
+       gn_error error;
 
        if (argc != 1) {
                fprintf(stderr, _("Usage: %s\nPurpose: take a photo with 
supported phones\n"), argv[0]);
@@ -99,20 +113,21 @@ int main(int argc, char *argv[]) {
 
        gn_data_clear(&data);
 
-       /* Press the camera button twice to take a photo */
-       data.write_buffer = &write_buffer;
-       data.read_buffer = &read_buffer;
-       error = gn_sm_functions(GN_OP_Passthrough, &data, state);
-       free(read_buffer.buffer);
-       read_buffer.buffer = NULL;
+       /* Go to the idle screen */
+       error = press_red_phone_key(&data, state);
+       if (error == GN_ERR_NONE) {
+               /* Start the camera app and wait for it to be ready */
+               error = press_camera_key(&data, state);
+               sleep(2);
+       }
        if (error == GN_ERR_NONE) {
-               /* Need to wait a little before the camera app is ready */
+               /* Take a picture and wait for it to be saved */
+               error = press_camera_key(&data, state);
                sleep(2);
-               error = gn_sm_functions(GN_OP_Passthrough, &data, state);
-               free(read_buffer.buffer);
-               read_buffer.buffer = NULL;
-               /* Now we could wait for the photo to be saved, then exit the 
camera app */
        }
+       /* Go back to the idle screen */
+       if (error == GN_ERR_NONE)
+               error = press_red_phone_key(&data, state);
 
        exit(error);
 }

-----------------------------------------------------------------------

Summary of changes:
 snippets/misc/photo.c |   61 ++++++++++++++++++++++++++++++------------------
 1 files changed, 38 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
Additional programs and language bindings



reply via email to

[Prev in Thread] Current Thread [Next in Thread]