Merge branch 'master' of repos.ctdo.de:psychose

This commit is contained in:
Stefan Kögl 2014-12-03 16:33:07 +01:00
commit 5da5f207b4
57 changed files with 7598 additions and 997 deletions

View File

@ -174,8 +174,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow,
except AttributeError:
pass
else:
if text == "temperatur":
text += "e"
if actor == "merle":
self.add_text(0, "%s = %s" % (
text, ", ".join([str(i) for i in args])))

View File

@ -59,14 +59,14 @@ float getTemperature(void)
void loop() {
zaehler++;
int airFlow = analogRead(A1);
int emg = analogRead(0);
int temp = getTemperature();
Serial.print(airFlow);
// int airFlow = analogRead(A1);
// int emg = analogRead(0);
// int temp = getTemperature();
Serial.print(analogRead(A1));
Serial.print(";");
Serial.print(emg);
Serial.print(analogRead(0));
Serial.print(";");
Serial.println(temp);
Serial.println(getTemperature());
delay(100);
if(zaehler >= 10) {

View File

@ -0,0 +1 @@
(if (contains (window_name) "VLC media player") (undecorate))

23
fensterkram/positions.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# vlc mit Kamera
STR="Universal Pictures"
wmctrl -r $STR -e 0,1600,0,640,480
wmctrl -r $STR -b add,sticky,above
# vlc mit annes texter
STR="http://walter"
wmctrl -r $STR -e 0,2240,0,640,480
wmctrl -r $STR -b add,sticky,above
# datenstroeme
STR="http://devimages"
wmctrl -r $STR -e 0,2880,0,640,480
wmctrl -r $STR -b add,sticky,above
#das HealthDisplay
wmctrl -r "HD Main" -e 0,2570,480,950,570
wmctrl -r "HD Main" -b add,sticky,above
killall devilspie
devilspie &

7
fensterkram/vlc_webcam.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
vlc --no-audio --video-on-top --no-video-title-show --no-osd \
--repeat --qt-notification 0 --no-video-deco --autoscale \
../streaming/Serenity\ -\ HD\ DVD\ Trailer.mp4

View File

@ -1,5 +1,3 @@
<component name="CopyrightManager">
<settings default="">
<module2copyright />
</settings>
<settings default="" />
</component>

View File

@ -10,7 +10,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -119,16 +119,21 @@
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
<item class="main.java.de.psychose.ActorDisplay" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item>
<item class="de.psychose.StatsDisplay" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item>
<item class="de.psychose.PulseControl" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item>
<item class="de.psychose.ActorHeart" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item>
<item class="de.psychose.ActorDisplay" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item>
<item class="de.psychose.TemperatureControl" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item>
</group>
</component>
</project>
</project>

View File

@ -1,5 +1,10 @@
you need jdk 1.7 or newer and maven2 installed
compile with
mvn clean compile ideauidesigner:javac2 assembly:single
run with
java -jar psychose-X.X-jar-with-dependencies.jar

View File

@ -5,20 +5,19 @@
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="clibwrapper_jiio" level="project" />
<orderEntry type="library" name="jai_imageio" level="project" />
<orderEntry type="library" name="Maven: com.illposed.osc:javaosc-core:0.2" level="project" />
<orderEntry type="library" name="Maven: org.jboss.netty:netty:3.2.7.Final" level="project" />
<orderEntry type="library" name="Maven: com.intellij:forms_rt:7.0.3" level="project" />
<orderEntry type="library" name="Maven: asm:asm-commons:3.0" level="project" />
<orderEntry type="library" name="Maven: asm:asm-tree:3.0" level="project" />
<orderEntry type="library" name="Maven: asm:asm:3.0" level="project" />
<orderEntry type="library" name="Maven: com.jgoodies:forms:1.1-preview" level="project" />
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
<orderEntry type="library" name="Maven: org.snmp4j:snmp4j:1.9.1f" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.9" level="project" />
</component>
</module>
</module>

View File

@ -15,21 +15,22 @@
<version>0.2</version>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.7.Final</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.jboss.netty</groupId>-->
<!--<artifactId>netty</artifactId>-->
<!--<version>3.2.7.Final</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.intellij</groupId>
<artifactId>forms_rt</artifactId>
<version>7.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.snmp4j</groupId>
<artifactId>snmp4j</artifactId>
<version>1.9.1f</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.snmp4j</groupId>-->
<!--<artifactId>snmp4j</artifactId>-->
<!--<version>1.9.1f</version>-->
<!--</dependency>-->
</dependencies>

View File

@ -0,0 +1,162 @@
package de.psychose;
/**
* @author: lucas
* @date: 17.11.14 21:07
*/
public class ActorData {
private String actor = "";
private String caption = "";
private PulseData pulseData = new PulseData();
private int airflow;
private int ekg;
private int emg;
private double temperature;
private double temperatureOffset;
private boolean tommyHeartbeat;
private long timestampPulse = 0;
private long timestampHeartbeat = 0;
private long timestampOxygen = 0;
private long timestampTommyHeartbeat = 0;
private long timestampEkg = 0;
private long timestampEmg = 0;
private long timestampTemperature = 0;
private long timestampBreath = 0;
public ActorData(String actor, String caption) {
this.actor = actor;
this.caption = caption;
}
public String getActor() {
return actor;
}
public String getCaption() {
return caption;
}
public int getOxygen() {
return pulseData.getOxygen();
}
public void setOxygen(int oxygen) {
timestampOxygen = System.currentTimeMillis();
pulseData.setOxygen(oxygen);
}
public boolean getHeartbeat() {
return pulseData.getHeartbeat();
}
public void setHeartbeat(boolean heartbeat) {
timestampHeartbeat = System.currentTimeMillis();
pulseData.setHeartbeat(heartbeat);
}
public int getPulse() {
return pulseData.getPulse();
}
public void setPulse(int pulse) {
timestampPulse = System.currentTimeMillis();
pulseData.setPulse(pulse);
}
public int getAirflow() {
return airflow;
}
public void setAirflow(int airflow) {
this.airflow = airflow;
this.timestampBreath = System.currentTimeMillis();
}
public int getEkg() {
return ekg;
}
public void setEkg(int ekg) {
this.ekg = ekg;
this.timestampEkg = System.currentTimeMillis();
}
public int getEmg() {
return emg;
}
public void setEmg(int emg) {
this.emg = emg;
this.timestampEmg = System.currentTimeMillis();
}
public double getTemperature() {
return temperature;
}
public void setTemperature(double temperature) {
this.temperature = temperature;
this.timestampTemperature = System.currentTimeMillis();
}
public boolean getTommyHeartbeat() {
return tommyHeartbeat;
}
public void setTommyHeartbeat(boolean tommyHeartbeat) {
this.tommyHeartbeat = tommyHeartbeat;
this.timestampTommyHeartbeat = System.currentTimeMillis();
}
public double getTemperatureOffset() {
return temperatureOffset;
}
public void setTemperatureOffset(double temperatureOffset) {
this.temperatureOffset = temperatureOffset;
}
public long getTimestampPulse() {
return timestampPulse;
}
public long getTimestampEkg() {
return timestampEkg;
}
public long getTimestampEmg() {
return timestampEmg;
}
public long getTimestampTemperature() {
return timestampTemperature;
}
public long getTimestampBreath() {
return timestampBreath;
}
@Override
public String toString() {
return "ActorData{" +
"actor='" + actor + '\'' +
", caption='" + caption + '\'' +
", airflow=" + airflow +
", ekg=" + ekg +
", emg=" + emg +
", temperature=" + temperature +
", temperatureOffset=" + temperatureOffset +
", tommyHeartbeat=" + tommyHeartbeat +
", timestampPulse=" + timestampPulse +
", timestampHeartbeat=" + timestampHeartbeat +
", timestampOxygen=" + timestampOxygen +
", timestampTommyHeartbeat=" + timestampTommyHeartbeat +
", timestampEkg=" + timestampEkg +
", timestampEmg=" + timestampEmg +
", timestampTemperature=" + timestampTemperature +
", timestampBreath=" + timestampBreath +
'}';
}
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.ActorDisplay">
<grid id="27dc6" binding="actorPanel" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="4" left="6" bottom="4" right="6"/>
<constraints>
<xy x="20" y="20" width="316" height="302"/>

View File

@ -2,19 +2,14 @@ package de.psychose;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.text.DecimalFormat;
/**
* @author: lucas
* @date: 14.04.14 21:44
*/
public class ActorDisplay {
private final Timer timer;
private final static Color onColor = Color.WHITE;
private final static Color offColor = Color.RED;
private final static String offText = "no data";
private JPanel actorPanel;
private static final long TIMEOUT_MILLISECONDS = 2000;
private JLabel lblCaption;
private JLabel lblHeartbeat;
private JLabel lblPulse;
@ -23,116 +18,48 @@ public class ActorDisplay {
private JLabel lblEmg;
private JLabel lblTemperature;
private JLabel lblBreath;
private JPanel mainPanel;
private ActorData actorData;
private boolean showErrors = false;
private DecimalFormat df = new DecimalFormat("#.0");
private int counterHeartbeat = 0;
private int counterPulse = 0;
private int counterOxy = 0;
private int counterEkg = 0;
private int counterEmg = 0;
private int counterTemperature = 0;
private int counterBreath = 0;
public void update() {
if (actorData == null) {
return;
}
private int timeout = 20; // 20 * 100ms
lblBreath.setText(String.valueOf(actorData.getAirflow()));
lblTemperature.setText(df.format(actorData.getTemperature() + actorData.getTemperatureOffset()));
lblEkg.setText(String.valueOf(actorData.getEkg()));
lblPulse.setText(actorData.getHeartbeat() ? "systole" : "diastole");
lblEmg.setText(String.valueOf(actorData.getEmg()));
lblOxy.setText(String.valueOf(actorData.getOxygen()));
lblHeartbeat.setText(String.valueOf(actorData.getPulse()));
public void setCaption(String caption) {
lblCaption.setText(caption);
if (showErrors) {
checkTimeout(lblTemperature, actorData.getTimestampTemperature());
checkTimeout(lblPulse, actorData.getTimestampPulse());
checkTimeout(lblOxy, actorData.getTimestampPulse());
checkTimeout(lblHeartbeat, actorData.getTimestampPulse());
checkTimeout(lblEkg, actorData.getTimestampEkg());
checkTimeout(lblEmg, actorData.getTimestampEmg());
checkTimeout(lblBreath, actorData.getTimestampBreath());
}
}
public void setBreath(String breath) {
lblBreath.setText(breath);
counterBreath = 0;
public void init(ActorData actorData, final boolean showErrors) {
this.actorData = actorData;
lblCaption.setText(actorData.getCaption());
this.showErrors = showErrors;
}
public void setTemperature(String temperature) {
lblTemperature.setText(temperature);
counterTemperature = 0;
}
public void setEkg(String value) {
lblEkg.setText(value);
counterEkg = 0;
}
public void setPulse(String pulse) {
lblPulse.setText(pulse);
counterPulse = 0;
}
public void setEmg(String emg) {
lblEmg.setText(emg);
counterEmg = 0;
}
public void setOxy(String oxy) {
lblOxy.setText(oxy);
counterOxy = 0;
}
public void setHeartbeat(String heartbeat) {
lblHeartbeat.setText(heartbeat);
counterHeartbeat = 0;
}
public ActorDisplay() {
this.timer = new Timer(100, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (++counterTemperature > timeout) {
lblTemperature.setForeground(offColor);
lblTemperature.setText(offText);
} else {
lblTemperature.setForeground(onColor);
}
if (++counterPulse > timeout) {
lblPulse.setForeground(offColor);
lblPulse.setText(offText);
} else {
lblPulse.setForeground(onColor);
}
if (++counterOxy > timeout) {
lblOxy.setForeground(offColor);
lblOxy.setText(offText);
} else {
lblOxy.setForeground(onColor);
}
if (++counterEkg > timeout) {
lblEkg.setForeground(offColor);
lblEkg.setText(offText);
} else {
lblEkg.setForeground(onColor);
}
if (++counterEmg > timeout) {
lblEmg.setForeground(offColor);
lblEmg.setText(offText);
} else {
lblEmg.setForeground(onColor);
}
if (++counterHeartbeat > timeout) {
lblHeartbeat.setForeground(offColor);
lblHeartbeat.setText(offText);
} else {
lblHeartbeat.setForeground(onColor);
}
if (++counterBreath > timeout) {
lblBreath.setForeground(offColor);
lblBreath.setText(offText);
} else {
lblBreath.setForeground(onColor);
}
}
});
this.timer.setRepeats(true);
}
public void startErrorTimer() {
this.timer.start();
private void checkTimeout(final JLabel label, final long time) {
if (time < System.currentTimeMillis() - TIMEOUT_MILLISECONDS) {
label.setText("no data");
label.setForeground(Color.red);
} else {
label.setForeground(Color.white);
}
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.ActorHeart">
<grid id="27dc6" binding="mainPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="20" y="20" width="789" height="299"/>
</constraints>
<properties>
<background color="-16777216"/>
<enabled value="true"/>
<focusable value="false"/>
<maximumSize width="789" height="299"/>
<minimumSize width="789" height="299"/>
<preferredSize width="789" height="299"/>
</properties>
<border type="none"/>
<children/>
</grid>
</form>

View File

@ -0,0 +1,57 @@
package de.psychose;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
* @author: lucas
* @date: 15.11.14 21:36
*/
public class ActorHeart {
private JPanel mainPanel;
private ActorData[] actorDatas;
private ImagePanel imagePanel;
public ActorHeart() {
imagePanel = new ImagePanel("/de/psychose/heart1_klein_inv.jpg", "/de/psychose/heart2_klein_inv.jpg");
mainPanel.add(imagePanel);
}
public void update() {
imagePanel.repaint();
}
public void setActorDatas(final ActorData[] actorDatas) {
this.actorDatas = actorDatas;
}
private class ImagePanel extends JPanel {
private BufferedImage image1;
private BufferedImage image2;
public ImagePanel(String imageA, String imageB) {
try {
image1 = ImageIO.read(getClass().getResourceAsStream(imageA));
image2 = ImageIO.read(getClass().getResourceAsStream(imageB));
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (actorDatas != null) {
for (int i = 0; i < actorDatas.length; i++) {
if (actorDatas[i] != null) {
g.drawImage(actorDatas[i].getTommyHeartbeat() ? image1 : image2, 263 * i, 0, null, null);
}
}
}
}
}
}

View File

@ -23,7 +23,12 @@ public class ChaOSCclient {
public ChaOSCclient(String host, int port) throws UnknownHostException, SocketException {
portOut = new OSCPortOut(InetAddress.getByName(host), port);
portIn = new OSCPortIn(OSC_CLIENT_PORT);
try {
portIn = new OSCPortIn(OSC_CLIENT_PORT);
} catch (SocketException se) {
System.out.println("Port " + OSC_CLIENT_PORT + " already in use. Trying " + OSC_CLIENT_PORT + 1);
portIn = new OSCPortIn(OSC_CLIENT_PORT + 1);
}
}
public void addListener(String address, OSCListener listener) {
@ -40,21 +45,21 @@ public class ChaOSCclient {
return changeChaoscSubscription(true);
}
public void sendPulse(String actor, int heartbeat, int pulse, int oxygen) {
public void sendMessage(final String address, Object... args) {
try {
OSCMessage subscribeMessage = new OSCMessage("/" + actor + "/heartbeat");
subscribeMessage.addArgument(heartbeat);
subscribeMessage.addArgument(pulse);
subscribeMessage.addArgument(oxygen);
OSCMessage subscribeMessage = new OSCMessage(address);
for(Object param: args) {
subscribeMessage.addArgument(param);
}
portOut.send(subscribeMessage);
} catch (IOException e) {
System.out.println("could not send pulse OSC Message");
e.printStackTrace();
}
}
}
private boolean changeChaoscSubscription(boolean subscribe) {
try {

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.ControlForm">
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="704" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<nested-form id="680ad" form-file="de/psychose/PulseControl.form" binding="pulse1">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="8c36a" form-file="de/psychose/PulseControl.form" binding="pulse2">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="94992" form-file="de/psychose/PulseControl.form" binding="pulse3">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="c060f" form-file="de/psychose/ActorDisplay.form" binding="actor1">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="abfde" form-file="de/psychose/ActorDisplay.form" binding="actor2">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="97d21" form-file="de/psychose/ActorDisplay.form" binding="actor3">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="f7ec5" form-file="de/psychose/TemperatureControl.form" binding="temp1">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="bcc93" form-file="de/psychose/TemperatureControl.form" binding="temp2">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="3726f" form-file="de/psychose/TemperatureControl.form" binding="temp3">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
</children>
</grid>
</form>

View File

@ -0,0 +1,68 @@
package de.psychose;
import javax.swing.*;
import java.util.Observable;
import java.util.Observer;
/**
* @author: lucas
* @date: 15.11.14 22:23
*/
public class ControlForm extends JFrame {
private PulseControl pulse1;
private PulseControl pulse2;
private PulseControl pulse3;
private JPanel rootPanel;
private ActorDisplay actor1;
private ActorDisplay actor2;
private ActorDisplay actor3;
private TemperatureControl temp1;
private TemperatureControl temp2;
private TemperatureControl temp3;
private final ChaOSCclient osCclient;
public ControlForm(ChaOSCclient chaOSCclient, final ActorData[] actorData) {
super("HD Control");
this.osCclient = chaOSCclient;
setContentPane(rootPanel);
setResizable(false);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
addActor(pulse1, actor1, temp1, actorData[0]);
addActor(pulse2, actor2, temp2, actorData[1]);
addActor(pulse3, actor3, temp3, actorData[2]);
pack();
setVisible(true);
}
private void addActor(final PulseControl pulse, final ActorDisplay display, final TemperatureControl temp, final ActorData actorData) {
pulse.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if (arg instanceof PulseData) {
final PulseData data = (PulseData) arg;
osCclient.sendMessage("/" + actorData.getActor().toLowerCase() + "/heartbeat", data.getHeartbeat(),
data.getPulse(), data.getOxygen());
// TODO: delete this line, bc tommy will send the real events
osCclient.sendMessage("/" + actorData.getActor().toLowerCase() + "/tommyheartbeat");
}
}
});
temp.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if (arg instanceof Double) {
actorData.setTemperatureOffset((double)arg);
}
}
});
display.init(actorData, true);
}
}

View File

@ -1,10 +1,12 @@
package de.psychose;
import com.illposed.osc.OSCListener;
import com.illposed.osc.OSCMessage;
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Date;
/**
* @author: lucas
@ -12,48 +14,116 @@ import java.net.UnknownHostException;
*/
public class Main {
public static void main(String[] args) {
new Main();
}
final boolean showErrors = args.length > 0;
public Main() {
final ActorData[] actorDatas = new ActorData[3];
actorDatas[0] = new ActorData("merle", "Körper 1");
actorDatas[1] = new ActorData("uwe", "Körper 2");
actorDatas[2] = new ActorData("bjoern", "Körper 3");
try
{
//UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
UIManager.setLookAndFeel( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" );
}
catch ( Exception e )
{
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
try {
final ChaOSCclient chaOSCclient = new ChaOSCclient("chaosc", 7110);
final SnmpStatClient snmp = new SnmpStatClient("switch/161");
final MainForm mainForm = new MainForm(showErrors, chaOSCclient, snmp);
final JFrame frame = new JFrame("MainForm");
frame.setContentPane(mainForm.getMainPanel());
frame.setResizable(false);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
chaOSCclient.stopReceiver();
super.windowClosing(e);
}
});
frame.setVisible(true);
new Streamer(8888, mainForm.getMainPanel()).run();
for(int i = 0; i < actorDatas.length; i++) {
addActorOSCListeners(chaOSCclient, actorDatas[i]);
}
chaOSCclient.startReceiver();
new ControlForm(chaOSCclient, actorDatas);
new MainForm(actorDatas);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
chaOSCclient.stopReceiver();
}
}));
} catch (UnknownHostException | SocketException e) {
e.printStackTrace();
}
}
private static void addActorOSCListeners(final ChaOSCclient chaOSCclient, final ActorData actorData) {
chaOSCclient.addListener("/" + actorData.getActor().toLowerCase() + "/heartbeat", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 3) {
// set the beat ( 0 or 1 )
if (message.getArguments()[0] instanceof Integer) {
actorData.setHeartbeat( (int)(message.getArguments()[0]) == 1);
}
// set the heartrate
if (message.getArguments()[1] instanceof Integer) {
final int pulse = (int) (message.getArguments()[1]);
if (pulse > 60) { // try to skip the invalid pulse rate from device
actorData.setPulse(pulse);
}
}
// set the oxy level
if (message.getArguments()[2] instanceof Integer) {
actorData.setOxygen((int) (message.getArguments()[2]));
}
}
}
});
chaOSCclient.addListener("/" + actorData.getActor().toLowerCase() + "/ekg", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1 && message.getArguments()[0] instanceof Integer) {
actorData.setEkg((int) (message.getArguments()[0]));
}
}
});
chaOSCclient.addListener("/" + actorData.getActor().toLowerCase() + "/emg", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1 && message.getArguments()[0] instanceof Integer) {
actorData.setEmg((int) (message.getArguments()[0]));
}
}
});
chaOSCclient.addListener("/" + actorData.getActor().toLowerCase() + "/temperature", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1 && message.getArguments()[0] instanceof Float) {
actorData.setTemperature((float) (message.getArguments()[0]));
}
}
});
chaOSCclient.addListener("/" + actorData.getActor().toLowerCase() + "/airFlow", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1 && message.getArguments()[0] instanceof Integer) {
actorData.setAirflow((int) (message.getArguments()[0]));
}
}
});
//TODO: evtl muss das oben hier noch anders
chaOSCclient.addListener("/" + actorData.getActor().toLowerCase() + "/tommyheartbeat", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
actorData.setTommyHeartbeat(!actorData.getTommyHeartbeat());
}
});
}
}

