Add cutter to control, test via preset buttons
This commit is contained in:
parent
bb22fb340d
commit
9600932ae8
@ -181,6 +181,11 @@ void task_control(void *pvParameter)
|
||||
SW_PRESET3.handle();
|
||||
|
||||
|
||||
//---------------------------
|
||||
//------ handle cutter ------
|
||||
//---------------------------
|
||||
cutter_handle();
|
||||
|
||||
|
||||
//----------------------------
|
||||
//------ rotary encoder ------
|
||||
@ -202,6 +207,11 @@ void task_control(void *pvParameter)
|
||||
rotary_encoder_reset(&encoder);
|
||||
lengthNow = 0;
|
||||
buzzer.beep(1, 700, 100);
|
||||
|
||||
//######### TESTING #########
|
||||
//stop cutter
|
||||
cutter_stop();
|
||||
//######### TESTING #########
|
||||
}
|
||||
|
||||
|
||||
@ -266,6 +276,11 @@ void task_control(void *pvParameter)
|
||||
lengthTarget = 10000;
|
||||
buzzer.beep(lengthTarget/1000, 25, 30);
|
||||
displayBot.blink(2, 100, 100, "S0LL ");
|
||||
|
||||
//######### TESTING #########
|
||||
//stop cutter
|
||||
cutter_start();
|
||||
//######### TESTING #########
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ extern "C"
|
||||
#include "buzzer.hpp"
|
||||
#include "vfd.hpp"
|
||||
#include "display.hpp"
|
||||
#include "cutter.hpp"
|
||||
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ bool checkTimeout();
|
||||
//---------------------------
|
||||
//----- local variables -----
|
||||
//---------------------------
|
||||
cutter_state_t state = cutter_state_t::IDLE;
|
||||
cutter_state_t cutter_state = cutter_state_t::IDLE;
|
||||
uint32_t timestamp_turnedOn;
|
||||
uint32_t msTimeout = 3000;
|
||||
static const char *TAG = "cutter"; //tag for logging
|
||||
@ -47,7 +47,7 @@ void cutter_stop(){
|
||||
//===== cutter_getState =====
|
||||
//===========================
|
||||
cutter_state_t cutter_getState(){
|
||||
return state;
|
||||
return cutter_state;
|
||||
}
|
||||
|
||||
|
||||
@ -58,16 +58,16 @@ cutter_state_t cutter_getState(){
|
||||
//local function for changing state, taking corresponding actions and sending log output
|
||||
void setState(cutter_state_t stateNew){
|
||||
//only proceed and send log output when state or direction actually changed
|
||||
if ( state == stateNew) {
|
||||
if ( cutter_state == stateNew) {
|
||||
//already at target state -> do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
//log old and new state
|
||||
ESP_LOGI(TAG, "CHANGING state from: %i %s", (int)state, cutter_stateStr[(int)state]);
|
||||
ESP_LOGI(TAG, "CHANGING state to: %i %s", (int)stateNew, cutter_stateStr[(int)stateNew]);
|
||||
ESP_LOGI(TAG, "CHANGING state from: %s",cutter_stateStr[(int)cutter_state]);
|
||||
ESP_LOGI(TAG, "CHANGING state to: %s",cutter_stateStr[(int)stateNew]);
|
||||
//update stored state
|
||||
state = stateNew;
|
||||
cutter_state = stateNew;
|
||||
|
||||
switch(stateNew){
|
||||
case cutter_state_t::IDLE:
|
||||
@ -111,7 +111,7 @@ bool checkTimeout(){
|
||||
//function that handles the cutter logic -> has to be run repeatedly
|
||||
void cutter_handle(){
|
||||
|
||||
switch(state){
|
||||
switch(cutter_state){
|
||||
case cutter_state_t::IDLE:
|
||||
case cutter_state_t::TIMEOUT:
|
||||
case cutter_state_t::CANCELED:
|
||||
|
@ -25,7 +25,7 @@ void gpio_configure_output(gpio_num_t gpio_pin){
|
||||
}
|
||||
|
||||
void init_gpios(){
|
||||
//initialize all outputs
|
||||
//--- outputs ---
|
||||
//4x stepper mosfets
|
||||
gpio_configure_output(GPIO_VFD_FWD);
|
||||
gpio_configure_output(GPIO_VFD_D0);
|
||||
@ -40,9 +40,15 @@ void init_gpios(){
|
||||
//5v regulator
|
||||
gpio_configure_output(GPIO_NUM_17);
|
||||
|
||||
//--- inputs ---
|
||||
//initialize and configure ADC
|
||||
adc1_config_width(ADC_WIDTH_BIT_12); //=> max resolution 4096
|
||||
adc1_config_channel_atten(ADC_CHANNEL_POTI, ADC_ATTEN_DB_11); //max voltage
|
||||
//initialize input for cutter position switch with pullup
|
||||
gpio_pad_select_gpio(GPIO_CUTTER_POS_SW);
|
||||
gpio_set_direction(GPIO_CUTTER_POS_SW, GPIO_MODE_INPUT);
|
||||
gpio_pad_select_gpio(GPIO_CUTTER_POS_SW);
|
||||
gpio_set_pull_mode(GPIO_CUTTER_POS_SW, GPIO_PULLUP_ONLY);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user