Bye bye Wii Motion Plus, hello MPU6050. Also, increase control loop

to 200Hz, add SD card logging, and a number of other changes.
This commit is contained in:
2014-05-06 21:03:48 +00:00
parent b482b85ffd
commit e8adff93c1
25 changed files with 1725 additions and 581 deletions

36
panic.c
View File

@@ -13,17 +13,38 @@
#include "motor.h"
#include "led.h"
#ifdef PANIC_CHECKPOINT
unsigned int checkpoint;
#endif
#ifdef PANIC_32BIT
#define PANIC_BITS 32
#else
#define PANIC_BITS 16
#endif
#ifdef PANIC_32BIT
led_pattern led_pattern_panic[] = {100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 3000, 0};
#else
led_pattern led_pattern_panic[] = {100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 3000, 0};
#endif
/* Take the lower 16 bits and make a pattern of them, MSB first */
static void panic_create_pattern(led_pattern *pattern, unsigned int reason)
{
int i;
for (i = 0; i < 16; i++) {
if (reason & (1<<(15-i))) {
for (i = 0; i < PANIC_BITS; i++) {
if (reason & (1<<((PANIC_BITS-1)-i))) {
pattern[2*i] = 400;
pattern[2*i+1] = 100;
} else {
@@ -32,19 +53,16 @@ static void panic_create_pattern(led_pattern *pattern, unsigned int reason)
}
if ((i % 4) == 3)
pattern[2*i+1] += 500;
if (i == 15)
if (i == (PANIC_BITS-1))
pattern[2*i+1] += 2500;
}
}
void panic(unsigned int reason)
{
/*
* We may one day be able to do something with the reason, like emit
* a final deathbed confession. So we'll provide the reasons in the
* caller and just ignore them for now.
*/
(void)reason;
#if PANIC_CHECKPOINT
reason = checkpoint;
#endif
motor_kill();