View File

@ -1,74 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.MainForm">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="720" height="576"/>
<xy x="0" y="0" width="930" height="560"/>
</constraints>
<properties>
<background color="-16777216"/>
<foreground color="-1"/>
<maximumSize width="720" height="576"/>
<minimumSize width="720" height="576"/>
<preferredSize width="720" height="576"/>
<maximumSize width="1000" height="1000"/>
<minimumSize width="930" height="560"/>
<preferredSize width="950" height="570"/>
</properties>
<border type="none"/>
<children>
<hspacer id="f912c">
<constraints>
<grid row="2" column="5" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="6a2b8">
<constraints>
<grid row="2" column="1" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="67192">
<constraints>
<grid row="2" column="3" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<nested-form id="5519b" form-file="de/psychose/StatsDisplay.form" binding="statDisplay">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<vspacer id="ad2ab">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<nested-form id="736bf" form-file="de/psychose/ActorDisplay.form" binding="actor2">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="7fe82" form-file="de/psychose/ActorDisplay.form" binding="actor3">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="bd9b" form-file="de/psychose/ActorDisplay.form" binding="actor1">
<nested-form id="7ac3d" form-file="de/psychose/ActorDisplay.form" binding="actor1">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="5b53" form-file="de/psychose/PulseControl.form" binding="pulse1">
<nested-form id="e6dc4" form-file="de/psychose/ActorHeart.form" binding="heart">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="4c934" form-file="de/psychose/PulseControl.form" binding="pulse2">
<nested-form id="18353" form-file="de/psychose/ActorDisplay.form" binding="actor2">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<nested-form id="f9eb3" form-file="de/psychose/PulseControl.form" binding="pulse3">
<nested-form id="d8afa" form-file="de/psychose/ActorDisplay.form" binding="actor3">
<constraints>
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</nested-form>
<component id="fe39c" class="javax.swing.JLabel" binding="breath">
<constraints>
<grid row="0" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<font size="70"/>
<foreground color="-1"/>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="999"/>
</properties>
</component>
<hspacer id="10ad8">
<constraints>
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</form>

View File

@ -1,148 +1,52 @@
package de.psychose;
import com.illposed.osc.OSCListener;
import com.illposed.osc.OSCMessage;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Date;
import java.util.Observable;
import java.util.Observer;
/**
* @author: lucas
* @date: 14.04.14 21:43
*/
public class MainForm {
private final ChaOSCclient osCclient;
public class MainForm extends JFrame {
private JPanel mainPanel;
private ActorHeart heart;
private ActorDisplay actor1;
private ActorDisplay actor2;
private ActorDisplay actor3;
private StatsDisplay statDisplay;
private PulseControl pulse1;
private PulseControl pulse2;
private PulseControl pulse3;
private JLabel breath;
private int totalMessageCount = 0;
private int messagesTempCounter = 0;
public MainForm(final ActorData[] actorDatas) {
super("HD Main");
setContentPane(mainPanel);
setResizable(false);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setUndecorated(true);
private long totalTraffic = 0;
private long lastTraffic = 0;
actor1.init(actorDatas[0], false);
actor2.init(actorDatas[1], false);
actor3.init(actorDatas[2], false);
heart.setActorDatas(actorDatas);
public JPanel getMainPanel() {
return mainPanel;
}
public MainForm(final boolean showErrors, final ChaOSCclient chaOSCclient, final SnmpStatClient snmpStatClient) {
this.osCclient = chaOSCclient;
addActor("merle", "Körper 1", actor1, pulse1);
addActor("uwe", "Körper 2", actor2, pulse2);
addActor("bjoern", "Körper 3", actor3, pulse3);
final Timer timer = new Timer(1000, new AbstractAction() {
// this is now our main timer to update all and everything gui related
final Timer timer = new Timer(50, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
statDisplay.setMessagesPerSec(String.valueOf(totalMessageCount - messagesTempCounter));
statDisplay.setMessageCount(String.valueOf(totalMessageCount));
messagesTempCounter = totalMessageCount;
// update the breath display
breath.setText(String.valueOf(actorDatas[0].getAirflow()));
actor1.update();
actor2.update();
actor3.update();
heart.update();
}
});
timer.setRepeats(true);
timer.start();
final Timer snmpTimer = new Timer(5000, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
totalTraffic = snmpStatClient.getTrafficSum(); // in kB
statDisplay.setTotalTraffic(String.valueOf(totalTraffic));
statDisplay.setBandwidth(String.valueOf((totalTraffic - lastTraffic) / 5));
lastTraffic = totalTraffic;
}
});
snmpTimer.setRepeats(true);
if(showErrors) {
actor1.startErrorTimer();
actor2.startErrorTimer();
actor3.startErrorTimer();
snmpTimer.start();
} else {
pulse1.hide();
pulse2.hide();
pulse3.hide();
statDisplay.hide();
}
pack();
setVisible(true);
}
private void addActor(final String actor, final String label, final ActorDisplay actorDisplay, final PulseControl pulse) {
actorDisplay.setCaption(label);
osCclient.addListener("/" + actor.toLowerCase() + "/heartbeat", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 3) {
totalMessageCount++;
actorDisplay.setHeartbeat(message.getArguments()[0].toString().equals("0") ? "Systole" : "Diastole");
actorDisplay.setPulse(message.getArguments()[1].toString());
actorDisplay.setOxy(message.getArguments()[2].toString());
}
}
});
osCclient.addListener("/" + actor.toLowerCase() + "/ekg", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setEkg(message.getArguments()[0].toString());
}
}
});
osCclient.addListener("/" + actor.toLowerCase() + "/emg", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setEmg(message.getArguments()[0].toString());
}
}
});
osCclient.addListener("/" + actor.toLowerCase() + "/temperatur", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setTemperature(message.getArguments()[0].toString());
}
}
});
osCclient.addListener("/" + actor.toLowerCase() + "/airFlow", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setBreath(message.getArguments()[0].toString());
}
}
});
pulse.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if(arg instanceof PulseData) {
final PulseData data = (PulseData)arg;
osCclient.sendPulse(actor, data.getHeartbeat(), data.getPulse(), data.getOxygen());
}
}
});
}

View File

@ -1,42 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.PulseControl">
<grid id="27dc6" binding="pulsePanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="261" height="38"/>
<xy x="20" y="20" width="179" height="30"/>
</constraints>
<properties>
<background color="-16777216"/>
<foreground color="-1"/>
</properties>
<border type="none"/>
<children>
<component id="a9565" class="javax.swing.JCheckBox" binding="enableCheckBox" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<foreground color="-1"/>
<focusable value="false"/>
<selected value="false"/>
<text value="Enable"/>
</properties>
</component>
<component id="dadb" class="javax.swing.JSpinner" binding="spinner1" default-binding="true">
<component id="dadb" class="javax.swing.JSpinner" binding="spinner">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="50" height="-1"/>
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
<properties>
<background color="-16711423"/>
<focusable value="false"/>
</properties>
</component>
<hspacer id="dec01">
<component id="b9118" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<properties>
<text value="Pulse"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@ -14,63 +14,41 @@ import java.util.Random;
public class PulseControl extends Observable {
private final int PULSE_WOBBLE_WIDTH = 10;
private JCheckBox enableCheckBox;
private JSpinner spinner1;
private JPanel pulsePanel;
private Timer timer;
private Random random = new Random();
private int heartbeat = 0;
private JSpinner spinner;
private JPanel mainPanel;
private final Timer timer;
private final Random random = new Random();
private boolean heartbeat = false;
public PulseControl() {
enableCheckBox.setFocusable(false);
spinner1.setFocusable(false);
spinner1.setValue(110);
spinner.setValue(110);
timer = new Timer(100, new AbstractAction() {
timer = new Timer(500, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
heartbeat = (heartbeat+1) % 2;
heartbeat = !heartbeat;
final int pulseWobbleCenter = (int)spinner1.getValue();
int pulse = pulseWobbleCenter - PULSE_WOBBLE_WIDTH / 2 + random.nextInt(PULSE_WOBBLE_WIDTH);
int pulse = (int) spinner.getValue() - PULSE_WOBBLE_WIDTH / 2 + random.nextInt(PULSE_WOBBLE_WIDTH);
if(pulse < 60) pulse = 60;
if(pulse > 180) pulse = 180;
if(pulse > 230) pulse = 230;
final PulseData data = new PulseData(heartbeat, pulse, 95 + random.nextInt(4));
setChanged();
notifyObservers(data);
notifyObservers(new PulseData(heartbeat, pulse, 95 + random.nextInt(4)));
final int delay = 60000 / pulse;
timer.setDelay(delay);
timer.setDelay(60000 / pulse);
}
});
timer.setRepeats(true);
enableCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
System.out.println("item state changed");
JCheckBox checkBox = (JCheckBox)e.getSource();
if(checkBox.isSelected()) {
if(!timer.isRunning()) {
System.out.println("starting pulsecontrol " + this);
timer.start();
}
} else {
if(timer.isRunning()) {
System.out.println("stopping pulsecontrol " + this);
timer.stop();
}
if (enableCheckBox.isSelected() && !timer.isRunning()) {
timer.start();
} else if (timer.isRunning()) {
timer.stop();
}
}
});
}
public void hide() {
this.pulsePanel.setVisible(false);
}
}

View File

