#define AVR_ATmega2560
#include <Arduino.h>
#include "lcd.h"
#include "handleCommands.h"
#define UART_SPD 9600
const uint8_t ledPin = LED_BUILTIN;
const uint8_t buttonPin = 22;
void setupTimer()
{
// Timer0 -- fast PWM
TCCR0A = (1 << WGM01) | (1 << WGM00) | (1 << COM0A1) | (1 << COM0B1);
// TCCR0B = (0 << CS02) | (1 << CS01) | (1 << CS00); // prescaler=
TCCR0B = (0 << CS02) | (1 << CS01) | (0 << CS00); // prescaler=
}
void setupOC_Pins()
{
FAN_A = 0;
FAN_B = 0;
// OC_Pins
DDRB |= 1 << 7;
DDRG |= 1 << 5;
}
void setupPinsIO()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
pinMode(buttonPin, INPUT_PULLUP);
}
void setup()
{
Serial.begin(UART_SPD);
setupPinsIO();
setupTimer();
setupOC_Pins();
}
void loop()
{
while (Serial.available())
{
uint8_t inByte = Serial.read();
if (isCommand)
{
handleFanACommand(inByte);
handleFanBCommand(inByte);
handleOCRCommand(inByte);
}
else
{
handleOCRCommand(inByte);
}
}
}