Commit 1fc0c146 authored by Víctor Fernandes Gandara's avatar Víctor Fernandes Gandara
Browse files

Merge branch '1stSketch_patch01' into '1stSketch'

Proposta de organização do projeto

See merge request !1
parents 6e48cfcb afd22db2
#include <stdbool.h>
uint8_t InterruptPin = D2;
#define SensorTimeInterval 1000 /*1000ms = 1s*/
bool event_flag;
int event_count = 0;
unsigned long previousMillis = 0;
#include "teste.h"
void setup() {
Serial.begin(9600);
delay(100);
pinMode(InterruptPin, INPUT); /*Declaramos aqui que o pino InterruptPin será usado como trigger*/
attachInterrupt(digitalPinToInterrupt(InterruptPin), interrupt_call, RISING);
}
ICACHE_RAM_ATTR void interrupt_call(){
event_flag = true;
delay(0);
}
void loop() {
check_event();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= SensorTimeInterval)
{
previousMillis = currentMillis;
UpdateSensor();
}
}
#include<stdio.h>
void check_event()
{
if (event_flag)
{
event_flag = false;
Serial.println("Evento detectado.");
event_count = event_count + 1;
Serial.println(event_count);
}
else
{
Serial.println(".");
}
}
void UpdateSensor()
{
Serial.println("Updating sensors...");
Serial.println("Done.");
}
#include <stdio.h>
#include "CPDigiMain.h"
int main()
void check_event()
{
process_event();
if (event_flag)
{
event_flag = false;
Serial.println("Evento detectado.");
event_count = event_count + 1;
Serial.println(event_count);
}
else
{
Serial.println(".");
}
}
void UpdateSensor()
{
Serial.println("Updating sensors...");
Serial.println("Done.");
}
#include <stdbool.h>
#define InterruptPin D2
#define SensorTimeInterval 1000 /*1000ms = 1s*/
#define QueueTimeInterval 3000
bool event_flag;
int event_count = 0;
unsigned long queue_last_time = 0;
unsigned long sensors_last_time = 0;
#include "CPDigiMain/teste.c"
void setup() {
Serial.begin(9600);
delay(100);
pinMode(InterruptPin, INPUT); /* Declaramos aqui que o pino InterruptPin será usado como trigger */
attachInterrupt(digitalPinToInterrupt(InterruptPin), interrupt_call, RISING);
}
ICACHE_RAM_ATTR void interrupt_call() {
event_flag = true;
delay(0);
}
void loop() {
check_event();
//Update sensor caches
unsigned long currentMillis = millis();
if (currentMillis - sensors_last_time >= SensorTimeInterval) {
sensors_last_time = currentMillis;
UpdateSensor();
}
// Queue timer
currentMillis = millis();
if (currentMillis - queue_last_time >= QueueTimeInterval) {
queue_last_time = currentMillis;
//processQueue();
}
} // loop
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment