Selaa lähdekoodia

Remove unneeded sensor.

Vladimir N. Shilov 1 vuosi sitten
vanhempi
commit
ab8c9a3bc4
5 muutettua tiedostoa jossa 0 lisäystä ja 104 poistoa
  1. 0 5
      app/application.cpp
  2. 0 76
      app/gy49.cpp
  3. 0 3
      app/webserver.cpp
  4. 0 10
      include/gy49.h
  5. 0 10
      web/index.html

+ 0 - 5
app/application.cpp

@@ -9,7 +9,6 @@
 #include "tm1650.h"
 #include "AHTxx.h"
 #include "led_spi.h"
-#include "gy49.h"
 
 Timer procTimer, procRTimer;
 Timer displayTimer, tmpTimer;
@@ -19,7 +18,6 @@ Timer brightTimer;
 ahtxx_t sensorData;
 float SensorT, SensorH, SensorHI, SensorCR;
 String StrCF;
-uint32_t SensorLux;
 // Time values
 time_t Time, NTPLastUpdate;
 DateTime dt;
@@ -76,7 +74,6 @@ void init(void) {
 
 	// init sensors
 	AHTxx_Init();
-	GY49_Init();
 
 	// polling sensors - once per two seconds
 	procTimer.initializeMs(2000, GetData).start();
@@ -209,8 +206,6 @@ void GetData(void) {
 	}
 
 	Serial.printf("Humidity: %d.%d %%; Temperature: %d.%d *C\r\n", sensorData.Humidity/10, sensorData.Humidity%10, sensorData.Temperature/10, sensorData.Temperature%10);
-
-	SensorLux = GY49_GetData();
 }
 
 void connectOk(const String& SSID, MacAddress bssid, uint8_t channel)

+ 0 - 76
app/gy49.cpp

@@ -1,76 +0,0 @@
-#include "gy49.h"
-
-// MAX44009 I2C address is 0x4A/0x4B
-#define GY49_ADDR 0x4A
-
-/* Private variables */ 
-static bool isPresent;
-static Timer dataTimer;
-static uint32_t Luminance;
-
-/* Private Fuctions */ 
-void _read_data(void);
-
-/**
- * @brief Initialization
- */
-void GY49_Init(void) {
-  // Start I2C Transmission
-  Wire.beginTransmission(GY49_ADDR);
-  // Select configuration register
-  Wire.write(0x02);
-  // Continuous mode, Integration time = 800 ms
-  Wire.write(0x40);
-  // Stop I2C transmission
-  if (Wire.endTransmission()) {
-    Serial.println("GY-49: Sensor not respond!");
-    isPresent = false;
-    return;
-  }
-  isPresent = true;
-
-  // start polling sensors - once per two seconds
-  dataTimer.initializeMs(1000, _read_data).start();
-}
-
-void _read_data(void) {
-  if (!isPresent) { return; }
-
-  unsigned int data[2] = {0};
-
-  // Start I2C Transmission
-  Wire.beginTransmission(GY49_ADDR);
-  // Select data register
-  Wire.write(0x03);
-  // Stop I2C transmission
-  Wire.endTransmission();
-
-  // Request 2 bytes of data
-  Wire.requestFrom(GY49_ADDR, 2);
-
-  // Read 2 bytes of data
-  // luminance msb, luminance lsb
-  if (Wire.available() == 2) {
-    data[0] = Wire.read();
-    data[1] = Wire.read();
-  } else {
-    Serial.println("GY-49: No data from sensor.");
-    return;
-  }
-
-  // Convert the data to microLux
-  uint32_t exponent = 1 << ((data[0] & 0xF0) >> 4);
-  uint32_t mantissa = ((data[0] & 0x0F) << 4) | (data[1] & 0x0F);
-  Luminance = exponent * mantissa * 45;
-
-  // Output data to serial monitor
-  Serial.print("Ambient Light luminance :");
-  Serial.print(Luminance/1000);
-  Serial.print(",");
-  Serial.print(Luminance%1000);
-  Serial.println(" lux");
-}
-
-uint32_t GY49_GetData(void) {
-  return Luminance;
-}

+ 0 - 3
app/webserver.cpp

@@ -5,7 +5,6 @@ bool serverStarted = false;
 HttpServer server;
 
 extern float SensorT, SensorH, SensorHI, SensorCR;
-extern uint32_t SensorLux;
 extern String StrCF;
 extern time_t NTPLastUpdate;
 
@@ -19,7 +18,6 @@ void onIndex(HttpRequest& request, HttpResponse& response)
   vars["HI"] = String(SensorHI, 0);
   vars["CR"] = String(SensorCR, 0);
   vars["CF"] = StrCF; // это первое место, где оно используется
-  vars["LUX"] = String((float)SensorLux/1000, 3);
   vars["VDD"] = String(system_get_vdd33 ());
   vars["LASTNTP"] = String (SystemClock.now () - NTPLastUpdate);
 
@@ -144,7 +142,6 @@ void onApiSensors(HttpRequest& request, HttpResponse& response)
 	sensors["heatindex"] = String(SensorHI, 2);
 	sensors["comfortp"] = String(SensorCR, 2);
 	sensors["comforts"] = StrCF.c_str (); //??? второе место
-	sensors["luxvalue"] = String(SensorLux, 0);
 	sensors["vddvalue"] = String(system_get_vdd33 ());
 	time_t now = SystemClock.now();
 	sensors["datetime"] = String(now);

+ 0 - 10
include/gy49.h

@@ -1,10 +0,0 @@
-#pragma once
-#ifndef _GY49_H_
-#define _GY49_H_
-
-#include <SmingCore.h>
-
-void GY49_Init(void);
-uint32_t GY49_GetData(void);
-
-#endif /* _GY49_H_ */

+ 0 - 10
web/index.html

@@ -80,16 +80,6 @@
 				</div>
 				</div>
 			</div>
-			<div class="col-xs-10 col-md-5">
-				<div class="panel panel-default">
-				<div class="panel-heading">
-					<h3 class="panel-title">Luminance</h3>
-				</div>
-				<div class="panel-body">
-					<h1 class="text-center main">{LUX} lux</h1>
-				</div>
-				</div>
-			</div>
 			<div class="col-xs-10 col-md-5">
 				<div class="panel panel-default">
 				<div class="panel-heading">