From 9a55e14e6ec1c05dfc3a6a7a9bc1b9c879207cad Mon Sep 17 00:00:00 2001 From: zer0 Date: Sat, 3 Apr 2010 15:01:51 +0200 Subject: [PATCH 1/1] cobboard updated --- projects/microb2010/cobboard/actuator.c | 1 + projects/microb2010/cobboard/commands_cobboard.c | 6 ++---- projects/microb2010/cobboard/i2c_protocol.c | 12 ++++++------ projects/microb2010/cobboard/main.c | 4 ++-- projects/microb2010/cobboard/main.h | 2 ++ projects/microb2010/cobboard/shovel.h | 2 +- projects/microb2010/cobboard/state.c | 11 +++++++++-- projects/microb2010/cobboard/state.h | 2 ++ 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/projects/microb2010/cobboard/actuator.c b/projects/microb2010/cobboard/actuator.c index 4606540..cebcd2a 100644 --- a/projects/microb2010/cobboard/actuator.c +++ b/projects/microb2010/cobboard/actuator.c @@ -46,6 +46,7 @@ #include "actuator.h" #define COBROLLER_SPEED 800 +//#define COBROLLER_SPEED 400 #define SERVO_DOOR_OPEN 250 #define SERVO_DOOR_CLOSED 470 diff --git a/projects/microb2010/cobboard/commands_cobboard.c b/projects/microb2010/cobboard/commands_cobboard.c index eb77cba..888d15a 100644 --- a/projects/microb2010/cobboard/commands_cobboard.c +++ b/projects/microb2010/cobboard/commands_cobboard.c @@ -53,8 +53,6 @@ #include "spickle.h" #include "shovel.h" -extern uint16_t state_debug; - struct cmd_event_result { fixed_string_t arg0; fixed_string_t arg1; @@ -68,7 +66,7 @@ static void cmd_event_parsed(void *parsed_result, __attribute__((unused)) void * u08 bit=0; struct cmd_event_result * res = parsed_result; - + if (!strcmp_P(res->arg1, PSTR("all"))) { bit = DO_ENCODERS | DO_CS | DO_BD | DO_POWER; if (!strcmp_P(res->arg2, PSTR("on"))) @@ -374,7 +372,7 @@ prog_char str_state_debug_arg0[] = "state_debug"; parse_pgm_token_string_t cmd_state_debug_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_debug_result, arg0, str_state_debug_arg0); parse_pgm_token_num_t cmd_state_debug_on = TOKEN_NUM_INITIALIZER(struct cmd_state_debug_result, on, UINT8); -prog_char help_state_debug[] = "Set debug timer for state machine"; +prog_char help_state_debug[] = "Set debug for state machine"; parse_pgm_inst_t cmd_state_debug = { .f = cmd_state_debug_parsed, /* function to call */ .data = NULL, /* 2nd arg of func */ diff --git a/projects/microb2010/cobboard/i2c_protocol.c b/projects/microb2010/cobboard/i2c_protocol.c index 77846d0..9de2d4c 100644 --- a/projects/microb2010/cobboard/i2c_protocol.c +++ b/projects/microb2010/cobboard/i2c_protocol.c @@ -113,21 +113,21 @@ static int8_t i2c_set_mode(struct i2c_cmd_cobboard_set_mode *cmd) void i2c_recvevent(uint8_t * buf, int8_t size) { void *void_cmd = buf; - + static uint8_t a = 0; - + a++; if (a & 0x10) LED2_TOGGLE(); - + if (size <= 0) { goto error; } - + switch (buf[0]) { /* Commands (no answer needed) */ - case I2C_CMD_GENERIC_LED_CONTROL: + case I2C_CMD_GENERIC_LED_CONTROL: { struct i2c_cmd_led_control *cmd = void_cmd; if (size != sizeof (*cmd)) @@ -135,7 +135,7 @@ void i2c_recvevent(uint8_t * buf, int8_t size) i2c_led_control(cmd->led_num, cmd->state); break; } - + case I2C_CMD_COBBOARD_SET_MODE: { struct i2c_cmd_cobboard_set_mode *cmd = void_cmd; diff --git a/projects/microb2010/cobboard/main.c b/projects/microb2010/cobboard/main.c index 8ba5d52..39318d9 100755 --- a/projects/microb2010/cobboard/main.c +++ b/projects/microb2010/cobboard/main.c @@ -253,7 +253,7 @@ int main(void) spickle_init(); shovel_init(); -/* state_init(); */ + state_init(); printf_P(PSTR("\r\n")); printf_P(PSTR("Dass das Gluck deinen Haus setzt.\r\n")); @@ -263,7 +263,7 @@ int main(void) gen.log_level = 5; cobboard.flags |= DO_CS; -/* state_machine(); */ + state_machine(); cmdline_interact(); return 0; diff --git a/projects/microb2010/cobboard/main.h b/projects/microb2010/cobboard/main.h index dce4825..a0dbac8 100755 --- a/projects/microb2010/cobboard/main.h +++ b/projects/microb2010/cobboard/main.h @@ -50,6 +50,8 @@ #define RIGHT_SPICKLE_ENCODER ((void *)1) #define SHOVEL_ENCODER ((void *)2) +#define SERVO_DOOR_PWM ((void *)&gen.servo2) + #define LEFT_SPICKLE_PWM ((void *)&gen.pwm1_4A) #define RIGHT_SPICKLE_PWM ((void *)&gen.pwm2_4B) #define SHOVEL_PWM ((void *)&gen.pwm3_1A) diff --git a/projects/microb2010/cobboard/shovel.h b/projects/microb2010/cobboard/shovel.h index 1f2e53b..7ba8445 100644 --- a/projects/microb2010/cobboard/shovel.h +++ b/projects/microb2010/cobboard/shovel.h @@ -23,7 +23,7 @@ #define _SHOVEL_H_ #define SHOVEL_DOWN 100 -#define SHOVEL_MID 4000 +#define SHOVEL_MID 6000 #define SHOVEL_UP 10000 void shovel_init(void); diff --git a/projects/microb2010/cobboard/state.c b/projects/microb2010/cobboard/state.c index 8e8affc..2903a4a 100644 --- a/projects/microb2010/cobboard/state.c +++ b/projects/microb2010/cobboard/state.c @@ -139,6 +139,7 @@ static uint8_t state_want_exit(void) return 0; if (vt100_parser(&local_vt100, c) == KEY_CTRL_C) return 1; + printf_P(PSTR("CTRL-C\r\n")); return 0; } @@ -155,7 +156,7 @@ static void state_do_harvest(uint8_t side) /* if there is no cob, return */ if (state_cob_present(side)) return; - + /* if it is black, nothing to do */ if (state_cob_color(side) == I2C_COB_BLACK) return; @@ -163,6 +164,9 @@ static void state_do_harvest(uint8_t side) /* eat the cob */ spickle_pack(side); state_debug_wait_key_pressed(); + /* xxx */ + time_wait_ms(250); + left_cobroller_on(); delay = spickle_get_pack_delay(side); time_wait_ms(delay); @@ -177,7 +181,9 @@ static void state_do_harvest(uint8_t side) wait_ms(200); state_debug_wait_key_pressed(); shovel_down(); + left_cobroller_off(); state_debug_wait_key_pressed(); + time_wait_ms(500); } /* eject cobs */ @@ -205,7 +211,8 @@ void state_machine(void) /* pack/deply spickles, enable/disable roller */ if (L_DEPLOY(state_mode)) { spickle_deploy(I2C_LEFT_SIDE); - left_cobroller_on(); + //left_cobroller_on(); + left_cobroller_off(); } else { spickle_pack(I2C_LEFT_SIDE); diff --git a/projects/microb2010/cobboard/state.h b/projects/microb2010/cobboard/state.h index 118926a..8dcb6c1 100644 --- a/projects/microb2010/cobboard/state.h +++ b/projects/microb2010/cobboard/state.h @@ -35,4 +35,6 @@ void state_machine(void); void state_init(void); +extern uint8_t state_debug; + #endif -- 2.20.1