diff --git a/buttons.h b/buttons.h index 376321d..4a4e799 100644 --- a/buttons.h +++ b/buttons.h @@ -27,10 +27,10 @@ #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 JOYSTICK_UPPER_PRESS_THRESHOLD 3595 // above this ADC value, button is pressed -#define JOYSTICK_UPPER_RELEASE_THRESHOLD 3095 // below this ADC value, button is released -#define JOYSTICK_LOWER_PRESS_THRESHOLD 500 // below this ADC value, button is pressed -#define JOYSTICK_LOWER_RELEASE_THRESHOLD 1000 // above this ADC value, button is released +#define JOYSTICK_UPPER_PRESS_THRESHOLD 2100 // above this ADC value, button is pressed +#define JOYSTICK_UPPER_RELEASE_THRESHOLD 2000 // below this ADC value, button is released +#define JOYSTICK_LOWER_PRESS_THRESHOLD 1700 // below this ADC value, button is pressed +#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 CRYSTAL_FREQUENCY 25000000 // [Hz] crystal oscillator frequency used to calculate clock rates diff --git a/main.c b/main.c index f06040e..f13cd1f 100644 --- a/main.c +++ b/main.c @@ -60,13 +60,13 @@ int main(void) GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ 0, /*opaque*/ false); // 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"}; int offset = 20; uint32_t buttons = gButtons; uint8_t i; - for (i = 0; i < 5; i++) { + for (i = 0; i < 9; i++) { snprintf(str, sizeof(str), "%s: %s", labels[i], statuses[buttons & 1]