Skip to content

Commit

Permalink
minor code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
acornejo committed Jun 11, 2014
1 parent 8a15c1d commit d2a8ad7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
9 changes: 5 additions & 4 deletions kilolib.c
Expand Up @@ -195,6 +195,7 @@ void kilo_loop(void (*program)(void)) {
case MOVING:
if (cur_motion == MOVE_STOP) {
set_motors(0,0);
prev_motion = MOVE_STOP;
} else {
if (cur_motion != prev_motion) {
prev_motion = cur_motion;
Expand All @@ -207,6 +208,7 @@ void kilo_loop(void (*program)(void)) {
_delay_ms(15);
set_motors(0, kilo_turn_right);
} else {
set_motors(0, 0xFF);
set_motors(0xFF, 0xFF);
_delay_ms(15);
set_motors(kilo_straight_left, kilo_straight_right);
Expand Down Expand Up @@ -264,7 +266,6 @@ static inline void process_message() {
}
break;
case CALIB:
reset();
switch(calibmsg->mode) {
case CALIB_SAVE:
if (kilo_state == MOVING) {
Expand All @@ -285,23 +286,23 @@ static inline void process_message() {
case CALIB_TURN_LEFT:
if (cur_motion != MOVE_LEFT || kilo_turn_left != calibmsg->turn_left) {
prev_motion = MOVE_STOP;
kilo_turn_left = calibmsg->turn_left;
cur_motion = MOVE_LEFT;
kilo_turn_left = calibmsg->turn_left;
}
break;
case CALIB_TURN_RIGHT:
if (cur_motion != MOVE_RIGHT || kilo_turn_right != calibmsg->turn_right) {
prev_motion = MOVE_STOP;
kilo_turn_right = calibmsg->turn_right;
cur_motion = MOVE_RIGHT;
kilo_turn_right = calibmsg->turn_right;
}
break;
case CALIB_STRAIGHT:
if (cur_motion != MOVE_STRAIGHT || kilo_straight_right != calibmsg->straight_right || kilo_straight_left != calibmsg->straight_left) {
prev_motion = MOVE_STOP;
cur_motion = MOVE_STRAIGHT;
kilo_straight_left = calibmsg->straight_left;
kilo_straight_right = calibmsg->straight_right;
cur_motion = MOVE_STRAIGHT;
}
break;
}
Expand Down
3 changes: 1 addition & 2 deletions ohc.c
Expand Up @@ -2,11 +2,10 @@
#include <avr/interrupt.h> // for ISR
#include <util/delay.h> // for _delay_ms
#include <string.h> // for memcpy
#include "message.h"
#include "ohc.h" // for message definitions
#include "message_crc.h"
#include "message_send.h"
#include "bootldr.h"
#include "ohc.h"

uint8_t packet_buffer[PACKET_SIZE];
uint8_t packet_head = 0;
Expand Down
29 changes: 15 additions & 14 deletions ohc.h
Expand Up @@ -2,6 +2,21 @@
#define __OHC_H__

#include <stdint.h>
#include "message.h"

// 01010101
#define PACKET_HEADER 0x55
#define PAGE_SIZE 128
#define PACKET_SIZE (PAGE_SIZE+4)
enum {
PACKET_STOP,
PACKET_LEDTOGGLE,
PACKET_FORWARDMSG,
PACKET_FORWARDRAWMSG,
PACKET_BOOTPAGE,
PACKET_GPSFRAME,
PACKET_FORWARDMSGSINGLE,
};

typedef struct {
uint16_t id;
Expand Down Expand Up @@ -29,18 +44,4 @@ enum {
CALIB_STRAIGHT
};

// 01010101
#define PACKET_HEADER 0x55
#define PAGE_SIZE 128
#define PACKET_SIZE (PAGE_SIZE+4)
enum {
PACKET_STOP,
PACKET_LEDTOGGLE,
PACKET_FORWARDMSG,
PACKET_FORWARDRAWMSG,
PACKET_BOOTPAGE,
PACKET_GPSFRAME,
PACKET_FORWARDMSGSINGLE,
};

#endif//__OHC_H__

0 comments on commit d2a8ad7

Please sign in to comment.