Skip to content

Chain_Joystick.ino:42:107: error: 'opr_status' was not declared in this scope; did you mean 'work_status_t'? #2

@lboue

Description

@lboue

Describe the bug

Chain_Joystick.ino:42:107: error: 'opr_status' was not declared in this scope; did you mean 'work_status_t'?

To reproduce

Builds example from the tutorial: https://docs.m5stack.com/en/arduino/projects/chain/chain_joystick

#include "M5Chain.h"

#define RXD_PIN GPIO_NUM_5  // 47 for the other side of Chain DualKey
#define TXD_PIN GPIO_NUM_6  // 48 for the other side of Chain DualKey

Chain M5Chain;

device_list_t *device_list = NULL;
uint16_t device_count = 0;

int16_t x_value, y_value;
uint8_t button_status;
chain_button_press_type_t button_press_type;

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("===========================");
  Serial.println("M5Stack Chain Joystick Test");

  M5Chain.begin(&Serial2, 115200, RXD_PIN, TXD_PIN);
  while (!M5Chain.isDeviceConnected()) {
    Serial.println("No device connected");
    delay(1000);
  }

  M5Chain.getDeviceNum(&device_count);
  device_list = (device_list_t *)malloc(sizeof(device_list_t));
  device_list->count = device_count;
  device_list->devices = (device_info_t *)malloc(sizeof(device_info_t) * device_count);
  M5Chain.getDeviceList(device_list);

  if (device_list->devices[0].device_type == CHAIN_JOYSTICK_TYPE_CODE) {
    Serial.println("ID[1] is Chain Joystick\n");
    delay(1000);
  } else {
    Serial.println("ID[1] is NOT Chain Joystick\n");
    return;
  }

  // Device ID, double click interval (100MS/200MS/.../900MS/1000MS), long press interval (3S/4S/.../9S/10S), operation status
  M5Chain.setJoystickButtonTriggerInterval(1, BUTTON_DOUBLE_CLICK_TIME_500MS, BUTTON_LONG_PRESS_TIME_5S, &opr_status);
  Serial.println("Set double and long press intervals\n");
  delay(1000);
}

void loop() {
  M5Chain.getJoystickMappedInt16Value(1, &x_value, &y_value);  // Device ID
  Serial.print("x_value:");
  Serial.println(x_value);
  Serial.print("y_value:");
  Serial.println(y_value);

  M5Chain.getJoystickButtonStatus(1, &button_status);  // Device ID
  Serial.print("button_status:");
  Serial.println(button_status);

  while (M5Chain.getJoystickButtonPressStatus(1, &button_press_type)) {  // Device ID
    switch (button_press_type) {
      case CHAIN_BUTTON_PRESS_SINGLE:
        Serial.println("Single pressed");
        break;
      case CHAIN_BUTTON_PRESS_DOUBLE:
        Serial.println("Double pressed");
        break;
      case CHAIN_BUTTON_PRESS_LONG:
        Serial.println("Long pressed");
        break;
    }
  }
} 

Expected behavior

Build example

Screenshots

No response

Environment

  • OS: Windows 11
  • IDE &IDE Version: Arduino IDE 2.3.6
  • Repository Version:

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions