Skip to content

Commit

Permalink
#27 - Added graphical indication of goal achievement to animated watch.
Browse files Browse the repository at this point in the history
Evaluate currently executing goal only when workout timer is running.
  • Loading branch information
John Wolfe committed Jul 16, 2014
1 parent 5e91382 commit a1eb4d2
Show file tree
Hide file tree
Showing 29 changed files with 680 additions and 22 deletions.
4 changes: 4 additions & 0 deletions applications/gps/GPS Watch/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/lib
/library
/uidatatypes
/uiinterfaces
Binary file modified applications/gps/GPS Watch/bin/lib/GuiBridge$GuiConnection.class
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/GuiBridge.class
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/SignalData.class
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/WatchGui$1.class
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/WatchGui$2.class
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/WatchGui$3.class
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/WatchGui$4.class
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/WatchGui$5.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/WatchGui$ButtonListener.class
Binary file not shown.
Binary file not shown.
Binary file modified applications/gps/GPS Watch/bin/lib/WatchGui.class
Binary file not shown.
10 changes: 10 additions & 0 deletions applications/gps/GPS Watch/javasrc/lib/GuiBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ public static void setData(float value, int unit) {
}
}

/**
* Send message setIndicator to GUI.
* @param value
*/
public static void setIndicator(int value) {
if (requester != null) {
requester.sendMessage( new SetIndicator(value));
}
}