@ -6,7 +6,7 @@ package de.psychose;
*/
public class PulseData {
private int heartbeat;
private boolean heartbeat;
private int pulse;
private int oxygen;
@ -14,17 +14,17 @@ public class PulseData {
}
public PulseData(int heartbeat, int pulse, int oxygen) {
public PulseData(boolean heartbeat, int pulse, int oxygen) {
this.heartbeat = heartbeat;
this.pulse = pulse;
this.oxygen = oxygen;
}
public int getHeartbeat() {
public boolean getHeartbeat() {
return heartbeat;
}
public void setHeartbeat(int heartbeat) {
public void setHeartbeat(boolean heartbeat) {
this.heartbeat = heartbeat;
}

View File

@ -1,93 +0,0 @@
package de.psychose;
import org.snmp4j.CommunityTarget;
import org.snmp4j.Snmp;
import org.snmp4j.TransportMapping;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.UdpAddress;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.DefaultPDUFactory;
import org.snmp4j.util.TreeEvent;
import org.snmp4j.util.TreeUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
/**
* @author: lucas
* @date: 18.04.14 12:10
*/
public class SnmpStatClient {
public static final String OID_COUNTER = "1.3.6.1.2.1.2.2.1.10";
private HashMap<Integer, Long> lastPorts = new HashMap<>();
private HashMap<Integer, Long> sumPorts = new HashMap<>();
private Snmp snmp;
private CommunityTarget communityTarget;
private CommunityTarget getCommunityTarget(String host) {
CommunityTarget communityTarget = new CommunityTarget();
communityTarget.setCommunity(new OctetString("public"));
communityTarget.setVersion(SnmpConstants.version2c);
communityTarget.setAddress(new UdpAddress(host));
communityTarget.setTimeout(100);
return communityTarget;
}
public SnmpStatClient(String host) {
try {
final TransportMapping transportMapping = new DefaultUdpTransportMapping();
transportMapping.listen();
this.communityTarget = getCommunityTarget(host);
this.snmp = new Snmp(transportMapping);
} catch (IOException e) {
System.out.println("error: cannot get traffic from snmp target");
}
}
public long getTrafficSum() {
if (snmp == null || this.communityTarget == null) {
System.out.println("snmp error");
return 0;
}
long sum = 0;
try {
final TreeUtils treeUtils = new TreeUtils(snmp, new DefaultPDUFactory());
final List<TreeEvent> treeEventList = treeUtils.getSubtree(this.communityTarget, new OID(OID_COUNTER));
for (TreeEvent treeEvent : treeEventList) {
if (treeEvent.getStatus() == TreeEvent.STATUS_OK) {
for (VariableBinding binding : treeEvent.getVariableBindings()) {
int oid = binding.getOid().last();
long value = binding.getVariable().toLong() / 1024; // convert bytes down to kilobytes
long lastValue = 0;
if (lastPorts.containsKey(oid)) lastValue = lastPorts.get(oid);
long diff = value - lastValue;
if (diff > 0) {
sumPorts.put(oid, lastValue + diff);
}
}
}
}
} catch (IllegalArgumentException e) {
System.out.println("error: could not resolve address from snmp target");
}
for (long port : sumPorts.values()) {
sum += port;
}
return sum;
}
}

View File

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.StatsDisplay">
<grid id="27dc6" binding="statPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="248" height="180"/>
</constraints>
<properties>
<background color="-16777216"/>
<foreground color="-1"/>
<minimumSize width="220" height="180"/>
</properties>
<border type="none"/>
<children>
<component id="69530" class="javax.swing.JLabel" binding="lblCaption">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="28" style="1"/>
<foreground color="-1"/>
<text value="Statistik"/>
</properties>
</component>
<vspacer id="9a59f">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="1d950" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Events"/>
</properties>
</component>
<component id="442f5" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Ev/Sek"/>
</properties>
</component>
<component id="54c59" class="javax.swing.JLabel" binding="lblMessageCount">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
<component id="eaaf9" class="javax.swing.JLabel" binding="lblMessagesPerSec">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
<component id="95ca8" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="kb"/>
</properties>
</component>
<component id="b1b4b" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="kb/Sek"/>
</properties>
</component>
<component id="af868" class="javax.swing.JLabel" binding="lblTraffic">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
<component id="88e99" class="javax.swing.JLabel" binding="lblBandwidth">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@ -1,37 +0,0 @@
package de.psychose;
import javax.swing.*;
/**
* @author: lucas
* @date: 18.04.14 02:19
*/
public class StatsDisplay {
private JLabel lblCaption;
private JLabel lblMessageCount;
private JLabel lblMessagesPerSec;
private JPanel statPanel;
private JLabel lblTraffic;
private JLabel lblBandwidth;
public void setMessageCount(String count) {
lblMessageCount.setText(count);
}
public void setMessagesPerSec(String messagesPerSec) {
lblMessagesPerSec.setText(messagesPerSec);
}
public void setTotalTraffic(String totalTraffic) {
lblTraffic.setText(totalTraffic);
}
public void setBandwidth(String bandwidth) {
lblBandwidth.setText(bandwidth);
}
public void hide() {
this.statPanel.setVisible(false);
}
}

View File

@ -1,256 +0,0 @@
package de.psychose;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.*;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
import org.jboss.netty.handler.codec.http.*;
import org.jboss.netty.handler.stream.ChunkedInput;
import org.jboss.netty.handler.stream.ChunkedWriteHandler;
import org.jboss.netty.util.CharsetUtil;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.ClosedChannelException;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static org.jboss.netty.handler.codec.http.HttpMethod.GET;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.*;
import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
/**
* @author Maurus Cuelenaere <mcuelenaere@gmail.com>
* taken from http://blog.maurus.be/2012/05/09/netty-mjpeg-streamer/
*/
public class Streamer {
private final int port;
private final Component view;
private final ViewRenderer renderer;
private class ViewRenderer implements Runnable {
private final BufferedImage image;
private final AtomicReference<byte[]> currentBuffer;
private final AtomicInteger listenerCount;
private final int napTime;
private final ByteArrayOutputStream outputStream;
public ViewRenderer() {
this(10);
}
public ViewRenderer(int fps) {
this.napTime = 1000 / fps;
this.listenerCount = new AtomicInteger();
this.currentBuffer = new AtomicReference<byte[]>();
this.image = new BufferedImage(view.getWidth(), view.getHeight(), BufferedImage.TYPE_INT_RGB);
this.outputStream = new ByteArrayOutputStream();
}
@Override
public void run() {
while (!Thread.interrupted()) {
long sleepTill = System.currentTimeMillis() + napTime;
if (listenerCount.get() > 0) {
Graphics g = image.createGraphics();
view.paint(g);
g.dispose();
byte[] newData = null;
try {
ImageIO.write(image, "jpg", outputStream);
newData = outputStream.toByteArray();
} catch (IOException e) {
e.printStackTrace();
} finally {
outputStream.reset();
}
if (newData != null) {
currentBuffer.set(newData);
synchronized (currentBuffer) {
currentBuffer.notifyAll();
}
}
}
try {
long remainingTime = sleepTill - System.currentTimeMillis();
if (remainingTime > 0)
Thread.sleep(remainingTime);
} catch (InterruptedException e) {
return;
}
}
}
public void registerListener() {
listenerCount.incrementAndGet();
}
public void unregisterListener() {
listenerCount.decrementAndGet();
}
public void waitForData() throws InterruptedException {
synchronized (currentBuffer) {
currentBuffer.wait();
}
}
public byte[] getData() {
return currentBuffer.get();
}
}
private class HttpMultipartReplaceStream implements ChunkedInput {
private final byte[] header;
private boolean closed;
public HttpMultipartReplaceStream(String boundary) {
this.header = ("--" + boundary + "\r\nContent-Type: image/jpeg\r\n\r\n").getBytes();
renderer.registerListener();
}
@Override
public void close() throws Exception {
if (closed)
return;
closed = true;
renderer.unregisterListener();
}
@Override
public boolean hasNextChunk() throws Exception {
return !closed;
}
@Override
public boolean isEndOfInput() throws Exception {
return closed;
}
@Override
public Object nextChunk() throws Exception {
if (closed)
return null;
renderer.waitForData();
byte[] body = renderer.getData();
return ChannelBuffers.wrappedBuffer(header, body);
}
}
private class HttpStreamerHandler extends SimpleChannelUpstreamHandler {
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
HttpRequest request = (HttpRequest) e.getMessage();
if (request.getMethod() != GET) {
sendError(ctx, METHOD_NOT_ALLOWED);
return;
} else if (!"/stream".equals(request.getUri())) {
sendError(ctx, NOT_FOUND);
return;
}
final String boundary = "thisisourmagicboundary";
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
HttpHeaders.setHeader(response, "Connection", "close");
HttpHeaders.setHeader(response, "Content-Type", "multipart/x-mixed-replace;boundary=" + boundary);
HttpHeaders.setHeader(response, "Cache-control", "no-cache");
HttpHeaders.setHeader(response, "Pragma", "no-cache");
HttpHeaders.setHeader(response, "Expires", "Thu, 01 Dec 1994 16:00:00 GMT");
Channel ch = e.getChannel();
final HttpMultipartReplaceStream replaceStream = new HttpMultipartReplaceStream(boundary);
ch.getCloseFuture().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
// Stop the stream when the channel is closed
replaceStream.close();
}
});
// Write the initial line and the headers
ch.write(response);
// Write the content
ChannelFuture writeFuture = ch.write(replaceStream);
// Close the connection when the whole content is written out
writeFuture.addListener(ChannelFutureListener.CLOSE);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
Channel ch = e.getChannel();
Throwable cause = e.getCause();
if (cause instanceof TooLongFrameException) {
sendError(ctx, BAD_REQUEST);
return;
} else if (cause instanceof ClosedChannelException) {
ch.close();
return;
}
cause.printStackTrace();
if (ch.isConnected())
sendError(ctx, INTERNAL_SERVER_ERROR);
}
private void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) {
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status);
response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");
response.setContent(ChannelBuffers.copiedBuffer("Failure: " + status.toString() + "\r\n", CharsetUtil.UTF_8));
// Close the connection as soon as the error message is sent.
ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE);
}
}
public Streamer(int port, Component view) {
this.port = port;
this.view = view;
this.renderer = new ViewRenderer();
}
public void run() {
// Configure the server.
ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("handler", new HttpStreamerHandler());
return pipeline;
}
});
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(port));
// Start the renderer
new Thread(renderer, "Image renderer").start();
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.TemperatureControl">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="211" height="30"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="c685e" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Temp"/>
</properties>
</component>
<component id="f12ee" class="javax.swing.JCheckBox" binding="enableCheckBox" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Enable"/>
</properties>
</component>
<component id="27ee3" class="javax.swing.JSpinner" binding="spinner1" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>

View File

@ -0,0 +1,34 @@
package de.psychose;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.util.Observable;
/**
* @author: lucas
* @date: 20.11.14 23:11
*/
public class TemperatureControl extends Observable {
private static final double MIN_OFFSET = -20;
private static final double MAX_OFFSET = 20;
private static final double INCREMENT = 0.1;
private JCheckBox enableCheckBox;
private JSpinner spinner1;
private JPanel mainPanel;
public TemperatureControl() {
spinner1.setModel(new SpinnerNumberModel(0, MIN_OFFSET, MAX_OFFSET, INCREMENT));
final ChangeListener changeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
setChanged();
notifyObservers(enableCheckBox.isSelected() ? spinner1.getValue() : 0.0);
}
};
spinner1.addChangeListener(changeListener);
enableCheckBox.addChangeListener(changeListener);
}
}

View File

