summaryrefslogtreecommitdiff
authorDustin Frisch <dustin@dustin-frisch.de>2011-06-20 02:44:18 (GMT)
committer Dustin Frisch <dustin@dustin-frisch.de>2011-06-20 02:44:18 (GMT)
commit41d3df2d2d7ded0ba0bee576bd7cabc02d24704b (patch) (side-by-side diff)
treed08ba13854821919756f6688e3414f1f8789845c
parent18cb5e98c922ce4face3ad290fdfe45ebacab9f5 (diff)
downloadsmartsens-demo-gtk-master.zip
smartsens-demo-gtk-master.tar.gz
Enhanced protocolHEADmaster
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--.cproject1
-rw-r--r--main.glade595
-rw-r--r--src/main.c861
3 files changed, 1209 insertions, 248 deletions
diff --git a/.cproject b/.cproject
index b616727..765f043 100644
--- a/.cproject
+++ b/.cproject
@@ -33,6 +33,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/smartsens-protocol/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/smartsens-server/include}&quot;"/>
<listOptionValue builtIn="false" value="/usr/include/gtk-2.0"/>
+ <listOptionValue builtIn="false" value="/usr/include/glib-2.0"/>
</option>
<option id="gnu.c.compiler.option.debugging.gprof.2080837340" name="Generate gprof information (-pg)" superClass="gnu.c.compiler.option.debugging.gprof" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.misc.other.1326081109" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 `pkg-config gtk+-2.0 --cflags`" valueType="string"/>
diff --git a/main.glade b/main.glade
index 2b94dfc..0c64a73 100644
--- a/main.glade
+++ b/main.glade
@@ -2,7 +2,14 @@
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkListStore" id="connections_liststore"/>
+ <object class="GtkListStore" id="connections_liststore">
+ <columns>
+ <!-- column-name guint1 -->
+ <column type="guint"/>
+ <!-- column-name gboolean1 -->
+ <column type="gboolean"/>
+ </columns>
+ </object>
<object class="GtkWindow" id="window">
<signal name="destroy" handler="on_window_destroy"/>
<child>
@@ -20,20 +27,60 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
- <object class="GtkTreeView" id="connections_treeview">
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="model">connections_liststore</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="connections_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">5</property>
+ <property name="model">connections_liststore</property>
+ <property name="headers_clickable">False</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">0</property>
+ <property name="enable_grid_lines">horizontal</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="id_treeviewcolumn">
+ <property name="title">ID</property>
+ <property name="reorderable">True</property>
+ <property name="sort_indicator">True</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="connected_treeviewcolumn">
+ <property name="title">Connected</property>
+ <child>
+ <object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
+ <attributes>
+ <attribute name="active">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkTable" id="table1">
+ <object class="GtkTable" id="devince_info_table">
<property name="visible">True</property>
- <property name="n_rows">12</property>
+ <property name="border_width">5</property>
+ <property name="n_rows">13</property>
<property name="n_columns">3</property>
+ <property name="column_spacing">3</property>
+ <property name="row_spacing">1</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
@@ -42,30 +89,6 @@
</object>
</child>
<child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Width:</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Height:</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
@@ -85,8 +108,9 @@
<property name="xalign">1</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -100,299 +124,260 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="event_accelerometer_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="feedback_blink_entry">
+ <object class="GtkLabel" id="label11">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Feedback:</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="feedback_vibrator_entry">
+ <object class="GtkCheckButton" id="event_accelerometer_checkbutton">
+ <property name="label" translatable="yes">Accelerometer</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">8</property>
- <property name="bottom_attach">9</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="event_touch_entry">
+ <object class="GtkCheckButton" id="event_gyroscope_checkbutton">
+ <property name="label" translatable="yes">Gyroscope</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="event_proximity_entry">
+ <object class="GtkCheckButton" id="event_light_checkbutton">
+ <property name="label" translatable="yes">Light</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="event_magnetic_field_entry">
+ <object class="GtkCheckButton" id="event_magnetic_field_checkbutton">
+ <property name="label" translatable="yes">Magnetic Field</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="event_light_entry">
+ <object class="GtkCheckButton" id="event_proximity_checkbutton">
+ <property name="label" translatable="yes">Proximity</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="event_gyroscope_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Accelerometer:</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label6">
+ <object class="GtkCheckButton" id="event_touch_checkbutton">
+ <property name="label" translatable="yes">Touch</property>
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Gyroscope:</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label7">
+ <object class="GtkCheckButton" id="feedback_vibrator_checkbutton">
+ <property name="label" translatable="yes">Vibrator</property>
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Light:</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">9</property>
+ <property name="bottom_attach">10</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label8">
+ <object class="GtkCheckButton" id="feedback_blink_checkbutton">
+ <property name="label" translatable="yes">Blink</property>
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Magnetic Field:</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">10</property>
+ <property name="bottom_attach">11</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label9">
+ <object class="GtkCheckButton" id="feedback_flash_checkbutton">
+ <property name="label" translatable="yes">Flash</property>
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Proximity:</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">11</property>
+ <property name="bottom_attach">12</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label10">
+ <object class="GtkCheckButton" id="feedback_screen_checkbutton">
+ <property name="label" translatable="yes">Screen</property>
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Touch:</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">12</property>
+ <property name="bottom_attach">13</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label11">
+ <object class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Feedback:</property>
</object>
<packing>
- <property name="top_attach">8</property>
- <property name="bottom_attach">9</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_padding">3</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label12">
+ <object class="GtkHSeparator" id="hseparator2">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Vibrator:</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
+ <property name="y_padding">3</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label13">
+ <object class="GtkEntry" id="event_accelerometer_max_entry">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Blink:</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x2022;</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">9</property>
- <property name="bottom_attach">10</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label14">
+ <object class="GtkEntry" id="event_gyroscope_max_entry">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Flash:</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x2022;</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">10</property>
- <property name="bottom_attach">11</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="feedback_flash_entry">
+ <object class="GtkEntry" id="event_light_max_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">10</property>
- <property name="bottom_attach">11</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label15">
+ <object class="GtkEntry" id="event_magnetic_field_max_entry">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Screen:</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x2022;</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">11</property>
- <property name="bottom_attach">12</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="feedback_screen_entry">
+ <object class="GtkEntry" id="event_proximity_max_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">&#x2022;</property>
- <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">11</property>
- <property name="bottom_attach">12</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
</packing>
</child>
<child>
@@ -434,7 +419,7 @@
</packing>
</child>
<child>
- <object class="GtkNotebook" id="notebook1">
+ <object class="GtkNotebook" id="event_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tab_pos">bottom</property>
@@ -478,8 +463,9 @@
</packing>
</child>
<child>
- <object class="GtkCurve" id="curve1">
+ <object class="GtkDrawingArea" id="event_accelerometer_x_drawingarea">
<property name="visible">True</property>
+ <signal name="expose_event" handler="event_accelerometer_x_drawingarea_expose_event_cb"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -487,8 +473,9 @@
</packing>
</child>
<child>
- <object class="GtkCurve" id="curve2">
+ <object class="GtkDrawingArea" id="event_accelerometer_y_drawingarea">
<property name="visible">True</property>
+ <signal name="expose_event" handler="event_accelerometer_y_drawingarea_expose_event_cb"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -498,8 +485,9 @@
</packing>
</child>
<child>
- <object class="GtkCurve" id="curve3">
+ <object class="GtkDrawingArea" id="event_accelerometer_z_drawingarea">
<property name="visible">True</property>
+ <signal name="expose_event" handler="event_accelerometer_z_drawingarea_expose_event_cb"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -515,9 +503,87 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Accelerometer</property>
</object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">3</property>
+ <property name="row_spacing">3</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">X:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Y:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Z:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="event_gyroscope_x_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_gyroscope_x_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="event_gyroscope_y_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_gyroscope_y_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="event_gyroscope_z_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_gyroscope_z_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label17">
@@ -526,10 +592,17 @@
</object>
<packing>
<property name="position">1</property>
+ <property name="tab_fill">False</property>
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkDrawingArea" id="event_light_brightness_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_light_brightness_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label18">
@@ -538,10 +611,86 @@
</object>
<packing>
<property name="position">2</property>
+ <property name="tab_fill">False</property>
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkTable" id="table4">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">3</property>
+ <property name="row_spacing">3</property>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">X:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Y:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Z:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="event_magnetic_field_x_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_magnetic_field_x_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="event_magnetic_field_y_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_magnetic_field_y_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="event_magnetic_field_z_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_magnetic_field_z_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label23">
@@ -550,10 +699,17 @@
</object>
<packing>
<property name="position">3</property>
+ <property name="tab_fill">False</property>
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkDrawingArea" id="event_proximity_distance_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_proximity_distance_drawingarea_expose_event_cb"/>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label24">
@@ -562,11 +718,28 @@
</object>
<packing>
<property name="position">4</property>
+ <property name="tab_fill">False</property>
</packing>
</child>
<child>
- <object class="GtkDrawingArea" id="event_touch_drawingarea">
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkViewport" id="event_touch_viewport">
+ <property name="visible">True</property>
+ <property name="resize_mode">queue</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkDrawingArea" id="event_touch_drawingarea">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="event_touch_drawingarea_expose_event_cb"/>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="position">5</property>
@@ -579,6 +752,7 @@
</object>
<packing>
<property name="position">5</property>
+ <property name="tab_fill">False</property>
</packing>
</child>
</object>
@@ -587,7 +761,7 @@
</packing>
</child>
<child>
- <object class="GtkNotebook" id="notebook2">
+ <object class="GtkNotebook" id="feedback_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tab_pos">bottom</property>
@@ -614,6 +788,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
+ <property name="climb_rate">10</property>
+ <property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -637,6 +813,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="feedback_vibrator_send_button_clicked_cb"/>
</object>
<packing>
<property name="right_attach">3</property>
@@ -657,7 +834,13 @@
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label35">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label20">
@@ -670,7 +853,13 @@
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label36">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label21">
@@ -683,7 +872,13 @@
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label37">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label22">
diff --git a/src/main.c b/src/main.c
index d5b8a44..853b36a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,9 +4,12 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include <math.h>
+
#include <errno.h>
#include <netinet/in.h>
@@ -18,17 +21,100 @@
#include <pthread.h>
+#include <glib.h>
#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+
+#include <cairo/cairo.h>
+
+#define SMARTSENS_DEMO_GTK_CONNECTIONS 64
+
+#define SMARTSENS_DEMO_GTK_BUFFER 100
+
+typedef struct {
+ smartsens_server_client_t* client;
+
+ float event_accelerometer_x[SMARTSENS_DEMO_GTK_BUFFER];
+ float event_accelerometer_y[SMARTSENS_DEMO_GTK_BUFFER];
+ float event_accelerometer_z[SMARTSENS_DEMO_GTK_BUFFER];
+
+ float event_gyroscope_x[SMARTSENS_DEMO_GTK_BUFFER];
+ float event_gyroscope_y[SMARTSENS_DEMO_GTK_BUFFER];
+ float event_gyroscope_z[SMARTSENS_DEMO_GTK_BUFFER];
+
+ float event_light_brightness[SMARTSENS_DEMO_GTK_BUFFER];
+
+ float event_magnetic_field_x[SMARTSENS_DEMO_GTK_BUFFER];
+ float event_magnetic_field_y[SMARTSENS_DEMO_GTK_BUFFER];
+ float event_magnetic_field_z[SMARTSENS_DEMO_GTK_BUFFER];
+
+ float event_proximity_distance[SMARTSENS_DEMO_GTK_BUFFER];
+
+ double event_touch_x[SMARTSENS_DEMO_GTK_BUFFER];
+ double event_touch_y[SMARTSENS_DEMO_GTK_BUFFER];
+
+} smartsens_demo_client_t;
smartsens_server_t* server;
+smartsens_demo_client_t* current_client;
+
GtkWidget* window;
GtkTextView* log_textview;
+GtkTable* devince_info_table;
+
+GtkNotebook* event_notebook;
+GtkNotebook* feedback_notebook;
+
GtkEntry* screen_width_entry;
GtkEntry* screen_height_entry;
+GtkCheckButton* event_accelerometer_checkbutton;
+GtkCheckButton* event_gyroscope_checkbutton;
+GtkCheckButton* event_light_checkbutton;
+GtkCheckButton* event_magnetic_field_checkbutton;
+GtkCheckButton* event_proximity_checkbutton;
+GtkCheckButton* event_touch_checkbutton;
+
+GtkCheckButton* feedback_vibrator_checkbutton;
+GtkCheckButton* feedback_blink_checkbutton;
+GtkCheckButton* feedback_flash_checkbutton;
+GtkCheckButton* feedback_screen_checkbutton;
+
+GtkEntry* event_accelerometer_max_entry;
+GtkEntry* event_gyroscope_max_entry;
+GtkEntry* event_light_max_entry;
+GtkEntry* event_magnetic_field_max_entry;
+GtkEntry* event_proximity_max_entry;
+
+GtkTreeView* connections_treeview;
+
+GtkListStore* connections_liststore;
+
+GtkTreeSelection* connections_selection;
+
+GtkDrawingArea* event_accelerometer_x_drawingarea;
+GtkDrawingArea* event_accelerometer_y_drawingarea;
+GtkDrawingArea* event_accelerometer_z_drawingarea;
+
+GtkDrawingArea* event_gyroscope_x_drawingarea;
+GtkDrawingArea* event_gyroscope_y_drawingarea;
+GtkDrawingArea* event_gyroscope_z_drawingarea;
+
+GtkDrawingArea* event_light_brightness_drawingarea;
+
+GtkDrawingArea* event_magnetic_field_x_drawingarea;
+GtkDrawingArea* event_magnetic_field_y_drawingarea;
+GtkDrawingArea* event_magnetic_field_z_drawingarea;
+
+GtkDrawingArea* event_proximity_distance_drawingarea;
+
+GtkDrawingArea* event_touch_drawingarea;
+
+GtkSpinButton* feedback_vibrator_duration_spinbutton;
+
pthread_t server_thread;
void log_print(const char* message) {
@@ -37,16 +123,18 @@ void log_print(const char* message) {
GtkTextIter i;
/* Append message to log */
- gtk_text_buffer_get_end_iter(textbuffer,
- &i);
- gtk_text_buffer_insert(textbuffer,
- &i,
- message,
- -1);
- gtk_text_buffer_insert(textbuffer,
- &i,
- "\n",
- -1);
+// gtk_text_buffer_get_end_iter(textbuffer,
+// &i);
+// gtk_text_buffer_insert(textbuffer,
+// &i,
+// message,
+// -1);
+// gtk_text_buffer_insert(textbuffer,
+// &i,
+// "\n",
+// -1);
+ printf("%s\n",
+ message);
}
void log_printf(const char* format, ...) {
@@ -75,39 +163,613 @@ void on_window_destroy(GtkObject* object,
smartsens_server_destroy(server);
}
+void connections_selections_set(smartsens_server_client_t* client) {
+ if (client != NULL) {
+ uint8_t event_capability = smartsens_server_client_event_capabilities(client);
+ uint8_t feedback_capability = smartsens_server_client_feedback_capabilities(client);
+
+ uint16_t screen_width = smartsens_server_client_screen_width(client);
+ uint16_t screen_height = smartsens_server_client_screen_height(client);
+
+ char text[64];
+
+ sprintf(text,
+ "%u",
+ screen_width);
+ gtk_entry_set_text(screen_width_entry,
+ text);
+
+ sprintf(text,
+ "%u",
+ screen_height);
+ gtk_entry_set_text(screen_height_entry,
+ text);
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(event_accelerometer_checkbutton),
+ event_capability & (1 << SMARTSENS_EVENT_TYPE_ACCELEROMETER));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(event_gyroscope_checkbutton),
+ event_capability & (1 << SMARTSENS_EVENT_TYPE_GYROSCOPE));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(event_light_checkbutton),
+ event_capability & (1 << SMARTSENS_EVENT_TYPE_LIGHT));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(event_magnetic_field_checkbutton),
+ event_capability & (1 << SMARTSENS_EVENT_TYPE_MAGNETIC_FIELD));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(event_proximity_checkbutton),
+ event_capability & (1 << SMARTSENS_EVENT_TYPE_PROXIMITY));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(event_touch_checkbutton),
+ event_capability & (1 << SMARTSENS_EVENT_TYPE_TOUCH));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(feedback_vibrator_checkbutton),
+ feedback_capability & (1 << SMARTSENS_FEEDBACK_TYPE_VIBRATOR));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(feedback_blink_checkbutton),
+ feedback_capability & (1 << SMARTSENS_FEEDBACK_TYPE_BLINKER));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(feedback_flash_checkbutton),
+ feedback_capability & (1 << SMARTSENS_FEEDBACK_TYPE_FLASHER));
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(feedback_screen_checkbutton),
+ feedback_capability & (1 << SMARTSENS_FEEDBACK_TYPE_SCREEN));
+
+ sprintf(text,
+ "%f",
+ smartsens_server_client_event_accelerometer_max(client));
+ gtk_entry_set_text(event_accelerometer_max_entry,
+ text);
+
+ sprintf(text,
+ "%f",
+ smartsens_server_client_event_gyroscope_max(client));
+ gtk_entry_set_text(event_gyroscope_max_entry,
+ text);
+
+ sprintf(text,
+ "%f",
+ smartsens_server_client_event_light_max(client));
+ gtk_entry_set_text(event_light_max_entry,
+ text);
+
+ sprintf(text,
+ "%f",
+ smartsens_server_client_event_magnetic_field_max(client));
+ gtk_entry_set_text(event_magnetic_field_max_entry,
+ text);
+
+ sprintf(text,
+ "%f",
+ smartsens_server_client_event_proximity_max(client));
+ gtk_entry_set_text(event_proximity_max_entry,
+ text);
+
+ gtk_widget_set_size_request(GTK_WIDGET(event_touch_drawingarea),
+ screen_width,
+ screen_height);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(devince_info_table),
+ true);
+ gtk_widget_set_sensitive(GTK_WIDGET(event_notebook),
+ true);
+ gtk_widget_set_sensitive(GTK_WIDGET(feedback_notebook),
+ true);
+
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(devince_info_table),
+ false);
+ gtk_widget_set_sensitive(GTK_WIDGET(event_notebook),
+ false);
+ gtk_widget_set_sensitive(GTK_WIDGET(feedback_notebook),
+ false);
+ }
+}
+
+void on_connections_selection_changed(GtkObject* object,
+ gpointer user_data) {
+ GtkTreeIter iter;
+ GtkTreeModel* model;
+
+ guint id;
+
+ if (gtk_tree_selection_get_selected(connections_selection,
+ &model,
+ &iter)) {
+ smartsens_server_client_t* client;
+
+ gtk_tree_model_get(model,
+ &iter,
+ 0,
+ &id,
+ -1);
+
+ client = smartsens_server_client(server,
+ id);
+
+ current_client = smartsens_server_client_data(client);
+ connections_selections_set(client);
+
+ } else {
+ connections_selections_set(NULL);
+ }
+}
+
void* server_run(void* unused) {
smartsens_server_run(server);
return NULL;
}
void* server_connect_cb(smartsens_server_client_t* client) {
+ smartsens_demo_client_t* demo_client = (smartsens_demo_client_t*) malloc(sizeof(smartsens_demo_client_t));
+ GtkTreeIter i;
+
+ memset(demo_client, 0, sizeof(smartsens_demo_client_t));
+ demo_client->client = client;
+
+ log_printf("Connected client with ID %02X screen_width=%d screen_height=%d event_capability=%02X feedback_capability=%02X",
+ smartsens_server_client_id(client),
+ smartsens_server_client_screen_width(client),
+ smartsens_server_client_screen_height(client),
+ smartsens_server_client_event_capabilities(client),
+ smartsens_server_client_feedback_capabilities(client));
+
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(connections_liststore),
+ &i,
+ gtk_tree_path_new_from_indices(smartsens_server_client_id(client),
+ -1));
+
+ gtk_list_store_set(connections_liststore,
+ &i,
+ 1,
+ true,
+ -1);
+
+ /* Update selected element */
+ current_client = demo_client;
+ connections_selections_set(client);
+
+ return demo_client;
+}
+
+void server_disconnect_cb(smartsens_server_client_t* client) {
+
+ GtkTreeIter i;
log_printf("Connected client with ID %02X",
smartsens_server_client_id(client));
- char text[64];
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(connections_liststore),
+ &i,
+ gtk_tree_path_new_from_indices(smartsens_server_client_id(client),
+ -1));
- sprintf(text,
- "%u",
- smartsens_server_client_screen_width(client));
- gtk_entry_set_text(screen_width_entry,
- text);
+ gtk_list_store_set(connections_liststore,
+ &i,
+ 1,
+ false,
+ -1);
+}
- sprintf(text,
- "%u",
- smartsens_server_client_screen_height(client));
- gtk_entry_set_text(screen_height_entry,
- text);
+void smartsens_event_accelerometer_cb(smartsens_server_client_t* client,
+ const smartsens_packet_event_t* packet) {
+ smartsens_demo_client_t* demo_client = (smartsens_demo_client_t*) smartsens_server_client_data(client);
+
+ float x = packet->data.event_accelerometer.x;
+ float y = packet->data.event_accelerometer.y;
+ float z = packet->data.event_accelerometer.z;
+
+ memmove(demo_client->event_accelerometer_x,
+ demo_client->event_accelerometer_x + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_accelerometer_x[SMARTSENS_DEMO_GTK_BUFFER - 1] = x;
+
+ memmove(demo_client->event_accelerometer_y,
+ demo_client->event_accelerometer_y + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_accelerometer_y[SMARTSENS_DEMO_GTK_BUFFER - 1] = y;
+
+ memmove(demo_client->event_accelerometer_z,
+ demo_client->event_accelerometer_z + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_accelerometer_z[SMARTSENS_DEMO_GTK_BUFFER - 1] = z;
+
+ if (demo_client == current_client) {
+ gtk_widget_queue_draw(GTK_WIDGET(event_accelerometer_x_drawingarea));
+ gtk_widget_queue_draw(GTK_WIDGET(event_accelerometer_y_drawingarea));
+ gtk_widget_queue_draw(GTK_WIDGET(event_accelerometer_z_drawingarea));
+ }
+}
- return NULL;
+void smartsens_event_gyroscope_cb(smartsens_server_client_t* client,
+ const smartsens_packet_event_t* packet) {
+ smartsens_demo_client_t* demo_client = (smartsens_demo_client_t*) smartsens_server_client_data(client);
+
+ float x = packet->data.event_gyroscope.x;
+ float y = packet->data.event_gyroscope.y;
+ float z = packet->data.event_gyroscope.z;
+
+ memmove(demo_client->event_gyroscope_x,
+ demo_client->event_gyroscope_x + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_gyroscope_x[SMARTSENS_DEMO_GTK_BUFFER - 1] = x;
+
+ memmove(demo_client->event_gyroscope_y,
+ demo_client->event_gyroscope_y + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_gyroscope_y[SMARTSENS_DEMO_GTK_BUFFER - 1] = y;
+
+ memmove(demo_client->event_gyroscope_z,
+ demo_client->event_gyroscope_z + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_gyroscope_z[SMARTSENS_DEMO_GTK_BUFFER - 1] = z;
+
+ if (demo_client == current_client) {
+ gtk_widget_queue_draw(GTK_WIDGET(event_gyroscope_x_drawingarea));
+ gtk_widget_queue_draw(GTK_WIDGET(event_gyroscope_y_drawingarea));
+ gtk_widget_queue_draw(GTK_WIDGET(event_gyroscope_z_drawingarea));
+ }
+}
+
+void smartsens_event_light_cb(smartsens_server_client_t* client,
+ const smartsens_packet_event_t* packet) {
+ smartsens_demo_client_t* demo_client = (smartsens_demo_client_t*) smartsens_server_client_data(client);
+
+ float brightness = packet->data.event_light.brightness;
+
+ memmove(demo_client->event_light_brightness,
+ demo_client->event_light_brightness + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_light_brightness[SMARTSENS_DEMO_GTK_BUFFER - 1] = brightness;
+
+ if (demo_client == current_client) {
+ gtk_widget_queue_draw(GTK_WIDGET(event_light_brightness_drawingarea));
+ }
+}
+
+void smartsens_event_magnetic_field_cb(smartsens_server_client_t* client,
+ const smartsens_packet_event_t* packet) {
+ smartsens_demo_client_t* demo_client = (smartsens_demo_client_t*) smartsens_server_client_data(client);
+
+ float x = packet->data.event_magnetic_field.x;
+ float y = packet->data.event_magnetic_field.y;
+ float z = packet->data.event_magnetic_field.z;
+
+ memmove(demo_client->event_magnetic_field_x,
+ demo_client->event_magnetic_field_x + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_magnetic_field_x[SMARTSENS_DEMO_GTK_BUFFER - 1] = x;
+
+ memmove(demo_client->event_magnetic_field_y,
+ demo_client->event_magnetic_field_y + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_magnetic_field_y[SMARTSENS_DEMO_GTK_BUFFER - 1] = y;
+
+ memmove(demo_client->event_magnetic_field_z,
+ demo_client->event_magnetic_field_z + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_magnetic_field_z[SMARTSENS_DEMO_GTK_BUFFER - 1] = z;
+
+ if (demo_client == current_client) {
+ gtk_widget_queue_draw(GTK_WIDGET(event_magnetic_field_x_drawingarea));
+ gtk_widget_queue_draw(GTK_WIDGET(event_magnetic_field_y_drawingarea));
+ gtk_widget_queue_draw(GTK_WIDGET(event_magnetic_field_z_drawingarea));
+ }
+}
+
+void smartsens_event_proximity_cb(smartsens_server_client_t* client,
+ const smartsens_packet_event_t* packet) {
+ smartsens_demo_client_t* demo_client = (smartsens_demo_client_t*) smartsens_server_client_data(client);
+
+ float distance = packet->data.event_proximity.distance;
+
+ memmove(demo_client->event_proximity_distance,
+ demo_client->event_proximity_distance + 1,
+ sizeof(float) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_proximity_distance[SMARTSENS_DEMO_GTK_BUFFER - 1] = distance;
+
+ if (demo_client == current_client) {
+ gtk_widget_queue_draw(GTK_WIDGET(event_proximity_distance_drawingarea));
+ }
+}
+
+void smartsens_event_touch_cb(smartsens_server_client_t* client,
+ const smartsens_packet_event_t* packet) {
+ smartsens_demo_client_t* demo_client = (smartsens_demo_client_t*) smartsens_server_client_data(client);
+
+ double x = ntohs(packet->data.event_touch.x);
+ double y = ntohs(packet->data.event_touch.y);
+
+ memmove(demo_client->event_touch_x,
+ demo_client->event_touch_x + 1,
+ sizeof(double) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_touch_x[SMARTSENS_DEMO_GTK_BUFFER - 1] = x;
+
+ memmove(demo_client->event_touch_y,
+ demo_client->event_touch_y + 1,
+ sizeof(double) * (SMARTSENS_DEMO_GTK_BUFFER - 1));
+ demo_client->event_touch_y[SMARTSENS_DEMO_GTK_BUFFER - 1] = y;
+
+ if (demo_client == current_client) {
+ gtk_widget_queue_draw(GTK_WIDGET(event_touch_drawingarea));
+ }
+}
+
+void graph_draw(GtkWidget* widget,
+ float* data,
+ float min,
+ float max) {
+ size_t i;
+
+ cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget,
+ &allocation);
+
+ double steps = (max - min);
+
+ double step_width = ((double) allocation.width) / ((double) SMARTSENS_DEMO_GTK_BUFFER);
+ double step_height = ((double) allocation.height) / steps;
+
+ cairo_set_source_rgb(cr,
+ 0.0,
+ 0.0,
+ 0.0);
+ cairo_paint(cr);
+
+ cairo_set_source_rgb(cr,
+ 0.2,
+ 0.2,
+ 0.2);
+ cairo_set_line_width(cr,
+ 1.0);
+
+ cairo_move_to(cr,
+ 0.0,
+ ((double) allocation.height) - (0 - min) * step_height);
+ cairo_line_to(cr,
+ allocation.width,
+ ((double) allocation.height) - (0 - min) * step_height);
+ cairo_stroke(cr);
+
+ cairo_set_source_rgb(cr,
+ 0.0,
+ 1.0,
+ 0.0);
+ cairo_set_line_width(cr,
+ 3.0);
+
+ cairo_move_to(cr,
+ 0.0,
+ ((double) allocation.height) - (data[0] - min) * step_height);
+ for (i = 1; i < SMARTSENS_DEMO_GTK_BUFFER; i++) {
+ cairo_line_to(cr,
+ i * step_width,
+ ((double) allocation.height) - (data[i] - min) * step_height);
+ }
+ cairo_stroke(cr);
+
+ cairo_destroy(cr);
+}
+
+void event_accelerometer_x_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_accelerometer_x_drawingarea),
+ current_client->event_accelerometer_x,
+ -smartsens_server_client_event_accelerometer_max(current_client->client),
+ smartsens_server_client_event_accelerometer_max(current_client->client));
+}
+
+void event_accelerometer_y_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_accelerometer_y_drawingarea),
+ current_client->event_accelerometer_y,
+ -smartsens_server_client_event_accelerometer_max(current_client->client),
+ smartsens_server_client_event_accelerometer_max(current_client->client));
+}
+
+void event_accelerometer_z_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_accelerometer_z_drawingarea),
+ current_client->event_accelerometer_z,
+ -smartsens_server_client_event_accelerometer_max(current_client->client),
+ smartsens_server_client_event_accelerometer_max(current_client->client));
+}
+
+void event_gyroscope_x_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_gyroscope_x_drawingarea),
+ current_client->event_gyroscope_x,
+ -smartsens_server_client_event_gyroscope_max(current_client->client),
+ smartsens_server_client_event_gyroscope_max(current_client->client));
+}
+
+void event_gyroscope_y_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_gyroscope_y_drawingarea),
+ current_client->event_gyroscope_y,
+ -smartsens_server_client_event_gyroscope_max(current_client->client),
+ smartsens_server_client_event_gyroscope_max(current_client->client));
+}
+
+void event_gyroscope_z_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_gyroscope_z_drawingarea),
+ current_client->event_gyroscope_z,
+ -smartsens_server_client_event_gyroscope_max(current_client->client),
+ smartsens_server_client_event_gyroscope_max(current_client->client));
+}
+
+void event_light_brightness_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_light_brightness_drawingarea),
+ current_client->event_light_brightness,
+ 0.0f,
+ smartsens_server_client_event_light_max(current_client->client));
+}
+
+void event_magnetic_field_x_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_magnetic_field_x_drawingarea),
+ current_client->event_magnetic_field_x,
+ -smartsens_server_client_event_magnetic_field_max(current_client->client),
+ smartsens_server_client_event_magnetic_field_max(current_client->client));
+}
+
+void event_magnetic_field_y_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_magnetic_field_y_drawingarea),
+ current_client->event_magnetic_field_y,
+ -smartsens_server_client_event_magnetic_field_max(current_client->client),
+ smartsens_server_client_event_magnetic_field_max(current_client->client));
+}
+
+void event_magnetic_field_z_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_magnetic_field_z_drawingarea),
+ current_client->event_magnetic_field_z,
+ -smartsens_server_client_event_magnetic_field_max(current_client->client),
+ smartsens_server_client_event_magnetic_field_max(current_client->client));
+}
+
+void event_proximity_distance_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ if (current_client == NULL) {
+ return;
+ }
+
+ graph_draw(GTK_WIDGET(event_proximity_distance_drawingarea),
+ current_client->event_proximity_distance,
+ 0.0f,
+ smartsens_server_client_event_proximity_max(current_client->client));
+}
+
+void feedback_vibrator_send_button_clicked_cb(GtkObject* object,
+ gpointer user_data) {
+ gint duration;
+
+ duration = gtk_spin_button_get_value_as_int(feedback_vibrator_duration_spinbutton);
+
+ smartsens_server_send_feedback_vibrator(current_client->client,
+ duration);
+}
+
+void event_touch_drawingarea_expose_event_cb(GtkObject* object,
+ gpointer user_data) {
+ size_t i;
+
+ cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(event_touch_drawingarea)));
+
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(GTK_WIDGET(event_touch_drawingarea),
+ &allocation);
+
+ if (current_client == NULL) {
+ return;
+ }
+
+ cairo_set_source_rgb(cr,
+ 0.0,
+ 0.0,
+ 0.0);
+ cairo_paint(cr);
+
+ cairo_set_source_rgb(cr,
+ 8.0,
+ 8.0,
+ 8.0);
+ cairo_set_line_width(cr,
+ 1.0);
+ cairo_move_to(cr,
+ 0.0,
+ 0.0);
+ cairo_line_to(cr,
+ smartsens_server_client_screen_width(current_client->client),
+ 0.0);
+ cairo_line_to(cr,
+ smartsens_server_client_screen_width(current_client->client),
+ smartsens_server_client_screen_height(current_client->client));
+ cairo_line_to(cr,
+ 0.0,
+ smartsens_server_client_screen_height(current_client->client));
+ cairo_line_to(cr,
+ 0.0,
+ 0.0);
+ cairo_stroke(cr);
+
+ for (i = 0; i < SMARTSENS_DEMO_GTK_BUFFER; i++) {
+ cairo_set_source_rgba(cr,
+ 1.0,
+ 0.0,
+ 0.0,
+ ((double) i) / ((double) SMARTSENS_DEMO_GTK_BUFFER));
+ cairo_set_line_width(cr,
+ 3.0);
+
+ cairo_arc(cr,
+ current_client->event_touch_x[i],
+ current_client->event_touch_y[i],
+ 3.0,
+ 0,
+ 2 * M_PI);
+ cairo_fill(cr);
+ }
+
+ cairo_destroy(cr);
}
int main(int argc,
char **argv) {
+ size_t i;
GtkBuilder* builder;
+ current_client = NULL;
+
/* Initialize GTK */
+// g_thread_init(NULL);
+// gdk_threads_init(); //gdk_thread_enter() and gdk_threads_leave()
gtk_init(&argc,
&argv);
@@ -119,14 +781,117 @@ int main(int argc,
/* Get widgets */
window = GTK_WIDGET(gtk_builder_get_object(builder,
- "window"));
+ "window"));
log_textview = GTK_TEXT_VIEW(gtk_builder_get_object(builder,
- "log_textview"));
+ "log_textview"));
+
+ connections_treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder,
+ "connections_treeview"));
+
+ devince_info_table = GTK_TABLE(gtk_builder_get_object(builder,
+ "devince_info_table"));
+
+ event_notebook = GTK_NOTEBOOK(gtk_builder_get_object(builder,
+ "event_notebook"));
+ feedback_notebook = GTK_NOTEBOOK(gtk_builder_get_object(builder,
+ "feedback_notebook"));
screen_width_entry = GTK_ENTRY(gtk_builder_get_object(builder,
- "screen_width_entry"));
+ "screen_width_entry"));
screen_height_entry = GTK_ENTRY(gtk_builder_get_object(builder,
- "screen_height_entry"));
+ "screen_height_entry"));
+
+ event_accelerometer_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "event_accelerometer_checkbutton"));
+ event_gyroscope_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "event_gyroscope_checkbutton"));
+ event_light_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "event_light_checkbutton"));
+ event_magnetic_field_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "event_magnetic_field_checkbutton"));
+ event_proximity_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "event_proximity_checkbutton"));
+ event_touch_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "event_touch_checkbutton"));
+
+ feedback_vibrator_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "feedback_vibrator_checkbutton"));
+ feedback_blink_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "feedback_blink_checkbutton"));
+ feedback_flash_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "feedback_flash_checkbutton"));
+ feedback_screen_checkbutton = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "feedback_screen_checkbutton"));
+
+ event_accelerometer_max_entry = GTK_ENTRY(gtk_builder_get_object(builder,
+ "event_accelerometer_max_entry"));
+ event_gyroscope_max_entry = GTK_ENTRY(gtk_builder_get_object(builder,
+ "event_gyroscope_max_entry"));
+ event_light_max_entry = GTK_ENTRY(gtk_builder_get_object(builder,
+ "event_light_max_entry"));
+ event_magnetic_field_max_entry = GTK_ENTRY(gtk_builder_get_object(builder,
+ "event_magnetic_field_max_entry"));
+ event_proximity_max_entry = GTK_ENTRY(gtk_builder_get_object(builder,
+ "event_proximity_max_entry"));
+
+ connections_liststore = GTK_LIST_STORE(gtk_builder_get_object(builder,
+ "connections_liststore"));
+
+ event_accelerometer_x_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_accelerometer_x_drawingarea"));
+ event_accelerometer_y_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_accelerometer_y_drawingarea"));
+ event_accelerometer_z_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_accelerometer_z_drawingarea"));
+
+ event_gyroscope_x_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_gyroscope_x_drawingarea"));
+ event_gyroscope_y_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_gyroscope_y_drawingarea"));
+ event_gyroscope_z_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_gyroscope_z_drawingarea"));
+
+ event_light_brightness_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_light_brightness_drawingarea"));
+
+ event_magnetic_field_x_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_magnetic_field_x_drawingarea"));
+ event_magnetic_field_y_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_magnetic_field_y_drawingarea"));
+ event_magnetic_field_z_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_magnetic_field_z_drawingarea"));
+
+ event_proximity_distance_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_proximity_distance_drawingarea"));
+
+ event_touch_drawingarea = GTK_DRAWING_AREA(gtk_builder_get_object(builder,
+ "event_touch_drawingarea"));
+
+ feedback_vibrator_duration_spinbutton = GTK_SPIN_BUTTON(gtk_builder_get_object(builder,
+ "feedback_vibrator_duration_spinbutton"));
+
+ /* Build list store for connections */
+ for (i = 0; i < SMARTSENS_DEMO_GTK_CONNECTIONS; i++) {
+ GtkTreeIter iter;
+
+ gtk_list_store_append(connections_liststore,
+ &iter);
+ gtk_list_store_set(connections_liststore,
+ &iter,
+ 0,
+ i,
+ 1,
+ false,
+ -1);
+ }
+
+ /* Listening for selection changes on connections list */
+ connections_selection = gtk_tree_view_get_selection(connections_treeview);
+
+ g_signal_connect(connections_selection,
+ "changed",
+ G_CALLBACK(on_connections_selection_changed),
+ NULL);
/* Connect signals to GUI */
gtk_builder_connect_signals(builder,
@@ -135,28 +900,28 @@ int main(int argc,
g_object_unref(G_OBJECT(builder));
/* Create server and start server thread */
- server = smartsens_server_new(64,
- NULL,
- NULL);
-
-// smartsens_server_register(server,
-// SMARTSENS_EVENT_TYPE_ACCELEROMETER,
-// smartsens_dump_accelerometer);
-// smartsens_server_register(smartsens,
-// SMARTSENS_TYPE_GYROSCOPE,
-// smartsens_dump);
-// smartsens_server_register(smartsens,
-// SMARTSENS_TYPE_LIGHT,
-// smartsens_dump);
-// smartsens_server_register(smartsens,
-// SMARTSENS_TYPE_MAGNETIC_FIELD,
-// smartsens_dump);
-// smartsens_server_register(smartsens,
-// SMARTSENS_TYPE_PROXIMITY,
-// smartsens_dump);
-// smartsens_server_register(server,
-// SMARTSENS_EVENT_TYPE_TOUCH,
-// smartsens_dump);
+ server = smartsens_server_new(SMARTSENS_DEMO_GTK_CONNECTIONS,
+ server_connect_cb,
+ server_disconnect_cb);
+
+ smartsens_server_register(server,
+ SMARTSENS_EVENT_TYPE_ACCELEROMETER,
+ smartsens_event_accelerometer_cb);
+ smartsens_server_register(server,
+ SMARTSENS_EVENT_TYPE_GYROSCOPE,
+ smartsens_event_gyroscope_cb);
+ smartsens_server_register(server,
+ SMARTSENS_EVENT_TYPE_LIGHT,
+ smartsens_event_light_cb);
+ smartsens_server_register(server,
+ SMARTSENS_EVENT_TYPE_MAGNETIC_FIELD,
+ smartsens_event_magnetic_field_cb);
+ smartsens_server_register(server,
+ SMARTSENS_EVENT_TYPE_PROXIMITY,
+ smartsens_event_proximity_cb);
+ smartsens_server_register(server,
+ SMARTSENS_EVENT_TYPE_TOUCH,
+ smartsens_event_touch_cb);
pthread_create(&server_thread,
NULL,