Compare commits
1 commit
develop
...
velocity_c
| Author | SHA1 | Date | |
|---|---|---|---|
| 1016cc3abc |
8 changed files with 55 additions and 5 deletions
|
|
@ -1 +1 @@
|
||||||
446
|
445
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ $(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(basename $(filter-out $(EXCLUDE_SOURC
|
||||||
|
|
||||||
$(addprefix $(BUILD_DIR)/,$(addsuffix .d,$(basename $(filter-out $(EXCLUDE_SOURCES),$(notdir $(wildcard $(1)/*.c)))))): $(BUILD_DIR)/%.d: $(1)/%.c
|
$(addprefix $(BUILD_DIR)/,$(addsuffix .d,$(basename $(filter-out $(EXCLUDE_SOURCES),$(notdir $(wildcard $(1)/*.c)))))): $(BUILD_DIR)/%.d: $(1)/%.c
|
||||||
@#echo " DP $$@"
|
@#echo " DP $$@"
|
||||||
$(Q)set -e; rm -f $$@; $$(CC) -MM $$(CFLAGS) $$< > $$@.$$$$$$$$; sed 's,\(.*\)\.o[ :]*,build\/\1.o $$@ : ,g' < $$@.$$$$$$$$ > $$@; rm -f $$@.$$$$$$$$
|
$(Q)set -e; rm -f $$@; $$(CC) -MM $$(CFLAGS) $$< > $$@.$$$$$$$$; sed 's,\($$*\)\.o[ :]*,build\/\1.o $$@ : ,g' < $$@.$$$$$$$$ > $$@; rm -f $$@.$$$$$$$$
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach directory,$(SOURCE_DIRS),$(eval $(call define_compile_rules,$(directory))))
|
$(foreach directory,$(SOURCE_DIRS),$(eval $(call define_compile_rules,$(directory))))
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
359
|
363
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ endif
|
||||||
define define_compile_rule
|
define define_compile_rule
|
||||||
$(addprefix $(BUILD_DIR)/,$(notdir $(1:.c=.d))): $(1)
|
$(addprefix $(BUILD_DIR)/,$(notdir $(1:.c=.d))): $(1)
|
||||||
@#echo " DP $$@"
|
@#echo " DP $$@"
|
||||||
$(Q)set -e; rm -f $$@; $$(CC) -MM $$(CFLAGS) $$< > $$@.$$$$$$$$; sed 's,\(.*\)\.o[ :]*,build\/\1.o $$@ : ,g' < $$@.$$$$$$$$ > $$@; rm -f $$@.$$$$$$$$
|
$(Q)set -e; rm -f $$@; $$(CC) -MM $$(CFLAGS) $$< > $$@.$$$$$$$$; sed 's,\($$*\)\.o[ :]*,build\/\1.o $$@ : ,g' < $$@.$$$$$$$$ > $$@; rm -f $$@.$$$$$$$$
|
||||||
$(addprefix $(BUILD_DIR)/,$(notdir $(1:.c=.o))): $(1)
|
$(addprefix $(BUILD_DIR)/,$(notdir $(1:.c=.o))): $(1)
|
||||||
@echo " CC $$@"
|
@echo " CC $$@"
|
||||||
$(Q)$$(CC) $$(CFLAGS) -o $$@ -c $$<
|
$(Q)$$(CC) $$(CFLAGS) -o $$@ -c $$<
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ typedef enum
|
||||||
HPGL_Parser_ReceivingX,
|
HPGL_Parser_ReceivingX,
|
||||||
HPGL_Parser_ReceivingY,
|
HPGL_Parser_ReceivingY,
|
||||||
|
|
||||||
|
// Receiving velocity value
|
||||||
|
HPGL_Parser_ReceivingVelocity,
|
||||||
|
|
||||||
HPGL_Parser_Error,
|
HPGL_Parser_Error,
|
||||||
} HPGL_ParserState_t;
|
} HPGL_ParserState_t;
|
||||||
|
|
||||||
|
|
@ -45,6 +48,8 @@ void HPGL_Poll(void)
|
||||||
|
|
||||||
static bool waiting_for_movement_queue = false;
|
static bool waiting_for_movement_queue = false;
|
||||||
|
|
||||||
|
static unsigned char current_velocity = OUTPUT_DEFAULT_VELOCITY;
|
||||||
|
|
||||||
if(waiting_for_movement_queue)
|
if(waiting_for_movement_queue)
|
||||||
{
|
{
|
||||||
if(!HPGL_EnqueueMovement(waiting_movement))
|
if(!HPGL_EnqueueMovement(waiting_movement))
|
||||||
|
|
@ -100,6 +105,7 @@ void HPGL_Poll(void)
|
||||||
// Initialise
|
// Initialise
|
||||||
HPGL_ParseErrorCounter = 0;
|
HPGL_ParseErrorCounter = 0;
|
||||||
// No parameters expected for this one
|
// No parameters expected for this one
|
||||||
|
current_velocity = OUTPUT_DEFAULT_VELOCITY;
|
||||||
state = HPGL_Parser_Idle;
|
state = HPGL_Parser_Idle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -111,6 +117,7 @@ void HPGL_Poll(void)
|
||||||
case INST('P', 'U'):
|
case INST('P', 'U'):
|
||||||
// Movement with pen up
|
// Movement with pen up
|
||||||
current_movement.pen_down = false;
|
current_movement.pen_down = false;
|
||||||
|
current_movement.velocity = current_velocity;
|
||||||
current_movement.x = 0;
|
current_movement.x = 0;
|
||||||
current_movement.y = 0;
|
current_movement.y = 0;
|
||||||
state = HPGL_Parser_ReceivingX;
|
state = HPGL_Parser_ReceivingX;
|
||||||
|
|
@ -119,11 +126,24 @@ void HPGL_Poll(void)
|
||||||
case INST('P', 'D'):
|
case INST('P', 'D'):
|
||||||
// Movement with pen down
|
// Movement with pen down
|
||||||
current_movement.pen_down = true;
|
current_movement.pen_down = true;
|
||||||
|
current_movement.velocity = current_velocity;
|
||||||
current_movement.x = 0;
|
current_movement.x = 0;
|
||||||
current_movement.y = 0;
|
current_movement.y = 0;
|
||||||
state = HPGL_Parser_ReceivingX;
|
state = HPGL_Parser_ReceivingX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case INST('V', 'N'):
|
||||||
|
// Reset velocity to default
|
||||||
|
current_velocity = OUTPUT_DEFAULT_VELOCITY;
|
||||||
|
state = HPGL_Parser_Idle;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INST('V', 'S'):
|
||||||
|
// Velocity set
|
||||||
|
current_velocity = 0;
|
||||||
|
state = HPGL_Parser_ReceivingVelocity;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Unsupported instruction
|
// Unsupported instruction
|
||||||
HPGL_ParseErrorCounter++;
|
HPGL_ParseErrorCounter++;
|
||||||
|
|
@ -213,6 +233,25 @@ void HPGL_Poll(void)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HPGL_Parser_ReceivingVelocity:
|
||||||
|
if(character == ';' || character == '\n')
|
||||||
|
{
|
||||||
|
// Command finished
|
||||||
|
state = HPGL_Parser_Idle;
|
||||||
|
}
|
||||||
|
else if(character >= '0' && character <= '9')
|
||||||
|
{
|
||||||
|
unsigned int digit = character - '0';
|
||||||
|
current_velocity = current_velocity * 10 + digit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The VS command could come with a pen number after a comma.
|
||||||
|
// This is currently unsupported.
|
||||||
|
state = HPGL_Parser_Error;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case HPGL_Parser_Error:
|
case HPGL_Parser_Error:
|
||||||
// Exit error state only after end of command
|
// Exit error state only after end of command
|
||||||
if(character == '\n' || character == ';')
|
if(character == '\n' || character == ';')
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bool pen_down;
|
bool pen_down;
|
||||||
|
unsigned char velocity;
|
||||||
unsigned int x;
|
unsigned int x;
|
||||||
unsigned int y;
|
unsigned int y;
|
||||||
} HPGL_Movement_t;
|
} HPGL_Movement_t;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ static Output_Coordinate_t Output_CurrentLineStart = {0, 0};
|
||||||
static Output_Coordinate_t Output_CurrentLineEnd = {0, 0};
|
static Output_Coordinate_t Output_CurrentLineEnd = {0, 0};
|
||||||
static unsigned int Output_CurrentLineLength;
|
static unsigned int Output_CurrentLineLength;
|
||||||
static unsigned int Output_CurrentLinePosition;
|
static unsigned int Output_CurrentLinePosition;
|
||||||
static unsigned int Output_CurrentVelocity = OUTPUT_LENGTH_SCALE / 3;
|
static unsigned int Output_CurrentVelocity = OUTPUT_DEFAULT_VELOCITY;
|
||||||
|
|
||||||
bool Output_EnqueueMovement(HPGL_Movement_t movement)
|
bool Output_EnqueueMovement(HPGL_Movement_t movement)
|
||||||
{
|
{
|
||||||
|
|
@ -52,6 +52,10 @@ bool Output_EnqueueMovement(HPGL_Movement_t movement)
|
||||||
{
|
{
|
||||||
movement.y = OUTPUT_COORDINATE_LIMIT;
|
movement.y = OUTPUT_COORDINATE_LIMIT;
|
||||||
}
|
}
|
||||||
|
if(movement.velocity > OUTPUT_MAXIMUM_VELOCITY)
|
||||||
|
{
|
||||||
|
movement.velocity = OUTPUT_MAXIMUM_VELOCITY;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(Output_BufferWrite, &movement, sizeof(HPGL_Movement_t));
|
memcpy(Output_BufferWrite, &movement, sizeof(HPGL_Movement_t));
|
||||||
Output_BufferWrite++;
|
Output_BufferWrite++;
|
||||||
|
|
@ -128,6 +132,7 @@ static bool Output_FetchNextPoint(void)
|
||||||
Output_CurrentLineEnd.x - Output_CurrentLineStart.x,
|
Output_CurrentLineEnd.x - Output_CurrentLineStart.x,
|
||||||
Output_CurrentLineEnd.y - Output_CurrentLineStart.y);
|
Output_CurrentLineEnd.y - Output_CurrentLineStart.y);
|
||||||
Output_CurrentLinePosition = 0;
|
Output_CurrentLinePosition = 0;
|
||||||
|
Output_CurrentVelocity = movement->velocity;
|
||||||
|
|
||||||
Output_BufferRead++;
|
Output_BufferRead++;
|
||||||
if(Output_BufferRead >= Output_Buffer + CONFIG_BUFFER_MOVEMENTS)
|
if(Output_BufferRead >= Output_Buffer + CONFIG_BUFFER_MOVEMENTS)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@
|
||||||
// overflows during coordinate calculations.
|
// overflows during coordinate calculations.
|
||||||
#define OUTPUT_LENGTH_SCALE (1 << 3)
|
#define OUTPUT_LENGTH_SCALE (1 << 3)
|
||||||
|
|
||||||
|
// If no velocity is sett via a ‘VS’ command or ‘VN’ is invoked, use this
|
||||||
|
// velocity setting
|
||||||
|
#define OUTPUT_DEFAULT_VELOCITY (OUTPUT_LENGTH_SCALE / 3)
|
||||||
|
#define OUTPUT_MAXIMUM_VELOCITY (OUTPUT_LENGTH_SCALE) // TODO: Check value
|
||||||
|
|
||||||
// Delay after initiating pen-up/-down before continuing movements
|
// Delay after initiating pen-up/-down before continuing movements
|
||||||
#define OUTPUT_PEN_UP_DELAY 200 // In movement timer ticks
|
#define OUTPUT_PEN_UP_DELAY 200 // In movement timer ticks
|
||||||
#define OUTPUT_PEN_DOWN_DELAY 20 // In movement timer ticks
|
#define OUTPUT_PEN_DOWN_DELAY 20 // In movement timer ticks
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue