DVT2023/DVT_MainClass.h

54 lines
1.5 KiB
C
Raw Normal View History

2023-11-24 21:09:47 +00:00
#ifndef DVT_MAINCLASS_H
#define DVT_MAINCLASS_H
#include <Arduino.h>
#include "DVT_Types.h"
class Pin {
private:
byte pin;
byte pinMODE;
DVT_State_t pinSTATE;
public:
Pin(byte pin, byte pinMODE, bool pinSTATE) {
this->pin = pin;
this->pinMODE = pinMODE;
this->pinSTATE.State = pinSTATE;
pinMode(pin, pinMODE);
if (this->pinMODE == OUTPUT)
digitalWrite(this->pin, this->pinSTATE.State);
}
void SetState(bool pinSTATE){
digitalWrite(this->pin, pinSTATE);
}
void SetAnalogState(int pinSTATE){
analogWrite(this->pin,pinSTATE);
}
bool GetState() {
return this->pinSTATE.State;
}
bool ReadState(){
return digitalRead(this->pin);
}
byte GetPin(){
return this->pin;
}
};
Pin INDUCT_SWITCH = Pin(PIN_INDUCT_SWITCH,INPUT,LOW);
Pin ENCODER = Pin(PIN_ENCODER,INPUT,LOW);
Pin VARIAC_LIMIT_BACK = Pin(PIN_VARIAC_LIMIT_BACK,INPUT,LOW);
Pin VARIAC_LIMIT_FOR = Pin(PIN_VARIAC_LIMIT_FOR,INPUT,LOW);
Pin ARM_STOP = Pin(PIN_ARM_STOP,OUTPUT,LOW);
Pin ARM_SPEED = Pin(PIN_ARM_SPEED,OUTPUT,LOW);
Pin ARM_DIRECT = Pin(PIN_ARM_DIRECT,OUTPUT,HIGH);
Pin STEPMOTOR_ABLE = Pin(PIN_STEPMOTOR_ABLE,OUTPUT,HIGH);
Pin STEPMOTOR_DIRECT = Pin(PIN_STEPMOTOR_DIRECT,OUTPUT,HIGH);
Pin STEPMOTOR_CLOCK = Pin(PIN_STEPMOTOR_CLOCK,OUTPUT,HIGH);
Pin XRAY_SWITCH = Pin(PIN_XRAY,OUTPUT,LOW);
Pin KV_SWITCH = Pin(PIN_KV_SWITCH, OUTPUT, LOW);
2023-11-24 21:09:47 +00:00
Pin FILAMENT_SWITCH = Pin(PIN_FILAMENT_SWITCH,OUTPUT,LOW);
#endif