Move source code to /firmware and fix build paths
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "moisture.h"
|
||||
#include "adc.h"
|
||||
|
||||
ISR(WDT_vect) {
|
||||
triggerSensorsRead();
|
||||
}
|
||||
|
||||
void watchdogs(void) {
|
||||
cli();
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
WDTCSR |= (1 << WDCE) | (1 << WDE);
|
||||
WDTCSR = (1 << WDIE) | (1 << WDP3) | (1 << WDP0);
|
||||
sei();
|
||||
}
|
||||
|
||||
void enterSleep(void) {
|
||||
set_sleep_mode(SLEEP_MODE_IDLE);
|
||||
sleep_enable();
|
||||
sleep_cpu();
|
||||
sleep_disable();
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
adcInit();
|
||||
initMoistureSensors();
|
||||
watchdogs();
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if (readSensors) {
|
||||
int16_t result = readMoisture();
|
||||
|
||||
//TODO: send result to esp32
|
||||
}
|
||||
// readFromEsp()
|
||||
// if esp tells to water plants: waterPlants()
|
||||
enterSleep();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user