From cf540bdec916e6ed5bf40ba96c384842b399abdd Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 27 Apr 2025 22:27:06 +0200 Subject: [PATCH] Refactor MAX7219 initialization and update MQ7 reading delay --- hardware/include/MAX7219.hpp | 1 - hardware/src/lib/actuator/MAX7219.cpp | 2 +- hardware/src/lib/sensor/MQ7.cpp | 8 ++------ hardware/src/main.cpp | 9 +++++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/hardware/include/MAX7219.hpp b/hardware/include/MAX7219.hpp index c182911..49e7734 100644 --- a/hardware/include/MAX7219.hpp +++ b/hardware/include/MAX7219.hpp @@ -4,7 +4,6 @@ #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define MAX_DEVICES 4 // 4 modulos 8x8 - #define DATA_PIN 19 #define CS_PIN 18 #define CLK_PIN 17 diff --git a/hardware/src/lib/actuator/MAX7219.cpp b/hardware/src/lib/actuator/MAX7219.cpp index 55be534..7d7f3e6 100644 --- a/hardware/src/lib/actuator/MAX7219.cpp +++ b/hardware/src/lib/actuator/MAX7219.cpp @@ -5,7 +5,7 @@ MD_Parola display = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVI void MAX7219_Init() { display.begin(); - display.setIntensity(1); // 0-15 + display.setIntensity(15); // 0-15 display.displayClear(); } diff --git a/hardware/src/lib/sensor/MQ7.cpp b/hardware/src/lib/sensor/MQ7.cpp index 8739ab2..e700cbd 100644 --- a/hardware/src/lib/sensor/MQ7.cpp +++ b/hardware/src/lib/sensor/MQ7.cpp @@ -8,6 +8,7 @@ void MQ7_Init() void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue) { + // preheat analogWrite(ANALOG_MQ7, 1023); delay(60000); analogWrite(ANALOG_MQ7, (1023/5)*1.4 ); @@ -15,16 +16,11 @@ void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue) for(int i = 0; i<100; i++) { sensorValue = sensorValue + analogRead(ANALOG_MQ7); - delay(90000); + delay(1200); } sensorValue = sensorValue/100.0; sensorVolt = sensorValue/1024*5.0; RSAir = (5.0-sensorVolt)/sensorVolt; R0 = RSAir/(26+(1/3)); - - Serial.print("R0 = "); - Serial.println(R0); - - delay(1000); } \ No newline at end of file diff --git a/hardware/src/main.cpp b/hardware/src/main.cpp index ce3f445..ec41d03 100644 --- a/hardware/src/main.cpp +++ b/hardware/src/main.cpp @@ -13,19 +13,19 @@ void setup() { Serial.begin(9600); - Serial.println("Iniciando..."); + /*Serial.println("Iniciando..."); MQ7_Init(); Serial.println("Sensor MQ7 inicializado"); BME280_Init(); Serial.println("Sensor BME280 inicializado"); GPS_Init(); - Serial.println("GPS inicializado"); + Serial.println("GPS inicializado"); */ MAX7219_Init(); Serial.println("Display inicializado"); - prettyReadBME280(); - prettyReadMQ7(); + //prettyReadBME280(); testMatrix(); + //prettyReadMQ7(); } void loop() @@ -65,6 +65,7 @@ void testMatrix() { Serial.println("Escribiendo en el display..."); MAX7219_DisplayText("Prueba de texto", PA_LEFT, 100, 500); + } uint32_t getChipID()