Rev 312 | Rev 316 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#include "defines.h"#include "STEPPER.h"#include "OLED_SSD1306.h"static STEPPER_MICROSTEP currStep = STEP_1_1;static STEPPER_SPEED currSpeed = DELAY_1000MS;static uint8_t autoOn = 0;void STEPPER_Set_Microstep(STEPPER_MICROSTEP step) {#ifdef DVR8825if (step == STEP_1_1) {M0_LAT = 0;M1_LAT = 0;M2_LAT = 0;} else if (step == STEP_1_2) {M0_LAT = 1;M1_LAT = 0;M2_LAT = 0;} else if (step == STEP_1_4) {M0_LAT = 0;M1_LAT = 1;M2_LAT = 0;} else if (step == STEP_1_8) {M0_LAT = 1;M1_LAT = 1;M2_LAT = 0;} else if (step == STEP_1_16) {M0_LAT = 0;M1_LAT = 0;M2_LAT = 1;} else if (step == STEP_1_32) {M0_LAT = 1;M1_LAT = 0;M2_LAT = 1;}#endif}void STEPPER_Set_Next_Step() {switch (currStep) {case STEP_1_1:currStep = STEP_1_2;break;case STEP_1_2:currStep = STEP_1_4;break;case STEP_1_4:currStep = STEP_1_8;break;case STEP_1_8:currStep = STEP_1_16;break;case STEP_1_16:currStep = STEP_1_32;break;case STEP_1_32:default:currStep = STEP_1_1;break;}STEPPER_Set_Microstep(currStep);}STEPPER_MICROSTEP STEPPER_Get_Cur_Step(void) {return currStep;}void STEPPER_Set_Next_Delay() {switch (currSpeed) {default:case DELAY_1000MS:currSpeed = DELAY_500MS;break;case DELAY_500MS:currSpeed = DELAY_333MS;break;case DELAY_333MS:currSpeed = DELAY_250MS;break;case DELAY_250MS:currSpeed = DELAY_100MS;break;case DELAY_100MS:currSpeed = DELAY_50MS;break;case DELAY_50MS:currSpeed = DELAY_25MS;break;case DELAY_25MS:currSpeed = DELAY_10MS;break;case DELAY_10MS:currSpeed = DELAY_5MS;break;case DELAY_5MS:currSpeed = DELAY_1MS;break;case DELAY_1MS:currSpeed = DELAY_1000MS;break;}}STEPPER_SPEED STEPPER_Get_Cur_Speed(void) {return currSpeed;}void STEPPER_Toggle_Auto() {if (autoOn == 0) {autoOn = 1;} else {autoOn = 0;}}STEPPER_SPEED STEPPER_Get_Auto() {if (autoOn == 0) {return DELAY_STOPPED;} else {return currSpeed;}}void STEPPER_Step() {STEP_LAT = 1;__delay_us(2);STEP_LAT = 0;}