diff --git a/software/Basic_Blink/.cproject b/software/Basic_Blink/.cproject
new file mode 100644
index 0000000..67c056d
--- /dev/null
+++ b/software/Basic_Blink/.cproject
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ make
+ -f ${ProjDirPath}/Makefile
+ all
+ true
+ true
+ true
+
+
+ make
+ -f ${ProjDirPath}/Makefile
+ clean
+ true
+ true
+ true
+
+
+ make
+ -f ${ProjDirPath}/Makefile
+ flash
+ true
+ true
+ true
+
+
+ make
+ -f ${ProjDirPath}/Makefile
+ flashonefile
+ true
+ true
+ true
+
+
+ make
+ -f ${ProjDirPath}/Makefile
+ flashinit
+ true
+ true
+ true
+
+
+ make
+ -f ${ProjDirPath}/Makefile
+ flashboot
+ true
+ true
+ true
+
+
+ make
+ -f ${ProjDirPath}/Makefile
+ rebuild
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/software/Basic_Blink/.project b/software/Basic_Blink/.project
new file mode 100644
index 0000000..045ddec
--- /dev/null
+++ b/software/Basic_Blink/.project
@@ -0,0 +1,28 @@
+
+
+ Basic_Blink
+
+
+ SmingFramework
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.core.ccnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/software/Makefile b/software/Basic_Blink/Makefile
similarity index 100%
rename from software/Makefile
rename to software/Basic_Blink/Makefile
diff --git a/software/app/adc.h b/software/Basic_Blink/app/adc.h
similarity index 100%
rename from software/app/adc.h
rename to software/Basic_Blink/app/adc.h
diff --git a/software/app/ads101x.cpp b/software/Basic_Blink/app/ads101x.cpp
similarity index 92%
rename from software/app/ads101x.cpp
rename to software/Basic_Blink/app/ads101x.cpp
index 773adf3..4546037 100644
--- a/software/app/ads101x.cpp
+++ b/software/Basic_Blink/app/ads101x.cpp
@@ -107,11 +107,15 @@ uint16_t cADS101x::GetSettings(void) {
Wire.requestFrom((int) m_address, 2); //16 bits
settings = Wire.read() << 8;
settings |= Wire.read();
+ int result = Wire.endTransmission();
+ if (result != 0) {
+ Serial.printf("Error sample i2c: %d \n\r", result);
+ }
return settings;
}
ads_voltage_t cADS101x::ConvertSample(ads_sample_t & sample) {
//Raw sample is in (parts of) millivolts, go to micro to remove fractions
- ads_voltage_t returnType = (sample.rawSample >> 4) * 1000; //Multiply for extra precision
+ ads_voltage_t returnType = (sample.rawSample >> 4); //Multiply for extra precision
switch (sample.gain) {
case eGainAmplifier::FSR_0_256:
//one lsb is 0.125 mv = 125 uv
@@ -138,7 +142,7 @@ ads_voltage_t cADS101x::ConvertSample(ads_sample_t & sample) {
returnType *= 3000;
break;
}
- return returnType;
+ return returnType/1000;
}
ads_sample_t cADS101x::RawSample(void) {
@@ -151,6 +155,10 @@ ads_sample_t cADS101x::RawSample(void) {
Wire.requestFrom((int) m_address, 2); //16 bits
sample.rawSample = Wire.read() << 8;
sample.rawSample |= Wire.read();
+ int result = Wire.endTransmission();
+ if (result != 0) {
+ Serial.printf("Error sample i2c: %d \n\r", result);
+ }
sample.gain = m_gain;
sample.mux = m_mux;
m_latestSample = sample;
diff --git a/software/app/ads101x.h b/software/Basic_Blink/app/ads101x.h
similarity index 100%
rename from software/app/ads101x.h
rename to software/Basic_Blink/app/ads101x.h
diff --git a/software/app/application.cpp b/software/Basic_Blink/app/application.cpp
similarity index 86%
rename from software/app/application.cpp
rename to software/Basic_Blink/app/application.cpp
index 95dc796..8e872c6 100644
--- a/software/app/application.cpp
+++ b/software/Basic_Blink/app/application.cpp
@@ -2,7 +2,6 @@
#include
#include
#include "ads101x.h"
-#include "dac101c085.h"
#include "sensor_hub.h"
#include "sensor_settings.h"
#include "double_buffer.h"
@@ -14,7 +13,6 @@ static const int HUB_PERIOD = 5;
static const int ADC_TIMEBASE = 250;
static const int ADC_PERIOD = 5;
static const uint8_t ADC_ADDRESS = 0x48;
-static const uint8_t DAC_ADDRESS = 0x0C;
using namespace rijnfel;
@@ -24,11 +22,20 @@ void STAGotIP(IPAddress ip, IPAddress mask, IPAddress gateway);
Timer procTimer;
ads::cADS101x adc(0, ADC_ADDRESS);
-dac::cDAC101C085 mydac(1, DAC_ADDRESS);
uint8_t channel = 0;
cSensorHub hub(HUB_PERIOD);
-int test = 0;
+
+void SettingsTest() {
+ channel++;
+ if (channel > 3) {
+ channel = 0;
+ cWebInterface::GetInstance()->PrintValues();
+ }
+ adc.SetMux(static_cast(ads::eInputMux::AIN_0 + channel));
+ Serial.printf("Settings: %d\n\r", adc.GetSettings());
+}
+
void updateSensorHub() {
hub.Update();
}
@@ -46,15 +53,18 @@ void adcCallback(cDoubleBuffer & buffer) {
void init() {
spiffs_mount();
Serial.begin(460800);
+ system_update_cpu_freq(SYS_CPU_160MHZ);
+ wifi_set_sleep_type(NONE_SLEEP_T);
+ //scl, sda
Wire.pins(4, 5);
Wire.begin();
//SET higher CPU freq & disable wifi sleep
- system_update_cpu_freq(SYS_CPU_160MHZ);
- wifi_set_sleep_type(NONE_SLEEP_T);
+
//WDT.enable(false);
pinMode(LED_PIN, OUTPUT);
adc.SetMux(ads::eInputMux::AIN_0);
adc.SetSampleSpeed(ads::eSampleSpeed::SPS_3300);
+ adc.SetGain(ads::eGainAmplifier::FSR_4_096);
hub.SetAdc(&adc);
cSensorSettings * adcSettings;
@@ -69,13 +79,8 @@ void init() {
cWebInterface::GetInstance()->Start();
procTimer.initializeMs(HUB_PERIOD, updateSensorHub).start();
- mydac.checkDev();
- Serial.print("Write DAC reg: ");
- Serial.print(mydac.changeSettings(dac::eOpMode::NORMAL, 1023));
- Serial.println("");
- Serial.print("Read out DAC regs: ");
- Serial.print(mydac.ReadSettings());
- Serial.println("");
+ //procTimer.initializeMs(5000, SettingsTest).start();
+
}
void STADisconnect(String ssid, uint8_t ssid_len, uint8_t bssid[6],
diff --git a/software/app/dac101c085.cpp b/software/Basic_Blink/app/dac101c085.cpp
similarity index 100%
rename from software/app/dac101c085.cpp
rename to software/Basic_Blink/app/dac101c085.cpp
diff --git a/software/app/dac101c085.h b/software/Basic_Blink/app/dac101c085.h
similarity index 100%
rename from software/app/dac101c085.h
rename to software/Basic_Blink/app/dac101c085.h
diff --git a/software/app/double_buffer.h b/software/Basic_Blink/app/double_buffer.h
similarity index 100%
rename from software/app/double_buffer.h
rename to software/Basic_Blink/app/double_buffer.h
diff --git a/software/app/sensor.h b/software/Basic_Blink/app/sensor.h
similarity index 100%
rename from software/app/sensor.h
rename to software/Basic_Blink/app/sensor.h
diff --git a/software/app/sensor_hub.cpp b/software/Basic_Blink/app/sensor_hub.cpp
similarity index 100%
rename from software/app/sensor_hub.cpp
rename to software/Basic_Blink/app/sensor_hub.cpp
diff --git a/software/app/sensor_hub.h b/software/Basic_Blink/app/sensor_hub.h
similarity index 100%
rename from software/app/sensor_hub.h
rename to software/Basic_Blink/app/sensor_hub.h
diff --git a/software/app/sensor_settings.h b/software/Basic_Blink/app/sensor_settings.h
similarity index 100%
rename from software/app/sensor_settings.h
rename to software/Basic_Blink/app/sensor_settings.h
diff --git a/software/app/temperature.h b/software/Basic_Blink/app/temperature.h
similarity index 100%
rename from software/app/temperature.h
rename to software/Basic_Blink/app/temperature.h
diff --git a/software/app/web_interface.cpp b/software/Basic_Blink/app/web_interface.cpp
similarity index 99%
rename from software/app/web_interface.cpp
rename to software/Basic_Blink/app/web_interface.cpp
index e7f4d8e..26127b1 100644
--- a/software/app/web_interface.cpp
+++ b/software/Basic_Blink/app/web_interface.cpp
@@ -90,7 +90,6 @@ void cWebInterface::UpdateAdc(cADC & adc,
for (int i = 0; i < size; i++) {
average += buf[i].rawSample;
}
-
if (size != 0) {
average /= size;
}
diff --git a/software/app/web_interface.h b/software/Basic_Blink/app/web_interface.h
similarity index 100%
rename from software/app/web_interface.h
rename to software/Basic_Blink/app/web_interface.h
diff --git a/software/files/bootstrap.min.css.gz b/software/Basic_Blink/files/bootstrap.min.css.gz
similarity index 100%
rename from software/files/bootstrap.min.css.gz
rename to software/Basic_Blink/files/bootstrap.min.css.gz
diff --git a/software/files/config.html b/software/Basic_Blink/files/config.html
similarity index 100%
rename from software/files/config.html
rename to software/Basic_Blink/files/config.html
diff --git a/software/files/config.js b/software/Basic_Blink/files/config.js
similarity index 100%
rename from software/files/config.js
rename to software/Basic_Blink/files/config.js
diff --git a/software/files/index.html b/software/Basic_Blink/files/index.html
similarity index 100%
rename from software/files/index.html
rename to software/Basic_Blink/files/index.html
diff --git a/software/files/index.js b/software/Basic_Blink/files/index.js
similarity index 100%
rename from software/files/index.js
rename to software/Basic_Blink/files/index.js
diff --git a/software/files/jquery-2.1.4.min.js.gz b/software/Basic_Blink/files/jquery-2.1.4.min.js.gz
similarity index 100%
rename from software/files/jquery-2.1.4.min.js.gz
rename to software/Basic_Blink/files/jquery-2.1.4.min.js.gz
diff --git a/software/include/user_config.h b/software/Basic_Blink/include/user_config.h
similarity index 100%
rename from software/include/user_config.h
rename to software/Basic_Blink/include/user_config.h