Add base code for PAT9125_sensor
This commit is contained in:
parent
90b78616b7
commit
c46b97ec2d
|
|
@ -5,5 +5,7 @@
|
||||||
IR_sensor fsensor;
|
IR_sensor fsensor;
|
||||||
#elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
|
#elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
|
||||||
IR_sensor_analog fsensor;
|
IR_sensor_analog fsensor;
|
||||||
|
#elif FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125
|
||||||
|
PAT9125_sensor fsensor;
|
||||||
#endif
|
#endif
|
||||||
#endif //FILAMENT_SENSOR
|
#endif //FILAMENT_SENSOR
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
#include "pat9125.h"
|
||||||
|
|
||||||
#define FSENSOR_IR 1
|
#define FSENSOR_IR 1
|
||||||
#define FSENSOR_IR_ANALOG 2
|
#define FSENSOR_IR_ANALOG 2
|
||||||
|
|
@ -438,10 +439,62 @@ private:
|
||||||
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
|
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
|
||||||
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR) || (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
|
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR) || (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
|
||||||
|
|
||||||
|
#if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
||||||
|
class PAT9125_sensor: public Filament_sensor {
|
||||||
|
public:
|
||||||
|
void init() {
|
||||||
|
if (state == State::error) {
|
||||||
|
deinit(); //deinit first if there was an error.
|
||||||
|
}
|
||||||
|
puts_P(PSTR("fsensor::init()"));
|
||||||
|
;//
|
||||||
|
settings_init(); //also sets the state to State::initializing
|
||||||
|
}
|
||||||
|
|
||||||
|
void deinit() {
|
||||||
|
puts_P(PSTR("fsensor::deinit()"));
|
||||||
|
;//
|
||||||
|
state = State::disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool update() {
|
||||||
|
switch (state) {
|
||||||
|
case State::initializing:
|
||||||
|
// state = State::ready; //the IR sensor gets ready instantly as it's just a gpio read operation.
|
||||||
|
oldFilamentPresent = getFilamentPresent(); //initialize the current filament state so that we don't create a switching event right after the sensor is ready.
|
||||||
|
// fallthru
|
||||||
|
case State::ready: {
|
||||||
|
postponedLoadEvent = false;
|
||||||
|
bool event = checkFilamentEvents();
|
||||||
|
|
||||||
|
;//
|
||||||
|
|
||||||
|
return event;
|
||||||
|
} break;
|
||||||
|
case State::disabled:
|
||||||
|
case State::error:
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getFilamentPresent() {
|
||||||
|
return false;///
|
||||||
|
}
|
||||||
|
|
||||||
|
void settings_init() {
|
||||||
|
Filament_sensor::settings_init();
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
||||||
|
|
||||||
#if FILAMENT_SENSOR_TYPE == FSENSOR_IR
|
#if FILAMENT_SENSOR_TYPE == FSENSOR_IR
|
||||||
extern IR_sensor fsensor;
|
extern IR_sensor fsensor;
|
||||||
#elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
|
#elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
|
||||||
extern IR_sensor_analog fsensor;
|
extern IR_sensor_analog fsensor;
|
||||||
|
#elif FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125
|
||||||
|
extern PAT9125_sensor fsensor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //FILAMENT_SENSOR
|
#endif //FILAMENT_SENSOR
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "Configuration_prusa.h"
|
||||||
|
|
||||||
|
#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
|
||||||
|
|
||||||
//PAT9125 registers
|
//PAT9125 registers
|
||||||
#define PAT9125_PID1 0x00
|
#define PAT9125_PID1 0x00
|
||||||
|
|
@ -305,3 +307,5 @@ static uint8_t pat9125_wr_seq(const uint8_t* seq)
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue