2018-10-09 22:33:54 +02:00
|
|
|
//! @file
|
2017-10-22 22:42:45 +02:00
|
|
|
#ifndef FSENSOR_H
|
|
|
|
#define FSENSOR_H
|
|
|
|
|
2018-07-21 01:57:41 +02:00
|
|
|
#include <inttypes.h>
|
2019-09-16 00:43:37 +02:00
|
|
|
#include "config.h"
|
2017-10-22 22:42:45 +02:00
|
|
|
|
2018-07-20 20:30:08 +02:00
|
|
|
|
2018-10-09 22:33:54 +02:00
|
|
|
// enable/disable flag
|
2018-07-21 01:57:41 +02:00
|
|
|
extern bool fsensor_enabled;
|
2018-10-09 22:33:54 +02:00
|
|
|
// not responding flag
|
2018-07-21 01:57:41 +02:00
|
|
|
extern bool fsensor_not_responding;
|
2020-02-05 15:17:19 +01:00
|
|
|
#ifdef PAT9125
|
|
|
|
// optical checking "chunk lenght" (already in steps)
|
|
|
|
extern int16_t fsensor_chunk_len;
|
|
|
|
// count of soft failures
|
2019-06-02 18:00:31 +02:00
|
|
|
extern uint8_t fsensor_softfail;
|
2020-02-05 15:17:19 +01:00
|
|
|
#endif
|
2018-07-19 20:55:38 +02:00
|
|
|
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @name save restore printing
|
|
|
|
//! @{
|
2018-07-20 14:03:22 +02:00
|
|
|
extern void fsensor_stop_and_save_print(void);
|
2019-06-05 18:34:10 +02:00
|
|
|
//! restore print - restore position and heatup to original temperature
|
2018-07-20 14:03:22 +02:00
|
|
|
extern void fsensor_restore_print_and_continue(void);
|
2019-10-16 18:47:18 +02:00
|
|
|
//! split the current gcode stream to insert new instructions
|
|
|
|
extern void fsensor_checkpoint_print(void);
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @}
|
2018-07-20 14:03:22 +02:00
|
|
|
|
2018-10-09 22:33:54 +02:00
|
|
|
//! initialize
|
2018-07-20 14:03:22 +02:00
|
|
|
extern void fsensor_init(void);
|
2017-10-24 19:45:15 +02:00
|
|
|
|
2020-02-05 15:17:19 +01:00
|
|
|
#ifdef PAT9125
|
2020-02-05 14:23:41 +01:00
|
|
|
//! update axis resolution
|
|
|
|
extern void fsensor_set_axis_steps_per_unit(float u);
|
2020-02-05 15:17:19 +01:00
|
|
|
#endif
|
2020-02-05 14:23:41 +01:00
|
|
|
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @name enable/disable
|
|
|
|
//! @{
|
2019-09-16 00:43:37 +02:00
|
|
|
extern bool fsensor_enable(bool bUpdateEEPROM=true);
|
|
|
|
extern void fsensor_disable(bool bUpdateEEPROM=true);
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @}
|
2017-10-24 19:45:15 +02:00
|
|
|
|
2018-07-20 23:48:00 +02:00
|
|
|
//autoload feature enabled
|
2018-07-20 14:03:22 +02:00
|
|
|
extern bool fsensor_autoload_enabled;
|
2018-07-19 20:55:38 +02:00
|
|
|
extern void fsensor_autoload_set(bool State);
|
2018-07-11 20:45:56 +02:00
|
|
|
|
2018-07-20 14:03:22 +02:00
|
|
|
extern void fsensor_update(void);
|
2019-01-24 16:14:02 +01:00
|
|
|
#ifdef PAT9125
|
2018-10-09 22:33:54 +02:00
|
|
|
//! setup pin-change interrupt
|
2018-07-20 14:03:22 +02:00
|
|
|
extern void fsensor_setup_interrupt(void);
|
2017-10-22 22:42:45 +02:00
|
|
|
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @name autoload support
|
|
|
|
//! @{
|
2019-01-24 16:14:02 +01:00
|
|
|
|
2017-12-13 17:39:32 +01:00
|
|
|
extern void fsensor_autoload_check_start(void);
|
|
|
|
extern void fsensor_autoload_check_stop(void);
|
2019-01-24 16:00:52 +01:00
|
|
|
#endif //PAT9125
|
2017-12-13 17:39:32 +01:00
|
|
|
extern bool fsensor_check_autoload(void);
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @}
|
2017-12-13 17:39:32 +01:00
|
|
|
|
2020-02-05 15:17:19 +01:00
|
|
|
#ifdef PAT9125
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @name optical quality measurement support
|
|
|
|
//! @{
|
2020-02-05 15:17:19 +01:00
|
|
|
extern bool fsensor_oq_meassure_enabled;
|
2018-10-04 15:48:28 +02:00
|
|
|
extern void fsensor_oq_meassure_set(bool State);
|
2018-07-22 16:14:13 +02:00
|
|
|
extern void fsensor_oq_meassure_start(uint8_t skip);
|
2018-07-20 20:30:08 +02:00
|
|
|
extern void fsensor_oq_meassure_stop(void);
|
|
|
|
extern bool fsensor_oq_result(void);
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @}
|
|
|
|
|
|
|
|
//! @name callbacks from stepper
|
|
|
|
//! @{
|
2019-06-01 19:59:39 +02:00
|
|
|
extern void fsensor_st_block_chunk(int cnt);
|
2019-06-03 11:48:36 +02:00
|
|
|
|
2020-03-30 16:50:50 +03:00
|
|
|
// debugging
|
|
|
|
extern uint8_t fsensor_log;
|
|
|
|
|
2019-06-03 11:48:36 +02:00
|
|
|
// There's really nothing to do in block_begin: the stepper ISR likely has
|
|
|
|
// called us already at the end of the last block, making this integration
|
|
|
|
// redundant. LA1.5 might not always do that during a coasting move, so attempt
|
|
|
|
// to drain fsensor_st_cnt anyway at the beginning of the new block.
|
|
|
|
#define fsensor_st_block_begin(rev) fsensor_st_block_chunk(0)
|
2018-10-09 22:33:54 +02:00
|
|
|
//! @}
|
2020-02-05 15:17:19 +01:00
|
|
|
#endif //PAT9125
|
2018-07-19 20:55:38 +02:00
|
|
|
|
2020-06-03 16:14:56 +02:00
|
|
|
#define VOLT_DIV_REF 5
|
2019-09-16 00:43:37 +02:00
|
|
|
|
2020-03-26 14:40:47 +01:00
|
|
|
#ifdef IR_SENSOR_ANALOG
|
2019-09-16 00:43:37 +02:00
|
|
|
#define IR_SENSOR_STEADY 10 // [ms]
|
|
|
|
|
|
|
|
enum class ClFsensorPCB:uint_least8_t
|
|
|
|
{
|
|
|
|
_Old=0,
|
2020-04-24 19:46:54 +02:00
|
|
|
_Rev04=1,
|
2019-09-16 00:43:37 +02:00
|
|
|
_Undef=EEPROM_EMPTY_VALUE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class ClFsensorActionNA:uint_least8_t
|
|
|
|
{
|
|
|
|
_Continue=0,
|
|
|
|
_Pause=1,
|
|
|
|
_Undef=EEPROM_EMPTY_VALUE
|
|
|
|
};
|
|
|
|
|
|
|
|
extern ClFsensorPCB oFsensorPCB;
|
|
|
|
extern ClFsensorActionNA oFsensorActionNA;
|
2020-06-03 16:14:56 +02:00
|
|
|
extern const char* FsensorIRVersionText();
|
2019-09-16 00:43:37 +02:00
|
|
|
|
|
|
|
extern bool fsensor_IR_check();
|
2020-06-03 16:14:56 +02:00
|
|
|
constexpr uint16_t Voltage2Raw(float V){
|
|
|
|
return ( V * 1023 * OVERSAMPLENR / VOLT_DIV_REF ) + 0.5F;
|
|
|
|
}
|
|
|
|
constexpr float Raw2Voltage(uint16_t raw){
|
|
|
|
return VOLT_DIV_REF*(raw / (1023.F * OVERSAMPLENR) );
|
|
|
|
}
|
|
|
|
constexpr uint16_t IRsensor_Ldiode_TRESHOLD = Voltage2Raw(0.3F); // ~0.3V, raw value=982
|
|
|
|
constexpr uint16_t IRsensor_Lmax_TRESHOLD = Voltage2Raw(1.5F); // ~1.5V (0.3*Vcc), raw value=4910
|
|
|
|
constexpr uint16_t IRsensor_Hmin_TRESHOLD = Voltage2Raw(3.0F); // ~3.0V (0.6*Vcc), raw value=9821
|
|
|
|
constexpr uint16_t IRsensor_Hopen_TRESHOLD = Voltage2Raw(4.6F); // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k), raw value=15059
|
|
|
|
constexpr uint16_t IRsensor_VMax_TRESHOLD = Voltage2Raw(5.F); // ~5V, raw value=16368
|
|
|
|
|
2019-09-16 00:43:37 +02:00
|
|
|
#endif //IR_SENSOR_ANALOG
|
|
|
|
|
2017-10-22 22:42:45 +02:00
|
|
|
#endif //FSENSOR_H
|