@ -1,94 +0,0 @@
package de.psychose;
import javax.sound.midi.*;
import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
public class Test {
public static final int NOTE_ON = 0x90;
public static final int NOTE_OFF = 0x80;
public static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "H"};
private static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
System.out.printf("Display name: %s%n", netint.getDisplayName());
System.out.printf("Name: %s%n", netint.getName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
System.out.printf("InetAddress: %s%n", inetAddress);
}
System.out.printf("%n");
}
public static void main(String[] args) throws Exception {
SnmpStatClient snmpStatClient = new SnmpStatClient("switch/161");
System.out.println(snmpStatClient.getTrafficSum() / 1024 / 1024 + "MB");
if(true) return;
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
displayInterfaceInformation(netint);
}
if(true) return;
Sequence sequence = MidiSystem.getSequence(new File("/home/lucas/jake-avril_14th.mid"));
HashSet<String> notes = new HashSet<String>();
int trackNumber = 0;
for (Track track : sequence.getTracks()) {
trackNumber++;
System.out.println("Track " + trackNumber + ": size = " + track.size());
System.out.println();
for (int i = 0; i < track.size(); i++) {
MidiEvent event = track.get(i);
System.out.print("@" + event.getTick() + " ");
MidiMessage message = event.getMessage();
if (message instanceof ShortMessage) {
ShortMessage sm = (ShortMessage) message;
System.out.print("Channel: " + sm.getChannel() + " ");
if (sm.getCommand() == NOTE_ON) {
int key = sm.getData1();
int octave = (key / 12) - 1;
int note = key % 12;
String noteName = NOTE_NAMES[note];
int velocity = sm.getData2();
System.out.println("Note on, " + noteName + octave + " key=" + key + " velocity: " + velocity);
notes.add(noteName + octave);
} else if (sm.getCommand() == NOTE_OFF) {
int key = sm.getData1();
int octave = (key / 12) - 1;
int note = key % 12;
String noteName = NOTE_NAMES[note];
int velocity = sm.getData2();
System.out.println("Note off, " + noteName + octave + " key=" + key + " velocity: " + velocity);
} else {
System.out.println("Command:" + sm.getCommand());
}
} else {
System.out.println("Other message: " + message.getClass());
}
}
System.out.println();
}
System.out.println(notes);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,462 @@
//*****************************************************************************
// MSP430FG439-Heart Rate Monitor Demo
//
// Description; Uses one Instrumentation Amplifier INA321 and the three
// internal opamps of the MSP430FG439
//
// Murugavel Raju
// Texas Instruments, Inc
// October 2004
// Edited by: M Morales, November 2008
// * Updated to non-depracated intrinsic functions
// * Changed spacing for legibility
// Edited by:
// Penko T. Bozhkov - Olimex LTD, 05.10.2012
// * RTC capcitors changed according to Olimex's crystall requirements
// * Olimex LCD definitions are added and heart rate is visualized at 2 places on LCD
// Built with IAR Embedded Workbench Version: 4.21
//*****************************************************************************
//*****************************************************************************
// THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
// REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
// INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
// COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
// TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
// POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
// INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
// YOUR USE OF THE PROGRAM.
//
// IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
// THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
// OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
// EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
// REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
// OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
// USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
// AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
// YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
// (U.S.$500).
//
// Unless otherwise stated, the Program written and copyrighted
// by Texas Instruments is distributed as "freeware". You may,
// only under TI's copyright in the Program, use and modify the
// Program without any charge or restriction. You may
// distribute to third parties, provided that you transfer a
// copy of this license to the third party and the third party
// agrees to these terms by its first use of the Program. You
// must reproduce the copyright notice and any other legend of
// ownership on each copy or partial copy, of the Program.
//
// You acknowledge and agree that the Program contains
// copyrighted material, trade secrets and other TI proprietary
// information and is protected by copyright laws,
// international copyright treaties, and trade secret laws, as
// well as other intellectual property laws. To protect TI's
// rights in the Program, you agree not to decompile, reverse
// engineer, disassemble or otherwise translate any object code
// versions of the Program to a human-readable form. You agree
// that in no event will you alter, remove or destroy any
// copyright notice included in the Program. TI reserves all
// rights not specifically granted under this license. Except
// as specifically provided herein, nothing in this agreement
// shall be construed as conferring by implication, estoppel,
// or otherwise, upon you, any license or other right under any
// TI patents, copyrights or trade secrets.
//
// You may not use the Program in non-TI devices.
//*****************************************************************************
#include "msp430fg439.h"
#include "math.h"
//defines
#define PB_2_0 (1 << 0) // Push Button on P2.0
#define PB_2_1 (1 << 1) // Push Button on P2.1
// variables declaration
static char beats;
int i=0, first_detection=0;
long result = 0;
int Datain, Dataout, Dataout_pulse, pulseperiod, counter, heartrate;
int heartrate_buffer[] = {0,0,0,0,0,0,0,0,0,0};
int heartrate_cursor = 0, heartrate_mean;
// Lowpass FIR filter coefficients for 17 taps to filter > 30Hz
static const int coeffslp[9] = {
5225, 5175, 7255, 9453, 11595, 13507, 15016, 15983, 16315 };
// Highpass FIR filter coefficients for 17 taps to filter < 2Hz
static const int coeffshp[9] = {
-763, -1267, -1091, -1867, -1969, -2507, -2619, -2911, 29908 };
// *******************************************
// Definitions related to Olimex LCD Digits!!!!
// *******************************************
// Definitions for Olimex LCD digits 10 and 11
#define a 0x10
#define b 0x01
#define c 0x04
#define d 0x08
#define e 0x40
#define f 0x20
#define g 0x02
#define h 0x80
// Character generator definition for display digits 10 and 11
const char char_gen_10_11[] = {
a+b+c+d+e+f, // 0 Displays "0"
b+c, // 1 Displays "1"
a+b+d+e+g, // 2 Displays "2"
a+b+c+d+g, // 3 Displays "3"
b+c+f+g, // 4 Displays "4"
a+c+d+f+g, // 5 Displays "5"
a+c+d+e+f+g, // 6 Displays "6"
a+b+c, // 7 Displays "7"
a+b+c+d+e+f+g, // 8 Displays "8"
a+b+c+d+f+g, // 9 Displays "9"
};
// undefines
#undef a
#undef b
#undef c
#undef d
#undef e
#undef f
#undef g
#undef h
// Definitions for Olimex LCD digits 8 and 9
#define a 0x01
#define b 0x02
#define c 0x04
#define d 0x80
#define e 0x40
#define f 0x10
#define g 0x20
#define h 0x08
// Character generator definition for display digits 8 and 9
const char char_gen_8_9[] = {
a+b+c+d+e+f, // 0 Displays "0"
b+c, // 1 Displays "1"
a+b+d+e+g, // 2 Displays "2"
a+b+c+d+g, // 3 Displays "3"
b+c+f+g, // 4 Displays "4"
a+c+d+f+g, // 5 Displays "5"
a+c+d+e+f+g, // 6 Displays "6"
a+b+c, // 7 Displays "7"
a+b+c+d+e+f+g, // 8 Displays "8"
a+b+c+d+f+g, // 9 Displays "9"
};
// undefines
#undef a
#undef b
#undef c
#undef d
#undef e
#undef f
#undef g
#undef h
// Definitions for Olimex LCD digits 1 to 7. Here each digit definition require 2 bytes
#define a 0x0080
#define b 0x0040
#define c 0x0020
#define d 0x0010
#define e 0x2000
#define f 0x4000
#define g 0x0402
#define h 0x1000
// Character generator definition for display digits 1 to 7
const int char_gen_1_7[] = {
a+b+c+d+e+f, // 0 Displays "0"
b+c, // 1 Displays "1"
a+b+d+e+g, // 2 Displays "2"
a+b+c+d+g, // 3 Displays "3"
b+c+f+g, // 4 Displays "4"
a+c+d+f+g, // 5 Displays "5"
a+c+d+e+f+g, // 6 Displays "6"
a+b+c, // 7 Displays "7"
a+b+c+d+e+f+g, // 8 Displays "8"
a+b+c+d+f+g, // 9 Displays "9"
};
// undefines
#undef a
#undef b
#undef c
#undef d
#undef e
#undef f
#undef g
#undef h
// function prototypes
void Init(void); // Initializes device for the application
void ClearLCD(void); // Clears the LCD memory
int filterlp(int); // 17 tap lowpass FIR filter
int filterhp(int); // 17 tap highpass FIR filter
long mul16(register int x, register int y); // 16-bit signed multiplication
int itobcd(int i); // 16-bit hex to bcd conversion
// main function
int main(void)
{
Init(); // Initialize device for the application
LCDMEM[7] = 0x80; // Turn on LCD's Olimex row!!!
/*
// For debug purpose only!
for(unsigned char j=0;j<10;j++){
LCDMEM[2] = char_gen_10_11[j]; // LCD -> Digit 11
LCDMEM[3] = char_gen_10_11[j]; // LCD -> Digit 10
LCDMEM[4] = char_gen_8_9[j]; // LCD -> Digit 9
LCDMEM[5] = char_gen_8_9[j]; // LCD -> Digit 8
LCDMEM[7] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 7 High Byte
LCDMEM[6] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 7 Low Byte
LCDMEM[9] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 6 High Byte
LCDMEM[8] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 6 Low Byte
LCDMEM[11] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 5 High Byte
LCDMEM[10] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 5 Low Byte
//LCDMEM[13] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 4 High Byte
//LCDMEM[12] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 4 Low Byte
//LCDMEM[15] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 3 High Byte
//LCDMEM[14] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 3 Low Byte
//LCDMEM[17] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 2 High Byte
//LCDMEM[16] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 2 Low Byte
}
*/
while(1)
{
__bis_SR_register(LPM0_bits); // Enter LPM0 needed for UART TX completion
__no_operation();
Dataout = filterlp(Datain); // Lowpass FIR filter for filtering out 60Hz
Dataout_pulse = filterhp(Dataout)-128; // Highpass FIR filter to filter muscle artifacts
Dataout = Dataout >> 6; // Scale Dataout to use scope program
if(Dataout > 255) Dataout = 255; // Set boundary 255 max
if(Dataout < 0) Dataout = 0; // Set boundary 0 min
//DAC12_0DAT = Dataout; // For scope display
if( 0 ) {
TXBUF0 = Dataout; // Transmit via UART0 for Scope display
} else {
// send the data as ascii values
TXBUF0 = (Dataout / 100) + 48; // hundreds
while (!(IFG1 & UTXIFG0)); // wait for transmission
TXBUF0 = ((Dataout / 10) % 10 ) + 48; // tens
while (!(IFG1 & UTXIFG0));
TXBUF0 = ((Dataout / 1) % 10 ) + 48; // ones
while (!(IFG1 & UTXIFG0));
TXBUF0 = 32; // send a blank
while (!(IFG1 & UTXIFG0));
TXBUF0 = ((heartrate & 0xf00) >> 8) + 48;
while (!(IFG1 & UTXIFG0));
TXBUF0 = ((heartrate & 0xf0) >> 4) + 48;
while (!(IFG1 & UTXIFG0));
TXBUF0 = (heartrate & 0x0f) + 48;
while (!(IFG1 & UTXIFG0));
TXBUF0 = 10; // send a \n
}
counter++; // Debounce counter
pulseperiod++; // Pulse period counter
if (Dataout_pulse > 100) // Check if above threshold (48)
{
LCDMEM[1] = 0xF0; // Heart beat detected enable "<^>" on LCD
counter = 0; // Reset debounce counter
}
if (counter == 128) // Allow 128 sample debounce time
{
LCDMEM[1] = 0x00; // Disable "<^>" on LCD for blinking effect
beats++;
if (beats == 3)
{
beats = 0;
//heartrate_buffer[heartrate_cursor] = 50720/pulseperiod;
//heartrate_cursor++;
//heartrate_cursor = heartrate_cursor % 10;
//int ct;
//for(ct = 0; ct < 10; ct++) {
// heartrate_mean += heartrate_buffer[ct];
//}
//heartrate = itobcd(heartrate_mean / 10);
// heartrate = itobcd(30720/pulseperiod); // Calculate beat to beat heart rate per min
//heartrate = itobcd(92160/pulseperiod); // Calculate 3 beat average heart rate per min
heartrate = itobcd(50720/pulseperiod); // Calculate 3 beat average heart rate per min
//heartrate = (92160/pulseperiod); // Calculate 3 beat average heart rate per min
pulseperiod = 0; // Reset pulse period for next measurement
///*
LCDMEM[2] = char_gen_10_11[heartrate & 0x0f]; // Display current heart rate units -> LCD Digit 11
LCDMEM[3] = char_gen_10_11[(heartrate & 0xf0) >> 4]; // tens -> LCD Digit 10
LCDMEM[4] = char_gen_8_9[(heartrate & 0xf00) >> 8]; // hundreds -> LCD Digit 9
LCDMEM[7] = ((char)(char_gen_1_7[heartrate & 0x0f]>>8)); // LCD -> Digit 7 High Byte
LCDMEM[6] = ((char)(char_gen_1_7[heartrate & 0x0f]&0x00FF)); // LCD -> Digit 7 Low Byte
LCDMEM[9] = ((char)(char_gen_1_7[((heartrate & 0xf0) >> 4)]>>8)); // LCD -> Digit 6 High Byte
LCDMEM[8] = ((char)(char_gen_1_7[((heartrate & 0xf0) >> 4)]&0x00FF)); // LCD -> Digit 6 Low Byte
LCDMEM[11] = ((char)(char_gen_1_7[((heartrate & 0xf00) >> 8)]>>8)); // LCD -> Digit 5 High Byte
LCDMEM[10] = ((char)(char_gen_1_7[((heartrate & 0xf00) >> 8)]&0x00FF)); // LCD -> Digit 5 Low Byte
//*/
}
}
}
}//main
// Initialization function
void Init( void )
{
FLL_CTL0 |= XCAP10PF; // Set load capacitance for xtal
WDTCTL = WDTPW | WDTHOLD; // Disable the Watchdog
while ( LFOF & FLL_CTL0); // wait for watch crystal to stabilize
SCFQCTL = 63; // 32 x 32768 x 2 = 2.097152MHz
BTCTL = BT_fLCD_DIV128; // Set LCD frame freq = ACLK/128
// Initialize and enable LCD peripheral
ClearLCD(); // Clear LCD memory
LCDCTL = LCDSG0_3 + LCD4MUX + LCDON ; // 4mux LCD, segs0-23 enabled
// Initialize and enable GPIO ports
P1OUT = 0x00 + BIT3; // Clear P1OUT register, INA turned ON
P1DIR = 0x3f; // Unused pins as outputs, Comparator pins as inputs
P2OUT = 0x00; // Clear P2OUT register
P2DIR = 0xff; // Unused pins as outputs
P2DIR = ~(PB_2_0+PB_2_1); // P2.0 and P2.1 push buttons
P2IES = 0x00; // Interrupt edge low to high transition
P2IFG = 0x00; // Clear pending P2 interrupts
P2IE = PB_2_0 | PB_2_1; // Enable intterupts for push buttons
P3OUT = 0x00; // Clear P3OUT register
P3DIR = 0x0f; // Unused pins as outputs except P3.<4-7> -> For the new LCD's received at ~04.10.2012 this must be inputs!!
P4OUT = 0x00; // Clear P4OUT register
P4DIR = 0xff; // Unused pins as outputs
P5OUT = 0x00; // Clear P5OUT register
P5DIR = 0xff; // Unused pins as outputs
P5SEL = 0xfc; // Set Rxx and COM pins for LCD
P6OUT = 0x00; // Clear P6OUT register
P6SEL = 0xff; // P6 = Analog
// Initialize and enable UART
P2SEL|=BIT4; // P2.4 = TXD
UCTL0 |= SWRST; // UART SWRST = 1
ME1 |= UTXE0; // Enable UART0 TXD
UCTL0 |= CHAR; // 8-bit char, SWRST=1
UTCTL0 |= SSEL1; // UCLK = SMCLK
UBR00 = 18; // 115200 from 2.097152MHz
UBR10 = 0;
UMCTL0 = 0x2c; // Modulation = 0.2044
UCTL0 &= ~SWRST; // UART SWRST = 0, enable UART
IFG1 &= ~UTXIFG0;
// Initialize and enable ADC12
ADC12CTL0 = ADC12ON + SHT0_4 + REFON + REF2_5V;
// ADC12 ON, Reference = 2.5V for DAC0
ADC12CTL1 = SHP + SHS_1 + CONSEQ_2; // Use sampling timer, TA1 trigger
ADC12MCTL0 = INCH_1 + SREF_1; // Vref, channel = 1 = OA0 Out
ADC12IE = BIT0; // Enable interrupt for ADC12 MEM0
ADC12CTL0 |= ENC; // Enable conversions
// Initialize and enable Timer_A
TACTL = TASSEL0 + MC_1 + TACLR; // ACLK, Clear TAR, Up Mode
TACCTL1 = OUTMOD_2; // Set / Reset
TACCR0 = 63; // 512 samples per second
TACCR1 = 15; //
// Initialize and enable DAC12x
DAC12_0CTL = DAC12OPS + DAC12CALON + DAC12IR + DAC12AMP_2 + DAC12ENC;// DAC0 enable
DAC12_1CTL = DAC12CALON + DAC12IR + DAC12AMP_2 + DAC12ENC; // DAC1 enable
DAC12_1DAT = 0x099A; // Offset level = 1.5V for op amp bias
// Initialize and enable opamps
OA0CTL0 = OAP_1 + OAPM_1 + OAADC1; // OA0 enable power mode 1, OA0- = P6.0, 0A0+ = P6.2, OA0O = P6.1
OA0CTL1 = OARRIP; // General purpose mode, no Rail-to-Rail inputs
OA1CTL0 = OAP_3 + OAPM_1 + OAADC1; // OA1 enable power mode 1, OA1- = P6.4, OA1+ = DAC1, OA1O = P6.3
OA1CTL1 = OARRIP; // General purpose mode, no Rail-to-Rail inputs
OA2CTL0 = OAP_3 + OAPM_1 + OAADC1; // OA2 enable power mode 1, OA2+ = DAC1, OA2O = P6.5, Select inputs, power mode
OA2CTL1 = OAFC_1 + OARRIP; // Unit gain Mode, no Rail-to-Rail inputs
__enable_interrupt(); // Enable global Interrupts
} //init
void ClearLCD(void)
{
int i; //
for( i = 0; i < 20; i++){ // Clear LCDMEM
LCDMEM[i] = 0; //
}
}//clear LCD
int itobcd(int i) // Convert hex word to BCD.
{
int bcd = 0; //
char j = 0; //
while (i > 9) //
{
bcd |= ((i % 10) << j); //
i /= 10; //
j += 4;
} //
return (bcd | (i << j)); // Return converted value
}// itobcd(i)
int filterlp(int sample) // Lowpass FIR filter for EKG
{
static int buflp[32]; // Reserve 32 loactions for circular buffering
static int offsetlp = 0;
long z;
int i;
buflp[offsetlp] = sample;
z = mul16(coeffslp[8], buflp[(offsetlp - 8) & 0x1F]);
__no_operation();
for (i = 0; i < 8; i++){
z += mul16(coeffslp[i], buflp[(offsetlp - i) & 0x1F] + buflp[(offsetlp - 16 + i) & 0x1F]);
}
offsetlp = (offsetlp + 1) & 0x1F;
return z >> 15; // Return filter output
}// int filter
int filterhp(int samplehp) // Highpass FIR filter for hear rate
{
static int bufhp[32]; // Reserve 32 loactions for circular buffering
static int offsethp = 0;
long z;
int i;
bufhp[offsethp] = samplehp;
z = mul16(coeffshp[8], bufhp[(offsethp - 8) & 0x1F]);
for (i = 0; i < 8; i++){
z += mul16(coeffshp[i], bufhp[(offsethp - i) & 0x1F] + bufhp[(offsethp - 16 + i) & 0x1F]);
}
offsethp = (offsethp + 1) & 0x1F;
return z >> 15; // Return filter output
}// int filterhp
long mul16(register int x, register int y)
{
return ((long)x) * y;
}
#pragma vector = PORT2_VECTOR
__interrupt void Port2ISR (void)
{
P2IFG = 0;
}//Push buttons unused
#pragma vector = ADC_VECTOR // ADC12 ISR
__interrupt void ADC12ISR (void)
{
Datain = ADC12MEM0; // Store converted value in Datain
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 on return
}// ADC12ISR

