Skip to content

Commit

Permalink
move definition of NC input range to src_nunchuk.c
Browse files Browse the repository at this point in the history
  • Loading branch information
wertarbyte committed Jul 2, 2012
1 parent 02e5530 commit 48200b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion input.c
Expand Up @@ -23,7 +23,7 @@ int16_t get_input_range(uint8_t src, uint8_t max) {
#endif
#ifdef USE_NUNCHUK
case SRC_NUNCHUK:
val = (max ? -1 : 1)*(SRC_NUM(src) == 0 ? 180 : 90);
val = nunchuk_get_range(SRC_NUM(src), max);
break;
#endif
case SRC_DS: /* SRC_DS will not yield a return value */
Expand Down
16 changes: 16 additions & 0 deletions src_nunchuk.c
Expand Up @@ -116,6 +116,22 @@ void nunchuk_query(void) {
}
}

int16_t nunchuk_get_range(uint8_t i, uint8_t max) {
switch (i) {
case NC_PITCH:
return max ? 90 : -90;
break;
case NC_ROLL:
return max ? 180 : -180;
break;
case NC_JOY_X:
case NC_JOY_Y:
return max ? 255 : 0;
default:
return 0;
}
}

void nunchuk_init(void) {
twi_start(NUNCHUK_ADDR<<1);
twi_write(0xF0);
Expand Down
1 change: 1 addition & 0 deletions src_nunchuk.h
Expand Up @@ -2,3 +2,4 @@ void nunchuk_init(void);
void nunchuk_query(void);
int16_t nunchuk_get(uint8_t n);
int16_t nunchuk_get_raw(uint8_t n);
int16_t nunchuk_get_range(uint8_t i, uint8_t max);

0 comments on commit 48200b8

Please sign in to comment.