display joystick status
also changed thresholds to account for drift
This commit is contained in:
parent
c6caef7ba0
commit
ed4d083358
2 changed files with 6 additions and 6 deletions
|
@ -27,10 +27,10 @@
|
||||||
#define BUTTON_AUTOREPEAT_INITIAL 100 // how many samples must read pressed before autorepeat starts
|
#define BUTTON_AUTOREPEAT_INITIAL 100 // how many samples must read pressed before autorepeat starts
|
||||||
#define BUTTON_AUTOREPEAT_NEXT 10 // how many samples must read pressed before the next repetition
|
#define BUTTON_AUTOREPEAT_NEXT 10 // how many samples must read pressed before the next repetition
|
||||||
|
|
||||||
#define JOYSTICK_UPPER_PRESS_THRESHOLD 3595 // above this ADC value, button is pressed
|
#define JOYSTICK_UPPER_PRESS_THRESHOLD 2100 // above this ADC value, button is pressed
|
||||||
#define JOYSTICK_UPPER_RELEASE_THRESHOLD 3095 // below this ADC value, button is released
|
#define JOYSTICK_UPPER_RELEASE_THRESHOLD 2000 // below this ADC value, button is released
|
||||||
#define JOYSTICK_LOWER_PRESS_THRESHOLD 500 // below this ADC value, button is pressed
|
#define JOYSTICK_LOWER_PRESS_THRESHOLD 1700 // below this ADC value, button is pressed
|
||||||
#define JOYSTICK_LOWER_RELEASE_THRESHOLD 1000 // above this ADC value, button is released
|
#define JOYSTICK_LOWER_RELEASE_THRESHOLD 1800 // above this ADC value, button is released
|
||||||
|
|
||||||
#define ADC_SAMPLING_RATE 1000000 // [samples/sec] desired ADC sampling rate
|
#define ADC_SAMPLING_RATE 1000000 // [samples/sec] desired ADC sampling rate
|
||||||
#define CRYSTAL_FREQUENCY 25000000 // [Hz] crystal oscillator frequency used to calculate clock rates
|
#define CRYSTAL_FREQUENCY 25000000 // [Hz] crystal oscillator frequency used to calculate clock rates
|
||||||
|
|
4
main.c
4
main.c
|
@ -60,13 +60,13 @@ int main(void)
|
||||||
GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ 0, /*opaque*/ false);
|
GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ 0, /*opaque*/ false);
|
||||||
|
|
||||||
// display button statuses
|
// display button statuses
|
||||||
char labels[5][4] = {"sw1", "sw2", "s1", "s2", "sel"};
|
char labels[9][7] = {"sw1", "sw2", "s1", "s2", "sel", "right", "left", "up", "down"};
|
||||||
char statuses[2][15] = {"not pressed", "pressed"};
|
char statuses[2][15] = {"not pressed", "pressed"};
|
||||||
int offset = 20;
|
int offset = 20;
|
||||||
uint32_t buttons = gButtons;
|
uint32_t buttons = gButtons;
|
||||||
|
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 9; i++) {
|
||||||
snprintf(str, sizeof(str), "%s: %s",
|
snprintf(str, sizeof(str), "%s: %s",
|
||||||
labels[i],
|
labels[i],
|
||||||
statuses[buttons & 1]
|
statuses[buttons & 1]
|
||||||
|
|
Loading…
Reference in a new issue