View File

@ -0,0 +1,91 @@
#
# Makefile for msp430
#
# 'make' builds everything
# 'make clean' deletes everything except source files and Makefile
# You need to set TARGET, MCU and SOURCES for your project.
# TARGET is the name of the executable file to be produced
# $(TARGET).elf $(TARGET).hex and $(TARGET).txt nad $(TARGET).map are all generated.
# The TXT file is used for BSL loading, the ELF can be used for JTAG use
#
TARGET = mod-pulse-ekg
MCU = msp430fg439
# List all the source files here
# eg if you have a source file foo.c then list it here
SOURCES = MOD-EKG_DemoSoft.c
# Include are located in the Include directory
INCLUDES = -IInclude
# Add or subtract whatever MSPGCC flags you want. There are plenty more
#######################################################################################
CFLAGS = -mmcu=$(MCU) -g -Os -Wall -Wunused $(INCLUDES)
ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs
LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map -lm -lfp -pipe
########################################################################################
CC = msp430-gcc
LD = msp430-ld
AR = msp430-ar
AS = msp430-gcc
GASP = msp430-gasp
NM = msp430-nm
OBJCOPY = msp430-objcopy
RANLIB = msp430-ranlib
STRIP = msp430-strip
SIZE = msp430-size
READELF = msp430-readelf
MAKETXT = srec_cat
CP = cp -p
RM = rm -f
MV = mv
########################################################################################
# the file which will include dependencies
DEPEND = $(SOURCES:.c=.d)
# all the object files
OBJECTS = $(SOURCES:.c=.o)
#all: $(TARGET).elf $(TARGET).hex $(TARGET).txt
all: $(TARGET).elf $(TARGET).hex
$(TARGET).elf: $(OBJECTS)
echo "Linking $@"
$(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
echo
echo ">>>> Size of Firmware <<<<"
$(SIZE) $(TARGET).elf
echo
%.hex: %.elf
$(OBJCOPY) -O ihex $< $@
#%.txt: %.hex
# $(MAKETXT) -O $@ -TITXT $< -I
# unix2dos $(TARGET).txt
# The above line is required for the DOS based TI BSL tool to be able to read the txt file generated from linux/unix systems.
%.o: %.c
echo "Compiling $<"
$(CC) -c $(CFLAGS) -o $@ $<
# rule for making assembler source listing, to see the code
%.lst: %.c
$(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@
# include the dependencies unless we're going to clean, then forget about them.
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPEND)
endif
# dependencies file
# includes also considered, since some of these are our own
# (otherwise use -MM instead of -M)
%.d: %.c
echo "Generating dependencies $@ from $<"
$(CC) -M ${CFLAGS} $< >$@
.SILENT:
.PHONY: clean
clean:
-$(RM) $(OBJECTS)
-$(RM) $(TARGET).*
-$(RM) $(SOURCES:.c=.lst)
-$(RM) $(DEPEND)

2
mod_ekg_psychose/gcc/make.sh Executable file
View File

@ -0,0 +1,2 @@
msp430-gcc -I/usr/msp430/include -Wall mod_ -mmcu=msp430fg439 -o mod-ekg-pyschose -L /usr/msp430/lib/ldscripts/msp430fg439 -lm -lfp -pipe

View File

@ -0,0 +1,571 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<project>
<fileVersion>2</fileVersion>
<configuration>
<name>Debug</name>
<toolchain>
<name>MSP430</name>
</toolchain>
<debug>1</debug>
<settings>
<name>C-SPY</name>
<archiveVersion>4</archiveVersion>
<data>
<version>23</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>CInput</name>
<state>1</state>
</option>
<option>
<name>MacOverride</name>
<state>0</state>
</option>
<option>
<name>MacFile</name>
<state></state>
</option>
<option>
<name>IProcessor</name>
<state>0</state>
</option>
<option>
<name>GoToEnable</name>
<state>1</state>
</option>
<option>
<name>GoToName</name>
<state>main</state>
</option>
<option>
<name>DynDriver</name>
<state>430FET</state>
</option>
<option>
<name>dDllSlave</name>
<state>0</state>
</option>
<option>
<name>DdfFileSlave</name>
<state>1</state>
</option>
<option>
<name>DdfOverride</name>
<state>0</state>
</option>
<option>
<name>DdfFileName</name>
<state>$TOOLKIT_DIR$\config\MSP430FG439.ddf</state>
</option>
<option>
<name>ProcTMS</name>
<state>1</state>
</option>
<option>
<name>CExtraOptionsCheck</name>
<state>0</state>
</option>
<option>
<name>CExtraOptions</name>
<state></state>
</option>
<option>
<name>ProcMSP430X</name>
<state>1</state>
</option>
<option>
<name>CompilerDataModel</name>
<state>1</state>
</option>
<option>
<name>IVBASE</name>
<state>1</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath1</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck2</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath2</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck3</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath3</name>
<state></state>
</option>
<option>
<name>CPUTAG</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
<name>430FET</name>
<archiveVersion>1</archiveVersion>
<data>
<version>15</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>CFetMandatory</name>
<state>0</state>
</option>
<option>
<name>Erase</name>
<state>1</state>
</option>
<option>
<name>EMUVerifyDownloadP7</name>
<state>0</state>
</option>
<option>
<name>EraseOptionSlaveP7</name>
<state>0</state>
</option>
<option>
<name>ExitBreakpointP7</name>
<state>0</state>
</option>
<option>
<name>PutcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>GetcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>derivativeP7</name>
<state>0</state>
</option>
<option>
<name>ParallelPortP7</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>TargetVoltage</name>
<state>3.3</state>
</option>
<option>
<name>AllowLockedFlashAccessP7</name>
<state>0</state>
</option>
<option>
<name>EMUAttach</name>
<state>0</state>
</option>
<option>
<name>AttachOptionSlave</name>
<state>0</state>
</option>
<option>
<name>OProtocolTypeDefault</name>
<state>0</state>
</option>
<option>
<name>CRadioProtocolType</name>
<state>1</state>
</option>
<option>
<name>CCRadioModuleTypeSlave</name>
<state>1</state>
</option>
<option>
<name>EEMLevel</name>
<state>0</state>
</option>
<option>
<name>DiasbleMemoryCache</name>
<state>0</state>
</option>
<option>
<name>NeedLockedFlashAccess</name>
<state>1</state>
</option>
<option>
<name>UsbComPort</name>
<state>Automatic</state>
</option>
<option>
<name>FetConnection</name>
<version>1</version>
<state>6</state>
</option>
<option>
<name>SoftwareBreakpointEnable</name>
<state>0</state>
</option>
<option>
<name>RadioSoftwareBreakpointType</name>
<state>0</state>
</option>
<option>
<name>TargetSettlingtime</name>
<state>0</state>
</option>
<option>
<name>AllowAccessToBSL</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>SIM430</name>
<archiveVersion>1</archiveVersion>
<data>
<version>3</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>SimOddAddressCheckP7</name>
<state>1</state>
</option>
<option>
<name>CSimMandatory</name>
<state>1</state>
</option>
<option>
<name>derivativeSim</name>
<state>0</state>
</option>
</data>
</settings>
<debuggerPlugins>
<plugin>
<file>$TOOLKIT_DIR$\plugins\Lcd\lcd.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Profiling\Profiling.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
</debuggerPlugins>
</configuration>
<configuration>
<name>Release</name>
<toolchain>
<name>MSP430</name>
</toolchain>
<debug>0</debug>
<settings>
<name>C-SPY</name>
<archiveVersion>4</archiveVersion>
<data>
<version>23</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>CInput</name>
<state>1</state>
</option>
<option>
<name>MacOverride</name>
<state>0</state>
</option>
<option>
<name>MacFile</name>
<state></state>
</option>
<option>
<name>IProcessor</name>
<state>0</state>
</option>
<option>
<name>GoToEnable</name>
<state>1</state>
</option>
<option>
<name>GoToName</name>
<state>main</state>
</option>
<option>
<name>DynDriver</name>
<state>SIM430</state>
</option>
<option>
<name>dDllSlave</name>
<state>0</state>
</option>
<option>
<name>DdfFileSlave</name>
<state>1</state>
</option>
<option>
<name>DdfOverride</name>
<state>0</state>
</option>
<option>
<name>DdfFileName</name>
<state></state>
</option>
<option>
<name>ProcTMS</name>
<state>1</state>
</option>
<option>
<name>CExtraOptionsCheck</name>
<state>0</state>
</option>
<option>
<name>CExtraOptions</name>
<state></state>
</option>
<option>
<name>ProcMSP430X</name>
<state>1</state>
</option>
<option>
<name>CompilerDataModel</name>
<state>1</state>
</option>
<option>
<name>IVBASE</name>
<state>1</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath1</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck2</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath2</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck3</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath3</name>
<state></state>
</option>
<option>
<name>CPUTAG</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
<name>430FET</name>
<archiveVersion>1</archiveVersion>
<data>
<version>15</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>CFetMandatory</name>
<state>0</state>
</option>
<option>
<name>Erase</name>
<state>1</state>
</option>
<option>
<name>EMUVerifyDownloadP7</name>
<state>0</state>
</option>
<option>
<name>EraseOptionSlaveP7</name>
<state>0</state>
</option>
<option>
<name>ExitBreakpointP7</name>
<state>0</state>
</option>
<option>
<name>PutcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>GetcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>derivativeP7</name>
<state>0</state>
</option>
<option>
<name>ParallelPortP7</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>TargetVoltage</name>
<state>###Uninitialized###</state>
</option>
<option>
<name>AllowLockedFlashAccessP7</name>
<state>0</state>
</option>
<option>
<name>EMUAttach</name>
<state>0</state>
</option>
<option>
<name>AttachOptionSlave</name>
<state>0</state>
</option>
<option>
<name>OProtocolTypeDefault</name>
<state>0</state>
</option>
<option>
<name>CRadioProtocolType</name>
<state>1</state>
</option>
<option>
<name>CCRadioModuleTypeSlave</name>
<state>1</state>
</option>
<option>
<name>EEMLevel</name>
<state>0</state>
</option>
<option>
<name>DiasbleMemoryCache</name>
<state>0</state>
</option>
<option>
<name>NeedLockedFlashAccess</name>
<state>1</state>
</option>
<option>
<name>UsbComPort</name>
<state>Automatic</state>
</option>
<option>
<name>FetConnection</name>
<version>1</version>
<state>0</state>
</option>
<option>
<name>SoftwareBreakpointEnable</name>
<state>0</state>
</option>
<option>
<name>RadioSoftwareBreakpointType</name>
<state>0</state>
</option>
<option>
<name>TargetSettlingtime</name>
<state>0</state>
</option>
<option>
<name>AllowAccessToBSL</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>SIM430</name>
<archiveVersion>1</archiveVersion>
<data>
<version>3</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>SimOddAddressCheckP7</name>
<state>1</state>
</option>
<option>
<name>CSimMandatory</name>
<state>1</state>
</option>
<option>
<name>derivativeSim</name>
<state>0</state>
</option>
</data>
</settings>
<debuggerPlugins>
<plugin>
<file>$TOOLKIT_DIR$\plugins\Lcd\lcd.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Profiling\Profiling.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
</debuggerPlugins>
</configuration>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,436 @@
//*****************************************************************************
// MSP430FG439-Heart Rate Monitor Demo
//
// Description; Uses one Instrumentation Amplifier INA321 and the three
// internal opamps of the MSP430FG439
//
// Murugavel Raju
// Texas Instruments, Inc
// October 2004
// Edited by: M Morales, November 2008
// * Updated to non-depracated intrinsic functions
// * Changed spacing for legibility
// Edited by:
// Penko T. Bozhkov - Olimex LTD, 05.10.2012
// * RTC capcitors changed according to Olimex's crystall requirements
// * Olimex LCD definitions are added and heart rate is visualized at 2 places on LCD
// Built with IAR Embedded Workbench Version: 4.21
//*****************************************************************************
//*****************************************************************************
// THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
// REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
// INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
// COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
// TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
// POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
// INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
// YOUR USE OF THE PROGRAM.
//
// IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
// THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
// OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
// EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
// REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
// OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
// USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
// AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
// YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
// (U.S.$500).
//
// Unless otherwise stated, the Program written and copyrighted
// by Texas Instruments is distributed as "freeware". You may,
// only under TI's copyright in the Program, use and modify the
// Program without any charge or restriction. You may
// distribute to third parties, provided that you transfer a
// copy of this license to the third party and the third party
// agrees to these terms by its first use of the Program. You
// must reproduce the copyright notice and any other legend of
// ownership on each copy or partial copy, of the Program.
//
// You acknowledge and agree that the Program contains
// copyrighted material, trade secrets and other TI proprietary
// information and is protected by copyright laws,
// international copyright treaties, and trade secret laws, as
// well as other intellectual property laws. To protect TI's
// rights in the Program, you agree not to decompile, reverse
// engineer, disassemble or otherwise translate any object code
// versions of the Program to a human-readable form. You agree
// that in no event will you alter, remove or destroy any
// copyright notice included in the Program. TI reserves all
// rights not specifically granted under this license. Except
// as specifically provided herein, nothing in this agreement
// shall be construed as conferring by implication, estoppel,
// or otherwise, upon you, any license or other right under any
// TI patents, copyrights or trade secrets.
//
// You may not use the Program in non-TI devices.
//*****************************************************************************
#include <msp430xG43x.h>
#include "math.h"
//defines
#define PB_2_0 (1 << 0) // Push Button on P2.0
#define PB_2_1 (1 << 1) // Push Button on P2.1
// variables declaration
static char beats;
int i=0, first_detection=0;
long result = 0;
int Datain, Dataout, Dataout_pulse, pulseperiod, counter, heartrate;
int Heart_Rate_Buffer[] = {0,0,0,0};
// Lowpass FIR filter coefficients for 17 taps to filter > 30Hz
static const int coeffslp[9] = {
5225, 5175, 7255, 9453, 11595, 13507, 15016, 15983, 16315 };
// Highpass FIR filter coefficients for 17 taps to filter < 2Hz
static const int coeffshp[9] = {
-763, -1267, -1091, -1867, -1969, -2507, -2619, -2911, 29908 };
// *******************************************
// Definitions related to Olimex LCD Digits!!!!
// *******************************************
// Definitions for Olimex LCD digits 10 and 11
#define a 0x10
#define b 0x01
#define c 0x04
#define d 0x08
#define e 0x40
#define f 0x20
#define g 0x02
#define h 0x80
// Character generator definition for display digits 10 and 11
const char char_gen_10_11[] = {
a+b+c+d+e+f, // 0 Displays "0"
b+c, // 1 Displays "1"
a+b+d+e+g, // 2 Displays "2"
a+b+c+d+g, // 3 Displays "3"
b+c+f+g, // 4 Displays "4"
a+c+d+f+g, // 5 Displays "5"
a+c+d+e+f+g, // 6 Displays "6"
a+b+c, // 7 Displays "7"
a+b+c+d+e+f+g, // 8 Displays "8"
a+b+c+d+f+g, // 9 Displays "9"
};
// undefines
#undef a
#undef b
#undef c
#undef d
#undef e
#undef f
#undef g
#undef h
// Definitions for Olimex LCD digits 8 and 9
#define a 0x01
#define b 0x02
#define c 0x04
#define d 0x80
#define e 0x40
#define f 0x10
#define g 0x20
#define h 0x08
// Character generator definition for display digits 8 and 9
const char char_gen_8_9[] = {
a+b+c+d+e+f, // 0 Displays "0"
b+c, // 1 Displays "1"
a+b+d+e+g, // 2 Displays "2"
a+b+c+d+g, // 3 Displays "3"
b+c+f+g, // 4 Displays "4"
a+c+d+f+g, // 5 Displays "5"
a+c+d+e+f+g, // 6 Displays "6"
a+b+c, // 7 Displays "7"
a+b+c+d+e+f+g, // 8 Displays "8"
a+b+c+d+f+g, // 9 Displays "9"
};
// undefines
#undef a
#undef b
#undef c
#undef d
#undef e
#undef f
#undef g
#undef h
// Definitions for Olimex LCD digits 1 to 7. Here each digit definition require 2 bytes
#define a 0x0080
#define b 0x0040
#define c 0x0020
#define d 0x0010
#define e 0x2000
#define f 0x4000
#define g 0x0402
#define h 0x1000
// Character generator definition for display digits 1 to 7
const int char_gen_1_7[] = {
a+b+c+d+e+f, // 0 Displays "0"
b+c, // 1 Displays "1"
a+b+d+e+g, // 2 Displays "2"
a+b+c+d+g, // 3 Displays "3"
b+c+f+g, // 4 Displays "4"
a+c+d+f+g, // 5 Displays "5"
a+c+d+e+f+g, // 6 Displays "6"
a+b+c, // 7 Displays "7"
a+b+c+d+e+f+g, // 8 Displays "8"
a+b+c+d+f+g, // 9 Displays "9"
};
// undefines
#undef a
#undef b
#undef c
#undef d
#undef e
#undef f
#undef g
#undef h
// function prototypes
void Init(void); // Initializes device for the application
void ClearLCD(void); // Clears the LCD memory
int filterlp(int); // 17 tap lowpass FIR filter
int filterhp(int); // 17 tap highpass FIR filter
long mul16(register int x, register int y); // 16-bit signed multiplication
int itobcd(int i); // 16-bit hex to bcd conversion
// main function
void main(void)
{
Init(); // Initialize device for the application
LCDMEM[7] = 0x80; // Turn on LCD's Olimex row!!!
/*
// For debug purpose only!
for(unsigned char j=0;j<10;j++){
LCDMEM[2] = char_gen_10_11[j]; // LCD -> Digit 11
LCDMEM[3] = char_gen_10_11[j]; // LCD -> Digit 10
LCDMEM[4] = char_gen_8_9[j]; // LCD -> Digit 9
LCDMEM[5] = char_gen_8_9[j]; // LCD -> Digit 8
LCDMEM[7] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 7 High Byte
LCDMEM[6] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 7 Low Byte
LCDMEM[9] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 6 High Byte
LCDMEM[8] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 6 Low Byte
LCDMEM[11] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 5 High Byte
LCDMEM[10] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 5 Low Byte
//LCDMEM[13] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 4 High Byte
//LCDMEM[12] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 4 Low Byte
//LCDMEM[15] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 3 High Byte
//LCDMEM[14] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 3 Low Byte
//LCDMEM[17] = ((char)(char_gen_1_7[j]>>8)); // LCD -> Digit 2 High Byte
//LCDMEM[16] = ((char)(char_gen_1_7[j]&0x00FF)); // LCD -> Digit 2 Low Byte
}
*/
while(1)
{
__bis_SR_register(LPM0_bits); // Enter LPM0 needed for UART TX completion
__no_operation();
Dataout = filterlp(Datain); // Lowpass FIR filter for filtering out 60Hz
Dataout_pulse = filterhp(Dataout)-128; // Highpass FIR filter to filter muscle artifacts
Dataout = Dataout >> 6; // Scale Dataout to use scope program
if(Dataout > 255) Dataout = 255; // Set boundary 255 max
if(Dataout < 0) Dataout = 0; // Set boundary 0 min
//DAC12_0DAT = Dataout; // For scope display
//TXBUF0 = Dataout; // Transmit via UART0 for Scope display
// send the data as ascii values
TXBUF0 = (Dataout / 100) + 48; // hundreds
while (!(IFG1 & UTXIFG0)); // wait for transmission
TXBUF0 = ((Dataout / 10) % 10 ) + 48; // tens
while (!(IFG1 & UTXIFG0));
TXBUF0 = ((Dataout / 1) % 10 ) + 48; // ones
while (!(IFG1 & UTXIFG0));
TXBUF0 = 32; // send a blank
while (!(IFG1 & UTXIFG0));
TXBUF0 = ((heartrate & 0xf00) >> 8) + 48;
while (!(IFG1 & UTXIFG0));
TXBUF0 = ((heartrate & 0xf0) >> 4) + 48;
while (!(IFG1 & UTXIFG0));
TXBUF0 = (heartrate & 0x0f) + 48;
while (!(IFG1 & UTXIFG0));
TXBUF0 = 10; // send a \n
counter++; // Debounce counter
pulseperiod++; // Pulse period counter
if (Dataout_pulse > 110) // Check if above threshold (48)
{
LCDMEM[1] = 0xF0; // Heart beat detected enable "<^>" on LCD
counter = 0; // Reset debounce counter
}
if (counter == 128) // Allow 128 sample debounce time
{
LCDMEM[1] = 0x00; // Disable "<^>" on LCD for blinking effect
beats++;
if (beats == 3)
{
beats = 0;
// heartrate = itobcd(30720/pulseperiod); // Calculate beat to beat heart rate per min
//heartrate = itobcd(92160/pulseperiod); // Calculate 3 beat average heart rate per min
heartrate = itobcd(50720/pulseperiod); // Calculate 3 beat average heart rate per min
//heartrate = (92160/pulseperiod); // Calculate 3 beat average heart rate per min
pulseperiod = 0; // Reset pulse period for next measurement
///*
LCDMEM[2] = char_gen_10_11[heartrate & 0x0f]; // Display current heart rate units -> LCD Digit 11
LCDMEM[3] = char_gen_10_11[(heartrate & 0xf0) >> 4]; // tens -> LCD Digit 10
LCDMEM[4] = char_gen_8_9[(heartrate & 0xf00) >> 8]; // hundreds -> LCD Digit 9
LCDMEM[7] = ((char)(char_gen_1_7[heartrate & 0x0f]>>8)); // LCD -> Digit 7 High Byte
LCDMEM[6] = ((char)(char_gen_1_7[heartrate & 0x0f]&0x00FF)); // LCD -> Digit 7 Low Byte
LCDMEM[9] = ((char)(char_gen_1_7[((heartrate & 0xf0) >> 4)]>>8)); // LCD -> Digit 6 High Byte
LCDMEM[8] = ((char)(char_gen_1_7[((heartrate & 0xf0) >> 4)]&0x00FF)); // LCD -> Digit 6 Low Byte
LCDMEM[11] = ((char)(char_gen_1_7[((heartrate & 0xf00) >> 8)]>>8)); // LCD -> Digit 5 High Byte
LCDMEM[10] = ((char)(char_gen_1_7[((heartrate & 0xf00) >> 8)]&0x00FF)); // LCD -> Digit 5 Low Byte
//*/
}
}
}
}//main
// Initialization function
void Init( void )
{
FLL_CTL0 |= XCAP10PF; // Set load capacitance for xtal
WDTCTL = WDTPW | WDTHOLD; // Disable the Watchdog
while ( LFOF & FLL_CTL0); // wait for watch crystal to stabilize
SCFQCTL = 63; // 32 x 32768 x 2 = 2.097152MHz
BTCTL = BT_fLCD_DIV128; // Set LCD frame freq = ACLK/128
// Initialize and enable LCD peripheral
ClearLCD(); // Clear LCD memory
LCDCTL = LCDSG0_3 + LCD4MUX + LCDON ; // 4mux LCD, segs0-23 enabled
// Initialize and enable GPIO ports
P1OUT = 0x00 + BIT3; // Clear P1OUT register, INA turned ON
P1DIR = 0x3f; // Unused pins as outputs, Comparator pins as inputs
P2OUT = 0x00; // Clear P2OUT register
P2DIR = 0xff; // Unused pins as outputs
P2DIR = ~(PB_2_0+PB_2_1); // P2.0 and P2.1 push buttons
P2IES = 0x00; // Interrupt edge low to high transition
P2IFG = 0x00; // Clear pending P2 interrupts
P2IE = PB_2_0 | PB_2_1; // Enable intterupts for push buttons
P3OUT = 0x00; // Clear P3OUT register
P3DIR = 0x0f; // Unused pins as outputs except P3.<4-7> -> For the new LCD's received at ~04.10.2012 this must be inputs!!
P4OUT = 0x00; // Clear P4OUT register
P4DIR = 0xff; // Unused pins as outputs
P5OUT = 0x00; // Clear P5OUT register
P5DIR = 0xff; // Unused pins as outputs
P5SEL = 0xfc; // Set Rxx and COM pins for LCD
P6OUT = 0x00; // Clear P6OUT register
P6SEL = 0xff; // P6 = Analog
// Initialize and enable UART
P2SEL|=BIT4; // P2.4 = TXD
UCTL0 |= SWRST; // UART SWRST = 1
ME1 |= UTXE0; // Enable UART0 TXD
UCTL0 |= CHAR; // 8-bit char, SWRST=1
UTCTL0 |= SSEL1; // UCLK = SMCLK
UBR00 = 18; // 115200 from 2.097152MHz
UBR10 = 0;
UMCTL0 = 0x2c; // Modulation = 0.2044
UCTL0 &= ~SWRST; // UART SWRST = 0, enable UART
IFG1 &= ~UTXIFG0;
// Initialize and enable ADC12
ADC12CTL0 = ADC12ON + SHT0_4 + REFON + REF2_5V;
// ADC12 ON, Reference = 2.5V for DAC0
ADC12CTL1 = SHP + SHS_1 + CONSEQ_2; // Use sampling timer, TA1 trigger
ADC12MCTL0 = INCH_1 + SREF_1; // Vref, channel = 1 = OA0 Out
ADC12IE = BIT0; // Enable interrupt for ADC12 MEM0
ADC12CTL0 |= ENC; // Enable conversions
// Initialize and enable Timer_A
TACTL = TASSEL0 + MC_1 + TACLR; // ACLK, Clear TAR, Up Mode
TACCTL1 = OUTMOD_2; // Set / Reset
TACCR0 = 63; // 512 samples per second
TACCR1 = 15; //
// Initialize and enable DAC12x
DAC12_0CTL = DAC12OPS + DAC12CALON + DAC12IR + DAC12AMP_2 + DAC12ENC;// DAC0 enable
DAC12_1CTL = DAC12CALON + DAC12IR + DAC12AMP_2 + DAC12ENC; // DAC1 enable
DAC12_1DAT = 0x099A; // Offset level = 1.5V for op amp bias
// Initialize and enable opamps
OA0CTL0 = OAP_1 + OAPM_1 + OAADC1; // OA0 enable power mode 1, OA0- = P6.0, 0A0+ = P6.2, OA0O = P6.1
OA0CTL1 = OARRIP; // General purpose mode, no Rail-to-Rail inputs
OA1CTL0 = OAP_3 + OAPM_1 + OAADC1; // OA1 enable power mode 1, OA1- = P6.4, OA1+ = DAC1, OA1O = P6.3
OA1CTL1 = OARRIP; // General purpose mode, no Rail-to-Rail inputs
OA2CTL0 = OAP_3 + OAPM_1 + OAADC1; // OA2 enable power mode 1, OA2+ = DAC1, OA2O = P6.5, Select inputs, power mode
OA2CTL1 = OAFC_1 + OARRIP; // Unit gain Mode, no Rail-to-Rail inputs
__enable_interrupt(); // Enable global Interrupts
} //init
void ClearLCD(void)
{
int i; //
for( i = 0; i < 20; i++){ // Clear LCDMEM
LCDMEM[i] = 0; //
}
}//clear LCD
int itobcd(int i) // Convert hex word to BCD.
{
int bcd = 0; //
char j = 0; //
while (i > 9) //
{
bcd |= ((i % 10) << j); //
i /= 10; //
j += 4;
} //
return (bcd | (i << j)); // Return converted value
}// itobcd(i)
int filterlp(int sample) // Lowpass FIR filter for EKG
{
static int buflp[32]; // Reserve 32 loactions for circular buffering
static int offsetlp = 0;
long z;
int i;
buflp[offsetlp] = sample;
z = mul16(coeffslp[8], buflp[(offsetlp - 8) & 0x1F]);
__no_operation();
for (i = 0; i < 8; i++){
z += mul16(coeffslp[i], buflp[(offsetlp - i) & 0x1F] + buflp[(offsetlp - 16 + i) & 0x1F]);
}
offsetlp = (offsetlp + 1) & 0x1F;
return z >> 15; // Return filter output
}// int filter
int filterhp(int samplehp) // Highpass FIR filter for hear rate
{
static int bufhp[32]; // Reserve 32 loactions for circular buffering
static int offsethp = 0;
long z;
int i;
bufhp[offsethp] = samplehp;
z = mul16(coeffshp[8], bufhp[(offsethp - 8) & 0x1F]);
for (i = 0; i < 8; i++){
z += mul16(coeffshp[i], bufhp[(offsethp - i) & 0x1F] + bufhp[(offsethp - 16 + i) & 0x1F]);
}
offsethp = (offsethp + 1) & 0x1F;
return z >> 15; // Return filter output
}// int filterhp
#pragma vector = PORT2_VECTOR
__interrupt void Port2ISR (void)
{
P2IFG = 0;
}//Push buttons unused
#pragma vector = ADC_VECTOR // ADC12 ISR
__interrupt void ADC12ISR (void)
{
Datain = ADC12MEM0; // Store converted value in Datain
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 on return
}// ADC12ISR

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<project>
<fileVersion>2</fileVersion>
<fileChecksum>475830264</fileChecksum>
<configuration>
<name>Debug</name>
<outputs>
<file>$PROJ_DIR$\MOD-EKG_DemoSoft.c</file>
<file>$TOOLKIT_DIR$\inc\msp430xg43x.h</file>
<file>$PROJ_DIR$\Debug\Exe\MOD-EKG_DemoSoft.d43</file>
<file>$PROJ_DIR$\Debug\Obj\MOD-EKG_DemoSoft.pbd</file>
<file>$PROJ_DIR$\mul.s43</file>
<file>$TOOLKIT_DIR$\inc\intrinsics.h</file>
<file>$PROJ_DIR$\Debug\Obj\MOD-EKG_DemoSoft.pbi</file>
<file>$TOOLKIT_DIR$\lib\dlib\dl430fn.h</file>
<file>$PROJ_DIR$\Debug\Obj\MOD-EKG_DemoSoft.r43</file>
<file>$TOOLKIT_DIR$\lib\dlib\dl430fn.r43</file>
<file>$TOOLKIT_DIR$\inc\in430.h</file>
<file>$PROJ_DIR$\Debug\Exe\MOD-EKG_DemoSoft.ulp</file>
<file>$PROJ_DIR$\Debug\Obj\mul.r43</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\ymath.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\math.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\ycheck.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\DLib_Defaults.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\xencoding_limits.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\yvals.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\DLib_Threads.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\DLib_Product.h</file>
<file>$TOOLKIT_DIR$\inc\dlib\c\xtgmath.h</file>
<file>$TOOLKIT_DIR$\config\linker\lnk430fg439.xcl</file>
<file>$PROJ_DIR$\Debug\Exe\MOD-EKG_DemoSoft.a43</file>
<file>$PROJ_DIR$\Debug\Exe\MOD-EKG_DemoSoft.hex</file>
<file>$PROJ_DIR$\Debug\Exe\ekg.hex</file>
</outputs>
<file>
<name>$PROJ_DIR$\MOD-EKG_DemoSoft.c</name>
<outputs>
<tool>
<name>BICOMP</name>
<file> 6</file>
</tool>
<tool>
<name>ICC430</name>
<file> 8</file>
</tool>
</outputs>
<inputs>
<tool>
<name>BICOMP</name>
<file> 1 10 5 14 15 13 18 16 7 20 17 19 21</file>
</tool>
<tool>
<name>ICC430</name>
<file> 1 10 5 14 15 13 18 16 7 20 17 19 21</file>
</tool>
</inputs>
</file>
<file>
<name>$PROJ_DIR$\Debug\Exe\MOD-EKG_DemoSoft.d43</name>
<inputs>
<tool>
<name>XLINK</name>
<file> 22 8 12 9</file>
</tool>
</inputs>
</file>
<file>
<name>$PROJ_DIR$\mul.s43</name>
<outputs>
<tool>
<name>A430</name>
<file> 12</file>
</tool>
</outputs>
</file>
<file>
<name>$PROJ_DIR$\Debug\Exe\MOD-EKG_DemoSoft.a43</name>
<inputs>
<tool>
<name>XLINK</name>
<file> 22 8 12 9</file>
</tool>
</inputs>
</file>
<file>
<name>$PROJ_DIR$\Debug\Exe\MOD-EKG_DemoSoft.hex</name>
<inputs>
<tool>
<name>XLINK</name>
<file> 22 8 12 9</file>
</tool>
</inputs>
</file>
<file>
<name>[ROOT_NODE]</name>
<outputs>
<tool>
<name>XLINK</name>
<file> 25</file>
</tool>
<tool>
<name>ULP430</name>
<file> 11</file>
</tool>
</outputs>
</file>
<file>
<name>$PROJ_DIR$\Debug\Exe\ekg.hex</name>
<inputs>
<tool>
<name>XLINK</name>
<file> 22 8 12 9</file>
</tool>
</inputs>
</file>
</configuration>
<configuration>
<name>Release</name>
<outputs/>
<forcedrebuild>
<name>[MULTI_TOOL]</name>
<tool>XLINK</tool>
</forcedrebuild>
</configuration>
</project>

View File

@ -0,0 +1,819 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<project>
<fileVersion>2</fileVersion>
<configuration>
<name>Debug</name>
<toolchain>
<name>MSP430</name>
</toolchain>
<debug>1</debug>
<settings>
<name>C-SPY</name>
<archiveVersion>4</archiveVersion>
<data>
<version>27</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>CInput</name>
<state>1</state>
</option>
<option>
<name>MacOverride</name>
<state>0</state>
</option>
<option>
<name>MacFile</name>
<state></state>
</option>
<option>
<name>IProcessor</name>
<state>0</state>
</option>
<option>
<name>GoToEnable</name>
<state>1</state>
</option>
<option>
<name>GoToName</name>
<state>main</state>
</option>
<option>
<name>DynDriver</name>
<state>430FET</state>
</option>
<option>
<name>dDllSlave</name>
<state>0</state>
</option>
<option>
<name>DdfFileSlave</name>
<state>1</state>
</option>
<option>
<name>DdfOverride</name>
<state>0</state>
</option>
<option>
<name>DdfFileName</name>
<state>$TOOLKIT_DIR$\config\debugger\MSP430FG439.ddf</state>
</option>
<option>
<name>ProcTMS</name>
<state>1</state>
</option>
<option>
<name>CExtraOptionsCheck</name>
<state>0</state>
</option>
<option>
<name>CExtraOptions</name>
<state></state>
</option>
<option>
<name>ProcMSP430X</name>
<state>1</state>
</option>
<option>
<name>CompilerDataModel</name>
<state>1</state>
</option>
<option>
<name>IVBASE</name>
<state>1</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath1</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck2</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath2</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck3</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath3</name>
<state></state>
</option>
<option>
<name>CPUTAG</name>
<state>1</state>
</option>
<option>
<name>L092Mode</name>
<state>1</state>
</option>
<option>
<name>OCImagesOffset1</name>
<state></state>
</option>
<option>
<name>OCImagesOffset2</name>
<state></state>
</option>
<option>
<name>OCImagesOffset3</name>
<state></state>
</option>
<option>
<name>OCImagesUse1</name>
<state>0</state>
</option>
<option>
<name>OCImagesUse2</name>
<state>0</state>
</option>
<option>
<name>OCImagesUse3</name>
<state>0</state>
</option>
<option>
<name>ENERGYTRACE</name>
<state>1</state>
</option>
<option>
<name>FETIPE</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
<name>430FET</name>
<archiveVersion>1</archiveVersion>
<data>
<version>27</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>CFetMandatory</name>
<state>0</state>
</option>
<option>
<name>Erase</name>
<state>1</state>
</option>
<option>
<name>EMUVerifyDownloadP7</name>
<state>0</state>
</option>
<option>
<name>EraseOptionSlaveP7</name>
<state>0</state>
</option>
<option>
<name>ExitBreakpointP7</name>
<state>0</state>
</option>
<option>
<name>PutcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>GetcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>derivativeP7</name>
<state>0</state>
</option>
<option>
<name>ParallelPortP7</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>TargetVoltage</name>
<state>3.3</state>
</option>
<option>
<name>AllowLockedFlashAccessP7</name>
<state>0</state>
</option>
<option>
<name>EMUAttach</name>
<state>0</state>
</option>
<option>
<name>AttachOptionSlave</name>
<state>0</state>
</option>
<option>
<name>CRadioProtocolType</name>
<state>0</state>
</option>
<option>
<name>CCRadioModuleTypeSlave</name>
<state>1</state>
</option>
<option>
<name>EEMLevel</name>
<state>0</state>
</option>
<option>
<name>DiasbleMemoryCache</name>
<state>0</state>
</option>
<option>
<name>NeedLockedFlashAccess</name>
<state>1</state>
</option>
<option>
<name>UsbComPort</name>
<state>Automatic</state>
</option>
<option>
<name>FetConnection</name>
<version>3</version>
<state>6</state>
</option>
<option>
<name>SoftwareBreakpointEnable</name>
<state>0</state>
</option>
<option>
<name>RadioSoftwareBreakpointType</name>
<state>0</state>
</option>
<option>
<name>TargetSettlingtime</name>
<state>0</state>
</option>
<option>
<name>AllowAccessToBSL</name>
<state>0</state>
</option>
<option>
<name>OTargetVccTypeDefault</name>
<state>0</state>
</option>
<option>
<name>CCBetaDll</name>
<state>1</state>
</option>
<option>
<name>GPassword</name>
<state></state>
</option>
<option>
<name>DebugLPM5</name>
<state>0</state>
</option>
<option>
<name>LPM5Slave</name>
<state>0</state>
</option>
<option>
<name>CRadioAutoManualType</name>
<state>0</state>
</option>
<option>
<name>ExternalCodeDownload</name>
<state>0</state>
</option>
<option>
<name>CCVCCDefault</name>
<state>1</state>
</option>
<option>
<name>Retain</name>
<state>0</state>
</option>
<option>
<name>jstatebit</name>
<state>0</state>
</option>
<option>
<name>RadioJtagSpeedType</name>
<state>1</state>
</option>
<option>
<name>memoryTypeSlave</name>
<state>0</state>
</option>
<option>
<name>fuseBlowDisabledSlave</name>
<state>0</state>
</option>
<option>
<name>eraseTypeSlave</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>SIM430</name>
<archiveVersion>1</archiveVersion>
<data>
<version>4</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>SimOddAddressCheckP7</name>
<state>1</state>
</option>
<option>
<name>CSimMandatory</name>
<state>1</state>
</option>
<option>
<name>derivativeSim</name>
<state>0</state>
</option>
<option>
<name>SimEnablePSP</name>
<state>0</state>
</option>
<option>
<name>SimPspOverrideConfig</name>
<state>0</state>
</option>
<option>
<name>SimPspConfigFile</name>
<state>###Uninitialized###</state>
</option>
</data>
</settings>
<debuggerPlugins>
<plugin>
<file>$TOOLKIT_DIR$\plugins\Lcd\lcd.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxPlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyPlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
</debuggerPlugins>
</configuration>
<configuration>
<name>Release</name>
<toolchain>
<name>MSP430</name>
</toolchain>
<debug>0</debug>
<settings>
<name>C-SPY</name>
<archiveVersion>4</archiveVersion>
<data>
<version>27</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>CInput</name>
<state>1</state>
</option>
<option>
<name>MacOverride</name>
<state>0</state>
</option>
<option>
<name>MacFile</name>
<state></state>
</option>
<option>
<name>IProcessor</name>
<state>0</state>
</option>
<option>
<name>GoToEnable</name>
<state>1</state>
</option>
<option>
<name>GoToName</name>
<state>main</state>
</option>
<option>
<name>DynDriver</name>
<state>SIM430</state>
</option>
<option>
<name>dDllSlave</name>
<state>0</state>
</option>
<option>
<name>DdfFileSlave</name>
<state>1</state>
</option>
<option>
<name>DdfOverride</name>
<state>0</state>
</option>
<option>
<name>DdfFileName</name>
<state></state>
</option>
<option>
<name>ProcTMS</name>
<state>1</state>
</option>
<option>
<name>CExtraOptionsCheck</name>
<state>0</state>
</option>
<option>
<name>CExtraOptions</name>
<state></state>
</option>
<option>
<name>ProcMSP430X</name>
<state>1</state>
</option>
<option>
<name>CompilerDataModel</name>
<state>1</state>
</option>
<option>
<name>IVBASE</name>
<state>1</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath1</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck2</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath2</name>
<state></state>
</option>
<option>
<name>OCImagesSuppressCheck3</name>
<state>0</state>
</option>
<option>
<name>OCImagesPath3</name>
<state></state>
</option>
<option>
<name>CPUTAG</name>
<state>1</state>
</option>
<option>
<name>L092Mode</name>
<state>1</state>
</option>
<option>
<name>OCImagesOffset1</name>
<state></state>
</option>
<option>
<name>OCImagesOffset2</name>
<state></state>
</option>
<option>
<name>OCImagesOffset3</name>
<state></state>
</option>
<option>
<name>OCImagesUse1</name>
<state>0</state>
</option>
<option>
<name>OCImagesUse2</name>
<state>0</state>
</option>
<option>
<name>OCImagesUse3</name>
<state>0</state>
</option>
<option>
<name>ENERGYTRACE</name>
<state>1</state>
</option>
<option>
<name>FETIPE</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
<name>430FET</name>
<archiveVersion>1</archiveVersion>
<data>
<version>27</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>CFetMandatory</name>
<state>0</state>
</option>
<option>
<name>Erase</name>
<state>1</state>
</option>
<option>
<name>EMUVerifyDownloadP7</name>
<state>0</state>
</option>
<option>
<name>EraseOptionSlaveP7</name>
<state>0</state>
</option>
<option>
<name>ExitBreakpointP7</name>
<state>0</state>
</option>
<option>
<name>PutcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>GetcharBreakpointP7</name>
<state>1</state>
</option>
<option>
<name>derivativeP7</name>
<state>0</state>
</option>
<option>
<name>ParallelPortP7</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>TargetVoltage</name>
<state>###Uninitialized###</state>
</option>
<option>
<name>AllowLockedFlashAccessP7</name>
<state>0</state>
</option>
<option>
<name>EMUAttach</name>
<state>0</state>
</option>
<option>
<name>AttachOptionSlave</name>
<state>0</state>
</option>
<option>
<name>CRadioProtocolType</name>
<state>1</state>
</option>
<option>
<name>CCRadioModuleTypeSlave</name>
<state>1</state>
</option>
<option>
<name>EEMLevel</name>
<state>0</state>
</option>
<option>
<name>DiasbleMemoryCache</name>
<state>0</state>
</option>
<option>
<name>NeedLockedFlashAccess</name>
<state>1</state>
</option>
<option>
<name>UsbComPort</name>
<state>Automatic</state>
</option>
<option>
<name>FetConnection</name>
<version>3</version>
<state>0</state>
</option>
<option>
<name>SoftwareBreakpointEnable</name>
<state>0</state>
</option>
<option>
<name>RadioSoftwareBreakpointType</name>
<state>0</state>
</option>
<option>
<name>TargetSettlingtime</name>
<state>0</state>
</option>
<option>
<name>AllowAccessToBSL</name>
<state>0</state>
</option>
<option>
<name>OTargetVccTypeDefault</name>
<state>0</state>
</option>
<option>
<name>CCBetaDll</name>
<state>1</state>
</option>
<option>
<name>GPassword</name>
<state>###Uninitialized###</state>
</option>
<option>
<name>DebugLPM5</name>
<state>0</state>
</option>
<option>
<name>LPM5Slave</name>
<state>0</state>
</option>
<option>
<name>CRadioAutoManualType</name>
<state>0</state>
</option>
<option>
<name>ExternalCodeDownload</name>
<state>0</state>
</option>
<option>
<name>CCVCCDefault</name>
<state>1</state>
</option>
<option>
<name>Retain</name>
<state>0</state>
</option>
<option>
<name>jstatebit</name>
<state>0</state>
</option>
<option>
<name>RadioJtagSpeedType</name>
<state>1</state>
</option>
<option>
<name>memoryTypeSlave</name>
<state>0</state>
</option>
<option>
<name>fuseBlowDisabledSlave</name>
<state>0</state>
</option>
<option>
<name>eraseTypeSlave</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>SIM430</name>
<archiveVersion>1</archiveVersion>
<data>
<version>4</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
<name>SimOddAddressCheckP7</name>
<state>1</state>
</option>
<option>
<name>CSimMandatory</name>
<state>1</state>
</option>
<option>
<name>derivativeSim</name>
<state>0</state>
</option>
<option>
<name>SimEnablePSP</name>
<state>0</state>
</option>
<option>
<name>SimPspOverrideConfig</name>
<state>0</state>
</option>
<option>
<name>SimPspConfigFile</name>
<state>###Uninitialized###</state>
</option>
</data>
</settings>
<debuggerPlugins>
<plugin>
<file>$TOOLKIT_DIR$\plugins\Lcd\lcd.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxPlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyPlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\PowerPac\PowerPacRTOS.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin</file>
<loadFlag>1</loadFlag>
</plugin>
<plugin>
<file>$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
</debuggerPlugins>
</configuration>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<project>
<path>$WS_DIR$\MOD-EKG_DemoSoft.ewp</path>
</project>
<batchBuild/>
</workspace>

View File

@ -0,0 +1,110 @@
//
//16x16=>32 multiply
//long mul16(register int x, register int y)
//
// Edited by: M Morales, November 2008
// * Updated calling conventions in support of IAR compiler >= 4.x
//*****************************************************************************
// THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
// REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
// INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
// COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
// TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
// POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
// INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
// YOUR USE OF THE PROGRAM.
//
// IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
// THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
// OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
// EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
// REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
// OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
// USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
// AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
// YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
// (U.S.$500).
//
// Unless otherwise stated, the Program written and copyrighted
// by Texas Instruments is distributed as "freeware". You may,
// only under TI's copyright in the Program, use and modify the
// Program without any charge or restriction. You may
// distribute to third parties, provided that you transfer a
// copy of this license to the third party and the third party
// agrees to these terms by its first use of the Program. You
// must reproduce the copyright notice and any other legend of
// ownership on each copy or partial copy, of the Program.
//
// You acknowledge and agree that the Program contains
// copyrighted material, trade secrets and other TI proprietary
// information and is protected by copyright laws,
// international copyright treaties, and trade secret laws, as
// well as other intellectual property laws. To protect TI's
// rights in the Program, you agree not to decompile, reverse
// engineer, disassemble or otherwise translate any object code
// versions of the Program to a human-readable form. You agree
// that in no event will you alter, remove or destroy any
// copyright notice included in the Program. TI reserves all
// rights not specifically granted under this license. Except
// as specifically provided herein, nothing in this agreement
// shall be construed as conferring by implication, estoppel,
// or otherwise, upon you, any license or other right under any
// TI patents, copyrights or trade secrets.
//
// You may not use the Program in non-TI devices.
//*****************************************************************************
public mul16
RSEG CODE
mul16
#define x1 r9
#define z0 r14
#define z1 r15
#define x r12
#define y r13
push r9
clr z0
mov z0,z1
mov z0,x1
tst x
jge xbooth_2
mov #-1,x1
jmp xbooth_2
xbooth_6
add x,z1
addc x1,z0
xbooth_1
rla x
rlc x1
xbooth_2
rra y
jc xbooth_5
jne xbooth_1
jmp xbooth_4
xbooth_5
sub x,z1
subc x1,z0
xbooth_3
rla x
rlc x1
rra y
jnc xbooth_6
cmp #0FFFFh,y
jne xbooth_3
xbooth_4
mov z1,r12
mov z0,r13
pop r9
ret
end

View File

View File

@ -0,0 +1,24 @@
@REM This batch file has been generated by the IAR Embedded Workbench
@REM C-SPY Debugger, as an aid to preparing a command line for running
@REM the cspybat command line utility using the appropriate settings.
@REM
@REM Note that this file is generated every time a new debug session
@REM is initialized, so you may want to move or rename the file before
@REM making changes.
@REM
@REM You can launch cspybat by typing the name of this batch file followed
@REM by the name of the debug file (usually an ELF/DWARF or UBROF file).
@REM
@REM Read about available command line parameters in the C-SPY Debugging
@REM Guide. Hints about additional command line parameters that may be
@REM useful in specific cases:
@REM --download_only Downloads a code image without starting a debug
@REM session afterwards.
@REM --silent Omits the sign-on message.
@REM --timeout Limits the maximum allowed execution time.
@REM
"C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0_2\common\bin\cspybat" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0_2\430\bin\430proc.dll" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0_2\430\bin\430fet.dll" %1 --plugin "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0_2\430\bin\430bat.dll" --backend -B "-p" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0_2\430\config\debugger\MSP430FG439.ddf" "--iv_base" "0xFFE0" "-d" "fet" "--erase_main_and_info" "--derivative" "MSP430FG43x_F43x" "--protocol" "4wire" "--eem" "EMEX_LOW" "--port" "Automatic" "--connection" "olimex" "--settlingtime=0" "--msp430_dll" "msp430.dll" "--vccDefault" "3.3" "--jtag_speed" "medium" "--memtype" "F"

View File

@ -0,0 +1,34 @@
@REM This bat file has been generated by the IAR Embeddded Workbench
@REM C-SPY interactive debugger,as an aid to preparing a command
@REM line for running the cspybat command line utility with the
@REM appropriate settings.
@REM
@REM After making some adjustments to this file, you can launch cspybat
@REM by typing the name of this file followed by the name of the debug
@REM file (usually an ubrof file). Note that this file is generated
@REM every time a new debug session is initialized, so you may want to
@REM move or rename the file before making changes.
@REM
@REM Note: some command line arguments cannot be properly generated
@REM by this process. Specifically, the plugin which is responsible
@REM for the Terminal I/O window (and other C runtime functionality)
@REM comes in a special version for cspybat, and the name of that
@REM plugin dll is not known when generating this file. It resides in
@REM the $TOOLKIT_DIR$\bin folder and is usually called XXXbat.dll or
@REM XXXlibsupportbat.dll, where XXX is the name of the corresponding
@REM tool chain. Replace the '<libsupport_plugin>' parameter
@REM below with the appropriate file name. Other plugins loaded by
@REM C-SPY are usually not needed by, or will not work in, cspybat
@REM but they are listed at the end of this file for reference.
"C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\common\bin\cspybat" "C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\430\bin\430proc.dll" "C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\430\bin\430fet.dll" %1 --plugin "C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\430\bin\<libsupport_plugin>" --backend -B "-p" "C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\430\config\MSP430FG439.ddf" "--iv_base" "0xFFE0" "-d" "fet" "--erase_main_and_info" "--derivative" "MSP430FG439" "--vccvoltage=3.3" "--protocol" "4wire" "--eem" "EMEX_LOW" "--connection" "olimex" "--settlingtime=0"
@REM Loaded plugins:
@REM C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\430\bin\430libsupport.dll
@REM C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\430\plugins\lcd\lcd.dll
@REM C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\common\plugins\CodeCoverage\CodeCoverage.dll
@REM C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\common\plugins\Profiling\Profiling.dll
@REM C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\common\plugins\stack\stack.dll
@REM C:\Program Files\IAR Systems\IAR Embedded Workbench for MSP, v4.21 Evaluation version\common\plugins\SymList\SymList.dll

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<Project>
<Desktop>
<Static>
<Debug-Log>
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1221</ColumnWidth1></Debug-Log>
<Build>
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>915</ColumnWidth1><ColumnWidth2>244</ColumnWidth2><ColumnWidth3>61</ColumnWidth3></Build>
<Workspace>
<ColumnWidths>
<Column0>174</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>
</Workspace>
<Disassembly>
<MixedMode>1</MixedMode><CodeCovShow>0</CodeCovShow><InstrProfShow>0</InstrProfShow><col-names><item>Disassembly</item><item>_I0</item></col-names><col-widths><item>500</item><item>20</item></col-widths><DisasmHistory/><ShowCodeCoverage>1</ShowCodeCoverage><ShowInstrProfiling>1</ShowInstrProfiling></Disassembly>
</Static>
<Windows>
<Wnd0>
<Tabs>
<Tab>
<Identity>TabID-32631-32423</Identity>
<TabName>Debug Log</TabName>
<Factory>Debug-Log</Factory>
<Session/>
</Tab>
<Tab>
<Identity>TabID-32108-32433</Identity>
<TabName>Build</TabName>
<Factory>Build</Factory>
<Session/>
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd0><Wnd1>
<Tabs>
<Tab>
<Identity>TabID-10611-32426</Identity>
<TabName>Workspace</TabName>
<Factory>Workspace</Factory>
<Session>
<NodeDict><ExpandedNode>MOD-EKG_DemoSoft</ExpandedNode></NodeDict></Session>
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd1><Wnd2>
<Tabs>
<Tab>
<Identity>TabID-21360-32430</Identity>
<TabName>Disassembly</TabName>
<Factory>Disassembly</Factory>
<Session/>
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd2></Windows>
<Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\MOD-EKG_DemoSoft.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>249</YPos2><SelStart2>11595</SelStart2><SelEnd2>11595</SelEnd2></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
<Top><Row0><Sizes><Toolbar-00C12E30><key>iaridepm.enu1</key></Toolbar-00C12E30></Sizes></Row0><Row1><Sizes><Toolbar-0B3FCAF8><key>debuggergui.enu1</key></Toolbar-0B3FCAF8></Sizes></Row1><Row2><Sizes><Toolbar-0B3FD5E8><key>430fet1</key></Toolbar-0B3FD5E8></Sizes></Row2></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>562</Bottom><Right>248</Right><x>-2</x><y>-2</y><xscreen>250</xscreen><yscreen>175</yscreen><sizeHorzCX>156250</sizeHorzCX><sizeHorzCY>211353</sizeHorzCY><sizeVertCX>156250</sizeVertCX><sizeVertCY>681159</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>562</Bottom><Right>248</Right><x>-2</x><y>-2</y><xscreen>250</xscreen><yscreen>175</yscreen><sizeHorzCX>156250</sizeHorzCX><sizeHorzCY>211353</sizeHorzCY><sizeVertCX>156250</sizeVertCX><sizeVertCY>681159</sizeVertCY></Rect></Wnd2></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>173</Bottom><Right>1602</Right><x>-2</x><y>-2</y><xscreen>1604</xscreen><yscreen>175</yscreen><sizeHorzCX>1002500</sizeHorzCX><sizeHorzCY>211353</sizeHorzCY><sizeVertCX>156250</sizeVertCX><sizeVertCY>211353</sizeVertCY></Rect></Wnd0></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Project>

View File

@ -0,0 +1,94 @@
[Interrupts]
Enabled=1
[MemoryMap]
Enabled=0
Base=0
UseAuto=0
TypeViolation=1
UnspecRange=1
ActionState=1
[TraceHelper]
Enabled=0
ShowSource=1
[DebugChecksum]
Checksum=-1742591943
[State Storage]
Control Register=5814
[Sequencer]
Control Register=0
NextState0=0
NextState1=0
[Action Register]
Break=0
State Storage=0
[DisAssemblyWindow]
NumStates=_ 1
State 1=_ 1
[InstructionProfiling]
Enabled=_ 0
[CodeCoverage]
Enabled=_ 0
[Profiling]
Enabled=0
[StackPlugin]
Enabled=1
OverflowWarningsEnabled=1
WarningThreshold=90
SpWarningsEnabled=1
WarnHow=0
UseTrigger=1
TriggerName=main
LimitSize=0
ByteLimit=50
[Stack]
FillEnabled=0
OverflowWarningsEnabled=1
WarningThreshold=90
SpWarningsEnabled=1
WarnLogOnly=1
UseTrigger=1
TriggerName=main
LimitSize=0
ByteLimit=50
[EEM State Storage]
Buffer=BAAAAAAADAAAAAAAAAAAAAAA
[EEM Sequencer]
Buffer=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
[NumberOfSequencerBp]
Number=4
[Breakpoints]
Count=0
[FET]
Clock mode=46
Extended Clock mode=65535
Secure Password=
Extended Clock Control Enable=1
Advanced Extended Clock Control=0
Emulation mode=0
Free running=0
Shutting Down=3
[Memory Dump]
Start address=
Lenghth=
Address info=0
Format=0
Dump registers=0
PC=0
SP=0
SR=0
all registers=0
File name=
[Log file]
LoggingEnabled=_ 0
LogFile=_ ""
Category=_ 0
[TermIOLog]
LoggingEnabled=_ 0
LogFile=_ ""
[Aliases]
Count=0
SuppressDialog=0
[CallStack]
ShowArgs=0
[Disassembly]
MixedMode=1

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<Workspace>
<ConfigDictionary>
<CurrentConfigs><Project>MOD-EKG_DemoSoft/Debug</Project></CurrentConfigs></ConfigDictionary>
<Desktop>
<Static>
<Workspace>
<ColumnWidths>
<Column0>318</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>
</Workspace>
<Build>
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>915</ColumnWidth1><ColumnWidth2>244</ColumnWidth2><ColumnWidth3>61</ColumnWidth3></Build>
<Debug-Log>
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1221</ColumnWidth1></Debug-Log>
<TerminalIO/>
<Find-in-Files><ColumnWidth0>440</ColumnWidth0><ColumnWidth1>62</ColumnWidth1><ColumnWidth2>754</ColumnWidth2></Find-in-Files></Static>
<Windows>
<Wnd2>
<Tabs>
<Tab>
<Identity>TabID-5007-30075</Identity>
<TabName>Workspace</TabName>
<Factory>Workspace</Factory>
<Session>
<NodeDict><ExpandedNode>MOD-EKG_DemoSoft</ExpandedNode><ExpandedNode>MOD-EKG_DemoSoft/Output</ExpandedNode><ExpandedNode>MOD-EKG_DemoSoft/Output/MOD-EKG_DemoSoft.d43</ExpandedNode></NodeDict></Session>
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd2><Wnd3>
<Tabs>
<Tab>
<Identity>TabID-616-32204</Identity>
<TabName>Build</TabName>
<Factory>Build</Factory>
<Session/>
</Tab>
<Tab>
<Identity>TabID-32338-32224</Identity>
<TabName>Debug Log</TabName>
<Factory>Debug-Log</Factory>
<Session/>
</Tab>
<Tab><Identity>TabID-552-6144</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs>
<SelectedTab>0</SelectedTab></Wnd3></Windows>
<Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\MOD-EKG_DemoSoft.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>199</YPos2><SelStart2>11905</SelStart2><SelEnd2>11905</SelEnd2></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
<Top><Row0><Sizes><Toolbar-00C12E30><key>iaridepm.enu1</key></Toolbar-00C12E30></Sizes></Row0><Row1><Sizes/></Row1><Row2><Sizes/></Row2><Row3><Sizes/></Row3><Row4><Sizes/></Row4><Row5><Sizes/></Row5><Row6><Sizes/></Row6></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>630</Bottom><Right>392</Right><x>-2</x><y>-2</y><xscreen>250</xscreen><yscreen>175</yscreen><sizeHorzCX>156250</sizeHorzCX><sizeHorzCY>211353</sizeHorzCY><sizeVertCX>246250</sizeVertCX><sizeVertCY>763285</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>153</Bottom><Right>1602</Right><x>-2</x><y>-2</y><xscreen>1604</xscreen><yscreen>155</yscreen><sizeHorzCX>1002500</sizeHorzCX><sizeHorzCY>187198</sizeHorzCY><sizeVertCX>156250</sizeVertCX><sizeVertCY>211353</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Workspace>

View File

@ -0,0 +1,2 @@
[MainWindow]
WindowPlacement=_ 25 25 1225 657 3

View File

@ -79,14 +79,14 @@ def main():
try:
temp = int(temp)
temp = float(temp)
except ValueError, msg:
logger.exception(msg)
continue
try:
osc_message = OSCMessage("/%s/temperatur" % actor)
osc_message.appendTypedArg(temp, "i")
osc_message = OSCMessage("/%s/temperature" % actor)
osc_message.appendTypedArg(temp, "f")
platform.osc_sock.sendto(osc_message.encode_osc(), platform.remote)
except socket.error, msg:
logger.exception(msg)

View File

@ -73,7 +73,7 @@ class EHealth2OSC(Forwarder):
osc_message = OSCMessage("/%s/emg" % self.actor)
osc_message.appendTypedArg(emg, "i")
osc_sock.sendall(osc_message.encode_osc())
osc_message = OSCMessage("/%s/temperatur" % self.actor)
osc_message = OSCMessage("/%s/temperature" % self.actor)
osc_message.appendTypedArg(temp, "i")
osc_sock.sendall(osc_message.encode_osc())

View File

@ -75,7 +75,7 @@ class EHealth2OSC(Forwarder):
osc_message = OSCMessage("/%s/emg" % self.actor)
osc_message.appendTypedArg(emg, "i")
osc_sock.sendall(osc_message.encode_osc())
osc_message = OSCMessage("/%s/temperatur" % self.actor)
osc_message = OSCMessage("/%s/temperature" % self.actor)
osc_message.appendTypedArg(temp, "i")
osc_sock.sendall(osc_message.encode_osc())