Commit d4da0cb9 authored by Karol Hennessy's avatar Karol Hennessy

added gpl v3 licence

parent a98e5b94
This diff is collapsed.
MIT License
Copyright (c) 2020 HEV Collaboration, CERN
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
ansible_home=`pwd`/playbooks
export ANSIBLE_CONFIG=$ansible_home/ansible.cfg
export ANSIBLE_INVENTORY=$ansible_home/hosts
export ANSIBLE_LIBRARY=$ansible_home
......
---
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- hosts: hevpi
remote_user: pi
vars:
......
#!/bin/bash
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
download_dir=/home/pi/Downloads/
......
---
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- hosts: hevpi
remote_user: pi
vars:
......
#!/bin/bash
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
sudo raspi-config nonint do_hostname hevpi
sudo raspi-config nonint do_overscan 1
......
---
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- hosts: hevpi
remote_user: pi
vars:
......
#!/bin/bash
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
download_dir=/home/pi/Downloads
dev_dir=/home/pi/Development
......
#!/bin/bash
wget -qO - https://hev-sw.gitlab.io/public.key | sudo apt-key add - && echo deb https://hev-sw.gitlab.io/wip/deb/raspbian/ buster main | sudo tee /etc/apt/sources.list.d/hev-sw.list
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
---
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- hosts: cernpi
remote_user: pi
vars:
......
---
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- hosts: hevpi
remote_user: pi
vars:
......
rpi_swlist:
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- vim
- cowsay
- openssh-server
......
#!/bin/bash
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -o get-platformio.py
python3 get-platformio.py
......
---
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- hosts: allpi
remote_user: pi
vars:
......
---
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
- hosts: hevpi
remote_user: pi
vars:
......
#!/bin/bash
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
a2dismod wsgi
a2enmod wsgi
#update the locations in hev.conf if needed
......
#!/bin/bash
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
sketch=Multiloop_skeleton
......
- hosts: hevpi
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
vars:
download_dir: /home/pi/Downloads
......
int Sentor_P0 = A0;
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(13, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2, HIGH); // sets the digital pin 13 on
int P0 = analogRead(Sentor_P0);
delay(1000); // waits for a second
digitalWrite(2, LOW); // sets the digital pin 13 off
//Serial.print("P0");
Serial.println((String)+P0+",2000,");
/* Serial.println("1234");
Serial.println(P2);
Serial.println(P3);
Serial.println(P4);
(String)"x:"+x+" y:"+y
*/
;
// Serial.print("\n");
delay(1000);
}
import serial
import matplotlib.pyplot as plt
from drawnow import *
import atexit
P0 = []
P1 = []
x = []
plt.ion()
cnt=0
serialArduino = serial.Serial('/dev/ttyUSB0', 9600)
def plotValues():
plt.title('Serial value from Arduino')
plt.grid(True)
plt.ylabel('Pressure')
plt.plot(P0, 'rx-', label='P0')
plt.plot(P1, 'bx-', label='P1')
plt.legend(loc='upper right')
def doAtExit():
serialArduino.close()
print("Close serial")
print("serialArduino.isOpen() = " + str(serialArduino.isOpen()))
atexit.register(doAtExit)
print("serialArduino.isOpen() = " + str(serialArduino.isOpen()))
#pre-load dummy data
for i in range(0,26):
P0.append(0)
P1.append(0)
while True:
while (serialArduino.inWaiting()==0):
pass
print("readline()")
valueRead = serialArduino.readline()
print(valueRead)
#valueInInt = int(valueRead)
# x = valueRead.split()
# print(valueRead[1])
Pressure0 = valueRead.decode().split(",")[0]
print(Pressure0)
Pressure1 = valueRead.decode().split(",")[1]
print(Pressure1)
#check if valid value can be casted
try:
valueInInt = int(Pressure0)
valueInInt1 = int(Pressure1)
print(valueInInt)
if valueInInt <= 1024:
P0.append(valueInInt)
P0.pop(0)
P1.append(valueInInt1)
P1.pop(0)
drawnow(plotValues)
else:
print("Invalid! too large")
except ValueError:
print("Invalid! cannot cast")
"""
ldr.py
Display analog data from Arduino using Python (matplotlib)
Author: Mahesh Venkitachalam
Website: electronut.in
"""
import sys, serial, argparse
import numpy as np
from time import sleep
from collections import deque
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# plot class
class AnalogPlot:
# constr
def __init__(self, strPort, maxLen):
# open serial port
self.ser = serial.Serial(strPort, 9600)
self.ax = deque([0.0]*maxLen)
self.ay = deque([0.0]*maxLen)
self.maxLen = maxLen
# add to buffer
def addToBuf(self, buf, val):
if len(buf) < self.maxLen:
buf.append(val)
else:
buf.pop()
buf.appendleft(val)
# add data
def add(self, data):
assert(len(data) == 2)
self.addToBuf(self.ax, data[0])
self.addToBuf(self.ay, data[1])
# update plot
def update(self, frameNum, a0, a1):
try:
line = self.ser.readline()
data = [float(val) for val in line.split()]
# print data
if(len(data) == 2):
self.add(data)
a0.set_data(range(self.maxLen), self.ax)
a1.set_data(range(self.maxLen), self.ay)
except KeyboardInterrupt:
print('exiting')
return a0,
# clean up
def close(self):
# close serial
self.ser.flush()
self.ser.close()
# main() function
def main():
# create parser
parser = argparse.ArgumentParser(description="LDR serial")
# add expected arguments
parser.add_argument('--port', dest='port', required=True)
# parse args
args = parser.parse_args()
#strPort = '/dev/tty.usbserial-A7006Yqh'
strPort = args.port
print('reading from serial port %s...' % strPort)
# plot parameters
analogPlot = AnalogPlot(strPort, 100)
print('plotting data...')
# set up animation
fig = plt.figure()
ax = plt.axes(xlim=(0, 100), ylim=(0, 1023))
a0, = ax.plot([], [])
a1, = ax.plot([], [])
anim = animation.FuncAnimation(fig, analogPlot.update,
fargs=(a0, a1),
interval=50)
# show plot
plt.show()
# clean up
analogPlot.close()
print('exiting.')
# call main
if __name__ == '__main__':
main()
// Multi-loops skeleton
// Description: Shows 3 loops operating in "parallel" reading/writing a global variable
// Karol Hennessy
// 2020-03-29
#include <VariableTimedAction.h>
// global variables
static int globalcnt = 0;
class SafetyAlarmLoop : public VariableTimedAction
{
private:
int cnt = 0;
unsigned long run()
{
cnt++;
Serial.println("SA "+ String(globalcnt));
return 0;
}
public:
int getCnt()
{
return cnt;
}
} safetyalarmloop ;
class BreathingLoop : public VariableTimedAction
{
private:
int cnt = 0;
unsigned long run()
{
cnt++;
Serial.println("BR "+ String(cnt));
return 0;
}
public:
int getCnt()
{
return cnt;
}
} breathingloop;
class UILoop : public VariableTimedAction
{
private:
//int cnt = 0;
unsigned long run()
{
globalcnt++;
Serial.println("UI "+ String(globalcnt));
return 0;
}
public:
/* int getCnt()
{
return cnt;
}*/
} uiloop;
void setup() {
Serial.begin(9600);
// note - order is not guaranteed if they all run on the same "cycle"
safetyalarmloop.start(1000);
//breathingloop.start(500);
uiloop.start(1000);
}
void loop() {
// put your main code here, to run repeatedly:
VariableTimedAction::updateActions();
}
[env:uno]
platform = atmelavr
framework = arduino
board = uno
[env:mkrwifi1010]
platform = atmelsam
framework = arduino
board = mkrwifi1010
[env:mkrvidor4000]
platform = atmelsam
framework = arduino
board = mkrvidor4000
[env:featheresp32]
platform = espressif32
framework = arduino
board = featheresp32
[env:nodemcu-32s]
platform = espressif32
framework = arduino
board = nodemcu-32s
// Multi-loops skeleton
// Description: Shows 3 loops operating in "parallel" reading/writing a global variable
// Karol Hennessy
// 2020-03-29
#include <VariableTimedAction.h>
// global variables
static int globalcnt = 0;
class SafetyAlarmLoop : public VariableTimedAction
{
private:
int cnt = 0;
unsigned long run()
{
cnt++;
Serial.println("SA "+ String(globalcnt));
return 0;
}
public:
int getCnt()
{
return cnt;
}
} safetyalarmloop ;
class BreathingLoop : public VariableTimedAction
{
private:
int cnt = 0;
unsigned long run()
{
cnt++;
Serial.println("BR "+ String(cnt));
return 0;
}
public:
int getCnt()
{
return cnt;
}
} breathingloop;
class UILoop : public VariableTimedAction
{
private:
//int cnt = 0;
unsigned long run()
{
globalcnt++;
Serial.println("UI "+ String(globalcnt));
return 0;
}
public:
/* int getCnt()
{
return cnt;
}*/
} uiloop;
void setup() {
Serial.begin(9600);
// note - order is not guaranteed if they all run on the same "cycle"
safetyalarmloop.start(1000);
//breathingloop.start(500);
uiloop.start(1000);
}
void loop() {
// put your main code here, to run repeatedly:
VariableTimedAction::updateActions();
}
#include <LiquidCrystal.h>
//Arduino pins
const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2); // Declare number of columns and rows
Serial.begin(9600);
}
void loop() {
// This code shows on the LCD the characters received over serial port
if (Serial.available()) {
delay(1000);
lcd.clear();
while (Serial.available() > 0) {
lcd.write(Serial.read());
}
}
}
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env]
lib_deps =
5574 ; INA2xx
820 ; Adafruit mcp9808
[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>
#include "Adafruit_MCP9808.h"
#include <INA.h>
#define DEBUG
#ifdef DEBUG
#define DEBUG_SERIAL(x) Serial.begin (x)
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x)
#define DEBUG_PRINT2(x,y) Serial.print (x,y)
#define DEBUG_PRINTLN2(x,y) Serial.println (x,y)
#else
#define DEBUG_SERIAL(x)
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINT2(x,y)
#define DEBUG_PRINTLN2(x,y)
#endif
//Flag to close all valves of the system to stop the data taking in a safe state
bool stop = true;
// Create the MCP9808 temperature sensor object
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();
// Set Board to "ESP32 Dev Module"
// Set Port to /dev/ttyUSB0 on Linux
const int freq = 500; // 900 Hz for burkert 2875; Note - could be 500 Hz; depending on valve
float duty_cycle = 0.0;
const float max_duty_cycle = 0.85;
//const int pin_valve_air_in = 3; // RX0
const int pin_valve_o2_in = 5; // STRAPPING PIN (prefer as output / high-Z)
const int pin_valve_inhale = 21; // formerly valve_out
const int pin_valve_exhale = 19; // formerly valve_scavenge
const int pin_valve_purge = 18;
//const int pin_valve_atmosphere = 12; // A15 // STRAPPING PIN (prefer as output / high-Z)
const int pin_valve_air_in = 25; // DAC0
const int redled = 12; // red led on J28
const int yellowled = 16;
const int greenled = 17;
const int buzzer = 2;
const int p_patient = 32; // red led on J28
const int p_buffer = 34; //
const int p_air_supply = 36; //
const int p_air_regulated = 39; //
const int p_inhale = 35; //
const int p_o2_supply = 27; //
const int p_o2_regulated = 14; //
uint8_t devicesFound = 0; ///< Number of INAs found
INA_Class INA;
TwoWire I2CMCP9808 = TwoWire(0);
void setup() {
Serial.begin(9600);
//Wire.begin(SDA,SCL);
Wire.begin(22,23);
I2CMCP9808.begin(22,23);
if (!tempsensor.begin(0x18, &I2CMCP9808)) {
Serial.println("Couldn't find MCP9808! Check your connections and verify the address is correct.");
while (1);
}
tempsensor.setResolution(3);
// NodeMCU32
// pwm
ledcSetup(0, freq, 8);
ledcSetup(1, freq, 8);
//ledcSetup(1,2200,8); // buzzer frequency
//ledcAttachPin(pin_valve_o2_in , 0);
ledcAttachPin(pin_valve_inhale , 0);
ledcAttachPin(pin_valve_exhale , 1);
ledcAttachPin(buzzer , 1);
//ledcWrite(1, 128); //buzzer
pinMode(A13, INPUT); // potentiometer
// pressure sensors IO config
pinMode(p_patient, INPUT);
pinMode(p_buffer, INPUT);
pinMode(p_air_supply, INPUT);
pinMode(p_air_regulated, INPUT);
pinMode(p_inhale, INPUT);
pinMode(p_o2_supply, INPUT);
pinMode(p_o2_regulated, INPUT);
// Valves IO config
pinMode(pin_valve_air_in,OUTPUT);
//pinMode(pin_valve_exhale,OUTPUT);
pinMode(pin_valve_purge,OUTPUT);
pinMode(pin_valve_o2_in,OUTPUT);
// LEDs IO config
pinMode(redled,OUTPUT);
pinMode(yellowled,OUTPUT);
pinMode(greenled,OUTPUT);
if(stop){
//To Close all valves of the system
digitalWrite(pin_valve_air_in, LOW);
digitalWrite(pin_valve_exhale, LOW);
digitalWrite(pin_valve_purge, LOW);
digitalWrite(pin_valve_o2_in, LOW);
}
else{
//Default values for data taking
digitalWrite(pin_valve_air_in, HIGH);
//digitalWrite(pin_valve_exhale, LOW);
digitalWrite(pin_valve_purge, LOW);
digitalWrite(pin_valve_o2_in, HIGH);
}
//digitalWrite(redled, HIGH);
//digitalWrite(yellowled, HIGH);
//digitalWrite(greenled, HIGH);
DEBUG_PRINT("Hello");
Serial.println("Hello");
// current sensor configuration
devicesFound = INA.begin(1,500000); // Set to an expected 1 Amp maximum and a 100000 microOhm resistor
while (INA.begin(1, 500000) == 0)
{
DEBUG_PRINTLN("No INA device found, retrying in 10s...");
delay(1000); // Wait 10 seconds before retrying
} // while no devices detected
DEBUG_PRINT(" - Detected ");
DEBUG_PRINT(devicesFound);
DEBUG_PRINTLN(" INA devices on the I2C bus");
INA.setBusConversion(8500); // Maximum conversion time 8.244ms
INA.setShuntConversion(8500); // Maximum conversion time 8.244ms
INA.setAveraging(128); // Average each reading n-times
INA.setMode(INA_MODE_CONTINUOUS_BOTH); // Bus/shunt measured continuously
INA.AlertOnBusOverVoltage(true,5000); // Trigger alert if over 5V on bus
}
void loop() {
float res = analogRead(A13); //12 bit ADC on esp32
float pressure_patient = analogRead(p_patient); //12 bit ADC on esp32
float pressure_buffer = analogRead(p_buffer); //12 bit ADC on esp32
float pressure_asupply = analogRead(p_air_supply); //12 bit ADC on esp32
float pressure_aregulated = analogRead(p_air_regulated); //12 bit ADC on esp32
float pressure_inhale = analogRead(p_inhale); //12 bit ADC on esp32
float pressure_o2supply = analogRead(p_o2_supply); //12 bit ADC on esp32
float pressure_o2regulated = analogRead(p_o2_regulated); //12 bit ADC on esp32
tempsensor.wake(); //sensor on
float c = tempsensor.readTempC();
tempsensor.shutdown_wake(1); //sensor off
duty_cycle = res/4096.0;
if (duty_cycle > max_duty_cycle){
duty_cycle = max_duty_cycle;
}
//Serial.print("Pot ");
//Serial.print(String((int)res));
//Serial.print(" p_patient ");
//Serial.print(String((int)pressure_patient));
//Serial.print(" p_buffer ");
//Serial.print(String((int)pressure_buffer));
//Serial.print(" p_as ");
//Serial.print(String((int)pressure_asupply));
//Serial.print(" p_ar ");
//Serial.print(String((int)pressure_aregulated));
//Serial.print(" p_inhale ");
//Serial.print(String((int)pressure_inhale));
//Serial.print(" p_o2s ");
//Serial.print(String((int)pressure_o2supply));
//Serial.print(" p_o2r ");
//Serial.print(String((int)pressure_o2regulated));
//Serial.print(" Temp: ");
//Serial.print(c, 4);
//// measuring Valves voltage and current
//Serial.print(" ");
//Serial.print((float)INA.getBusMilliVolts(0)/1000.0,4);
//DEBUG_PRINT("V ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(0)/5,0);
//DEBUG_PRINT("mA ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(1)/5,0);
//DEBUG_PRINT("mA ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(2)/5,0);
//DEBUG_PRINT("mA ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(3)/5,0);
//DEBUG_PRINT("mA ");
if(stop){
ledcWrite(0, 0);//val);// exhale
ledcWrite(1, 0);//val);// exhale
}
else{
duty_cycle = 0.74;
float low_duty_cycle = 0.54;//525;
int nsteps = 1; // number of steps of 10 ms in between
float step_size = (duty_cycle-low_duty_cycle) / nsteps;
int val = (int)(255.0*duty_cycle);
int vallow = (int)(255.0*low_duty_cycle);
//Serial.print(" duty cycle ");
//Serial.println(String(duty_cycle));
//Serial.print(" raw val ");
//Serial.println(String(val));
digitalWrite(greenled, HIGH);
//ledcWrite(0, val);// inhale
ledcWrite(0, vallow);//vallow);// exhale
delay(1000);
for(int i=0; i<nsteps ; i++){
int _val = (int)( 255.0 * ( low_duty_cycle + ( i * step_size ) ) );
ledcWrite(0,_val);
delay(10);
}
ledcWrite(0, val);//val);// exhale
delay(1000);
//ledcWrite(1, 0);// exhale
//digitalWrite(greenled, LOW);
//delay(1000);
}
}
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = uno
[env]
lib_deps =
commsControl
ArduinoQueue
uCRC16Lib
build_flags = -fpermissive -I../common/include/
[env:uno]
platform = atmelavr
framework = arduino
board = uno
[env:mkrvidor4000]
platform = atmelsam
framework = arduino
board = mkrvidor4000
[env:featheresp32]
platform = espressif32
framework = arduino
board = featheresp32
upload_port = /dev/ttyUSB0
[env:due]
platform = atmelsam
framework = arduino
board = due
[env:yun]
platform = atmelavr
framework = arduino
board = yun
[env:mkrwifi1010]
platform = atmelsam
framework = arduino
board = mkrwifi1010
[env:nodemcu-32s]
platform = espressif32
framework = arduino
board = nodemcu-32s
#include "common.h"
void setValves(bool vin, bool vout, bool vscav, bool vpurge)
{
digitalWrite(pin_valve_air_in, vin);
digitalWrite(pin_valve_o2_in, vin);
digitalWrite(pin_valve_inhale, vout);
digitalWrite(pin_valve_exhale, vscav);
digitalWrite(pin_valve_purge, vpurge);
}
#include <Arduino.h>
#if defined(ARDUINO_FEATHER_ESP32)
#define BOARD "HUZZAH32"
#include <huzzah32_pinout.h>
#elif defined(ARDUINO_NodeMCU_32S)
#define BOARD "ESP32"
#include <nodemcu_32s_pinout.h>
#elif defined(ARDUINO_AVR_UNO)
#define BOARD "UNO"
#include <Arduino_uno_pinout.h>
#elif defined(ARDUINO_SAMD_MKRVIDOR4000)
#define BOARD "VIDOR"
#include <Arduino_MKR_4000_Vidor_pinout.h>
#elif defined(ARDUINO_SAMD_MKRWIFI1010)
#define BOARD "MKR1010"
#include <Arduino_MKR_1010_WIFI_pinout.h>
#elif defined(ARDUINO_SAM_DUE)
#define BOARD "MKR1010"
#include <Arduino_Due_pinout.h>
#elif defined(ARDUINO_AVR_YUN)
#define BOARD "MKR1010"
#include <Arduino_Yun_pinout.h>
#endif
// input params
enum hev_modes : byte
{
HEV_MODE_PS,
HEV_MODE_CPAP,
HEV_MODE_PRVC,
HEV_MODE_TEST
};
enum valve_states : bool
{
V_OPEN = LOW,
V_CLOSED = HIGH
};
void setValves(bool vin, bool vout, bool vscav, bool vpurge);
#include <Arduino.h>
#include "test_hw_loop.h"
#include "common.h"
//#include <LiquidCrystal.h>
//LiquidCrystal lcd(pin_lcd_rs, pin_lcd_en, pin_lcd_d4, pin_lcd_d5, pin_lcd_d6, pin_lcd_d7);
int ventilation_mode = HEV_MODE_PS;
float working_pressure = 1; //?
float inspiratory_minute_volume = 6000; // ml/min
float respiratory_rate = 15; // 10-40 +-1 ;aka breaths_per_min
float inspiratory_pressure = 10; // 10-80 cmH2O +-1
//float tidal_volume = 200; // calc 200-1500ml +- 100
float inspiratory_time = 1.0; // 0.4-1.5s +-0.1
float pause_time = 1.0; // range?
//float expiratory_time ; // calc
float expiratory_minute_volume; // calc?? same as inspiratory_minute_volume?
float trigger_sensitivity;
// calculations
float calc_tidal_volume()
{
return inspiratory_minute_volume / respiratory_rate;
}
float calc_expiration_time()
{
float total_respiratory_time = 60.0 / respiratory_rate;
// total = expire + inspire + pause
return (total_respiratory_time - inspiratory_time - pause_time);
}
float calc_expiratory_minute_volume()
{
// probably need to calculate this from readings
return 0;
}
// FROM OVERLEAF DOC
// Working pressure, corresponding to the manually set and monitored input pressure to the unit
// Inspiratory Minute Volume setting
// Breaths per minute setting
// Tidal volume display, based on previous two parameters
// Inspiration time setting
// Pause time setting
// expiration time display based on previous two parameters
// expired minute volume
// Airway pressure display based on the reading of $P_2$ ??? not a setting
// PEEP setting ??? external
// Trigger sensitivity to patient initiated breath
void setup()
{
pinMode(pin_valve_air_in, OUTPUT);
pinMode(pin_valve_o2_in, OUTPUT);
pinMode(pin_valve_inhale, OUTPUT);
pinMode(pin_valve_exhale, OUTPUT);
pinMode(pin_valve_purge, OUTPUT);
pinMode(pin_p_air_supply, INPUT);
pinMode(pin_p_air_regulated, INPUT);
pinMode(pin_p_buffer, INPUT);
pinMode(pin_p_inhale, INPUT);
pinMode(pin_p_patient, INPUT);
pinMode(pin_temp, INPUT);
pinMode(pin_led_0, OUTPUT);
pinMode(pin_led_1, OUTPUT);
pinMode(pin_led_2, OUTPUT);
pinMode(pin_buzzer, OUTPUT);
pinMode(pin_button_0, INPUT);
Serial.begin(9600);
// lcd.begin(16, 2); // Declare number of columns and rows
}
void loop()
{
// put your main code here, to run repeatedly:
//Serial.println(BOARD);
// delay(1000);
// buzzer
// tone(pin, freq (Hz), duration);
//breath_cycle();
FSM_assignment();
FSM_breath_cycle();
delay(10);
}
#include "test_hw_loop.h"
#include "common.h"
/*
The Idea of this code is to unfold the FSM in two: one to assign the transitions and the second one to program the states.
*/
uint64_t FSM_time;
int timeout;
byte lab_cycle_mode = 0;
int bs_state = BS_IDLE;
bool start = LOW;
int next_state;
//This is used to assign the transitions of the fsm
void FSM_assignment( ) {
if (millis() > FSM_time + timeout ) {
switch (bs_state)
{
case BS_IDLE:
if (start == LOW)
{
next_state = BS_BUFF_PREFILL;
FSM_time = millis();
Serial.println("Exit IDLE") ;
}
else
{
next_state = BS_IDLE;
}
break;
case BS_BUFF_PREFILL:
next_state = BS_BUFF_FILL;
break;
case BS_BUFF_FILL:
next_state = BS_BUFF_LOADED;
break;
case BS_BUFF_LOADED:
switch (lab_cycle_mode)
{
case LAB_MODE_FLUSH:
next_state = BS_BUFF_FLUSH;
break;
case LAB_MODE_PURGE:
next_state = BS_BUFF_PURGE;
break;
default:
next_state = BS_BUFF_PRE_INHALE;
}
break;
case BS_BUFF_PRE_INHALE:
next_state = BS_INHALE;
break;
case BS_INHALE:
next_state = BS_PAUSE;
break;
case BS_PAUSE:
next_state = BS_EXHALE_FILL;
break;
case BS_EXHALE_FILL:
next_state = BS_EXHALE;
break;
case BS_EXHALE:
next_state = BS_BUFF_LOADED;
break;
case BS_BUFF_PURGE:
next_state = BS_BUFF_PREFILL;
break;
case BS_BUFF_FLUSH:
next_state = BS_IDLE;
break;
default:
next_state = bs_state;
}
bs_state = next_state;
FSM_time = millis();
}
}
void FSM_breath_cycle()
{
// basic cycle for testing hardware
start = digitalRead(pin_button_0);
switch (bs_state)
{
case BS_IDLE:
if (start == LOW)
{
FSM_time = millis();
}
else
{
timeout = 1000;
}
setValves(V_CLOSED, V_OPEN, V_OPEN, V_CLOSED);
break;
case BS_BUFF_PREFILL:
setValves(V_CLOSED, V_CLOSED, V_OPEN, V_CLOSED);
timeout = 1000;
break;
case BS_BUFF_FILL:
setValves(V_OPEN, V_CLOSED, V_OPEN, V_CLOSED);
timeout = 500;
break;
case BS_BUFF_LOADED:
setValves(V_CLOSED, V_CLOSED, V_OPEN, V_CLOSED);
switch (lab_cycle_mode)
{
case LAB_MODE_FLUSH:
timeout = 500;
break;
case LAB_MODE_PURGE:
timeout =500;
break;
default:
timeout =1500;
}
break;
case BS_BUFF_PRE_INHALE:
setValves(V_CLOSED, V_CLOSED, V_CLOSED, V_CLOSED);
timeout =100;
break;
case BS_INHALE:
setValves(V_CLOSED, V_OPEN, V_CLOSED, V_CLOSED);
timeout =100;
break;
case BS_PAUSE:
setValves(V_CLOSED, V_CLOSED, V_CLOSED, V_CLOSED);
timeout =1000;
break;
case BS_EXHALE_FILL:
setValves(V_OPEN, V_CLOSED, V_OPEN, V_CLOSED);
timeout =1000;
break;
case BS_EXHALE:
setValves(V_CLOSED, V_CLOSED, V_OPEN, V_CLOSED);
timeout =10;
break;
case BS_BUFF_PURGE:
setValves(V_CLOSED, V_CLOSED, V_OPEN, V_OPEN);
timeout =1000;
break;
case BS_BUFF_FLUSH:
setValves(V_CLOSED, V_OPEN, V_OPEN, V_CLOSED);
timeout =1000;
break;
}
Serial.println("state FSM_breath_cycle: " + String(bs_state));
Serial.println("start: " + String(start));
}
#include <Arduino.h>
void FSM_assignment();
void FSM_breath_cycle();
// states
enum BS_STATES : byte
{
BS_IDLE,
BS_BUFF_PREFILL,
BS_BUFF_FILL,
BS_BUFF_LOADED,
BS_BUFF_PRE_INHALE,
BS_INHALE,
BS_PAUSE,
BS_EXHALE_FILL,
BS_EXHALE,
BS_BUFF_PURGE,
BS_BUFF_FLUSH
};
enum lab_cycle_modes : byte
{
LAB_MODE_BREATHE = 0,
LAB_MODE_PURGE = 1,
LAB_MODE_FLUSH = 2
};
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
#include <Arduino.h>
//#include <HardwareSerial.h>
HardwareSerial co2_serial(2); // RX2 = pin IO16, TX2 = pin IO17
// #define RXD2 16
// #define TXD2 17
unsigned char hexdata[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79}; //Read the gas density command /Don't change the order
void setup()
{
Serial.begin(9600);
while (!Serial)
{
delay(1);
}
Serial.println("setup Serial1 ok");
co2_serial.begin(9600);
// Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
// while (!Serial2)
while (!co2_serial)
{
delay(1);
}
Serial.println("setup Serial2 ok");
}
void loop()
{
co2_serial.write(hexdata, 9);
// delay(500);
// Serial2.write(hexdata, 9);
delay(500);
for (int i = 0, j = 0; i < 9; i++) {
if (co2_serial.available() > 0) {
// if (Serial2.available() > 0) {
long hi, lo, CO2;
int ch = co2_serial.read();
// int ch = Serial2.read();
if (i == 2) {
hi = ch;
} //High concentration
if (i == 3) {
lo = ch;
} //Low concentration
if (i == 8) {
CO2 = hi * 256 + lo; //CO2 concentration
Serial.print("CO2 concentration: ");
Serial.print(CO2);
Serial.println("ppm");
}
}
}
}
\ No newline at end of file
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// Arduino Due
#define BOARD "DUE"
#define HEV_FULL_SYSTEM
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// Arduino MKR 1010 Wifi
#define BOARD "MKR1010"
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// arduino MKR 4000 Vidor
#define BOARD "VIDOR"
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// Arduino Nano 33 IOT
#define BOARD "NANO33IOT"
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// Arduino Yun
#define BOARD "YUN"
// pwm pins
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// Arduino Uno
#define BOARD "UNO"
// pwm pins
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// Arduino Uno
#define BOARD "UNO"
// pwm pins
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// ESP32 HUZZAH
#define BOARD "HUZZAH32"
#define CHIP_ESP32
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// Node MCU 32s
#define BOARD "NODEMCU32S"
#define CHIP_ESP32
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef COMMSCONSTANTS_H
#define COMMSCONSTANTS_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "CommsControl.h"
CommsControl::CommsControl(uint32_t baudrate) {
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef COMMS_CONTROL_H
#define COMMS_CONTROL_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "CommsFormat.h"
// constructor to init variables
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef COMMSFORMAT_H
#define COMMSFORMAT_H
......
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
#
#
# Please choose one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#
#
# Template #1: General project. Test it using existing `platformio.ini`.
#
# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be used as a library with examples.
#
# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:featheresp32]
platform = espressif32
framework = arduino
board = featheresp32
upload_port = /dev/ttyUSB0
; [env:nodemcu-32s]
; platform = espressif32
; framework = arduino
; board = nodemcu-32s
#include <Arduino.h>
#include <WiFi.h>
void setup() {
// put your setup code here, to run once:
// Huzzah32
// WiFi.mode(WIFI_MODE_NULL);
WiFi.mode(WIFI_OFF);
btStop();
// ADC2
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A5, INPUT);
pinMode(A12, INPUT);
pinMode(A11, INPUT);
pinMode(A10, INPUT);
pinMode(A8, INPUT);
pinMode(A6, INPUT);
// ADC1
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A9, INPUT);
pinMode(A7, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int aA0 = analogRead(A0);
int aA1 = analogRead(A1);
int aA5 = analogRead(A5);
int aA12 = analogRead(A12);
int aA11 = analogRead(A11);
int aA10 = analogRead(A10);
int aA8 = analogRead(A8);
int aA6 = analogRead(A6);
int aA2 = analogRead(A2);
int aA3 = analogRead(A3);
int aA4 = analogRead(A4);
int aA9 = analogRead(A9);
int aA7 = analogRead(A7);
Serial.println("aA0 "+String(aA0));
Serial.println("aA1 "+String(aA1));
Serial.println("aA5 "+String(aA5));
Serial.println("aA12 "+String(aA12));
Serial.println("aA11 "+String(aA11));
Serial.println("aA10 "+String(aA10));
Serial.println("aA8 "+String(aA8 ));
Serial.println("aA6 "+String(aA6 ));
Serial.println("aA2 "+String(aA2 ));
Serial.println("aA3 "+String(aA3 ));
Serial.println("aA4 "+String(aA4 ));
Serial.println("aA9 "+String(aA9 ));
Serial.println("aA7 "+String(aA7 ));
delay(3000);
}
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
Import("env")
# General options that are passed to the C and C++ compilers
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "AlarmLoop.h"
AlarmLoop::AlarmLoop()
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef ALARM_LOOP_H
#define ALARM_LOOP_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "AudioVisualController.h"
#include "common.h"
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef AUDIOVISUALCONTROLLER_H
#define AUDIOVISUALCONTROLLER_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "BreathingLoop.h"
#include "common.h"
/*
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef BREATHING_LOOP_H
#define BREATHING_LOOP_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef LINEARFITTER_H
#define LINEARFITTER_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
// MemoryFree library based on code posted here:
// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213583720/15
// Extended by Matthew Murdoch to include walking of the free list.
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "SystemUtils.h"
SystemUtils::SystemUtils()
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef SYSTEMUTILS_H
#define SYSTEMUTILS_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "UILoop.h"
UILoop::UILoop(BreathingLoop *bl, AlarmLoop *al, CommsControl *comms)
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef UI_LOOP_H
#define UI_LOOP_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "ValvesController.h"
ValvesController::ValvesController()
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef VALVES_CONTROLLER_H
#define VALVES_CONTROLLER_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include "common.h"
CommsControl* global_comms;
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef COMMON_H
#define COMMON_H
#include <Arduino.h>
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#ifndef LOCALCONF_H
#define LOCALCONF_H
......
// © Copyright CERN, Riga Technical University and University of Liverpool 2020.
// All rights not expressly granted are reserved.
//
// This file is part of hev-sw.
//
// hev-sw is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public Licence as published by the Free
// Software Foundation, either version 3 of the Licence, or (at your option)
// any later version.
//
// hev-sw is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with hev-sw. If not, see <http://www.gnu.org/licenses/>.
//
// The authors would like to acknowledge the much appreciated support
// of all those involved with the High Energy Ventilator project
// (https://hev.web.cern.ch/).
#include <Arduino.h>
#include "common.h"
#ifdef CHIP_ESP32
......
#!/usr/bin/python3
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
# from Oscar's excel sheet
......
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = uno
[env]
lib_deps =
commsControl
5390 ; uCRC16Lib
5418 ; RingBuffer
build_flags = -fpermissive -I../common/include/
lib_extra_dirs = ../common/lib
[env:uno]
platform = atmelavr
framework = arduino
board = uno
[env:mkrvidor4000]
platform = atmelsam
framework = arduino
board = mkrvidor4000
[env:featheresp32]
platform = espressif32
framework = arduino
board = featheresp32
upload_port = /dev/ttyUSB0
[env:due]
platform = atmelsam
framework = arduino
board = due
[env:yun]
platform = atmelavr
framework = arduino
board = yun
;[env:mkrwifi1010]
;platform = atmelsam
;framework = arduino
;board = mkrwifi1010
[env:nodemcu-32s]
platform = espressif32
framework = arduino
board = nodemcu-32s
win32 {
HOMEDIR += $$(USERPROFILE)
}
else {
HOMEDIR += $$(HOME)
}
INCLUDEPATH += "$${_PRO_FILE_PWD_}/include"
INCLUDEPATH += "$${_PRO_FILE_PWD_}/src"
INCLUDEPATH += "$${_PRO_FILE_PWD_}/../common/lib/commsControl"
INCLUDEPATH += "$${_PRO_FILE_PWD_}/.pio/libdeps/uno/uCRC16Lib_ID5390/src"
INCLUDEPATH += "$${_PRO_FILE_PWD_}/.pio/libdeps/uno/RingBuffer_ID5418/src"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduino-avr/cores/arduino"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduino-avr/variants/standard"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduino-avr/libraries/HID/src"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduino-avr/libraries/SPI/src"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduino-avr/libraries/Wire/src"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/toolchain-atmelavr/avr/include"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed"
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/tool-unity"
DEFINES += "PLATFORMIO=40301"
DEFINES += "ARDUINO_AVR_UNO"
DEFINES += "F_CPU=16000000L"
DEFINES += "ARDUINO_ARCH_AVR"
DEFINES += "ARDUINO=10808"
DEFINES += "__AVR_ATmega328P__"
OTHER_FILES += platformio.ini
SOURCES += src/protocol.cpp \
../common/lib/commsControl/commsControl.cpp \
../common/lib/commsControl/commsFormat.cpp
HEADERS += ../common/lib/commsControl/commsConstants.h \
../common/lib/commsControl/commsControl.h \
../common/lib/commsControl/commsFormat.h
#include <Arduino.h>
#include "commsControl.h"
#define LED_BLUE 5
#define LED_GREEN 7
#define LED_RED 3
#define BTN 8
payload plReceive_;
payload plSend_;
commsControl comms_;
dataFormat data_;
alarmFormat alarm_;
int currentState_ = 0;
int previousState_ = 0;
int led_ = 0;
bool blue_ = false;
bool green_ = false;
bool red_ = false;
bool enabled_ = false;
uint32_t lastTime_ = 0;
uint32_t offset_ = 10;
// dirty function to switch one of the LEDs
void switchLED(int led) {
int state = HIGH;
switch (led) {
case LED_BLUE:
if (blue_)
state = LOW;
blue_ = !blue_;
break;
case LED_RED:
if (red_)
state = LOW;
red_ = !red_;
break;
case LED_GREEN:
if (green_)
state = LOW;
green_ = !green_;
break;
}
digitalWrite(led, state);
}
void setup() {
plSend_.setType(payloadType::payloadData);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_RED, OUTPUT);
pinMode(BTN, INPUT);
// initialize comms connection
comms_.beginSerial();
}
void loop() {
// testing increase of values to be sent
// will only increase the count on the button release (reasons)
currentState_ = digitalRead(BTN);
if ( currentState_ != previousState_) {
if (currentState_ != HIGH) {
switchLED(LED_BLUE);
// counter increase on button press
data_.fsm_state += 1;
plSend_.setData(&data_);
// register new data in comms
comms_.writePayload(plSend_);
}
previousState_ = currentState_;
}
if (enabled_ & (millis() > (lastTime_ + offset_)))
{
lastTime_ = millis();
plSend_.getData()->readback_valve_air_in = static_cast<uint8_t>((lastTime_ >> 24) & 0xFF);
plSend_.getData()->readback_valve_o2_in = static_cast<uint8_t>((lastTime_ >> 16) & 0xFF);
plSend_.getData()->readback_valve_inhale = static_cast<uint8_t>((lastTime_ >> 8 ) & 0xFF);
plSend_.getData()->readback_valve_exhale = static_cast<uint8_t>((lastTime_ >> 0 ) & 0xFF);
switchLED(LED_BLUE);
plSend_.setType(payloadType::payloadData);
plSend_.getData()->fsm_state += 1;
comms_.writePayload(plSend_);
}
// per cycle sender
comms_.sender();
// per cycle receiver
int x1, x2, x3 = 0;
comms_.receiver(x1,x2,x3);
if (comms_.readPayload(plReceive_)) {
switch (plReceive_.getType()) {
case payloadType::payloadCmd:
if (plReceive_.getCmd()->cmdCode % 2 == 0) {
enabled_ = false;
} else {
enabled_ = true;
}
offset_ = plReceive_.getCmd()->param;
alarm_.alarmCode = plReceive_.getCmd()->cmdCode;
alarm_.param = millis() & 0xFFFFFFFF;
plSend_.setAlarm(&alarm_);
comms_.writePayload(plSend_);
break;
default:
break;
}
plReceive_.setType(payloadType::payloadUnset);
}
}
#!/usr/bin/env python3
# © Copyright CERN, Riga Technical University and University of Liverpool 2020.
# All rights not expressly granted are reserved.
#
# This file is part of hev-sw.
#
# hev-sw is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public Licence as published by the Free
# Software Foundation, either version 3 of the Licence, or (at your option)
# any later version.
#
# hev-sw is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with hev-sw. If not, see <http://www.gnu.org/licenses/>.
#
# The authors would like to acknowledge the much appreciated support
# of all those involved with the High Energy Ventilator project
# (https://hev.web.cern.ch/).
import asyncio
import logging
......
../raspberry-dataserver/CommsCommon.py
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment