a.binder 5 năm trước cách đây
mục cha
commit
f725ea8517
100 tập tin đã thay đổi với 0 bổ sung12879 xóa
  1. BIN
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/LcdBarGraph.gif
  2. 0 8
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/README.md
  3. 0 24
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/AnalogVisualization/AnalogVisualization.ino
  4. 0 48
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/MoreGraphs/MoreGraphs.ino
  5. 0 50
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/MoreGraphsI2C/MoreGraphsI2C.ino
  6. 0 24
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/PositionVisualization/PositionVisualization.ino
  7. 0 23
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/keywords.txt
  8. 0 9
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/library.properties
  9. 0 171
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/src/LcdBarGraphX.cpp
  10. 0 78
      SE/stuff/P5_Automation-library-dev/LcdBarGraphX/src/LcdBarGraphX.h
  11. 0 315
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/LiquidCrystal_I2C.cpp
  12. 0 126
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/LiquidCrystal_I2C.h
  13. BIN
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/LiquidCrystal_I2C.o
  14. 0 2
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/README.md
  15. 0 70
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/examples/CustomChars/CustomChars.pde
  16. 0 28
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/examples/HelloWorld/HelloWorld.pde
  17. 0 34
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/examples/SerialDisplay/SerialDisplay.pde
  18. 0 46
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/keywords.txt
  19. 0 15
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/library.json
  20. 0 9
      SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/library.properties
  21. 0 751
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/DallasTemperature.cpp
  22. 0 243
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/DallasTemperature.h
  23. 0 53
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/README.TXT
  24. 0 85
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/change.txt
  25. 0 140
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Multiple/Multiple.pde
  26. 0 33
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Simple/Simple.pde
  27. 0 109
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Single/Single.pde
  28. 0 124
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Tester/Tester.pde
  29. 0 54
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/keywords.txt
  30. 0 9
      SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/library.properties
  31. 0 557
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/OneWire.cpp
  32. 0 251
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/OneWire.h
  33. 0 112
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde
  34. 0 77
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/DS2408_Switch/DS2408_Switch.pde
  35. 0 90
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/DS250x_PROM/DS250x_PROM.pde
  36. 0 127
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/MAX31850_Temperature/MAX31850_Temperature.ino
  37. 0 64
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/MAX31850_sample/MAX31850_sample.ino
  38. 0 64
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/sample/sample.pde
  39. 0 38
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/keywords.txt
  40. 0 9
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/library.properties
  41. 0 32
      SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/readme.txt
  42. BIN
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/MCP2515Calc.xlsx
  43. 0 39
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/README.md
  44. 0 88
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_loopback/CAN_loopback.ino
  45. 0 62
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_receive/CAN_receive.ino
  46. 0 36
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_send/CAN_send.ino
  47. 0 59
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_to_Ethernet/CAN_to_Ethernet.ino
  48. 0 19
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_to_Ethernet/udp_listen.pl
  49. 0 55
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/Dual_CAN/Dual_CAN.ino
  50. 0 87
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/Extended_MaskFilter/Extended_MaskFilter.ino
  51. 0 1046
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/OBD_Sim/OBD_Sim.ino
  52. 0 94
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/Standard_MaskFilter/Standard_MaskFilter.ino
  53. 0 60
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/keywords.txt
  54. 0 1308
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/mcp_can.cpp
  55. 0 143
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/mcp_can.h
  56. 0 476
      SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/mcp_can_dfs.h
  57. 0 508
      SE/stuff/P5_Automation-library-dev/MobaTools/LICENSE
  58. BIN
      SE/stuff/P5_Automation-library-dev/MobaTools/MobaTools-09 -en.pdf
  59. BIN
      SE/stuff/P5_Automation-library-dev/MobaTools/MobaTools-09.pdf
  60. 0 27
      SE/stuff/P5_Automation-library-dev/MobaTools/README.md
  61. 0 56
      SE/stuff/P5_Automation-library-dev/MobaTools/examples/Servo_01/Servo_01.ino
  62. 0 60
      SE/stuff/P5_Automation-library-dev/MobaTools/examples/Servo_02/Servo_02.ino
  63. 0 27
      SE/stuff/P5_Automation-library-dev/MobaTools/examples/SoftLed_01/SoftLed_01.ino
  64. 0 41
      SE/stuff/P5_Automation-library-dev/MobaTools/examples/Stepper_01/Stepper_01.ino
  65. 0 90
      SE/stuff/P5_Automation-library-dev/MobaTools/examples/Wechselblinker/Wechselblinker.ino
  66. 0 57
      SE/stuff/P5_Automation-library-dev/MobaTools/examples/Zeitgeber_01/Zeitgeber_01.ino
  67. 0 79
      SE/stuff/P5_Automation-library-dev/MobaTools/keywords.txt
  68. 0 9
      SE/stuff/P5_Automation-library-dev/MobaTools/library.properties
  69. 0 1620
      SE/stuff/P5_Automation-library-dev/MobaTools/src/MobaTools.cpp
  70. 0 374
      SE/stuff/P5_Automation-library-dev/MobaTools/src/MobaTools.h
  71. 0 21
      SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/LICENSE
  72. 0 41
      SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/README.md
  73. 0 15
      SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/examples/simple_scale/simple_scale.ino
  74. 0 20
      SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/keywords.txt
  75. 0 9
      SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/library.properties
  76. 0 53
      SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/src/Q2HX711.cpp
  77. 0 19
      SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/src/Q2HX711.h
  78. 0 22
      SE/stuff/P5_Automation-library-dev/Scheduler/README.adoc
  79. 0 81
      SE/stuff/P5_Automation-library-dev/Scheduler/examples/MultipleBlinks/MultipleBlinks.ino
  80. 0 20
      SE/stuff/P5_Automation-library-dev/Scheduler/keywords.txt
  81. 0 9
      SE/stuff/P5_Automation-library-dev/Scheduler/library.properties
  82. 0 208
      SE/stuff/P5_Automation-library-dev/Scheduler/src/Scheduler.cpp
  83. 0 40
      SE/stuff/P5_Automation-library-dev/Scheduler/src/Scheduler.h
  84. 0 21
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/LICENSE
  85. 0 207
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/MedianFilter.cpp
  86. 0 67
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/MedianFilter.h
  87. 0 100
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/README.md
  88. 0 167
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/SharpDistSensor.cpp
  89. 0 146
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/SharpDistSensor.h
  90. 0 75
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorArray/SharpDistSensorArray.ino
  91. 0 64
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorBasic/SharpDistSensorBasic.ino
  92. 0 62
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorByModel/SharpDistSensorByModel.ino
  93. 0 89
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorCustomPoly/SharpDistSensorCustomPoly.ino
  94. 0 83
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorCustomPower/SharpDistSensorCustomPower.ino
  95. 0 10
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/keywords.txt
  96. 0 9
      SE/stuff/P5_Automation-library-dev/SharpDistSensor/library.properties
  97. 0 55
      SE/stuff/P5_Automation-library-dev/SharpIR/CHANGELOG.md
  98. 0 427
      SE/stuff/P5_Automation-library-dev/SharpIR/LICENSE.md
  99. 0 70
      SE/stuff/P5_Automation-library-dev/SharpIR/README.md
  100. 0 47
      SE/stuff/P5_Automation-library-dev/SharpIR/examples/getDistance/getDistance.ino

BIN
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/LcdBarGraph.gif


+ 0 - 8
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/README.md

@@ -1,8 +0,0 @@
-LcdBarGraphX
-============
-
-LcdBarGraph is an Arduino library to draw bar graph on a Liquid Chrystal display. This LcdBarGraphX is a fork of the original project to be driven by the "F. Malpartida" version LCD lib (aka. LiquidCrystal_I2C)
-
-See page http://playground.arduino.cc/Code/LcdBarGraph for details.
-
-See details about the I2C supported liquid chrystal library here: https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

+ 0 - 24
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/AnalogVisualization/AnalogVisualization.ino

@@ -1,24 +0,0 @@
-#include <LiquidCrystal.h>
-#include <LcdBarGraphX.h>
-
-byte lcdNumCols = 16; // -- number of columns in the LCD
-byte sensorPin = 0; // -- value for this example
-
-LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // -- creating LCD instance
-LcdBarGraphX lbg(&lcd, lcdNumCols);  // -- creating
-
-void setup(){
-  // -- initializing the LCD
-  lcd.begin(2, lcdNumCols);
-  lcd.clear();
-  // -- do some delay: some time I've got broken visualization
-  delay(100);
-}
-
-void loop()
-{
-  // -- draw bar graph from the analog value readed
-  lbg.drawValue( analogRead(sensorPin), 1024);
-  // -- do some delay: frequent draw may cause broken visualization
-  delay(100);
-}

+ 0 - 48
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/MoreGraphs/MoreGraphs.ino

@@ -1,48 +0,0 @@
-#include <LiquidCrystal.h>
-#include <LcdBarGraphX.h>
-
-byte lcdNumCols = 16; // -- number of columns in the LCD
-
-LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // -- creating LCD instance
-// -- creating a 4 chars wide bars
-LcdBarGraphX lbg0(&lcd, 4, 0, 0); // -- First line at column 0
-LcdBarGraphX lbg1(&lcd, 4, 5, 0); // -- First line at column 5
-LcdBarGraphX lbg2(&lcd, 4, 10, 0); // -- First line at column 10
-LcdBarGraphX lbg3(&lcd, 4, 0, 1); // -- Second line at column 0
-LcdBarGraphX lbg4(&lcd, 4, 5, 1);  // -- Second line at column 5
-LcdBarGraphX lbg5(&lcd, 4, 10, 1); // -- Second line at column 0
-
-byte i0 = 0;
-byte i1 = 0;
-byte i2 = 0;
-byte i3 = 0;
-byte i4 = 0;
-byte i5 = 0;
-
-void setup(){
-  // -- initializing the LCD
-  lcd.begin(2, lcdNumCols);
-  lcd.clear();
-  // -- do some delay: some time I've got broken visualization
-  delay(100);
-}
-
-void loop()
-{
-  // -- draw bar graph from the analog value readed
-  lbg0.drawValue( i0, 255);
-  lbg1.drawValue( i1, 255);
-  lbg2.drawValue( i2, 255);
-  lbg3.drawValue( i3, 255);
-  lbg4.drawValue( i4, 255);
-  lbg5.drawValue( i5, 255);
-  // -- do some delay: frequent draw may cause broken visualization
-  delay(100);
-  
-  i0 += 5;
-  i1 += 7;
-  i2 += 9;
-  i3 += 11;
-  i4 += 13;
-  i5 += 15;
-}

+ 0 - 50
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/MoreGraphsI2C/MoreGraphsI2C.ino

@@ -1,50 +0,0 @@
-#include <Wire.h>
-#include <LiquidCrystal_I2C.h>
-#include <LcdBarGraphX.h>
-
-byte lcdNumCols = 20; // -- number of columns in the LCD
-
-LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);   // -- creating LCD instance
-
-// -- creating a 4 chars wide bars
-LcdBarGraphX lbg0(&lcd, 4, 0, 0); // -- First line at column 0
-LcdBarGraphX lbg1(&lcd, 4, 5, 0); // -- First line at column 5
-LcdBarGraphX lbg2(&lcd, 4, 10, 0); // -- First line at column 10
-LcdBarGraphX lbg3(&lcd, 4, 0, 1); // -- Second line at column 0
-LcdBarGraphX lbg4(&lcd, 4, 5, 1);  // -- Second line at column 5
-LcdBarGraphX lbg5(&lcd, 4, 10, 1); // -- Second line at column 0
-
-byte i0 = 0;
-byte i1 = 0;
-byte i2 = 0;
-byte i3 = 0;
-byte i4 = 0;
-byte i5 = 0;
-
-void setup(){
-  // -- initializing the LCD
-  lcd.begin(4, lcdNumCols);
-  lcd.clear();
-  // -- do some delay: some time I've got broken visualization
-  delay(100);
-}
-
-void loop()
-{
-  // -- draw bar graph from the analog value readed
-  lbg0.drawValue( i0, 255);
-  lbg1.drawValue( i1, 255);
-  lbg2.drawValue( i2, 255);
-  lbg3.drawValue( i3, 255);
-  lbg4.drawValue( i4, 255);
-  lbg5.drawValue( i5, 255);
-  // -- do some delay: frequent draw may cause broken visualization
-  delay(100);
-  
-  i0 += 5;
-  i1 += 7;
-  i2 += 9;
-  i3 += 11;
-  i4 += 13;
-  i5 += 15;
-}

+ 0 - 24
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/examples/PositionVisualization/PositionVisualization.ino

@@ -1,24 +0,0 @@
-#include <LiquidCrystal.h>
-#include <LcdBarGraphX.h>
-
-byte lcdNumCols = 16; // -- number of columns in the LCD
-byte sensorPin = 0; // -- value for this example
-
-LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // -- creating LCD instance
-LcdBarGraphX lbg(&lcd, 4, 12, 1);  // -- creating a 4 char wide baraph in the end of second column (column 1)
-
-void setup(){
-  // -- initializing the LCD
-  lcd.begin(2, lcdNumCols);
-  lcd.clear();
-  // -- do some delay: some time I've got broken visualization
-  delay(100);
-}
-
-void loop()
-{
-  // -- draw bar graph from the analog value readed
-  lbg.drawValue( analogRead(sensorPin), 1024);
-  // -- do some delay: frequent draw may cause broken visualization
-  delay(100);
-}

+ 0 - 23
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/keywords.txt

@@ -1,23 +0,0 @@
-#######################################
-# Syntax Coloring Map For LEDs
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-
-LcdBarGraphX	KEYWORD1
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-drawValue	KEYWORD2
-begin	KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-
-
-

+ 0 - 9
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/library.properties

@@ -1,9 +0,0 @@
-name=LcdBarGraphX
-version=2.0.1
-author=Balazs Kelemen <prampec+arduino@gmail.com>
-maintainer=Balazs Kelemen <prampec+arduino@gmail.com>
-sentence=Visualizing alanalog values on an LCD with the LiquidCrystal_I2C library.
-paragraph=LcdBarGraph is an Arduino library to draw bar graph on a Liquid Chrystal display. This LcdBarGraphX is a fork of the original project to be driven by the "F. Malpartida" version LCD lib (aka. LiquidCrystal_I2C) instead of the bound one.
-category=Display
-url=https://github.com/prampec/LcdBarGraphX
-architectures=*

+ 0 - 171
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/src/LcdBarGraphX.cpp

@@ -1,171 +0,0 @@
-/**
- * File: LcdBarGraphX.cpp
- * Description:
- * LcdBarGraphX is an Arduino library for displaying analog values in LCD display, 
- *   which is previously initialized. This library uses LCD library (https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home) for displaying.
- *
- * Author: Balazs Kelemen
- * Contact: prampec+arduino@gmail.com
- * Copyright: 2010 Balazs Kelemen
- * Credits: Hans van Neck
- * Copying permission statement:
-    This file is part of LcdBarGraphX.
-
-    LcdBarGraphX is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program 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 License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "Arduino.h"
-#include "LcdBarGraphX.h"
-
-
-// -- initializing bar segment characters
-#ifndef USE_BUILDIN_FILLED_CHAR
-// -- filled character
-byte LcdBarGraphX::_level0[8] = {
-    B11111,
-    B11111,
-    B11111,
-    B11111,
-    B11111,
-    B11111,
-    B11111,
-    B11111
-};
-#endif
-
-// -- character with one bar
-byte LcdBarGraphX::_level1[8] = {
-    B10000,
-    B10000,
-    B10000,
-    B10000,
-    B10000,
-    B10000,
-    B10000,
-    B10000
-};
-// -- character with two bars
-byte LcdBarGraphX::_level2[8] = {
-    B11000,
-    B11000,
-    B11000,
-    B11000,
-    B11000,
-    B11000,
-    B11000,
-    B11000
-};
-// -- character with three bars
-byte LcdBarGraphX::_level3[8] = {
-    B11100,
-    B11100,
-    B11100,
-    B11100,
-    B11100,
-    B11100,
-    B11100,
-    B11100
-};
-// -- character with four bars
-byte LcdBarGraphX::_level4[8] = {
-    B11110,
-    B11110,
-    B11110,
-    B11110,
-    B11110,
-    B11110,
-    B11110,
-    B11110
-};
-
-// -- constructor
-LcdBarGraphX::LcdBarGraphX(LCD* lcd, byte numCols, byte startX, byte startY)
-{
-    // -- setting fields
-    _lcd = lcd;
-    _numCols = numCols;
-    _startX = startX;
-	_startY = startY;
-}
-
-void LcdBarGraphX::begin()
-{
-    // -- creating characters
-#ifndef USE_BUILDIN_FILLED_CHAR
-    _lcd->createChar(0, this->_level0);
-#endif
-    _lcd->createChar(1, this->_level1);
-    _lcd->createChar(2, this->_level2);
-    _lcd->createChar(3, this->_level3);
-    _lcd->createChar(4, this->_level4);
-    _lcd->clear(); // put lcd back into DDRAM mode
-    // -- setting initial values
-    this->_prevValue = 0; // -- cached value
-    this->_lastFullChars = 0; // -- cached value
-	this->_initialized = true;
-}
-
-// -- the draw function
-void LcdBarGraphX::drawValue(int value, int maxValue) {
-	if(!this->_initialized) {
-		this->begin();
-	}
-    // -- calculate full (filled) character count
-    byte fullChars = (long)value * _numCols / maxValue;
-    // -- calculate partial character bar count
-    byte mod = ((long)value * _numCols * 5 / maxValue) % 5;
-
-    // -- if value does not change, do not draw anything
-    int normalizedValue = (int)fullChars * 5 + mod;
-    if(this->_prevValue != normalizedValue) {
-        // -- do not clear the display to eliminate flickers
-        _lcd->setCursor(_startX, _startY);
-        
-        // -- write filled characters
-        for(byte i=0; i<fullChars; i++) {
-#ifdef USE_BUILDIN_FILLED_CHAR
-            _lcd->write((byte)USE_BUILDIN_FILLED_CHAR);  // -- use build in filled char
-#else
-            _lcd->write((byte)0);
-#endif
-        }
-        
-        // -- write the partial character
-        if(mod > 0) {
-            _lcd->write(mod); // -- index the right partial character
-            ++fullChars;
-        }
-        
-        // -- clear characters left over the previous draw
-        for(byte i=fullChars;i<this->_lastFullChars;i++) {
-            _lcd->write(' ');
-        }
-        
-        // -- save cache
-        this->_lastFullChars = fullChars;
-        this->_prevValue = normalizedValue;
-    }
-    /*
-    // debug info
-    _lcd->setCursor(0,1);
-    _lcd->write('[');
-    _lcd->print((int)value);
-    _lcd->write(' ');
-    _lcd->print(normalizedValue);
-    _lcd->write(' ');
-    _lcd->print((int)mod);
-    _lcd->write(']');
-    */
-}

+ 0 - 78
SE/stuff/P5_Automation-library-dev/LcdBarGraphX/src/LcdBarGraphX.h

@@ -1,78 +0,0 @@
-/**
- * File: LcdBarGraphX.h
- * Description:
- * LcdBarGraphX is an Arduino library for displaying analog values in LCD display, 
- *   which is previously initialized. This library uses LCD library (https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home) for displaying.
- *
- * Author: Balazs Kelemen
- * Contact: prampec+arduino@gmail.com
- * Copyright: 2010 Balazs Kelemen
- * Credits: Hans van Neck
- * Copying permission statement:
-    This file is part of LcdBarGraphX.
-
-    LcdBarGraphX is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program 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 License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef LCDBARGRAPH_H
-#define LCDBARGRAPH_H
-
-#include <LCD.h>
-
-#include "Arduino.h"
-
-#define USE_BUILDIN_FILLED_CHAR  0xFF // -- Char 0xFF is usualy a filled character. Uncomment if you want the library to create the filled char at the expense of 26 bytes.
-
-class LcdBarGraphX
-{
-public:
-    /**
-     * Create an instance of the class. The bar will be drawn in the startY row 
-	 * of the LCD, from the startX column positon (inclusive) to to the startX+numCols column position
-	 * (inclusive).
-	 * lcd - A LiquidCristal instance should be passed.
-	 * numCols - Width of the bar.
-	 * startX - Horzontal starting position (column) of the bar. Zero based value.
-	 * startY - Vertical starting position (row) of the bar. Zero based value.
-     */
-    LcdBarGraphX(LCD* lcd, byte numCols, byte startX = 0, byte startY = 0);
-    /**
-     * Draw a bargraph with a value between 0 and maxValue.
-     */
-    void drawValue(int value, int maxvalue);
-   /**
-    * Initializes the display.
-    */
-   void begin();
-	
-private:
-    LCD* _lcd;
-    byte _numCols;
-    byte _startX;
-    byte _startY;
-    int _prevValue;
-    byte _lastFullChars;
-	boolean _initialized = false;
-
-#ifndef USE_BUILDIN_FILLED_CHAR
-    static byte _level0[8];
-#endif
-    static byte _level1[8];
-    static byte _level2[8];
-    static byte _level3[8];
-    static byte _level4[8];
-};
-
-#endif

+ 0 - 315
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/LiquidCrystal_I2C.cpp

@@ -1,315 +0,0 @@
-// Based on the work by DFRobot
-
-#include "LiquidCrystal_I2C.h"
-#include <inttypes.h>
-#if defined(ARDUINO) && ARDUINO >= 100
-
-#include "Arduino.h"
-
-#define printIIC(args)	Wire.write(args)
-inline size_t LiquidCrystal_I2C::write(uint8_t value) {
-	send(value, Rs);
-	return 1;
-}
-
-#else
-#include "WProgram.h"
-
-#define printIIC(args)	Wire.send(args)
-inline void LiquidCrystal_I2C::write(uint8_t value) {
-	send(value, Rs);
-}
-
-#endif
-#include "Wire.h"
-
-
-
-// When the display powers up, it is configured as follows:
-//
-// 1. Display clear
-// 2. Function set: 
-//    DL = 1; 8-bit interface data 
-//    N = 0; 1-line display 
-//    F = 0; 5x8 dot character font 
-// 3. Display on/off control: 
-//    D = 0; Display off 
-//    C = 0; Cursor off 
-//    B = 0; Blinking off 
-// 4. Entry mode set: 
-//    I/D = 1; Increment by 1
-//    S = 0; No shift 
-//
-// Note, however, that resetting the Arduino doesn't reset the LCD, so we
-// can't assume that its in that state when a sketch starts (and the
-// LiquidCrystal constructor is called).
-
-LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows)
-{
-  _Addr = lcd_Addr;
-  _cols = lcd_cols;
-  _rows = lcd_rows;
-  _backlightval = LCD_NOBACKLIGHT;
-}
-
-void LiquidCrystal_I2C::init(){
-	init_priv();
-}
-
-void LiquidCrystal_I2C::init_priv()
-{
-	Wire.begin();
-	_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
-	begin(_cols, _rows);  
-}
-
-void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
-	if (lines > 1) {
-		_displayfunction |= LCD_2LINE;
-	}
-	_numlines = lines;
-
-	// for some 1 line displays you can select a 10 pixel high font
-	if ((dotsize != 0) && (lines == 1)) {
-		_displayfunction |= LCD_5x10DOTS;
-	}
-
-	// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
-	// according to datasheet, we need at least 40ms after power rises above 2.7V
-	// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
-	delay(50); 
-  
-	// Now we pull both RS and R/W low to begin commands
-	expanderWrite(_backlightval);	// reset expanderand turn backlight off (Bit 8 =1)
-	delay(1000);
-
-  	//put the LCD into 4 bit mode
-	// this is according to the hitachi HD44780 datasheet
-	// figure 24, pg 46
-	
-	  // we start in 8bit mode, try to set 4 bit mode
-   write4bits(0x03 << 4);
-   delayMicroseconds(4500); // wait min 4.1ms
-   
-   // second try
-   write4bits(0x03 << 4);
-   delayMicroseconds(4500); // wait min 4.1ms
-   
-   // third go!
-   write4bits(0x03 << 4); 
-   delayMicroseconds(150);
-   
-   // finally, set to 4-bit interface
-   write4bits(0x02 << 4); 
-
-
-	// set # lines, font size, etc.
-	command(LCD_FUNCTIONSET | _displayfunction);  
-	
-	// turn the display on with no cursor or blinking default
-	_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
-	display();
-	
-	// clear it off
-	clear();
-	
-	// Initialize to default text direction (for roman languages)
-	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
-	
-	// set the entry mode
-	command(LCD_ENTRYMODESET | _displaymode);
-	
-	home();
-  
-}
-
-/********** high level commands, for the user! */
-void LiquidCrystal_I2C::clear(){
-	command(LCD_CLEARDISPLAY);// clear display, set cursor position to zero
-	delayMicroseconds(2000);  // this command takes a long time!
-}
-
-void LiquidCrystal_I2C::home(){
-	command(LCD_RETURNHOME);  // set cursor position to zero
-	delayMicroseconds(2000);  // this command takes a long time!
-}
-
-void LiquidCrystal_I2C::setCursor(uint8_t col, uint8_t row){
-	int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
-	if ( row > _numlines ) {
-		row = _numlines-1;    // we count rows starting w/0
-	}
-	command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
-}
-
-// Turn the display on/off (quickly)
-void LiquidCrystal_I2C::noDisplay() {
-	_displaycontrol &= ~LCD_DISPLAYON;
-	command(LCD_DISPLAYCONTROL | _displaycontrol);
-}
-void LiquidCrystal_I2C::display() {
-	_displaycontrol |= LCD_DISPLAYON;
-	command(LCD_DISPLAYCONTROL | _displaycontrol);
-}
-
-// Turns the underline cursor on/off
-void LiquidCrystal_I2C::noCursor() {
-	_displaycontrol &= ~LCD_CURSORON;
-	command(LCD_DISPLAYCONTROL | _displaycontrol);
-}
-void LiquidCrystal_I2C::cursor() {
-	_displaycontrol |= LCD_CURSORON;
-	command(LCD_DISPLAYCONTROL | _displaycontrol);
-}
-
-// Turn on and off the blinking cursor
-void LiquidCrystal_I2C::noBlink() {
-	_displaycontrol &= ~LCD_BLINKON;
-	command(LCD_DISPLAYCONTROL | _displaycontrol);
-}
-void LiquidCrystal_I2C::blink() {
-	_displaycontrol |= LCD_BLINKON;
-	command(LCD_DISPLAYCONTROL | _displaycontrol);
-}
-
-// These commands scroll the display without changing the RAM
-void LiquidCrystal_I2C::scrollDisplayLeft(void) {
-	command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
-}
-void LiquidCrystal_I2C::scrollDisplayRight(void) {
-	command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
-}
-
-// This is for text that flows Left to Right
-void LiquidCrystal_I2C::leftToRight(void) {
-	_displaymode |= LCD_ENTRYLEFT;
-	command(LCD_ENTRYMODESET | _displaymode);
-}
-
-// This is for text that flows Right to Left
-void LiquidCrystal_I2C::rightToLeft(void) {
-	_displaymode &= ~LCD_ENTRYLEFT;
-	command(LCD_ENTRYMODESET | _displaymode);
-}
-
-// This will 'right justify' text from the cursor
-void LiquidCrystal_I2C::autoscroll(void) {
-	_displaymode |= LCD_ENTRYSHIFTINCREMENT;
-	command(LCD_ENTRYMODESET | _displaymode);
-}
-
-// This will 'left justify' text from the cursor
-void LiquidCrystal_I2C::noAutoscroll(void) {
-	_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
-	command(LCD_ENTRYMODESET | _displaymode);
-}
-
-// Allows us to fill the first 8 CGRAM locations
-// with custom characters
-void LiquidCrystal_I2C::createChar(uint8_t location, uint8_t charmap[]) {
-	location &= 0x7; // we only have 8 locations 0-7
-	command(LCD_SETCGRAMADDR | (location << 3));
-	for (int i=0; i<8; i++) {
-		write(charmap[i]);
-	}
-}
-
-// Turn the (optional) backlight off/on
-void LiquidCrystal_I2C::noBacklight(void) {
-	_backlightval=LCD_NOBACKLIGHT;
-	expanderWrite(0);
-}
-
-void LiquidCrystal_I2C::backlight(void) {
-	_backlightval=LCD_BACKLIGHT;
-	expanderWrite(0);
-}
-
-
-
-/*********** mid level commands, for sending data/cmds */
-
-inline void LiquidCrystal_I2C::command(uint8_t value) {
-	send(value, 0);
-}
-
-
-/************ low level data pushing commands **********/
-
-// write either command or data
-void LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) {
-	uint8_t highnib=value&0xf0;
-	uint8_t lownib=(value<<4)&0xf0;
-       write4bits((highnib)|mode);
-	write4bits((lownib)|mode); 
-}
-
-void LiquidCrystal_I2C::write4bits(uint8_t value) {
-	expanderWrite(value);
-	pulseEnable(value);
-}
-
-void LiquidCrystal_I2C::expanderWrite(uint8_t _data){                                        
-	Wire.beginTransmission(_Addr);
-	printIIC((int)(_data) | _backlightval);
-	Wire.endTransmission();   
-}
-
-void LiquidCrystal_I2C::pulseEnable(uint8_t _data){
-	expanderWrite(_data | En);	// En high
-	delayMicroseconds(1);		// enable pulse must be >450ns
-	
-	expanderWrite(_data & ~En);	// En low
-	delayMicroseconds(50);		// commands need > 37us to settle
-} 
-
-
-// Alias functions
-
-void LiquidCrystal_I2C::cursor_on(){
-	cursor();
-}
-
-void LiquidCrystal_I2C::cursor_off(){
-	noCursor();
-}
-
-void LiquidCrystal_I2C::blink_on(){
-	blink();
-}
-
-void LiquidCrystal_I2C::blink_off(){
-	noBlink();
-}
-
-void LiquidCrystal_I2C::load_custom_character(uint8_t char_num, uint8_t *rows){
-		createChar(char_num, rows);
-}
-
-void LiquidCrystal_I2C::setBacklight(uint8_t new_val){
-	if(new_val){
-		backlight();		// turn backlight on
-	}else{
-		noBacklight();		// turn backlight off
-	}
-}
-
-void LiquidCrystal_I2C::printstr(const char c[]){
-	//This function is not identical to the function used for "real" I2C displays
-	//it's here so the user sketch doesn't have to be changed 
-	print(c);
-}
-
-
-// unsupported API functions
-void LiquidCrystal_I2C::off(){}
-void LiquidCrystal_I2C::on(){}
-void LiquidCrystal_I2C::setDelay (int cmdDelay,int charDelay) {}
-uint8_t LiquidCrystal_I2C::status(){return 0;}
-uint8_t LiquidCrystal_I2C::keypad (){return 0;}
-uint8_t LiquidCrystal_I2C::init_bargraph(uint8_t graphtype){return 0;}
-void LiquidCrystal_I2C::draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len,  uint8_t pixel_col_end){}
-void LiquidCrystal_I2C::draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len,  uint8_t pixel_row_end){}
-void LiquidCrystal_I2C::setContrast(uint8_t new_val){}
-
-	

+ 0 - 126
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/LiquidCrystal_I2C.h

@@ -1,126 +0,0 @@
-//YWROBOT
-#ifndef LiquidCrystal_I2C_h
-#define LiquidCrystal_I2C_h
-
-#include <inttypes.h>
-#include "Print.h" 
-#include <Wire.h>
-
-// commands
-#define LCD_CLEARDISPLAY 0x01
-#define LCD_RETURNHOME 0x02
-#define LCD_ENTRYMODESET 0x04
-#define LCD_DISPLAYCONTROL 0x08
-#define LCD_CURSORSHIFT 0x10
-#define LCD_FUNCTIONSET 0x20
-#define LCD_SETCGRAMADDR 0x40
-#define LCD_SETDDRAMADDR 0x80
-
-// flags for display entry mode
-#define LCD_ENTRYRIGHT 0x00
-#define LCD_ENTRYLEFT 0x02
-#define LCD_ENTRYSHIFTINCREMENT 0x01
-#define LCD_ENTRYSHIFTDECREMENT 0x00
-
-// flags for display on/off control
-#define LCD_DISPLAYON 0x04
-#define LCD_DISPLAYOFF 0x00
-#define LCD_CURSORON 0x02
-#define LCD_CURSOROFF 0x00
-#define LCD_BLINKON 0x01
-#define LCD_BLINKOFF 0x00
-
-// flags for display/cursor shift
-#define LCD_DISPLAYMOVE 0x08
-#define LCD_CURSORMOVE 0x00
-#define LCD_MOVERIGHT 0x04
-#define LCD_MOVELEFT 0x00
-
-// flags for function set
-#define LCD_8BITMODE 0x10
-#define LCD_4BITMODE 0x00
-#define LCD_2LINE 0x08
-#define LCD_1LINE 0x00
-#define LCD_5x10DOTS 0x04
-#define LCD_5x8DOTS 0x00
-
-// flags for backlight control
-#define LCD_BACKLIGHT 0x08
-#define LCD_NOBACKLIGHT 0x00
-
-#define En B00000100  // Enable bit
-#define Rw B00000010  // Read/Write bit
-#define Rs B00000001  // Register select bit
-
-class LiquidCrystal_I2C : public Print {
-public:
-  LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows);
-  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS );
-  void clear();
-  void home();
-  void noDisplay();
-  void display();
-  void noBlink();
-  void blink();
-  void noCursor();
-  void cursor();
-  void scrollDisplayLeft();
-  void scrollDisplayRight();
-  void printLeft();
-  void printRight();
-  void leftToRight();
-  void rightToLeft();
-  void shiftIncrement();
-  void shiftDecrement();
-  void noBacklight();
-  void backlight();
-  void autoscroll();
-  void noAutoscroll(); 
-  void createChar(uint8_t, uint8_t[]);
-  void setCursor(uint8_t, uint8_t); 
-#if defined(ARDUINO) && ARDUINO >= 100
-  virtual size_t write(uint8_t);
-#else
-  virtual void write(uint8_t);
-#endif
-  void command(uint8_t);
-  void init();
-
-////compatibility API function aliases
-void blink_on();						// alias for blink()
-void blink_off();       					// alias for noBlink()
-void cursor_on();      	 					// alias for cursor()
-void cursor_off();      					// alias for noCursor()
-void setBacklight(uint8_t new_val);				// alias for backlight() and nobacklight()
-void load_custom_character(uint8_t char_num, uint8_t *rows);	// alias for createChar()
-void printstr(const char[]);
-
-////Unsupported API functions (not implemented in this library)
-uint8_t status();
-void setContrast(uint8_t new_val);
-uint8_t keypad();
-void setDelay(int,int);
-void on();
-void off();
-uint8_t init_bargraph(uint8_t graphtype);
-void draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len,  uint8_t pixel_col_end);
-void draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len,  uint8_t pixel_col_end);
-	 
-
-private:
-  void init_priv();
-  void send(uint8_t, uint8_t);
-  void write4bits(uint8_t);
-  void expanderWrite(uint8_t);
-  void pulseEnable(uint8_t);
-  uint8_t _Addr;
-  uint8_t _displayfunction;
-  uint8_t _displaycontrol;
-  uint8_t _displaymode;
-  uint8_t _numlines;
-  uint8_t _cols;
-  uint8_t _rows;
-  uint8_t _backlightval;
-};
-
-#endif

BIN
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/LiquidCrystal_I2C.o


+ 0 - 2
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/README.md

@@ -1,2 +0,0 @@
-# LiquidCrystal_I2C
-LiquidCrystal Arduino library for the DFRobot I2C LCD displays

+ 0 - 70
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/examples/CustomChars/CustomChars.pde

@@ -1,70 +0,0 @@
-//YWROBOT
-//Compatible with the Arduino IDE 1.0
-//Library version:1.1
-#include <Wire.h>
-#include <LiquidCrystal_I2C.h>
-
-#if defined(ARDUINO) && ARDUINO >= 100
-#define printByte(args)  write(args);
-#else
-#define printByte(args)  print(args,BYTE);
-#endif
-
-uint8_t bell[8]  = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
-uint8_t note[8]  = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
-uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
-uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
-uint8_t duck[8]  = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
-uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
-uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
-uint8_t retarrow[8] = {	0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
-  
-LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
-
-void setup()
-{
-  lcd.init();                      // initialize the lcd 
-  lcd.backlight();
-  
-  lcd.createChar(0, bell);
-  lcd.createChar(1, note);
-  lcd.createChar(2, clock);
-  lcd.createChar(3, heart);
-  lcd.createChar(4, duck);
-  lcd.createChar(5, check);
-  lcd.createChar(6, cross);
-  lcd.createChar(7, retarrow);
-  lcd.home();
-  
-  lcd.print("Hello world...");
-  lcd.setCursor(0, 1);
-  lcd.print(" i ");
-  lcd.printByte(3);
-  lcd.print(" arduinos!");
-  delay(5000);
-  displayKeyCodes();
-  
-}
-
-// display all keycodes
-void displayKeyCodes(void) {
-  uint8_t i = 0;
-  while (1) {
-    lcd.clear();
-    lcd.print("Codes 0x"); lcd.print(i, HEX);
-    lcd.print("-0x"); lcd.print(i+16, HEX);
-    lcd.setCursor(0, 1);
-    for (int j=0; j<16; j++) {
-      lcd.printByte(i+j);
-    }
-    i+=16;
-    
-    delay(4000);
-  }
-}
-
-void loop()
-{
-
-}
-

+ 0 - 28
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/examples/HelloWorld/HelloWorld.pde

@@ -1,28 +0,0 @@
-//YWROBOT
-//Compatible with the Arduino IDE 1.0
-//Library version:1.1
-#include <Wire.h> 
-#include <LiquidCrystal_I2C.h>
-
-LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
-
-void setup()
-{
-  lcd.init();                      // initialize the lcd 
-  lcd.init();
-  // Print a message to the LCD.
-  lcd.backlight();
-  lcd.setCursor(3,0);
-  lcd.print("Hello, world!");
-  lcd.setCursor(2,1);
-  lcd.print("Ywrobot Arduino!");
-   lcd.setCursor(0,2);
-  lcd.print("Arduino LCM IIC 2004");
-   lcd.setCursor(2,3);
-  lcd.print("Power By Ec-yuan!");
-}
-
-
-void loop()
-{
-}

+ 0 - 34
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/examples/SerialDisplay/SerialDisplay.pde

@@ -1,34 +0,0 @@
-/*
- * Displays text sent over the serial port (e.g. from the Serial Monitor) on
- * an attached LCD.
- * YWROBOT
- *Compatible with the Arduino IDE 1.0
- *Library version:1.1
- */
-#include <Wire.h> 
-#include <LiquidCrystal_I2C.h>
-
-LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
-
-void setup()
-{
-  lcd.init();                      // initialize the lcd 
-  lcd.backlight();
-  Serial.begin(9600);
-}
-
-void loop()
-{
-  // when characters arrive over the serial port...
-  if (Serial.available()) {
-    // wait a bit for the entire message to arrive
-    delay(100);
-    // clear the screen
-    lcd.clear();
-    // read all the available characters
-    while (Serial.available() > 0) {
-      // display each character to the LCD
-      lcd.write(Serial.read());
-    }
-  }
-}

+ 0 - 46
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/keywords.txt

@@ -1,46 +0,0 @@
-###########################################
-# Syntax Coloring Map For LiquidCrystal_I2C
-###########################################
-
-###########################################
-# Datatypes (KEYWORD1)
-###########################################
-
-LiquidCrystal_I2C	KEYWORD1
-
-###########################################
-# Methods and Functions (KEYWORD2)
-###########################################
-init	KEYWORD2
-begin	KEYWORD2
-clear	KEYWORD2
-home	KEYWORD2
-noDisplay	KEYWORD2
-display	KEYWORD2
-noBlink	KEYWORD2
-blink	KEYWORD2
-noCursor	KEYWORD2
-cursor	KEYWORD2
-scrollDisplayLeft	KEYWORD2
-scrollDisplayRight	KEYWORD2
-leftToRight	KEYWORD2
-rightToLeft	KEYWORD2
-shiftIncrement	KEYWORD2
-shiftDecrement	KEYWORD2
-noBacklight	KEYWORD2
-backlight	KEYWORD2
-autoscroll	KEYWORD2
-noAutoscroll	KEYWORD2
-createChar	KEYWORD2
-setCursor	KEYWORD2
-print	KEYWORD2
-blink_on	KEYWORD2
-blink_off	KEYWORD2
-cursor_on	KEYWORD2
-cursor_off	KEYWORD2
-setBacklight	KEYWORD2
-load_custom_character	KEYWORD2
-printstr	KEYWORD2
-###########################################
-# Constants (LITERAL1)
-###########################################

+ 0 - 15
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/library.json

@@ -1,15 +0,0 @@
-{
-  "name": "LiquidCrystal_I2C",
-  "keywords": "LCD, liquidcrystal, I2C",
-  "description": "A library for DFRobot I2C LCD displays",
-  "repository":
-  {
-    "type": "git",
-    "url": "https://github.com/marcoschwartz/LiquidCrystal_I2C.git"
-  },
-  "frameworks": "arduino",
-  "platforms":
-  [
-    "atmelavr"
-  ]
-}

+ 0 - 9
SE/stuff/P5_Automation-library-dev/LiquidCrystal_I2C/library.properties

@@ -1,9 +0,0 @@
-name=LiquidCrystal I2C
-version=1.1.2
-author=Frank de Brabander
-maintainer=Marco Schwartz <marcolivier.schwartz@gmail.com>
-sentence=A library for I2C LCD displays.
-paragraph= The library allows to control I2C displays with functions extremely similar to LiquidCrystal library. THIS LIBRARY MIGHT NOT BE COMPATIBLE WITH EXISTING SKETCHES.
-category=Display
-url=https://github.com/marcoschwartz/LiquidCrystal_I2C
-architectures=avr

+ 0 - 751
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/DallasTemperature.cpp

@@ -1,751 +0,0 @@
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-
-// Version 3.7.2 modified on Dec 6, 2011 to support Arduino 1.0
-// See Includes...
-// Modified by Jordan Hochenbaum
-
-#include "DallasTemperature.h"
-
-#if ARDUINO >= 100
-    #include "Arduino.h"   
-#else
-extern "C" {
-    #include "WConstants.h"
-}
-#endif
-
-DallasTemperature::DallasTemperature(OneWire* _oneWire)
-  #if REQUIRESALARMS
-  : _AlarmHandler(&defaultAlarmHandler)
-  #endif
-{
-  _wire = _oneWire;
-  devices = 0;
-  parasite = false;
-  bitResolution = 9;
-  waitForConversion = true;
-  checkForConversion = true;
-}
-
-// initialise the bus
-void DallasTemperature::begin(void)
-{
-  DeviceAddress deviceAddress;
-
-  _wire->reset_search();
-  devices = 0; // Reset the number of devices when we enumerate wire devices
-
-  while (_wire->search(deviceAddress))
-  {
-    if (validAddress(deviceAddress))
-    {
-      if (!parasite && readPowerSupply(deviceAddress)) parasite = true;
-
-      ScratchPad scratchPad;
-
-      readScratchPad(deviceAddress, scratchPad);
-
-	  bitResolution = max(bitResolution, getResolution(deviceAddress));
-
-      devices++;
-    }
-  }
-}
-
-// returns the number of devices found on the bus
-uint8_t DallasTemperature::getDeviceCount(void)
-{
-  return devices;
-}
-
-// returns true if address is valid
-bool DallasTemperature::validAddress(uint8_t* deviceAddress)
-{
-  return (_wire->crc8(deviceAddress, 7) == deviceAddress[7]);
-}
-
-// finds an address at a given index on the bus
-// returns true if the device was found
-bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index)
-{
-  uint8_t depth = 0;
-
-  _wire->reset_search();
-
-  while (depth <= index && _wire->search(deviceAddress))
-  {
-    if (depth == index && validAddress(deviceAddress)) return true;
-    depth++;
-  }
-
-  return false;
-}
-
-// attempt to determine if the device at the given address is connected to the bus
-bool DallasTemperature::isConnected(uint8_t* deviceAddress)
-{
-  ScratchPad scratchPad;
-  return isConnected(deviceAddress, scratchPad);
-}
-
-// attempt to determine if the device at the given address is connected to the bus
-// also allows for updating the read scratchpad
-bool DallasTemperature::isConnected(uint8_t* deviceAddress, uint8_t* scratchPad)
-{
-  readScratchPad(deviceAddress, scratchPad);
-  return (_wire->crc8(scratchPad, 8) == scratchPad[SCRATCHPAD_CRC]);
-}
-
-// read device's scratch pad
-void DallasTemperature::readScratchPad(uint8_t* deviceAddress, uint8_t* scratchPad)
-{
-  // send the command
-  _wire->reset();
-  _wire->select(deviceAddress);
-  _wire->write(READSCRATCH);
-
-  // TODO => collect all comments &  use simple loop
-  // byte 0: temperature LSB  
-  // byte 1: temperature MSB
-  // byte 2: high alarm temp
-  // byte 3: low alarm temp
-  // byte 4: DS18S20: store for crc
-  //         DS18B20 & DS1822: configuration register
-  // byte 5: internal use & crc
-  // byte 6: DS18S20: COUNT_REMAIN
-  //         DS18B20 & DS1822: store for crc
-  // byte 7: DS18S20: COUNT_PER_C
-  //         DS18B20 & DS1822: store for crc
-  // byte 8: SCRATCHPAD_CRC
-  //
-  // for(int i=0; i<9; i++)
-  // {
-  //   scratchPad[i] = _wire->read();
-  // }
-
-  
-  // read the response
-
-  // byte 0: temperature LSB
-  scratchPad[TEMP_LSB] = _wire->read();
-
-  // byte 1: temperature MSB
-  scratchPad[TEMP_MSB] = _wire->read();
-
-  // byte 2: high alarm temp
-  scratchPad[HIGH_ALARM_TEMP] = _wire->read();
-
-  // byte 3: low alarm temp
-  scratchPad[LOW_ALARM_TEMP] = _wire->read();
-
-  // byte 4:
-  // DS18S20: store for crc
-  // DS18B20 & DS1822: configuration register
-  scratchPad[CONFIGURATION] = _wire->read();
-
-  // byte 5:
-  // internal use & crc
-  scratchPad[INTERNAL_BYTE] = _wire->read();
-
-  // byte 6:
-  // DS18S20: COUNT_REMAIN
-  // DS18B20 & DS1822: store for crc
-  scratchPad[COUNT_REMAIN] = _wire->read();
-
-  // byte 7:
-  // DS18S20: COUNT_PER_C
-  // DS18B20 & DS1822: store for crc
-  scratchPad[COUNT_PER_C] = _wire->read();
-
-  // byte 8:
-  // SCTRACHPAD_CRC
-  scratchPad[SCRATCHPAD_CRC] = _wire->read();
-
-  for (uint8_t i=0; i<8; i++) {
-    //Serial.print("\n 0x"); Serial.print(scratchPad[i], HEX);
-  }
-  _wire->reset();
-}
-
-// writes device's scratch pad
-void DallasTemperature::writeScratchPad(uint8_t* deviceAddress, const uint8_t* scratchPad)
-{
-  _wire->reset();
-  _wire->select(deviceAddress);
-  _wire->write(WRITESCRATCH);
-  _wire->write(scratchPad[HIGH_ALARM_TEMP]); // high alarm temp
-  _wire->write(scratchPad[LOW_ALARM_TEMP]); // low alarm temp
-  // DS18S20 does not use the configuration register
-  if (deviceAddress[0] != DS18S20MODEL) _wire->write(scratchPad[CONFIGURATION]); // configuration
-  _wire->reset();
-  // save the newly written values to eeprom
-  _wire->write(COPYSCRATCH, parasite);
-  if (parasite) delay(10); // 10ms delay
-  _wire->reset();
-}
-
-// reads the device's power requirements
-bool DallasTemperature::readPowerSupply(uint8_t* deviceAddress)
-{
-  bool ret = false;
-  _wire->reset();
-  _wire->select(deviceAddress);
-  _wire->write(READPOWERSUPPLY);
-  if (_wire->read_bit() == 0) ret = true;
-  _wire->reset();
-  return ret;
-}
-
-
-// set resolution of all devices to 9, 10, 11, or 12 bits
-// if new resolution is out of range, it is constrained.
-void DallasTemperature::setResolution(uint8_t newResolution)
-{
-  bitResolution = constrain(newResolution, 9, 12);
-  DeviceAddress deviceAddress;
-  for (int i=0; i<devices; i++)
-  {
-    getAddress(deviceAddress, i);
-	setResolution(deviceAddress, bitResolution);
-  }
-}
-
-// set resolution of a device to 9, 10, 11, or 12 bits
-// if new resolution is out of range, 9 bits is used. 
-bool DallasTemperature::setResolution(uint8_t* deviceAddress, uint8_t newResolution)
-{
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad))
-  {
-    // DS18S20 has a fixed 9-bit resolution
-    if (deviceAddress[0] != DS18S20MODEL)
-    {
-      switch (newResolution)
-      {
-        case 12:
-          scratchPad[CONFIGURATION] = TEMP_12_BIT;
-          break;
-        case 11:
-          scratchPad[CONFIGURATION] = TEMP_11_BIT;
-          break;
-        case 10:
-          scratchPad[CONFIGURATION] = TEMP_10_BIT;
-          break;
-        case 9:
-        default:
-          scratchPad[CONFIGURATION] = TEMP_9_BIT;
-          break;
-      }
-      writeScratchPad(deviceAddress, scratchPad);
-    }
-	return true;  // new value set
-  }
-  return false;
-}
-
-// returns the global resolution
-uint8_t DallasTemperature::getResolution()
-{
-	return bitResolution;
-}
-
-// returns the current resolution of the device, 9-12
-// returns 0 if device not found
-uint8_t DallasTemperature::getResolution(uint8_t* deviceAddress)
-{
-  if (deviceAddress[0] == DS18S20MODEL) return 9; // this model has a fixed resolution
-
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad))
-  {
-    switch (scratchPad[CONFIGURATION])
-    {
-      case TEMP_12_BIT:
-        return 12;
-        
-      case TEMP_11_BIT:
-        return 11;
-        
-      case TEMP_10_BIT:
-        return 10;
-        
-      case TEMP_9_BIT:
-        return 9;
-        
-     }
-    // special exception for MAX31850
-    if ((scratchPad[CONFIGURATION] & 0xF0) == 0xF0) 
-      return 12;
-  }
-  return 0;
-}
-
-
-// sets the value of the waitForConversion flag
-// TRUE : function requestTemperature() etc returns when conversion is ready
-// FALSE: function requestTemperature() etc returns immediately (USE WITH CARE!!)
-// 		  (1) programmer has to check if the needed delay has passed 
-//        (2) but the application can do meaningful things in that time
-void DallasTemperature::setWaitForConversion(bool flag)
-{
-	waitForConversion = flag;
-}
-
-// gets the value of the waitForConversion flag
-bool DallasTemperature::getWaitForConversion()
-{
-	return waitForConversion;
-}
-
-
-// sets the value of the checkForConversion flag
-// TRUE : function requestTemperature() etc will 'listen' to an IC to determine whether a conversion is complete
-// FALSE: function requestTemperature() etc will wait a set time (worst case scenario) for a conversion to complete
-void DallasTemperature::setCheckForConversion(bool flag)
-{
-	checkForConversion = flag;
-}
-
-// gets the value of the waitForConversion flag
-bool DallasTemperature::getCheckForConversion()
-{
-	return checkForConversion;
-}
-
-bool DallasTemperature::isConversionAvailable(uint8_t* deviceAddress)
-{
-	// Check if the clock has been raised indicating the conversion is complete
-  	ScratchPad scratchPad;
-  	readScratchPad(deviceAddress, scratchPad);
-	return scratchPad[0];
-}	
-
-
-// sends command for all devices on the bus to perform a temperature conversion
-void DallasTemperature::requestTemperatures()
-{
-  _wire->reset();
-  _wire->skip();
-  _wire->write(STARTCONVO, parasite);
-
-  // ASYNC mode?
-  if (!waitForConversion) return; 
-  blockTillConversionComplete(&bitResolution, 0);
-
-  return;
-}
-
-// sends command for one device to perform a temperature by address
-// returns FALSE if device is disconnected
-// returns TRUE  otherwise
-bool DallasTemperature::requestTemperaturesByAddress(uint8_t* deviceAddress)
-{
-
-  _wire->reset();
-  _wire->select(deviceAddress);
-  _wire->write(STARTCONVO, parasite);
-  
-    // check device
-  ScratchPad scratchPad;
-  if (!isConnected(deviceAddress, scratchPad)) return false;
-  
-  
-  // ASYNC mode?
-  if (!waitForConversion) return true;   
-  uint8_t bitResolution = getResolution(deviceAddress);
-  blockTillConversionComplete(&bitResolution, deviceAddress);
-  
-  return true;
-}
-
-
-void DallasTemperature::blockTillConversionComplete(uint8_t* bitResolution, uint8_t* deviceAddress)
-{
-	if(deviceAddress != 0 && checkForConversion && !parasite)
-	{
-	  	// Continue to check if the IC has responded with a temperature
-	  	// NB: Could cause issues with multiple devices (one device may respond faster)
-	  	unsigned long start = millis();
-		while(!isConversionAvailable(0) && ((millis() - start) < 750));	
-	}
-	
-  	// Wait a fix number of cycles till conversion is complete (based on IC datasheet)
-	  switch (*bitResolution)
-	  {
-	    case 9:
-	      delay(94);
-	      break;
-	    case 10:
-	      delay(188);
-	      break;
-	    case 11:
-	      delay(375);
-	      break;
-	    case 12:
-	    default:
-	      delay(750);
-	      break;
-	  }
-
-}
-
-// sends command for one device to perform a temp conversion by index
-bool DallasTemperature::requestTemperaturesByIndex(uint8_t deviceIndex)
-{
-  DeviceAddress deviceAddress;
-  getAddress(deviceAddress, deviceIndex);
-  return requestTemperaturesByAddress(deviceAddress);
-}
-
-// Fetch temperature for device index
-float DallasTemperature::getTempCByIndex(uint8_t deviceIndex)
-{
-  DeviceAddress deviceAddress;
-  getAddress(deviceAddress, deviceIndex);
-  return getTempC((uint8_t*)deviceAddress);
-}
-
-// Fetch temperature for device index
-float DallasTemperature::getTempFByIndex(uint8_t deviceIndex)
-{
-  return toFahrenheit(getTempCByIndex(deviceIndex));
-}
-
-// reads scratchpad and returns the temperature in degrees C
-float DallasTemperature::calculateTemperature(uint8_t* deviceAddress, uint8_t* scratchPad)
-{
-  int16_t rawTemperature = (((int16_t)scratchPad[TEMP_MSB]) << 8) | scratchPad[TEMP_LSB];
-
-  switch (deviceAddress[0])
-  {
-    case MAX31850MODEL:
-      if (scratchPad[0] & 0x1) {
-	return NAN;
-      } else {
-	return (float)rawTemperature * 0.0625;
-      }
-      break;
-    case DS18B20MODEL:
-    case DS1822MODEL:
-      switch (scratchPad[CONFIGURATION])
-      {
-        case TEMP_12_BIT:
-          return (float)rawTemperature * 0.0625;
-          break;
-        case TEMP_11_BIT:
-          return (float)(rawTemperature >> 1) * 0.125;
-          break;
-        case TEMP_10_BIT:
-          return (float)(rawTemperature >> 2) * 0.25;
-          break;
-        case TEMP_9_BIT:
-          return (float)(rawTemperature >> 3) * 0.5;
-          break;
-      }
-      break;
-    case DS18S20MODEL:
-      /*
-
-      Resolutions greater than 9 bits can be calculated using the data from
-      the temperature, COUNT REMAIN and COUNT PER �C registers in the
-      scratchpad. Note that the COUNT PER �C register is hard-wired to 16
-      (10h). After reading the scratchpad, the TEMP_READ value is obtained
-      by truncating the 0.5�C bit (bit 0) from the temperature data. The
-      extended resolution temperature can then be calculated using the
-      following equation:
-
-                                       COUNT_PER_C - COUNT_REMAIN
-      TEMPERATURE = TEMP_READ - 0.25 + --------------------------
-                                               COUNT_PER_C
-      */
-
-      // Good spot. Thanks Nic Johns for your contribution
-      return (float)(rawTemperature >> 1) - 0.25 +((float)(scratchPad[COUNT_PER_C] - scratchPad[COUNT_REMAIN]) / (float)scratchPad[COUNT_PER_C] );
-      break;
-  }
-}
-
-// returns temperature in degrees C or DEVICE_DISCONNECTED if the
-// device's scratch pad cannot be read successfully.
-// the numeric value of DEVICE_DISCONNECTED is defined in
-// DallasTemperature.h. It is a large negative number outside the
-// operating range of the device
-float DallasTemperature::getTempC(uint8_t* deviceAddress)
-{
-  // TODO: Multiple devices (up to 64) on the same bus may take 
-  //       some time to negotiate a response
-  // What happens in case of collision?
-
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad)) return calculateTemperature(deviceAddress, scratchPad);
-  return DEVICE_DISCONNECTED;
-}
-
-// returns temperature in degrees F
-// TODO: - when getTempC returns DEVICE_DISCONNECTED 
-//        -127 gets converted to -196.6 F
-float DallasTemperature::getTempF(uint8_t* deviceAddress)
-{
-  return toFahrenheit(getTempC(deviceAddress));
-}
-
-// returns true if the bus requires parasite power
-bool DallasTemperature::isParasitePowerMode(void)
-{
-  return parasite;
-}
-
-#if REQUIRESALARMS
-
-/*
-
-ALARMS:
-
-TH and TL Register Format
-
-BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0
-  S    2^6   2^5   2^4   2^3   2^2   2^1   2^0
-
-Only bits 11 through 4 of the temperature register are used
-in the TH and TL comparison since TH and TL are 8-bit
-registers. If the measured temperature is lower than or equal
-to TL or higher than or equal to TH, an alarm condition exists
-and an alarm flag is set inside the DS18B20. This flag is
-updated after every temperature measurement; therefore, if the
-alarm condition goes away, the flag will be turned off after
-the next temperature conversion.
-
-*/
-
-// sets the high alarm temperature for a device in degrees celsius
-// accepts a float, but the alarm resolution will ignore anything
-// after a decimal point.  valid range is -55C - 125C
-void DallasTemperature::setHighAlarmTemp(uint8_t* deviceAddress, char celsius)
-{
-  // make sure the alarm temperature is within the device's range
-  if (celsius > 125) celsius = 125;
-  else if (celsius < -55) celsius = -55;
-
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad))
-  {
-    scratchPad[HIGH_ALARM_TEMP] = (uint8_t)celsius;
-    writeScratchPad(deviceAddress, scratchPad);
-  }
-}
-
-// sets the low alarm temperature for a device in degreed celsius
-// accepts a float, but the alarm resolution will ignore anything
-// after a decimal point.  valid range is -55C - 125C
-void DallasTemperature::setLowAlarmTemp(uint8_t* deviceAddress, char celsius)
-{
-  // make sure the alarm temperature is within the device's range
-  if (celsius > 125) celsius = 125;
-  else if (celsius < -55) celsius = -55;
-
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad))
-  {
-    scratchPad[LOW_ALARM_TEMP] = (uint8_t)celsius;
-    writeScratchPad(deviceAddress, scratchPad);
-  }
-}
-
-// returns a char with the current high alarm temperature or
-// DEVICE_DISCONNECTED for an address
-char DallasTemperature::getHighAlarmTemp(uint8_t* deviceAddress)
-{
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[HIGH_ALARM_TEMP];
-  return DEVICE_DISCONNECTED;
-}
-
-// returns a char with the current low alarm temperature or
-// DEVICE_DISCONNECTED for an address
-char DallasTemperature::getLowAlarmTemp(uint8_t* deviceAddress)
-{
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[LOW_ALARM_TEMP];
-  return DEVICE_DISCONNECTED;
-}
-
-// resets internal variables used for the alarm search
-void DallasTemperature::resetAlarmSearch()
-{
-  alarmSearchJunction = -1;
-  alarmSearchExhausted = 0;
-  for(uint8_t i = 0; i < 7; i++)
-    alarmSearchAddress[i] = 0;
-}
-
-// This is a modified version of the OneWire::search method.
-//
-// Also added the OneWire search fix documented here:
-// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295
-//
-// Perform an alarm search. If this function returns a '1' then it has
-// enumerated the next device and you may retrieve the ROM from the
-// OneWire::address variable. If there are no devices, no further
-// devices, or something horrible happens in the middle of the
-// enumeration then a 0 is returned.  If a new device is found then
-// its address is copied to newAddr.  Use
-// DallasTemperature::resetAlarmSearch() to start over.
-bool DallasTemperature::alarmSearch(uint8_t* newAddr)
-{
-  uint8_t i;
-  char lastJunction = -1;
-  uint8_t done = 1;
-
-  if (alarmSearchExhausted) return false;
-  if (!_wire->reset()) return false;
-
-  // send the alarm search command
-  _wire->write(0xEC, 0);
-
-  for(i = 0; i < 64; i++)
-  {
-    uint8_t a = _wire->read_bit( );
-    uint8_t nota = _wire->read_bit( );
-    uint8_t ibyte = i / 8;
-    uint8_t ibit = 1 << (i & 7);
-
-    // I don't think this should happen, this means nothing responded, but maybe if
-    // something vanishes during the search it will come up.
-    if (a && nota) return false;
-
-    if (!a && !nota)
-    {
-      if (i == alarmSearchJunction)
-      {
-        // this is our time to decide differently, we went zero last time, go one.
-        a = 1;
-        alarmSearchJunction = lastJunction;
-      }
-      else if (i < alarmSearchJunction)
-      {
-        // take whatever we took last time, look in address
-        if (alarmSearchAddress[ibyte] & ibit) a = 1;
-        else
-        {
-          // Only 0s count as pending junctions, we've already exhasuted the 0 side of 1s
-          a = 0;
-          done = 0;
-          lastJunction = i;
-        }
-      }
-      else
-      {
-        // we are blazing new tree, take the 0
-        a = 0;
-        alarmSearchJunction = i;
-        done = 0;
-      }
-      // OneWire search fix
-      // See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295
-    }
-
-    if (a) alarmSearchAddress[ibyte] |= ibit;
-    else alarmSearchAddress[ibyte] &= ~ibit;
-
-    _wire->write_bit(a);
-  }
-
-  if (done) alarmSearchExhausted = 1;
-  for (i = 0; i < 8; i++) newAddr[i] = alarmSearchAddress[i];
-  return true;
-}
-
-// returns true if device address has an alarm condition
-// TODO: can this be done with only TEMP_MSB REGISTER (faster)
-//       if ((char) scratchPad[TEMP_MSB] <= (char) scratchPad[LOW_ALARM_TEMP]) return true;
-//       if ((char) scratchPad[TEMP_MSB] >= (char) scratchPad[HIGH_ALARM_TEMP]) return true;
-bool DallasTemperature::hasAlarm(uint8_t* deviceAddress)
-{
-  ScratchPad scratchPad;
-  if (isConnected(deviceAddress, scratchPad))
-  {
-    float temp = calculateTemperature(deviceAddress, scratchPad);
-
-    // check low alarm
-    if ((char)temp <= (char)scratchPad[LOW_ALARM_TEMP]) return true;
-
-    // check high alarm
-    if ((char)temp >= (char)scratchPad[HIGH_ALARM_TEMP]) return true;
-  }
-
-  // no alarm
-  return false;
-}
-
-// returns true if any device is reporting an alarm condition on the bus
-bool DallasTemperature::hasAlarm(void)
-{
-  DeviceAddress deviceAddress;
-  resetAlarmSearch();
-  return alarmSearch(deviceAddress);
-}
-
-// runs the alarm handler for all devices returned by alarmSearch()
-void DallasTemperature::processAlarms(void)
-{
-  resetAlarmSearch();
-  DeviceAddress alarmAddr;
-
-  while (alarmSearch(alarmAddr))
-  {
-    if (validAddress(alarmAddr))
-      _AlarmHandler(alarmAddr);
-  }
-}
-
-// sets the alarm handler
-void DallasTemperature::setAlarmHandler(AlarmHandler *handler)
-{
-  _AlarmHandler = handler;
-}
-
-// The default alarm handler
-void DallasTemperature::defaultAlarmHandler(uint8_t* deviceAddress)
-{
-}
-
-#endif
-
-// Convert float celsius to fahrenheit
-float DallasTemperature::toFahrenheit(float celsius)
-{
-  return (celsius * 1.8) + 32;
-}
-
-// Convert float fahrenheit to celsius
-float DallasTemperature::toCelsius(float fahrenheit)
-{
-  return (fahrenheit - 32) / 1.8;
-}
-
-#if REQUIRESNEW
-
-// MnetCS - Allocates memory for DallasTemperature. Allows us to instance a new object
-void* DallasTemperature::operator new(unsigned int size) // Implicit NSS obj size
-{
-  void * p; // void pointer
-  p = malloc(size); // Allocate memory
-  memset((DallasTemperature*)p,0,size); // Initalise memory
-
-  //!!! CANT EXPLICITLY CALL CONSTRUCTOR - workaround by using an init() methodR - workaround by using an init() method
-  return (DallasTemperature*) p; // Cast blank region to NSS pointer
-}
-
-// MnetCS 2009 -  Unallocates the memory used by this instance
-void DallasTemperature::operator delete(void* p)
-{
-  DallasTemperature* pNss =  (DallasTemperature*) p; // Cast to NSS pointer
-  pNss->~DallasTemperature(); // Destruct the object
-
-  free(p); // Free the memory
-}
-
-#endif

+ 0 - 243
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/DallasTemperature.h

@@ -1,243 +0,0 @@
-#ifndef DallasTemperature_h
-#define DallasTemperature_h
-
-#define DALLASTEMPLIBVERSION "3.7.2"
-
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-
-// set to true to include code for new and delete operators
-#ifndef REQUIRESNEW
-#define REQUIRESNEW false
-#endif
-
-// set to true to include code implementing alarm search functions
-#ifndef REQUIRESALARMS
-#define REQUIRESALARMS true
-#endif
-
-#include <inttypes.h>
-#include <OneWire.h>
-
-// Model IDs
-#define DS18S20MODEL 0x10
-#define DS18B20MODEL 0x28
-#define DS1822MODEL  0x22
-#define MAX31850MODEL 0x3B
-
-// OneWire commands
-#define STARTCONVO      0x44  // Tells device to take a temperature reading and put it on the scratchpad
-#define COPYSCRATCH     0x48  // Copy EEPROM
-#define READSCRATCH     0xBE  // Read EEPROM
-#define WRITESCRATCH    0x4E  // Write to EEPROM
-#define RECALLSCRATCH   0xB8  // Reload from last known
-#define READPOWERSUPPLY 0xB4  // Determine if device needs parasite power
-#define ALARMSEARCH     0xEC  // Query bus for devices with an alarm condition
-
-// Scratchpad locations
-#define TEMP_LSB        0
-#define TEMP_MSB        1
-#define HIGH_ALARM_TEMP 2
-#define LOW_ALARM_TEMP  3
-#define CONFIGURATION   4
-#define INTERNAL_BYTE   5
-#define COUNT_REMAIN    6
-#define COUNT_PER_C     7
-#define SCRATCHPAD_CRC  8
-
-// Device resolution
-#define TEMP_9_BIT  0x1F //  9 bit
-#define TEMP_10_BIT 0x3F // 10 bit
-#define TEMP_11_BIT 0x5F // 11 bit
-#define TEMP_12_BIT 0x7F // 12 bit
-
-// Error Codes
-#define DEVICE_DISCONNECTED -127
-
-typedef uint8_t DeviceAddress[8];
-
-class DallasTemperature
-{
-  public:
-
-  DallasTemperature(OneWire*);
-
-  // initalise bus
-  void begin(void);
-
-  // returns the number of devices found on the bus
-  uint8_t getDeviceCount(void);
-  
-  // Is a conversion complete on the wire?
-  bool isConversionComplete(void);
-  
-  // returns true if address is valid
-  bool validAddress(uint8_t*);
-
-  // finds an address at a given index on the bus 
-  bool getAddress(uint8_t*, const uint8_t);
-  
-  // attempt to determine if the device at the given address is connected to the bus
-  bool isConnected(uint8_t*);
-
-  // attempt to determine if the device at the given address is connected to the bus
-  // also allows for updating the read scratchpad
-  bool isConnected(uint8_t*, uint8_t*);
-
-  // read device's scratchpad
-  void readScratchPad(uint8_t*, uint8_t*);
-
-  // write device's scratchpad
-  void writeScratchPad(uint8_t*, const uint8_t*);
-
-  // read device's power requirements
-  bool readPowerSupply(uint8_t*);
-
-  // get global resolution
-  uint8_t getResolution();
-  
-  // set global resolution to 9, 10, 11, or 12 bits
-  void setResolution(uint8_t);
-
-  // returns the device resolution, 9-12
-  uint8_t getResolution(uint8_t*);
-
-  // set resolution of a device to 9, 10, 11, or 12 bits
-  bool setResolution(uint8_t*, uint8_t);
-  
-  // sets/gets the waitForConversion flag
-  void setWaitForConversion(bool);
-  bool getWaitForConversion(void);
-  
-  // sets/gets the checkForConversion flag
-  void setCheckForConversion(bool);
-  bool getCheckForConversion(void);
-  
-  // sends command for all devices on the bus to perform a temperature conversion 
-  void requestTemperatures(void);
-   
-  // sends command for one device to perform a temperature conversion by address
-  bool requestTemperaturesByAddress(uint8_t*);
-
-  // sends command for one device to perform a temperature conversion by index
-  bool requestTemperaturesByIndex(uint8_t);
-
-  // returns temperature in degrees C
-  float getTempC(uint8_t*);
-
-  // returns temperature in degrees F
-  float getTempF(uint8_t*);
-
-  // Get temperature for device index (slow)
-  float getTempCByIndex(uint8_t);
-  
-  // Get temperature for device index (slow)
-  float getTempFByIndex(uint8_t);
-  
-  // returns true if the bus requires parasite power
-  bool isParasitePowerMode(void);
-  
-  bool isConversionAvailable(uint8_t*);
-
-  #if REQUIRESALARMS
-  
-  typedef void AlarmHandler(uint8_t*);
-
-  // sets the high alarm temperature for a device
-  // accepts a char.  valid range is -55C - 125C
-  void setHighAlarmTemp(uint8_t*, const char);
-
-  // sets the low alarm temperature for a device
-  // accepts a char.  valid range is -55C - 125C
-  void setLowAlarmTemp(uint8_t*, const char);
-
-  // returns a signed char with the current high alarm temperature for a device
-  // in the range -55C - 125C
-  char getHighAlarmTemp(uint8_t*);
-
-  // returns a signed char with the current low alarm temperature for a device
-  // in the range -55C - 125C
-  char getLowAlarmTemp(uint8_t*);
-  
-  // resets internal variables used for the alarm search
-  void resetAlarmSearch(void);
-
-  // search the wire for devices with active alarms
-  bool alarmSearch(uint8_t*);
-
-  // returns true if ia specific device has an alarm
-  bool hasAlarm(uint8_t*);
-
-  // returns true if any device is reporting an alarm on the bus
-  bool hasAlarm(void);
-
-  // runs the alarm handler for all devices returned by alarmSearch()
-  void processAlarms(void);
-  
-  // sets the alarm handler
-  void setAlarmHandler(AlarmHandler *);
-  
-  // The default alarm handler
-  static void defaultAlarmHandler(uint8_t*);
-
-  #endif
-
-  // convert from celcius to farenheit
-  static float toFahrenheit(const float);
-
-  // convert from farenheit to celsius
-  static float toCelsius(const float);
-
-  #if REQUIRESNEW
-
-  // initalize memory area
-  void* operator new (unsigned int);
-
-  // delete memory reference
-  void operator delete(void*);
-  
-  #endif
-
-  private:
-  typedef uint8_t ScratchPad[9];
-  
-  // parasite power on or off
-  bool parasite;
-
-  // used to determine the delay amount needed to allow for the
-  // temperature conversion to take place
-  uint8_t bitResolution;
-  
-  // used to requestTemperature with or without delay
-  bool waitForConversion;
-  
-  // used to requestTemperature to dynamically check if a conversion is complete
-  bool checkForConversion;
-  
-  // count of devices on the bus
-  uint8_t devices;
-  
-  // Take a pointer to one wire instance
-  OneWire* _wire;
-
-  // reads scratchpad and returns the temperature in degrees C
-  float calculateTemperature(uint8_t*, uint8_t*);
-  
-  void	blockTillConversionComplete(uint8_t*,uint8_t*);
-  
-  #if REQUIRESALARMS
-
-  // required for alarmSearch 
-  uint8_t alarmSearchAddress[8];
-  char alarmSearchJunction;
-  uint8_t alarmSearchExhausted;
-
-  // the alarm handler function pointer
-  AlarmHandler *_AlarmHandler;
-
-  #endif
-  
-};
-#endif

+ 0 - 53
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/README.TXT

@@ -1,53 +0,0 @@
-Arduino Library for Dallas Temperature ICs
-==========================================
-
-For MAX31850 support, be sure to also get OneWire from
-https://github.com/adafruit/MAX31850_OneWire
-
-Usage
------
-
-This library supports the following devices: 
-    MAX31850
-    DS18B20
-    DS18S20 - Please note there appears to be an issue with this series.
-    DS1822
-
-You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line
-and your 3 or 5V power. If you are using the DS18B20, ground pins 1 and 3. The
-centre pin is the data line '1-wire'.
-
-Credits
--------
-
-The OneWire code has been derived from
-http://www.arduino.cc/playground/Learning/OneWire.
-Miles Burton <miles@mnetcs.com> originally developed this library.
-Tim Newsome <nuisance@casualhacker.net> added support for multiple sensors on
-the same bus.
-Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5)
-Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0)
-ladyad added MAX31850 support
-
-Website
--------
-
-You can find the latest version of the library at
-http://milesburton.com/index.php?title=Dallas_Temperature_Control_Library
-
-License
--------
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library 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
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

+ 0 - 85
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/change.txt

@@ -1,85 +0,0 @@
-
-This file contains the change history of the Dallas Temperature Control Library.
-
-VERSION 3.7.2 BETA
-===================
-DATE: 6 DEC  2011
-
-- Jordan Hochenbaum [jhochenbaum@gmail.com] updated library for compatibility with Arduino 1.0.
-
-VERSION 3.7.0 BETA
-===================
-DATE: 11 JAN  2011
-
-- Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0)
-  The library is backwards compatible with version 3.6.0
-
-  MAJOR: async modus
-  ------------------
-- Added - private bool waitForConversion. 
-This boolean is default set to true in the Constructor to keep the library backwards compatible. If this flag is true calls to requestTemperatures(), requestTemperaturesByAddress() et al, will be blocking with the appropiate time specified (in datasheet) for the resolution used. If the flag is set to false, requestTemperatures() et al, will return immediately after the conversion command is send over the 1-wire interface. The programmer is responsible to wait long enough before reading the temperature values. This enables the application to do other things while waiting for a new reading, like calculations, update LCD, read/write other IO lines etc. See examples.
-
-- Added - void setWaitForConversion(bool); 
-To set the flag to true or false, depending on the modus needed.
-
-- Added - bool getWaitForConversion(void); 
-To get the current value of the flag.
-
-- Changed - void requestTemperatures(void);
-Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready.
- 
-- Changed - bool requestTemperaturesByAddress(uint8_t*); 
-Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready.
-
-
-  MINOR version number
-  --------------------
-- Added - #define DALLASTEMPLIBVERSION "3.7.0" 
-To indicate the version number in .h file 
-  
-  
-  MINOR internal var bitResolution
-  ----------------------------
-- Changed - private int conversionDelay - is renamed to - private int bitResolution
-As this variable holds the resolution. The delay for the conversion is derived from it.
-
-- Changed - uint8_t getResolution(uint8_t* deviceAddress);
-If the device is not connected, it returns 0, otherwise it returns the resolution of the device.
-
-- Changed - bool setResolution(uint8_t* deviceAddress, uint8_t newResolution);
-If the device is not connected, it returns FALSE (fail), otherwise it returns TRUE (succes).
-
-- Added - uint8_t getResolution();
-Returns bitResolution.
-
-- Added - void setResolution(uint8_t newResolution)
-Sets the internal variable bitResolution, and all devices to this value
-
-
-  MINOR check connected state
-  ----------------------------
-- Changed - bool requestTemperaturesByIndex(deviceIndex) 
-Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise.
-
-- Changed - bool requestTemperaturesByAddress(deviceAddress)
-Changed return type from void to bool. The function returns false if the device identified with [deviceAddress] is not found on the bus and true otherwise.
-Added code to handle the DS18S20 which has a 9 bit resolution separately.
-Changed code so the blocking delay matches the bitResolution set in the device with deviceAddress.
-
-- Changed - bool requestTemperaturesByIndex(uint8_t deviceIndex)
-Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise.
-
-
-
-VERSION 3.6.0
-==============
-DATE: 2010-10-10
-
-- no detailed change history known except:
-
-- The OneWire code has been derived from
-http://www.arduino.cc/playground/Learning/OneWire.
-- Miles Burton <miles@mnetcs.com> originally developed this library.
-- Tim Newsome <nuisance@casualhacker.net> added support for multiple sensors on
-the same bus.
-- Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5)

+ 0 - 140
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Multiple/Multiple.pde

@@ -1,140 +0,0 @@
-#include <OneWire.h>
-#include <DallasTemperature.h>
-
-// Data wire is plugged into port 2 on the Arduino
-#define ONE_WIRE_BUS 2
-#define TEMPERATURE_PRECISION 9
-
-// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
-OneWire oneWire(ONE_WIRE_BUS);
-
-// Pass our oneWire reference to Dallas Temperature. 
-DallasTemperature sensors(&oneWire);
-
-// arrays to hold device addresses
-DeviceAddress insideThermometer, outsideThermometer;
-
-void setup(void)
-{
-  // start serial port
-  Serial.begin(9600);
-  Serial.println("Dallas Temperature IC Control Library Demo");
-
-  // Start up the library
-  sensors.begin();
-
-  // locate devices on the bus
-  Serial.print("Locating devices...");
-  Serial.print("Found ");
-  Serial.print(sensors.getDeviceCount(), DEC);
-  Serial.println(" devices.");
-
-  // report parasite power requirements
-  Serial.print("Parasite power is: "); 
-  if (sensors.isParasitePowerMode()) Serial.println("ON");
-  else Serial.println("OFF");
-
-  // assign address manually.  the addresses below will beed to be changed
-  // to valid device addresses on your bus.  device address can be retrieved
-  // by using either oneWire.search(deviceAddress) or individually via
-  // sensors.getAddress(deviceAddress, index)
-  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
-  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };
-
-  // search for devices on the bus and assign based on an index.  ideally,
-  // you would do this to initially discover addresses on the bus and then 
-  // use those addresses and manually assign them (see above) once you know 
-  // the devices on your bus (and assuming they don't change).
-  // 
-  // method 1: by index
-  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
-  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); 
-
-  // method 2: search()
-  // search() looks for the next device. Returns 1 if a new address has been
-  // returned. A zero might mean that the bus is shorted, there are no devices, 
-  // or you have already retrieved all of them.  It might be a good idea to 
-  // check the CRC to make sure you didn't get garbage.  The order is 
-  // deterministic. You will always get the same devices in the same order
-  //
-  // Must be called before search()
-  //oneWire.reset_search();
-  // assigns the first address found to insideThermometer
-  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
-  // assigns the seconds address found to outsideThermometer
-  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");
-
-  // show the addresses we found on the bus
-  Serial.print("Device 0 Address: ");
-  printAddress(insideThermometer);
-  Serial.println();
-
-  Serial.print("Device 1 Address: ");
-  printAddress(outsideThermometer);
-  Serial.println();
-
-  // set the resolution to 9 bit
-  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
-  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);
-
-  Serial.print("Device 0 Resolution: ");
-  Serial.print(sensors.getResolution(insideThermometer), DEC); 
-  Serial.println();
-
-  Serial.print("Device 1 Resolution: ");
-  Serial.print(sensors.getResolution(outsideThermometer), DEC); 
-  Serial.println();
-}
-
-// function to print a device address
-void printAddress(DeviceAddress deviceAddress)
-{
-  for (uint8_t i = 0; i < 8; i++)
-  {
-    // zero pad the address if necessary
-    if (deviceAddress[i] < 16) Serial.print("0");
-    Serial.print(deviceAddress[i], HEX);
-  }
-}
-
-// function to print the temperature for a device
-void printTemperature(DeviceAddress deviceAddress)
-{
-  float tempC = sensors.getTempC(deviceAddress);
-  Serial.print("Temp C: ");
-  Serial.print(tempC);
-  Serial.print(" Temp F: ");
-  Serial.print(DallasTemperature::toFahrenheit(tempC));
-}
-
-// function to print a device's resolution
-void printResolution(DeviceAddress deviceAddress)
-{
-  Serial.print("Resolution: ");
-  Serial.print(sensors.getResolution(deviceAddress));
-  Serial.println();    
-}
-
-// main function to print information about a device
-void printData(DeviceAddress deviceAddress)
-{
-  Serial.print("Device Address: ");
-  printAddress(deviceAddress);
-  Serial.print(" ");
-  printTemperature(deviceAddress);
-  Serial.println();
-}
-
-void loop(void)
-{ 
-  // call sensors.requestTemperatures() to issue a global temperature 
-  // request to all devices on the bus
-  Serial.print("Requesting temperatures...");
-  sensors.requestTemperatures();
-  Serial.println("DONE");
-
-  // print the device information
-  printData(insideThermometer);
-  printData(outsideThermometer);
-}
-

+ 0 - 33
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Simple/Simple.pde

@@ -1,33 +0,0 @@
-#include <OneWire.h>
-#include <DallasTemperature.h>
-
-// Data wire is plugged into port 2 on the Arduino
-#define ONE_WIRE_BUS 2
-
-// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
-OneWire oneWire(ONE_WIRE_BUS);
-
-// Pass our oneWire reference to Dallas Temperature. 
-DallasTemperature sensors(&oneWire);
-
-void setup(void)
-{
-  // start serial port
-  Serial.begin(9600);
-  Serial.println("Dallas Temperature IC Control Library Demo");
-
-  // Start up the library
-  sensors.begin();
-}
-
-void loop(void)
-{ 
-  // call sensors.requestTemperatures() to issue a global temperature 
-  // request to all devices on the bus
-  Serial.print("Requesting temperatures...");
-  sensors.requestTemperatures(); // Send the command to get temperatures
-  Serial.println("DONE");
-  
-  Serial.print("Temperature for the device 1 (index 0) is: ");
-  Serial.println(sensors.getTempCByIndex(0));  
-}

+ 0 - 109
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Single/Single.pde

@@ -1,109 +0,0 @@
-#include <OneWire.h>
-#include <DallasTemperature.h>
-
-// Data wire is plugged into port 2 on the Arduino
-#define ONE_WIRE_BUS 2
-
-// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
-OneWire oneWire(ONE_WIRE_BUS);
-
-// Pass our oneWire reference to Dallas Temperature. 
-DallasTemperature sensors(&oneWire);
-
-// arrays to hold device address
-DeviceAddress insideThermometer;
-
-void setup(void)
-{
-  // start serial port
-  Serial.begin(9600);
-  Serial.println("Dallas Temperature IC Control Library Demo");
-
-  // locate devices on the bus
-  Serial.print("Locating devices...");
-  sensors.begin();
-  Serial.print("Found ");
-  Serial.print(sensors.getDeviceCount(), DEC);
-  Serial.println(" devices.");
-
-  // report parasite power requirements
-  Serial.print("Parasite power is: "); 
-  if (sensors.isParasitePowerMode()) Serial.println("ON");
-  else Serial.println("OFF");
-  
-  // assign address manually.  the addresses below will beed to be changed
-  // to valid device addresses on your bus.  device address can be retrieved
-  // by using either oneWire.search(deviceAddress) or individually via
-  // sensors.getAddress(deviceAddress, index)
-  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
-
-  // Method 1:
-  // search for devices on the bus and assign based on an index.  ideally,
-  // you would do this to initially discover addresses on the bus and then 
-  // use those addresses and manually assign them (see above) once you know 
-  // the devices on your bus (and assuming they don't change).
-  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
-  
-  // method 2: search()
-  // search() looks for the next device. Returns 1 if a new address has been
-  // returned. A zero might mean that the bus is shorted, there are no devices, 
-  // or you have already retrieved all of them.  It might be a good idea to 
-  // check the CRC to make sure you didn't get garbage.  The order is 
-  // deterministic. You will always get the same devices in the same order
-  //
-  // Must be called before search()
-  //oneWire.reset_search();
-  // assigns the first address found to insideThermometer
-  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
-
-  // show the addresses we found on the bus
-  Serial.print("Device 0 Address: ");
-  printAddress(insideThermometer);
-  Serial.println();
-
-  // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
-  sensors.setResolution(insideThermometer, 9);
- 
-  Serial.print("Device 0 Resolution: ");
-  Serial.print(sensors.getResolution(insideThermometer), DEC); 
-  Serial.println();
-}
-
-// function to print the temperature for a device
-void printTemperature(DeviceAddress deviceAddress)
-{
-  // method 1 - slower
-  //Serial.print("Temp C: ");
-  //Serial.print(sensors.getTempC(deviceAddress));
-  //Serial.print(" Temp F: ");
-  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit
-
-  // method 2 - faster
-  float tempC = sensors.getTempC(deviceAddress);
-  Serial.print("Temp C: ");
-  Serial.print(tempC);
-  Serial.print(" Temp F: ");
-  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
-}
-
-void loop(void)
-{ 
-  // call sensors.requestTemperatures() to issue a global temperature 
-  // request to all devices on the bus
-  Serial.print("Requesting temperatures...");
-  sensors.requestTemperatures(); // Send the command to get temperatures
-  Serial.println("DONE");
-  
-  // It responds almost immediately. Let's print out the data
-  printTemperature(insideThermometer); // Use a simple function to print out the data
-}
-
-// function to print a device address
-void printAddress(DeviceAddress deviceAddress)
-{
-  for (uint8_t i = 0; i < 8; i++)
-  {
-    if (deviceAddress[i] < 16) Serial.print("0");
-    Serial.print(deviceAddress[i], HEX);
-  }
-}

+ 0 - 124
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/examples/Tester/Tester.pde

@@ -1,124 +0,0 @@
-#include <OneWire.h>
-#include <DallasTemperature.h>
-
-// Data wire is plugged into port 2 on the Arduino
-#define ONE_WIRE_BUS 2
-#define TEMPERATURE_PRECISION 9
-
-// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
-OneWire oneWire(ONE_WIRE_BUS);
-
-// Pass our oneWire reference to Dallas Temperature. 
-DallasTemperature sensors(&oneWire);
-
-int numberOfDevices; // Number of temperature devices found
-
-DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address
-
-void setup(void)
-{
-  // start serial port
-  Serial.begin(9600);
-  Serial.println("Dallas Temperature IC Control Library Demo");
-
-  // Start up the library
-  sensors.begin();
-  
-  // Grab a count of devices on the wire
-  numberOfDevices = sensors.getDeviceCount();
-  
-  // locate devices on the bus
-  Serial.print("Locating devices...");
-  
-  Serial.print("Found ");
-  Serial.print(numberOfDevices, DEC);
-  Serial.println(" devices.");
-
-  // report parasite power requirements
-  Serial.print("Parasite power is: "); 
-  if (sensors.isParasitePowerMode()) Serial.println("ON");
-  else Serial.println("OFF");
-  
-  // Loop through each device, print out address
-  for(int i=0;i<numberOfDevices; i++)
-  {
-    // Search the wire for address
-    if(sensors.getAddress(tempDeviceAddress, i))
-	{
-		Serial.print("Found device ");
-		Serial.print(i, DEC);
-		Serial.print(" with address: ");
-		printAddress(tempDeviceAddress);
-		Serial.println();
-		
-		Serial.print("Setting resolution to ");
-		Serial.println(TEMPERATURE_PRECISION, DEC);
-		
-		// set the resolution to TEMPERATURE_PRECISION bit (Each Dallas/Maxim device is capable of several different resolutions)
-		sensors.setResolution(tempDeviceAddress, TEMPERATURE_PRECISION);
-		
-		 Serial.print("Resolution actually set to: ");
-		Serial.print(sensors.getResolution(tempDeviceAddress), DEC); 
-		Serial.println();
-	}else{
-		Serial.print("Found ghost device at ");
-		Serial.print(i, DEC);
-		Serial.print(" but could not detect address. Check power and cabling");
-	}
-  }
-
-}
-
-// function to print the temperature for a device
-void printTemperature(DeviceAddress deviceAddress)
-{
-  // method 1 - slower
-  //Serial.print("Temp C: ");
-  //Serial.print(sensors.getTempC(deviceAddress));
-  //Serial.print(" Temp F: ");
-  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit
-
-  // method 2 - faster
-  float tempC = sensors.getTempC(deviceAddress);
-  Serial.print("Temp C: ");
-  Serial.print(tempC);
-  Serial.print(" Temp F: ");
-  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
-}
-
-void loop(void)
-{ 
-  // call sensors.requestTemperatures() to issue a global temperature 
-  // request to all devices on the bus
-  Serial.print("Requesting temperatures...");
-  sensors.requestTemperatures(); // Send the command to get temperatures
-  Serial.println("DONE");
-  
-  
-  // Loop through each device, print out temperature data
-  for(int i=0;i<numberOfDevices; i++)
-  {
-    // Search the wire for address
-    if(sensors.getAddress(tempDeviceAddress, i))
-	{
-		// Output the device ID
-		Serial.print("Temperature for device: ");
-		Serial.println(i,DEC);
-		
-		// It responds almost immediately. Let's print out the data
-		printTemperature(tempDeviceAddress); // Use a simple function to print out the data
-	} 
-	//else ghost device! Check your power requirements and cabling
-	
-  }
-}
-
-// function to print a device address
-void printAddress(DeviceAddress deviceAddress)
-{
-  for (uint8_t i = 0; i < 8; i++)
-  {
-    if (deviceAddress[i] < 16) Serial.print("0");
-    Serial.print(deviceAddress[i], HEX);
-  }
-}

+ 0 - 54
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/keywords.txt

@@ -1,54 +0,0 @@
-#######################################
-# Syntax Coloring Map For Ultrasound
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-DallasTemperature	KEYWORD1
-OneWire	KEYWORD1
-AlarmHandler	KEYWORD1
-DeviceAddress	KEYWORD1
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-setResolution	KEYWORD2
-getResolution	KEYWORD2
-getTempC	KEYWORD2
-toFahrenheit	KEYWORD2
-getTempF	KEYWORD2
-getTempCByIndex 	KEYWORD2
-getTempFByIndex		KEYWORD2
-setWaitForConversion	KEYWORD2
-getWaitForConversion	KEYWORD2
-requestTemperatures	KEYWORD2
-requestTemperaturesByAddress	KEYWORD2
-requestTemperaturesByIndex	KEYWORD2
-isParasitePowerMode	KEYWORD2
-begin	KEYWORD2
-getDeviceCount	KEYWORD2
-getAddress	KEYWORD2
-validAddress	KEYWORD2
-isConnected	KEYWORD2
-readScratchPad	KEYWORD2
-writeScratchPad	KEYWORD2
-readPowerSupply	KEYWORD2
-setHighAlarmTemp	KEYWORD2
-setLowAlarmTemp	KEYWORD2
-getHighAlarmTemp	KEYWORD2
-getLowAlarmTemp	KEYWORD2
-resetAlarmSearch	KEYWORD2
-alarmSearch	KEYWORD2
-hasAlarm	KEYWORD2
-toCelsius	KEYWORD2
-processAlarmss	KEYWORD2
-setAlarmHandlers	KEYWORD2
-defaultAlarmHandler	KEYWORD2
-calculateTemperature	KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-

+ 0 - 9
SE/stuff/P5_Automation-library-dev/MAX31850_DallasTemp/library.properties

@@ -1,9 +0,0 @@
-name=MAX31850 DallasTemp
-version=1.0.0
-author=Adafruit
-maintainer=Adafruit <info@adafruit.com>
-sentence=A version of the DallasTemp Arduino library with MAX31850 support (Requires OneWire with MAX31850 support!)
-paragraph=A version of the DallasTemp Arduino library with MAX31850 support (Requires OneWire with MAX31850 support!)
-category=Sensors
-url=https://github.com/adafruit/MAX31850_DallasTemp
-architectures=*

+ 0 - 557
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/OneWire.cpp

@@ -1,557 +0,0 @@
-/*
-Copyright (c) 2007, Jim Studt  (original old version - many contributors since)
-
-The latest version of this library may be found at:
-  http://www.pjrc.com/teensy/td_libs_OneWire.html
-
-OneWire has been maintained by Paul Stoffregen (paul@pjrc.com) since
-January 2010.  At the time, it was in need of many bug fixes, but had
-been abandoned the original author (Jim Studt).  None of the known
-contributors were interested in maintaining OneWire.  Paul typically
-works on OneWire every 6 to 12 months.  Patches usually wait that
-long.  If anyone is interested in more actively maintaining OneWire,
-please contact Paul.
-
-Version 2.2:
-  Teensy 3.0 compatibility, Paul Stoffregen, paul@pjrc.com
-  Arduino Due compatibility, http://arduino.cc/forum/index.php?topic=141030
-  Fix DS18B20 example negative temperature
-  Fix DS18B20 example's low res modes, Ken Butcher
-  Improve reset timing, Mark Tillotson
-  Add const qualifiers, Bertrik Sikken
-  Add initial value input to crc16, Bertrik Sikken
-  Add target_search() function, Scott Roberts
-
-Version 2.1:
-  Arduino 1.0 compatibility, Paul Stoffregen
-  Improve temperature example, Paul Stoffregen
-  DS250x_PROM example, Guillermo Lovato
-  PIC32 (chipKit) compatibility, Jason Dangel, dangel.jason AT gmail.com
-  Improvements from Glenn Trewitt:
-  - crc16() now works
-  - check_crc16() does all of calculation/checking work.
-  - Added read_bytes() and write_bytes(), to reduce tedious loops.
-  - Added ds2408 example.
-  Delete very old, out-of-date readme file (info is here)
-
-Version 2.0: Modifications by Paul Stoffregen, January 2010:
-http://www.pjrc.com/teensy/td_libs_OneWire.html
-  Search fix from Robin James
-    http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27
-  Use direct optimized I/O in all cases
-  Disable interrupts during timing critical sections
-    (this solves many random communication errors)
-  Disable interrupts during read-modify-write I/O
-  Reduce RAM consumption by eliminating unnecessary
-    variables and trimming many to 8 bits
-  Optimize both crc8 - table version moved to flash
-
-Modified to work with larger numbers of devices - avoids loop.
-Tested in Arduino 11 alpha with 12 sensors.
-26 Sept 2008 -- Robin James
-http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27
-
-Updated to work with arduino-0008 and to include skip() as of
-2007/07/06. --RJL20
-
-Modified to calculate the 8-bit CRC directly, avoiding the need for
-the 256-byte lookup table to be loaded in RAM.  Tested in arduino-0010
--- Tom Pollard, Jan 23, 2008
-
-Jim Studt's original library was modified by Josh Larios.
-
-Tom Pollard, pollard@alum.mit.edu, contributed around May 20, 2008
-
-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.
-
-Much of the code was inspired by Derek Yerger's code, though I don't
-think much of that remains.  In any event that was..
-    (copyleft) 2006 by Derek Yerger - Free to distribute freely.
-
-The CRC code was excerpted and inspired by the Dallas Semiconductor
-sample code bearing this copyright.
-//---------------------------------------------------------------------------
-// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
-//
-// 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 DALLAS SEMICONDUCTOR 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.
-//
-// Except as contained in this notice, the name of Dallas Semiconductor
-// shall not be used except as stated in the Dallas Semiconductor
-// Branding Policy.
-//--------------------------------------------------------------------------
-*/
-
-#include "OneWire.h"
-
-
-OneWire::OneWire(uint8_t pin)
-{
-	pinMode(pin, INPUT);
-	bitmask = PIN_TO_BITMASK(pin);
-	baseReg = PIN_TO_BASEREG(pin);
-#if ONEWIRE_SEARCH
-	reset_search();
-#endif
-}
-
-
-// Perform the onewire reset function.  We will wait up to 250uS for
-// the bus to come high, if it doesn't then it is broken or shorted
-// and we return a 0;
-//
-// Returns 1 if a device asserted a presence pulse, 0 otherwise.
-//
-uint8_t OneWire::reset(void)
-{
-	IO_REG_TYPE mask = bitmask;
-	volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
-	uint8_t r;
-	uint8_t retries = 125;
-
-	noInterrupts();
-	DIRECT_MODE_INPUT(reg, mask);
-	interrupts();
-	// wait until the wire is high... just in case
-	do {
-		if (--retries == 0) return 0;
-		delayMicroseconds(2);
-	} while ( !DIRECT_READ(reg, mask));
-
-	noInterrupts();
-	DIRECT_WRITE_LOW(reg, mask);
-	DIRECT_MODE_OUTPUT(reg, mask);	// drive output low
-	interrupts();
-	delayMicroseconds(480);
-	noInterrupts();
-	DIRECT_MODE_INPUT(reg, mask);	// allow it to float
-	delayMicroseconds(70);
-	r = !DIRECT_READ(reg, mask);
-	interrupts();
-	delayMicroseconds(410);
-	return r;
-}
-
-//
-// Write a bit. Port and bit is used to cut lookup time and provide
-// more certain timing.
-//
-void OneWire::write_bit(uint8_t v)
-{
-	IO_REG_TYPE mask=bitmask;
-	volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
-
-	if (v & 1) {
-		noInterrupts();
-		DIRECT_WRITE_LOW(reg, mask);
-		DIRECT_MODE_OUTPUT(reg, mask);	// drive output low
-		delayMicroseconds(10);
-		DIRECT_WRITE_HIGH(reg, mask);	// drive output high
-		interrupts();
-		delayMicroseconds(55);
-	} else {
-		noInterrupts();
-		DIRECT_WRITE_LOW(reg, mask);
-		DIRECT_MODE_OUTPUT(reg, mask);	// drive output low
-		delayMicroseconds(65);
-		DIRECT_WRITE_HIGH(reg, mask);	// drive output high
-		interrupts();
-		delayMicroseconds(5);
-	}
-}
-
-//
-// Read a bit. Port and bit is used to cut lookup time and provide
-// more certain timing.
-//
-uint8_t OneWire::read_bit(void)
-{
-	IO_REG_TYPE mask=bitmask;
-	volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
-	uint8_t r;
-
-	noInterrupts();
-	DIRECT_MODE_OUTPUT(reg, mask);
-	DIRECT_WRITE_LOW(reg, mask);
-	delayMicroseconds(3);
-	DIRECT_MODE_INPUT(reg, mask);	// let pin float, pull up will raise
-	delayMicroseconds(10);
-	r = DIRECT_READ(reg, mask);
-	interrupts();
-	delayMicroseconds(53);
-	return r;
-}
-
-//
-// Write a byte. The writing code uses the active drivers to raise the
-// pin high, if you need power after the write (e.g. DS18S20 in
-// parasite power mode) then set 'power' to 1, otherwise the pin will
-// go tri-state at the end of the write to avoid heating in a short or
-// other mishap.
-//
-void OneWire::write(uint8_t v, uint8_t power /* = 0 */) {
-    uint8_t bitMask;
-
-    for (bitMask = 0x01; bitMask; bitMask <<= 1) {
-	OneWire::write_bit( (bitMask & v)?1:0);
-    }
-    if ( !power) {
-	noInterrupts();
-	DIRECT_MODE_INPUT(baseReg, bitmask);
-	DIRECT_WRITE_LOW(baseReg, bitmask);
-	interrupts();
-    }
-}
-
-void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) {
-  for (uint16_t i = 0 ; i < count ; i++)
-    write(buf[i]);
-  if (!power) {
-    noInterrupts();
-    DIRECT_MODE_INPUT(baseReg, bitmask);
-    DIRECT_WRITE_LOW(baseReg, bitmask);
-    interrupts();
-  }
-}
-
-//
-// Read a byte
-//
-uint8_t OneWire::read() {
-    uint8_t bitMask;
-    uint8_t r = 0;
-
-    for (bitMask = 0x01; bitMask; bitMask <<= 1) {
-	if ( OneWire::read_bit()) r |= bitMask;
-    }
-    return r;
-}
-
-void OneWire::read_bytes(uint8_t *buf, uint16_t count) {
-  for (uint16_t i = 0 ; i < count ; i++)
-    buf[i] = read();
-}
-
-//
-// Do a ROM select
-//
-void OneWire::select(const uint8_t rom[8])
-{
-    uint8_t i;
-
-    write(0x55);           // Choose ROM
-
-    for (i = 0; i < 8; i++) write(rom[i]);
-}
-
-//
-// Do a ROM skip
-//
-void OneWire::skip()
-{
-    write(0xCC);           // Skip ROM
-}
-
-void OneWire::depower()
-{
-	noInterrupts();
-	DIRECT_MODE_INPUT(baseReg, bitmask);
-	interrupts();
-}
-
-#if ONEWIRE_SEARCH
-
-//
-// You need to use this function to start a search again from the beginning.
-// You do not need to do it for the first search, though you could.
-//
-void OneWire::reset_search()
-{
-  // reset the search state
-  LastDiscrepancy = 0;
-  LastDeviceFlag = FALSE;
-  LastFamilyDiscrepancy = 0;
-  for(int i = 7; ; i--) {
-    ROM_NO[i] = 0;
-    if ( i == 0) break;
-  }
-}
-
-// Setup the search to find the device type 'family_code' on the next call
-// to search(*newAddr) if it is present.
-//
-void OneWire::target_search(uint8_t family_code)
-{
-   // set the search state to find SearchFamily type devices
-   ROM_NO[0] = family_code;
-   for (uint8_t i = 1; i < 8; i++)
-      ROM_NO[i] = 0;
-   LastDiscrepancy = 64;
-   LastFamilyDiscrepancy = 0;
-   LastDeviceFlag = FALSE;
-}
-
-//
-// Perform a search. If this function returns a '1' then it has
-// enumerated the next device and you may retrieve the ROM from the
-// OneWire::address variable. If there are no devices, no further
-// devices, or something horrible happens in the middle of the
-// enumeration then a 0 is returned.  If a new device is found then
-// its address is copied to newAddr.  Use OneWire::reset_search() to
-// start over.
-//
-// --- Replaced by the one from the Dallas Semiconductor web site ---
-//--------------------------------------------------------------------------
-// Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing
-// search state.
-// Return TRUE  : device found, ROM number in ROM_NO buffer
-//        FALSE : device not found, end of search
-//
-uint8_t OneWire::search(uint8_t *newAddr)
-{
-   uint8_t id_bit_number;
-   uint8_t last_zero, rom_byte_number, search_result;
-   uint8_t id_bit, cmp_id_bit;
-
-   unsigned char rom_byte_mask, search_direction;
-
-   // initialize for search
-   id_bit_number = 1;
-   last_zero = 0;
-   rom_byte_number = 0;
-   rom_byte_mask = 1;
-   search_result = 0;
-
-   // if the last call was not the last one
-   if (!LastDeviceFlag)
-   {
-      // 1-Wire reset
-      if (!reset())
-      {
-         // reset the search
-         LastDiscrepancy = 0;
-         LastDeviceFlag = FALSE;
-         LastFamilyDiscrepancy = 0;
-         return FALSE;
-      }
-
-      // issue the search command
-      write(0xF0);
-
-      // loop to do the search
-      do
-      {
-         // read a bit and its complement
-         id_bit = read_bit();
-         cmp_id_bit = read_bit();
-
-         // check for no devices on 1-wire
-         if ((id_bit == 1) && (cmp_id_bit == 1))
-            break;
-         else
-         {
-            // all devices coupled have 0 or 1
-            if (id_bit != cmp_id_bit)
-               search_direction = id_bit;  // bit write value for search
-            else
-            {
-               // if this discrepancy if before the Last Discrepancy
-               // on a previous next then pick the same as last time
-               if (id_bit_number < LastDiscrepancy)
-                  search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0);
-               else
-                  // if equal to last pick 1, if not then pick 0
-                  search_direction = (id_bit_number == LastDiscrepancy);
-
-               // if 0 was picked then record its position in LastZero
-               if (search_direction == 0)
-               {
-                  last_zero = id_bit_number;
-
-                  // check for Last discrepancy in family
-                  if (last_zero < 9)
-                     LastFamilyDiscrepancy = last_zero;
-               }
-            }
-
-            // set or clear the bit in the ROM byte rom_byte_number
-            // with mask rom_byte_mask
-            if (search_direction == 1)
-              ROM_NO[rom_byte_number] |= rom_byte_mask;
-            else
-              ROM_NO[rom_byte_number] &= ~rom_byte_mask;
-
-            // serial number search direction write bit
-            write_bit(search_direction);
-
-            // increment the byte counter id_bit_number
-            // and shift the mask rom_byte_mask
-            id_bit_number++;
-            rom_byte_mask <<= 1;
-
-            // if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask
-            if (rom_byte_mask == 0)
-            {
-                rom_byte_number++;
-                rom_byte_mask = 1;
-            }
-         }
-      }
-      while(rom_byte_number < 8);  // loop until through all ROM bytes 0-7
-
-      // if the search was successful then
-      if (!(id_bit_number < 65))
-      {
-         // search successful so set LastDiscrepancy,LastDeviceFlag,search_result
-         LastDiscrepancy = last_zero;
-
-         // check for last device
-         if (LastDiscrepancy == 0)
-            LastDeviceFlag = TRUE;
-
-         search_result = TRUE;
-      }
-   }
-
-   // if no device found then reset counters so next 'search' will be like a first
-   if (!search_result || !ROM_NO[0])
-   {
-      LastDiscrepancy = 0;
-      LastDeviceFlag = FALSE;
-      LastFamilyDiscrepancy = 0;
-      search_result = FALSE;
-   }
-   for (int i = 0; i < 8; i++) newAddr[i] = ROM_NO[i];
-   return search_result;
-  }
-
-#endif
-
-#if ONEWIRE_CRC
-// The 1-Wire CRC scheme is described in Maxim Application Note 27:
-// "Understanding and Using Cyclic Redundancy Checks with Maxim iButton Products"
-//
-
-#if ONEWIRE_CRC8_TABLE
-// This table comes from Dallas sample code where it is freely reusable,
-// though Copyright (C) 2000 Dallas Semiconductor Corporation
-static const uint8_t PROGMEM dscrc_table[] = {
-      0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65,
-    157,195, 33,127,252,162, 64, 30, 95,  1,227,189, 62, 96,130,220,
-     35,125,159,193, 66, 28,254,160,225,191, 93,  3,128,222, 60, 98,
-    190,224,  2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255,
-     70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89,  7,
-    219,133,103, 57,186,228,  6, 88, 25, 71,165,251,120, 38,196,154,
-    101, 59,217,135,  4, 90,184,230,167,249, 27, 69,198,152,122, 36,
-    248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91,  5,231,185,
-    140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205,
-     17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80,
-    175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238,
-     50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115,
-    202,148,118, 40,171,245, 23, 73,  8, 86,180,234,105, 55,213,139,
-     87,  9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22,
-    233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168,
-    116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53};
-
-//
-// Compute a Dallas Semiconductor 8 bit CRC. These show up in the ROM
-// and the registers.  (note: this might better be done without to
-// table, it would probably be smaller and certainly fast enough
-// compared to all those delayMicrosecond() calls.  But I got
-// confused, so I use this table from the examples.)
-//
-uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len)
-{
-	uint8_t crc = 0;
-
-	while (len--) {
-		crc = pgm_read_byte(dscrc_table + (crc ^ *addr++));
-	}
-	return crc;
-}
-#else
-//
-// Compute a Dallas Semiconductor 8 bit CRC directly.
-// this is much slower, but much smaller, than the lookup table.
-//
-uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len)
-{
-	uint8_t crc = 0;
-	
-	while (len--) {
-		uint8_t inbyte = *addr++;
-		for (uint8_t i = 8; i; i--) {
-			uint8_t mix = (crc ^ inbyte) & 0x01;
-			crc >>= 1;
-			if (mix) crc ^= 0x8C;
-			inbyte >>= 1;
-		}
-	}
-	return crc;
-}
-#endif
-
-#if ONEWIRE_CRC16
-bool OneWire::check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc)
-{
-    crc = ~crc16(input, len, crc);
-    return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1];
-}
-
-uint16_t OneWire::crc16(const uint8_t* input, uint16_t len, uint16_t crc)
-{
-    static const uint8_t oddparity[16] =
-        { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
-
-    for (uint16_t i = 0 ; i < len ; i++) {
-      // Even though we're just copying a byte from the input,
-      // we'll be doing 16-bit computation with it.
-      uint16_t cdata = input[i];
-      cdata = (cdata ^ crc) & 0xff;
-      crc >>= 8;
-
-      if (oddparity[cdata & 0x0F] ^ oddparity[cdata >> 4])
-          crc ^= 0xC001;
-
-      cdata <<= 6;
-      crc ^= cdata;
-      cdata <<= 1;
-      crc ^= cdata;
-    }
-    return crc;
-}
-#endif
-
-#endif

+ 0 - 251
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/OneWire.h

@@ -1,251 +0,0 @@
-#ifndef OneWire_h
-#define OneWire_h
-
-#include <inttypes.h>
-
-#if ARDUINO >= 100
-#include "Arduino.h"       // for delayMicroseconds, digitalPinToBitMask, etc
-#else
-#include "WProgram.h"      // for delayMicroseconds
-#include "pins_arduino.h"  // for digitalPinToBitMask, etc
-#endif
-
-// You can exclude certain features from OneWire.  In theory, this
-// might save some space.  In practice, the compiler automatically
-// removes unused code (technically, the linker, using -fdata-sections
-// and -ffunction-sections when compiling, and Wl,--gc-sections
-// when linking), so most of these will not result in any code size
-// reduction.  Well, unless you try to use the missing features
-// and redesign your program to not need them!  ONEWIRE_CRC8_TABLE
-// is the exception, because it selects a fast but large algorithm
-// or a small but slow algorithm.
-
-// you can exclude onewire_search by defining that to 0
-#ifndef ONEWIRE_SEARCH
-#define ONEWIRE_SEARCH 1
-#endif
-
-// You can exclude CRC checks altogether by defining this to 0
-#ifndef ONEWIRE_CRC
-#define ONEWIRE_CRC 1
-#endif
-
-// Select the table-lookup method of computing the 8-bit CRC
-// by setting this to 1.  The lookup table enlarges code size by
-// about 250 bytes.  It does NOT consume RAM (but did in very
-// old versions of OneWire).  If you disable this, a slower
-// but very compact algorithm is used.
-#ifndef ONEWIRE_CRC8_TABLE
-#define ONEWIRE_CRC8_TABLE 1
-#endif
-
-// You can allow 16-bit CRC checks by defining this to 1
-// (Note that ONEWIRE_CRC must also be 1.)
-#ifndef ONEWIRE_CRC16
-#define ONEWIRE_CRC16 1
-#endif
-
-#define FALSE 0
-#define TRUE  1
-
-// Platform specific I/O definitions
-
-#if defined(__AVR__)
-#define PIN_TO_BASEREG(pin)             (portInputRegister(digitalPinToPort(pin)))
-#define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))
-#define IO_REG_TYPE uint8_t
-#define IO_REG_ASM asm("r30")
-#define DIRECT_READ(base, mask)         (((*(base)) & (mask)) ? 1 : 0)
-#define DIRECT_MODE_INPUT(base, mask)   ((*((base)+1)) &= ~(mask))
-#define DIRECT_MODE_OUTPUT(base, mask)  ((*((base)+1)) |= (mask))
-#define DIRECT_WRITE_LOW(base, mask)    ((*((base)+2)) &= ~(mask))
-#define DIRECT_WRITE_HIGH(base, mask)   ((*((base)+2)) |= (mask))
-
-#elif defined(__MK20DX128__)
-#define PIN_TO_BASEREG(pin)             (portOutputRegister(pin))
-#define PIN_TO_BITMASK(pin)             (1)
-#define IO_REG_TYPE uint8_t
-#define IO_REG_ASM
-#define DIRECT_READ(base, mask)         (*((base)+512))
-#define DIRECT_MODE_INPUT(base, mask)   (*((base)+640) = 0)
-#define DIRECT_MODE_OUTPUT(base, mask)  (*((base)+640) = 1)
-#define DIRECT_WRITE_LOW(base, mask)    (*((base)+256) = 1)
-#define DIRECT_WRITE_HIGH(base, mask)   (*((base)+128) = 1)
-
-#elif defined(__SAM3X8E__)
-// Arduino 1.5.1 may have a bug in delayMicroseconds() on Arduino Due.
-// http://arduino.cc/forum/index.php/topic,141030.msg1076268.html#msg1076268
-// If you have trouble with OneWire on Arduino Due, please check the
-// status of delayMicroseconds() before reporting a bug in OneWire!
-#define PIN_TO_BASEREG(pin)             (&(digitalPinToPort(pin)->PIO_PER))
-#define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))
-#define IO_REG_TYPE uint32_t
-#define IO_REG_ASM
-#define DIRECT_READ(base, mask)         (((*((base)+15)) & (mask)) ? 1 : 0)
-#define DIRECT_MODE_INPUT(base, mask)   ((*((base)+5)) = (mask))
-#define DIRECT_MODE_OUTPUT(base, mask)  ((*((base)+4)) = (mask))
-#define DIRECT_WRITE_LOW(base, mask)    ((*((base)+13)) = (mask))
-#define DIRECT_WRITE_HIGH(base, mask)   ((*((base)+12)) = (mask))
-#ifndef PROGMEM
-#define PROGMEM
-#endif
-#ifndef pgm_read_byte
-#define pgm_read_byte(addr) (*(const uint8_t *)(addr))
-#endif
-
-#elif defined(__PIC32MX__)
-#define PIN_TO_BASEREG(pin)             (portModeRegister(digitalPinToPort(pin)))
-#define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))
-#define IO_REG_TYPE uint32_t
-#define IO_REG_ASM
-#define DIRECT_READ(base, mask)         (((*(base+4)) & (mask)) ? 1 : 0)  //PORTX + 0x10
-#define DIRECT_MODE_INPUT(base, mask)   ((*(base+2)) = (mask))            //TRISXSET + 0x08
-#define DIRECT_MODE_OUTPUT(base, mask)  ((*(base+1)) = (mask))            //TRISXCLR + 0x04
-#define DIRECT_WRITE_LOW(base, mask)    ((*(base+8+1)) = (mask))          //LATXCLR  + 0x24
-#define DIRECT_WRITE_HIGH(base, mask)   ((*(base+8+2)) = (mask))          //LATXSET + 0x28
-
-#elif defined(ARDUINO_ARCH_ESP8266)
-#define PIN_TO_BASEREG(pin)             ((volatile uint32_t*) GPO)
-#define PIN_TO_BITMASK(pin)             (1 << pin)
-#define IO_REG_TYPE uint32_t
-#define IO_REG_ASM
-#define DIRECT_READ(base, mask)         ((GPI & (mask)) ? 1 : 0)    //GPIO_IN_ADDRESS
-#define DIRECT_MODE_INPUT(base, mask)   (GPE &= ~(mask))            //GPIO_ENABLE_W1TC_ADDRESS
-#define DIRECT_MODE_OUTPUT(base, mask)  (GPE |= (mask))             //GPIO_ENABLE_W1TS_ADDRESS
-#define DIRECT_WRITE_LOW(base, mask)    (GPOC = (mask))             //GPIO_OUT_W1TC_ADDRESS
-#define DIRECT_WRITE_HIGH(base, mask)   (GPOS = (mask))             //GPIO_OUT_W1TS_ADDRESS
-
-#elif defined(__SAMD21G18A__)
-#define PIN_TO_BASEREG(pin)             portModeRegister(digitalPinToPort(pin))
-#define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))
-#define IO_REG_TYPE uint32_t
-#define IO_REG_ASM
-#define DIRECT_READ(base, mask)         (((*((base)+8)) & (mask)) ? 1 : 0)
-#define DIRECT_MODE_INPUT(base, mask)   ((*((base)+1)) = (mask))
-#define DIRECT_MODE_OUTPUT(base, mask)  ((*((base)+2)) = (mask))
-#define DIRECT_WRITE_LOW(base, mask)    ((*((base)+5)) = (mask))
-#define DIRECT_WRITE_HIGH(base, mask)   ((*((base)+6)) = (mask))
-
-#else
-#error "Please define I/O register types here"
-#endif
-
-
-class OneWire
-{
-  private:
-    IO_REG_TYPE bitmask;
-    volatile IO_REG_TYPE *baseReg;
-
-#if ONEWIRE_SEARCH
-    // global search state
-    unsigned char ROM_NO[8];
-    uint8_t LastDiscrepancy;
-    uint8_t LastFamilyDiscrepancy;
-    uint8_t LastDeviceFlag;
-#endif
-
-  public:
-    OneWire( uint8_t pin);
-
-    // Perform a 1-Wire reset cycle. Returns 1 if a device responds
-    // with a presence pulse.  Returns 0 if there is no device or the
-    // bus is shorted or otherwise held low for more than 250uS
-    uint8_t reset(void);
-
-    // Issue a 1-Wire rom select command, you do the reset first.
-    void select(const uint8_t rom[8]);
-
-    // Issue a 1-Wire rom skip command, to address all on bus.
-    void skip(void);
-
-    // Write a byte. If 'power' is one then the wire is held high at
-    // the end for parasitically powered devices. You are responsible
-    // for eventually depowering it by calling depower() or doing
-    // another read or write.
-    void write(uint8_t v, uint8_t power = 0);
-
-    void write_bytes(const uint8_t *buf, uint16_t count, bool power = 0);
-
-    // Read a byte.
-    uint8_t read(void);
-
-    void read_bytes(uint8_t *buf, uint16_t count);
-
-    // Write a bit. The bus is always left powered at the end, see
-    // note in write() about that.
-    void write_bit(uint8_t v);
-
-    // Read a bit.
-    uint8_t read_bit(void);
-
-    // Stop forcing power onto the bus. You only need to do this if
-    // you used the 'power' flag to write() or used a write_bit() call
-    // and aren't about to do another read or write. You would rather
-    // not leave this powered if you don't have to, just in case
-    // someone shorts your bus.
-    void depower(void);
-
-#if ONEWIRE_SEARCH
-    // Clear the search state so that if will start from the beginning again.
-    void reset_search();
-
-    // Setup the search to find the device type 'family_code' on the next call
-    // to search(*newAddr) if it is present.
-    void target_search(uint8_t family_code);
-
-    // Look for the next device. Returns 1 if a new address has been
-    // returned. A zero might mean that the bus is shorted, there are
-    // no devices, or you have already retrieved all of them.  It
-    // might be a good idea to check the CRC to make sure you didn't
-    // get garbage.  The order is deterministic. You will always get
-    // the same devices in the same order.
-    uint8_t search(uint8_t *newAddr);
-#endif
-
-#if ONEWIRE_CRC
-    // Compute a Dallas Semiconductor 8 bit CRC, these are used in the
-    // ROM and scratchpad registers.
-    static uint8_t crc8(const uint8_t *addr, uint8_t len);
-
-#if ONEWIRE_CRC16
-    // Compute the 1-Wire CRC16 and compare it against the received CRC.
-    // Example usage (reading a DS2408):
-    //    // Put everything in a buffer so we can compute the CRC easily.
-    //    uint8_t buf[13];
-    //    buf[0] = 0xF0;    // Read PIO Registers
-    //    buf[1] = 0x88;    // LSB address
-    //    buf[2] = 0x00;    // MSB address
-    //    WriteBytes(net, buf, 3);    // Write 3 cmd bytes
-    //    ReadBytes(net, buf+3, 10);  // Read 6 data bytes, 2 0xFF, 2 CRC16
-    //    if (!CheckCRC16(buf, 11, &buf[11])) {
-    //        // Handle error.
-    //    }     
-    //          
-    // @param input - Array of bytes to checksum.
-    // @param len - How many bytes to use.
-    // @param inverted_crc - The two CRC16 bytes in the received data.
-    //                       This should just point into the received data,
-    //                       *not* at a 16-bit integer.
-    // @param crc - The crc starting value (optional)
-    // @return True, iff the CRC matches.
-    static bool check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc = 0);
-
-    // Compute a Dallas Semiconductor 16 bit CRC.  This is required to check
-    // the integrity of data received from many 1-Wire devices.  Note that the
-    // CRC computed here is *not* what you'll get from the 1-Wire network,
-    // for two reasons:
-    //   1) The CRC is transmitted bitwise inverted.
-    //   2) Depending on the endian-ness of your processor, the binary
-    //      representation of the two-byte return value may have a different
-    //      byte order than the two bytes you get from 1-Wire.
-    // @param input - Array of bytes to checksum.
-    // @param len - How many bytes to use.
-    // @param crc - The crc starting value (optional)
-    // @return The CRC16, as defined by Dallas Semiconductor.
-    static uint16_t crc16(const uint8_t* input, uint16_t len, uint16_t crc = 0);
-#endif
-#endif
-};
-
-#endif

+ 0 - 112
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde

@@ -1,112 +0,0 @@
-#include <OneWire.h>
-
-// OneWire DS18S20, DS18B20, DS1822 Temperature Example
-//
-// http://www.pjrc.com/teensy/td_libs_OneWire.html
-//
-// The DallasTemperature library can do all this work for you!
-// http://milesburton.com/Dallas_Temperature_Control_Library
-
-OneWire  ds(10);  // on pin 10 (a 4.7K resistor is necessary)
-
-void setup(void) {
-  Serial.begin(9600);
-}
-
-void loop(void) {
-  byte i;
-  byte present = 0;
-  byte type_s;
-  byte data[12];
-  byte addr[8];
-  float celsius, fahrenheit;
-  
-  if ( !ds.search(addr)) {
-    Serial.println("No more addresses.");
-    Serial.println();
-    ds.reset_search();
-    delay(250);
-    return;
-  }
-  
-  Serial.print("ROM =");
-  for( i = 0; i < 8; i++) {
-    Serial.write(' ');
-    Serial.print(addr[i], HEX);
-  }
-
-  if (OneWire::crc8(addr, 7) != addr[7]) {
-      Serial.println("CRC is not valid!");
-      return;
-  }
-  Serial.println();
- 
-  // the first ROM byte indicates which chip
-  switch (addr[0]) {
-    case 0x10:
-      Serial.println("  Chip = DS18S20");  // or old DS1820
-      type_s = 1;
-      break;
-    case 0x28:
-      Serial.println("  Chip = DS18B20");
-      type_s = 0;
-      break;
-    case 0x22:
-      Serial.println("  Chip = DS1822");
-      type_s = 0;
-      break;
-    default:
-      Serial.println("Device is not a DS18x20 family device.");
-      return;
-  } 
-
-  ds.reset();
-  ds.select(addr);
-  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
-  
-  delay(1000);     // maybe 750ms is enough, maybe not
-  // we might do a ds.depower() here, but the reset will take care of it.
-  
-  present = ds.reset();
-  ds.select(addr);    
-  ds.write(0xBE);         // Read Scratchpad
-
-  Serial.print("  Data = ");
-  Serial.print(present, HEX);
-  Serial.print(" ");
-  for ( i = 0; i < 9; i++) {           // we need 9 bytes
-    data[i] = ds.read();
-    Serial.print(data[i], HEX);
-    Serial.print(" ");
-  }
-  Serial.print(" CRC=");
-  Serial.print(OneWire::crc8(data, 8), HEX);
-  Serial.println();
-
-  // Convert the data to actual temperature
-  // because the result is a 16 bit signed integer, it should
-  // be stored to an "int16_t" type, which is always 16 bits
-  // even when compiled on a 32 bit processor.
-  int16_t raw = (data[1] << 8) | data[0];
-  if (type_s) {
-    raw = raw << 3; // 9 bit resolution default
-    if (data[7] == 0x10) {
-      // "count remain" gives full 12 bit resolution
-      raw = (raw & 0xFFF0) + 12 - data[6];
-    }
-  } else {
-    byte cfg = (data[4] & 0x60);
-    // at lower res, the low bits are undefined, so let's zero them
-    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
-    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
-    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
-    //// default is 12 bit resolution, 750 ms conversion time
-  }
-  celsius = (float)raw / 16.0;
-  fahrenheit = celsius * 1.8 + 32.0;
-  Serial.print("  Temperature = ");
-  Serial.print(celsius);
-  Serial.print(" Celsius, ");
-  Serial.print(fahrenheit);
-  Serial.println(" Fahrenheit");
-}

+ 0 - 77
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/DS2408_Switch/DS2408_Switch.pde

@@ -1,77 +0,0 @@
-#include <OneWire.h>
-
-/*
- * DS2408 8-Channel Addressable Switch
- *
- * Writte by Glenn Trewitt, glenn at trewitt dot org
- *
- * Some notes about the DS2408:
- *   - Unlike most input/output ports, the DS2408 doesn't have mode bits to
- *       set whether the pins are input or output.  If you issue a read command,
- *       they're inputs.  If you write to them, they're outputs.
- *   - For reading from a switch, you should use 10K pull-up resisters.
- */
-
-void PrintBytes(uint8_t* addr, uint8_t count, bool newline=0) {
-  for (uint8_t i = 0; i < count; i++) {
-    Serial.print(addr[i]>>4, HEX);
-    Serial.print(addr[i]&0x0f, HEX);
-  }
-  if (newline)
-    Serial.println();
-}
-
-void ReadAndReport(OneWire* net, uint8_t* addr) {
-  Serial.print("  Reading DS2408 ");
-  PrintBytes(addr, 8);
-  Serial.println();
-	
-  uint8_t buf[13];  // Put everything in the buffer so we can compute CRC easily.
-  buf[0] = 0xF0;    // Read PIO Registers
-  buf[1] = 0x88;    // LSB address
-  buf[2] = 0x00;    // MSB address
-  net->write_bytes(buf, 3);
-  net->read_bytes(buf+3, 10);     // 3 cmd bytes, 6 data bytes, 2 0xFF, 2 CRC16
-  net->reset();
-
-  if (!OneWire::check_crc16(buf, 11, &buf[11])) {
-    Serial.print("CRC failure in DS2408 at ");
-    PrintBytes(addr, 8, true);
-    return;
-  }
-  Serial.print("  DS2408 data = ");
-  // First 3 bytes contain command, register address.
-  Serial.println(buf[3], BIN);
-}
-
-OneWire net(10);  // on pin 10
-
-void setup(void) {
-  Serial.begin(9600);
-}
-
-void loop(void) {
-  byte i;
-  byte present = 0;
-  byte addr[8];
-  
-  if (!net.search(addr)) {
-    Serial.print("No more addresses.\n");
-    net.reset_search();
-    delay(1000);
-    return;
-  }
-  
-  if (OneWire::crc8(addr, 7) != addr[7]) {
-    Serial.print("CRC is not valid!\n");
-    return;
-  }
-  
-  if (addr[0] != 0x29) {
-    PrintBytes(addr, 8);
-    Serial.print(" is not a DS2408.\n");
-    return;
-  }
-
-  ReadAndReport(&net, addr);
-}

+ 0 - 90
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/DS250x_PROM/DS250x_PROM.pde

@@ -1,90 +0,0 @@
-/*
-DS250x add-only programmable memory reader w/SKIP ROM.
- 
- The DS250x is a 512/1024bit add-only PROM(you can add data but cannot change the old one) that's used mainly for device identification purposes
- like serial number, mfgr data, unique identifiers, etc. It uses the Maxim 1-wire bus.
- 
- This sketch will use the SKIP ROM function that skips the 1-Wire search phase since we only have one device connected in the bus on digital pin 6.
- If more than one device is connected to the bus, it will fail.
- Sketch will not verify if device connected is from the DS250x family since the skip rom function effectively skips the family-id byte readout.
- thus it is possible to run this sketch with any Maxim OneWire device in which case the command CRC will most likely fail.
- Sketch will only read the first page of memory(32bits) starting from the lower address(0000h), if more than 1 device is present, then use the sketch with search functions.
- Remember to put a 4.7K pullup resistor between pin 6 and +Vcc
- 
- To change the range or ammount of data to read, simply change the data array size, LSB/MSB addresses and for loop iterations
- 
- This example code is in the public domain and is provided AS-IS.
- 
- Built with Arduino 0022 and PJRC OneWire 2.0 library http://www.pjrc.com/teensy/td_libs_OneWire.html
- 
- created by Guillermo Lovato <glovato@gmail.com>
- march/2011
- 
- */
-
-#include <OneWire.h>
-OneWire ds(6);                    // OneWire bus on digital pin 6
-void setup() {
-  Serial.begin (9600);
-}
-
-void loop() {
-  byte i;                         // This is for the for loops
-  boolean present;                // device present var
-  byte data[32];                  // container for the data from device
-  byte leemem[3] = {              // array with the commands to initiate a read, DS250x devices expect 3 bytes to start a read: command,LSB&MSB adresses
-    0xF0 , 0x00 , 0x00   };       // 0xF0 is the Read Data command, followed by 00h 00h as starting address(the beginning, 0000h)
-  byte ccrc;                      // Variable to store the command CRC
-  byte ccrc_calc;
-
-  present = ds.reset();           // OneWire bus reset, always needed to start operation on the bus, returns a 1/TRUE if there's a device present.
-  ds.skip();                      // Skip ROM search
-
-  if (present == TRUE){           // We only try to read the data if there's a device present 
-    Serial.println("DS250x device present");
-    ds.write(leemem[0],1);        // Read data command, leave ghost power on
-    ds.write(leemem[1],1);        // LSB starting address, leave ghost power on
-    ds.write(leemem[2],1);        // MSB starting address, leave ghost power on
-
-    ccrc = ds.read();             // DS250x generates a CRC for the command we sent, we assign a read slot and store it's value
-    ccrc_calc = OneWire::crc8(leemem, 3);  // We calculate the CRC of the commands we sent using the library function and store it
-
-    if ( ccrc_calc != ccrc) {      // Then we compare it to the value the ds250x calculated, if it fails, we print debug messages and abort
-      Serial.println("Invalid command CRC!");
-      Serial.print("Calculated CRC:");
-      Serial.println(ccrc_calc,HEX);    // HEX makes it easier to observe and compare
-      Serial.print("DS250x readback CRC:");
-      Serial.println(ccrc,HEX);
-      return;                      // Since CRC failed, we abort the rest of the loop and start over
-    }
-    Serial.println("Data is: ");   // For the printout of the data 
-    for ( i = 0; i < 32; i++) {    // Now it's time to read the PROM data itself, each page is 32 bytes so we need 32 read commands
-      data[i] = ds.read();         // we store each read byte to a different position in the data array 
-      Serial.print(data[i]);       // printout in ASCII
-      Serial.print(" ");           // blank space 
-    }
-    Serial.println();
-    delay(5000);                    // Delay so we don't saturate the serial output
-  }
-  else {                           // Nothing is connected in the bus 
-    Serial.println("Nothing connected");
-    delay(3000);
-  }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 0 - 127
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/MAX31850_Temperature/MAX31850_Temperature.ino

@@ -1,127 +0,0 @@
-#include <OneWire.h>
-
-// OneWire MAX31850 or DS18B20 example!
-// Connect either/both kinds of sensors, it will automatically detect
-// the type and decode properly
-
-#define TYPE_DS18S20 0
-#define TYPE_DS18B20 1
-#define TYPE_DS18S22 2
-#define TYPE_MAX31850 3
-OneWire  ds(10);  // on pin 10 (a 4.7K pullup resistor is necessary)
-
-void setup(void) {
-  Serial.begin(9600);
-}
-
-void loop(void) {
-  byte i;
-  byte present = 0;
-  byte temptype;
-  byte data[12];
-  byte addr[8];
-  float celsius, fahrenheit;
-  
-  Serial.println(F("******************************************"));
-  if ( !ds.search(addr)) {
-    Serial.println();
-    Serial.println("No more addresses.");
-    Serial.println();
-    ds.reset_search();
-    delay(250);
-    return;
-  }
-  Serial.print("ROM =");
-  for( i = 0; i < 8; i++) {
-    Serial.write(' ');
-    Serial.print(addr[i], HEX);
-  }
-
-  if (OneWire::crc8(addr, 7) != addr[7]) {
-      Serial.println("CRC is not valid!");
-      return;
-  }
-  Serial.println();
- 
-  // the first ROM byte indicates which chip
-  switch (addr[0]) {
-    case 0x10:
-      Serial.println("  Chip = DS18S20");  // or old DS1820
-      temptype = TYPE_DS18S20;
-      break;
-    case 0x28:
-      Serial.println("  Chip = DS18B20");
-      temptype = TYPE_DS18B20;
-      break;
-    case 0x22:
-      Serial.println("  Chip = DS1822");
-      temptype = TYPE_DS18S22;
-      break;
-      // ADDED SUPPORT FOR MAX31850!
-    case 0x3B:
-      Serial.println("  Chip = MAX31850");
-      temptype = TYPE_MAX31850;
-      break;
-    default:
-      Serial.println("Device is not a DS18x20 family device.");
-      return;
-  } 
-
-  ds.reset();
-  ds.select(addr);
-  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
-  
-  delay(1000);     // maybe 750ms is enough, maybe not
-  // we might do a ds.depower() here, but the reset will take care of it.
-  
-  present = ds.reset();
-  ds.select(addr);    
-  ds.write(0xBE);         // Read Scratchpad
-
-  Serial.print("  Data = ");
-  Serial.print(present, HEX);
-  Serial.print(" ");
-  for ( i = 0; i < 9; i++) {           // we need 9 bytes
-    data[i] = ds.read();
-    Serial.print(data[i], HEX);
-    Serial.print(" ");
-  }
-  Serial.print(" CRC=");
-  Serial.print(OneWire::crc8(data, 8), HEX);
-  Serial.println();
-
-  Serial.print("  Address = 0x"); Serial.println(data[4] & 0xF, HEX);
-
-  // Convert the data to actual temperature
-  // because the result is a 16 bit signed integer, it should
-  // be stored to an "int16_t" type, which is always 16 bits
-  // even when compiled on a 32 bit processor.
-  int16_t raw = (data[1] << 8) | data[0];
-  if (temptype == TYPE_DS18S20) {
-    raw = raw << 3; // 9 bit resolution default
-    if (data[7] == 0x10) {
-      // "count remain" gives full 12 bit resolution
-      raw = (raw & 0xFFF0) + 12 - data[6];
-    }
-  } else if (temptype == TYPE_MAX31850) {
-    //Serial.println(raw, HEX);
-    if (raw & 0x01) {
-      Serial.println("**FAULT!**");
-      return;
-    }
-  } else {
-    byte cfg = (data[4] & 0x60);
-    // at lower res, the low bits are undefined, so let's zero them
-    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
-    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
-    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
-    //// default is 12 bit resolution, 750 ms conversion time
-  }
-  celsius = (float)raw / 16.0;
-  fahrenheit = celsius * 1.8 + 32.0;
-  Serial.print("  Temperature = ");
-  Serial.print(celsius);
-  Serial.print(" Celsius, ");
-  Serial.print(fahrenheit);
-  Serial.println(" Fahrenheit");
-}

+ 0 - 64
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/MAX31850_sample/MAX31850_sample.ino

@@ -1,64 +0,0 @@
-#include <OneWire.h>
-
-/* MAX31850 Temperature chip i/o */
-
-OneWire  ds(10);  // on pin 10
-
-void setup(void) {
-  Serial.begin(9600);
-}
-
-void loop(void) {
-  byte i;
-  byte present = 0;
-  byte data[12];
-  byte addr[8];
-  
-  if ( !ds.search(addr)) {
-    Serial.print("No more addresses.\n");
-    ds.reset_search();
-    delay(250);
-    return;
-  }
-  
-  Serial.print("R=");
-  for( i = 0; i < 8; i++) {
-    Serial.print(addr[i], HEX);
-    Serial.print(" ");
-  }
-
-  if ( OneWire::crc8( addr, 7) != addr[7]) {
-      Serial.print("CRC is not valid!\n");
-      return;
-  }
-  
-  if ( addr[0] != 0x3B) {
-      Serial.print("Device is not a MAX31850 family device.\n");
-      return;
-  }
-
-  // The DallasTemperature library can do all this work for you!
-
-  ds.reset();
-  ds.select(addr);
-  ds.write(0x44,1);         // start conversion, with parasite power on at the end
-  
-  delay(1000);     // maybe 750ms is enough, maybe not
-  // we might do a ds.depower() here, but the reset will take care of it.
-  
-  present = ds.reset();
-  ds.select(addr);    
-  ds.write(0xBE);         // Read Scratchpad
-
-  Serial.print("P=");
-  Serial.print(present,HEX);
-  Serial.print(" ");
-  for ( i = 0; i < 9; i++) {           // we need 9 bytes
-    data[i] = ds.read();
-    Serial.print(data[i], HEX);
-    Serial.print(" ");
-  }
-  Serial.print(" CRC=");
-  Serial.print( OneWire::crc8( data, 8), HEX);
-  Serial.println();
-}

+ 0 - 64
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/examples/sample/sample.pde

@@ -1,64 +0,0 @@
-#include <OneWire.h>
-
-/* DS18S20 Temperature chip i/o */
-
-OneWire  ds(10);  // on pin 10
-
-void setup(void) {
-  Serial.begin(9600);
-}
-
-void loop(void) {
-  byte i;
-  byte present = 0;
-  byte data[12];
-  byte addr[8];
-  
-  if ( !ds.search(addr)) {
-    Serial.print("No more addresses.\n");
-    ds.reset_search();
-    delay(250);
-    return;
-  }
-  
-  Serial.print("R=");
-  for( i = 0; i < 8; i++) {
-    Serial.print(addr[i], HEX);
-    Serial.print(" ");
-  }
-
-  if ( OneWire::crc8( addr, 7) != addr[7]) {
-      Serial.print("CRC is not valid!\n");
-      return;
-  }
-  
-  if ( addr[0] != 0x10) {
-      Serial.print("Device is not a DS18S20 family device.\n");
-      return;
-  }
-
-  // The DallasTemperature library can do all this work for you!
-
-  ds.reset();
-  ds.select(addr);
-  ds.write(0x44,1);         // start conversion, with parasite power on at the end
-  
-  delay(1000);     // maybe 750ms is enough, maybe not
-  // we might do a ds.depower() here, but the reset will take care of it.
-  
-  present = ds.reset();
-  ds.select(addr);    
-  ds.write(0xBE);         // Read Scratchpad
-
-  Serial.print("P=");
-  Serial.print(present,HEX);
-  Serial.print(" ");
-  for ( i = 0; i < 9; i++) {           // we need 9 bytes
-    data[i] = ds.read();
-    Serial.print(data[i], HEX);
-    Serial.print(" ");
-  }
-  Serial.print(" CRC=");
-  Serial.print( OneWire::crc8( data, 8), HEX);
-  Serial.println();
-}

+ 0 - 38
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/keywords.txt

@@ -1,38 +0,0 @@
-#######################################
-# Syntax Coloring Map For OneWire
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-
-OneWire	KEYWORD1
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-reset	KEYWORD2
-write_bit	KEYWORD2
-read_bit	KEYWORD2
-write	KEYWORD2
-write_bytes	KEYWORD2
-read	KEYWORD2
-read_bytes	KEYWORD2
-select	KEYWORD2
-skip	KEYWORD2
-depower	KEYWORD2
-reset_search	KEYWORD2
-search	KEYWORD2
-crc8	KEYWORD2
-crc16	KEYWORD2
-check_crc16	KEYWORD2
-
-#######################################
-# Instances (KEYWORD2)
-#######################################
-
-
-#######################################
-# Constants (LITERAL1)
-#######################################

+ 0 - 9
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/library.properties

@@ -1,9 +0,0 @@
-name=MAX31850 OneWire
-version=1.0.1
-author=Adafruit
-maintainer=Adafruit <info@adafruit.com>
-sentence=A version of the OneWire Arduino library with MAX31850 support
-paragraph=A version of the OneWire Arduino library with MAX31850 support
-category=Sensors
-url=https://github.com/adafruit/MAX31850_OneWire
-architectures=*

+ 0 - 32
SE/stuff/P5_Automation-library-dev/MAX31850_OneWire/readme.txt

@@ -1,32 +0,0 @@
-
-OneWire library for Arduino with MAX31850 support
--------------------------------------------------
-
-=================================================================
-This version is based on V2.0 from pjrc but with MAX31850 support
-=================================================================
-
-Version 2.0 fixes search bugs (thanks to Robin James) and interrupt issues.
-http://www.pjrc.com/teensy/td_libs_OneWire.html
-
-
-This is a slightly modified version of the OneWire library originally written by Jim Studt for arduino-0007 and later updated for arduino-0008 by Josh Larios.  This new version eliminates the large lookup table that was previously used by the checksum calculation - otherwise it's identical to Josh's version.  It was developed under arduino-0010.
-
-For a general description and links, see
-
-    http://www.arduino.cc/playground/Learning/OneWire
-
-Jim Studt's original verion of this library is still available at
-
-    http://www.federated.com/~jim/onewire/
-
-Josh Larios' version is available at 
-
-    http://www.elsewhere.org/onewire/
-
-To install this library, you should just have to unzip the archive in the arduino-0010/hardware/libraries directory.  It will create a subdirectory
-called 'OneWire'.
-
-Tom Pollard
-pollard@alum.mit.edu
-May 20, 2008

BIN
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/MCP2515Calc.xlsx


+ 0 - 39
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/README.md

@@ -1,39 +0,0 @@
-MCP_CAN Library for Arduino
-==============
-MCP_CAN library v1.5
-This library is compatible with any shield or board that uses the MCP2515 or MCP25625 CAN protocol controller.
-
-This version supports setting the ID filter mode of the protocol controller, the BAUD rate with clock speed with the begin() function.  Baudrates 5k, 10k, 20k, 50k, 100k, 125k, 250k, 500k, & 1000k using 16MHz clock on the MCP2515 are confirmed to work using a Peak-System PCAN-USB dongle as a reference.  Baudrates for 8MHz and 20MHz crystals are yet to be confirmed but were calculated appropiately.
-
-**The readMsgBuf() functions bring in the message ID. The getCanId() function is obsolete and no longer exists, don't use it.**
-
-The readMsgBuf(*ID, *DLC, *DATA) function will return the ID type (extended or standard) and it will bring back the remote request status bit.  
-If the ID AND 0x80000000 EQUALS 0x80000000, the ID is of the Extended type, otherwise it is standard.  
-If the ID AND 0x40000000 EQUALS 0x40000000, the message is a remote request.  
-
-The readMsgBuf(*ID, *EXT, *DLC, *DATA) function will return the ID unaltered and doesn't inform us of a remote request.  
-If EXT is true, the ID is extended.  
-  
-The sendMsgBuf(ID, DLC, DATA) function can send extended or standard IDs.  
-To mark an ID as extended, OR the ID with 0x80000000.    
-To send a remote request, OR the ID with 0x40000000.  
-  
-The sendMsgBuf(ID, EXT, DLC, DATA) has not changed other than fixing return values.  
-
-Using the setMode() function the sketch can now put the protocol controller into sleep, loop-back, or listen-only modes as well as normal operation.  Right now the code defaults to loop-back mode after the begin() function runs.  I have found this to increase the stability of filtering when the controller is initialized while connected to an active bus.
-
-User can enable and disable (default) One-Shot transmission mode from the sketch using enOneShotTX() or disOneShotTX() respectively.
-
-Installation
-==============
-Copy this into the "[.../MySketches/]libraries/" folder and restart the Arduino editor.
-
-NOTE: If an older version of the library exists (e.g. CAN_BUS_Shield) be sure to remove it from the libraries folder or replace the files with those in this library to avoid conflicts.
-
-
-Help and Support
-==============
-This is primarily for non-bug related issues: Please start a *new thread* in an appropriate area at Seeedstudio forums or Arduino.cc forums and then send me (coryjfowler) a link through the PM system, my user name is the same as it is here.  I will receive an email about the PM and generally get to it with-in a week or less.  Keep in mind, I do this in my spare time.
-
-
-*Happy Coding!*

+ 0 - 88
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_loopback/CAN_loopback.ino

@@ -1,88 +0,0 @@
-/* CAN Loopback Example
- * This example sends a message once a second and receives that message
- *   no CAN bus is required.  This example will test the functionality 
- *   of the protocol controller, and connections to it.
- *   
- *   Written By: Cory J. Fowler - October 5th 2016
- */
-
-#include <mcp_can.h>
-#include <SPI.h>
-
-// CAN TX Variables
-unsigned long prevTX = 0;                                        // Variable to store last execution time
-const unsigned int invlTX = 1000;                                // One second interval constant
-byte data[] = {0xAA, 0x55, 0x01, 0x10, 0xFF, 0x12, 0x34, 0x56};  // Generic CAN data to send
-
-// CAN RX Variables
-long unsigned int rxId;
-unsigned char len;
-unsigned char rxBuf[8];
-
-// Serial Output String Buffer
-char msgString[128];
-
-// CAN0 INT and CS
-#define CAN0_INT 2                              // Set INT to pin 2
-MCP_CAN CAN0(10);                               // Set CS to pin 10
-
-
-void setup()
-{
-  Serial.begin(115200);  // CAN is running at 500,000BPS; 115,200BPS is SLOW, not FAST, thus 9600 is crippling.
-  
-  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
-  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)
-    Serial.println("MCP2515 Initialized Successfully!");
-  else
-    Serial.println("Error Initializing MCP2515...");
-  
-  // Since we do not set NORMAL mode, we are in loopback mode by default.
-  //CAN0.setMode(MCP_NORMAL);
-
-  pinMode(CAN0_INT, INPUT);                           // Configuring pin for /INT input
-  
-  Serial.println("MCP2515 Library Loopback Example...");
-}
-
-void loop()
-{
-  if(!digitalRead(CAN0_INT))                          // If CAN0_INT pin is low, read receive buffer
-  {
-    CAN0.readMsgBuf(&rxId, &len, rxBuf);              // Read data: len = data length, buf = data byte(s)
-    
-    if((rxId & 0x80000000) == 0x80000000)             // Determine if ID is standard (11 bits) or extended (29 bits)
-      sprintf(msgString, "Extended ID: 0x%.8lX  DLC: %1d  Data:", (rxId & 0x1FFFFFFF), len);
-    else
-      sprintf(msgString, "Standard ID: 0x%.3lX       DLC: %1d  Data:", rxId, len);
-  
-    Serial.print(msgString);
-  
-    if((rxId & 0x40000000) == 0x40000000){            // Determine if message is a remote request frame.
-      sprintf(msgString, " REMOTE REQUEST FRAME");
-      Serial.print(msgString);
-    } else {
-      for(byte i = 0; i<len; i++){
-        sprintf(msgString, " 0x%.2X", rxBuf[i]);
-        Serial.print(msgString);
-      }
-    }
-        
-    Serial.println();
-  }
-  
-  if(millis() - prevTX >= invlTX){                    // Send this at a one second interval. 
-    prevTX = millis();
-    byte sndStat = CAN0.sendMsgBuf(0x100, 8, data);
-    
-    if(sndStat == CAN_OK)
-      Serial.println("Message Sent Successfully!");
-    else
-      Serial.println("Error Sending Message...");
-
-  }
-}
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 62
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_receive/CAN_receive.ino

@@ -1,62 +0,0 @@
-// CAN Receive Example
-//
-
-#include <mcp_can.h>
-#include <SPI.h>
-
-long unsigned int rxId;
-unsigned char len = 0;
-unsigned char rxBuf[8];
-char msgString[128];                        // Array to store serial string
-
-#define CAN0_INT 2                              // Set INT to pin 2
-MCP_CAN CAN0(10);                               // Set CS to pin 10
-
-
-void setup()
-{
-  Serial.begin(115200);
-  
-  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
-  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)
-    Serial.println("MCP2515 Initialized Successfully!");
-  else
-    Serial.println("Error Initializing MCP2515...");
-  
-  CAN0.setMode(MCP_NORMAL);                     // Set operation mode to normal so the MCP2515 sends acks to received data.
-
-  pinMode(CAN0_INT, INPUT);                            // Configuring pin for /INT input
-  
-  Serial.println("MCP2515 Library Receive Example...");
-}
-
-void loop()
-{
-  if(!digitalRead(CAN0_INT))                         // If CAN0_INT pin is low, read receive buffer
-  {
-    CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)
-    
-    if((rxId & 0x80000000) == 0x80000000)     // Determine if ID is standard (11 bits) or extended (29 bits)
-      sprintf(msgString, "Extended ID: 0x%.8lX  DLC: %1d  Data:", (rxId & 0x1FFFFFFF), len);
-    else
-      sprintf(msgString, "Standard ID: 0x%.3lX       DLC: %1d  Data:", rxId, len);
-  
-    Serial.print(msgString);
-  
-    if((rxId & 0x40000000) == 0x40000000){    // Determine if message is a remote request frame.
-      sprintf(msgString, " REMOTE REQUEST FRAME");
-      Serial.print(msgString);
-    } else {
-      for(byte i = 0; i<len; i++){
-        sprintf(msgString, " 0x%.2X", rxBuf[i]);
-        Serial.print(msgString);
-      }
-    }
-        
-    Serial.println();
-  }
-}
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 36
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_send/CAN_send.ino

@@ -1,36 +0,0 @@
-// CAN Send Example
-//
-
-#include <mcp_can.h>
-#include <SPI.h>
-
-MCP_CAN CAN0(10);     // Set CS to pin 10
-
-void setup()
-{
-  Serial.begin(115200);
-
-  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
-  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK) Serial.println("MCP2515 Initialized Successfully!");
-  else Serial.println("Error Initializing MCP2515...");
-
-  CAN0.setMode(MCP_NORMAL);   // Change to normal mode to allow messages to be transmitted
-}
-
-byte data[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
-
-void loop()
-{
-  // send data:  ID = 0x100, Standard CAN Frame, Data length = 8 bytes, 'data' = array of data bytes to send
-  byte sndStat = CAN0.sendMsgBuf(0x100, 0, 8, data);
-  if(sndStat == CAN_OK){
-    Serial.println("Message Sent Successfully!");
-  } else {
-    Serial.println("Error Sending Message...");
-  }
-  delay(100);   // send data per 100ms
-}
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 59
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_to_Ethernet/CAN_to_Ethernet.ino

@@ -1,59 +0,0 @@
-//  CAN to Ethernet
-//  Jan 28th, 2014
-//  Written by: Cory J. Fowler
-
-#include <mcp_can.h>
-#include <SPI.h>
-#include <Ethernet.h>
-#include <EthernetUdp.h>
-
-// Change these for your network!
-byte mac[] = {0x00, 0x55, 0x66, 0xEE, 0xFF, 0xFF};
-IPAddress      ip(10, 100, 50, 233);
-IPAddress gateway(10, 100, 50, 254);
-IPAddress    dest(10, 100, 50, 210);
-
-unsigned int localPort = 8888;
-unsigned int   remPort = 54321;
-
-unsigned long rxId;
-byte len = 0;
-byte rxBuf[8];
-char buffer[50];
-
-MCP_CAN CAN0(9);                                   // Set CS to pin 9
-
-EthernetUDP UDP;
-void setup()
-{
-  Serial.begin(115200);
-//  CAN0.begin(CAN_250KBPS);                         // init CAN Bus with 250kb/s baudrate
-  CAN0.begin(MCP_ANY, CAN_250KBPS, MCP_16MHZ);     // init CAN Bus with 250kb/s baudrate at 16MHz with Mask & Filters Disabled
-  CAN0.setMode(MCP_NORMAL);                        // Set operation mode to normal so the MCP2515 sends acks to received data.
-  pinMode(2, INPUT);                               // Setting pin 2, MCP2515 /INT, to input mode
-  Ethernet.begin(mac,ip);                          // Initialize Ethernet
-  UDP.begin(localPort);                            // Initialize the UDP listen port that is currently unused!
-
-  Serial.println("CAN to Ethernet...");
-}
-
-void loop()
-{
-    if(!digitalRead(2))                            // If pin 2 is low, read receive buffer
-    {
-      CAN0.readMsgBuf(&rxId, &len, rxBuf);         // Read Data: rxID = Message ID, len = Data Length, buf = Data Byte(s)
-//      CAN0.readMsgBuf(&len, rxBuf);                // Read Data: len = Data Length, buf = Data Byte(s)
-//      rxId = CAN0.getCanId();                      // Function will be depreciated soon due to readMsgBuf now returning ID
-
-      sprintf(buffer, "ID: %.8lX  Data: %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X\n\r",
-              rxId, rxBuf[0], rxBuf[1], rxBuf[2], rxBuf[3], rxBuf[4], rxBuf[5], rxBuf[6], rxBuf[7]);
-
-      UDP.beginPacket(dest, remPort);
-      UDP.write(buffer);
-      UDP.endPacket();
-    }
-}
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 19
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/CAN_to_Ethernet/udp_listen.pl

@@ -1,19 +0,0 @@
-#!/usr/bin/perl -w
-#This works on Debian Linux
-#I have not tested it on a Windows system running Perl, but it should work if all dependencies are met.
-#Also, FIREWALL.  <--- I gaurantee that will be the issue.
-
-use IO::Socket;
-
-### Create UDP Listen Socket
-my $udpsocket = new IO::Socket::INET (
-  LocalPort => '54321',
-  Proto => 'udp',
-  );
-  die "Could not create socket: $!\n" unless $udpsocket;
-
-### Data Manipulation and Display
-while(1) {
-    $udpsocket->recv(my $data,512);
-    print $data;
-}

+ 0 - 55
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/Dual_CAN/Dual_CAN.ino

@@ -1,55 +0,0 @@
-// Demo: Dual CAN-BUS Shields, Data Pass-through
-// Written by: Cory J. Fowler
-// January 31st 2014
-// This examples the ability of this library to support more than one MCP2515 based CAN interface.
-
-
-#include <mcp_can.h>
-#include <SPI.h>
-
-unsigned long rxId;
-byte len;
-byte rxBuf[8];
-
-byte txBuf0[] = {AA,55,AA,55,AA,55,AA,55};
-byte txBuf1[] = {55,AA,55,AA,55,AA,55,AA};
-
-MCP_CAN CAN0(10);                              // CAN0 interface usins CS on digital pin 10
-MCP_CAN CAN1(9);                               // CAN1 interface using CS on digital pin 9
-
-void setup()
-{
-  Serial.begin(115200);
-  
-  // init CAN0 bus, baudrate: 250k@16MHz
-  if(CAN0.begin(MCP_EXT, CAN_250KBPS, MCP_16MHZ) == CAN_OK){
-  Serial.print("CAN0: Init OK!\r\n");
-  CAN0.setMode(MCP_NORMAL);
-  } else Serial.print("CAN0: Init Fail!!!\r\n");
-  
-  // init CAN1 bus, baudrate: 250k@16MHz
-  if(CAN1.begin(MCP_EXT, CAN_250KBPS, MCP_16MHZ) == CAN_OK){
-  Serial.print("CAN1: Init OK!\r\n");
-  CAN1.setMode(MCP_NORMAL);
-  } else Serial.print("CAN1: Init Fail!!!\r\n");
-  
-  SPI.setClockDivider(SPI_CLOCK_DIV2);         // Set SPI to run at 8MHz (16MHz / 2 = 8 MHz)
-  
-  CAN0.sendMsgBuf(0x1000000, 1, 8, tx0Buf);
-  CAN1.sendMsgBuf(0x1000001, 1, 8, tx1Buf);
-}
-
-void loop(){  
-  if(!digitalRead(2)){                         // If pin 2 is low, read CAN0 receive buffer
-    CAN0.readMsgBuf(&rxId, &len, rxBuf);       // Read data: len = data length, buf = data byte(s)
-    CAN1.sendMsgBuf(rxId, 1, len, rxBuf);      // Immediately send message out CAN1 interface
-  }
-  if(!digitalRead(3)){                         // If pin 3 is low, read CAN1 receive buffer
-    CAN1.readMsgBuf(&rxId, &len, rxBuf);       // Read data: len = data length, buf = data byte(s)
-    CAN0.sendMsgBuf(rxId, 1, len, rxBuf);      // Immediately send message out CAN0 interface
-  }
-}
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 87
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/Extended_MaskFilter/Extended_MaskFilter.ino

@@ -1,87 +0,0 @@
-
-// MCP2515 Mask and Filter example for extended CAN message frames.
-// Written by Cory J. Fowler (20140717)
-
-/***********************************************************************************
-If you send the following extended IDs below to an Arduino loaded with this sketch
-you will find that 0x00FFCC00 and 0x00FF9900 will not get in.
-
-   ID in Hex is the same as the Filter in Hex.
-   0x00FFEE00
-   0x00FFDD00
-   0x00FFCC00  This example will NOT be receiving this ID
-   0x00FFBB00
-   0x00FFAA00
-   0x00FF9900  This example will NOT be receiving this ID
-   0x00FF8800
-   0x00FF7700
-
-   This mask will check the filters against ID bits 23 through 8.
-   (Those familiar with J1939 might see why I used this mask.)
-    MASK = 0x00FFFF00
-   If there is an explicit filter match to those bits, the message will be passed to the
-   receive buffer and the interrupt pin will be set.
-   
-   This example will NOT be exclusive to ONLY the above message IDs, for that a mask such
-   as the below would be used: 
-    MASK = 0x1FFFFFFF
-   
-   At the moment, to disable a filter or mask, copy the value of a used filter or mask.
-   
-***********************************************************************************/
-
-
-#include <mcp_can.h>
-#include <SPI.h>
-
-long unsigned int rxId;
-unsigned char len = 0;
-unsigned char rxBuf[8];
-
-MCP_CAN CAN0(10);                          // Set CS to pin 10
-
-void setup()
-{
-  Serial.begin(115200);
-  if(CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_16MHZ) == CAN_OK) Serial.print("MCP2515 Init Okay!!\r\n");
-  else Serial.print("MCP2515 Init Failed!!\r\n");
-  pinMode(2, INPUT);                       // Setting pin 2 for /INT input
-
-  CAN0.init_Mask(0,1,0x00FFFF00);                // Init first mask...
-  CAN0.init_Filt(0,1,0x00FFEE00);                // Init first filter...
-  CAN0.init_Filt(1,1,0x00FFDD00);                // Init second filter...
-  
-  CAN0.init_Mask(1,1,0x00FFFF00);                // Init second mask... 
-  CAN0.init_Filt(2,1,0x00FFBB00);                // Init third filter...
-  CAN0.init_Filt(3,1,0x00FFAA00);                // Init fouth filter...
-  CAN0.init_Filt(4,1,0x00FF8800);                // Init fifth filter...
-  CAN0.init_Filt(5,1,0x00FF7700);                // Init sixth filter...
-  
-  Serial.println("MCP2515 Library Mask & Filter Example...");
-  CAN0.setMode(MCP_NORMAL);                // Change to normal mode to allow messages to be transmitted
-}
-
-void loop()
-{
-    if(!digitalRead(2))                    // If pin 2 is low, read receive buffer
-    {
-      CAN0.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s)
-      Serial.print("ID: ");
-      Serial.print(rxId, HEX);
-      Serial.print(" Data: ");
-      for(int i = 0; i<len; i++)           // Print each byte of the data
-      {
-        if(rxBuf[i] < 0x10)                // If data byte is less than 0x10, add a leading zero
-        {
-          Serial.print("0");
-        }
-        Serial.print(rxBuf[i], HEX);
-        Serial.print(" ");
-      }
-      Serial.println();
-    }
-}
-
-/*********************************************************************************************************
-END FILE
-*********************************************************************************************************/

+ 0 - 1046
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/OBD_Sim/OBD_Sim.ino

@@ -1,1046 +0,0 @@
-/* CAN OBD & UDS Simulator
- *  
- *  Currently replies to some general OBD requests 
- *  Place holders exist for what I've been able to locate on the Internet
- *  Does not currently support UDS correctly, just placeholders with mode descriptions
- *  
- *  Written By: Cory J. Fowler  December 20th, 2016
- *  
- */ 
-
-#include <mcp_can.h>
-#include <SPI.h>
-
-
-#define PAD 0x00
-
-// What CAN ID type?  Standard or Extended
-#define standard 0
-
-// 7E0/8 = Engine ECM
-// 7E1/9 = Transmission ECM
-
-#if standard == 1
-  #define REPLY_ID 0x7E9
-  #define LISTEN_ID 0x7E1
-  #define FUNCTIONAL_ID 0x7DF  
-#else
-  #define REPLY_ID 0x98DAF101
-  #define LISTEN_ID 0x98DA01F1
-  #define FUNCTIONAL_ID 0x98DB33F1
-#endif
-
-
-// CAN RX Variables
-unsigned long rxId;
-byte dlc;
-byte rxBuf[8];
-
-// CAN Interrupt and Chip Select
-#define CAN0_INT 2                              // Set CAN0 INT to pin 2
-MCP_CAN CAN0(9);                                // Set CAN0 CS to pin 9
-
-
-void setup()
-{
-  Serial.begin(115200);
-  while(!Serial);
-  
-  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
-  if(CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_20MHZ) == CAN_OK)
-    Serial.println("MCP2515 Initialized Successfully!");
-  else
-    Serial.println("Error Initializing MCP2515...");
-
-
-#if standard == 1
-  // Standard ID Filters
-  CAN0.init_Mask(0,0x7F00000);                // Init first mask...
-  CAN0.init_Filt(0,0x7DF0000);                // Init first filter...
-  CAN0.init_Filt(1,0x7E10000);                // Init second filter...
-  
-  CAN0.init_Mask(1,0x7F00000);                // Init second mask... 
-  CAN0.init_Filt(2,0x7DF0000);                // Init third filter...
-  CAN0.init_Filt(3,0x7E10000);                // Init fouth filter...
-  CAN0.init_Filt(4,0x7DF0000);                // Init fifth filter...
-  CAN0.init_Filt(5,0x7E10000);                // Init sixth filter...
-
-#else
-  // Extended ID Filters
-  CAN0.init_Mask(0,0x90FFFF00);                // Init first mask...
-  CAN0.init_Filt(0,0x90DB3300);                // Init first filter...
-  CAN0.init_Filt(1,0x90DA0100);                // Init second filter...
-  
-  CAN0.init_Mask(1,0x90FFFF00);                // Init second mask... 
-  CAN0.init_Filt(2,0x90DB3300);                // Init third filter...
-  CAN0.init_Filt(3,0x90DA0100);                // Init fouth filter...
-  CAN0.init_Filt(4,0x90DB3300);                // Init fifth filter...
-  CAN0.init_Filt(5,0x90DA0100);                // Init sixth filter...
-#endif
-  
-  CAN0.setMode(MCP_NORMAL);                          // Set operation mode to normal so the MCP2515 sends acks to received data.
-
-  pinMode(CAN0_INT, INPUT);                          // Configuring pin for /INT input
-  
-  Serial.println("OBD-II CAN Simulator");
-}
-
-void loop()
-{
-  if(!digitalRead(CAN0_INT))                         // If CAN0_INT pin is low, read receive buffer
-  {
-    CAN0.readMsgBuf(&rxId, &dlc, rxBuf);             // Get CAN data
-    
-    // First request from most adapters...
-    if(rxId == FUNCTIONAL_ID){
-      obdReq(rxBuf);
-    }       
-  }
-}
-
-
-void obdReq(byte *data){
-  byte numofBytes = data[0];
-  byte mode = data[1] & 0x0F;
-  byte pid = data[2];
-  bool tx = false;
-  byte txData[] = {0x00,(0x40 | mode),pid,PAD,PAD,PAD,PAD,PAD};
-
-  
-  //txData[1] = 0x40 | mode;
-  //txData[2] = pid; 
-  
-  //=============================================================================
-  // MODE $01 - Show current data
-  //=============================================================================
-  if(mode == 0x01){
-    if(pid == 0x00){        // Supported PIDs 01-20
-      txData[0] = 0x06;
-      
-      txData[3] = 0x80;
-      txData[4] = 0x38;
-      txData[5] = 0x00;
-      txData[6] = 0x01;
-      tx = true;
-    }
-    else if(pid == 0x01){    // Monitor status since DTs cleared.
-      bool MIL = true;
-      byte DTC = 5;
-      txData[0] = 0x06;
-      
-      txData[3] = (MIL << 7) | (DTC & 0x7F);
-      txData[4] = 0x07;
-      txData[5] = 0xFF;
-      txData[6] = 0x00;
-      tx = true;
-    }
-//    else if(pid == 0x02){    // Freeze DTC
-//    }
-    else if(pid == 0x03){    // Fuel system status
-      txData[0] = 0x03;
-      
-      txData[3] = 0xFA;
-      tx = true;
-    }
-//    else if(pid == 0x04){    // Calculated engine load
-//    }
-    else if(pid == 0x05){    // Engine coolant temperature
-      txData[0] = 0x03;
-      
-      txData[3] = 0xFA;
-      tx = true;
-    }
-//    else if(pid == 0x06){    // Short term fuel trim - Bank 1
-//    }
-//    else if(pid == 0x07){    // Long tern fuel trim - Bank 1
-//    }
-//    else if(pid == 0x08){    // Short term fuel trim - Bank 2
-//    }
-//    else if(pid == 0x09){    // Long term fuel trim - Bank 2
-//    }
-//    else if(pid == 0x0A){    // Fuel pressure (gauge)
-//    }
-    else if(pid == 0x0B){    // Intake manifold absolute pressure
-      txData[0] = 0x03;
-      
-      txData[3] = 0x64;
-      tx = true;
-    }
-    else if(pid == 0x0C){    // Engine RPM
-      txData[0] = 0x04;
-      
-      txData[3] = 0x9C;
-      txData[4] = 0x40;
-      tx = true;
-    }
-    else if(pid == 0x0D){    // Vehicle speed
-      txData[0] = 0x03;
-      
-      txData[3] = 0xFA;
-      tx = true;
-    }
-//    else if(pid == 0x0E){    // Timing advance
-//    }
-    else if(pid == 0x0F){    // Intake air temperature
-      txData[0] = 0x03;
-      
-      txData[3] = 0xFA;
-      tx = true;
-    }
-//    else if(pid == 0x10){    // MAF air flow rate
-//    }
-    else if(pid == 0x11){    // Throttle position
-      txData[0] = 0x03;
-      
-      txData[3] = 0xFA;
-      tx = true;
-    }
-//    else if(pid == 0x12){    // Commanded secondary air status
-//    }
-//    else if(pid == 0x13){    // Oxygen sensors present (in 2 banks)
-//    }
-//    else if(pid == 0x14){    // Oxygen Sensor 1 (Voltage & Trim)
-//    }
-//    else if(pid == 0x15){    // Oxygen Sensor 2 (Voltage & Trim)
-//    }
-//    else if(pid == 0x16){    // Oxygen Sensor 3 (Voltage & Trim)
-//    }
-//    else if(pid == 0x17){    // Oxygen Sensor 4 (Voltage & Trim)
-//    }
-//    else if(pid == 0x18){    // Oxygen Sensor 5 (Voltage & Trim)
-//    }
-//    else if(pid == 0x19){    // Oxygen Sensor 6 (Voltage & Trim)
-//    }
-//    else if(pid == 0x1A){    // Oxygen Sensor 7 (Voltage & Trim)
-//    }
-//    else if(pid == 0x1B){    // Oxygen Sensor 8 (Voltage & Trim)
-//    }
-//    else if(pid == 0x1C){    // OBD standards this vehicle conforms to
-//    }
-//    else if(pid == 0x1D){    // Oxygen sensors present (in 4 banks)
-//    }
-//    else if(pid == 0x1E){    // Auxillary input status
-//    }
-//    else if(pid == 0x1F){    // Run time since engine start
-//    }
-    else if(pid == 0x20){    // Supported PIDs 21-40
-      txData[0] = 0x06;
-      
-      txData[3] = 0x80;
-      txData[4] = 0x00;
-      txData[5] = 0x00;
-      txData[6] = 0x01;
-      tx = true;
-    }
-    else if(pid == 0x21){    // Distance traveled with MIL on
-      txData[0] = 0x04;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x23;
-      tx = true;
-    }
-//    else if(pid == 0x22){    // Fuel rail pressure (Relative to Manifold Vacuum)
-//    }
-//    else if(pid == 0x23){    // Fuel rail gauge pressure (diesel or gasoline direct injection)
-//    }
-//    else if(pid == 0x24){    // Oxygen Sensor 1 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x25){    // Oxygen Sensor 2 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x26){    // Oxygen Sensor 3 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x27){    // Oxygen Sensor 4 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x28){    // Oxygen Sensor 5 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x29){    // Oxygen Sensor 6 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x2A){    // Oxygen Sensor 7 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x2B){    // Oxygen Sensor 8 (Fuel to Air & Voltage)
-//    }
-//    else if(pid == 0x2C){    // Commanded EGR
-//    }
-//    else if(pid == 0x2D){    // EGR Error
-//    }
-//    else if(pid == 0x2E){    // Commanded evaporative purge
-//    }
-//    else if(pid == 0x2F){    // Fuel tank level input
-//    }
-//    else if(pid == 0x30){    // Warm-ups since codes cleared
-//    }
-//    else if(pid == 0x31){    // Distance traveled since codes cleared
-//    }
-//    else if(pid == 0x32){    // Evap. System Vapor Pressure
-//    }
-//    else if(pid == 0x33){    // Absolute Barometric Pressure
-//    }
-//    else if(pid == 0x34){    // Oxygen Sensor 1 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x35){    // Oxygen Sensor 2 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x36){    // Oxygen Sensor 3 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x37){    // Oxygen Sensor 4 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x38){    // Oxygen Sensor 5 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x39){    // Oxygen Sensor 6 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x3A){    // Oxygen Sensor 7 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x3B){    // Oxygen Sensor 8 (Fuel to Air & Current) 
-//    }
-//    else if(pid == 0x3C){    // Catalyst Temperature: Bank 1, Sensor 1
-//    }
-//    else if(pid == 0x3D){    // Catalyst Temperature: Bank 2, Sensor 1
-//    }
-//    else if(pid == 0x3E){    // Catalyst Temperature: Bank 1, Sensor 2
-//    }
-//    else if(pid == 0x3F){    // Catalyst Temperature: Bank 2, Sensor 2
-//    }
-    else if(pid == 0x40){    // Supported PIDs 41-60
-      txData[0] = 0x06;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x08;
-      txData[5] = 0x00;
-      txData[6] = 0x0D;
-      tx = true;
-    }
-//    else if(pid == 0x41){    // Monitor status this drive cycle
-//    }
-//    else if(pid == 0x42){    // Control module voltage
-//    }
-//    else if(pid == 0x43){    // Absolute load value
-//    }
-//    else if(pid == 0x44){    // Fuel-Air commanded equivalence ratio
-//    }
-//    else if(pid == 0x45){    // Relative throttle position
-//    }
-//    else if(pid == 0x46){    // Ambient air temperature
-//    }
-//    else if(pid == 0x47){    // Absolute throttle postion B
-//    }
-//    else if(pid == 0x48){    // Absolute throttle postion C
-//    }
-//    else if(pid == 0x49){    // Accelerator pedal position D
-//    }
-//    else if(pid == 0x4A){    // Accelerator pedal position E
-//    }
-//    else if(pid == 0x4B){    // Accelerator pedal position F
-//    }
-//    else if(pid == 0x4C){    // Commanded throttle actuator
-//    }
-    else if(pid == 0x4D){    // Time run with MIL on
-      txData[0] = 0x04;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x3C;
-      tx = true;
-    }
-//    else if(pid == 0x4E){    // Time since troble codes cleared
-//    }
-//    else if(pid == 0x4F){    // Time since trouble codes cleared
-//    }
-//    else if(pid == 0x50){    // Maximum value for Fuel-Air equivalence ratio, oxygen sensor voltage, oxygen sensro current, and intake manifold absolute-pressure
-//    }
-//    else if(pid == 0x51){    // Fuel Type
-//    }
-//    else if(pid == 0x52){    // Ethanol Fuel %
-//    }
-//    else if(pid == 0x53){    // Absolute evap system vapor pressure
-//    }
-//    else if(pid == 0x54){    // Evap system vapor pressure
-//    }
-//    else if(pid == 0x55){    // Short term secondary oxygen sensor trim, A: bank 1, B: bank 3
-//    }
-//    else if(pid == 0x56){    // Long term secondary oxygen sensor trim, A: bank 1, B: bank 3
-//    }
-//    else if(pid == 0x57){    // Short term secondary oxygen sensor trim, A: bank 2, B: bank 4
-//    }
-//    else if(pid == 0x58){    // Long term secondary oxygen sensor trim, A: bank 2, B: bank 4
-//    }
-//    else if(pid == 0x59){    // Fuel rail absolute pressure
-//    }
-//    else if(pid == 0x5A){    // Relative accelerator pedal position
-//    }
-//    else if(pid == 0x5B){    // Hybrid battery pack remaining life
-//    }
-    else if(pid == 0x5C){    // Engine oil Temperature
-      txData[0] = 0x03;
-      
-      txData[3] = 0x1E;
-      tx = true;
-    }
-    else if(pid == 0x5D){    // Fuel injection timing
-      txData[0] = 0x04;
-      
-      txData[3] = 0x61;
-      txData[4] = 0x80;
-      tx = true;
-    }
-    else if(pid == 0x5E){    // Engine fuel rate
-      txData[0] = 0x04;
-      
-      txData[3] = 0x07;
-      txData[4] = 0xD0;
-      tx = true;
-    }
-//    else if(pid == 0x5F){    // Emissions requirements to which vehicle is designed
-//    }
-    else if(pid == 0x60){    // Supported PIDs 61-80
-      txData[0] = 0x06;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x00;
-      txData[5] = 0x00;
-      txData[6] = 0x01;
-      tx = true;
-    }
-//    else if(pid == 0x61){    // Driver's demand engine - percent torque
-//    }
-//    else if(pid == 0x62){    // Actual engine - percent torque
-//    }
-//    else if(pid == 0x63){    // Engine reference torque
-//    }
-//    else if(pid == 0x64){    // Engine percent torque data
-//    }
-//    else if(pid == 0x65){    // Auxiliary input / output supported
-//    }
-//    else if(pid == 0x66){    // Mas air flow sensor
-//    }
-//    else if(pid == 0x67){    // Engine coolant temperature
-//    }
-//    else if(pid == 0x68){    // Intake air temperature sensor
-//    }
-//    else if(pid == 0x69){    // Commanded EGR and EGR error
-//    }
-//    else if(pid == 0x6A){    // Commanded Diesel intake air flow control and relative intake air flow position
-//    }
-//    else if(pid == 0x6B){    // Exhaust gas recirculation temperature
-//    }
-//    else if(pid == 0x6C){    // Commanded throttle actuator control and relative throttle position
-//    }
-//    else if(pid == 0x6D){    // Fuel pressure control system
-//    }
-//    else if(pid == 0x6E){    // Injection pressure control system
-//    }
-//    else if(pid == 0x6F){    // Turbocharger compressor inlet pressure
-//    }
-//    else if(pid == 0x70){    // Boost pressure control
-//    }
-//    else if(pid == 0x71){    // Variable Geometry turbo sensor
-//    }
-//    else if(pid == 0x72){    // Wastegate control
-//    }  
-//    else if(pid == 0x73){    // Exhaust pressure
-//    }
-//    else if(pid == 0x74){    // Turbocharger RPM
-//    }
-//    else if(pid == 0x75){    // Turbocharger temperature
-//    }
-//    else if(pid == 0x76){    // Turbocharger temperature
-//    }
-//    else if(pid == 0x77){    // Charge air cooler temperature (CACT)
-//    }
-//    else if(pid == 0x78){    // Exhaust Gas Temperature (EGT) bank 1
-//    }
-//    else if(pid == 0x79){    // Exhaust Gas Temperature (EGT) bank 2
-//    }
-//    else if(pid == 0x7A){    // Diesel particulate filter (DPF)
-//    }
-//    else if(pid == 0x7B){    // Diesel particulate filter (DPF)
-//    }
-//    else if(pid == 0x7C){    // Diesel particulate filter (DPF) temperature
-//    }
-//    else if(pid == 0x7D){    // NOx NTE control area status
-//    }
-//    else if(pid == 0x7E){    // PM NTE control area status
-//    }
-//    else if(pid == 0x7F){    // Engine run time
-//    }
-    else if(pid == 0x80){    // Supported PIDs 81-A0
-      txData[0] = 0x06;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x00;
-      txData[5] = 0x00;
-      txData[6] = 0x01;
-      tx = true;
-    }
-//    else if(pid == 0x81){    // Engine run time for Auxiliary Emissions Control Device (AECD)
-//    }
-//    else if(pid == 0x82){    // Engine run time for Auxiliary Emissions Control Device (AECD)
-//    }  
-//    else if(pid == 0x83){    // NOx sensor
-//    }
-//    else if(pid == 0x84){    // Manifold surface temperature
-//    }
-//    else if(pid == 0x85){    // NOx reqgent system
-//    }
-//    else if(pid == 0x86){    // Particulate Matter (PM) sensor
-//    }
-//    else if(pid == 0x87){    // Intake manifold absolute pressure
-//    }
-    else if(pid == 0xA0){    // Supported PIDs A1-C0
-      txData[0] = 0x06;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x00;
-      txData[5] = 0x00;
-      txData[6] = 0x01;
-      tx = true;
-    }
-    else if(pid == 0xC0){    // Supported PIDs C1-E0
-      txData[0] = 0x06;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x00;
-      txData[5] = 0x00;
-      txData[6] = 0x01;
-      tx = true;
-    }
-    else if(pid == 0xE0){    // Supported PIDs E1-FF?
-      txData[0] = 0x06;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x00;
-      txData[5] = 0x00;
-      txData[6] = 0x00;
-      tx = true;
-    }
-    else{
-      unsupported(mode, pid);
-    }
-  }
-  
-  //=============================================================================
-  // MODE $02 - Show freeze frame data
-  //=============================================================================
-  else if(mode == 0x02){
-      unsupported(mode, pid);
-  }
-  
-  //=============================================================================
-  // MODE $03 - Show stored DTCs
-  //=============================================================================
-  else if(mode == 0x03){
-      byte DTCs[] = {(0x40 | mode), 0x05, 0xC0, 0xBA, 0x00, 0x11, 0x80, 0x13, 0x90, 0x45, 0xA0, 0x31};
-      iso_tp(mode, pid, 12, DTCs);
-  }
-  
-  //=============================================================================
-  // MODE $04 - Clear DTCs and stored values
-  //=============================================================================
-  else if(mode == 0x04){
-      // Need to cleat DTCs.  We just acknowledge the command for now.
-      txData[0] = 0x01;
-      tx = true;
-  }
-  
-  //=============================================================================
-  // MODE $05 - Test Results, oxygen sensor monitoring (non CAN only)
-  //=============================================================================
-  else if(mode == 0x05){
-      unsupported(mode, pid);
-  }
-  
-  //=============================================================================
-  // MODE $06 - Test Results, On-Board Monitoring (Oxygen sensor monitoring for CAN only)
-  //=============================================================================
-  else if(mode == 0x06){
-    if(pid == 0x00){        // Supported PIDs 01-20
-      txData[0] = 0x06;
-      
-      txData[3] = 0x00;
-      txData[4] = 0x00;
-      txData[5] = 0x00;
-      txData[6] = 0x00;
-      tx = true;
-    }
-    else{
-      unsupported(mode, pid);
-    }
-  }
-  
-  //=============================================================================
-  // MODE $07 - Show pending DTCs (Detected during current or last driving cycle)
-  //=============================================================================
-  else if(mode == 0x07){
-      byte DTCs[] = {(0x40 | mode), 0x05, 0xC0, 0xBA, 0x00, 0x11, 0x80, 0x13, 0x90, 0x45, 0xA0, 0x31};
-      iso_tp(mode, pid, 12, DTCs);
-  }
-  
-  //=============================================================================
-  // MODE $08 - Control operation of on-board component/system
-  //=============================================================================
-  else if(mode == 0x08){
-      unsupported(mode, pid);
-  }
-  
-  //=============================================================================
-  // MODE $09 - Request vehcile information
-  //=============================================================================
-  else if(mode == 0x09){
-    if(pid == 0x00){        // Supported PIDs 01-20
-      txData[0] = 0x06;
-      
-      txData[3] = 0x54;
-      txData[4] = 0x40;
-      txData[5] = 0x00;
-      txData[6] = 0x00;
-      tx = true;
-    }
-//    else if(pid == 0x01){    // VIN message count for PID 02. (Only for ISO 9141-2, ISO 14230-4 and SAE J1850.)
-//    }
-    else if(pid == 0x02){    // VIN (17 to 20 Bytes) Uses ISO-TP
-      byte VIN[] = {(0x40 | mode), pid, 0x01, 0x31, 0x5a, 0x56, 0x42, 0x50, 0x38, 0x41, 0x4d, 0x37, 0x44, 0x35, 0x32, 0x32, 0x30, 0x31, 0x38, 0x31};
-      iso_tp(mode, pid, 20, VIN);
-    }
-//    else if(pid == 0x03){    // Calibration ID message count for PID 04. (Only for ISO 9141-2, ISO 14230-4 and SAE J1850.)
-//    }
-    else if(pid == 0x04){    // Calibration ID
-      byte CID[] = {(0x40 | mode), pid, 0x01, 0x41, 0x72, 0x64, 0x75, 0x69, 0x6E, 0x6F, 0x20, 0x4F, 0x42, 0x44, 0x49, 0x49, 0x73, 0x69, 0x6D, 0x51, 0x52, 0x53, 0x54};
-      iso_tp(mode, pid, 23, CID);
-    }
-//    else if(pid == 0x05){    // Calibration Verification Number (CVN) message count for PID 06. (Only for ISO 9141-2, ISO 14230-4 and SAE J1850.)
-//    }
-    else if(pid == 0x06){    // CVN
-      byte CVN[] = {(0x40 | mode), pid, 0x02, 0x11, 0x42, 0x42, 0x42, 0x22, 0x43, 0x43, 0x43};
-      iso_tp(mode, pid, 11, CVN);
-    }
-//    else if(pid == 0x07){    // In-use performance tracking message count for PID 08 and 0B. (Only for ISO 9141-2, ISO 14230-4 and SAE J1850.)
-//    }
-//    else if(pid == 0x08){    // In-use performance tracking for spark ignition vehicles.
-//    }
-//    else if(pid == 0x09){    // ECU name message count for PID 0A.
-//    }
-    else if(pid == 0x0A){    // ECM Name
-      byte ECMname[] = {(0x40 | mode), pid, 0x01, 0x45, 0x43, 0x4D, 0x00, 0x2D, 0x41, 0x72, 0x64, 0x75, 0x69, 0x6E, 0x6F, 0x4F, 0x42, 0x44, 0x49, 0x49, 0x73, 0x69, 0x6D};
-      iso_tp(mode, pid, 23, ECMname);
-    }
-//    else if(pid == 0x0B){    // In-use performance tracking for compression ignition vehicles.
-//    }
-//    else if(pid == 0x0C){    // ESN message count for PID 0D.
-//    }
-    else if(pid == 0x0D){    // ESN
-      byte ESN[] = {(0x40 | mode), pid, 0x01, 0x41, 0x72, 0x64, 0x75, 0x69, 0x6E, 0x6F, 0x2D, 0x4F, 0x42, 0x44, 0x49, 0x49, 0x73, 0x69, 0x6D, 0x00};
-      iso_tp(mode, pid, 20, ESN);
-    }
-    else{
-      unsupported(mode, pid); 
-    }
-  }
-  
-  //=============================================================================
-  // MODE $0A - Show permanent DTCs 
-  //=============================================================================
-  else if(mode == 0x0A){
-      byte DTCs[] = {(0x40 | mode), 0x05, 0xC0, 0xBA, 0x00, 0x11, 0x80, 0x13, 0x90, 0x45, 0xA0, 0x31};
-      iso_tp(mode, pid, 12, DTCs);
-  }
-  
-  // UDS Modes: Diagonstic and Communications Management =======================================
-  //=============================================================================
-  // MODE $10 - Diagnostic Session Control
-  //=============================================================================
-//  else if(mode == 0x10){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $11 - ECU Reset
-  //=============================================================================
-//  else if(mode == 0x11){
-//      txData[0] = 0x02;
-//      
-//      txData[2] = mode;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $27 - Security Access
-  //=============================================================================
-//  else if(mode == 0x27){
-//      txData[0] = 0x02;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $28 - Communication Control
-  //=============================================================================
-//  else if(mode == 0x28){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $3E - Tester Present
-  //=============================================================================
-//  else if(mode == 0x3E){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $83 - Access Timing Parameters
-  //=============================================================================
-//  else if(mode == 0x83){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $84 - Secured Data Transmission
-  //=============================================================================
-//  else if(mode == 0x84){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-//  
-  //=============================================================================
-  // MODE $85 - Control DTC Sentings
-  //=============================================================================
-//  else if(mode == 0x85){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $86 - Response On Event
-  //=============================================================================
-//  else if(mode == 0x86){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $87 - Link Control
-  //=============================================================================
-//  else if(mode == 0x87){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  // UDS Modes: Data Transmission ==============================================================
-  //=============================================================================
-  // MODE $22 - Read Data By Identifier
-  //=============================================================================
-//  else if(mode == 0x22){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $23 - Read Memory By Address
-  //=============================================================================
-//  else if(mode == 0x23){
-//      txData[0] = 0x02;
-//      
-//      txData[2] = mode;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $24 - Read Scaling Data By Identifier
-  //=============================================================================
-//  else if(mode == 0x24){
-//      txData[0] = 0x02;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $2A - Read Data By Periodic Identifier
-  //=============================================================================
-//  else if(mode == 0x2A){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $2C - Dynamically Define Data Identifier
-  //=============================================================================
-//  else if(mode == 0x2C){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $2E - Write Data By Identifier
-  //=============================================================================
-//  else if(mode == 0x2E){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $3D - Write Memory By Address
-  //=============================================================================
-//  else if(mode == 0x3D){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  // UDS Modes: Stored Data Transmission =======================================================
-  //=============================================================================
-  // MODE $14 - Clear Diagnostic Information
-  //=============================================================================
-//  else if(mode == 0x14){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $19 - Read DTC Information
-  //=============================================================================
-//  else if(mode == 0x19){
-//      txData[0] = 0x02;
-//      
-//      txData[2] = mode;
-//      tx = true;
-//  }
-  
-  // UDS Modes: Input Output Control ===========================================================
-  //=============================================================================
-  // MODE $2F - Input Output Control By Identifier
-  //=============================================================================
-//  else if(mode == 0x2F){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  // UDS Modes: Remote Activation of Routine ===================================================
-  //=============================================================================
-  // MODE $31 - Routine Control
-  //=============================================================================
-//  else if(mode == 0x2F){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  // UDS Modes: Upload / Download ==============================================================
-  //=============================================================================
-  // MODE $34 - Request Download
-  //=============================================================================
-//  else if(mode == 0x34){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $35 - Request Upload
-  //=============================================================================
-//  else if(mode == 0x35){
-//      txData[0] = 0x02;
-//      
-//      txData[2] = mode;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $36 - Transfer Data
-  //=============================================================================
-//  else if(mode == 0x36){
-//      txData[0] = 0x02;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $37 - Request Transfer Exit
-  //=============================================================================
-//  else if(mode == 0x37){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  
-  //=============================================================================
-  // MODE $38 - Request File Transfer
-  //=============================================================================
-//  else if(mode == 0x38){
-//      txData[0] = 0x03;
-//      
-//      txData[2] = mode;
-//      txData[3] = 0x00;
-//      tx = true;
-//  }
-  else { 
-    unsupported(mode, pid);
-  }
-  
-  if(tx)
-    CAN0.sendMsgBuf(REPLY_ID, 8, txData);
-}
-
-
-// Generic debug serial output
-void unsupported(byte mode, byte pid){
-  negAck(mode, 0x12);
-  unsupportedPrint(mode, pid);  
-}
-
-
-// Generic debug serial output
-void negAck(byte mode, byte reason){
-  byte txData[] = {0x03,0x7F,mode,reason,PAD,PAD,PAD,PAD};
-  CAN0.sendMsgBuf(REPLY_ID, 8, txData);
-}
-
-
-// Generic debug serial output
-void unsupportedPrint(byte mode, byte pid){
-  char msgstring[64];
-  sprintf(msgstring, "Mode $%02X: Unsupported PID $%02X requested!", mode, pid);
-  Serial.println(msgstring);
-}
-
-
-// Blocking example of ISO transport
-void iso_tp(byte mode, byte pid, int len, byte *data){
-  byte tpData[8];
-  int offset = 0;
-  byte index = 0;
-//  byte packetcnt = ((len & 0x0FFF) - 6) / 7;
-//  if((((len & 0x0FFF) - 6) % 7) > 0)
-//    packetcnt++;
-
-  // First frame
-  tpData[0] = 0x10 | ((len >> 8) & 0x0F);
-  tpData[1] = 0x00FF & len;
-  for(byte i=2; i<8; i++){
-    tpData[i] = data[offset++];
-  }
-  CAN0.sendMsgBuf(REPLY_ID, 8, tpData);
-  index++; // We sent a packet so increase our index.
-  
-  bool not_done = true;
-  unsigned long sepPrev = millis();
-  byte sepInvl = 0;
-  byte frames = 0;
-  bool lockout = false;
-  while(not_done){
-    // Need to wait for flow frame
-    if(!digitalRead(CAN0_INT)){
-      CAN0.readMsgBuf(&rxId, &dlc, rxBuf);
-    
-      if((rxId == LISTEN_ID) && ((rxBuf[0] & 0xF0) == 0x30)){
-        if((rxBuf[0] & 0x0F) == 0x00){
-          // Continue
-          frames = rxBuf[1];
-          sepInvl = rxBuf[2];
-          lockout = true;
-        } else if((rxBuf[0] & 0x0F) == 0x01){
-          // Wait
-          lockout = false;
-          delay(rxBuf[2]);
-        } else if((rxBuf[0] & 0x0F) == 0x03){
-          // Abort
-          not_done = false;
-          return;
-        }
-      }
-    }
-
-    if(((millis() - sepPrev) >= sepInvl) && lockout){
-      sepPrev = millis();
-
-      tpData[0] = 0x20 | index++;
-      for(byte i=1; i<8; i++){
-        if(offset != len)
-          tpData[i] = data[offset++];
-        else
-          tpData[i] = 0x00;
-      }
-      
-      // Do consecutive frames as instructed via flow frame
-      CAN0.sendMsgBuf(REPLY_ID, 8, tpData);
-      
-      if(frames-- == 1)
-        lockout = false;
-        
-    }
-
-    if(offset == len)
-      not_done = false;
-    else{
-      char msgstring[32];
-      sprintf(msgstring,"Offset: 0x%04X\tLen: 0x%04X", offset, len);
-      Serial.println(msgstring);
-    }
-
-
-    // Timeout
-    if((millis() - sepPrev) >= 1000)
-      not_done = false;
-  }
-  
-}
-  
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 94
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/examples/Standard_MaskFilter/Standard_MaskFilter.ino

@@ -1,94 +0,0 @@
-
-// MCP2515 Mask and Filter example for standard CAN message frames.
-// Written by Cory J. Fowler (20140717)
-
-/***********************************************************************************
-If you send the following standard IDs below to an Arduino loaded with this sketch
-you will find that 0x102 and 0x105 will not get in.
-
-ID in Hex  -   Two Data Bytes!   -  Filter/Mask in HEX
-   0x100   + 0000 0000 0000 0000 =   0x01000000
-   0x101   + 0000 0000 0000 0000 =   0x01010000
-   0x102   + 0000 0000 0000 0000 =   0x01020000  This example will NOT be receiving this ID
-   0x103   + 0000 0000 0000 0000 =   0x01030000
-   0x104   + 0000 0000 0000 0000 =   0x01040000
-   0x105   + 0000 0000 0000 0000 =   0x01050000  This example will NOT be receiving this ID
-   0x106   + 0000 0000 0000 0000 =   0x01060000
-   0x107   + 0000 0000 0000 0000 =   0x01070000
-
-   This mask will check the filters against ID bit 8 and ID bits 3-0.   
-    MASK   + 0000 0000 0000 0000 =   0x010F0000
-   
-   If there is an explicit filter match to those bits, the message will be passed to the
-   receive buffer and the interrupt pin will be set.
-   This example will NOT be exclusive to ONLY the above frame IDs, for that a mask such
-   as the below would be used: 
-    MASK   + 0000 0000 0000 0000 = 0x07FF0000
-    
-   This mask will check the filters against all ID bits and the first data byte:
-    MASK   + 1111 1111 0000 0000 = 0x07FFFF00
-   If you use this mask and do not touch the filters below, you will find that your first
-   data byte must be 0x00 for the message to enter the receive buffer.
-   
-   At the moment, to disable a filter or mask, copy the value of a used filter or mask.
-   
-   Data bytes are ONLY checked when the MCP2515 is in 'MCP_STDEXT' mode via the begin
-   function, otherwise ('MCP_STD') only the ID is checked.
-***********************************************************************************/
-
-
-#include <mcp_can.h>
-#include <SPI.h>
-
-long unsigned int rxId;
-unsigned char len = 0;
-unsigned char rxBuf[8];
-
-MCP_CAN CAN0(10);                          // Set CS to pin 10
-
-void setup()
-{
-  Serial.begin(115200);
-  if(CAN0.begin(MCP_STDEXT, CAN_500KBPS, MCP_16MHZ) == CAN_OK) Serial.print("MCP2515 Init Okay!!\r\n");
-  else Serial.print("MCP2515 Init Failed!!\r\n");
-  pinMode(2, INPUT);                       // Setting pin 2 for /INT input
-
-
-  CAN0.init_Mask(0,0,0x010F0000);                // Init first mask...
-  CAN0.init_Filt(0,0,0x01000000);                // Init first filter...
-  CAN0.init_Filt(1,0,0x01010000);                // Init second filter...
-  
-  CAN0.init_Mask(1,0,0x010F0000);                // Init second mask... 
-  CAN0.init_Filt(2,0,0x01030000);                // Init third filter...
-  CAN0.init_Filt(3,0,0x01040000);                // Init fouth filter...
-  CAN0.init_Filt(4,0,0x01060000);                // Init fifth filter...
-  CAN0.init_Filt(5,0,0x01070000);                // Init sixth filter...
-  
-  Serial.println("MCP2515 Library Mask & Filter Example...");
-  CAN0.setMode(MCP_NORMAL);                // Change to normal mode to allow messages to be transmitted
-}
-
-void loop()
-{
-    if(!digitalRead(2))                    // If pin 2 is low, read receive buffer
-    {
-      CAN0.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s)
-      Serial.print("ID: ");
-      Serial.print(rxId, HEX);
-      Serial.print(" Data: ");
-      for(int i = 0; i<len; i++)           // Print each byte of the data
-      {
-        if(rxBuf[i] < 0x10)                // If data byte is less than 0x10, add a leading zero
-        {
-          Serial.print("0");
-        }
-        Serial.print(rxBuf[i], HEX);
-        Serial.print(" ");
-      }
-      Serial.println();
-    }
-}
-
-/*********************************************************************************************************
-END FILE
-*********************************************************************************************************/

+ 0 - 60
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/keywords.txt

@@ -1,60 +0,0 @@
-#######################################
-# Syntax Coloring Map For debug_lvc
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-MCP_CAN	KEYWORD1
-mcp_can_dfs	KEYWORD1
-mcp_can	KEYWORD1
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-begin	KEYWORD2
-setMode	KEYWORD2
-init_Mask	KEYWORD2
-init_Filt	KEYWORD2
-sendMsgBuf	KEYWORD2
-readMsgBuf	KEYWORD2
-checkReceive	KEYWORD2
-checkError	KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-MCP_8MHZ	LITERAL1
-MCP_16MHZ	LITERAL1
-MCP_20MHZ	LITERAL1
-CAN_4K096BPS	LITERAL1
-CAN_5KBPS	LITERAL1
-CAN_10KBPS	LITERAL1
-CAN_20KBPS	LITERAL1
-CAN_31K25BPS	LITERAL1
-CAN_40KBPS	LITERAL1
-CAN_50KBPS	LITERAL1
-CAN_80KBPS	LITERAL1
-CAN_100KBPS	LITERAL1
-CAN_125KBPS	LITERAL1
-CAN_200KBPS	LITERAL1
-CAN_250KBPS	LITERAL1
-CAN_500KBPS	LITERAL1
-CAN_1000KBPS	LITERAL1
-MCP_ANY	LITERAL1
-MCP_STD	LITERAL1
-MCP_EXT	LITERAL1
-MCP_STDEXT	LITERAL1
-CAN_OK	LITERAL1
-CAN_FAILINIT	LITERAL1
-CAN_FAILTX	LITERAL1
-CAN_MSGAVAIL	LITERAL1
-CAN_NOMSG	LITERAL1
-CAN_CTRLERROR	LITERAL1
-CAN_GETTXBFTIMEOUT	LITERAL1
-CAN_SENDMSGTIMEOUT	LITERAL1
-CAN_FAIL	LITERAL1
-MCP_NORMAL	LITERAL1
-MCP_SLEEP	LITERAL1
-MCP_LOOPBACK	LITERAL1
-MCP_LISTENONLY	LITERAL1

+ 0 - 1308
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/mcp_can.cpp

@@ -1,1308 +0,0 @@
-/*
-  mcp_can.cpp
-  2012 Copyright (c) Seeed Technology Inc.  All right reserved.
-  2017 Copyright (c) Cory J. Fowler  All Rights Reserved.
-
-  Author: Loovee
-  Contributor: Cory J. Fowler
-  2017-09-25
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-
-  1301  USA
-*/
-#include "mcp_can.h"
-
-#define spi_readwrite SPI.transfer
-#define spi_read() spi_readwrite(0x00)
-
-/*********************************************************************************************************
-** Function name:           mcp2515_reset
-** Descriptions:            Performs a software reset
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_reset(void)                                      
-{
-    SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
-    MCP2515_SELECT();
-    spi_readwrite(MCP_RESET);
-    MCP2515_UNSELECT();
-    SPI.endTransaction();
-    delayMicroseconds(10);
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_readRegister
-** Descriptions:            Read data register
-*********************************************************************************************************/
-INT8U MCP_CAN::mcp2515_readRegister(const INT8U address)                                                                     
-{
-    INT8U ret;
-
-    SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
-    MCP2515_SELECT();
-    spi_readwrite(MCP_READ);
-    spi_readwrite(address);
-    ret = spi_read();
-    MCP2515_UNSELECT();
-    SPI.endTransaction();
-
-    return ret;
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_readRegisterS
-** Descriptions:            Reads sucessive data registers
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_readRegisterS(const INT8U address, INT8U values[], const INT8U n)
-{
-    INT8U i;
-    SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
-    MCP2515_SELECT();
-    spi_readwrite(MCP_READ);
-    spi_readwrite(address);
-    // mcp2515 has auto-increment of address-pointer
-    for (i=0; i<n; i++) 
-        values[i] = spi_read();
-
-    MCP2515_UNSELECT();
-    SPI.endTransaction();
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_setRegister
-** Descriptions:            Sets data register
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_setRegister(const INT8U address, const INT8U value)
-{
-    SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
-    MCP2515_SELECT();
-    spi_readwrite(MCP_WRITE);
-    spi_readwrite(address);
-    spi_readwrite(value);
-    MCP2515_UNSELECT();
-    SPI.endTransaction();
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_setRegisterS
-** Descriptions:            Sets sucessive data registers
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_setRegisterS(const INT8U address, const INT8U values[], const INT8U n)
-{
-    INT8U i;
-    SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
-    MCP2515_SELECT();
-    spi_readwrite(MCP_WRITE);
-    spi_readwrite(address);
-       
-    for (i=0; i<n; i++) 
-        spi_readwrite(values[i]);
-	
-    MCP2515_UNSELECT();
-    SPI.endTransaction();
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_modifyRegister
-** Descriptions:            Sets specific bits of a register
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_modifyRegister(const INT8U address, const INT8U mask, const INT8U data)
-{
-    SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
-    MCP2515_SELECT();
-    spi_readwrite(MCP_BITMOD);
-    spi_readwrite(address);
-    spi_readwrite(mask);
-    spi_readwrite(data);
-    MCP2515_UNSELECT();
-    SPI.endTransaction();
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_readStatus
-** Descriptions:            Reads status register
-*********************************************************************************************************/
-INT8U MCP_CAN::mcp2515_readStatus(void)                             
-{
-    INT8U i;
-    SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
-    MCP2515_SELECT();
-    spi_readwrite(MCP_READ_STATUS);
-    i = spi_read();
-    MCP2515_UNSELECT();
-    SPI.endTransaction();
-    return i;
-}
-
-/*********************************************************************************************************
-** Function name:           setMode
-** Descriptions:            Sets control mode
-*********************************************************************************************************/
-INT8U MCP_CAN::setMode(const INT8U opMode)
-{
-    mcpMode = opMode;
-    return mcp2515_setCANCTRL_Mode(mcpMode);
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_setCANCTRL_Mode
-** Descriptions:            Set control mode
-*********************************************************************************************************/
-INT8U MCP_CAN::mcp2515_setCANCTRL_Mode(const INT8U newmode)
-{
-    INT8U i;
-
-    mcp2515_modifyRegister(MCP_CANCTRL, MODE_MASK, newmode);
-
-    i = mcp2515_readRegister(MCP_CANCTRL);
-    i &= MODE_MASK;
-
-    if ( i == newmode ) 
-        return MCP2515_OK;
-
-    return MCP2515_FAIL;
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_configRate
-** Descriptions:            Set baudrate
-*********************************************************************************************************/
-INT8U MCP_CAN::mcp2515_configRate(const INT8U canSpeed, const INT8U canClock)            
-{
-    INT8U set, cfg1, cfg2, cfg3;
-    set = 1;
-    switch (canClock)
-    {
-        case (MCP_8MHZ):
-        switch (canSpeed) 
-        {
-            case (CAN_5KBPS):                                               //   5KBPS                  
-            cfg1 = MCP_8MHz_5kBPS_CFG1;
-            cfg2 = MCP_8MHz_5kBPS_CFG2;
-            cfg3 = MCP_8MHz_5kBPS_CFG3;
-            break;
-
-            case (CAN_10KBPS):                                              //  10KBPS                  
-            cfg1 = MCP_8MHz_10kBPS_CFG1;
-            cfg2 = MCP_8MHz_10kBPS_CFG2;
-            cfg3 = MCP_8MHz_10kBPS_CFG3;
-            break;
-
-            case (CAN_20KBPS):                                              //  20KBPS                  
-            cfg1 = MCP_8MHz_20kBPS_CFG1;
-            cfg2 = MCP_8MHz_20kBPS_CFG2;
-            cfg3 = MCP_8MHz_20kBPS_CFG3;
-            break;
-
-            case (CAN_31K25BPS):                                            //  31.25KBPS                  
-            cfg1 = MCP_8MHz_31k25BPS_CFG1;
-            cfg2 = MCP_8MHz_31k25BPS_CFG2;
-            cfg3 = MCP_8MHz_31k25BPS_CFG3;
-            break;
-
-            case (CAN_33K3BPS):                                             //  33.33KBPS                  
-            cfg1 = MCP_8MHz_33k3BPS_CFG1;
-            cfg2 = MCP_8MHz_33k3BPS_CFG2;
-            cfg3 = MCP_8MHz_33k3BPS_CFG3;
-            break;
-
-            case (CAN_40KBPS):                                              //  40Kbps
-            cfg1 = MCP_8MHz_40kBPS_CFG1;
-            cfg2 = MCP_8MHz_40kBPS_CFG2;
-            cfg3 = MCP_8MHz_40kBPS_CFG3;
-            break;
-
-            case (CAN_50KBPS):                                              //  50Kbps
-            cfg1 = MCP_8MHz_50kBPS_CFG1;
-            cfg2 = MCP_8MHz_50kBPS_CFG2;
-            cfg3 = MCP_8MHz_50kBPS_CFG3;
-            break;
-
-            case (CAN_80KBPS):                                              //  80Kbps
-            cfg1 = MCP_8MHz_80kBPS_CFG1;
-            cfg2 = MCP_8MHz_80kBPS_CFG2;
-            cfg3 = MCP_8MHz_80kBPS_CFG3;
-            break;
-
-            case (CAN_100KBPS):                                             // 100Kbps
-            cfg1 = MCP_8MHz_100kBPS_CFG1;
-            cfg2 = MCP_8MHz_100kBPS_CFG2;
-            cfg3 = MCP_8MHz_100kBPS_CFG3;
-            break;
-
-            case (CAN_125KBPS):                                             // 125Kbps
-            cfg1 = MCP_8MHz_125kBPS_CFG1;
-            cfg2 = MCP_8MHz_125kBPS_CFG2;
-            cfg3 = MCP_8MHz_125kBPS_CFG3;
-            break;
-
-            case (CAN_200KBPS):                                             // 200Kbps
-            cfg1 = MCP_8MHz_200kBPS_CFG1;
-            cfg2 = MCP_8MHz_200kBPS_CFG2;
-            cfg3 = MCP_8MHz_200kBPS_CFG3;
-            break;
-
-            case (CAN_250KBPS):                                             // 250Kbps
-            cfg1 = MCP_8MHz_250kBPS_CFG1;
-            cfg2 = MCP_8MHz_250kBPS_CFG2;
-            cfg3 = MCP_8MHz_250kBPS_CFG3;
-            break;
-
-            case (CAN_500KBPS):                                             // 500Kbps
-            cfg1 = MCP_8MHz_500kBPS_CFG1;
-            cfg2 = MCP_8MHz_500kBPS_CFG2;
-            cfg3 = MCP_8MHz_500kBPS_CFG3;
-            break;
-        
-            case (CAN_1000KBPS):                                            //   1Mbps
-            cfg1 = MCP_8MHz_1000kBPS_CFG1;
-            cfg2 = MCP_8MHz_1000kBPS_CFG2;
-            cfg3 = MCP_8MHz_1000kBPS_CFG3;
-            break;  
-
-            default:
-            set = 0;
-	    return MCP2515_FAIL;
-            break;
-        }
-        break;
-
-        case (MCP_16MHZ):
-        switch (canSpeed) 
-        {
-            case (CAN_5KBPS):                                               //   5Kbps
-            cfg1 = MCP_16MHz_5kBPS_CFG1;
-            cfg2 = MCP_16MHz_5kBPS_CFG2;
-            cfg3 = MCP_16MHz_5kBPS_CFG3;
-            break;
-
-            case (CAN_10KBPS):                                              //  10Kbps
-            cfg1 = MCP_16MHz_10kBPS_CFG1;
-            cfg2 = MCP_16MHz_10kBPS_CFG2;
-            cfg3 = MCP_16MHz_10kBPS_CFG3;
-            break;
-
-            case (CAN_20KBPS):                                              //  20Kbps
-            cfg1 = MCP_16MHz_20kBPS_CFG1;
-            cfg2 = MCP_16MHz_20kBPS_CFG2;
-            cfg3 = MCP_16MHz_20kBPS_CFG3;
-            break;
-
-            case (CAN_33K3BPS):                                              //  20Kbps
-            cfg1 = MCP_16MHz_33k3BPS_CFG1;
-            cfg2 = MCP_16MHz_33k3BPS_CFG2;
-            cfg3 = MCP_16MHz_33k3BPS_CFG3;
-            break;
-
-            case (CAN_40KBPS):                                              //  40Kbps
-            cfg1 = MCP_16MHz_40kBPS_CFG1;
-            cfg2 = MCP_16MHz_40kBPS_CFG2;
-            cfg3 = MCP_16MHz_40kBPS_CFG3;
-            break;
-
-            case (CAN_50KBPS):                                              //  50Kbps
-            cfg2 = MCP_16MHz_50kBPS_CFG2;
-            cfg3 = MCP_16MHz_50kBPS_CFG3;
-            break;
-
-            case (CAN_80KBPS):                                              //  80Kbps
-            cfg1 = MCP_16MHz_80kBPS_CFG1;
-            cfg2 = MCP_16MHz_80kBPS_CFG2;
-            cfg3 = MCP_16MHz_80kBPS_CFG3;
-            break;
-
-            case (CAN_100KBPS):                                             // 100Kbps
-            cfg1 = MCP_16MHz_100kBPS_CFG1;
-            cfg2 = MCP_16MHz_100kBPS_CFG2;
-            cfg3 = MCP_16MHz_100kBPS_CFG3;
-            break;
-
-            case (CAN_125KBPS):                                             // 125Kbps
-            cfg1 = MCP_16MHz_125kBPS_CFG1;
-            cfg2 = MCP_16MHz_125kBPS_CFG2;
-            cfg3 = MCP_16MHz_125kBPS_CFG3;
-            break;
-
-            case (CAN_200KBPS):                                             // 200Kbps
-            cfg1 = MCP_16MHz_200kBPS_CFG1;
-            cfg2 = MCP_16MHz_200kBPS_CFG2;
-            cfg3 = MCP_16MHz_200kBPS_CFG3;
-            break;
-
-            case (CAN_250KBPS):                                             // 250Kbps
-            cfg1 = MCP_16MHz_250kBPS_CFG1;
-            cfg2 = MCP_16MHz_250kBPS_CFG2;
-            cfg3 = MCP_16MHz_250kBPS_CFG3;
-            break;
-
-            case (CAN_500KBPS):                                             // 500Kbps
-            cfg1 = MCP_16MHz_500kBPS_CFG1;
-            cfg2 = MCP_16MHz_500kBPS_CFG2;
-            cfg3 = MCP_16MHz_500kBPS_CFG3;
-            break;
-        
-            case (CAN_1000KBPS):                                            //   1Mbps
-            cfg1 = MCP_16MHz_1000kBPS_CFG1;
-            cfg2 = MCP_16MHz_1000kBPS_CFG2;
-            cfg3 = MCP_16MHz_1000kBPS_CFG3;
-            break;  
-
-            default:
-            set = 0;
-	    return MCP2515_FAIL;
-            break;
-        }
-        break;
-        
-        case (MCP_20MHZ):
-        switch (canSpeed) 
-        {
-            case (CAN_40KBPS):                                              //  40Kbps
-            cfg1 = MCP_20MHz_40kBPS_CFG1;
-            cfg2 = MCP_20MHz_40kBPS_CFG2;
-            cfg3 = MCP_20MHz_40kBPS_CFG3;
-            break;
-
-            case (CAN_50KBPS):                                              //  50Kbps
-            cfg1 = MCP_20MHz_50kBPS_CFG1;
-            cfg2 = MCP_20MHz_50kBPS_CFG2;
-            cfg3 = MCP_20MHz_50kBPS_CFG3;
-            break;
-
-            case (CAN_80KBPS):                                              //  80Kbps
-            cfg1 = MCP_20MHz_80kBPS_CFG1;
-            cfg2 = MCP_20MHz_80kBPS_CFG2;
-            cfg3 = MCP_20MHz_80kBPS_CFG3;
-            break;
-
-            case (CAN_100KBPS):                                             // 100Kbps
-            cfg1 = MCP_20MHz_100kBPS_CFG1;
-            cfg2 = MCP_20MHz_100kBPS_CFG2;
-            cfg3 = MCP_20MHz_100kBPS_CFG3;
-            break;
-
-            case (CAN_125KBPS):                                             // 125Kbps
-            cfg1 = MCP_20MHz_125kBPS_CFG1;
-            cfg2 = MCP_20MHz_125kBPS_CFG2;
-            cfg3 = MCP_20MHz_125kBPS_CFG3;
-            break;
-
-            case (CAN_200KBPS):                                             // 200Kbps
-            cfg1 = MCP_20MHz_200kBPS_CFG1;
-            cfg2 = MCP_20MHz_200kBPS_CFG2;
-            cfg3 = MCP_20MHz_200kBPS_CFG3;
-            break;
-
-            case (CAN_250KBPS):                                             // 250Kbps
-            cfg1 = MCP_20MHz_250kBPS_CFG1;
-            cfg2 = MCP_20MHz_250kBPS_CFG2;
-            cfg3 = MCP_20MHz_250kBPS_CFG3;
-            break;
-
-            case (CAN_500KBPS):                                             // 500Kbps
-            cfg1 = MCP_20MHz_500kBPS_CFG1;
-            cfg2 = MCP_20MHz_500kBPS_CFG2;
-            cfg3 = MCP_20MHz_500kBPS_CFG3;
-            break;
-        
-            case (CAN_1000KBPS):                                            //   1Mbps
-            cfg1 = MCP_20MHz_1000kBPS_CFG1;
-            cfg2 = MCP_20MHz_1000kBPS_CFG2;
-            cfg3 = MCP_20MHz_1000kBPS_CFG3;
-            break;  
-
-            default:
-            set = 0;
-            return MCP2515_FAIL;
-            break;
-        }
-        break;
-        
-        default:
-        set = 0;
-	return MCP2515_FAIL;
-        break;
-    }
-
-    if (set) {
-        mcp2515_setRegister(MCP_CNF1, cfg1);
-        mcp2515_setRegister(MCP_CNF2, cfg2);
-        mcp2515_setRegister(MCP_CNF3, cfg3);
-        return MCP2515_OK;
-    }
-     
-    return MCP2515_FAIL;
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_initCANBuffers
-** Descriptions:            Initialize Buffers, Masks, and Filters
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_initCANBuffers(void)
-{
-    INT8U i, a1, a2, a3;
-    
-    INT8U std = 0;               
-    INT8U ext = 1;
-    INT32U ulMask = 0x00, ulFilt = 0x00;
-
-
-    mcp2515_write_mf(MCP_RXM0SIDH, ext, ulMask);			/*Set both masks to 0           */
-    mcp2515_write_mf(MCP_RXM1SIDH, ext, ulMask);			/*Mask register ignores ext bit */
-    
-                                                                        /* Set all filters to 0         */
-    mcp2515_write_mf(MCP_RXF0SIDH, ext, ulFilt);			/* RXB0: extended               */
-    mcp2515_write_mf(MCP_RXF1SIDH, std, ulFilt);			/* RXB1: standard               */
-    mcp2515_write_mf(MCP_RXF2SIDH, ext, ulFilt);			/* RXB2: extended               */
-    mcp2515_write_mf(MCP_RXF3SIDH, std, ulFilt);			/* RXB3: standard               */
-    mcp2515_write_mf(MCP_RXF4SIDH, ext, ulFilt);
-    mcp2515_write_mf(MCP_RXF5SIDH, std, ulFilt);
-
-                                                                        /* Clear, deactivate the three  */
-                                                                        /* transmit buffers             */
-                                                                        /* TXBnCTRL -> TXBnD7           */
-    a1 = MCP_TXB0CTRL;
-    a2 = MCP_TXB1CTRL;
-    a3 = MCP_TXB2CTRL;
-    for (i = 0; i < 14; i++) {                                          /* in-buffer loop               */
-        mcp2515_setRegister(a1, 0);
-        mcp2515_setRegister(a2, 0);
-        mcp2515_setRegister(a3, 0);
-        a1++;
-        a2++;
-        a3++;
-    }
-    mcp2515_setRegister(MCP_RXB0CTRL, 0);
-    mcp2515_setRegister(MCP_RXB1CTRL, 0);
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_init
-** Descriptions:            Initialize the controller
-*********************************************************************************************************/
-INT8U MCP_CAN::mcp2515_init(const INT8U canIDMode, const INT8U canSpeed, const INT8U canClock)
-{
-
-  INT8U res;
-
-    mcp2515_reset();
-    
-    mcpMode = MCP_LOOPBACK;
-
-    res = mcp2515_setCANCTRL_Mode(MODE_CONFIG);
-    if(res > 0)
-    {
-#if DEBUG_MODE
-      Serial.print("Entering Configuration Mode Failure...\r\n"); 
-#endif
-      return res;
-    }
-#if DEBUG_MODE
-    Serial.print("Entering Configuration Mode Successful!\r\n");
-#endif
-
-    // Set Baudrate
-    if(mcp2515_configRate(canSpeed, canClock))
-    {
-#if DEBUG_MODE
-      Serial.print("Setting Baudrate Failure...\r\n");
-#endif
-      return res;
-    }
-#if DEBUG_MODE
-    Serial.print("Setting Baudrate Successful!\r\n");
-#endif
-
-    if ( res == MCP2515_OK ) {
-
-                                                                        /* init canbuffers              */
-        mcp2515_initCANBuffers();
-
-                                                                        /* interrupt mode               */
-        mcp2515_setRegister(MCP_CANINTE, MCP_RX0IF | MCP_RX1IF);
-
-	//Sets BF pins as GPO
-	mcp2515_setRegister(MCP_BFPCTRL,MCP_BxBFS_MASK | MCP_BxBFE_MASK);
-	//Sets RTS pins as GPI
-	mcp2515_setRegister(MCP_TXRTSCTRL,0x00);
-
-        switch(canIDMode)
-        {
-            case (MCP_ANY):
-            mcp2515_modifyRegister(MCP_RXB0CTRL,
-            MCP_RXB_RX_MASK | MCP_RXB_BUKT_MASK,
-            MCP_RXB_RX_ANY | MCP_RXB_BUKT_MASK);
-            mcp2515_modifyRegister(MCP_RXB1CTRL, MCP_RXB_RX_MASK,
-            MCP_RXB_RX_ANY);
-            break;
-/*          The followingn two functions of the MCP2515 do not work, there is a bug in the silicon.
-            case (MCP_STD): 
-            mcp2515_modifyRegister(MCP_RXB0CTRL,
-            MCP_RXB_RX_MASK | MCP_RXB_BUKT_MASK,
-            MCP_RXB_RX_STD | MCP_RXB_BUKT_MASK );
-            mcp2515_modifyRegister(MCP_RXB1CTRL, MCP_RXB_RX_MASK,
-            MCP_RXB_RX_STD);
-            break;
-
-            case (MCP_EXT): 
-            mcp2515_modifyRegister(MCP_RXB0CTRL,
-            MCP_RXB_RX_MASK | MCP_RXB_BUKT_MASK,
-            MCP_RXB_RX_EXT | MCP_RXB_BUKT_MASK );
-            mcp2515_modifyRegister(MCP_RXB1CTRL, MCP_RXB_RX_MASK,
-            MCP_RXB_RX_EXT);
-            break;
-*/
-            case (MCP_STDEXT): 
-            mcp2515_modifyRegister(MCP_RXB0CTRL,
-            MCP_RXB_RX_MASK | MCP_RXB_BUKT_MASK,
-            MCP_RXB_RX_STDEXT | MCP_RXB_BUKT_MASK );
-            mcp2515_modifyRegister(MCP_RXB1CTRL, MCP_RXB_RX_MASK,
-            MCP_RXB_RX_STDEXT);
-            break;
-    
-            default:
-#if DEBUG_MODE        
-            Serial.print("`Setting ID Mode Failure...\r\n");
-#endif           
-            return MCP2515_FAIL;
-            break;
-}    
-
-
-        res = mcp2515_setCANCTRL_Mode(mcpMode);                                                                
-        if(res)
-        {
-#if DEBUG_MODE        
-          Serial.print("Returning to Previous Mode Failure...\r\n");
-#endif           
-          return res;
-        }
-
-    }
-    return res;
-
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_write_id
-** Descriptions:            Write CAN ID
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_write_id( const INT8U mcp_addr, const INT8U ext, const INT32U id )
-{
-    uint16_t canid;
-    INT8U tbufdata[4];
-
-    canid = (uint16_t)(id & 0x0FFFF);
-
-    if ( ext == 1) 
-    {
-        tbufdata[MCP_EID0] = (INT8U) (canid & 0xFF);
-        tbufdata[MCP_EID8] = (INT8U) (canid >> 8);
-        canid = (uint16_t)(id >> 16);
-        tbufdata[MCP_SIDL] = (INT8U) (canid & 0x03);
-        tbufdata[MCP_SIDL] += (INT8U) ((canid & 0x1C) << 3);
-        tbufdata[MCP_SIDL] |= MCP_TXB_EXIDE_M;
-        tbufdata[MCP_SIDH] = (INT8U) (canid >> 5 );
-    }
-    else 
-    {
-        tbufdata[MCP_SIDH] = (INT8U) (canid >> 3 );
-        tbufdata[MCP_SIDL] = (INT8U) ((canid & 0x07 ) << 5);
-        tbufdata[MCP_EID0] = 0;
-        tbufdata[MCP_EID8] = 0;
-    }
-    
-    mcp2515_setRegisterS( mcp_addr, tbufdata, 4 );
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_write_mf
-** Descriptions:            Write Masks and Filters
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_write_mf( const INT8U mcp_addr, const INT8U ext, const INT32U id )
-{
-    uint16_t canid;
-    INT8U tbufdata[4];
-
-    canid = (uint16_t)(id & 0x0FFFF);
-
-    if ( ext == 1) 
-    {
-        tbufdata[MCP_EID0] = (INT8U) (canid & 0xFF);
-        tbufdata[MCP_EID8] = (INT8U) (canid >> 8);
-        canid = (uint16_t)(id >> 16);
-        tbufdata[MCP_SIDL] = (INT8U) (canid & 0x03);
-        tbufdata[MCP_SIDL] += (INT8U) ((canid & 0x1C) << 3);
-        tbufdata[MCP_SIDL] |= MCP_TXB_EXIDE_M;
-        tbufdata[MCP_SIDH] = (INT8U) (canid >> 5 );
-    }
-    else 
-    {
-        tbufdata[MCP_EID0] = (INT8U) (canid & 0xFF);
-        tbufdata[MCP_EID8] = (INT8U) (canid >> 8);
-        canid = (uint16_t)(id >> 16);
-        tbufdata[MCP_SIDL] = (INT8U) ((canid & 0x07) << 5);
-        tbufdata[MCP_SIDH] = (INT8U) (canid >> 3 );
-    }
-    
-    mcp2515_setRegisterS( mcp_addr, tbufdata, 4 );
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_read_id
-** Descriptions:            Read CAN ID
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_read_id( const INT8U mcp_addr, INT8U* ext, INT32U* id )
-{
-    INT8U tbufdata[4];
-
-    *ext = 0;
-    *id = 0;
-
-    mcp2515_readRegisterS( mcp_addr, tbufdata, 4 );
-
-    *id = (tbufdata[MCP_SIDH]<<3) + (tbufdata[MCP_SIDL]>>5);
-
-    if ( (tbufdata[MCP_SIDL] & MCP_TXB_EXIDE_M) ==  MCP_TXB_EXIDE_M ) 
-    {
-                                                                        /* extended id                  */
-        *id = (*id<<2) + (tbufdata[MCP_SIDL] & 0x03);
-        *id = (*id<<8) + tbufdata[MCP_EID8];
-        *id = (*id<<8) + tbufdata[MCP_EID0];
-        *ext = 1;
-    }
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_write_canMsg
-** Descriptions:            Write message
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_write_canMsg( const INT8U buffer_sidh_addr)
-{
-    INT8U mcp_addr;
-    mcp_addr = buffer_sidh_addr;
-    mcp2515_setRegisterS(mcp_addr+5, m_nDta, m_nDlc );                  /* write data bytes             */
-	
-    if ( m_nRtr == 1)                                                   /* if RTR set bit in byte       */
-        m_nDlc |= MCP_RTR_MASK;  
-
-    mcp2515_setRegister((mcp_addr+4), m_nDlc );                         /* write the RTR and DLC        */
-    mcp2515_write_id(mcp_addr, m_nExtFlg, m_nID );                      /* write CAN id                 */
-
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_read_canMsg
-** Descriptions:            Read message
-*********************************************************************************************************/
-void MCP_CAN::mcp2515_read_canMsg( const INT8U buffer_sidh_addr)        /* read can msg                 */
-{
-    INT8U mcp_addr, ctrl;
-
-    mcp_addr = buffer_sidh_addr;
-
-    mcp2515_read_id( mcp_addr, &m_nExtFlg,&m_nID );
-
-    ctrl = mcp2515_readRegister( mcp_addr-1 );
-    m_nDlc = mcp2515_readRegister( mcp_addr+4 );
-
-    if (ctrl & 0x08)
-        m_nRtr = 1;
-    else
-        m_nRtr = 0;
-
-    m_nDlc &= MCP_DLC_MASK;
-    mcp2515_readRegisterS( mcp_addr+5, &(m_nDta[0]), m_nDlc );
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_getNextFreeTXBuf
-** Descriptions:            Send message
-*********************************************************************************************************/
-INT8U MCP_CAN::mcp2515_getNextFreeTXBuf(INT8U *txbuf_n)                 /* get Next free txbuf          */
-{
-    INT8U res, i, ctrlval;
-    INT8U ctrlregs[MCP_N_TXBUFFERS] = { MCP_TXB0CTRL, MCP_TXB1CTRL, MCP_TXB2CTRL };
-
-    res = MCP_ALLTXBUSY;
-    *txbuf_n = 0x00;
-
-                                                                        /* check all 3 TX-Buffers       */
-    for (i=0; i<MCP_N_TXBUFFERS; i++) {
-        ctrlval = mcp2515_readRegister( ctrlregs[i] );
-        if ( (ctrlval & MCP_TXB_TXREQ_M) == 0 ) {
-            *txbuf_n = ctrlregs[i]+1;                                   /* return SIDH-address of Buffer*/
-            
-            res = MCP2515_OK;
-            return res;                                                 /* ! function exit              */
-        }
-    }
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           MCP_CAN
-** Descriptions:            Public function to declare CAN class and the /CS pin.
-*********************************************************************************************************/
-MCP_CAN::MCP_CAN(INT8U _CS)
-{
-    MCPCS = _CS;
-    MCP2515_UNSELECT();
-    pinMode(MCPCS, OUTPUT);
-}
-
-/*********************************************************************************************************
-** Function name:           begin
-** Descriptions:            Public function to declare controller initialization parameters.
-*********************************************************************************************************/
-
- //static inline void initSS()  { pinMode(SPI_CS, OUTPUT); }
-  //static inline void setSS()   {  digitalWrite(SPI_CS, LOW); }
-  //static inline void resetSS() {  digitalWrite(SPI_CS, HIGH); }
-/*void MCP_CAN::setSS() {
-        Serial.print(" Set Low ");
-        digitalWrite(8, LOW);
-    }
-
-
-void MCP_CAN::resetSS() {
-        digitalWrite(8, HIGH);
-    }
-
-*/
-INT8U MCP_CAN::begin(INT8U idmodeset, INT8U speedset, INT8U clockset)
-{
-    INT8U res;
-
-        SPI.begin();
-            setSS();
-    res = mcp2515_init(idmodeset, speedset, clockset);
-        resetSS();
-    if (res == MCP2515_OK)
-        return CAN_OK;
-    
-    return CAN_FAILINIT;
-}
-
-/*********************************************************************************************************
-** Function name:           init_Mask
-** Descriptions:            Public function to set mask(s).
-*********************************************************************************************************/
-INT8U MCP_CAN::init_Mask(INT8U num, INT8U ext, INT32U ulData)
-{
-    INT8U res = MCP2515_OK;
-#if DEBUG_MODE
-    Serial.print("Starting to Set Mask!\r\n");
-#endif
-    res = mcp2515_setCANCTRL_Mode(MODE_CONFIG);
-    if(res > 0){
-#if DEBUG_MODE
-	Serial.print("Entering Configuration Mode Failure...\r\n"); 
-#endif
-	return res;
-     }
-    
-    if (num == 0){
-        mcp2515_write_mf(MCP_RXM0SIDH, ext, ulData);
-
-    }
-    else if(num == 1){
-        mcp2515_write_mf(MCP_RXM1SIDH, ext, ulData);
-    }
-    else res =  MCP2515_FAIL;
-    
-    res = mcp2515_setCANCTRL_Mode(mcpMode);
-    if(res > 0){
-#if DEBUG_MODE
-	Serial.print("Entering Previous Mode Failure...\r\nSetting Mask Failure...\r\n"); 
-#endif
-	return res;
-    }
-#if DEBUG_MODE
-    Serial.print("Setting Mask Successful!\r\n");
-#endif
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           init_Mask
-** Descriptions:            Public function to set mask(s).
-*********************************************************************************************************/
-INT8U MCP_CAN::init_Mask(INT8U num, INT32U ulData)
-{
-    INT8U res = MCP2515_OK;
-    INT8U ext = 0;
-#if DEBUG_MODE
-    Serial.print("Starting to Set Mask!\r\n");
-#endif
-    res = mcp2515_setCANCTRL_Mode(MODE_CONFIG);
-    if(res > 0){
-#if DEBUG_MODE
-    Serial.print("Entering Configuration Mode Failure...\r\n"); 
-#endif
-  return res;
-}
-    
-    if((ulData & 0x80000000) == 0x80000000)
-        ext = 1;
-    
-    if (num == 0){
-        mcp2515_write_mf(MCP_RXM0SIDH, ext, ulData);
-
-    }
-    else if(num == 1){
-        mcp2515_write_mf(MCP_RXM1SIDH, ext, ulData);
-    }
-    else res =  MCP2515_FAIL;
-    
-    res = mcp2515_setCANCTRL_Mode(mcpMode);
-    if(res > 0){
-#if DEBUG_MODE
-    Serial.print("Entering Previous Mode Failure...\r\nSetting Mask Failure...\r\n"); 
-#endif
-    return res;
-  }
-#if DEBUG_MODE
-    Serial.print("Setting Mask Successful!\r\n");
-#endif
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           init_Filt
-** Descriptions:            Public function to set filter(s).
-*********************************************************************************************************/
-INT8U MCP_CAN::init_Filt(INT8U num, INT8U ext, INT32U ulData)
-{
-    INT8U res = MCP2515_OK;
-#if DEBUG_MODE
-    Serial.print("Starting to Set Filter!\r\n");
-#endif
-    res = mcp2515_setCANCTRL_Mode(MODE_CONFIG);
-    if(res > 0)
-    {
-#if DEBUG_MODE
-      Serial.print("Enter Configuration Mode Failure...\r\n"); 
-#endif
-      return res;
-    }
-    
-    switch( num )
-    {
-        case 0:
-        mcp2515_write_mf(MCP_RXF0SIDH, ext, ulData);
-        break;
-
-        case 1:
-        mcp2515_write_mf(MCP_RXF1SIDH, ext, ulData);
-        break;
-
-        case 2:
-        mcp2515_write_mf(MCP_RXF2SIDH, ext, ulData);
-        break;
-
-        case 3:
-        mcp2515_write_mf(MCP_RXF3SIDH, ext, ulData);
-        break;
-
-        case 4:
-        mcp2515_write_mf(MCP_RXF4SIDH, ext, ulData);
-        break;
-
-        case 5:
-        mcp2515_write_mf(MCP_RXF5SIDH, ext, ulData);
-        break;
-
-        default:
-        res = MCP2515_FAIL;
-    }
-    
-    res = mcp2515_setCANCTRL_Mode(mcpMode);
-    if(res > 0)
-    {
-#if DEBUG_MODE
-      Serial.print("Entering Previous Mode Failure...\r\nSetting Filter Failure...\r\n"); 
-#endif
-      return res;
-    }
-#if DEBUG_MODE
-    Serial.print("Setting Filter Successfull!\r\n");
-#endif
-    
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           init_Filt
-** Descriptions:            Public function to set filter(s).
-*********************************************************************************************************/
-INT8U MCP_CAN::init_Filt(INT8U num, INT32U ulData)
-{
-    INT8U res = MCP2515_OK;
-    INT8U ext = 0;
-    
-#if DEBUG_MODE
-    Serial.print("Starting to Set Filter!\r\n");
-#endif
-    res = mcp2515_setCANCTRL_Mode(MODE_CONFIG);
-    if(res > 0)
-    {
-#if DEBUG_MODE
-      Serial.print("Enter Configuration Mode Failure...\r\n"); 
-#endif
-      return res;
-    }
-    
-    if((ulData & 0x80000000) == 0x80000000)
-        ext = 1;
-    
-    switch( num )
-    {
-        case 0:
-        mcp2515_write_mf(MCP_RXF0SIDH, ext, ulData);
-        break;
-
-        case 1:
-        mcp2515_write_mf(MCP_RXF1SIDH, ext, ulData);
-        break;
-
-        case 2:
-        mcp2515_write_mf(MCP_RXF2SIDH, ext, ulData);
-        break;
-
-        case 3:
-        mcp2515_write_mf(MCP_RXF3SIDH, ext, ulData);
-        break;
-
-        case 4:
-        mcp2515_write_mf(MCP_RXF4SIDH, ext, ulData);
-        break;
-
-        case 5:
-        mcp2515_write_mf(MCP_RXF5SIDH, ext, ulData);
-        break;
-
-        default:
-        res = MCP2515_FAIL;
-    }
-    
-    res = mcp2515_setCANCTRL_Mode(mcpMode);
-    if(res > 0)
-    {
-#if DEBUG_MODE
-      Serial.print("Entering Previous Mode Failure...\r\nSetting Filter Failure...\r\n"); 
-#endif
-      return res;
-    }
-#if DEBUG_MODE
-    Serial.print("Setting Filter Successfull!\r\n");
-#endif
-    
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           setMsg
-** Descriptions:            Set can message, such as dlc, id, dta[] and so on
-*********************************************************************************************************/
-INT8U MCP_CAN::setMsg(INT32U id, INT8U rtr, INT8U ext, INT8U len, INT8U *pData)
-{
-    int i = 0;
-    m_nID     = id;
-    m_nRtr    = rtr;
-    m_nExtFlg = ext;
-    m_nDlc    = len;
-    for(i = 0; i<MAX_CHAR_IN_MESSAGE; i++)
-        m_nDta[i] = *(pData+i);
-	
-    return MCP2515_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           clearMsg
-** Descriptions:            Set all messages to zero
-*********************************************************************************************************/
-INT8U MCP_CAN::clearMsg()
-{
-    m_nID       = 0;
-    m_nDlc      = 0;
-    m_nExtFlg   = 0;
-    m_nRtr      = 0;
-    m_nfilhit   = 0;
-    for(int i = 0; i<m_nDlc; i++ )
-      m_nDta[i] = 0x00;
-
-    return MCP2515_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           sendMsg
-** Descriptions:            Send message
-*********************************************************************************************************/
-INT8U MCP_CAN::sendMsg()
-{
-    INT8U res, res1, txbuf_n;
-    uint16_t uiTimeOut = 0;
-
-    do {
-        res = mcp2515_getNextFreeTXBuf(&txbuf_n);                       /* info = addr.                 */
-        uiTimeOut++;
-    } while (res == MCP_ALLTXBUSY && (uiTimeOut < TIMEOUTVALUE));
-
-    if(uiTimeOut == TIMEOUTVALUE) 
-    {   
-        return CAN_GETTXBFTIMEOUT;                                      /* get tx buff time out         */
-    }
-    uiTimeOut = 0;
-    mcp2515_write_canMsg( txbuf_n);
-    mcp2515_modifyRegister( txbuf_n-1 , MCP_TXB_TXREQ_M, MCP_TXB_TXREQ_M );
-    
-    do
-    {
-        uiTimeOut++;        
-        res1 = mcp2515_readRegister(txbuf_n-1);                         /* read send buff ctrl reg 	*/
-        res1 = res1 & 0x08;                               		
-    } while (res1 && (uiTimeOut < TIMEOUTVALUE));   
-    
-    if(uiTimeOut == TIMEOUTVALUE)                                       /* send msg timeout             */	
-        return CAN_SENDMSGTIMEOUT;
-    
-    return CAN_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           sendMsgBuf
-** Descriptions:            Send message to transmitt buffer
-*********************************************************************************************************/
-INT8U MCP_CAN::sendMsgBuf(INT32U id, INT8U ext, INT8U len, INT8U *buf)
-{
-    INT8U res;
-	
-    setMsg(id, 0, ext, len, buf);
-    res = sendMsg();
-    
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           sendMsgBuf
-** Descriptions:            Send message to transmitt buffer
-*********************************************************************************************************/
-INT8U MCP_CAN::sendMsgBuf(INT32U id, INT8U len, INT8U *buf)
-{
-    INT8U ext = 0, rtr = 0;
-    INT8U res;
-    
-    if((id & 0x80000000) == 0x80000000)
-        ext = 1;
- 
-    if((id & 0x40000000) == 0x40000000)
-        rtr = 1;
-        
-    setMsg(id, rtr, ext, len, buf);
-    res = sendMsg();
-    
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           readMsg
-** Descriptions:            Read message
-*********************************************************************************************************/
-INT8U MCP_CAN::readMsg()
-{
-    INT8U stat, res;
-
-    stat = mcp2515_readStatus();
-
-    if ( stat & MCP_STAT_RX0IF )                                        /* Msg in Buffer 0              */
-    {
-        mcp2515_read_canMsg( MCP_RXBUF_0);
-        mcp2515_modifyRegister(MCP_CANINTF, MCP_RX0IF, 0);
-        res = CAN_OK;
-    }
-    else if ( stat & MCP_STAT_RX1IF )                                   /* Msg in Buffer 1              */
-    {
-        mcp2515_read_canMsg( MCP_RXBUF_1);
-        mcp2515_modifyRegister(MCP_CANINTF, MCP_RX1IF, 0);
-        res = CAN_OK;
-    }
-    else 
-        res = CAN_NOMSG;
-    
-    return res;
-}
-
-/*********************************************************************************************************
-** Function name:           readMsgBuf
-** Descriptions:            Public function, Reads message from receive buffer.
-*********************************************************************************************************/
-INT8U MCP_CAN::readMsgBuf(INT32U *id, INT8U *ext, INT8U *len, INT8U buf[])
-{
-    if(readMsg() == CAN_NOMSG)
-	return CAN_NOMSG;
-	
-    *id  = m_nID;
-    *len = m_nDlc;
-    *ext = m_nExtFlg;
-    for(int i = 0; i<m_nDlc; i++)
-        buf[i] = m_nDta[i];
-
-    return CAN_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           readMsgBuf
-** Descriptions:            Public function, Reads message from receive buffer.
-*********************************************************************************************************/
-INT8U MCP_CAN::readMsgBuf(INT32U *id, INT8U *len, INT8U buf[])
-{
-    if(readMsg() == CAN_NOMSG)
-	return CAN_NOMSG;
-
-    if (m_nExtFlg)
-        m_nID |= 0x80000000;
-
-    if (m_nRtr)
-        m_nID |= 0x40000000;
-	
-    *id  = m_nID;
-    *len = m_nDlc;
-    
-    for(int i = 0; i<m_nDlc; i++)
-        buf[i] = m_nDta[i];
-
-    return CAN_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           checkReceive
-** Descriptions:            Public function, Checks for received data.  (Used if not using the interrupt output)
-*********************************************************************************************************/
-INT8U MCP_CAN::checkReceive(void)
-{
-    INT8U res;
-    res = mcp2515_readStatus();                                         /* RXnIF in Bit 1 and 0         */
-    if ( res & MCP_STAT_RXIF_MASK )
-        return CAN_MSGAVAIL;
-    else 
-        return CAN_NOMSG;
-}
-
-/*********************************************************************************************************
-** Function name:           checkError
-** Descriptions:            Public function, Returns error register data.
-*********************************************************************************************************/
-INT8U MCP_CAN::checkError(void)
-{
-    INT8U eflg = mcp2515_readRegister(MCP_EFLG);
-
-    if ( eflg & MCP_EFLG_ERRORMASK ) 
-        return CAN_CTRLERROR;
-    else
-        return CAN_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           getError
-** Descriptions:            Returns error register value.
-*********************************************************************************************************/
-INT8U MCP_CAN::getError(void)
-{
-    return mcp2515_readRegister(MCP_EFLG);
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_errorCountRX
-** Descriptions:            Returns REC register value
-*********************************************************************************************************/
-INT8U MCP_CAN::errorCountRX(void)                             
-{
-    return mcp2515_readRegister(MCP_REC);
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_errorCountTX
-** Descriptions:            Returns TEC register value
-*********************************************************************************************************/
-INT8U MCP_CAN::errorCountTX(void)                             
-{
-    return mcp2515_readRegister(MCP_TEC);
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_enOneShotTX
-** Descriptions:            Enables one shot transmission mode
-*********************************************************************************************************/
-INT8U MCP_CAN::enOneShotTX(void)                             
-{
-    mcp2515_modifyRegister(MCP_CANCTRL, MODE_ONESHOT, MODE_ONESHOT);
-    if((mcp2515_readRegister(MCP_CANCTRL) & MODE_ONESHOT) != MODE_ONESHOT)
-	    return CAN_FAIL;
-    else
-	    return CAN_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_disOneShotTX
-** Descriptions:            Disables one shot transmission mode
-*********************************************************************************************************/
-INT8U MCP_CAN::disOneShotTX(void)                             
-{
-    mcp2515_modifyRegister(MCP_CANCTRL, MODE_ONESHOT, 0);
-    if((mcp2515_readRegister(MCP_CANCTRL) & MODE_ONESHOT) != 0)
-        return CAN_FAIL;
-    else
-        return CAN_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           mcp2515_abortTX
-** Descriptions:            Aborts any queued transmissions
-*********************************************************************************************************/
-INT8U MCP_CAN::abortTX(void)                             
-{
-    mcp2515_modifyRegister(MCP_CANCTRL, ABORT_TX, ABORT_TX);
-	
-    // Maybe check to see if the TX buffer transmission request bits are cleared instead?
-    if((mcp2515_readRegister(MCP_CANCTRL) & ABORT_TX) != ABORT_TX)
-	    return CAN_FAIL;
-    else
-	    return CAN_OK;
-}
-
-/*********************************************************************************************************
-** Function name:           setGPO
-** Descriptions:            Public function, Checks for r
-*********************************************************************************************************/
-INT8U MCP_CAN::setGPO(INT8U data)
-{
-    mcp2515_modifyRegister(MCP_BFPCTRL, MCP_BxBFS_MASK, (data<<4));
-	    
-    return 0;
-}
-
-/*********************************************************************************************************
-** Function name:           getGPI
-** Descriptions:            Public function, Checks for r
-*********************************************************************************************************/
-INT8U MCP_CAN::getGPI(void)
-{
-    INT8U res;
-    res = mcp2515_readRegister(MCP_TXRTSCTRL) & MCP_BxRTS_MASK;
-    return (res >> 3);
-}
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 143
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/mcp_can.h

@@ -1,143 +0,0 @@
-/*
-  mcp_can.h
-  2012 Copyright (c) Seeed Technology Inc.  All right reserved.
-  2017 Copyright (c) Cory J. Fowler  All Rights Reserved.
-
-  Author:Loovee
-  Contributor: Cory J. Fowler
-  2017-09-25
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-
-  1301  USA
-*/
-#ifndef _MCP2515_H_
-#define _MCP2515_H_
-
-#include "mcp_can_dfs.h"
-#define MAX_CHAR_IN_MESSAGE 8
-
-class MCP_CAN
-{
-    private:
-    
-    INT8U   m_nExtFlg;                                                  // Identifier Type
-                                                                        // Extended (29 bit) or Standard (11 bit)
-    INT32U  m_nID;                                                      // CAN ID
-    INT8U   m_nDlc;                                                     // Data Length Code
-    INT8U   m_nDta[MAX_CHAR_IN_MESSAGE];                            	// Data array
-    INT8U   m_nRtr;                                                     // Remote request flag
-    INT8U   m_nfilhit;                                                  // The number of the filter that matched the message
-    INT8U   MCPCS;                                                      // Chip Select pin number
-    INT8U   mcpMode;                                                    // Mode to return to after configurations are performed.
-    
-
-/*********************************************************************************************************
- *  mcp2515 driver function 
- *********************************************************************************************************/
-   // private:
-   private:
-
-    void mcp2515_reset(void);                                           // Soft Reset MCP2515
-
-    INT8U mcp2515_readRegister(const INT8U address);                    // Read MCP2515 register
-    
-    void mcp2515_readRegisterS(const INT8U address,                     // Read MCP2515 successive registers
-	                             INT8U values[], 
-                               const INT8U n);
-   
-    void mcp2515_setRegister(const INT8U address,                       // Set MCP2515 register
-                             const INT8U value);
-
-    void mcp2515_setRegisterS(const INT8U address,                      // Set MCP2515 successive registers
-                              const INT8U values[],
-                              const INT8U n);
-    
-    void mcp2515_initCANBuffers(void);
-    
-    void mcp2515_modifyRegister(const INT8U address,                    // Set specific bit(s) of a register
-                                const INT8U mask,
-                                const INT8U data);
-
-    INT8U mcp2515_readStatus(void);                                     // Read MCP2515 Status
-    INT8U mcp2515_setCANCTRL_Mode(const INT8U newmode);                 // Set mode
-    INT8U mcp2515_configRate(const INT8U canSpeed,                      // Set baud rate
-                             const INT8U canClock);
-                             
-    INT8U mcp2515_init(const INT8U canIDMode,                           // Initialize Controller
-                       const INT8U canSpeed,
-                       const INT8U canClock);
-		       
-    void mcp2515_write_mf( const INT8U mcp_addr,                        // Write CAN Mask or Filter
-                           const INT8U ext,
-                           const INT32U id );
-			       
-    void mcp2515_write_id( const INT8U mcp_addr,                        // Write CAN ID
-                           const INT8U ext,
-                           const INT32U id );
-
-    void mcp2515_read_id( const INT8U mcp_addr,                         // Read CAN ID
-				INT8U* ext,
-                                INT32U* id );
-
-    void mcp2515_write_canMsg( const INT8U buffer_sidh_addr );          // Write CAN message
-    void mcp2515_read_canMsg( const INT8U buffer_sidh_addr);            // Read CAN message
-    INT8U mcp2515_getNextFreeTXBuf(INT8U *txbuf_n);                     // Find empty transmit buffer
-    
-    
-      inline void initSS()  { pinMode(MCPCS, OUTPUT); }
-      inline void setSS()   {  digitalWrite(MCPCS, LOW); Serial.print(" SET CS["); Serial.print(MCPCS); Serial.print("] "); }
-      inline void resetSS() {  digitalWrite(MCPCS, HIGH); }
-    
-    
-
-/*********************************************************************************************************
- *  CAN operator function
- *********************************************************************************************************/
-
-    INT8U setMsg(INT32U id, INT8U rtr, INT8U ext, INT8U len, INT8U *pData);        // Set message
-    INT8U clearMsg();                                                   // Clear all message to zero
-    INT8U readMsg();                                                    // Read message
-    INT8U sendMsg();                                                    // Send message
-
-public:
-    MCP_CAN(INT8U _CS);
-    INT8U begin(INT8U idmodeset, INT8U speedset, INT8U clockset);       // Initialize controller parameters
-    INT8U init_Mask(INT8U num, INT8U ext, INT32U ulData);               // Initialize Mask(s)
-    INT8U init_Mask(INT8U num, INT32U ulData);                          // Initialize Mask(s)
-    INT8U init_Filt(INT8U num, INT8U ext, INT32U ulData);               // Initialize Filter(s)
-    INT8U init_Filt(INT8U num, INT32U ulData);                          // Initialize Filter(s)
-    INT8U setMode(INT8U opMode);                                        // Set operational mode
-    INT8U sendMsgBuf(INT32U id, INT8U ext, INT8U len, INT8U *buf);      // Send message to transmit buffer
-    INT8U sendMsgBuf(INT32U id, INT8U len, INT8U *buf);                 // Send message to transmit buffer
-    INT8U readMsgBuf(INT32U *id, INT8U *ext, INT8U *len, INT8U *buf);   // Read message from receive buffer
-    INT8U readMsgBuf(INT32U *id, INT8U *len, INT8U *buf);               // Read message from receive buffer
-    INT8U checkReceive(void);                                           // Check for received data
-    INT8U checkError(void);                                             // Check for errors
-    INT8U getError(void);                                               // Check for errors
-    INT8U errorCountRX(void);                                           // Get error count
-    INT8U errorCountTX(void);                                           // Get error count
-    INT8U enOneShotTX(void);                                            // Enable one-shot transmission
-    INT8U disOneShotTX(void);                                           // Disable one-shot transmission
-    INT8U abortTX(void);                                                // Abort queued transmission(s)
-    INT8U setGPO(INT8U data);                                           // Sets GPO
-    INT8U getGPI(void);                                                 // Reads GPI
-    
-  
-    
-};
-
-#endif
-/*********************************************************************************************************
- *  END FILE
- *********************************************************************************************************/

+ 0 - 476
SE/stuff/P5_Automation-library-dev/MCP_CAN_lib/mcp_can_dfs.h

@@ -1,476 +0,0 @@
-/*
-  mcp_can_dfs.h
-  2012 Copyright (c) Seeed Technology Inc.  All right reserved.
-  2017 Copyright (c) Cory J. Fowler  All Rights Reserved.
-
-  Author:Loovee
-  Contributor: Cory J. Fowler
-  2017-09-25
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-
-  1301  USA
-*/
-#ifndef _MCP2515DFS_H_
-#define _MCP2515DFS_H_
-
-#include <Arduino.h>
-#include <SPI.h>
-#include <inttypes.h>
-
-#ifndef INT32U
-#define INT32U unsigned long
-#endif
-
-#ifndef INT8U
-#define INT8U byte
-#endif
-
-// if print debug information
-#define DEBUG_MODE 1
-
-/*
- *   Begin mt
- */
-#define TIMEOUTVALUE    50
-#define MCP_SIDH        0
-#define MCP_SIDL        1
-#define MCP_EID8        2
-#define MCP_EID0        3
-
-#define MCP_TXB_EXIDE_M     0x08                                        /* In TXBnSIDL                  */
-#define MCP_DLC_MASK        0x0F                                        /* 4 LSBits                     */
-#define MCP_RTR_MASK        0x40                                        /* (1<<6) Bit 6                 */
-
-#define MCP_RXB_RX_ANY      0x60
-#define MCP_RXB_RX_EXT      0x40
-#define MCP_RXB_RX_STD      0x20
-#define MCP_RXB_RX_STDEXT   0x00
-#define MCP_RXB_RX_MASK     0x60
-#define MCP_RXB_BUKT_MASK   (1<<2)
-
-/*
-** Bits in the TXBnCTRL registers.
-*/
-#define MCP_TXB_TXBUFE_M    0x80
-#define MCP_TXB_ABTF_M      0x40
-#define MCP_TXB_MLOA_M      0x20
-#define MCP_TXB_TXERR_M     0x10
-#define MCP_TXB_TXREQ_M     0x08
-#define MCP_TXB_TXIE_M      0x04
-#define MCP_TXB_TXP10_M     0x03
-
-#define MCP_TXB_RTR_M       0x40                                        /* In TXBnDLC                   */
-#define MCP_RXB_IDE_M       0x08                                        /* In RXBnSIDL                  */
-#define MCP_RXB_RTR_M       0x40                                        /* In RXBnDLC                   */
-
-#define MCP_STAT_RXIF_MASK   (0x03)
-#define MCP_STAT_RX0IF       (1<<0)
-#define MCP_STAT_RX1IF       (1<<1)
-
-#define MCP_EFLG_RX1OVR     (1<<7)
-#define MCP_EFLG_RX0OVR     (1<<6)
-#define MCP_EFLG_TXBO       (1<<5)
-#define MCP_EFLG_TXEP       (1<<4)
-#define MCP_EFLG_RXEP       (1<<3)
-#define MCP_EFLG_TXWAR      (1<<2)
-#define MCP_EFLG_RXWAR      (1<<1)
-#define MCP_EFLG_EWARN      (1<<0)
-#define MCP_EFLG_ERRORMASK  (0xF8)                                      /* 5 MS-Bits                    */
-
-#define MCP_BxBFS_MASK    0x30
-#define MCP_BxBFE_MASK    0x0C
-#define MCP_BxBFM_MASK    0x03
-
-#define MCP_BxRTS_MASK    0x38
-#define MCP_BxRTSM_MASK   0x07
-
-/*
- *   Define MCP2515 register addresses
- */
-#define MCP_RXF0SIDH    0x00
-#define MCP_RXF0SIDL    0x01
-#define MCP_RXF0EID8    0x02
-#define MCP_RXF0EID0    0x03
-#define MCP_RXF1SIDH    0x04
-#define MCP_RXF1SIDL    0x05
-#define MCP_RXF1EID8    0x06
-#define MCP_RXF1EID0    0x07
-#define MCP_RXF2SIDH    0x08
-#define MCP_RXF2SIDL    0x09
-#define MCP_RXF2EID8    0x0A
-#define MCP_RXF2EID0    0x0B
-#define MCP_BFPCTRL     0x0C
-#define MCP_TXRTSCTRL   0x0D
-#define MCP_CANSTAT     0x0E
-#define MCP_CANCTRL     0x0F
-#define MCP_RXF3SIDH    0x10
-#define MCP_RXF3SIDL    0x11
-#define MCP_RXF3EID8    0x12
-#define MCP_RXF3EID0    0x13
-#define MCP_RXF4SIDH    0x14
-#define MCP_RXF4SIDL    0x15
-#define MCP_RXF4EID8    0x16
-#define MCP_RXF4EID0    0x17
-#define MCP_RXF5SIDH    0x18
-#define MCP_RXF5SIDL    0x19
-#define MCP_RXF5EID8    0x1A
-#define MCP_RXF5EID0    0x1B
-#define MCP_TEC            0x1C
-#define MCP_REC            0x1D
-#define MCP_RXM0SIDH    0x20
-#define MCP_RXM0SIDL    0x21
-#define MCP_RXM0EID8    0x22
-#define MCP_RXM0EID0    0x23
-#define MCP_RXM1SIDH    0x24
-#define MCP_RXM1SIDL    0x25
-#define MCP_RXM1EID8    0x26
-#define MCP_RXM1EID0    0x27
-#define MCP_CNF3        0x28
-#define MCP_CNF2        0x29
-#define MCP_CNF1        0x2A
-#define MCP_CANINTE        0x2B
-#define MCP_CANINTF        0x2C
-#define MCP_EFLG        0x2D
-#define MCP_TXB0CTRL    0x30
-#define MCP_TXB1CTRL    0x40
-#define MCP_TXB2CTRL    0x50
-#define MCP_RXB0CTRL    0x60
-#define MCP_RXB0SIDH    0x61
-#define MCP_RXB1CTRL    0x70
-#define MCP_RXB1SIDH    0x71
-
-
-#define MCP_TX_INT          0x1C                                    /* Enable all transmit interrup ts  */
-#define MCP_TX01_INT        0x0C                                    /* Enable TXB0 and TXB1 interru pts */
-#define MCP_RX_INT          0x03                                    /* Enable receive interrupts        */
-#define MCP_NO_INT          0x00                                    /* Disable all interrupts           */
-
-#define MCP_TX01_MASK       0x14
-#define MCP_TX_MASK        0x54
-
-/*
- *   Define SPI Instruction Set
- */
-#define MCP_WRITE           0x02
-
-#define MCP_READ            0x03
-
-#define MCP_BITMOD          0x05
-
-#define MCP_LOAD_TX0        0x40
-#define MCP_LOAD_TX1        0x42
-#define MCP_LOAD_TX2        0x44
-
-#define MCP_RTS_TX0         0x81
-#define MCP_RTS_TX1         0x82
-#define MCP_RTS_TX2         0x84
-#define MCP_RTS_ALL         0x87
-
-#define MCP_READ_RX0        0x90
-#define MCP_READ_RX1        0x94
-
-#define MCP_READ_STATUS     0xA0
-
-#define MCP_RX_STATUS       0xB0
-
-#define MCP_RESET           0xC0
-
-
-/*
- *   CANCTRL Register Values
- */
-#define MCP_NORMAL     0x00
-#define MCP_SLEEP      0x20
-#define MCP_LOOPBACK   0x40
-#define MCP_LISTENONLY 0x60
-#define MODE_CONFIG     0x80
-#define MODE_POWERUP    0xE0
-#define MODE_MASK       0xE0
-#define ABORT_TX        0x10
-#define MODE_ONESHOT    0x08
-#define CLKOUT_ENABLE   0x04
-#define CLKOUT_DISABLE  0x00
-#define CLKOUT_PS1      0x00
-#define CLKOUT_PS2      0x01
-#define CLKOUT_PS4      0x02
-#define CLKOUT_PS8      0x03
-
-
-/*
- *   CNF1 Register Values
- */
-#define SJW1            0x00
-#define SJW2            0x40
-#define SJW3            0x80
-#define SJW4            0xC0
-
-
-/*
- *   CNF2 Register Values
- */
-#define BTLMODE         0x80
-#define SAMPLE_1X       0x00
-#define SAMPLE_3X       0x40
-
-
-/*
- *   CNF3 Register Values
- */
-#define SOF_ENABLE      0x80
-#define SOF_DISABLE     0x00
-#define WAKFIL_ENABLE   0x40
-#define WAKFIL_DISABLE  0x00
-
-
-/*
- *   CANINTF Register Bits
- */
-#define MCP_RX0IF       0x01
-#define MCP_RX1IF       0x02
-#define MCP_TX0IF       0x04
-#define MCP_TX1IF       0x08
-#define MCP_TX2IF       0x10
-#define MCP_ERRIF       0x20
-#define MCP_WAKIF       0x40
-#define MCP_MERRF       0x80
-
-
-/*
- *  Speed 8M
- */
-#define MCP_8MHz_1000kBPS_CFG1 (0x00)  
-#define MCP_8MHz_1000kBPS_CFG2 (0xC0)  /* Enabled SAM bit     */
-#define MCP_8MHz_1000kBPS_CFG3 (0x80)  /* Sample point at 75% */
-
-#define MCP_8MHz_500kBPS_CFG1 (0x00)
-#define MCP_8MHz_500kBPS_CFG2 (0xD1)   /* Enabled SAM bit     */
-#define MCP_8MHz_500kBPS_CFG3 (0x81)   /* Sample point at 75% */
-
-#define MCP_8MHz_250kBPS_CFG1 (0x80)   /* Increased SJW       */
-#define MCP_8MHz_250kBPS_CFG2 (0xE5)   /* Enabled SAM bit     */
-#define MCP_8MHz_250kBPS_CFG3 (0x83)   /* Sample point at 75% */
-
-#define MCP_8MHz_200kBPS_CFG1 (0x80)   /* Increased SJW       */
-#define MCP_8MHz_200kBPS_CFG2 (0xF6)   /* Enabled SAM bit     */
-#define MCP_8MHz_200kBPS_CFG3 (0x84)   /* Sample point at 75% */
-
-#define MCP_8MHz_125kBPS_CFG1 (0x81)   /* Increased SJW       */
-#define MCP_8MHz_125kBPS_CFG2 (0xE5)   /* Enabled SAM bit     */
-#define MCP_8MHz_125kBPS_CFG3 (0x83)   /* Sample point at 75% */
-
-#define MCP_8MHz_100kBPS_CFG1 (0x81)   /* Increased SJW       */
-#define MCP_8MHz_100kBPS_CFG2 (0xF6)   /* Enabled SAM bit     */
-#define MCP_8MHz_100kBPS_CFG3 (0x84)   /* Sample point at 75% */
-
-#define MCP_8MHz_80kBPS_CFG1 (0x84)    /* Increased SJW       */
-#define MCP_8MHz_80kBPS_CFG2 (0xD3)    /* Enabled SAM bit     */
-#define MCP_8MHz_80kBPS_CFG3 (0x81)    /* Sample point at 75% */
-
-#define MCP_8MHz_50kBPS_CFG1 (0x84)    /* Increased SJW       */
-#define MCP_8MHz_50kBPS_CFG2 (0xE5)    /* Enabled SAM bit     */
-#define MCP_8MHz_50kBPS_CFG3 (0x83)    /* Sample point at 75% */
-
-#define MCP_8MHz_40kBPS_CFG1 (0x84)    /* Increased SJW       */
-#define MCP_8MHz_40kBPS_CFG2 (0xF6)    /* Enabled SAM bit     */
-#define MCP_8MHz_40kBPS_CFG3 (0x84)    /* Sample point at 75% */
-
-#define MCP_8MHz_33k3BPS_CFG1 (0x85)   /* Increased SJW       */
-#define MCP_8MHz_33k3BPS_CFG2 (0xF6)   /* Enabled SAM bit     */
-#define MCP_8MHz_33k3BPS_CFG3 (0x84)   /* Sample point at 75% */
-
-#define MCP_8MHz_31k25BPS_CFG1 (0x87)  /* Increased SJW       */
-#define MCP_8MHz_31k25BPS_CFG2 (0xE5)  /* Enabled SAM bit     */
-#define MCP_8MHz_31k25BPS_CFG3 (0x83)  /* Sample point at 75% */
-
-#define MCP_8MHz_20kBPS_CFG1 (0x89)    /* Increased SJW       */
-#define MCP_8MHz_20kBPS_CFG2 (0xF6)    /* Enabled SAM bit     */
-#define MCP_8MHz_20kBPS_CFG3 (0x84)    /* Sample point at 75% */
-
-#define MCP_8MHz_10kBPS_CFG1 (0x93)    /* Increased SJW       */
-#define MCP_8MHz_10kBPS_CFG2 (0xF6)    /* Enabled SAM bit     */
-#define MCP_8MHz_10kBPS_CFG3 (0x84)    /* Sample point at 75% */
-
-#define MCP_8MHz_5kBPS_CFG1 (0xA7)     /* Increased SJW       */
-#define MCP_8MHz_5kBPS_CFG2 (0xF6)     /* Enabled SAM bit     */
-#define MCP_8MHz_5kBPS_CFG3 (0x84)     /* Sample point at 75% */
-
-/*
- *  speed 16M
- */
-#define MCP_16MHz_1000kBPS_CFG1 (0x00)
-#define MCP_16MHz_1000kBPS_CFG2 (0xCA)
-#define MCP_16MHz_1000kBPS_CFG3 (0x81)    /* Sample point at 75% */
-
-#define MCP_16MHz_500kBPS_CFG1 (0x40)     /* Increased SJW       */
-#define MCP_16MHz_500kBPS_CFG2 (0xE5)
-#define MCP_16MHz_500kBPS_CFG3 (0x83)     /* Sample point at 75% */
-
-#define MCP_16MHz_250kBPS_CFG1 (0x41)
-#define MCP_16MHz_250kBPS_CFG2 (0xE5)
-#define MCP_16MHz_250kBPS_CFG3 (0x83)     /* Sample point at 75% */
-
-#define MCP_16MHz_200kBPS_CFG1 (0x41)     /* Increased SJW       */
-#define MCP_16MHz_200kBPS_CFG2 (0xF6)
-#define MCP_16MHz_200kBPS_CFG3 (0x84)     /* Sample point at 75% */
-
-#define MCP_16MHz_125kBPS_CFG1 (0x43)     /* Increased SJW       */
-#define MCP_16MHz_125kBPS_CFG2 (0xE5)
-#define MCP_16MHz_125kBPS_CFG3 (0x83)     /* Sample point at 75% */
-
-#define MCP_16MHz_100kBPS_CFG1 (0x44)     /* Increased SJW       */
-#define MCP_16MHz_100kBPS_CFG2 (0xE5)
-#define MCP_16MHz_100kBPS_CFG3 (0x83)     /* Sample point at 75% */
-
-#define MCP_16MHz_80kBPS_CFG1 (0x44)      /* Increased SJW       */
-#define MCP_16MHz_80kBPS_CFG2 (0xF6)
-#define MCP_16MHz_80kBPS_CFG3 (0x84)      /* Sample point at 75% */
-
-#define MCP_16MHz_50kBPS_CFG1 (0x47)      /* Increased SJW       */
-#define MCP_16MHz_50kBPS_CFG2 (0xF6)
-#define MCP_16MHz_50kBPS_CFG3 (0x84)      /* Sample point at 75% */
-
-#define MCP_16MHz_40kBPS_CFG1 (0x49)      /* Increased SJW       */
-#define MCP_16MHz_40kBPS_CFG2 (0xF6)
-#define MCP_16MHz_40kBPS_CFG3 (0x84)      /* Sample point at 75% */
-
-#define MCP_16MHz_33k3BPS_CFG1 (0x4E)
-#define MCP_16MHz_33k3BPS_CFG2 (0xE5)
-#define MCP_16MHz_33k3BPS_CFG3 (0x83)     /* Sample point at 75% */
-
-#define MCP_16MHz_20kBPS_CFG1 (0x53)      /* Increased SJW       */
-#define MCP_16MHz_20kBPS_CFG2 (0xF6)
-#define MCP_16MHz_20kBPS_CFG3 (0x84)      /* Sample point at 75% */
-
-#define MCP_16MHz_10kBPS_CFG1 (0x67)      /* Increased SJW       */
-#define MCP_16MHz_10kBPS_CFG2 (0xF6)
-#define MCP_16MHz_10kBPS_CFG3 (0x84)      /* Sample point at 75% */
-
-#define MCP_16MHz_5kBPS_CFG1 (0x3F)
-#define MCP_16MHz_5kBPS_CFG2 (0xFF)
-#define MCP_16MHz_5kBPS_CFG3 (0x87)       /* Sample point at 68% */
-
-/*
- *  speed 20M
- */
-#define MCP_20MHz_1000kBPS_CFG1 (0x00)
-#define MCP_20MHz_1000kBPS_CFG2 (0xD9)
-#define MCP_20MHz_1000kBPS_CFG3 (0x82)     /* Sample point at 80% */
-
-#define MCP_20MHz_500kBPS_CFG1 (0x40)     /* Increased SJW       */
-#define MCP_20MHz_500kBPS_CFG2 (0xF6)
-#define MCP_20MHz_500kBPS_CFG3 (0x84)     /* Sample point at 75% */
-
-#define MCP_20MHz_250kBPS_CFG1 (0x41)     /* Increased SJW       */
-#define MCP_20MHz_250kBPS_CFG2 (0xF6)
-#define MCP_20MHz_250kBPS_CFG3 (0x84)     /* Sample point at 75% */
-
-#define MCP_20MHz_200kBPS_CFG1 (0x44)     /* Increased SJW       */
-#define MCP_20MHz_200kBPS_CFG2 (0xD3)
-#define MCP_20MHz_200kBPS_CFG3 (0x81)     /* Sample point at 80% */
-
-#define MCP_20MHz_125kBPS_CFG1 (0x44)     /* Increased SJW       */
-#define MCP_20MHz_125kBPS_CFG2 (0xE5)
-#define MCP_20MHz_125kBPS_CFG3 (0x83)     /* Sample point at 75% */
-
-#define MCP_20MHz_100kBPS_CFG1 (0x44)     /* Increased SJW       */
-#define MCP_20MHz_100kBPS_CFG2 (0xF6)
-#define MCP_20MHz_100kBPS_CFG3 (0x84)     /* Sample point at 75% */
-
-#define MCP_20MHz_80kBPS_CFG1 (0xC4)      /* Increased SJW       */
-#define MCP_20MHz_80kBPS_CFG2 (0xFF)
-#define MCP_20MHz_80kBPS_CFG3 (0x87)      /* Sample point at 68% */
-
-#define MCP_20MHz_50kBPS_CFG1 (0x49)      /* Increased SJW       */
-#define MCP_20MHz_50kBPS_CFG2 (0xF6)
-#define MCP_20MHz_50kBPS_CFG3 (0x84)      /* Sample point at 75% */
-
-#define MCP_20MHz_40kBPS_CFG1 (0x18)
-#define MCP_20MHz_40kBPS_CFG2 (0xD3)
-#define MCP_20MHz_40kBPS_CFG3 (0x81)      /* Sample point at 80% */
-
-
-#define MCPDEBUG        (0)
-#define MCPDEBUG_TXBUF  (0)
-#define MCP_N_TXBUFFERS (3)
-
-#define MCP_RXBUF_0 (MCP_RXB0SIDH)
-#define MCP_RXBUF_1 (MCP_RXB1SIDH)
-
-#define MCP2515_SELECT()   digitalWrite(MCPCS, LOW)
-#define MCP2515_UNSELECT() digitalWrite(MCPCS, HIGH)
-
-#define MCP2515_OK         (0)
-#define MCP2515_FAIL       (1)
-#define MCP_ALLTXBUSY      (2)
-
-#define CANDEBUG   1
-
-#define CANUSELOOP 0
-
-#define CANSENDTIMEOUT (200)                                            /* milliseconds                 */
-
-/*
- *   initial value of gCANAutoProcess
- */
-#define CANAUTOPROCESS (1)
-#define CANAUTOON  (1)
-#define CANAUTOOFF (0)
-
-#define CAN_STDID (0)
-#define CAN_EXTID (1)
-
-#define CANDEFAULTIDENT    (0x55CC)
-#define CANDEFAULTIDENTEXT (CAN_EXTID)
-
-#define MCP_STDEXT   0                                                  /* Standard and Extended        */
-#define MCP_STD      1                                                  /* Standard IDs ONLY            */
-#define MCP_EXT      2                                                  /* Extended IDs ONLY            */
-#define MCP_ANY      3                                                  /* Disables Masks and Filters   */
-
-#define MCP_20MHZ    0
-#define MCP_16MHZ    1
-#define MCP_8MHZ     2
-
-#define CAN_4K096BPS 0
-#define CAN_5KBPS    1
-#define CAN_10KBPS   2
-#define CAN_20KBPS   3
-#define CAN_31K25BPS 4
-#define CAN_33K3BPS  5
-#define CAN_40KBPS   6
-#define CAN_50KBPS   7
-#define CAN_80KBPS   8
-#define CAN_100KBPS  9
-#define CAN_125KBPS  10
-#define CAN_200KBPS  11
-#define CAN_250KBPS  12
-#define CAN_500KBPS  13
-#define CAN_1000KBPS 14
-
-#define CAN_OK             (0)
-#define CAN_FAILINIT       (1)
-#define CAN_FAILTX         (2)
-#define CAN_MSGAVAIL       (3)
-#define CAN_NOMSG          (4)
-#define CAN_CTRLERROR      (5)
-#define CAN_GETTXBFTIMEOUT (6)
-#define CAN_SENDMSGTIMEOUT (7)
-#define CAN_FAIL       (0xff)
-
-#define CAN_MAX_CHAR_IN_MESSAGE (8)
-
-#endif
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/

+ 0 - 508
SE/stuff/P5_Automation-library-dev/MobaTools/LICENSE

@@ -1,508 +0,0 @@
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-(This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.)
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard.  To achieve this, non-free programs must be
-allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    {description}
-    Copyright (C) {year} {fullname}
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library 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
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-    USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random
-  Hacker.
-
-  {signature of Ty Coon}, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-    Status API Training Shop Blog About Pricing 
-
-    © 2016 GitHub, Inc. Terms Privacy Security Contact Help 

BIN
SE/stuff/P5_Automation-library-dev/MobaTools/MobaTools-09 -en.pdf


BIN
SE/stuff/P5_Automation-library-dev/MobaTools/MobaTools-09.pdf


+ 0 - 27
SE/stuff/P5_Automation-library-dev/MobaTools/README.md

@@ -1,27 +0,0 @@
-# MobaTools
-Arduino library for model railroaders ( and maybe for others too ;)
-
-
-It contains 4 classes:
-
-Servo8: 
-Can control up to 16 servos. Compatible with arduino servo lib, but allows to control 
-the speed of the servo.
-
-Stepper4: 
-A class to control unipolar stepper motors. The arduino sketch is not blocked while 
-the stepper is moving. After setting a reference point, the stepper can be positioned 
-absolutely just like a servo. But without the angle limitation of 0--180 degrees.
-
-Softled: 
-Allows easy softon / softoff of leds. It works on all digital outputs.
-
-Eggtimer: 
-Allows easy nonblocking timedelays in sketches.
-
-
-The library uses Timer1 for all classes. V1.0: from this version on, timer 3 is used instead of timer 1 if available.
-
-There is no special function that has to be
-called in the loop frequently. You can even use the delay() function in the loop while
-servos and steppers are moving.

+ 0 - 56
SE/stuff/P5_Automation-library-dev/MobaTools/examples/Servo_01/Servo_01.ino

@@ -1,56 +0,0 @@
-#include <MobaTools.h>
-/* Demo zum langsamen Bewegen eines Servos
- * Die aktuelle Version der MoBatools erlaubt bis zu 16 Servos nur an beliebigen Pins
- * Eine gleichzeitige Verwendung mit der Standard Servo Library des Arduino
- * ist nicht möglich, da die gleichen HW-Komponenten verwendet werden.
- * Die Aufrufe sind kompatibel zur Standard-Servo Library. 
- * zusätzliche Aufrufe:
- * Servo2.setSpeed( wert ); Vorgabe der Geschwindigkeit. Je größer die Zahl, umso
- *                          größer ist die Geschwindigkeit. Bei 0 (defaultwert)
- *                          verhält das Servo sich wie bei der Standard Bibliothek
- * byte = Servo2.moving();  gibt den noch verbleibenden Fahrweg in % vom gesamten
- *                          Verfahrweg an. Bei 0 hat das Servo die Zielposition
- *                           erreicht und steht.
- * fehlende Aufrufe:
- * writeMicroseconds() auch beim normalen write Aufruf können Microsekunden übergeben 
- *                     werden. Die Unterscheidung Winkel (0..180) und Mikrosekunden 
- *                    ( 700...2300 )ergibt sich aus dem Zahlenwert.
- * 
-*/
-// Die Taster müssen so angeschlossen sein, dass der Eingang bei gedrücktem
-// Taster auf LOW (=0) geht. 
-const int tasterPin1 = 2;    //Taster1 Pin 2
-const int tasterPin2 = 3;    //Taster2  Pin 3
-const int servoPin =  9;  // Anschluß für den Servo 
-// bei Werten, die sich im Programm nie verändern, sollte immer 'const' vorangestellt
-// werden
-
-
-bool tasterStatus1, tasterStatus2;
-Servo8 meinServo;
-
-void setup() {
-    pinMode(tasterPin1, INPUT_PULLUP); // so ist kein externer pullup Widerstand am 
-    pinMode(tasterPin2, INPUT_PULLUP); // Taster erforderlich
-    
-    meinServo.attach(servoPin); //Servo an Pin 9
-    meinServo.setSpeed( 5 );    // Verfahrgeschwindigkeit einstellen
-}
-
-void loop() {
-    tasterStatus1 = digitalRead(tasterPin1);
-    tasterStatus2 = digitalRead(tasterPin2);
-
-    if (tasterStatus1 == LOW) {
-        meinServo.write(40); //wird langsam  drehen
-        delay(100);
-    }
-
-    if (tasterStatus2 == LOW) {
-        meinServo.write(120); //wird langsam drehen
-        delay(100);
-    }
-
-    delay(20);
-
-}

+ 0 - 60
SE/stuff/P5_Automation-library-dev/MobaTools/examples/Servo_02/Servo_02.ino

@@ -1,60 +0,0 @@
-#include <MobaTools.h>
-/* Demo zum langsamen Bewegen eines Servos
- * Die aktuelle Version der MoBatools erlaubt bis zu 16 Servos nur an beliebigen Pins
- * Eine gleichzeitige Verwendung mit der Standard Servo Library des Arduino
- * ist nicht möglich, da die gleichen HW-Komponenten verwendet werden.
- * Die Aufrufe sind kompatibel zur Standard-Servo Library. 
- * zusätzliche Aufrufe:
- * Servo2.setSpeed( wert ); Vorgabe der Geschwindigkeit. Je größer die Zahl, umso
- *                          größer ist die Geschwindigkeit. Bei 0 (defaultwert)
- *                          verhält das Servo sich wie bei der Standard Bibliothek
- * byte = Servo2.moving();  gibt den noch verbleibenden Fahrweg in % vom gesamten
- *                          Verfahrweg an. Bei 0 hat das Servo die Zielposition
- *                           erreicht und steht.
- * fehlende Aufrufe:
- * writeMicroseconds() auch beim normalen write Aufruf können Microsekunden übergeben 
- *                     werden. Die Unterscheidung Winkel (0..180) und Mikrosekunden 
- *                    ( 700...2300 )ergibt sich aus dem Zahlenwert.
- * 
- * Demo 02 : mit Abfrage der Servobewegung.
- * In diesem Sketch kann das Servo erst umgesteuert werden, wenn es seine Zielposition 
- * erreicht hat und steht. Im Demo Servo_01 kann das Servo jederzeit umgesteuert werden
-*/
-
-// Die Taster müssen so angeschlossen sein, dass der Eingang bei gedrücktem
-// Taster auf LOW (=0) geht. 
-const int tasterPin1 = 2;    //Taster1 Pin 2
-const int tasterPin2 = 3;    //Taster2  Pin 3
-const int servoPin =  9;  // Anschluß für den Servo
-// bei Werten, die sich im Programm nie verändern, sollte immer 'const' vorangestellt
-// werden
-
-
-int tasterStatus1, tasterStatus2;
-Servo8 meinServo;
-
-void setup() {
-    pinMode(tasterPin1, INPUT_PULLUP); // so ist kein externer pullup Widerstand am 
-    pinMode(tasterPin2, INPUT_PULLUP); // Taster erforderlich
-    
-    meinServo.attach(servoPin); //Servo an Pin 9
-    meinServo.setSpeed( 5 );    // Verfahrgeschwindigkeit einstellen
-}
-
-void loop() {
-    tasterStatus1 = digitalRead(tasterPin1);
-    tasterStatus2 = digitalRead(tasterPin2);
-
-    if (tasterStatus1 == LOW && meinServo.moving() == 0 ) {
-        meinServo.write(40); //wird langsam  drehen
-        delay(100);
-    }
-
-    if (tasterStatus2 == LOW && meinServo.moving() == 0) {
-        meinServo.write(120); //wird langsam drehen
-        delay(100);
-    }
-
-    delay(20);
-
-}

+ 0 - 27
SE/stuff/P5_Automation-library-dev/MobaTools/examples/SoftLed_01/SoftLed_01.ino

@@ -1,27 +0,0 @@
-#include <MobaTools.h>
-/* Demo: weiches Auf/Abblenden einer LED
- *  Mit der Klasse SoftLed lässt sich eine Led 'weich' ein- und ausschalten
- * Die Led muss an einem PWM-fähigen pin angeschlossen sein, d.h. an einem Pin
- * an dem auch analogWrite() funktioniert.
- * SoftLed.attach( byte Pinnr );// Anschlußpin für die Led festlegen
- * SoftLed.riseTime( int zeit );// Zeit für auf/abblenden in ms
- * SoftLed.on();                // 'weich' einschalten
- * SoftLed.off();               // 'weich' ausschalten
-*/
-
-const int ledPin =  5;  // PWM - fähiger Pin
-
-
-SoftLed meinLed;
-
-void setup() {
-    meinLed.attach(ledPin); 
-    meinLed.riseTime( 500 );    // Aufblendzeit in ms
-}
-
-void loop() {
-	meinLed.on();
-	delay(1000);
-	meinLed.off();
-	delay(1000);
-}

+ 0 - 41
SE/stuff/P5_Automation-library-dev/MobaTools/examples/Stepper_01/Stepper_01.ino

@@ -1,41 +0,0 @@
-#include <MobaTools.h>
-/*  Demo zum Anschluß eines unipolaren Stepmotors 28BYJ-48
- *  Der Schrittmotor kann wahlweise direkt über 4 frei wählbare Pins, oder über die SPI-
- *  Schnittstelle und Schieberegister angeschlossen werden. 
- *  SPI belegt beim UNO oder nano die Pins 10(SS),11(MOSI) und 13(SCK)
- *  Pin 12 (MISO) wird zwar nicht genutzt, aber von der HW belegt
-*/
-Stepper4 Step1(4096);           // HALFSTEP ist default
-Stepper4 Step2(2048,FULLSTEP);
-
-
-void setup() {
-    Step1.attach( 4,5,6,7 );    // Anschluß an digitalen Ausgängen
-    Step2.attach( SPI_1 );      // an die SPI-Schnittstelle muss ein Schieberegister angschlossen werden
-                                // 
-    Step1.setSpeed( 60 );       // = 6 U/Min
-    Step2.setSpeed( 120 );      // = 12 U/Min
-    Step2.rotate( -1 );         // Motor 2 dreht dauerhaft rückwärts
-    Step1.setZero();            // Referenzpunkt für Motor 1 setzen
-    Step1.write(360);           // 1 Umdrehung vorwärts
-    while( Step1.moving() );    // warten bis die Bewegung abgeschlossen ist
-    delay(1000);                // 1 Sec stillstehen
-    Step1.write(0);             // 1 Umdrehung zurück zum Referenzpunkt
-    while( Step1.moving() );    // warten bis Stillstand
-    delay(1000);                // Motor steht 1 sec.
-    Step1.doSteps(4096);        // 4096 Schritte vorwärts ( = auch 1 Umdrehung )
-    while( Step1.moving() );
-    delay(1000);
-    Step1.write(0);             // 1 Umdrehung zurück zum Referenzpunkt ( auch bei doSteps wird die
-    while( Step1.moving() );    // Position verfolgt
-    delay(1000);                // Motor steht 1 sec.
-    Step1.detach();             // Motor deaktivieren
-    Step1.attach(7,6,5,4);      // mit umgekehrter Reihenfolge der Pins aktivieren
-    Step1.doSteps(4096);        // 'vorwärts' ist jetzt andersherum!
-    while( Step1.moving() );
-    delay(1000);
-
-}
-
-void loop() {
-}

+ 0 - 90
SE/stuff/P5_Automation-library-dev/MobaTools/examples/Wechselblinker/Wechselblinker.ino

@@ -1,90 +0,0 @@
-#include <MobaTools.h>
-
-/* Demo: Wechselblinker
- * Dieses Demo ist etwas komplexer und zeigt die Realisierung eines
- * Wechselblinker, der per Schalter ein- und ausgeschaltet wird.
- * Wie bei Wechselblinkern an einem BÜ üblich, starten die beiden Lampen
- * gleichzeitig, um dann im Wechseltakt zu blinken
- * Dieses Demo verwendet auch die 'Eieruhr' um Zeitverzögerungen zu realisieren
- * Die 'Eieruhr' ist ein Zeitzähler, der aufgezogen werden kann und im loop kann
- * abgefragt werden, ob er abgelaufen ist.
-*/
-
-// Festlegen der Ports
-const int Blinker1P =  5;  // Die beiden Led's des
-const int Blinker2P =  6;  // Wechselblinkers.
-const int SchalterP =  7;  // Schalter, der den Wechselblinker ein und ausschaltet
-
-// Weitere Konstante
-const int wbZykl = 1100;   // Zykluszeit des Wechselblinkers
-const int wbSoft = 400;    // Auf/Abblendzeit der Lampen
-
-// Zustand des Wechselblinker
-byte wblZustand = 0;   // In dieser Variable wird hinterlegt, in welchem Zustand
-						// sich der Wechselblinker gerade befindet
-#define   WBL_AUS     0 	// beide Lampen sind aus
-#define   WBL_START   1   	// Startphase: beide Lampen sind an
-#define   WBL_BLINKT  2   	// Die Lampen blinken normal im Wechsel
-byte ledState;              // HIGH : Blinker1 ist an, LOW Blinker2 ist an
-
-SoftLed Blinker1;
-SoftLed Blinker2;
-
-EggTimer BlinkUhr;
-
-void setup() {
-    pinMode(SchalterP, INPUT_PULLUP); 
-    Blinker1.attach(Blinker1P);  // die Ausgänge werden automatisch auf OUTPUT gesetzt
-    Blinker2.attach(Blinker2P); 
-    Blinker1.riseTime( wbSoft );    // Aufblendzeit in ms
-    Blinker2.riseTime( wbSoft );    // Aufblendzeit in ms
-}
-
-void loop() {
-    // Wechselblinker
-    switch (wblZustand) {
-      case WBL_AUS:
-        // Beide Lampen sind aus, warten auf einschalten
-        if ( digitalRead(SchalterP) == HIGH && BlinkUhr.running() == false ) {
-            // Beide Leds einschalten, Timer für gemeinsames Startleuchten
-            Blinker1.on();
-            Blinker2.on();
-            BlinkUhr.setTime( wbSoft );
-            wblZustand = WBL_START;
-        }
-        break;
-      case WBL_START:
-        // Startphase: Nach Zeitablauf erste Led wieder aus
-        if ( BlinkUhr.running() == false ) {
-            // Die Startzeit ist abgelaufen, Übergang zur normalen Blinkphase
-            ledState = HIGH;
-            Blinker2.off();
-            BlinkUhr.setTime(wbZykl/2); // Zeitverzögerung setzen
-            wblZustand = WBL_BLINKT;
-        }
-        break;
-      case WBL_BLINKT:
-        if ( BlinkUhr.running() == false ) {
-            BlinkUhr.setTime(wbZykl/2); // Zeitverzögerung setzen
-            if ( ledState == LOW ) {
-                Blinker1.on();
-                Blinker2.off();
-                ledState = HIGH;
-            } else {
-                ledState = LOW;
-                Blinker2.on();
-                Blinker1.off();
-            }
-        }
-        if ( digitalRead(SchalterP) == LOW ) {
-            // Wechselblinker abschalten
-            Blinker1.off();
-            Blinker2.off();
-            wblZustand = WBL_AUS;
-            BlinkUhr.setTime(wbZykl);   // minimale 'Aus' zeit des Blinkers
-                                        //( schützt vor Schalterprellen )
-        }
-        break;
-            
-    } // Ende switch Wechselblinker
-}

+ 0 - 57
SE/stuff/P5_Automation-library-dev/MobaTools/examples/Zeitgeber_01/Zeitgeber_01.ino

@@ -1,57 +0,0 @@
-#include <MobaTools.h>
-/* Demo: Zeitverzögerungen ohne delay-befehl
- * Der 'eggtimer' arbeitet im Prinzip wie ein Kurzzeitwecker in der
- * Küche: Man zieht ihn auf eine bestimmte Zeit auf, und dann läuft 
- * er bis 0 zurück. Im Gegensatz zum Küchenwecker klingelt er aber nicht.
- * Man muss zyklisch nachschauen, ob er abgelaufen ist. Das passt aber
- * perfekt zum prinzip des 'loop', also einer Endlosschleife, in der man
- * zyklisch abfragt.
- * Aufrufe:
- * EggTimer.setTime( long Laufzeit );    setzt die Zeit in ms
- * bool = EggTimer.running();       == true solange die Zeit noch läuft, 
- *                                  == false wenn abgelaufen
- *                                  
- * Im Gegensatz zum Verfahren mit delay() lassen sich damit mehrere
- * unabhängige und asynchrone Taktzeiten realisieren
- * In dieser Demo blinken 2 Led mit unterschiedlichen Taktraten
-*/
-
-const int led1P =  5; 
-const int led2P =  6; 
-
-EggTimer Blinkzeit1;
-EggTimer Blinkzeit2;
-
-void setup() {
-    pinMode(led1P, OUTPUT); 
-    pinMode(led2P, OUTPUT);
-}
-
-void loop() {
-    // -------- Blinken der 1. Led ------------------
-    // diese Led blinkt mit unsymetrischem Taktverhältnis
-	if ( Blinkzeit1.running()== false ) {
-        // Blinkzeit abgelaufen, Ausgang toggeln und
-        // Zeit neu aufziehen
-        if ( digitalRead( led1P ) == HIGH ) {
-            digitalWrite( led1P, LOW );
-            Blinkzeit1.setTime( 600 );
-       } else {
-            digitalWrite( led1P, HIGH );
-            Blinkzeit1.setTime( 300 );
-        }
-	}
-   
-    // -------- Blinken der 2. Led ------------------
-    // Diese Led blinkt symetrisch
-    if ( Blinkzeit2.running() == false ) {
-        // Blinkzeit abgelaufen, Ausgang toggeln und
-        // Zeit neu aufziehen
-        if ( digitalRead( led2P ) == HIGH ) {
-            digitalWrite( led2P, LOW);
-        } else {
-            digitalWrite( led2P, HIGH);
-        }
-        Blinkzeit2.setTime( 633 );
-    }
-}

+ 0 - 79
SE/stuff/P5_Automation-library-dev/MobaTools/keywords.txt

@@ -1,79 +0,0 @@
-#######################################
-# Syntax Coloring Map Servo
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-MobaTools	KEYWORD1
-
-Servo8	KEYWORD1
-Servo2	KEYWORD1
-EggTimer	KEYWORD1    
-SoftLed	KEYWORD1   
-Stepper4	KEYWORD1
- 
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-#Methods for Class Servo2
-attach	KEYWORD2
-detach	KEYWORD2
-write	KEYWORD2
-read	KEYWORD2
-readMicroseconds	KEYWORD2
-read	KEYWORD2
-setSpeed	KEYWORD2
-moving	KEYWORD2
-setMinimumPulse	KEYWORD2
-setMaximumPulse	KEYWORD2
-
-#Methods for Class EggTimer
-setTime	KEYWORD2
-running	KEYWORD2
-
-#Methods for Class SoftLed 
-attach	KEYWORD2
-riseTime	KEYWORD2
-on	KEYWORD2
-off	KEYWORD2
-toggle	KEYWORD2
-write	KEYWORD2
-
-#Methods for Class Stepper4
-attach	KEYWORD2
-detach	KEYWORD2
-write	KEYWORD2
-setZero	KEYWORD2
-setSpeed	KEYWORD2
-doSteps	KEYWORD2
-rotate	KEYWORD2
-stop	KEYWORD2
-moving	KEYWORD2
-read	KEYWORD2
-attached	KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-MAX_STEPPER	LITERAL1
-SPI_1	LITERAL1
-SPI_2	LITERAL1
-SPI_3	LITERAL1
-SPI_4	LITERAL1
-HALFSTEP	LITERAL1
-FULLSTEP	LITERAL1
-MAX_SERVOS	LITERAL1
-MINPULSEWIDTH	LITERAL1
-MAXPULSEWIDTH	LITERAL1
-HIGHRES	LITERAL1
-SPEEDV08	LITERAL1
-MAX_LEDS	LITERAL1
-LINEAR	LITERAL1
-BULB	LITERAL1
-ON	LITERAL1
-OFF	LITERAL1
-
-
-

+ 0 - 9
SE/stuff/P5_Automation-library-dev/MobaTools/library.properties

@@ -1,9 +0,0 @@
-name=MobaTools
-version=1.0.3
-author=MicroBahner
-maintainer=MicroBahner
-sentence=Special functions for model railroaders, for arduino uno, mini, nano, micro and mega
-paragraph=Bibliothek mit Funktionen für Modellbahner:<br />Steuern von bis zu 16 Servos mit Geschwindigkeitskontrolle. Ebenso 4 unipolare Schrittmotore<br />Funktionen zum weichen auf/abblenden von Leds.<br />Zeitgeberfunktion.<br />This library can control up to 16 servos with speed control and 4 stepper motors.<br /> There are also functions for a bulb simulation with leds.<br />It uses timer 1 for all tasks. If timer 3 is available it is used instead.<br />
-category=Device Control
-url=https://github.com/MicroBahner/MobaTools
-architectures=avr,STM32F1

+ 0 - 1620
SE/stuff/P5_Automation-library-dev/MobaTools/src/MobaTools.cpp

@@ -1,1620 +0,0 @@
-
-/*
-  MobaTools V1.0
-   (C) 11-2017 fpm fpm@mnet-online.de
-   
-  History:
-  V1.0  11-2017 Use of Timer 3 if available ( on AtMega32u4 and AtMega2560 )
-  V0.91 08-2017
-        Enhanced EggTimer Class. Additional method 'getTime'
-        Uses only 5 byte Ram per Instance.
-        No Problems with rollover of millis and if the methods are called very rarely
-        ( less than once every 25 days )
-  V0.9  03-2017
-        Better resolution for the 'speed' paramter (programm starts in compatibility mode
-        preparations for porting to STM32F1 platform
-        
-  V0.8 02-2017
-        Enable Softleds an all digital outputs
-  V0.7 01-2017
-		Allow nested Interrupts with the servos. This allows more precise other
-        interrupts e.g. for NmraDCC Library.
-		A4988 stepper driver IC is supported (needs only 2 ports: step and direction)
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#include "MobaTools.h"
-#include <avr/interrupt.h>
-#include <Arduino.h>
-
-// Debug-Ports
-//#define debugTP
-//#define debugPrint
-#ifdef debugTP 
-    #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-        #define MODE_TP1 DDRF |= (1<<2) //pinA2
-        #define SET_TP1 PORTF |= (1<<2)
-        #define CLR_TP1 PORTF &= ~(1<<2)
-        #define MODE_TP2 DDRF |= (1<<3) //pinA3
-        #define SET_TP2 PORTF |= (1<<3)
-        #define CLR_TP2 PORTF &= ~(1<<3)
-        #define MODE_TP3 DDRF |= (1<<4) //pinA4 
-        #define SET_TP3 PORTF |= (1<<4) 
-        #define CLR_TP3 PORTF &= ~(1<<4) 
-        #define MODE_TP4 DDRF |= (1<<5) //pinA5 
-        #define SET_TP4 PORTF |= (1<<5) 
-        #define CLR_TP4 PORTF &= ~(1<<5) 
-    #elif defined(__AVR_ATmega32U4__)
-        #define MODE_TP1 DDRF |= (1<<4) //A3
-        #define SET_TP1 PORTF |= (1<<4)
-        #define CLR_TP1 PORTF &= ~(1<<4)
-        #define MODE_TP2 DDRF |= (1<<5) //A2
-        #define SET_TP2 PORTF |= (1<<5)
-        #define CLR_TP2 PORTF &= ~(1<<5)
-        #define MODE_TP3 
-        #define SET_TP3 
-        #define CLR_TP3 
-        #define MODE_TP4 
-        #define SET_TP4 
-        #define CLR_TP4 
-    #elif defined(__AVR_ATmega328P__) 
-        #define MODE_TP1 DDRC |= (1<<1) //A1
-        #define SET_TP1 PORTC |= (1<<1)
-        #define CLR_TP1 PORTC &= ~(1<<1)
-        #define MODE_TP2 DDRC |= (1<<2) // A2
-        #define SET_TP2 PORTC |= (1<<2)
-        #define CLR_TP2 PORTC &= ~(1<<2)
-        #define MODE_TP3 DDRC |= (1<<3) //A3
-        #define SET_TP3 PORTC |= (1<<3) 
-        #define CLR_TP3 PORTC &= ~(1<<3) 
-        #define MODE_TP4 DDRC |= (1<<4) //A4 
-        #define SET_TP4 PORTC |= (1<<4) 
-        #define CLR_TP4 PORTC &= ~(1<<4) 
-    #elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
-    #elif defined (__SAM3X8E__)
-        // Arduino Due
-        #define MODE_TP1 pinMode( A1,OUTPUT )   // A1= PA24
-        #define SET_TP1  REG_PIOA_SODR = (1<<24)
-        #define CLR_TP1  REG_PIOA_CODR = (1<<24)
-        #define MODE_TP2 pinMode( A2,OUTPUT )   // A2= PA23
-        #define SET_TP2  REG_PIOA_SODR = (1<<23)
-        #define CLR_TP2  REG_PIOA_CODR = (1<<23)
-        #define MODE_TP3 pinMode( A3,OUTPUT )   // A3 = PA22
-        #define SET_TP3  REG_PIOA_SODR = (1<<22)
-        #define CLR_TP3  REG_PIOA_CODR = (1<<22)
-        #define MODE_TP4 pinMode( A4,OUTPUT )   // A4 = PA6
-        #define SET_TP4  REG_PIOA_SODR = (1<<6)
-        #define CLR_TP4  REG_PIOA_CODR = (1<<6)
-    #elif defined (__STM32F1__)
-        // STM32F103... ( SPI2-Pins! pin 31-28 maple mini )
-        #define MODE_TP1 pinMode( PB12,OUTPUT )   // TP1= PB12
-        #define SET_TP1  gpio_write_bit( GPIOB,12, HIGH );
-        #define CLR_TP1  gpio_write_bit( GPIOB,12, LOW );
-        #define MODE_TP2 pinMode( PB13,OUTPUT )   // TP2= PB13
-        #define SET_TP2  gpio_write_bit( GPIOB,13, HIGH );
-        #define CLR_TP2  gpio_write_bit( GPIOB,13, LOW );
-        #define MODE_TP3 pinMode( PB14,OUTPUT )   // TP3 = PB14
-        #define SET_TP3  gpio_write_bit( GPIOB,14, HIGH );
-        #define CLR_TP3  gpio_write_bit( GPIOB,14, LOW );
-        #define MODE_TP4 pinMode( PB15,OUTPUT )   // TP4 = PB15
-        #define SET_TP4  gpio_write_bit( GPIOB,15, HIGH );
-        #define CLR_TP4  gpio_write_bit( GPIOB,15, LOW );
-    #else
-        #define MODE_TP1 DDRC |= (1<<3) //A3
-        #define SET_TP1 PORTC |= (1<<3)
-        #define CLR_TP1 PORTC &= ~(1<<3)
-        #define MODE_TP2 DDRC |= (1<<2) // A2
-        #define SET_TP2 PORTC |= (1<<2)
-        #define CLR_TP2 PORTC &= ~(1<<2)
-        #define MODE_TP3 
-        #define SET_TP3 
-        #define CLR_TP3 
-        #define MODE_TP4 
-        #define SET_TP4 
-        #define CLR_TP4 
-    #endif 
-#else
-    #define MODE_TP1 
-    #define SET_TP1 
-    #define CLR_TP1 
-    #define MODE_TP2 
-    #define SET_TP2 
-    #define CLR_TP2 
-    #define MODE_TP3 
-    #define SET_TP3 
-    #define CLR_TP3 
-    #define MODE_TP4 
-    #define SET_TP4 
-    #define CLR_TP4 
-    
-#endif
-
-#ifdef debugPrint
-    #define DB_PRINT( x, ... ) { sprintf_P( dbgBuf, PSTR( x ), __VA_ARGS__ ) ; Serial.println( dbgBuf ); }
-    static char dbgBuf[80];
-#else
-    #define DB_PRINT ;
-#endif
-
-// select timer to use
-#ifdef __AVR_MEGA__
-    // defines only for ATMega
-    #ifdef TCNT3
-        // Timer 3 is available, use it
-        // #warning "Timer 3 used"
-        #define TCNTx       TCNT3
-        #define GET_COUNT   TCNT3
-        #define TIMERx_COMPB_vect TIMER3_COMPB_vect
-        #define TIMERx_COMPA_vect TIMER3_COMPA_vect
-        #define OCRxB      OCR3B
-        #define OCRxA      OCR3A
-        #define TCCRxA     TCCR3A
-        #define TCCRxB     TCCR3B
-        #define WGMx3      WGM33
-        #define WGMx2      WGM32
-        #define ICRx       ICR3
-        #define OCIExA     OCIE3A
-        #define OCIExB     OCIE3B
-        #define TIMSKx     TIMSK3
-    #else
-        // Timer 1 benutzen
-        #define TCNTx       TCNT1
-        #define GET_COUNT   TCNT1
-        #define TIMERx_COMPB_vect TIMER1_COMPB_vect
-        #define TIMERx_COMPA_vect TIMER1_COMPA_vect
-        #define OCRxB      OCR1B
-        #define OCRxA      OCR1A
-        #define TCCRxA     TCCR1A
-        #define TCCRxB     TCCR1B
-        #define WGMx3      WGM13
-        #define WGMx2      WGM12
-        #define ICRx       ICR1
-        #define OCIExA     OCIE1A
-        #define OCIExB     OCIE1B
-        #define TIMSKx     TIMSK1
-    #endif    
-        
-#elif defined __STM32F1__
-    //defines only for STM32
-    #define MT_TIMER TIMER4     // Timer used by MobaTools
-    #define STEP_CHN    2       // OCR channel for Stepper and Leds
-    #define SERVO_CHN   1       // OCR channel for Servos
-    #define GET_COUNT timer_get_count(MT_TIMER)
-#endif
-
-// constants
-static const int stepPattern[8] = {0b0011, 0b0010, 0b0110, 0b0100, 0b1100, 0b1000, 0b1001,0b0001 };
-
-// Global Data for all instances and classes  --------------------------------
-static uint8_t timerInitialized = false;
-static uint8_t spiInitialized = false;
-
-// Variables for servos
-static servoData_t* lastServoDataP = NULL; //start of ServoData-chain
-static byte servoCount = 0;
-static servoData_t* pulseP = NULL;         // pulse Ptr in IRQ
-static servoData_t* activePulseP = NULL;   // Ptr to pulse to stop
-static servoData_t* stopPulseP = NULL;     // Ptr to Pulse whose stop time is already in OCR1
-static servoData_t* nextPulseP = NULL;
-static enum { PON, POFF } IrqType = PON; // Cycle starts with 'pulse on'
-static word activePulseOff = 0;     // OCR-value of pulse end 
-static word nextPulseLength = 0;
-static bool speedV08 = true;    // Compatibility-Flag for speed method
-
-
-
-// Variables for stepper motors
-static stepperData_t stepperData[MAX_STEPPER];
-static uint8_t spiData[2]; // step pattern to be output on SPI
-                            // low nibble of spiData[0] is SPI_1
-                            // high nibble of spiData[1] is SPI_4
-                            // spiData[1] is shifted out first
-static uint8_t spiByteCount = 0;
-static byte stepperCount = 0;
-static uint8_t cyclesLastIRQ = 1;  // cycles since last IRQ
-
-// variables for softLeds
-static ledData_t* ledRootP = NULL; //start of ledData-chain
-static byte ledCount = 0;
-static uint8_t ledNextCyc = 1;     // next Cycle that is relevant for leds
-static uint8_t ledCycleCnt = 0;    // count IRQ cycles within PWM cycle
-//static uint8_t  ledStepIx = 0;      // Stepcounter for Leds ( Index in Array isteps , 0: start of pwm-Cycle )
-//static uint8_t  ledNextStep = 0;    // next step needed for softleds
-//static ledData_t*  ledDataP;              // pointer to active Led in ISR
-//==========================================================================
-
-// global functions / Interrupts
-
-
-// ---------- OCRxB Compare Interrupt used for stepper motor and Softleds ----------------
-#pragma GCC optimize "Os"
-#ifdef __AVR_MEGA__
-ISR ( TIMERx_COMPB_vect)
-#elif defined __STM32F1__
-void ISR_Stepper(void)
-#endif
-{ // Timer1 Compare B, used for stepper motor, starts every CYCLETIME us
-    // 26-09-15 An Interrupt is only created at timeslices, where data is to output
-    uint8_t i, spiChanged, changedPins, bitNr;
-    uint16_t tmp;
-    uint8_t nextCycle = 20000  / CYCLETIME ;// min ist one cycle per Timeroverflow
-    SET_TP3; // Oszimessung Dauer der ISR-Routine
-    spiChanged = false;
-    interrupts(); // allow nested interrupts, because this IRQ may take long
-    
-    // ---------------Stepper motors ---------------------------------------------
-    for ( i=0; i<stepperCount; i++ ) {
-        // für maximal 4 Motore
-        if ( stepperData[i].output == A4988_PINS ) {
-            // reset step pulse - pulse is max one cycle lenght
-            #ifdef FAST_PORTWRT
-            *stepperData[i].portPins[0].Adr &= ~stepperData[i].portPins[0].Mask;
-            #else
-            digitalWrite( stepperData[i].pins[0], LOW );
-            #endif
-        }
-        if ( stepperData[i].activ && stepperData[i].stepCnt > 0 ) {
-            // only active motors
-            stepperData[i].cycCnt+=cyclesLastIRQ;
-            if ( stepperData[i].cycCnt >= stepperData[i].cycSteps ) {
-                // Do one step
-                stepperData[i].cycCnt = 0 ;
-                // update position for absolute positioning
-                stepperData[i].stepsFromZero += stepperData[i].patternIxInc;
-                
-                if ( !stepperData[i].endless ) --stepperData[i].stepCnt;
-                // sign of patternIxInc defines direction
-                stepperData[i].patternIx += stepperData[i].patternIxInc;
-                if ( stepperData[i].patternIx > 7 ) stepperData[i].patternIx = 0;
-                if ( stepperData[i].patternIx < 0 ) stepperData[i].patternIx += 8;
-                
-                // store pattern data
-                switch ( stepperData[i].output ) {
-                  #ifdef __AVR_MEGA__
-                  case PIN4_7:
-                    PORTD = (PORTD & 0x0f) | ( stepPattern[ stepperData[i].patternIx ] <<4 );   
-                    break;
-                  case PIN8_11:
-                    PORTB = (PORTB & 0xf0) | ( stepPattern[ stepperData[i].patternIx ] );   
-                    break;
-                  #endif
-                  case SPI_1:
-                    spiData[0] = (spiData[0] & 0xf0) | ( stepPattern[ stepperData[i].patternIx ] );
-                    spiChanged = true;                    
-                    break;
-                  case SPI_2:
-                    spiData[0] = (spiData[0] & 0x0f) | ( stepPattern[ stepperData[i].patternIx ] <<4 );
-                    spiChanged = true;
-                    break;
-                  case SPI_3:
-                    spiData[1] = (spiData[1] & 0xf0) | ( stepPattern[ stepperData[i].patternIx ] );   
-                    spiChanged = true;
-                    break;
-                  case SPI_4:
-                    spiData[1] = (spiData[1] & 0x0f) | ( stepPattern[ stepperData[i].patternIx ] <<4 );
-                    spiChanged = true;
-                    break;
-                  case SINGLE_PINS : // Outpins are individually defined
-                    changedPins = stepPattern[ stepperData[i].patternIx ] ^ stepperData[i].lastPattern;
-                    for ( bitNr = 0; bitNr < 4; bitNr++ ) {
-                        if ( changedPins & (1<<bitNr ) ) {
-                            // bit Changed, write to pin
-                            if ( stepPattern[ stepperData[i].patternIx ] & (1<<bitNr) ) {
-                                #ifdef FAST_PORTWRT
-                                *stepperData[i].portPins[bitNr].Adr |= stepperData[i].portPins[bitNr].Mask;
-                                #else
-                                digitalWrite( stepperData[i].pins[bitNr], HIGH );
-                                #endif
-                            } else {
-                                #ifdef FAST_PORTWRT
-                                *stepperData[i].portPins[bitNr].Adr &= ~stepperData[i].portPins[bitNr].Mask;
-                                #else    
-                                digitalWrite( stepperData[i].pins[bitNr], LOW );
-                                #endif    
-                            }
-                        }
-                    }
-                    stepperData[i].lastPattern = stepPattern[ stepperData[i].patternIx ];
-                    break;
-                  case A4988_PINS : // output step-pulse and direction
-                    // direction first
-                    if ( stepperData[i].patternIxInc > 0 ) {
-                        // turn forward 
-                        #ifdef FAST_PORTWRT
-                        *stepperData[i].portPins[1].Adr |= stepperData[i].portPins[1].Mask;
-                        #else
-                        digitalWrite( stepperData[i].pins[1], HIGH );
-                        #endif
-                    } else {
-                        // turn backwards
-                        #ifdef FAST_PORTWRT
-                        *stepperData[i].portPins[1].Adr &= ~stepperData[i].portPins[1].Mask;
-                        #else
-                        digitalWrite( stepperData[i].pins[1], LOW );
-                        #endif
-                    }    
-                    // Set step pulse ( will be resettet in next IRQ )
-                    #ifdef FAST_PORTWRT
-                    *stepperData[i].portPins[0].Adr |= stepperData[i].portPins[0].Mask;
-                    #else
-                    digitalWrite( stepperData[i].pins[0], HIGH );
-                    #endif
-                    
-                  default:
-                    // should never be reached
-                    break;
-                }
-            }
-            nextCycle = min ( nextCycle, stepperData[i].cycSteps-stepperData[i].cycCnt );
-        } // end of 'if stepper active'
-    } // end of stepper-loop
-    
-    // shift out spiData, if SPI is active
-    if ( spiInitialized && spiChanged ) {
-        digitalWrite( SS, LOW );
-        #ifdef __AVR_MEGA__
-        spiByteCount = 0;
-        SPDR = spiData[1];
-        #elif defined __STM32F1__
-        digitalWrite(BOARD_SPI2_NSS_PIN,LOW);
-        spi_tx_reg(SPI2, (spiData[1]<<8) + spiData[0] );
-        #endif
-    }
-    //============  End of steppermotor ======================================
-    ledData_t*  ledDataP;              // pointer to active Led in ISR
-    // ---------------------- softleds -----------------------------------------------
-    CLR_TP3;
-    ledCycleCnt += cyclesLastIRQ;
-    SET_TP3;
-    if ( ledCycleCnt >= ledNextCyc ) {
-        // this IRQ is relevant for softleds
-        ledNextCyc = LED_CYCLE_MAX; // there must be atleast one IRQ per PWM Cycle
-        if ( ledCycleCnt >= LED_CYCLE_MAX ) {
-            // start of a new PWM Cycle - switch all leds with rising/falling state to on
-            ledCycleCnt = 0;
-            for ( ledDataP=ledRootP; ledDataP!=NULL; ledDataP = ledDataP->nextLedDataP ) {
-                SET_TP1;
-                // loop over led-objects
-                // yes it's ugly, but because of performance reasons this is done a little bit assembler like
-                static const void * pwm0tab[]  { &&pwm0end,&&pwm0end,&&pwm0end,         // NOTATTACHED, STATE_OFF, STATE_ON
-                            &&incfast0,&&decfast0,&&incslow0,&&decslow0,&&inclin0,&&declin0 };
-                goto  *pwm0tab[ledDataP->state] ;
-                  incfast0:
-                  incslow0:
-                  inclin0:
-                    // switch on led with linear characteristic
-                    if (ledDataP->invFlg  ) {
-                        #ifdef FAST_PORTWRT
-                        *ledDataP->portPin.Adr &= ~ledDataP->portPin.Mask;
-                        #else
-                        digitalWrite( ledDataP->pin, LOW );
-                        #endif
-                    } else { 
-                        #ifdef FAST_PORTWRT
-                        *ledDataP->portPin.Adr |= ledDataP->portPin.Mask;
-                        #else
-                        digitalWrite( ledDataP->pin, HIGH );
-                        #endif
-                    }
-                    // check if led off is reached
-                    if ( ledDataP->aCycle >=  LED_CYCLE_MAX-1 ) {
-                        // led is full on, remove from active-chain
-                        SET_TP2;
-                        ledDataP->state = STATE_ON;
-                        *ledDataP->backLedDataPP = ledDataP->nextLedDataP;
-                        if ( ledDataP->nextLedDataP ) ledDataP->nextLedDataP->backLedDataPP = ledDataP->backLedDataPP;
-                        ledDataP->aCycle = 0;
-                        CLR_TP2;
-                    } else { // switch to next PWM step
-                        //ledNextCyc = min( ledDataP->aCycle, ledNextCyc);
-                        if ( ledNextCyc > ledDataP->aCycle ) ledNextCyc = ledDataP->aCycle;
-                        ledDataP->actPulse = true;
-                    }
-                    goto pwm0end;
-                  decfast0:
-                  decslow0:
-                  declin0:
-                    // switch off led 
-                   if ( ledDataP->aCycle <= 0  ) {
-                        // led is full off, remove from active-chain
-                        SET_TP2;
-                        ledDataP->state = STATE_OFF;
-                        *ledDataP->backLedDataPP = ledDataP->nextLedDataP;
-                        if ( ledDataP->nextLedDataP ) ledDataP->nextLedDataP->backLedDataPP = ledDataP->backLedDataPP;
-                        CLR_TP2;
-                        ledDataP->aCycle = 0;
-                    } else { // switch to next PWM step
-                        if (ledDataP->invFlg  ) {
-                            #ifdef FAST_PORTWRT
-                            *ledDataP->portPin.Adr &= ~ledDataP->portPin.Mask;
-                            #else
-                            digitalWrite( ledDataP->pin, LOW );
-                            #endif
-                        } else {
-                            #ifdef FAST_PORTWRT
-                            *ledDataP->portPin.Adr |= ledDataP->portPin.Mask;
-                            #else
-                            digitalWrite( ledDataP->pin, HIGH );
-                            #endif
-                        }
-                        if ( ledNextCyc > ledDataP->aCycle ) ledNextCyc = ledDataP->aCycle;
-                        ledDataP->actPulse = true;
-                    }
-                pwm0end: // end of 'switch'
-                ;//CLR_TP1;
-            } // end of led loop
-        } else { // is switchofftime within PWM cycle
-            for ( ledDataP=ledRootP; ledDataP!=NULL; ledDataP = ledDataP->nextLedDataP ) {
-                SET_TP4;
-                if ( ledDataP->actPulse ) {
-                    // led is within PWM cycle with output high
-                    if ( ledDataP->aCycle <= ledCycleCnt ) {
-                        SET_TP4;
-                        if (ledDataP->invFlg  ) {
-                            #ifdef FAST_PORTWRT
-                            *ledDataP->portPin.Adr |= ledDataP->portPin.Mask;
-                            #else
-                            digitalWrite( ledDataP->pin, HIGH );
-                            #endif
-                        } else {
-                            #ifdef FAST_PORTWRT
-                            *ledDataP->portPin.Adr &= ~ledDataP->portPin.Mask;
-                            #else
-                            digitalWrite( ledDataP->pin, LOW );
-                            #endif
-                        }
-                        CLR_TP4;
-                        ledDataP->actPulse = false;
-                        // determine length of next PWM Cyle
-                        switch ( ledDataP->state ) {
-                          case INCFAST:
-                            ledDataP->aStep += ledDataP->speed;
-                            if ( ledDataP->aStep > LED_STEP_MAX ) ledDataP->aStep = LED_STEP_MAX;
-                            ledDataP->aCycle = iSteps[ledDataP->aStep];
-                            break;
-                          case DECFAST:
-                            ledDataP->aStep += ledDataP->speed;
-                            if ( ledDataP->aStep > LED_STEP_MAX ) ledDataP->aStep = LED_STEP_MAX;
-                            ledDataP->aCycle = LED_CYCLE_MAX-iSteps[ledDataP->aStep];
-                            break;
-                          case INCSLOW:
-                            if ( --ledDataP->stpCnt < ledDataP->speed ) {
-                                ledDataP->aStep += 1;
-                                ledDataP->stpCnt = 1;
-                            }
-                            if ( ledDataP->aStep > LED_STEP_MAX ) ledDataP->aStep = LED_STEP_MAX;
-                            ledDataP->aCycle = iSteps[ledDataP->aStep];
-                            break;
-                          case DECSLOW:
-                            if ( --ledDataP->stpCnt < ledDataP->speed ) {
-                                ledDataP->aStep += 1;
-                                ledDataP->stpCnt = 1;
-                            }
-                            if ( ledDataP->aStep > LED_STEP_MAX ) ledDataP->aStep = LED_STEP_MAX;
-                            ledDataP->aCycle = LED_CYCLE_MAX-iSteps[ledDataP->aStep];
-                            break;
-                          case INCLIN:
-                            ledDataP->aCycle += ledDataP->speed;
-                            if ( ledDataP->aCycle > LED_CYCLE_MAX-1 ) ledDataP->aCycle = LED_CYCLE_MAX-1;
-                            //ledNextCyc = min( ledDataP->aCycle, ledNextCyc);
-                            break;
-                          case DECLIN:
-                            ledDataP->aCycle -= ledDataP->speed;
-                            if ( ledDataP->aCycle <= 0 ) ledDataP->aCycle = 0;
-                            //ledNextCyc = min( ledDataP->aCycle, ledNextCyc);
-                            break;
-                          default:
-                            // no action if state is one of NOTATTACHED, STATE_ON, STATE_OFF
-                            break;
-                        }
-                        
-                    } else { // next necessary step
-                       //SET_TP2;
-                       ledNextCyc = min( ledDataP->aCycle, ledNextCyc);
-                       //CLR_TP2;
-                    }
-                }
-                CLR_TP4;
-            }
-        }
-        //CLR_TP1;
-     } // end of softleds 
-    CLR_TP3;
-    nextCycle = min( nextCycle, ( ledNextCyc-ledCycleCnt ) );
-    SET_TP3;
-    // ======================= end of softleds =====================================
-        
-    
-    
-    cyclesLastIRQ = nextCycle;
-    // set compareregister to next interrupt time;
-     noInterrupts(); // when manipulating 16bit Timerregisters IRQ must be disabled
-    // compute next IRQ-Time in us, not in tics, so we don't need long
-    #ifdef __AVR_MEGA__
-    tmp = ( OCRxB / TICS_PER_MICROSECOND + nextCycle * CYCLETIME );
-    if ( tmp > 20000 ) tmp = tmp - 20000;
-    OCRxB = tmp * TICS_PER_MICROSECOND;
-    #elif defined __STM32F1__
-    tmp = ( timer_get_compare(MT_TIMER, STEP_CHN) / TICS_PER_MICROSECOND + nextCycle * CYCLETIME );
-    if ( tmp > 20000 ) tmp = tmp - 20000;
-    timer_set_compare( MT_TIMER, STEP_CHN, tmp * TICS_PER_MICROSECOND) ;
-    #endif
-    interrupts();
-    
-    CLR_TP3; // Oszimessung Dauer der ISR-Routine
-}
-// ---------- SPI interupt used for output stepper motor data -------------
-extern "C" {
-#ifdef __AVR_MEGA__
-ISR ( SPI_STC_vect )
-{   // output step-pattern on SPI, set SS when ready
-    if ( spiByteCount++ == 0 ) {
-        // end of shifting out high Byte, shift out low Byte
-        SPDR = spiData[0];
-    } else {
-        // end of data shifting
-        digitalWrite( SS, HIGH );
-        spiByteCount = 0;
-    }
-}
-#elif defined __STM32F1__
-void __irq_spi2(void) {// STM32
-    static int rxData;
-    rxData = spi_rx_reg(SPI2);            // Get dummy data (Clear RXNE-Flag)
-    digitalWrite(BOARD_SPI2_NSS_PIN,HIGH);
-}
-#endif
-}
-#ifdef FIXED_POSITION_SERVO_PULSES
-// ---------- OCRxA Compare Interrupt used for servo motor ----------------
-// Positions of servopulses within 20ms cycle are fixed -  8 servos
-#define PULSESTEP ( 40000 / MAX_SERVOS )
-#ifdef __AVR_MEGA__
-ISR ( TIMERx_COMPA_vect) {
-#elif defined __STM32F1__
-void ISR_Servo( void) {
-    uint16_t OCRxA;
-#endif
-    // Timer1 Compare A, used for servo motor
-    if ( IrqType == POFF ) {
-        SET_TP1; // Oszimessung Dauer der ISR-Routine OFF
-        IrqType = PON ; // it's always alternating
-        // switch off previous started pulse
-        #ifdef FAST_PORTWRT
-        *pulseP->portAdr &= ~pulseP->bitMask;
-        #else
-        digitalWrite( pulseP->pin, LOW );
-        #endif
-        // Set next startpoint of servopulse
-        if ( (pulseP = pulseP->prevServoDataP) == NULL ) {
-            // Start over
-            OCRxA = FIRST_PULSE;
-            pulseP = lastServoDataP;
-        } else {
-            // The pointerchain comes from the end of the servos, but servoIx is incremented starting
-            // from the first servo. Pulses must be sorted in ascending order.
-            OCRxA = FIRST_PULSE + (servoCount-1-pulseP->servoIx) * PULSESTEP;
-        }
-        CLR_TP1; // Oszimessung Dauer der ISR-Routine OFF
-    } else {
-        SET_TP2; // Oszimessung Dauer der ISR-Routine ON
-        // look for next pulse to start
-        if ( pulseP->soll < 0 ) {
-            // no pulse to output, switch to next startpoint
-            if ( (pulseP = pulseP->prevServoDataP) == NULL ) {
-                // Start over
-                OCRxA = FIRST_PULSE;
-                pulseP = lastServoDataP;
-            } else {
-                OCRxA = FIRST_PULSE + (servoCount-1-pulseP->servoIx) * PULSESTEP;
-            }
-        } else { // found pulse to output
-            if ( pulseP->ist == pulseP->soll ) {
-                // no change of pulselength
-                if ( pulseP->offcnt > 0 ) pulseP->offcnt--;
-            } else if ( pulseP->ist < pulseP->soll ) {
-                pulseP->offcnt = OFF_COUNT;
-                if ( pulseP->ist < 0 ) pulseP->ist = pulseP->soll; // first position after attach
-                else pulseP->ist += pulseP->inc;
-                if ( pulseP->ist > pulseP->soll ) pulseP->ist = pulseP->soll;
-            } else {
-                pulseP->offcnt = OFF_COUNT;
-                pulseP->ist -= pulseP->inc;
-                if ( pulseP->ist < pulseP->soll ) pulseP->ist = pulseP->soll;
-            } 
-            OCRxA = (pulseP->ist/SPEED_RES) + GET_COUNT - 4; // compensate for computing time
-            if ( pulseP->on && (pulseP->offcnt+pulseP->noAutoff) > 0 ) {
-                CLR_TP1;
-                #ifdef FAST_PORTWRT
-                *pulseP->portAdr |= pulseP->bitMask;
-                #else
-                digitalWrite( pulseP->pin, HIGH );
-                #endif
-                SET_TP1;
-            }
-            IrqType = POFF;
-        } 
-        CLR_TP2; // Oszimessung Dauer der ISR-Routine ON
-    } //end of 'pulse ON'
-    #ifdef __STM32F1__
-    timer_set_compare(MT_TIMER,  SERVO_CHN, OCRxA);
-    #endif 
-}
-
-#else // create overlapping servo pulses
-// Positions of servopulses within 20ms cycle are variable, max 2 pulses at the same time
-// 27.9.15 with variable overlap, depending on length of next pulse: 16 Servos
-// 2.1.16 Enable interrupts after timecritical path (e.g. starting/stopping servo pulses)
-//        so other timecritical tasks can interrupt (nested interrupts)
-static bool searchNextPulse() {
-    //SET_TP2;
-   while ( pulseP != NULL && pulseP->soll < 0 ) {
-        //SET_TP4;
-        pulseP = pulseP->prevServoDataP;
-        //CLR_TP4;
-    }
-    //CLR_TP2;
-    if ( pulseP == NULL ) {
-        // there is no more pulse to start, we reached the end
-        //SET_TP2; CLR_TP2;
-        return false;
-    } else { // found pulse to output
-        //SET_TP2;
-        if ( pulseP->ist == pulseP->soll ) {
-            // no change of pulselength
-            if ( pulseP->offcnt > 0 ) pulseP->offcnt--;
-        } else if ( pulseP->ist < pulseP->soll ) {
-            pulseP->offcnt = OFF_COUNT;
-            if ( pulseP->ist < 0 ) pulseP->ist = pulseP->soll; // first position after attach
-            else pulseP->ist += pulseP->inc;
-            if ( pulseP->ist > pulseP->soll ) pulseP->ist = pulseP->soll;
-        } else {
-            pulseP->offcnt = OFF_COUNT;
-            pulseP->ist -= pulseP->inc;
-            if ( pulseP->ist < pulseP->soll ) pulseP->ist = pulseP->soll;
-        } 
-        //CLR_TP2;
-        return true;
-    } 
-} //end of 'searchNextPulse'
-
-// ---------- OCRxA Compare Interrupt used for servo motor ----------------
-#ifdef __AVR_MEGA__
-ISR ( TIMERx_COMPA_vect) {
-#elif defined __STM32F1__
-void ISR_Servo( void) {
-    uint16_t OCRxA;
-#endif
-    // Timer1 Compare A, used for servo motor
-    if ( IrqType == POFF ) { // Pulse OFF time
-        SET_TP1; // Oszimessung Dauer der ISR-Routine OFF
-        //SET_TP3; // Oszimessung Dauer der ISR-Routine
-        IrqType = PON ; // it's (nearly) always alternating
-        // switch off previous started pulse
-        #ifdef FAST_PORTWRT
-        *stopPulseP->portAdr &= ~stopPulseP->bitMask;
-        #else
-        digitalWrite( stopPulseP->pin, LOW );
-        #endif
-        if ( nextPulseLength > 0 ) {
-            // there is a next pulse to start, compute starttime 
-            // set OCR value to next starttime ( = endtime of running pulse -overlap )
-            // next starttime must behind actual timervalue and endtime of next pulse must
-            // lay after endtime of runningpuls + safetymargin (it may be necessary to start
-            // another pulse between these 2 ends)
-            word tmpTCNT1 = GET_COUNT + MARGINTICS/2;
-            interrupts();
-            //CLR_TP3 ;
-            OCRxA = max ( ((long)activePulseOff + (long) MARGINTICS - (long) nextPulseLength), ( tmpTCNT1 ) );
-        } else {
-            // we are at the end, no need to start another pulse in this cycle
-            if ( activePulseOff ) {
-                // there is still a running pulse to stop
-                //SET_TP1; // Oszimessung Dauer der ISR-Routine
-                OCRxA = activePulseOff;
-                IrqType = POFF;
-                stopPulseP = activePulseP;
-                activePulseOff = 0;
-                //CLR_TP1; // Oszimessung Dauer der ISR-Routine
-            } else { // was last pulse, start over
-                pulseP = lastServoDataP;
-                nextPulseLength = 0;
-                OCRxA = FIRST_PULSE;
-            }
-        }
-        CLR_TP1; // Oszimessung Dauer der ISR-Routine OFF
-    } else { // Pulse ON - time
-        SET_TP2; // Oszimessung Dauer der ISR-Routine ON
-        if ( pulseP == lastServoDataP ) SET_TP3;
-        // look for next pulse to start
-        // do we know the next pulse already?
-        if ( nextPulseLength > 0 ) {
-            // yes we know, start this pulse and then look for next one
-            word tmpTCNT1= GET_COUNT-4; // compensate for computing time
-            if ( nextPulseP->on && (nextPulseP->offcnt+nextPulseP->noAutoff) > 0 ) {
-                // its a 'real' pulse, set output pin
-                //CLR_TP1;
-                #ifdef FAST_PORTWRT
-                *nextPulseP->portAdr |= nextPulseP->bitMask;
-                #else
-                digitalWrite( nextPulseP->pin, HIGH );
-                #endif
-            }
-            interrupts(); // the following isn't time critical, so allow nested interrupts
-            //SET_TP3;
-            // the 'nextPulse' we have started now, is from now on the 'activePulse', the running activPulse is now the
-            // pulse to stop next.
-            stopPulseP = activePulseP; // because there was a 'nextPulse' there is also an 'activPulse' which is the next to stop
-            OCRxA = activePulseOff;
-            activePulseP = nextPulseP;
-            activePulseOff = activePulseP->ist/SPEED_RES + tmpTCNT1; // end of actually started pulse
-            nextPulseLength = 0;
-            //SET_TP1;
-        }
-        if ( searchNextPulse() ) {
-            // found a pulse
-            if ( activePulseOff == 0 ) {
-                // it is the first pulse in the sequence, start it
-                activePulseP = pulseP; 
-                activePulseOff = pulseP->ist/SPEED_RES + GET_COUNT - 4; // compensate for computing time
-                if ( pulseP->on && (pulseP->offcnt+pulseP->noAutoff) > 0 ) {
-                    // its a 'real' pulse, set output pin
-                    #ifdef FAST_PORTWRT
-                    *pulseP->portAdr |= pulseP->bitMask;
-                    #else
-                    digitalWrite( pulseP->pin, HIGH );
-                    #endif
-                }
-                word tmpTCNT1 = GET_COUNT;
-                interrupts(); // the following isn't time critical, so allow nested interrupts
-                //SET_TP3;
-                // look for second pulse
-                //SET_TP4;
-                pulseP = pulseP->prevServoDataP;
-                //CLR_TP4;
-                if ( searchNextPulse() ) {
-                    // there is a second pulse - this is the 'nextPulse'
-                    nextPulseLength = pulseP->ist/SPEED_RES;
-                    nextPulseP = pulseP;
-                    //SET_TP4;
-                    pulseP = pulseP->prevServoDataP;
-                    //CLR_TP4;
-                    // set Starttime for 2. pulse in sequence
-                    OCRxA = max ( ((long)activePulseOff + (long) MARGINTICS - (long) nextPulseLength), ( tmpTCNT1 + MARGINTICS/2 ) );
-                } else {
-                    // no next pulse, there is only one pulse
-                    OCRxA = activePulseOff;
-                    activePulseOff = 0;
-                    stopPulseP = activePulseP;
-                    IrqType = POFF;
-                }
-            } else {
-                // its a pulse in sequence, so this is the 'nextPulse'
-                nextPulseLength = pulseP->ist/SPEED_RES;
-                nextPulseP = pulseP;
-                //SET_TP4;
-                pulseP = pulseP->prevServoDataP;
-                //CLR_TP4;
-                IrqType = POFF;
-            }
-        } else {
-            // found no pulse, so the last one is running or no pulse at all
-            
-            if ( activePulseOff == 0 ) {
-                // there wasn't any pulse, restart
-                pulseP = lastServoDataP;
-                nextPulseLength = 0;
-                OCRxA = FIRST_PULSE;
-            } else {
-                // is last pulse, don't start a new one
-                IrqType = POFF;
-            }
-        }
-        CLR_TP2; CLR_TP3; // Oszimessung Dauer der ISR-Routine ON
-    } //end of 'pulse ON'
-    #ifdef __STM32F1__
-    timer_set_compare(MT_TIMER,  SERVO_CHN, OCRxA);
-    #endif 
-    //CLR_TP1; CLR_TP3; // Oszimessung Dauer der ISR-Routine
-}
-
-#endif // VARIABLE_POSITION_SERVO_PULSES
-
-// ------------ end of Interruptroutines ------------------------------
-
-static void seizeTimer1()
-{
-# ifdef __AVR_MEGA__
-    uint8_t oldSREG = SREG;
-    cli();
-    
-    TCCRxA =0; /* CTC Mode, ICRx is TOP */
-    TCCRxB = _BV(WGMx3) | _BV(WGMx2) /* CTC Mode, ICRx is TOP */
-  | _BV(CS11) /* div 8 clock prescaler */
-  ;
-    ICRx = 20000 * TICS_PER_MICROSECOND;  // timer periode is 20000us 
-    OCRxA = FIRST_PULSE;
-    OCRxB = 400;
-    // Serial.print( " Timer initialized " ); Serial.println( TIMSKx, HEX );
-    SREG = oldSREG;  // undo cli() 
-#elif defined __STM32F1__
-    timer_init( MT_TIMER );
-    timer_pause(MT_TIMER);
-    timer_oc_set_mode( MT_TIMER, SERVO_CHN, TIMER_OC_MODE_FROZEN, 0 );  // comparison between output compare register and counter 
-                                                                //has no effect on the outputs
-    timer_oc_set_mode( MT_TIMER, STEP_CHN, TIMER_OC_MODE_FROZEN, 0 );
-    timer_set_prescaler(MT_TIMER, 36-1 );    // = 0.5µs Tics at 72MHz
-    timer_set_reload(MT_TIMER, 20000 * TICS_PER_MICROSECOND );
-    timer_set_compare(MT_TIMER, SERVO_CHN, FIRST_PULSE );
-    timer_attach_interrupt(MT_TIMER, TIMER_CC1_INTERRUPT, ISR_Servo );
-    timer_set_compare(MT_TIMER, STEP_CHN, 400 );
-    timer_attach_interrupt(MT_TIMER, TIMER_CC2_INTERRUPT, ISR_Stepper );
-    timer_resume(MT_TIMER);
-#endif
-    timerInitialized = true;  
-    MODE_TP1;   // set debug-pins to Output
-    MODE_TP2;
-    MODE_TP3;
-    MODE_TP4;
-}
-
-static void initSPI() {
-    // initialize SPI hardware.
-    // MSB first, default Clk Level is 0, shift on leading edge
-#ifdef __AVR_MEGA__
-    byte tmp;
-    uint8_t oldSREG = SREG;
-    cli();
-    pinMode( MOSI, OUTPUT );
-    pinMode( SCK, OUTPUT );
-    pinMode( SS, OUTPUT );
-    SPCR = (1<<SPIE)    // Interrupt enable
-         | (1<<SPE )    // SPI enable
-         | (0<<DORD)    // MSB first
-         | (1<<MSTR)    // Master Mode
-         | (0<<CPOL)    // Clock is low when idle
-         | (0<<CPHA)    // Data is sampled on leading edge
-         | (0<<SPR1) | (1<<SPR0);    // fosc/16
-    digitalWrite( SS, LOW );
-    SREG = oldSREG;  // undo cli() 
-    
-#elif defined __STM32F1__
-    // use SPI 2 interface
-    spi_init(SPI2);
-    spi_config_gpios(SPI2, 1,  // initialize as master
-                     PIN_MAP[BOARD_SPI2_NSS_PIN].gpio_device, PIN_MAP[BOARD_SPI2_NSS_PIN].gpio_bit,        
-                     PIN_MAP[BOARD_SPI2_SCK_PIN].gpio_device, PIN_MAP[BOARD_SPI2_SCK_PIN].gpio_bit,
-                     PIN_MAP[BOARD_SPI2_MISO_PIN].gpio_bit,
-                     PIN_MAP[BOARD_SPI2_MOSI_PIN].gpio_bit);
-
-    uint32 flags = (SPI_FRAME_MSB | SPI_CR1_DFF_16_BIT | SPI_SW_SLAVE | SPI_SOFT_SS);
-    spi_master_enable(SPI2, (spi_baud_rate)SPI_BAUD_PCLK_DIV_16, (spi_mode)SPI_MODE_0, flags);
-    spi_irq_enable(SPI2, SPI_RXNE_INTERRUPT);
-    pinMode( BOARD_SPI2_NSS_PIN, OUTPUT);
-    digitalWrite( BOARD_SPI2_NSS_PIN, LOW );
-
-#endif
-    spiInitialized = true;  
-}
-// ========================= Class Definitions ============================================
-// --------- Class Stepper ---------------------------------
-// Class-specific Variables
-outUsed_t Stepper4::outputsUsed;
-
-// constructor -------------------------
-Stepper4::Stepper4(int steps ) {
-    // constuctor for stepper Class, initialize data
-    Stepper4::initialize ( steps, HALFSTEP, 1 );
-}
-
-Stepper4::Stepper4(int steps, uint8_t mode ) {
-    // constuctor for stepper Class, initialize data
-    Stepper4::initialize ( steps, mode, 1 );
-}
-
-Stepper4::Stepper4(int steps, uint8_t mode,uint8_t minStepTime ) {
-    // constuctor for stepper Class, initialize data
-    Stepper4::initialize ( steps, mode, minStepTime );
-}
-
-// private functions ---------------
-void Stepper4::initialize ( int steps360, uint8_t mode, uint8_t minStepTime ) {
-    stepMode = NOSTEP;
-    if( stepperCount < MAX_STEPPER )  {
-        // create new instance
-        stepperIx = stepperCount++ ;
-        stepsRev = steps360;       // number of steps for full rotation in fullstep mode
-        if ( mode != FULLSTEP && mode != A4988 ) mode = HALFSTEP;
-        // initialize data for interrupts
-        stepperData[stepperIx].stepCnt = 0;         // don't move
-        stepMode = mode;
-        stepperData[stepperIx].patternIx = 0;
-        stepperData[stepperIx].patternIxInc = mode;    // positive direction
-        minCycSteps = minStepTime*1000/CYCLETIME; // minStepTime in ms, cycletime in us
-        stepperData[stepperIx].cycSteps = 2;        // set to maximum speed, 1 Step every 2 Irq's
-        stepperData[stepperIx].stepsFromZero = 0;
-        stepperData[stepperIx].activ = 0;
-        stepperData[stepperIx].endless = 0;
-        stepperData[stepperIx].output = NO_OUTPUT;          // unknown
-    }
-    
-}
-long Stepper4::getSFZ() {
-    // get step-distance from zero point
-    // irq must be disabled, because stepsFromZero is updated in interrupt
-    long tmp;
-    noInterrupts();
-    tmp = stepperData[stepperIx].stepsFromZero;
-    interrupts();
-    return tmp / stepMode;
-}
-
-// public functions -------------------
-uint8_t Stepper4::attach( byte stepP, byte dirP ) {
-    // step motor driver A4988 is used
-    byte pins[2];
-    if ( stepMode != A4988 ) return 0;    // false mode
-    //DB_PRINT( "Attach4988, S=%d, D=%d", stepP, dirP );
-    
-    pins[0] = stepP;
-    pins[1] = dirP;
-    return Stepper4::attach( A4988_PINS, pins );
-}
-uint8_t Stepper4::attach( byte pin1, byte pin2, byte pin3, byte pin4 ) {
-    byte pins[4];
-    pins[0] = pin1;
-    pins[1] = pin2;
-    pins[2] = pin3;
-    pins[3] = pin4;
-    return Stepper4::attach( SINGLE_PINS, pins );
-}
-uint8_t Stepper4::attach(byte outArg) {
-    return Stepper4::attach( outArg, (byte *)NULL );
-}
-    
-uint8_t Stepper4::attach( byte outArg, byte pins[] ) {
-    // outArg must be one of PIN8_11 ... SPI_4 or SINGLE_PINS, A4988_PINS
-    if ( stepMode == NOSTEP ) return 0; // Invalid object
-    uint8_t attachOK = true;
-    switch ( outArg ) {
-      #ifdef __AVR_MEGA__
-      case PIN4_7:
-        if ( Stepper4::outputsUsed.pin4_7 ) {
-            // output already in use
-            attachOK = false;
-        } else {
-            // Port D initiieren, Pin4-7 as Output
-            Stepper4::outputsUsed.pin4_7 = true;
-            DDRD |= 0xf0;
-            PORTD &= 0x0f;
-        }
-        break;
-      case PIN8_11:
-        if ( spiInitialized || Stepper4::outputsUsed.pin8_11 ) {
-            // PIN8_11 and SPI cannot be used simultaneously ( this is not true for Arduino mega )
-            attachOK = false;
-        } else {
-            Stepper4::outputsUsed.pin8_11 = true;
-            DDRB |= 0x0f;
-            PORTB &= 0xf0;
-        }
-        break;
-      #endif
-      case SPI_1:
-      case SPI_2:
-      case SPI_3:
-      case SPI_4:
-        // check if already in use or if PIN8_11 is in use
-        if ( (Stepper4::outputsUsed.outputs & (1<<(outArg-1))) || Stepper4::outputsUsed.pin8_11 ) {
-            // incompatible!
-            attachOK = false;
-        } else {
-            if ( !spiInitialized ) initSPI();
-            Stepper4::outputsUsed.outputs |= (1<<(outArg-1));
-        }
-        break;
-      case SINGLE_PINS:
-        // 4 single output pins - as yet there is no check if they are allowed!
-        for ( byte i = 0; i<4; i++ ) {
-            #ifdef FAST_PORTWRT
-            // compute portadress and bitnumber
-            stepperData[stepperIx].portPins[i].Adr = (byte *) pgm_read_word_near(&port_to_output_PGM[pgm_read_byte_near(&digital_pin_to_port_PGM[ pins[i]])]);
-            stepperData[stepperIx].portPins[i].Mask = pgm_read_byte_near(&digital_pin_to_bit_mask_PGM[pins[i]]);
-            #else // store pins directly
-            stepperData[stepperIx].pins[i] = pins[i];
-            #endif
-            pinMode( pins[i], OUTPUT );
-            digitalWrite( pins[i], LOW );
-        }
-        break;
-      case A4988_PINS:
-        // 2 single output pins (step and direction) - as yet there is no check if they are allowed!
-        for ( byte i = 0; i<2; i++ ) {
-            #ifdef FAST_PORTWRT
-            // compute portadress and bitnumber
-            stepperData[stepperIx].portPins[i].Adr = (byte *) pgm_read_word_near(&port_to_output_PGM[pgm_read_byte_near(&digital_pin_to_port_PGM[ pins[i]])]);
-            stepperData[stepperIx].portPins[i].Mask = pgm_read_byte_near(&digital_pin_to_bit_mask_PGM[pins[i]]);
-            #else // store pins directly
-            stepperData[stepperIx].pins[i] = pins[i];
-            #endif
-            stepMode = HALFSTEP;                      // There are no real stepmodes in A4988 - mode
-            stepperData[stepperIx].patternIxInc = 1;  // defines direction
-            pinMode( pins[i], OUTPUT );
-            digitalWrite( pins[i], LOW );
-        }
-        break;
-     default:
-        // invalid Arg
-        attachOK = false;
-    }
-    if ( attachOK ) {
-        if ( !timerInitialized) seizeTimer1();
-        stepperData[stepperIx].output = outArg;
-        stepperData[stepperIx].activ = 1;
-        // enable compareB- interrupt
-        #if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
-            TIMSK |= ( _BV(OCIExB) );    // enable compare interrupts
-        #elif defined __AVR_MEGA__
-            TIMSKx |= _BV(OCIExB) ; 
-        #elif defined __STM32F1__
-            timer_cc_enable(MT_TIMER, STEP_CHN);
-        #endif
-    }
-    //DB_PRINT( "attach: output=%d, attachOK=%d", stepperData[stepperIx].output, attachOK );
-    //Serial.print( "Attach Stepper, Ix= "); Serial.println( stepperIx );
-    return attachOK;
-}
-
-void Stepper4::detach()
-{   // no more moving, detach from output
-    if ( stepMode == NOSTEP ) return ; // Invalid object
-    
-    stepperData[stepperIx].output = 0;
-    stepperData[stepperIx].activ = 0;
-    
-}
-
-int Stepper4::setSpeed( int rpm10 ) {
-    // Set speed in rpm*10. Step time is computed internally based on CYCLETIME and
-    // steps per full rotation (stepsRev)
-    if ( stepMode == NOSTEP ) return 0; // Invalid object
-    stepperData[stepperIx].cycSteps = (((60L*10L*1000000L / CYCLETIME )*10 / stepsRev/ rpm10) +5)/10;
-    return stepperData[stepperIx].cycSteps;
-    
-}
-
-void Stepper4::setZero() {
-    // set reference point for absolute positioning
-    if ( stepMode == NOSTEP ) return ; // Invalid object
-    noInterrupts();
-    stepperData[stepperIx].stepsFromZero = 0;
-    interrupts();
-}
-
-void Stepper4::write(long angleArg ) {
-    // set next position as angle, measured from last setZero() - point
-    //DB_PRINT("write: %d", angleArg);
-    Stepper4::write( angleArg, 1 );
-}
-
-void Stepper4::write( long angleArg, byte fact ) {
-    // for better resolution. angelArg/fact = angle in degrees
-    // typical: fact = 10, angleArg in .1 degrees
-    if ( stepMode == NOSTEP ) return ; // Invalid object
-    bool negative;
-    int angel2steps;
-    negative =  ( angleArg < 0 ) ;
-    //DB_PRINT( "angleArg: %d",angleArg ); //DB_PRINT( " getSFZ: ", getSFZ() );
-    //Serial.print( "Write: " ); Serial.println( angleArg );
-    angel2steps =  ( (abs(angleArg) * (long)stepsRev*10) / ( 360L * fact) +5) /10 ;
-    if ( negative ) angel2steps = -angel2steps;
-    doSteps(angel2steps  - getSFZ() );
-}
-
-void Stepper4::writeSteps( long stepPos ) {
-    // go to position stepPos steps away from zeropoint
-    if ( stepMode == NOSTEP ) return ; // Invalid object
-
-    doSteps(stepPos  - getSFZ() );
-}
-
-long Stepper4::read()
-{   // returns actual position as degree
-    if ( stepMode == NOSTEP ) return 0; // Invalid object
-
-    long tmp = getSFZ();
-    bool negative;
-    negative = ( tmp < 0 );
-	tmp = (abs(tmp)/stepsRev*360) + (( (abs(tmp)%stepsRev) *3600L / stepsRev ) +5) / 10;
-    if ( negative ) tmp = -tmp;
-    return  tmp;
-}
-
-long Stepper4::readSteps()
-{   // returns actual position as steps
-    if ( stepMode == NOSTEP ) return 0; // Invalid object
-
-    return  getSFZ();
-}
-
-void Stepper4::doSteps( long stepValue ) {
-    // rotate stepValue steps
-    if ( stepMode == NOSTEP ) return ; // Invalid object
-    //Serial.print( "doSteps: " ); Serial.println( stepValue );
-    stepsToMove = stepValue;
-    //DB_PRINT( " stepsToMove: %d ",stepsToMove );
-    if ( stepValue > 0 ) stepperData[stepperIx].patternIxInc = abs( stepperData[stepperIx].patternIxInc );
-    else stepperData[stepperIx].patternIxInc = -abs( stepperData[stepperIx].patternIxInc );
-    noInterrupts();
-    stepperData[stepperIx].stepCnt = abs(stepsToMove);
-    interrupts();
-}
-
-
-uint8_t Stepper4::moving() {
-    // return how much still to move (percentage)
-    int tmp;
-    if ( stepMode == NOSTEP ) return 0; // Invalid object
-    //Serial.print( stepperData[stepperIx].stepCnt ); Serial.print(" "); 
-    //Serial.println( stepperData[stepperIx].cycSteps );
-    if ( stepsToMove == 0 ) {
-        tmp = 0;        // there was nothing to move
-    } else {
-        noInterrupts(); // disable interrupt, because integer stepcnt is changed in TCR interrupt
-        tmp = stepperData[stepperIx].stepCnt;
-        interrupts();  // undo cli() 
-        if ( tmp > 0 ) {
-            // do NOT return 0, even if less than 1%, because 0 means real stop of the motor
-            tmp = max ( ((long)tmp * 100L / abs( stepsToMove)) , 1 );
-        }
-    }
-    return tmp ;
-}
-
-void Stepper4::rotate(int8_t direction) {
-	// rotate endless
-    if ( stepMode == NOSTEP ) return; // Invalid object
-    
-	if (direction == 0 ) {
-        // identical to 'stop'
-		stop();
-	} else {
-		noInterrupts();
-		stepperData[stepperIx].endless = true;
-		stepperData[stepperIx].stepCnt = 1;
-		if ( direction > 0 ) {
-            stepperData[stepperIx].patternIxInc = abs( stepperData[stepperIx].patternIxInc );
-            stepsToMove = 1;
-         } else {
-            stepperData[stepperIx].patternIxInc = -abs( stepperData[stepperIx].patternIxInc );
-            stepsToMove = -1;
-         }
-		interrupts();
-	}
-}
-
-void Stepper4::stop() {
-	// immediate stop of the motor
-    if ( stepMode == NOSTEP ) return ; // Invalid object
-    
-    noInterrupts();
-    stepperData[stepperIx].endless = false;
-	stepsToMove = 0;
-    stepperData[stepperIx].stepCnt = 0;
-    interrupts();
-}
-///////////////////////////////////////////////////////////////////////////////////
-// --------- Class Servo8 ---------------------------------
-// Class-specific Variables
-
-
-const byte NO_ANGLE = 0xff;
-const byte NO_PIN = 0xff;
-
-Servo8::Servo8() : pin(NO_PIN),angle(NO_ANGLE),min16(1000/16),max16(2000/16)
-{   servoData.servoIx = servoCount++;
-    servoData.soll = -1;    // = not initialized
-    noInterrupts();
-    servoData.prevServoDataP = lastServoDataP;
-    lastServoDataP = &servoData;
-    interrupts();
-}
-
-void Servo8::setMinimumPulse(uint16_t t)
-{
-    t = t/16;
-    if ( t >= MINPULSEWIDTH/16 && t < max16 ) min16 = t;
-}
-
-void Servo8::setMaximumPulse(uint16_t t)
-{
-    t = t/16;
-    if ( t > min16 && t <= MAXPULSEWIDTH/16 ) max16 = t;
-}
-
-
-uint8_t Servo8::attach(int pinArg) {
-    return attach( pinArg, MINPULSEWIDTH, MAXPULSEWIDTH, false );
-}
-uint8_t Servo8::attach(int pinArg, bool autoOff ) {
-    return attach( pinArg, MINPULSEWIDTH, MAXPULSEWIDTH, autoOff );
-}
-uint8_t Servo8::attach(int pinArg, int pmin, int pmax ) {
-    return attach( pinArg, pmin, pmax, false );
-}
-
-uint8_t Servo8::attach( int pinArg, int pmin, int pmax, bool autoOff ) {
-    // return false if already attached or too many servos
-    if ( pin != NO_PIN ||  servoData.servoIx >= MAX_SERVOS ) return 0;
-    // set pulselength for angle 0 and 180
-    if ( pmin >= MINPULSEWIDTH && pmin <= MAXPULSEWIDTH) min16 = pmin/16;
-    if ( pmax >= MINPULSEWIDTH && pmax <= MAXPULSEWIDTH ) max16 = pmax/16;
-	//DB_PRINT( "pin: %d, pmin:%d pmax%d autoOff=%d, min16=%d, max16=%d", pinArg, pmin, pmax, autoOff, min16, max16);
-    
-    // intialize objectspecific data
-    lastPos = 3000*SPEED_RES ;    // initalize to middle position
-    servoData.soll = -1;  // invalid position -> no pulse output
-    servoData.ist = -1;   
-    servoData.inc = 2000*SPEED_RES;  // means immediate movement
-    servoData.pin = pinArg;
-    servoData.on = false;  // create no pulses until next write
-    servoData.noAutoff = autoOff?0:1 ;  
-    #ifdef FAST_PORTWRT
-    // compute portaddress and bitmask related to pin number
-    servoData.portAdr = (byte *) pgm_read_word_near(&port_to_output_PGM[pgm_read_byte_near(&digital_pin_to_port_PGM[ pinArg])]);
-    servoData.bitMask = pgm_read_byte_near(&digital_pin_to_bit_mask_PGM[pinArg]);
-    //DB_PRINT( "Idx: %d Portadr: 0x%x, Bitmsk: 0x%x", servoData.servoIx, servoData.portAdr, servoData.bitMask );
-	#endif
-    pin = pinArg;
-    angle = NO_ANGLE;
-    pinMode(pin,OUTPUT);
-    digitalWrite(pin,LOW);
-
-    if ( !timerInitialized) seizeTimer1();
-    // initialize servochain pointer if not done already
-    noInterrupts();
-    if ( pulseP == NULL ) pulseP = lastServoDataP;
-    interrupts();
-    
-    // enable compare-A interrupt
-    #if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
-    TIMSK |=  _BV(OCIExA);   
-    #elif defined __AVR_MEGA__
-    //DB_PRINT( "IniOCR: %d", OCRxA );
-    TIMSKx |=  _BV(OCIExA) ; 
-    //DB_PRINT( "AttOCR: %d", OCRxA );
-    #elif defined __STM32F1__
-        timer_cc_enable(MT_TIMER, SERVO_CHN);
-    #endif
-    return 1;
-}
-
-void Servo8::detach()
-{
-    servoData.on = false;  
-    servoData.soll = -1;  
-    servoData.ist = -1;  
-    servoData.pin = NO_PIN;  
-    pin = NO_PIN;
-}
-
-void Servo8::write(int angleArg)
-{   // set position to move to
-    // values between 0 and 180 are interpreted as degrees,
-    // values between MINPULSEWIDTH and MAXPULSEWIDTH are interpreted as microseconds
-    static int newpos;
-    #ifdef __AVR_MEGA__
-	//DB_PRINT( "Write: angleArg=%d, Soll=%d, OCR=%u", angleArg, servoData.soll, OCRxA );
-    #endif
-    if ( pin != NO_PIN ) { // only if servo is attached
-        //Serial.print( "Pin:" );Serial.print(pin);Serial.print("Wert:");Serial.println(angleArg);
-        #ifdef __AVR_MEGA__
-		//DB_PRINT( "Stack=0x%04x, &sIx=0x%04x", ((SPH&0x7)<<8)|SPL, &servoData.servoIx );
-        #endif
-        if ( angleArg < 0) angleArg = 0;
-        if ( angleArg <= 255) {
-            // pulse width as degrees (byte values are always degrees) 09-02-2017
-            angle = min( 180,angleArg);
-
-            newpos = map( angle, 0,180, min16*16, max16*16 ) * TICS_PER_MICROSECOND * SPEED_RES;
-        } else {
-            // pulsewidth as microseconds
-            if ( angleArg < MINPULSEWIDTH ) angleArg = MINPULSEWIDTH;
-            if ( angleArg > MAXPULSEWIDTH ) angleArg = MAXPULSEWIDTH;
-            newpos = angleArg * TICS_PER_MICROSECOND * SPEED_RES;
-            angle = map( angleArg, min16*16, max16*16, 0, 180 );  // angle in degrees
-        }
-        if ( servoData.soll < 0 ) {
-            // Serial.println( "first write");
-            // this is the first pulse to be created after attach
-            servoData.on = true;
-            lastPos = newpos;
-            noInterrupts();
-            servoData.soll= newpos ; // .ist - value is still -1 (invalid) -> will jump to .soll immediately
-            interrupts();
-            
-        }
-        else if ( newpos != servoData.soll ) {
-            // position has changed, store old position, set new position
-            lastPos = servoData.soll;
-            noInterrupts();
-            servoData.soll= newpos ;
-            interrupts();
-        }
-        servoData.offcnt = OFF_COUNT;   // auf jeden Fall wieder Pulse ausgeben
-    }
-}
-
-void Servo8::setSpeed( int speed, bool compatibility ) {
-    // set global compatibility-Flag
-    speedV08 = compatibility;
-    setSpeed( speed );
-}
-
-void Servo8::setSpeed( int speed ) {
-    // Set increment value for movement to new angle
-    if ( pin != NO_PIN ) { // only if servo is attached
-        if ( speedV08 ) speed *= SPEED_RES;
-        noInterrupts();
-        if ( speed == 0 )
-            servoData.inc = 2000*SPEED_RES;  // means immiediate movement
-        else
-            servoData.inc = speed;
-        interrupts();
-    }
-}
-
-uint8_t Servo8::read() {
-    // get position in degrees
-    int value;
-    if ( pin == NO_PIN ) return -1; // Servo not attached
-    noInterrupts();
-    value = servoData.ist;
-    interrupts();
-    return map( value/TICS_PER_MICROSECOND/SPEED_RES, min16*16, max16*16, 0, 180 );
-}
-
-int Servo8::readMicroseconds() {
-    // get position in microseconds
-    int value;
-    if ( pin == NO_PIN ) return -1; // Servo not attached
-    noInterrupts();
-    value = servoData.ist;
-    interrupts();
-    return value/TICS_PER_MICROSECOND/SPEED_RES;   
-
-}
-
-uint8_t Servo8::moving() {
-    // return how much still to move (percentage)
-    if ( pin == NO_PIN ) return 0; // Servo not attached
-    long total , remaining;
-    total = abs( lastPos - servoData.soll );
-    noInterrupts(); // disable interrupt, because integer servoData.ist is changed in interrupt
-    remaining = abs( servoData.soll - servoData.ist );
-    interrupts();  // allow interrupts again
-    if ( remaining == 0 ) return 0;
-    return ( remaining * 100 ) /  total +1;
-}
-uint8_t Servo8::attached()
-{
-    return ( pin != NO_PIN );
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-//Class SoftLed - for Led with soft on / soft off ---------------------------
-// Version with Software PWM
-
-SoftLed::SoftLed() {
-    ledValid = LEDVALID;            // Flag 'object created'
-    ledIx = ledCount++;
-    ledData.speed    = 0;           // defines rising/falling timer
-    ledData.aStep    = 0 ;          // actual PWM step
-    ledData.aCycle   = 0;           // actual cycle ( =length of PWM pule )
-    ledData.stpCnt   = 0;           // counter for PWM cycles on same step (for low speed)
-    ledData.actPulse = false;       // PWM pulse is active
-    ledData.state    = NOTATTACHED; // initialize 
-    setpoint = OFF ;                // initialize to off
-    ledType = LINEAR;
-    ledData.nextLedDataP = NULL;    // don't put in ISR chain
-    ledData.invFlg = false;
-}
-
-void SoftLed::mount( uint8_t stateVal ) {
-    // mount softLed to ISR chain ( if not already in )
-    // new active Softleds are always inserted at the beginning of the chain
-    // only leds in the ISR chain are processed in ISR
-    noInterrupts();
-    SET_TP2;
-    // check if it's not already active (mounted)
-    // Leds must not be mounted twice!
-    if ( ledData.state < ACTIVE ) {
-        // write backward reference into the existing first entry 
-        // only if the chain is not empty
-        if ( ledRootP ) ledRootP->backLedDataPP = &ledData.nextLedDataP;
-        CLR_TP2;
-        ledData.nextLedDataP = ledRootP;
-        ledRootP = &ledData;
-        ledData.backLedDataPP = &ledRootP;
-        SET_TP2;
-    }
-    ledData.state = stateVal;
-    CLR_TP2;
-    interrupts();
-}   
-    
-
-uint8_t SoftLed::attach(uint8_t pinArg, uint8_t invArg ){
-    // Led-Ausgang mit Softstart. 
-    if ( ledValid != LEDVALID ) return false; // this is not a valid instance
-    
-    ledData.invFlg  = invArg;
-    pinMode( pinArg, OUTPUT );
-    //DB_PRINT( "Led attached, ledIx = 0x%x, Count = %d", ledIx, ledCount );
-    ledData.state   = STATE_OFF ;   // initialize 
-    ledSpeed        = 1;            // defines rising/falling timer
-    ledData.aStep   = 0 ;           // actual PWM step
-    if ( ledData.invFlg ) { 
-        digitalWrite( pinArg, HIGH );
-    } else {
-        digitalWrite( pinArg, LOW );
-    }
-    
-    #ifdef FAST_PORTWRT
-    ledData.portPin.Adr = (byte *) pgm_read_word_near(&port_to_output_PGM[pgm_read_byte_near(&digital_pin_to_port_PGM[pinArg])]);
-    ledData.portPin.Mask = pgm_read_byte_near(&digital_pin_to_bit_mask_PGM[pinArg]);
-    #else
-    ledData.pin=pinArg ;      // Pin-Nbr 
-    #endif
-    
-    if ( !timerInitialized ) seizeTimer1();
-    // enable compareB- interrupt
-    #if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
-        TIMSK |= ( _BV(OCIExB) );    // enable compare interrupts
-    #elif defined __AVR_MEGA__
-        TIMSKx |= _BV(OCIExB) ; 
-    #elif defined __STM32F1__
-        timer_cc_enable(MT_TIMER, STEP_CHN);
-    #endif
-
-    return true;
-}
-
-void SoftLed::on(){
-    if ( ledValid != LEDVALID ) return;  // this is not a valid instance
-    uint8_t stateT;
-    // Don't do anything if its already ON 
-    if ( setpoint != ON  ) {
-        setpoint        = ON ;
-        ledData.aStep   = 0;
-        ledData.stpCnt  = 0; 
-        if ( ledType == LINEAR ) {
-            stateT          = INCLIN;
-            ledData.speed   = ledSpeed;
-            ledData.aCycle  = 1;
-        } else { // is bulb simulation
-            stateT          = INCFAST;
-            ledData.speed   = ledSpeed==1? -1 : ledSpeed / 3;
-            if ( ledData.speed <= 0 ) {
-                stateT      = INCSLOW;
-                ledData.stpCnt = 1;
-            }
-            ledData.aCycle  = iSteps[0];
-        }
-        mount(stateT);
-    }
-    //DB_PRINT( "Led %d On, state=%d", ledIx, ledData.state);
-}
-
-void SoftLed::off(){
-    if ( ledValid != LEDVALID ) return; // this is not a valid instance
-    uint8_t stateT;
-    // Dont do anything if its already OFF 
-    if ( setpoint != OFF ) {
-        //SET_TP3;
-        setpoint            = OFF;
-        ledData.aStep       = 0;
-        ledData.stpCnt      = 0; 
-        if ( ledType == LINEAR ) {
-            stateT          = DECLIN;
-            ledData.speed   = ledSpeed;
-            ledData.aCycle  = LED_CYCLE_MAX-1;
-        } else { // is bulb simulation
-            //CLR_TP3;
-            stateT = DECFAST;
-            ledData.speed = ledSpeed==1? -1 : ledSpeed / 3;
-            //SET_TP3;
-            if ( ledData.speed <= 0 ) {
-                stateT          = DECSLOW;
-                ledData.stpCnt  = 1;
-            }
-            ledData.aCycle = LED_CYCLE_MAX + 1 - iSteps[0];
-        }
-        //CLR_TP3;
-        mount(stateT);
-    }
-    //DB_PRINT( "Led %d Off, state=%d", ledIx, ledData.state);
-}
-
-void SoftLed::toggle( void ) {
-    if ( ledValid != LEDVALID ) return; // this is not a valid instance
-    if ( setpoint == ON  ) off();
-    else on();
-}
-
-void SoftLed::write( uint8_t setpntVal, uint8_t ledPar ){
-    if ( ledValid != LEDVALID ) return; // this is not a valid instance
-    ledType = ledPar;
-    write( setpntVal ) ;
-}
-
-void SoftLed::write( uint8_t setpntVal ){
-    //DB_PRINT( "LedWrite ix= %d, valid= 0x%x, sp=%d, lT=%d", ledIx, ledValid, setpntVal, ledType );
-    if ( ledValid != LEDVALID ) return; // this is not a valid instance
-    if ( setpntVal == ON ) on(); else off();
-    #ifdef debug
-    // im Debugmode hier die Led-Daten ausgeben
-    //DB_PRINT( "LedData[%d]\n\speed=%d, Type=%d, aStep=%d, stpCnt=%d, state=%d, setpoint= %d",
-            ledValid, ledSpeed, ledType, ledData.aStep, ledData.stpCnt, ledData.state
-                    , setpoint);
-    //DB_PRINT( "ON=%d, NextCyc=%d, CycleCnt=%d, StepIx=%d, NextStep=%d", 
-    //         ON, ledNextCyc, ledCycleCnt, ledStepIx, ledNextStep);
-    #endif
-}
-
-void SoftLed::riseTime( int riseTime ) {
-    if ( ledValid != LEDVALID ) return;
-    // length of startphase in ms (min 20ms, max 1200ms )
-    // the real risetime is only a rough approximate to this time
-    // risetime is computed to a 'speed' Value with 1 beeing the slowest 
-    // with speed value = 1 means risetime is (LED_CYCLE_MAX * LED_PWMTIME)
-    // risetime = (LED_CYCLE_MAX * LED_PWMTIME) / speed
-    // 
-    // toDo: a better approximation to 'riseTime'
-    int riseMax = (int)( LED_CYCLE_MAX * (int)LED_PWMTIME);
-    if ( riseTime <= 20 ) riseTime = 20;
-    if ( riseTime >= riseMax ) riseTime = riseMax;
-    int tmp = ( (riseMax  *10) / ( riseTime  ) +5 ) /10;
-    ledSpeed = tmp;
-    //DB_PRINT( "ledSpeed[%d] = %d ( risetime=%d, riseMax=%d )", ledIx, ledSpeed, riseTime, riseMax );
-}
-
-////////////////////////////////////////////////////////////////////////////
-// Class EggTimer - Timerverwaltung für Zeitverzögerungen in der Loop-Schleife
-// 
-void EggTimer::setTime(  long wert ) {
-    endtime =  (long) millis() + ( (long)wert>0?wert:1 );
-    active = true;
-}
-
-bool EggTimer::running() {
-    if ( active ) active =  ( endtime - (long)millis() > 0 );
-    return active;
-}
-
-long EggTimer::getTime() {
-    // return remaining time
-    if ( running() ) return endtime - (long)millis();
-    else return 0;
-}
-EggTimer::EggTimer()
-{
-    active = false;
-}
-
-

+ 0 - 374
SE/stuff/P5_Automation-library-dev/MobaTools/src/MobaTools.h

@@ -1,374 +0,0 @@
-#ifndef MOBATOOLS_H
-#define MOBATOOLS_H
-/*
-  MobaTools.h - a library for model railroaders
-  Author: fpm, fpm@mnet-mail.de
-  Copyright (c) 2017 All right reserved.
-
-  MobaTools V1.0
-   (C) 11-2017 fpm fpm@mnet-online.de
-   
-  History:
-  V1.0  11-2017 Use of Timer 3 if available ( on AtMega32u4 and AtMega2560 )
-  V0.9  03-2017
-        Better resolution for the 'speed' servo-paramter (programm starts in compatibility mode)
-        outputs for softleds can be inverted
-        MobaTools run on STM32F1 platform
-        
-  V0.8 02-2017
-        Enable Softleds an all digital outputs
-  V0.7 01-2017
-		Allow nested Interrupts with the servos. This allows more precise other
-        interrupts e.g. for NmraDCC Library.
-		A4988 stepper driver IC is supported (needs only 2 ports: step and direction)
-
-  Library to drive the Stepper Motor 28BYJ-48
-  connected to SPI (MOSI,CLK,SS) Interface via shift register
-  or 4 pins directly
-   
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-/*  08-02-17    start of implementing STM32 support
-    03-02-17 / V0.8  Softleds now working on all digital outputs
-    02-11-16 / (V0.7) Updating Stepper driver:
-   - stepper motor can be connected ba means of a4988 stepper motor driver IC
-     this uses only 2 pins: STEP and DIRECTION
-*/
-#include <inttypes.h>
-#include <Arduino.h>
-
-#ifndef  __AVR_MEGA__
-#ifndef __STM32F1__
-#error "Only AVR AtMega  or STM32F1 processors are supported"
-#endif
-#endif
-#ifdef __STM32F1__
-#include <libmaple/timer.h>
-#include <libmaple/spi.h>
-#endif
-
-
-#define Servo2	Servo8		// Kompatibilität zu Version 01 und 02
-//defines used in user programs
-#define HALFSTEP    1
-#define FULLSTEP    2
-#define A4988       3   // using motordriver A4988
-#define NOSTEP      0   // invalid-flag
-
-#define NO_OUTPUT   0
-#ifdef __AVR_MEGA__
-#define PIN8_11     1
-#define PIN4_7      2
-#endif
-#define SPI_1        3
-#define SPI_2        4
-#define SPI_3        5
-#define SPI_4        6
-#define SINGLE_PINS  7
-#define A4988_PINS  8
-
-// for formatted printing to Serial( just like fprintf )
-// you need to define txtbuf with proper length to use this
-#define SerialPrintf( ... ) sprintf( txtbuf,  __VA_ARGS__ ); Serial.print( txtbuf );
-
-//#define FIXED_POSITION_SERVO_PULSES
-////////////////// END OF 'PUBLIC' PARAMETERS ////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// internal defines
-#ifdef __AVR_MEGA__
-    // defines only for ATMega
-    #define FAST_PORTWRT        // if this is defined, ports are written directly in IRQ-Routines,
-                                // not with 'digitalWrite' functions
-    #define TICS_PER_MICROSECOND (clockCyclesPerMicrosecond() / 8 ) // prescaler is 8 = 0.5us
-        
-#elif defined __STM32F1__
-    //defines only for STM32
-    #define TICS_PER_MICROSECOND (clockCyclesPerMicrosecond() / 36 ) // prescaler is 36 = 0.5us
-#endif
-
-// defines for the stepper motor
-#define MAX_STEPPER  4    // 
-#define MIN_STEPTIME 800  // minimum steptime between 2 steps
-#define CYCLETIME   200     // Irq-periode in us. Step time is an integer multiple
-                            // of this value
-#define CYCLETICS   CYCLETIME*TICS_PER_MICROSECOND
-
-// defines for soft-leds
-#define MAX_LEDS    16     // Soft On/Off defined for compatibility reasons. There is no fixed limit anymore.
-
-// defines for servos
-    #define MINPULSEWIDTH   700     // don't make it shorter
-    #define MAXPULSEWIDTH   2300    // don't make it longer
-#ifdef FIXED_POSITION_SERVO_PULSES
-    #define MAX_SERVOS  8
-#else
-    #define OVLMARGIN           280     // Overlap margin ( Overlap is MINPULSEWIDTH - OVLMARGIN )
-    #define OVL_TICS       ( ( MINPULSEWIDTH - OVLMARGIN ) * TICS_PER_MICROSECOND )
-    #define MARGINTICS      ( OVLMARGIN * TICS_PER_MICROSECOND )
-    #define MAX_SERVOS  16  
-#endif               
-#define MINPULSETICS    MINPULSEWIDTH * TICS_PER_MICROSECOND
-#define MAXPULSETICS    MAXPULSEWIDTH * TICS_PER_MICROSECOND
-#define OFF_COUNT       50  // if autoOff is set, a pulse is switched off, if it length does not change for
-                            // OFF_COUNT cycles ( = OFF_COUNT * 20ms )
-#define FIRST_PULSE     100 // first pulse starts 200 tics after timer overflow, so we do not compete
-                            // with overflow IRQ
-#define SPEED_RES       4   // All position values in tics are multiplied by this factor. This means, that one 
-                            // 'Speed-tic' is 0,125 µs per 20ms cycle. This gives better resolution in defining the speed.
-                            // Only when computing the next interrupt time the values are divided by this value again to get
-                            // the real 'timer tics'
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-// 
-typedef struct {    // portaddress and bitmask for direkt pin set/reset
-   uint8_t* Adr;
-   uint8_t Mask;
-} portBits_t;
-
-/////////////////////////////////////////////////////////////////////////////////
-// global stepper data ( used in ISR )
-typedef struct {
-  volatile long stepCnt;        // nmbr of steps to take
-  volatile int8_t patternIx;    // Pattern-Index of actual Step (0-7)
-  int8_t patternIxInc;          // halfstep: +/-1, fullstep: +/-2, A4988 +3/-3/
-                                // sign defines direction
-  uint16_t cycSteps;            // nbr of IRQ cycles per step ( speed of motor )
-  uint16_t rCycSteps;           // nbr of IRQ cycles per step during start/stop ramp
-  uint16_t rStepDec;            // count of steps until decrementing cycle ( during start ramp )
-  volatile uint16_t cycCnt;     // counting cycles until cycStep
-  volatile long stepsFromZero;  // distance from last reference point ( always as steps in HALFSTEP mode )
-                                // in FULLSTEP mode this is twice the real step number
-  uint8_t output  :6 ;             // PORTB(pin8-11), PORTD (pin4-7), SPI0,SPI1,SPI2,SPI3, SINGLE_PINS, A4988_PINS
-  uint8_t activ :1;  
-  uint8_t endless :1;              // turn endless
-  #ifdef FAST_PORTWRT
-  portBits_t portPins[4];       // Outputpins as Portaddress and Bitmask for faster writing
-  #else
-  uint8_t pins[4];                 // Outputpins as Arduino numbers
-  #endif
-  uint8_t lastPattern;             // only changed pins are updated ( is faster )
-} stepperData_t ;
-
-typedef union { // used output channels as bit and uint8_t
-      struct {
-        uint8_t pin8_11 :1;
-        uint8_t pin4_7  :1;
-        uint8_t spi1    :1;
-        uint8_t spi2    :1;
-        uint8_t spi3    :1;
-        uint8_t spi4    :1;
-      };
-      uint8_t outputs;
-    
-} outUsed_t;
-
-////////////////////////////////////////////////////////////////////////////////////
-// global servo data ( used in ISR )
-typedef struct servoData_t {
-  struct servoData_t* prevServoDataP;
-  uint8_t servoIx :6 ;  // Servo number
-  uint8_t on   :1 ;     // True: create pulse
-  uint8_t noAutoff :1;  // don't switch pulses off automatically
-  int soll;             // Position, die der Servo anfahren soll ( in Tics ). -1: not initialized
-  volatile int ist;     // Position, die der Servo derzeit einnimt ( in Tics )
-  int inc;              // Schrittweite je Zyklus um Ist an Soll anzugleichen
-  uint8_t offcnt;       // counter to switch off pulses if length doesn't change
-  #ifdef FAST_PORTWRT
-  uint8_t* portAdr;     // port adress related to pin number
-  uint8_t  bitMask;     // bitmask related to pin number
-  #endif
-  uint8_t pin     ;     // pin 
-} servoData_t ;
-
-//////////////////////////////////////////////////////////////////////////////////
-// global data for softleds ( used in ISR )
-// the PWM pulses are created together with stepper pulses
-//
-// table of pwm-steps for soft on/off in CYCLETIME units ( bulb simulation). The last value means pwm cycletime
-//14ms cycletime
-//const uint8_t iSteps[] = { 2, 3 , 4, 6, 8, 11, 14, 17, 21, 25, 30, 36, 43, 55, 70 };
-//16ms cycletime ( 60Hz )
-//const uint8_t iSteps[] = {2, 8 ,14 ,20, 25,30, 35, 39, 43, 47, 50, 53, 56, 58, 60, 62, 64,66,68,70,72,73,74,75,76,78,79,80 };
-const uint8_t iSteps[] = {9, 16 ,23 ,29, 35,41, 45, 49, 53, 56, 59, 62, 64, 66, 68, 70, 71,72,73,74,75,76,77,77,78,78,79,80 };
-// 20ms cycletime ( 50Hz )
-//const uint8_t iSteps[] = { 2,4, 6, 9, 12, 15, 20, 25, 30, 35, 40, 45,50,55,65,80,100 };
-
-#define LED_STEP_MAX    (sizeof(iSteps) -1)
-#define LED_CYCLE_MAX   (iSteps[LED_STEP_MAX])
-#define LED_PWMTIME     (iSteps[LED_STEP_MAX] / 5)  // PWM refreshrate in ms
-                                        // todo: dies gilt nur bei einer CYCLETIME von 200us (derzeit default)
-
-typedef struct ledData_t {            // global led values ( used in IRQ )
-  struct ledData_t*   nextLedDataP;   // chaining the active Leds
-  struct ledData_t**  backLedDataPP;    // adress of pointer, that points to this led (backwards reference)
-  int8_t speed;             // > 0 : steps per cycle ( more steps = more speed )
-                            // < 0 : cycles per step ( more cycles = less speed )
-                            // 0: led is inactive (not attached)
-    // uint8_t invert=false;   // false: ON ist HIGH, true: ON is LOW
-  int8_t aStep;      // actual step (brightness)
-  int8_t aCycle;  // actual cycle ( =length of PWM pule )
-  int8_t stpCnt;     // counter for PWM cycles on same step (for low speed)
-  uint8_t actPulse;    // PWM pulse is active
-  uint8_t state;	// actual state: steady or incementing/decrementing
-    #define NOTATTACHED 0
-    #define STATE_OFF   1       // using #defines here is a little bit faster in the ISR than enums
-    #define STATE_ON    2
-    #define ACTIVE      3       // state >= ACTIVE means active in ISR routine
-    #define INCFAST     3
-    #define DECFAST     4
-    #define INCSLOW     5
-    #define DECSLOW     6
-    #define INCLIN      7
-    #define DECLIN      8
-    
-  volatile uint8_t invFlg;
-  #ifdef FAST_PORTWRT
-  portBits_t portPin;       // Outputpin as portaddress and bitmask for faster writing
-  #else
-  uint8_t pin;                 // Outputpins as Arduino numbers
-  #endif
-} ledData_t;
-
-
-//////////////////////////////////////////////////////////////////////////////
-class Stepper4
-{
-  private:
-    uint8_t stepperIx;              // Index in Structure
-    int stepsRev;                   // steps per full rotation
-    long stepsToMove;                // from last point
-    uint8_t stepMode;               // FULLSTEP or HALFSTEP
-    uint8_t minCycSteps;            // minimum time between 2 steps without ramp
-                                    // ramp starts with this speed if wanted speed ist faster
-    uint8_t minrCycSteps;           // absolute minimum time between 2 steps even with ramp
-    static outUsed_t outputsUsed;
-    long getSFZ();                  // get step-distance from last reference point
-    void initialize(int,uint8_t,uint8_t);
-  public:
-    Stepper4(int steps);            // steps per 360 degree in FULLSTEP mode
-    Stepper4(int steps, uint8_t mode ); 
-                                    // mode means HALFSTEP or FULLSTEP
-    Stepper4(int steps, uint8_t mode, uint8_t minStepTime ); // min StepTim in ms
-    
-    uint8_t attach( uint8_t,uint8_t,uint8_t,uint8_t); //single pins definition for output
-    uint8_t attach( uint8_t stepP, uint8_t dirP); // Port for step and direction in A4988 mode
-    uint8_t attach(uint8_t outArg);    // stepMode defaults to halfstep
-    uint8_t attach(uint8_t outArg, uint8_t*  ); 
-                                    // returns 0 on failure
-    void detach();                  // detach from output, motor will not move anymore
-    void write(long angle);         // specify the angle in degrees, mybe pos or neg. angle is
-                                    // measured from last 'setZero' point
-    void write(long angle, uint8_t factor);        // factor specifies resolution of parameter angle
-                                    // e.g. 10 means, 'angle' is angle in .1 degrees
-	void writeSteps( long stepPos );// Go to position stepPos steps from zeropoint
-    void setZero();                 // actual position is set as 0 angle (zeropoint)
-    int setSpeed(int rpm10 );       // Set movement speed, rpm*10
-    void doSteps(long count);       // rotate count steps. May be positive or negative
-                                    // angle is updated internally, so the next call to 'write'
-                                    // will move to the correct angle
-    void rotate(int8_t direction ); // rotate endless until 'stop',
-    void stop();                    // stops moving immediately
-    uint8_t moving();               // returns the remaining way to the angle last set with write() in
-                                    // in percentage. '0' means, that the angle is reached
-                                    // 255 means the motor is rotating endlessly
-    long read();                    // actual angle from zeropoint (setZero)
-    long readSteps();               // actual distance to zeropoint in steps
-    uint8_t attached();
-};
-
-////////////////////////////////////////////////////////////////////////////////////////
-class Servo8
-{
-  private:
-    int16_t lastPos;     // startingpoint of movement
-    uint8_t pin;
-    uint8_t angle;       // in degrees
-    uint8_t min16;       // minimum pulse, 16uS units  (default is 34)
-    uint8_t max16;       // maximum pulse, 16uS units, (default is 150)
-    servoData_t servoData;  // Servo data to be used in ISR
-
-	public:
-    Servo8();
-    uint8_t attach(int pin); // attach to a pin, sets pinMode, returns 0 on failure, won't
-                             // position the servo until a subsequent write() happens
-    uint8_t attach( int pin, bool autoOff );        // automatic switch off pulses with constant length
-    uint8_t attach(int pin, int pos0, int pos180 ); // also sets position values (in us) for angele 0 and 180
-    uint8_t attach(int pin, int pos0, int pos180, bool autoOff );
-    void detach();
-    void write(int);         // specify the angle in degrees, 0 to 180. Values obove 180 are interpreted
-                             // as microseconds, limited to MaximumPulse and MinimumPulse
-    void setSpeed(int);      // Set Movement speed, the higher the faster
-                             // Zero means no speed control (default)
-    void setSpeed(int,bool); // Set compatibility-Flag (true= compatibility with version V08 and earlier)
-    #define HIGHRES 0
-    #define SPEEDV08 1
-    
-    uint8_t moving();        // returns the remaining Way to the angle last set with write() in
-                             // in percentage. '0' means, that the angle is reached
-    uint8_t read();          // current position in degrees (0...180)
-    int   readMicroseconds();// current pulsewidth in microseconds
-    uint8_t attached();
-    void setMinimumPulse(uint16_t);  // pulse length for 0 degrees in microseconds, 700uS default
-    void setMaximumPulse(uint16_t);  // pulse length for 180 degrees in microseconds, 2300uS default
-};
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-class SoftLed
-{ // Switch leds on/off softly.
-  // 
-  public:
-    SoftLed();
-    uint8_t attach(uint8_t pinArg, uint8_t invArg = false );     // Led-pin with soft on
-    void riseTime( int );       // in millisec - falltime is the same
-    void on();                   // 
-    void off();                  // 
-	void write( uint8_t );			// is ON or OFF
-    void write( uint8_t time, uint8_t type  ); //whether it is a linear or bulb type
-    void toggle( void ); 
-  private:
-    void mount( uint8_t state );
-    ledData_t ledData;
-    uint8_t	setpoint;
-    #define OFF 0
-    #define ON  1
-    uint8_t ledType;        // Type of lamp (linear or bulb)
-    #define LINEAR  0
-    #define BULB    1
-    uint8_t ledIx;
-    uint8_t ledValid;       // Flag that this is a valid instance
-    #define LEDVALID 0x55
-    uint8_t ledSpeed;       // speed with IRQ based softleds
-    
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////
-// Timermanagement
-
-
-class EggTimer
-{
-  public:
-    EggTimer();
-    void setTime( long);
-    bool running();
-    long getTime();
-
-  private:
-    bool active;
-    long endtime;
-};
-#endif
-

+ 0 - 21
SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/LICENSE

@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2015 Scott Russell (scott@queuetue.com)
-
-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.

+ 0 - 41
SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/README.md

@@ -1,41 +0,0 @@
-# Queuetue HX711 Arduino Library
-
-Copyright (c) 2015 Scott Russell (scott@queuetue.com), released under the MIT license.  
-See the LICENSE file for licensing details.
-
-A simple Arduino driver for the HX711 ADC.
-
-The HX711 is a low-cost strain gauge amplifier produced by Avia Semiconductor.  Breakout boards are available for it by many producers, including the [Sparkfun 13230](https://www.sparkfun.com/products/13230).
-
-The HX711 communicates with a non-i2c compliant two wire protocol and provides an all-in-one solution to load cell amplification with relatively low noise.
-
-This library provides the code required to use an Arduino, the HX711 module and a strain gauge load cell to build a scale, force gauge or many other pressure or force sensitive projects.
-
-The library has a single class, **Q2HX711** with two functions.  
-
-## Class
-The **Q2HX711** class takes two parameters on construction, the pin to use for data (output) and the pin to use to signal readiness (clock).
-
-## Functions
-
-Function  | Description
-------------- | -------------
-**read**  | Returns a long integer that is the current value of the HX711
-**readyToSend**  | Returns a boolean indicating if the HX711 is prepared to send data.
-
-## Example
-
-Here is a simple example of using the HX711 on pins A2 and A3 to read a strain gauge and print it's current value:
-
-```c++
-#include <Q2HX711.h>
-Q2HX711 hx711(A2, A3);
-void setup() {
-  Serial.begin(9600);
-}
-
-void loop() {
-  Serial.println(hx711.read());
-  delay(500);
-}
-```

+ 0 - 15
SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/examples/simple_scale/simple_scale.ino

@@ -1,15 +0,0 @@
-#include <Q2HX711.h>
-
-const byte hx711_data_pin = A2;
-const byte hx711_clock_pin = A3;
-
-Q2HX711 hx711(hx711_data_pin, hx711_clock_pin);
-
-void setup() {
-  Serial.begin(9600);
-}
-
-void loop() {
-  Serial.println(hx711.read()/100.0);
-  delay(500);
-}

+ 0 - 20
SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/keywords.txt

@@ -1,20 +0,0 @@
-#######################################
-# Syntax Coloring Map For Q2HX711
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-
-Q2HX711				KEYWORD1	Q2HX711
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-readyToSend				KEYWORD2
-read			KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################

+ 0 - 9
SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/library.properties

@@ -1,9 +0,0 @@
-name=Queuetue HX711 Library
-version=1.0.1
-author=Scott Russell <scott@queuetue.com>
-maintainer=Scott Russell <scott@queuetue.com>
-sentence=Simple driver for the HX711 ADC.
-paragraph=Allows you to use the inexpensive HX711 strain gauge amplifier and 24-bit ADC to build scales, force gauges and other sensors.
-category=Sensors
-url=https://github.com/queuetue/Q2-HX711-Arduino-Library
-architectures=*

+ 0 - 53
SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/src/Q2HX711.cpp

@@ -1,53 +0,0 @@
-#include <Arduino.h>
-#include "Q2HX711.h"
-
-Q2HX711::Q2HX711(byte output_pin, byte clock_pin) {
-  CLOCK_PIN  = clock_pin;
-  OUT_PIN  = output_pin;
-  GAIN = 1;
-  pinMode(CLOCK_PIN, OUTPUT);
-  pinMode(OUT_PIN, INPUT);
-}
-
-Q2HX711::~Q2HX711() {
-}
-
-bool Q2HX711::readyToSend() {
-  return digitalRead(OUT_PIN) == LOW;
-}
-
-void Q2HX711::setGain(byte gain) {
-  switch (gain) {
-    case 128:
-      GAIN = 1;
-      break;
-    case 64:
-      GAIN = 3;
-      break;
-    case 32:
-      GAIN = 2;
-      break;
-  }
-
-  digitalWrite(CLOCK_PIN, LOW);
-  read();
-}
-
-long Q2HX711::read() {
-   while (!readyToSend());
-
-  byte data[3];
-
-  for (byte j = 3; j--;) {
-      data[j] = shiftIn(OUT_PIN,CLOCK_PIN, MSBFIRST);
-  }
-
-  // set gain
-  for (int i = 0; i < GAIN; i++) {
-    digitalWrite(CLOCK_PIN, HIGH);
-    digitalWrite(CLOCK_PIN, LOW);
-  }
-
-  data[2] ^= 0x80;
-  return ((uint32_t) data[2] << 16) | ((uint32_t) data[1] << 8) | (uint32_t) data[0];
-}

+ 0 - 19
SE/stuff/P5_Automation-library-dev/Queuetue_HX711_Library/src/Q2HX711.h

@@ -1,19 +0,0 @@
-#ifndef Q2HX711_h
-#define Q2HX711_h
-#include "Arduino.h"
-
-class Q2HX711
-{
-  private:
-    byte CLOCK_PIN;
-    byte OUT_PIN;
-    byte GAIN;
-    void setGain(byte gain = 128);
-  public:
-    Q2HX711(byte output_pin, byte clock_pin);
-    virtual ~Q2HX711();
-    bool readyToSend();
-    long read();
-};
-
-#endif /* Q2HX711_h */

+ 0 - 22
SE/stuff/P5_Automation-library-dev/Scheduler/README.adoc

@@ -1,22 +0,0 @@
-= Scheduler Library for Arduino =
-
-The Scheduler library enables the Arduino Due to run multiple functions at the same time. This allows tasks to happen without interrupting each other. 
-
-For more information about this library please visit us at
-http://www.arduino.cc/en/Reference/Scheduler
-
-== License ==
-
-Copyright (c) 2012 The Android Open Source Project. All right reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.

+ 0 - 81
SE/stuff/P5_Automation-library-dev/Scheduler/examples/MultipleBlinks/MultipleBlinks.ino

@@ -1,81 +0,0 @@
-/*
- Multiple Blinks
-
- Demonstrates the use of the Scheduler library for the Arduino Due
-
- Hardware required :
- * LEDs connected to pins 11, 12, and 13
-
- created 8 Oct 2012
- by Cristian Maglie
- Modified by
- Scott Fitzgerald 19 Oct 2012
-
- This example code is in the public domain
-
- http://www.arduino.cc/en/Tutorial/MultipleBlinks
-*/
-
-// Include Scheduler since we want to manage multiple tasks.
-#include <Scheduler.h>
-
-int led1 = 13;
-int led2 = 12;
-int led3 = 11;
-
-void setup() {
-  Serial.begin(9600);
-
-  // Setup the 3 pins as OUTPUT
-  pinMode(led1, OUTPUT);
-  pinMode(led2, OUTPUT);
-  pinMode(led3, OUTPUT);
-
-  // Add "loop2" and "loop3" to scheduling.
-  // "loop" is always started by default.
-  Scheduler.startLoop(loop2);
-  Scheduler.startLoop(loop3);
-}
-
-// Task no.1: blink LED with 1 second delay.
-void loop() {
-  digitalWrite(led1, HIGH);
-
-  // IMPORTANT:
-  // When multiple tasks are running 'delay' passes control to
-  // other tasks while waiting and guarantees they get executed.
-  delay(1000);
-
-  digitalWrite(led1, LOW);
-  delay(1000);
-}
-
-// Task no.2: blink LED with 0.1 second delay.
-void loop2() {
-  digitalWrite(led2, HIGH);
-  delay(100);
-  digitalWrite(led2, LOW);
-  delay(100);
-}
-
-// Task no.3: accept commands from Serial port
-// '0' turns off LED
-// '1' turns on LED
-void loop3() {
-  if (Serial.available()) {
-    char c = Serial.read();
-    if (c == '0') {
-      digitalWrite(led3, LOW);
-      Serial.println("Led turned off!");
-    }
-    if (c == '1') {
-      digitalWrite(led3, HIGH);
-      Serial.println("Led turned on!");
-    }
-  }
-
-  // IMPORTANT:
-  // We must call 'yield' at a regular basis to pass
-  // control to other tasks.
-  yield();
-}

+ 0 - 20
SE/stuff/P5_Automation-library-dev/Scheduler/keywords.txt

@@ -1,20 +0,0 @@
-#######################################
-# Syntax Coloring Map For Scheduler
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-
-Scheduler	KEYWORD1	Scheduler
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-startLoop	KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-

+ 0 - 9
SE/stuff/P5_Automation-library-dev/Scheduler/library.properties

@@ -1,9 +0,0 @@
-name=Scheduler
-version=0.4.4
-author=Arduino
-maintainer=Arduino <info@arduino.cc>
-sentence=Allows multiple tasks to run at the same time, without interrupting each other. For Arduino sam and samd architectures only (Due, Zero...).
-paragraph=The Scheduler library enables the Arduino to run multiple functions at the same time. This allows tasks to happen without interrupting each other.</br>This is a cooperative scheduler in that the CPU switches from one task to another. The library includes methods for passing control between tasks.
-category=Other
-url=http://www.arduino.cc/en/Reference/Scheduler
-architectures=sam,samd

+ 0 - 208
SE/stuff/P5_Automation-library-dev/Scheduler/src/Scheduler.cpp

@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Scheduler.h"
-
-extern "C" {
-
-#define NUM_REGS 10	// r4-r11, sp, pc
-
-typedef struct CoopTask {
-	uint32_t regs[NUM_REGS];
-	void* stackPtr;
-	struct CoopTask* next;
-	struct CoopTask* prev;
-} CoopTask;
-
-static CoopTask *cur = 0;
-
-static CoopTask* __attribute__((noinline)) coopSchedule(char taskDied) {
-	CoopTask* next = cur->next;
-
-	if (taskDied) {
-		// Halt if last task died.
-		if (next == cur)
-			while (1)
-				;
-
-		// Delete task
-		if (cur->stackPtr)
-			free(cur->stackPtr);
-		cur->next->prev = cur->prev;
-		cur->prev->next = cur->next;
-		free(cur);
-	}
-	cur = next;
-	return next;
-}
-
-static void __attribute__((naked)) __attribute__((noinline)) coopTaskStart(void) {
-	asm (
-		"mov   r0, r5;"
-		"blx   r4;"
-		/* schedule. */
-		"mov   r0, #1;"      /* returned from task func: task done */
-		"bl    coopSchedule;"
-		/* r0 holds address of next task context */
-#if defined(ARDUINO_ARCH_SAMD)
-		/* for cortex m0, ldm and stm are restricted to low registers */
-		/* load high registers */
-		"add   r0, #16;"     /* they are 4 words higher in memory */
-		"ldmia r0, {r1-r6};" /* load them in low registers first... */
-		"mov   r8, r1;"      /* ...and move them into high registers... */
-		"mov   r9, r2;"
-		"mov   r10, r3;"
-		"mov   r11, r4;"
-		"mov   r12, r5;"
-		"mov   lr, r6;"
-		/* load low registers */
-		"sub   r0, r0, #40;" /* back to begin of context */
-		"ldmia r0, {r4-r7};"
-#else
-		"ldmia r0, {r4-r12, lr};"
-#endif
-		/* restore task stack */
-		"mov   sp, r12;"
-		/* resume task */
-		"bx    lr;"
-	);
-}
-
-static void __attribute__((naked)) __attribute__((noinline)) coopDoYield(CoopTask* curTask) {
-	asm (
-		"mov   r12, sp;"
-#if defined(ARDUINO_ARCH_SAMD)
-		/* store low registers */
-		"stmia r0, {r4-r7};"
-		/* store high registers */
-		"mov   r1, r8;"      /* move them to low registers first. */
-		"mov   r2, r9;"
-		"mov   r3, r10;"
-		"mov   r4, r11;"
-		"mov   r5, r12;"
-		"mov   r6, lr;"
-		"stmia r0, {r1-r6};"
-#else
-		"stmia r0, {r4-r12, lr};"
-#endif
-		/* schedule. */
-		"mov   r0, #0;"      /* previous task did not complete */
-		"bl    coopSchedule;"
-		/* r0 holds address of next task context */
-#if defined(ARDUINO_ARCH_SAMD)
-		/* for cortex m0, ldm and stm are restricted to low registers */
-		/* load high registers */
-		"add   r0, #16;"     /* they are 4 words higher in memory */
-		"ldmia r0, {r1-r6};" /* load them in low registers first... */
-		"mov   r8, r1;"      /* ...and move them into high registers... */
-		"mov   r9, r2;"
-		"mov   r10, r3;"
-		"mov   r11, r4;"
-		"mov   r12, r5;"
-		"mov   lr, r6;"
-		/* load low registers */
-		"sub   r0, r0, #40;" /* back to begin of context */
-		"ldmia r0, {r4-r7};"
-#else
-		"ldmia r0, {r4-r12, lr};"
-#endif
-		/* restore task stack */
-		"mov   sp, r12;"
-		/* resume task */
-		"bx    lr;"
-	);
-}
-
-static int coopInit(void) {
-	CoopTask* task;
-
-	task = reinterpret_cast<CoopTask *>(malloc(sizeof(CoopTask)));
-	if (!task)
-		return 0;
-	task->next = task;
-	task->prev = task;
-	task->stackPtr = 0;
-	cur = task;
-
-	return 1;
-}
-
-static int coopSpawn(SchedulerParametricTask taskF, void* taskData, uint32_t stackSz) {
-	uint8_t *stack = (uint8_t*)malloc(stackSz);
-	if (!stack)
-		return 0;
-
-	CoopTask *task = reinterpret_cast<CoopTask *>(malloc(sizeof(CoopTask)));
-	if (!task) {
-		free(stack);
-		return 0;
-	}
-	task->stackPtr = stack;
-	task->regs[0] = (uint32_t) taskF;
-	task->regs[1] = (uint32_t) taskData;
-	task->regs[8] = ((uint32_t)(stack + stackSz)) & ~7;
-	task->regs[9] = (uint32_t) & coopTaskStart;
-
-	task->prev = cur;
-	task->next = cur->next;
-	cur->next->prev = task;
-	cur->next = task;
-
-	// These are here so compiler is sure that function is
-	// referenced in both variants (cancels a warning)
-	if (stackSz == 0xFFFFFFFF)
-		coopSchedule(0);
-	if (stackSz == 0xFFFFFFFE)
-		coopSchedule(1);
-
-	return 1;
-}
-
-void yield(void) {
-	coopDoYield(cur);
-}
-
-}; // extern "C"
-
-SchedulerClass::SchedulerClass() {
-	coopInit();
-}
-
-static void startLoopHelper(void *taskData) {
-	SchedulerTask task = reinterpret_cast<SchedulerTask>(taskData);
-	while (true)
-		task();
-}
-
-void SchedulerClass::startLoop(SchedulerTask task, uint32_t stackSize) {
-	coopSpawn(startLoopHelper, reinterpret_cast<void *>(task), stackSize);
-}
-
-static void startTaskHelper(void *taskData) {
-	SchedulerTask task = reinterpret_cast<SchedulerTask>(taskData);
-	task();
-}
-
-void SchedulerClass::start(SchedulerTask task, uint32_t stackSize) {
-	coopSpawn(startTaskHelper, reinterpret_cast<void *>(task), stackSize);
-}
-
-void SchedulerClass::start(SchedulerParametricTask task, void *taskData, uint32_t stackSize) {
-	coopSpawn(task, taskData, stackSize);
-}
-
-SchedulerClass Scheduler;
-

+ 0 - 40
SE/stuff/P5_Automation-library-dev/Scheduler/src/Scheduler.h

@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _SCHEDULER_H_
-#define _SCHEDULER_H_
-
-#include <Arduino.h>
-
-extern "C" {
-	typedef void (*SchedulerTask)(void);
-	typedef void (*SchedulerParametricTask)(void *);
-}
-
-class SchedulerClass {
-public:
-	SchedulerClass();
-	static void startLoop(SchedulerTask task, uint32_t stackSize = 1024);
-	static void start(SchedulerTask task, uint32_t stackSize = 1024);
-	static void start(SchedulerParametricTask task, void *data, uint32_t stackSize = 1024);
-
-	static void yield() { ::yield(); };
-};
-
-extern SchedulerClass Scheduler;
-
-#endif
-

+ 0 - 21
SE/stuff/P5_Automation-library-dev/SharpDistSensor/LICENSE

@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017-2018
-
-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.

+ 0 - 207
SE/stuff/P5_Automation-library-dev/SharpDistSensor/MedianFilter.cpp

@@ -1,207 +0,0 @@
-/*
-   MedianFilter.cpp - Median Filter for the Arduino platform.
-   Copyright (c) 2013 Phillip Schmidt.  All right reserved.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   This library 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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-/*
-    A median filter object is created by by passing the desired filter window size on object creation.
-   The window size should be an odd number between 3 and 255.
-
-   New data is added to the median filter by passing the data through the in() function.  The new medial value is returned.
-   The new data will over-write the oldest data point, then be shifted in the array to place it in the correct location.
-
-   The current median value is returned by the out() function for situations where the result is desired without passing in new data.
-
-   !!! All data must be type INT.  !!!
-
-   Window Size / avg processing time [us]
-   5  / 22
-   7  / 30
-   9  / 40
-   11 / 49
-   21 / 99
-
-*/
-
-#include "MedianFilter.h"
-
-
-MedianFilter::MedianFilter(int size, int seed)
-{
-   medFilterWin    = constrain(size, 3, 255); // number of samples in sliding median filter window - usually odd #
-   medDataPointer  = size >> 1;           // mid point of window
-   data            = (int*)     calloc (size, sizeof(int));     // array for data
-   sizeMap         = (uint8_t*) calloc (size, sizeof(uint8_t)); // array for locations of data in sorted list
-   locationMap     = (uint8_t*) calloc (size, sizeof(uint8_t)); // array for locations of history data in map list
-   oldestDataPoint = medDataPointer;      // oldest data point location in data array
-   totalSum        = size * seed;         // total of all values
-
-   for(uint8_t i = 0; i < medFilterWin; i++) // initialize the arrays
-   {
-      sizeMap[i]     = i;      // start map with straight run
-      locationMap[i] = i;      // start map with straight run
-      data[i]        = seed;   // populate with seed value
-   }
-}
-
-
-int MedianFilter::in(const int & value)
-{
-   // sort sizeMap
-   // small vaues on the left (-)
-   // larger values on the right (+)
-
-   boolean dataMoved = false;
-   const uint8_t rightEdge = medFilterWin - 1;  // adjusted for zero indexed array
-
-   totalSum += value - data[oldestDataPoint];  // add new value and remove oldest value
-
-   data[oldestDataPoint] = value;  // store new data in location of oldest data in ring buffer
-
-   // SORT LEFT (-) <======(n) (+)
-   if(locationMap[oldestDataPoint] > 0) // don't check left neighbours if at the extreme left
-   {
-      for(uint8_t i = locationMap[oldestDataPoint]; i > 0; i--)   //index through left adjacent data
-      {
-         uint8_t n = i - 1;   // neighbour location
-
-         if(data[oldestDataPoint] < data[sizeMap[n]]) // find insertion point, move old data into position
-         {
-            sizeMap[i] = sizeMap[n];   // move existing data right so the new data can go left
-            locationMap[sizeMap[n]]++;
-
-            sizeMap[n] = oldestDataPoint; // assign new data to neighbor position
-            locationMap[oldestDataPoint]--;
-
-            dataMoved = true;
-         }
-         else
-         {
-            break; // stop checking once a smaller value is found on the left
-         }
-      }
-   }
-
-   // SORT RIGHT (-) (n)======> (+)
-   if(!dataMoved && locationMap[oldestDataPoint] < rightEdge) // don't check right if at right border, or the data has already moved
-   {
-      for(int i = locationMap[oldestDataPoint]; i < rightEdge; i++)   //index through left adjacent data
-      {
-         int n = i + 1;   // neighbour location
-
-         if(data[oldestDataPoint] > data[sizeMap[n]]) // find insertion point, move old data into position
-         {
-            sizeMap[i] = sizeMap[n];   // move existing data left so the new data can go right
-            locationMap[sizeMap[n]]--;
-
-            sizeMap[n] = oldestDataPoint; // assign new data to neighbor position
-            locationMap[oldestDataPoint]++;
-         }
-         else
-         {
-            break; // stop checking once a smaller value is found on the right
-         }
-      }
-   }
-   oldestDataPoint++;       // increment and wrap
-   if(oldestDataPoint == medFilterWin) oldestDataPoint = 0;
-
-   return data[sizeMap[medDataPointer]];
-}
-
-
-int MedianFilter::out() // return the value of the median data sample
-{
-   return  data[sizeMap[medDataPointer]];
-}
-
-
-int MedianFilter::getMin()
-{
-   return data[sizeMap[ 0 ]];
-}
-
-
-int MedianFilter::getMax()
-{
-   return data[sizeMap[ medFilterWin - 1 ]];
-}
-
-
-int MedianFilter::getMean()
-{
-   return totalSum / medFilterWin;
-}
-
-
-int MedianFilter::getStDev()  // Arduino run time [us]: filterSize * 2 + 131
-{
-   int32_t diffSquareSum = 0;
-   int mean = getMean();
-
-   for( int i = 0; i < medFilterWin; i++ )
-   {
-      int diff = data[i] - mean;
-      diffSquareSum += diff * diff;
-   }
-
-   return int( sqrtf( float(diffSquareSum) / float(medFilterWin - 1) ) + 0.5f );
-}
-
-
-// *** debug fuctions ***
-/*
-void MedianFilter::printData() // display sorting data for debugging
-{
-   for(int i=0; i<medFilterWin; i++)
-   {
-      Serial.print(data[i]);
-      Serial.print("\t");
-   }
-   Serial.println("Data in ring buffer");
-}
-
-void MedianFilter::printSizeMap()
-{
-   for(int i=0; i<medFilterWin; i++)
-   {
-      Serial.print(sizeMap[i]);
-      Serial.print("\t");
-   }
-   Serial.println("Size Map, data sorted by size");
-}
-
-void MedianFilter::printLocationMap()
-{
-   for(int i=0; i<medFilterWin; i++)
-   {
-      Serial.print(locationMap[i]);
-      Serial.print("\t");
-   }
-   Serial.println("Location Map, size data sorted by age");
-}
-
-void MedianFilter::printSortedData() // display data for debugging
-{
-   for(int i=0; i<medFilterWin; i++)
-   {
-      Serial.print(data[sizeMap[i]]);
-      Serial.print("\t");
-   }
-   Serial.println("Data sorted by size");
-}
-*/

+ 0 - 67
SE/stuff/P5_Automation-library-dev/SharpDistSensor/MedianFilter.h

@@ -1,67 +0,0 @@
-/*
-  MedianFilter.h - Median Filter for the Arduino platform.
-  Copyright (c) 2013 Phillip Schmidt.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-/*
-   A median filter object is created by by passing the desired filter window size on object creation.
-   The window size should be an odd number between 3 and 255.
-
-   New data is added to the median filter by passing the data through the in() function.  The new medial value is returned.
-   The new data will over-write the oldest data point, then be shifted in the array to place it in the correct location.
-
-   The current median value is returned by the out() function for situations where the result is desired without passing in new data.
-
-   !!! All data must be type INT.  !!!
- */
-
-#ifndef MedianFilter_h
-
-   #define MedianFilter_h
-
-   #include "Arduino.h"
-
-   class MedianFilter
-   {
-      public:
-         MedianFilter(int size, int seed);
-         int in(const int & value);
-         int out();
-
-         int getMin();
-         int getMax();
-         int getMean();
-         int getStDev();
-
-         /*
-         void printData();		// used for debugging
-         void printSizeMap();
-         void printLocationMap();
-         void printSortedData();
-         */
-
-      private:
-         uint8_t medFilterWin;      // number of samples in sliding median filter window - usually odd #
-         uint8_t medDataPointer;	   // mid point of window
-         int     * data;			   // array pointer for data sorted by age in ring buffer
-         uint8_t * sizeMap;			// array pointer for locations data in sorted by size
-         uint8_t * locationMap;		// array pointer for data locations in history map
-         uint8_t oldestDataPoint;	// oldest data point location in ring buffer
-         int32_t totalSum;
-   };
-
-#endif

+ 0 - 100
SE/stuff/P5_Automation-library-dev/SharpDistSensor/README.md

@@ -1,100 +0,0 @@
-# SharpDistSensor
-A library for the Arduino IDE that helps interface with Sharp analog distance sensors.  
-
-Version 1.5.0  
-[![Build Status](https://travis-ci.org/DrGFreeman/SharpDistSensor.svg?branch=master)](https://travis-ci.org/DrGFreeman/SharpDistSensor)  
-By Julien de la Bruère-Terreault (drgfreeman@tuta.io)
-
-## Summary
-The analog value from the sensor is converted to distance using either a
-polynomial fit function up to fifth order or a power fit function.
-
-By default, this library is set to use polynomial coefficients calibrated for the Sharp GP2Y0A60SZLF Analog Distance Sensor 10-150cm 5V, over a range of 50-1500 mm (analog values 30-875). The returned distance is in millimeters (mm) units.  
-
-The library also allows the use of pre-defined calibrations for different sensor models as well as custom defined polynomial or power fit functions. Examples are provided showing how to use pre-defined calibrations or how to define custom fit functions.
-
-The distance output is filtered using real-time median filtering (sliding window of ajustable size). The MedianFilter class from the following library is used: https://github.com/daPhoosa/MedianFilter.
-
-## Examples
-Five example sketches are provided with the library:
-
-* _SharpDistSensorBasic.ino_  
-This example shows how to use the library with the default calibration function for the Sharp GP2Y0A60SZLF 5V sensor.
-
-* _SharpDistSensorByModel.ino_  
-This example shows how to use the library by selecting a pre-defined sensor
-model calibration.
-
-* _SharpDistSensorCustomPoly.ino_  
-This example shows how to use the library with a custom, user defined polynomial calibration function.
-
-* _SharpDistSensorCustomPower.ino_  
-This example shows how to use the library with a custom, user defined power calibration function.
-
-* _SharpDistSensorArray.ino_  
-This example shows how to use the library with an array of multiple sensors.
-
-## Library Reference
-* `SharpDistSensor(const byte pin, const byte size = 1)`  
-Constructor: `pin` is the analog pin to which the sensor is connected, `size` is the size of the median filter window and should be an odd positive integer (default = 1 = no filtering).  
-
-* `uint16_t getDist()`  
-Returns the measured distance. Distance units are in millimeters (mm) if using the library default settings or pre-defined sensor models. If using custom calibration, units depend on the calibration used.  
-
-* `void setModel(const byte model)`
-Sets the calibration based on pre-defined sensor model fit functions. Note that the model argument must be preceded by the SharpDistSensor namespace, i.e.: `setModel(SharpDistSensor::Model_Name)`
-
-* `void setPolyFitCoeffs(const byte nbCoeffs, const float* coeffs, const uint16_t valMin, const uint16_t valMax)`  
-Sets the polynomial fit function coefficients _C0_ to _C5_ in the relation:  
-_Distance = C0 + C1 * A + C2 * A^2 + ... + C5 * A^5_  
-where _A_ is the analog value read from the sensor. At least one coefficient must be provided and up to six maximum (5th order polynomial). `nbCoeffs` is the number of coefficients passed and `coeffs` a vector containing the coefficients (C0 to C5). `valMin` and `valMax` define the range of analog values for which the polynomial fit is valid. Analog values outside this range will be set to the respective min or max values.  
-
-* `void setPowerFitCoeffs(const float C, const float P, const uint16_t valMin, const uint16_t valMax)`  
-Sets the power fit function coefficients _C_ and _P_ in the relation:  
-_Distance = C * A^P_  
-where _A_ is the analog value read from the sensor. `valMin` and `valMax` define the range of analog values for which the power fit is valid. Analog values outside this range will be set to the respective min or max values.  
-
-* `void setValMinMax(const uint16_t valMin, const uint16_t valMax)`  
-Sets the range of analog values for which the polynomial or power fit is valid (`valMin` and `valMax`). Analog values outside this range will be set to the respective min or max values.
-
-## Pre-defined sensor models
-* `GP2Y0A60SZLF_5V`: GP2Y0A60SZLF Analog Distance Sensor 10-150cm, 5V, polynomial fit.
-* `GP2Y0A41SK0F_5V_DS`: GP2Y0A41SK0F Analog Distance Sensor 3-40cm, 5V (data sheet), polynomial fit.
-* `GP2Y0A51SK0F_5V_DS`: GP2Y0A51SK0F Analog Distance Sensor 2-15cm, 5V (data sheet), power fit.
-* `GP2Y0A710K0F_5V_DS`: GP2Y0A710K0F Analog Distance Sensor 100-500cm, 5V (data sheet), polynomial fit.
-
-#### Polynomial / Power fit coefficients:
-
-Model | Units | C0/C | C1/P | C2 | C3 | C4 | C5
-------|-------|----|----|----|----|----|----
-**GP2Y0A60SZLF_5V** | mm | 1734 | -9.005 | 2.032E-2 | -2.251E-5 | 1.167E-8 | -2.037E-12
-**GP2Y0A41SK0F_5V_DS** | mm | 761.9 | -8.13336 | 4.18857E-2 | -1.11338E-4 | 1.46237E-7 | -7.49656E-11
-**GP2Y0A51SK0F_5V_DS** | mm | 4.03576E+4 | -1.26093 | | | |
-**GP2Y0A710K0F_5V_DS** | mm | 178506 | -1607.72 | 5.5239 | -8.47601E-3 | 4.87819E-6 |
-
-#### Analog values range:
-
-Model | valMin | valMax
-------|--------|--------
-**GP2Y0A60SZLF_5V** | 30 | 875
-**GP2Y0A41SK0F_5V_DS** | 61 | 614
-**GP2Y0A51SK0F_5V_DS** | 70 | 500
-**GP2Y0A710K0F_5V_DS** | 284 | 507
-
-**Important Note:** The analog voltage returned by the sensor is largely dependent of the reflected object size and reflectivity. The distance returned by these pre-defined calibration functions can therefore vary significantly from the real distance depending on the object detected. Where accuracy is required by the application, it is recommended to perform calibration with the object to be detected and use custom calibration fit functions instead.
-
-This library has been designed so that it is easy to add sensor models. Contributions are therefore welcome. Adding models to the library can be done by either submitting a pull request or providing me the proposed fit function and associated calibration data by email so I can add it myself. Thank you for contributing!
-
-## Version history
-* 1.5.0 (2018-10-22): Added GP2Y0A41SK0F_5V_DS model.
-* 1.4.2 (2018-09-23): Improved comments in SharpDistSensorArray example.
-* 1.4.1 (2018-08-07): Updated MedianFilter to latest version from [daPhoosa/MedianFilter](https://github.com/daPhoosa/MedianFilter).
-* 1.4.0 (2018-05-21): Added GP2Y0A51SK0F_5V_DS model.
-* 1.3.0 (2018-05-20): Added SharpDistSensorArray example.
-* 1.2.0 (2017-05-10): Added GP2Y0A710K0F_5V_DS model.
-* 1.1.1 (2017-05-01): Clarified comments and fixed typos in examples, improved README.
-* 1.1.0 (2017-04-05): Added support of power fit functions.
-* 1.0.0 (2017-03-29): Initial major release for Arduino Library Manager (no change rel. to 0.3.2)
-* 0.3.2 (2017-03-29): Modified models enum and related type in setModel method arguments.
-* 0.3.1 (2017-03-28): Improved README and fixed comments in SharpDistSensorByModel example.
-* 0.3.0 (2017-03-24): Added method to set calibration based on pre-defined sensor models.

+ 0 - 167
SE/stuff/P5_Automation-library-dev/SharpDistSensor/SharpDistSensor.cpp

@@ -1,167 +0,0 @@
-/*
-SharpDistSensor.cpp
-Source: https://github.com/DrGFreeman/SharpDistSensor
-
-MIT License
-
-Copyright (c) 2018 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
-
-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.
-*/
-
-#include <SharpDistSensor.h>
-
-/* Constructor
-  pin:    Arduino analog pin the sensor is connected to
-  size: Window size of the median filter
-*/
-SharpDistSensor::SharpDistSensor(const byte pin, const byte size) :
-  medFilt(size, 1500)
-{
-  // Arduino analog pin the sensor is connected to
-  _pin = pin;
-
-  // Window size of the median filter (1 = no filtering)
-  _mfSize = size;
-
-  // Set default sensor model to GP2Y0A60SZLF 5V
-  setModel(GP2Y0A60SZLF_5V);
-}
-
-// Return the measured distance
-uint16_t SharpDistSensor::getDist()
-{
-  // Read analog value from sensor
-  uint16_t sensVal = analogRead(_pin);
-
-  // Constrain sensor values to remain within set min-max range
-  sensVal = constrain(sensVal, _valMin, _valMax);
-
-  uint16_t dist = 0;
-
-  if (_fitType == FIT_POLY)
-  {
-    // Calculate distance from polynomial fit function
-    dist += _polyCoeffs[5] * pow(sensVal, 5);
-    dist += _polyCoeffs[4] * pow(sensVal, 4);
-    dist += _polyCoeffs[3] * pow(sensVal, 3);
-    dist += _polyCoeffs[2] * pow(sensVal, 2);
-    dist += _polyCoeffs[1] * sensVal;
-    dist += _polyCoeffs[0];
-  }
-  else if (_fitType == FIT_POWER)
-  {
-    // Calculate distance from power fit function
-    dist = _powerCoeffC * pow(sensVal, _powerCoeffP);
-  }
-
-  if (_mfSize > 1)
-  {
-    // Get filtered distance value
-    dist = medFilt.in(dist);
-  }
-
-  return dist;
-}
-
-// Set the sensor model
-void SharpDistSensor::setModel(const models model)
-{
-  switch (model)
-  {
-    case GP2Y0A60SZLF_5V:
-    {
-      // Set coefficients and range for Sharp GP2Y0A60SZLF 5V
-      float coeffs[] = {1734, -9.005, 2.023E-2, -2.251E-5, 1.167E-8, -2.037E-12};
-      setPolyFitCoeffs(6, coeffs, 30, 875);
-      break;
-    }
-    case GP2Y0A710K0F_5V_DS:
-    {
-      // Set coefficients and range for Sharp GP2Y0A710K0F 5V
-      float coeffs[] = {178506, -1607.72, 5.5239, -8.47601E-3, 4.87819E-6};
-      setPolyFitCoeffs(5, coeffs, 284, 507);
-      break;
-    }
-    case GP2Y0A41SK0F_5V_DS:
-    {
-      // Set coefficients and range for Sharp GP2Y0A41SK0F 5V
-      float coeffs[] = {761.913, -8.13336, 4.18857E-02, -1.11338E-04, 1.46237E-07, -7.49656E-11};
-      setPolyFitCoeffs(6, coeffs, 61, 614);
-      break;
-    }
-    case GP2Y0A51SK0F_5V_DS:
-    {
-      // Set coefficients and range for Sharp GP2Y0A51SK0F 5V
-      setPowerFitCoeffs(4.03576E+4, -1.26093, 70, 500);
-      break;
-    }
-  }
-}
-
-// Set the polynomial fit function coefficients and range
-void SharpDistSensor::setPolyFitCoeffs(const byte nbCoeffs,
-  const float* coeffs, const uint16_t valMin, const uint16_t valMax)
-{
-  // Set fit type to FIT_POLY
-  _fitType = FIT_POLY;
-
-  // Set coefficients
-  for (byte i = 0; i < 6; i++)
-  {
-    if (i < nbCoeffs)
-    {
-      // Coefficient is provided
-      _polyCoeffs[i] = coeffs[i];
-    }
-    else
-    {
-      // Coefficient is not provided, set to zero
-      _polyCoeffs[i] = 0;
-    }
-  }
-
-  // Set analog value range
-  setValMinMax(valMin, valMax);
-}
-
-// Set the power fit function coefficients and range
-void SharpDistSensor::setPowerFitCoeffs(const float C, const float P,
-  const uint16_t valMin, const uint16_t valMax)
-{
-  // Set fit type to FIT_POWER
-  _fitType = FIT_POWER;
-
-  // Set power fit function coefficients
-  _powerCoeffC = C;
-  _powerCoeffP = P;
-
-  // Set analog value range
-  setValMinMax(valMin, valMax);
-}
-
-// Set the analog value range for which to return a distance
-void SharpDistSensor::setValMinMax(const uint16_t valMin, const uint16_t valMax)
-{
-    // Minimal analog value for which to return a distance
-    _valMin = valMin;
-
-    // Maximal analog value for which to return a distance
-    _valMax = valMax;
-}

+ 0 - 146
SE/stuff/P5_Automation-library-dev/SharpDistSensor/SharpDistSensor.h

@@ -1,146 +0,0 @@
-/*
-SharpDistSensor.h
-Source: https://github.com/DrGFreeman/SharpDistSensor
-
-MIT License
-
-Copyright (c) 2018 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
-
-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.
-*/
-
-/*
-SharpDistSensor; Sharp analog distance sensor library
-
-This is a library for the Arduino IDE that helps interface with Sharp IR analog
-distance sensors.
-
-The analog value from the sensor is converted to distance using either a fifth
-order polynomial fit function or a power fit function.
-
-By default, this library is set to use polynomial coefficients calibrated for
-the Sharp GP2Y0A60SZLF Analog Distance Sensor 10-150cm 5V, over a range of
-50-1500 mm (analog values 30-875). The returned distance is in millimeters (mm)
-units.  For different accuracy, range, sensor model or units, different
-coefficients may be required.
-
-Use the setModel method to change the sensor model calibration. The following
-models are currently supported:
--GP2Y0A60SZLF_5V (GP2Y0A60SZLF Analog Distance Sensor 10-150cm, 5V)
--GP2Y0A710K0F_5V_DS (GP2Y0A710K0F Analog Distance Sensor 100-500cm, 5V)
-
-Use the setPolyFitCoeffs method to define custom polynomial coefficients.
-
-Use the setPowerFitCoeffs method to define custom power coefficients.
-
-Use the setValMinMax method to define different analog values range.
-
-The distance output is filtered using median filtering. MedianFilter class from
-the following library is used: https://github.com/daPhoosa/MedianFilter.
-*/
-
-#ifndef SharpDistSensor_h
-#define SharpDistSensor_h
-
-#include <Arduino.h>
-#include <MedianFilter.h>
-
-class SharpDistSensor
-{
-public:
-  // List of pre-defined sensor models
-  enum models
-  {
-    // Constant for GP2Y0A60SZLF 5V model
-    GP2Y0A60SZLF_5V,
-    // Constant for GP2Y0A710K0F 5V model
-    GP2Y0A710K0F_5V_DS,
-    // Constant for GP2Y0A51SK0F 5V model
-    GP2Y0A51SK0F_5V_DS,
-    // Constant for GP2Y0A41SK0F 5V model
-    GP2Y0A41SK0F_5V_DS
-  };
-
-  /** Constructor
-    pin:    Arduino analog pin the sensor is connected to
-    size: Window size of the median filter (1 = no filtering)
-  **/
-  SharpDistSensor(const byte pin, const byte size = 1);
-
-  // Return the measured distance
-  uint16_t getDist();
-
-  // Set the sensor model
-  void setModel(const models model);
-
-  /* Set the polynomial fit function coefficients and range
-    nbCoeffs: Number of coefficients (1 min, 6 max)
-    coeffs:   Coefficients (x^0 to x^5)
-    valMin: Minimal analog value for which to return a distance
-    valMax: Maximal analog value for which to return a distance
-  */
-  void setPolyFitCoeffs(const byte nbCoeffs, const float* coeffs,
-    const uint16_t valMin, const uint16_t valMax);
-
-  /* Set the power fit function coefficients and range
-    C and P: Coefficients in Distance = C*x^P relation
-    valMin: Minimal analog value for which to return a distance
-    valMax: Maximal analog value for which to return a distance
-  */
-  void setPowerFitCoeffs(const float C, const float P,
-    const uint16_t valMin, const uint16_t valMax);
-
-  // Set the analog value range for which to return a distance
-  void setValMinMax(const uint16_t valMin, const uint16_t valMax);
-
-private:
-  // Arduino analog pin the sensor is connected to
-  byte _pin;
-
-  // Window size of the median filter (1 = no filtering)
-  byte _mfSize;
-
-  // Minimal analog value for which to return a distance
-  uint16_t _valMin;
-
-  // Maximal analog value for which to return a distance
-  uint16_t _valMax;
-
-  // Polynomial function coefficients to convert analog signal to distance
-  float _polyCoeffs[6];
-
-  // Power function coefficients to convert analog signal to distance
-  float _powerCoeffC;
-  float _powerCoeffP;
-
-  // Possible types of fit functions
-  enum fitTypes
-  {
-    FIT_POLY,
-    FIT_POWER
-  };
-
-  // Fit function type used
-  fitTypes _fitType;
-
-  // Median filter object instance
-  MedianFilter medFilt;
-};
-
-#endif

+ 0 - 75
SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorArray/SharpDistSensorArray.ino

@@ -1,75 +0,0 @@
-/*
-SharpDistSensorArray.ino
-
-Source: https://github.com/DrGFreeman/SharpDistSensor
-
-MIT License
-
-Copyright (c) 2018 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
-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.
-*/
-
-/*
-This example shows how to use the SharpDistSensor library with an array of
-multiple sensors.
-
-See the library README for how to use pre-defined sensor models or  custom fit
-functions.
-*/
-
-#include <SharpDistSensor.h>
-
-// Define the number of sensors in the array as a constant
-const byte nbSensors = 2;
-
-// Window size of the median filter (odd number, 1 = no filtering)
-const byte medianFilterWindowSize = 5;
-
-// Define the array of SharpDistSensor objects
-SharpDistSensor sensorArray[] = {
-  SharpDistSensor(A1, medianFilterWindowSize), // First sensor using pin A1
-  SharpDistSensor(A2, medianFilterWindowSize), // Second sensor using pin A2
-  // Add as many sensors as required
-};
-
-// Alternatively, the array can be defined this way
-// SharpDistSensor sensorArray[nbSensors] = {{A1, medianFilterWindowSize},
-//                                           {A2, medianFilterWindowSize}};
-
-// Define an array of integers that will store the measured distances
-uint16_t distArray[nbSensors];
-
-void setup() {
-  // Set some parameters for each sensor in array
-  for (byte i = 0; i < nbSensors; i++) {
-    sensorArray[i].setModel(SharpDistSensor::GP2Y0A710K0F_5V_DS);  // Set sensor model
-    // Set other parameters as required
-  }
-}
-
-void loop() {
-  // Read distance for each sensor in array into an array of distances
-  for (byte i = 0; i < nbSensors; i++) {
-    distArray[i] = sensorArray[i].getDist();
-  }
-
-  // The measured distances can now be accessed through the different indices of the
-  // distArray array, i.e. distArray[0] for the first sensor, distArray[1] for the
-  // sencond sensor ...
-}

+ 0 - 64
SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorBasic/SharpDistSensorBasic.ino

@@ -1,64 +0,0 @@
-/*
-SharpDistSensorBasic.ino
-Source: https://github.com/DrGFreeman/SharpDistSensor
-
-MIT License
-
-Copyright (c) 2017 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
-
-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.
-*/
-
-/*
-This example shows how to use the SharpDistSensor library to continuously
-read the sensor and display the measured distance in mm to the serial monitor.
-
-The library default values corresponding to the Sharp GP2Y0A60SZLF 5V sensor
-are used.
-
-See the library README for how to use pre-defined sensor models or custom
-fit functions.
-*/
-
-#include <SharpDistSensor.h>
-
-// Analog pin to which the sensor is connected
-const byte sensorPin = A0;
-
-// Window size of the median filter (odd number, 1 = no filtering)
-const byte medianFilterWindowSize = 5;
-
-// Create an object instance of the SharpDistSensor class
-SharpDistSensor sensor(sensorPin, medianFilterWindowSize);
-
-
-void setup() {
-  Serial.begin(9600);
-}
-
-void loop() {
-  // Get distance from sensor
-  unsigned int distance = sensor.getDist();
-
-  // Print distance to Serial
-  Serial.println(distance);
-
-  // Wait some time
-  delay(50);
-}

+ 0 - 62
SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorByModel/SharpDistSensorByModel.ino

@@ -1,62 +0,0 @@
-/*
-SharpDistSensorBasic.ino
-Source: https://github.com/DrGFreeman/SharpDistSensor
-
-MIT License
-
-Copyright (c) 2017 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
-
-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.
-*/
-
-/*
-This example shows how to use the SharpDistSensor library to continuously
-read the sensor and display the distance in mm using a pre-defined sensor model.
-See the library README page for the list of available models and corresponding
-constants or for how to use custom defined fit functions.
-*/
-
-#include <SharpDistSensor.h>
-
-// Analog pin to which the sensor is connected
-const byte sensorPin = A0;
-
-// Window size of the median filter (odd number, 1 = no filtering)
-const byte medianFilterWindowSize = 5;
-
-// Create an object instance of the SharpDistSensor class
-SharpDistSensor sensor(sensorPin, medianFilterWindowSize);
-
-void setup() {
-  Serial.begin(9600);
-
-  // Set sensor model
-  sensor.setModel(SharpDistSensor::GP2Y0A710K0F_5V_DS);
-}
-
-void loop() {
-  // Get distance from sensor
-  unsigned int distance = sensor.getDist();
-
-  // Print distance to Serial
-  Serial.println(distance);
-
-  // Wait some time
-  delay(50);
-}

+ 0 - 89
SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorCustomPoly/SharpDistSensorCustomPoly.ino

@@ -1,89 +0,0 @@
-/*
-SharpDistSensorCustomPoly.ino
-Source: https://github.com/DrGFreeman/SharpDistSensor
-
-MIT License
-
-Copyright (c) 2017 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
-
-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.
-*/
-
-/*
-This example shows how to use the SharpDistSensor library to continuously
-read the sensor and display the analog value and the corresponding distance
-using custom polynomial fit curve and range.
-
-The same values as the library default values for the Sharp GP2Y0A60SZLF 5V
-sensor are used for example purpose, however different values may be used
-for different sensors, units, calibration or range.
-*/
-
-#include <SharpDistSensor.h>
-
-// Analog pin to which the sensor is connected
-const byte sensorPin = A0;
-
-// Window size of the median filter (odd number, 1 = no filtering)
-const byte medianFilterWindowSize = 5;
-
-// Create an object instance of the SharpDistSensor class
-SharpDistSensor sensor(sensorPin, medianFilterWindowSize);
-
-/*
- * Polynomial fit curve coefficients C0 to C5 in relation:
- * Distance = C0 + C1*A + C2*A^2 + ... + C5*A^5
- * where A is the analog value read from the sensor
- * One coefficient minimum, six maximum (5th order polynomial)
- */
-const float polyCoefficients[] = {1734, -9.005, 2.023E-2, -2.251E-5, 1.167E-8, -2.037E-12};
-const byte nbCoefficients = 6;  // Number of coefficients
-
-/*
- * Minimum and maximum analog values for which to return a distance
- * These should represent a range of analog values within which the
- * polynomial fit curve is valid.
- */
-const unsigned int minVal = 134; // ~800 mm
-const unsigned int maxVal = 875; // ~50mm
-
-void setup() {
-  Serial.begin(9600);
-
-  // Set custom polynomial fit curve coefficients and range
-  sensor.setPolyFitCoeffs(nbCoefficients, polyCoefficients, minVal, maxVal);
-}
-
-void loop() {
-  /* Print raw analog value. This step is not required to read the sensor,
-     it is included here to show the relation between the raw analog value
-     and the returned distance. */
-  Serial.print(analogRead(sensorPin));
-
-  Serial.print(", ");
-
-  // Get distance from sensor
-  unsigned int distance = sensor.getDist();
-
-  // Print distance to Serial
-  Serial.println(distance);
-
-  // Wait some time
-  delay(50);
-}

+ 0 - 83
SE/stuff/P5_Automation-library-dev/SharpDistSensor/examples/SharpDistSensorCustomPower/SharpDistSensorCustomPower.ino

@@ -1,83 +0,0 @@
-/*
-SharpDistSensorCustomPower.ino
-Source: https://github.com/DrGFreeman/SharpDistSensor
-
-MIT License
-
-Copyright (c) 2017 Julien de la Bruere-Terreault <drgfreeman@tuta.io>
-
-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.
-*/
-
-/*
-This example shows how to use the SharpDistSensor library to continuously
-read the sensor and display the analog value and the corresponding distance
-using custom power fit curve and range.
-*/
-
-#include <SharpDistSensor.h>
-
-// Analog pin to which the sensor is connected
-const byte sensorPin = A0;
-
-// Window size of the median filter (odd number, 1 = no filtering)
-const byte medianFilterWindowSize = 5;
-
-// Create an object instance of the SharpDistSensor class
-SharpDistSensor sensor(sensorPin, medianFilterWindowSize);
-
-/* Set the power fit curve coefficients and range
- * C and P: Coefficients in Distance = C*A^P relation
- * where A is the analog value read from the sensor.
- */
-const float C = 90373.;
-const float P = -1.027;
-
-/*
- * Minimum and maximum analog values for which to return a distance
- * These should represent a range of analog values within which the
- * power fit curve is valid.
- */
-const unsigned int minVal = 134; // ~800 mm
-const unsigned int maxVal = 875; // ~50mm
-
-void setup() {
-  Serial.begin(9600);
-
-  // Set custom power fit curve coefficients and range
-  sensor.setPowerFitCoeffs(C, P, minVal, maxVal);
-}
-
-void loop() {
-  /* Print raw analog value. This step is not required to read the sensor,
-     it is included here to show the relation between the raw analog value
-     and the returned distance. */
-  Serial.print(analogRead(sensorPin));
-
-  Serial.print(", ");
-
-  // Get distance from sensor
-  unsigned int distance = sensor.getDist();
-
-  // Print distance to Serial
-  Serial.println(distance);
-
-  // Wait some time
-  delay(50);
-}

+ 0 - 10
SE/stuff/P5_Automation-library-dev/SharpDistSensor/keywords.txt

@@ -1,10 +0,0 @@
-SharpDistSensor	KEYWORD1
-getDist	KEYWORD2
-setModel	KEYWORD2
-setPolyFitCoeffs	KEYWORD2
-setPowerFitCoeffs	KEYWORD2
-setValMinMax	KEYWORD2
-GP2Y0A60SZLF_5V	LITERAL1
-GP2Y0A41SK0F_5V_DS	LITERAL1
-GP2Y0A51SK0F_5V_DS	LITERAL1
-GP2Y0A710K0F_5V_DS	LITERAL1

+ 0 - 9
SE/stuff/P5_Automation-library-dev/SharpDistSensor/library.properties

@@ -1,9 +0,0 @@
-name=SharpDistSensor
-version=1.5.0
-author=Julien de la Bruere-Terreault, drgfreeman@tuta.io
-maintainer=Julien de la Bruere-Terreault, drgfreeman@tuta.io
-sentence=Sharp analog distance sensor library
-paragraph=This is a library for the Arduino IDE that helps interface with Sharp IR analog distance sensors. It supports polynomial and power fit functions as well as real-time median filtering (sliding window of ajustable size).
-category=Sensors
-url=https://github.com/DrGFreeman/SharpDistSensor
-architectures=*

+ 0 - 55
SE/stuff/P5_Automation-library-dev/SharpIR/CHANGELOG.md

@@ -1,55 +0,0 @@
-# Change Log  
-All notable changes to this project will be documented in this file.  
-
-The format is based on [Keep a Changelog](http://keepachangelog.com/)  
-and this project adheres to [Semantic Versioning](http://semver.org/).  
-
-[![Keep a Changelog specification badge](https://img.shields.io/badge/Keep%20a%20Changelog%20Specification-1.0.0-orange.svg)](http://keepachangelog.com)
-[![Semantic Versioning specification badge](https://img.shields.io/badge/Semantic%20Versioning%20Specification-2.0.0-orange.svg)](http://semver.org)
-
-## [2.0.1] - 2018-07-20 ##
-## Fixed ##
-
-- Keyword highlighting for Arduino IDE
-
-## [2.0.0] - 2018-04-07 ##
-### Changed ###
-- Now sensor models have to be specified in the format SharpIR::model , this allow to generate a compile error if an invalid model is specified  
-- Updated library properties  
-
-### Fixed ##
-- A typo for the GP2Y0A41SK0F sensor model  
-- Fixed compile error for ESP8266 and potentially other platforms  
-
-## [1.1.0] - 2017-03-14 ##
-### Added  ###
-- Support for burst reads  
-
-### Changed ###
-- This changelog format is now based on [Keep a Changelog](http://keepachangelog.com/)  
-- Rewrote the changelog to accomplish what about the previous point  
-- Renamed the file of the changelog for the same purpose  
-- Updated README.md  
-
-## [1.0.3] - 2017-01-02 ##
-### Changed ###
-- Fixed a warning about the **getDistance()** method  
-
-## [1.0.2] - 2016-09-11 ##
-### Changed ###
-- Reduced memory use  
-
-### Fixed ###
-- (*Issue #1*) A bug that prevented the creation of the library instances  
-- The keyword highlight in the Arduino IDE  
-
-## [1.0.1] - 2016-08-25 - [YANKED] ##
-### Changed ###
-- Reduced memory use
-- Minor grammatical corrections in **"examples/getDistance.ino"**  
-- Changed the repository URL in **"library.properties"**  
-- Completely rewrote **README.md**  
-
-## [1.0.0] - 2016-08-25 ##
-### Added ###
-- Unreleased library files  

+ 0 - 427
SE/stuff/P5_Automation-library-dev/SharpIR/LICENSE.md

@@ -1,427 +0,0 @@
-Attribution-ShareAlike 4.0 International
-
-=======================================================================
-
-Creative Commons Corporation ("Creative Commons") is not a law firm and
-does not provide legal services or legal advice. Distribution of
-Creative Commons public licenses does not create a lawyer-client or
-other relationship. Creative Commons makes its licenses and related
-information available on an "as-is" basis. Creative Commons gives no
-warranties regarding its licenses, any material licensed under their
-terms and conditions, or any related information. Creative Commons
-disclaims all liability for damages resulting from their use to the
-fullest extent possible.
-
-Using Creative Commons Public Licenses
-
-Creative Commons public licenses provide a standard set of terms and
-conditions that creators and other rights holders may use to share
-original works of authorship and other material subject to copyright
-and certain other rights specified in the public license below. The
-following considerations are for informational purposes only, are not
-exhaustive, and do not form part of our licenses.
-
-     Considerations for licensors: Our public licenses are
-     intended for use by those authorized to give the public
-     permission to use material in ways otherwise restricted by
-     copyright and certain other rights. Our licenses are
-     irrevocable. Licensors should read and understand the terms
-     and conditions of the license they choose before applying it.
-     Licensors should also secure all rights necessary before
-     applying our licenses so that the public can reuse the
-     material as expected. Licensors should clearly mark any
-     material not subject to the license. This includes other CC-
-     licensed material, or material used under an exception or
-     limitation to copyright. More considerations for licensors:
-	wiki.creativecommons.org/Considerations_for_licensors
-
-     Considerations for the public: By using one of our public
-     licenses, a licensor grants the public permission to use the
-     licensed material under specified terms and conditions. If
-     the licensor's permission is not necessary for any reason--for
-     example, because of any applicable exception or limitation to
-     copyright--then that use is not regulated by the license. Our
-     licenses grant only permissions under copyright and certain
-     other rights that a licensor has authority to grant. Use of
-     the licensed material may still be restricted for other
-     reasons, including because others have copyright or other
-     rights in the material. A licensor may make special requests,
-     such as asking that all changes be marked or described.
-     Although not required by our licenses, you are encouraged to
-     respect those requests where reasonable. More_considerations
-     for the public: 
-	wiki.creativecommons.org/Considerations_for_licensees
-
-=======================================================================
-
-Creative Commons Attribution-ShareAlike 4.0 International Public
-License
-
-By exercising the Licensed Rights (defined below), You accept and agree
-to be bound by the terms and conditions of this Creative Commons
-Attribution-ShareAlike 4.0 International Public License ("Public
-License"). To the extent this Public License may be interpreted as a
-contract, You are granted the Licensed Rights in consideration of Your
-acceptance of these terms and conditions, and the Licensor grants You
-such rights in consideration of benefits the Licensor receives from
-making the Licensed Material available under these terms and
-conditions.
-
-
-Section 1 -- Definitions.
-
-  a. Adapted Material means material subject to Copyright and Similar
-     Rights that is derived from or based upon the Licensed Material
-     and in which the Licensed Material is translated, altered,
-     arranged, transformed, or otherwise modified in a manner requiring
-     permission under the Copyright and Similar Rights held by the
-     Licensor. For purposes of this Public License, where the Licensed
-     Material is a musical work, performance, or sound recording,
-     Adapted Material is always produced where the Licensed Material is
-     synched in timed relation with a moving image.
-
-  b. Adapter's License means the license You apply to Your Copyright
-     and Similar Rights in Your contributions to Adapted Material in
-     accordance with the terms and conditions of this Public License.
-
-  c. BY-SA Compatible License means a license listed at
-     creativecommons.org/compatiblelicenses, approved by Creative
-     Commons as essentially the equivalent of this Public License.
-
-  d. Copyright and Similar Rights means copyright and/or similar rights
-     closely related to copyright including, without limitation,
-     performance, broadcast, sound recording, and Sui Generis Database
-     Rights, without regard to how the rights are labeled or
-     categorized. For purposes of this Public License, the rights
-     specified in Section 2(b)(1)-(2) are not Copyright and Similar
-     Rights.
-
-  e. Effective Technological Measures means those measures that, in the
-     absence of proper authority, may not be circumvented under laws
-     fulfilling obligations under Article 11 of the WIPO Copyright
-     Treaty adopted on December 20, 1996, and/or similar international
-     agreements.
-
-  f. Exceptions and Limitations means fair use, fair dealing, and/or
-     any other exception or limitation to Copyright and Similar Rights
-     that applies to Your use of the Licensed Material.
-
-  g. License Elements means the license attributes listed in the name
-     of a Creative Commons Public License. The License Elements of this
-     Public License are Attribution and ShareAlike.
-
-  h. Licensed Material means the artistic or literary work, database,
-     or other material to which the Licensor applied this Public
-     License.
-
-  i. Licensed Rights means the rights granted to You subject to the
-     terms and conditions of this Public License, which are limited to
-     all Copyright and Similar Rights that apply to Your use of the
-     Licensed Material and that the Licensor has authority to license.
-
-  j. Licensor means the individual(s) or entity(ies) granting rights
-     under this Public License.
-
-  k. Share means to provide material to the public by any means or
-     process that requires permission under the Licensed Rights, such
-     as reproduction, public display, public performance, distribution,
-     dissemination, communication, or importation, and to make material
-     available to the public including in ways that members of the
-     public may access the material from a place and at a time
-     individually chosen by them.
-
-  l. Sui Generis Database Rights means rights other than copyright
-     resulting from Directive 96/9/EC of the European Parliament and of
-     the Council of 11 March 1996 on the legal protection of databases,
-     as amended and/or succeeded, as well as other essentially
-     equivalent rights anywhere in the world.
-
-  m. You means the individual or entity exercising the Licensed Rights
-     under this Public License. Your has a corresponding meaning.
-
-
-Section 2 -- Scope.
-
-  a. License grant.
-
-       1. Subject to the terms and conditions of this Public License,
-          the Licensor hereby grants You a worldwide, royalty-free,
-          non-sublicensable, non-exclusive, irrevocable license to
-          exercise the Licensed Rights in the Licensed Material to:
-
-            a. reproduce and Share the Licensed Material, in whole or
-               in part; and
-
-            b. produce, reproduce, and Share Adapted Material.
-
-       2. Exceptions and Limitations. For the avoidance of doubt, where
-          Exceptions and Limitations apply to Your use, this Public
-          License does not apply, and You do not need to comply with
-          its terms and conditions.
-
-       3. Term. The term of this Public License is specified in Section
-          6(a).
-
-       4. Media and formats; technical modifications allowed. The
-          Licensor authorizes You to exercise the Licensed Rights in
-          all media and formats whether now known or hereafter created,
-          and to make technical modifications necessary to do so. The
-          Licensor waives and/or agrees not to assert any right or
-          authority to forbid You from making technical modifications
-          necessary to exercise the Licensed Rights, including
-          technical modifications necessary to circumvent Effective
-          Technological Measures. For purposes of this Public License,
-          simply making modifications authorized by this Section 2(a)
-          (4) never produces Adapted Material.
-
-       5. Downstream recipients.
-
-            a. Offer from the Licensor -- Licensed Material. Every
-               recipient of the Licensed Material automatically
-               receives an offer from the Licensor to exercise the
-               Licensed Rights under the terms and conditions of this
-               Public License.
-
-            b. Additional offer from the Licensor -- Adapted Material.
-               Every recipient of Adapted Material from You
-               automatically receives an offer from the Licensor to
-               exercise the Licensed Rights in the Adapted Material
-               under the conditions of the Adapter's License You apply.
-
-            c. No downstream restrictions. You may not offer or impose
-               any additional or different terms or conditions on, or
-               apply any Effective Technological Measures to, the
-               Licensed Material if doing so restricts exercise of the
-               Licensed Rights by any recipient of the Licensed
-               Material.
-
-       6. No endorsement. Nothing in this Public License constitutes or
-          may be construed as permission to assert or imply that You
-          are, or that Your use of the Licensed Material is, connected
-          with, or sponsored, endorsed, or granted official status by,
-          the Licensor or others designated to receive attribution as
-          provided in Section 3(a)(1)(A)(i).
-
-  b. Other rights.
-
-       1. Moral rights, such as the right of integrity, are not
-          licensed under this Public License, nor are publicity,
-          privacy, and/or other similar personality rights; however, to
-          the extent possible, the Licensor waives and/or agrees not to
-          assert any such rights held by the Licensor to the limited
-          extent necessary to allow You to exercise the Licensed
-          Rights, but not otherwise.
-
-       2. Patent and trademark rights are not licensed under this
-          Public License.
-
-       3. To the extent possible, the Licensor waives any right to
-          collect royalties from You for the exercise of the Licensed
-          Rights, whether directly or through a collecting society
-          under any voluntary or waivable statutory or compulsory
-          licensing scheme. In all other cases the Licensor expressly
-          reserves any right to collect such royalties.
-
-
-Section 3 -- License Conditions.
-
-Your exercise of the Licensed Rights is expressly made subject to the
-following conditions.
-
-  a. Attribution.
-
-       1. If You Share the Licensed Material (including in modified
-          form), You must:
-
-            a. retain the following if it is supplied by the Licensor
-               with the Licensed Material:
-
-                 i. identification of the creator(s) of the Licensed
-                    Material and any others designated to receive
-                    attribution, in any reasonable manner requested by
-                    the Licensor (including by pseudonym if
-                    designated);
-
-                ii. a copyright notice;
-
-               iii. a notice that refers to this Public License;
-
-                iv. a notice that refers to the disclaimer of
-                    warranties;
-
-                 v. a URI or hyperlink to the Licensed Material to the
-                    extent reasonably practicable;
-
-            b. indicate if You modified the Licensed Material and
-               retain an indication of any previous modifications; and
-
-            c. indicate the Licensed Material is licensed under this
-               Public License, and include the text of, or the URI or
-               hyperlink to, this Public License.
-
-       2. You may satisfy the conditions in Section 3(a)(1) in any
-          reasonable manner based on the medium, means, and context in
-          which You Share the Licensed Material. For example, it may be
-          reasonable to satisfy the conditions by providing a URI or
-          hyperlink to a resource that includes the required
-          information.
-
-       3. If requested by the Licensor, You must remove any of the
-          information required by Section 3(a)(1)(A) to the extent
-          reasonably practicable.
-
-  b. ShareAlike.
-
-     In addition to the conditions in Section 3(a), if You Share
-     Adapted Material You produce, the following conditions also apply.
-
-       1. The Adapter's License You apply must be a Creative Commons
-          license with the same License Elements, this version or
-          later, or a BY-SA Compatible License.
-
-       2. You must include the text of, or the URI or hyperlink to, the
-          Adapter's License You apply. You may satisfy this condition
-          in any reasonable manner based on the medium, means, and
-          context in which You Share Adapted Material.
-
-       3. You may not offer or impose any additional or different terms
-          or conditions on, or apply any Effective Technological
-          Measures to, Adapted Material that restrict exercise of the
-          rights granted under the Adapter's License You apply.
-
-
-Section 4 -- Sui Generis Database Rights.
-
-Where the Licensed Rights include Sui Generis Database Rights that
-apply to Your use of the Licensed Material:
-
-  a. for the avoidance of doubt, Section 2(a)(1) grants You the right
-     to extract, reuse, reproduce, and Share all or a substantial
-     portion of the contents of the database;
-
-  b. if You include all or a substantial portion of the database
-     contents in a database in which You have Sui Generis Database
-     Rights, then the database in which You have Sui Generis Database
-     Rights (but not its individual contents) is Adapted Material,
-
-     including for purposes of Section 3(b); and
-  c. You must comply with the conditions in Section 3(a) if You Share
-     all or a substantial portion of the contents of the database.
-
-For the avoidance of doubt, this Section 4 supplements and does not
-replace Your obligations under this Public License where the Licensed
-Rights include other Copyright and Similar Rights.
-
-
-Section 5 -- Disclaimer of Warranties and Limitation of Liability.
-
-  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
-     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
-     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
-     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
-     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
-     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
-     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
-     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
-     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
-     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
-
-  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
-     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
-     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
-     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
-     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
-     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
-     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
-     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
-     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
-
-  c. The disclaimer of warranties and limitation of liability provided
-     above shall be interpreted in a manner that, to the extent
-     possible, most closely approximates an absolute disclaimer and
-     waiver of all liability.
-
-
-Section 6 -- Term and Termination.
-
-  a. This Public License applies for the term of the Copyright and
-     Similar Rights licensed here. However, if You fail to comply with
-     this Public License, then Your rights under this Public License
-     terminate automatically.
-
-  b. Where Your right to use the Licensed Material has terminated under
-     Section 6(a), it reinstates:
-
-       1. automatically as of the date the violation is cured, provided
-          it is cured within 30 days of Your discovery of the
-          violation; or
-
-       2. upon express reinstatement by the Licensor.
-
-     For the avoidance of doubt, this Section 6(b) does not affect any
-     right the Licensor may have to seek remedies for Your violations
-     of this Public License.
-
-  c. For the avoidance of doubt, the Licensor may also offer the
-     Licensed Material under separate terms or conditions or stop
-     distributing the Licensed Material at any time; however, doing so
-     will not terminate this Public License.
-
-  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
-     License.
-
-
-Section 7 -- Other Terms and Conditions.
-
-  a. The Licensor shall not be bound by any additional or different
-     terms or conditions communicated by You unless expressly agreed.
-
-  b. Any arrangements, understandings, or agreements regarding the
-     Licensed Material not stated herein are separate from and
-     independent of the terms and conditions of this Public License.
-
-
-Section 8 -- Interpretation.
-
-  a. For the avoidance of doubt, this Public License does not, and
-     shall not be interpreted to, reduce, limit, restrict, or impose
-     conditions on any use of the Licensed Material that could lawfully
-     be made without permission under this Public License.
-
-  b. To the extent possible, if any provision of this Public License is
-     deemed unenforceable, it shall be automatically reformed to the
-     minimum extent necessary to make it enforceable. If the provision
-     cannot be reformed, it shall be severed from this Public License
-     without affecting the enforceability of the remaining terms and
-     conditions.
-
-  c. No term or condition of this Public License will be waived and no
-     failure to comply consented to unless expressly agreed to by the
-     Licensor.
-
-  d. Nothing in this Public License constitutes or may be interpreted
-     as a limitation upon, or waiver of, any privileges and immunities
-     that apply to the Licensor or You, including from the legal
-     processes of any jurisdiction or authority.
-
-
-=======================================================================
-
-Creative Commons is not a party to its public
-licenses. Notwithstanding, Creative Commons may elect to apply one of
-its public licenses to material it publishes and in those instances
-will be considered the “Licensor.” The text of the Creative Commons
-public licenses is dedicated to the public domain under the CC0 Public
-Domain Dedication. Except for the limited purpose of indicating that
-material is shared under a Creative Commons public license or as
-otherwise permitted by the Creative Commons policies published at
-creativecommons.org/policies, Creative Commons does not authorize the
-use of the trademark "Creative Commons" or any other trademark or logo
-of Creative Commons without its prior written consent including,
-without limitation, in connection with any unauthorized modifications
-to any of its public licenses or any other arrangements,
-understandings, or agreements concerning use of licensed material. For
-the avoidance of doubt, this paragraph does not form part of the
-public licenses.
-
-Creative Commons may be contacted at creativecommons.org.

+ 0 - 70
SE/stuff/P5_Automation-library-dev/SharpIR/README.md

@@ -1,70 +0,0 @@
-# SharpIR
-An Arduino library that allows to acquire distance data from a Sharp analog distance sensor
-
-![Project status badge](https://img.shields.io/badge/Project%20status-ACTIVE-brightgreen.svg)
-[![License badge](https://img.shields.io/badge/license-custom%20CC%20BY--SA%204.0-brightgreen.svg)](https://github.com/qub1750ul/Arduino_L293/blob/master/LICENSE.md)  
-[![Arduino Library specification badge](https://img.shields.io/badge/Arduino%20Library%20Specification%20-rev.%202.1-blue.svg)](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification)
-[![Arduino IDE compatibility badge](https://img.shields.io/badge/Arduino%20IDE%20compatibility-1.6.10+-blue.svg)](https://www.arduino.cc/en/Main/Software)  
-[![Keep a Changelog specification badge](https://img.shields.io/badge/Keep%20a%20Changelog%20Specification-1.0.0-orange.svg)](http://keepachangelog.com)
-[![Semantic Versioning specification badge](https://img.shields.io/badge/Semantic%20Versioning%20Specification-2.0.0-orange.svg)](http://semver.org)
-
-## Currently supported sensor models
-
-- GP2Y0A41SK0F  
-- GP2Y0A21YK0F  
-- GP2Y0A02YK0F  
-
-## Usage
-
-- Adding the library to the sketch
-
-~~~c++
-#include <SharpIR.h>
-~~~
-
-- Creating an istance  
-
-~~~c++
-SharpIR sensorName(sensorModel, sensorPin);
-~~~
-~~~
-sensorName	: the name of the object   
-sensorModel	: the model code of the sensor (e.g. GP2YA41SK0F)  
-sensorPin	: the analog pin where the sensor Vout pin is attached  
-~~~    
-
-- Acquiring data
-
-~~~c++
-sensorName.getDistance();
-sensorName.getDistance( avoidBurstRead );
-~~~
-~~~
-avoidBurstRead	: can be true or false
-~~~
-
-The above method returns an uint8_t type value that is the distance in centimeters from the sensor and the object in front of it.  
-By default burst reads are avoided but this causes a delay of 20ms on every call.
-In order to speed up the sketch is possible to allow bust reads by setting the parameter **avoidBurstRead** to **false**, in this way:
-
-~~~c++
-sensorName.getDistance( false );
-~~~
-
-## License ##
-<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
-<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" />
-</a>
-<br />
-<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">The SharpIR Library</span>
-by <a xmlns:cc="http://creativecommons.org/ns#" href="https://facebook.com/dev.giuseppemasino" property="cc:attributionName" rel="cc:attributionURL">Giuseppe Masino </a>
-is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>
-
-If you need permissions that are beyond the scope of this license, you can ask me through this contacts,
-in order of preference:  
-
-- Telegram : <a xmlns:cc="http://creativecommons.org/ns#" href="https://telegram.me/qub1750ul" rel="cc:morePermissions">https://telegram.me/qub1750ul</a>
-- Twitter : <a xmlns:cc="http://creativecommons.org/ns#" href="https://telegram.me/qub1750ul" rel="cc:morePermissions">https://twitter.com/qub1750ul</a>
-- Facebook page : <a xmlns:cc="http://creativecommons.org/ns#" href="https://facebook.com/dev.giuseppemasino/" rel="cc:morePermissions">https://facebook.com/dev.giuseppemasino/</a>
-
-The license text can be found in the LICENSE.md file

+ 0 - 47
SE/stuff/P5_Automation-library-dev/SharpIR/examples/getDistance/getDistance.ino

@@ -1,47 +0,0 @@
-/*
- * getDistance
- *
- * Example of using SharpIR library to calculate the distance beetween the sensor and an obstacle
- *
- * Created by Giuseppe Masino, 15 June 2016
- *
- * -----------------------------------------------------------------------------------
- *
- * Things that you need:
- * - Arduino
- * - A Sharp IR Sensor
- *
- *
- * The circuit:
- * - Arduino 5V -> Sensor's pin 1 (Vcc)
- * - Arduino GND -> Sensor's pin 2 (GND)
- * - Arduino pin A0 -> Sensor's pin 3 (Output)
- *
- *
- * See the Sharp sensor datasheet for the pin reference, the pin configuration is the same for all models.
- * There is the datasheet for the model GP2Y0A41SK0F:
- *
- * http://www.robotstore.it/open2b/var/product-files/78.pdf
- *
- */
-
-//import the library in the sketch
-#include <SharpIR.h>
-
-//Create a new instance of the library
-//Call the sensor "sensor"
-//The model of the sensor is "GP2YA41SK0F"
-//The sensor output pin is attached to the pin A0
-SharpIR sensor( SharpIR::GP2Y0A41SK0F, A0 );
-
-void setup()
-{
-  Serial.begin( 9600 ); //Enable the serial comunication
-}
-
-void loop()
-{
-  int distance = sensor.getDistance(); //Calculate the distance in centimeters and store the value in a variable
-
-  Serial.println( distance ); //Print the value to the serial monitor
-}

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác