fix touch
This commit is contained in:
56
basic1.cpp
56
basic1.cpp
@@ -308,6 +308,27 @@ int main()
|
|||||||
renderer.set_font(&font_5x5_obj);
|
renderer.set_font(&font_5x5_obj);
|
||||||
LowLevelGUI gui = LowLevelGUI(&renderer, font_BMplain_obj);
|
LowLevelGUI gui = LowLevelGUI(&renderer, font_BMplain_obj);
|
||||||
|
|
||||||
|
// Initialize touch screen using abstraction FIRST (before InputManager needs it)
|
||||||
|
touch = LowLevelTouch::create((TouchType)TOUCH_TYPE_SELECTED, V_WIDTH, V_HEIGHT,
|
||||||
|
TOUCH_SWAP_XY, TOUCH_INVERT_X, TOUCH_INVERT_Y);
|
||||||
|
|
||||||
|
if (touch) {
|
||||||
|
printf("Touch initialized successfully\n");
|
||||||
|
|
||||||
|
// Set up interrupt-driven touch detection
|
||||||
|
printf("Setting up touch interrupt callback...\n");
|
||||||
|
touch->set_interrupt_callback(touch_interrupt_handler);
|
||||||
|
printf("Touch interrupt enabled on INT pin (falling and rising edges)\n");
|
||||||
|
|
||||||
|
// Run communication test if available
|
||||||
|
// Note: Commented out as it may hang on some hardware configurations
|
||||||
|
printf("\nRunning touch reliability test...\n");
|
||||||
|
touch->test_communication();
|
||||||
|
printf("...\n");
|
||||||
|
} else {
|
||||||
|
printf("Touch initialization failed or not configured\n");
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize game configuration
|
// Initialize game configuration
|
||||||
GameConfig config = {
|
GameConfig config = {
|
||||||
.touch_debounce_ms = 10,
|
.touch_debounce_ms = 10,
|
||||||
@@ -317,7 +338,7 @@ int main()
|
|||||||
.debug_verbose = false
|
.debug_verbose = false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create InputManager for processing inputs
|
// Create InputManager for processing inputs (touch must be initialized first!)
|
||||||
InputManager input_manager(touch, &config);
|
InputManager input_manager(touch, &config);
|
||||||
|
|
||||||
// Create GameLauncher
|
// Create GameLauncher
|
||||||
@@ -340,27 +361,6 @@ int main()
|
|||||||
// Refresh the screen with the launcher menu (async on Core 1)
|
// Refresh the screen with the launcher menu (async on Core 1)
|
||||||
refresh_screen_async(bit_buffer, display);
|
refresh_screen_async(bit_buffer, display);
|
||||||
printf("Initial screen refresh queued on Core 1\n");
|
printf("Initial screen refresh queued on Core 1\n");
|
||||||
|
|
||||||
// Initialize touch screen using abstraction
|
|
||||||
touch = LowLevelTouch::create((TouchType)TOUCH_TYPE_SELECTED, V_WIDTH, V_HEIGHT,
|
|
||||||
TOUCH_SWAP_XY, TOUCH_INVERT_X, TOUCH_INVERT_Y);
|
|
||||||
|
|
||||||
if (touch) {
|
|
||||||
printf("Touch initialized successfully\n");
|
|
||||||
|
|
||||||
// Set up interrupt-driven touch detection
|
|
||||||
printf("Setting up touch interrupt callback...\n");
|
|
||||||
touch->set_interrupt_callback(touch_interrupt_handler);
|
|
||||||
printf("Touch interrupt enabled on INT pin (falling and rising edges)\n");
|
|
||||||
|
|
||||||
// Run communication test if available
|
|
||||||
// Note: Commented out as it may hang on some hardware configurations
|
|
||||||
printf("\nRunning touch reliability test...\n");
|
|
||||||
touch->test_communication();
|
|
||||||
printf("...\n");
|
|
||||||
} else {
|
|
||||||
printf("Touch initialization failed or not configured\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef BUTTON_KEY0_PIN
|
#ifdef BUTTON_KEY0_PIN
|
||||||
// Initialize hardware buttons (e-ink board only)
|
// Initialize hardware buttons (e-ink board only)
|
||||||
@@ -434,10 +434,22 @@ int main()
|
|||||||
// 2. Process touch input (if no button was pressed)
|
// 2. Process touch input (if no button was pressed)
|
||||||
if (!input.valid) {
|
if (!input.valid) {
|
||||||
input = input_manager.process_touch_input(&last_touch_time);
|
input = input_manager.process_touch_input(&last_touch_time);
|
||||||
|
// if debugging enabled, print touch event
|
||||||
|
if (input.valid && config.debug_verbose) {
|
||||||
|
printf("Touch Event: type=%d, x=%d, y=%d, pressure=%d, gesture=0x%02X\n",
|
||||||
|
input.type, input.x, input.y, input.pressure, input.gesture_code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Process input based on current state
|
// 3. Process input based on current state
|
||||||
if (input.valid) {
|
if (input.valid) {
|
||||||
|
// if debugging enabled, print input event
|
||||||
|
if (config.debug_verbose) {
|
||||||
|
printf("Input Event: type=%d, x=%d, y=%d, gesture=0x%02X, button=%d, pressure=%d\n",
|
||||||
|
input.type, input.x, input.y, input.gesture_code,
|
||||||
|
input.button_id, input.pressure);
|
||||||
|
}
|
||||||
|
|
||||||
if (launcher.is_game_selected()) {
|
if (launcher.is_game_selected()) {
|
||||||
// In game mode - process game input
|
// In game mode - process game input
|
||||||
current_game = launcher.get_selected_game();
|
current_game = launcher.get_selected_game();
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// ---- SELECT YOUR BOARD HERE ----
|
// ---- SELECT YOUR BOARD HERE ----
|
||||||
// #define BOARD_FEATHER_TFT // Feather RP2350 + 4.0" TFT ST7796
|
#define BOARD_FEATHER_TFT // Feather RP2350 + 4.0" TFT ST7796
|
||||||
// #define BOARD_PICO2_TFT // Pico 2 + 4.0" TFT ST7796
|
// #define BOARD_PICO2_TFT // Pico 2 + 4.0" TFT ST7796
|
||||||
#define BOARD_PICO2_EINK // Pico 2 + E-Ink Display
|
// #define BOARD_PICO2_EINK // Pico 2 + E-Ink Display
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -90,3 +90,15 @@ echo ""
|
|||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
|
echo ""
|
||||||
|
echo "Waiting 0.5 seconds before connecting to serial..."
|
||||||
|
sleep 0.5
|
||||||
|
echo "Connecting to serial port /dev/cu.usbmodem101..."
|
||||||
|
echo "(Press Ctrl+A then K to exit screen)"
|
||||||
|
echo "Session will be logged to: screenlog.0"
|
||||||
|
echo ""
|
||||||
|
sleep 0.5
|
||||||
|
|
||||||
|
# Connect to serial port with logging enabled
|
||||||
|
# -L enables logging to screenlog.0 in the current directory
|
||||||
|
screen -L /dev/cu.usbmodem101
|
||||||
|
|||||||
Reference in New Issue
Block a user