/**
* When instantiated, the <code>GuiConnection</code> will connect to the
* Watch GUI. It will then sit in a loop waiting for signals from the GUI.
Expand Down
30 changes: 30 additions & 0 deletions applications/gps/GPS Watch/javasrc/lib/SetIndicator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package lib;

import java.io.DataOutputStream;
import java.util.StringTokenizer;

public class SetIndicator extends SignalData {
public static final long serialVersionUID = 0;

public int value;

public SetIndicator() {
super(SIGNAL_NO_SET_INDICATOR);
}

public SetIndicator(int value) {
super(SIGNAL_NO_SET_INDICATOR);
this.value = value;
}

@Override
public void unserialize(StringTokenizer in) {
value = Integer.parseInt(in.nextToken());
}

@Override
public void serialize(DataOutputStream dos) {
super.serialize(dos);
SignalData.serializeInt(dos, value);
}
}
1 change: 1 addition & 0 deletions applications/gps/GPS Watch/javasrc/lib/SignalData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SignalData implements Serializable, Runnable {
// client to server signals
public static final int SIGNAL_NO_SET_DATA = 0;
public static final int SIGNAL_NO_SET_TIME = 1;
public static final int SIGNAL_NO_SET_INDICATOR = 2;

//server to client signals
public static final int SIGNAL_NO_START_STOP_PRESSED = 0;
Expand Down
48 changes: 47 additions & 1 deletion applications/gps/GPS Watch/javasrc/lib/WatchGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class WatchGui extends JFrame {

public static final int LARGE_Y = 355;
public static final int SMALL_Y = 295;
public static final int INDICATOR_Y = SMALL_Y + ((LARGE_Y - SMALL_Y) / 2);

public static final String[] UNIT_LABELS = new String[] {
"km",
Expand All @@ -51,6 +52,11 @@ public class WatchGui extends JFrame {
public static final int UNIT_MPH = 8;
public static final int UNIT_BPM = 9;
public static final int UNIT_LAPS = 10;

public static final int INDICATOR_BLANK = 0;
public static final int INDICATOR_DOWN = 1;
public static final int INDICATOR_FLAT = 2;
public static final int INDICATOR_UP = 3;

private WatchGui.ApplicationConnection server;
private JPanel holdAll = new JPanel();
Expand All @@ -69,6 +75,10 @@ public class WatchGui extends JFrame {
protected ImageIcon startStopPressed;
protected ImageIcon smallSeparator;
protected ImageIcon largeDots;
protected ImageIcon upArrow;
protected ImageIcon downArrow;
protected ImageIcon flat;
protected ImageIcon blank;
protected ImageIcon smallDigit[] = new ImageIcon[10];
protected ImageIcon largeDigit[] = new ImageIcon[10];

Expand All @@ -81,6 +91,7 @@ public class WatchGui extends JFrame {
private JLabel smallSeparatorLabel = new JLabel();
private JLabel largeDotsLabel = new JLabel();
private JLabel unitsLabel = new JLabel();
private JLabel indicatorLabel = new JLabel();

private JLabel[] smallDigitLabel = new JLabel[4];
private JLabel[] largeDigitLabel = new JLabel[4];
Expand All @@ -107,8 +118,12 @@ protected void createImageIcons() {
lapResetPressed = createStandaloneImageIcon("lib/img/lap_reset_pressed.png");
startStopHover = createStandaloneImageIcon("lib/img/start_stop_hover.png");
startStopPressed = createStandaloneImageIcon("lib/img/start_stop_pressed.png");
smallSeparator = createStandaloneImageIcon("lib/img/dots_small.png");
smallSeparator = createStandaloneImageIcon("lib/img/dots_small.png");
largeDots = createStandaloneImageIcon("lib/img/dots_large.png");
upArrow = createStandaloneImageIcon("lib/img/up.png");
downArrow = createStandaloneImageIcon("lib/img/down.png");
blank = createStandaloneImageIcon("lib/img/blank.png");
flat = createStandaloneImageIcon("lib/img/flat.png");
for (int i = 0; i < largeDigit.length; i++) {
largeDigit[i] = createStandaloneImageIcon("lib/img/" + i + "_large.png");
smallDigit[i] = createStandaloneImageIcon("lib/img/" + i + "_small.png");
Expand Down Expand Up @@ -171,6 +186,9 @@ public void buttonPressed() {
largeDotsLabel.setBounds(242, LARGE_Y + 28, 13, 35);
largeDotsLabel.setIcon(largeDots);

indicatorLabel.setBounds(120, INDICATOR_Y, 26, 51);
indicatorLabel.setIcon(blank);

unitsLabel.setText("");
unitsLabel.setBounds(275, SMALL_Y + 28, 100, 25);
unitsLabel.setForeground(Color.DARK_GRAY);
Expand All @@ -186,6 +204,7 @@ public void buttonPressed() {
pane.add(smallSeparatorLabel, JLayeredPane.POPUP_LAYER);
pane.add(largeDotsLabel, JLayeredPane.POPUP_LAYER);
pane.add(unitsLabel, JLayeredPane.POPUP_LAYER);
pane.add(indicatorLabel, JLayeredPane.POPUP_LAYER);

for (int i = 0; i < largeDigitLabel.length; i++) {
smallDigitLabel[i] = new JLabel();
Expand Down Expand Up @@ -291,6 +310,24 @@ public void setData(float value, int unit) {
}
setUnit(UNIT_LABELS[unit]);
}
public void setIndicator(int value){
switch (value) {

case INDICATOR_DOWN:
indicatorLabel.setIcon(downArrow);
break;
case INDICATOR_FLAT:
indicatorLabel.setIcon(flat);
break;
case INDICATOR_UP:
indicatorLabel.setIcon(upArrow);
break;
case INDICATOR_BLANK:
indicatorLabel.setIcon(blank);
default:
break;
}
}

/**
* A generic button listener that will switch images when
Expand Down Expand Up @@ -428,6 +465,15 @@ public void run() {
}
};
break;
case SignalData.SIGNAL_NO_SET_INDICATOR:
data = new SetIndicator() {
public static final long serialVersionUID = 0;
@Override
public void run() {
setIndicator(value);
}
};
break;
default:
break;
}
Expand Down
Binary file added applications/gps/GPS Watch/javasrc/lib/img/blank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/gps/GPS Watch/javasrc/lib/img/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/gps/GPS Watch/javasrc/lib/img/flat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/gps/GPS Watch/javasrc/lib/img/up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ if ( distance > 1000.0 )
send UI::setData(value: distance / 1000.0, unit: Unit::km);
else
send UI::setData(value: distance, unit: Unit::meters);
end if;',
end if;
send UI::setIndicator( indicator: Display::goalDispositionIndicator() );',
'');
INSERT INTO SM_MOAH
VALUES ("49e1102e-0e00-4fe3-bffe-c39c2e793234",
Expand Down Expand Up @@ -326,6 +327,7 @@ INSERT INTO SM_ACT
self->WorkoutSession[R7.''indicates current status of'']->
TrackLog[R4.''captures path in'']->LapMarker[R5.''has laps defined by''];
send UI::setData(value: cardinality lapMarkers, unit: Unit::laps);
send UI::setIndicator( indicator: Display::goalDispositionIndicator() );
',
'');
INSERT INTO SM_TAH
Expand Down Expand Up @@ -442,7 +444,7 @@ INSERT INTO SM_AH
INSERT INTO SM_ACT
VALUES ("229102f9-6d0b-44af-90bb-ae61d289a2e0",
"a976fe2a-d67c-4ae5-b5fd-21cf77c5de22",
3,
1,
'',
'');
INSERT INTO SM_TAH
Expand All @@ -455,7 +457,7 @@ INSERT INTO SM_AH
INSERT INTO SM_ACT
VALUES ("affc1c39-a423-41f6-bb0a-e3faa00c7912",
"a976fe2a-d67c-4ae5-b5fd-21cf77c5de22",
3,
1,
'',
'');
INSERT INTO GD_MD
Expand Down Expand Up @@ -489,11 +491,11 @@ INSERT INTO GD_SHP
INSERT INTO GD_NCS
VALUES ("b1717eaa-2733-4617-a2c2-83c920803e72");
INSERT INTO DIM_ND
VALUES (361.000000,
193.000000,
VALUES (397.000000,
204.000000,
"b1717eaa-2733-4617-a2c2-83c920803e72");
INSERT INTO DIM_GE
VALUES (4452.000000,
VALUES (4416.000000,
2928.000000,
"b1717eaa-2733-4617-a2c2-83c920803e72",
"00000000-0000-0000-0000-000000000000");
Expand All @@ -514,12 +516,12 @@ INSERT INTO DIM_CON
INSERT INTO DIM_CON
VALUES ("12054a9d-9780-428f-855d-34ef8a48f096",
4572.000000,
3121.000000,
3132.000000,
"b1717eaa-2733-4617-a2c2-83c920803e72");
INSERT INTO DIM_CON
VALUES ("ce892560-74b2-4664-916c-bffa91844ab9",
4656.000000,
3121.000000,
3132.000000,
"b1717eaa-2733-4617-a2c2-83c920803e72");
INSERT INTO DIM_CON
VALUES ("7ba7c82d-4adb-4375-9b48-3eb322ff068a",
Expand All @@ -529,7 +531,7 @@ INSERT INTO DIM_CON
INSERT INTO DIM_CON
VALUES ("f10e76a3-cd17-43dc-aed3-ae032580b894",
4500.000000,
3121.000000,
3132.000000,
"b1717eaa-2733-4617-a2c2-83c920803e72");
INSERT INTO GD_GE
VALUES ("2fe033e7-e623-44bc-a5b2-1f774b72d21d",
Expand Down Expand Up @@ -1168,7 +1170,7 @@ INSERT INTO DIM_ND
"494bbdde-9dc7-4e36-86f7-3173cde6cd33");
INSERT INTO DIM_GE
VALUES (4568.000000,
3166.000000,
3177.000000,
"494bbdde-9dc7-4e36-86f7-3173cde6cd33",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down Expand Up @@ -1215,28 +1217,28 @@ INSERT INTO GD_LS
INSERT INTO DIM_WAY
VALUES ("c308f489-5ba6-4261-8feb-260a1edd9d5a",
4572.000000,
3121.000000,
3132.000000,
"de959ea9-5e8b-4798-9a14-b751d583e136",
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_WAY
VALUES ("09de6dc8-a752-4f65-b359-5b1ce816e89b",
4572.000000,
3156.000000,
3167.000000,
"de959ea9-5e8b-4798-9a14-b751d583e136",
"00000000-0000-0000-0000-000000000000",
"c308f489-5ba6-4261-8feb-260a1edd9d5a");
INSERT INTO DIM_WAY
VALUES ("ee93660e-cf0f-4434-bdb1-f74867427c92",
4656.000000,
3121.000000,
3132.000000,
"de959ea9-5e8b-4798-9a14-b751d583e136",
"00000000-0000-0000-0000-000000000000",
"09de6dc8-a752-4f65-b359-5b1ce816e89b");
INSERT INTO DIM_WAY
VALUES ("46cf88db-326f-43e4-bdad-e8769846769d",
4656.000000,
3156.000000,
3167.000000,
"de959ea9-5e8b-4798-9a14-b751d583e136",
"00000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000000000000");
Expand Down Expand Up @@ -1798,7 +1800,7 @@ INSERT INTO DIM_ND
"7117ce76-0fd0-4a83-9708-cb36b3db6554");
INSERT INTO DIM_GE
VALUES (4504.000000,
3246.000000,
3251.500000,
"7117ce76-0fd0-4a83-9708-cb36b3db6554",
"00000000-0000-0000-0000-000000000000");
INSERT INTO DIM_ELE
Expand Down Expand Up @@ -1840,7 +1842,7 @@ INSERT INTO DIM_WAY
INSERT INTO DIM_WAY
VALUES ("c206ad65-21eb-467b-97b2-cd62d63d922f",
4500.000000,
3121.000000,
3132.000000,
"80fb7395-3841-4e33-a080-a956bcb45c25",
"00000000-0000-0000-0000-000000000000",
"1fbb4e6b-5058-4b92-b670-091180f13c5f");
Expand Down
Loading

0 comments on commit a1eb4d2

Please sign in to comment.