为什么 ADK 的 demokit 程序无法在 Arduino 中编译?

发布于 2024-12-22 11:22:13 字数 10107 浏览 0 评论 0原文

我对 Arduino 和 Java 有很好的了解,因此我决定尝试用我的 Samsung Galaxy 10.1 选项卡来控制我的 Arduino ATMega。我已经安装了带有 SDK 管理器的 API 12、Eclipse 的 ADT 插件,现在我正在按照 安装 Arduino 软件和必要的库(位于Android 开放配件开发套件)以安装 ADK 板的固件。当我点击编译时,它给了我两个错误:

demokit:146: 错误:“acc”未在此范围内声明

demokit:249: 错误:“touch_robot”未在此范围内声明

并表示

“AndroidAccessory”未命名类型。

代码如下所示:

#include <Wire.h>
#include <Servo.h>

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

#include <CapSense.h>

#define  LED3_RED       2
#define  LED3_GREEN     4
#define  LED3_BLUE      3

#define  LED2_RED       5
#define  LED2_GREEN     7
#define  LED2_BLUE      6

#define  LED1_RED       8
#define  LED1_GREEN     10
#define  LED1_BLUE      9

#define  SERVO1         11
#define  SERVO2         12
#define  SERVO3         13

#define  TOUCH_RECV     14
#define  TOUCH_SEND     15

#define  RELAY1         A0
#define  RELAY2         A1

#define  LIGHT_SENSOR   A2
#define  TEMP_SENSOR    A3

#define  BUTTON1        A6
#define  BUTTON2        A7
#define  BUTTON3        A8

#define  JOY_SWITCH     A9      // pulls line down when pressed
#define  JOY_nINT       A10     // active low interrupt input
#define  JOY_nRESET     A11     // active low reset output

AndroidAccessory acc("Google, Inc.",
                     "DemoKit",
                     "DemoKit Arduino Board",
                     "1.0",
                     "http://www.android.com",
                     "0000000012345678");
Servo servos[3];

// 10 Mohm resistor on demo shield
CapSense   touch_robot = CapSense(TOUCH_SEND, TOUCH_RECV);

void setup();
void loop();

void init_buttons()
{
    pinMode(BUTTON1, INPUT);
    pinMode(BUTTON2, INPUT);
    pinMode(BUTTON3, INPUT);
    pinMode(JOY_SWITCH, INPUT);

    // enable the internal pullups
    digitalWrite(BUTTON1, HIGH);
    digitalWrite(BUTTON2, HIGH);
    digitalWrite(BUTTON3, HIGH);
    digitalWrite(JOY_SWITCH, HIGH);
}

void init_relays()
{
    pinMode(RELAY1, OUTPUT);
    pinMode(RELAY2, OUTPUT);
}

void init_LEDs()
{
    digitalWrite(LED1_RED, 1);
    digitalWrite(LED1_GREEN, 1);
    digitalWrite(LED1_BLUE, 1);

    pinMode(LED1_RED, OUTPUT);
    pinMode(LED1_GREEN, OUTPUT);
    pinMode(LED1_BLUE, OUTPUT);

    digitalWrite(LED2_RED, 1);
    digitalWrite(LED2_GREEN, 1);
    digitalWrite(LED2_BLUE, 1);

    pinMode(LED2_RED, OUTPUT);
    pinMode(LED2_GREEN, OUTPUT);
    pinMode(LED2_BLUE, OUTPUT);

    digitalWrite(LED3_RED, 1);
    digitalWrite(LED3_GREEN, 1);
    digitalWrite(LED3_BLUE, 1);

    pinMode(LED3_RED, OUTPUT);
    pinMode(LED3_GREEN, OUTPUT);
    pinMode(LED3_BLUE, OUTPUT);
}

void init_joystick(int threshold);

byte b1, b2, b3, b4, c;
void setup()
{
    Serial.begin(115200);
    Serial.print("\r\nStart");

    init_LEDs();
    init_relays();
    init_buttons();
    init_joystick( 5 );

    // autocalibrate OFF
    touch_robot.set_CS_AutocaL_Millis(0xFFFFFFFF);

    servos[0].attach(SERVO1);
    servos[0].write(90);
    servos[1].attach(SERVO2);
    servos[1].write(90);
    servos[2].attach(SERVO3);
    servos[2].write(90);

    b1 = digitalRead(BUTTON1);
    b2 = digitalRead(BUTTON2);
    b3 = digitalRead(BUTTON3);
    b4 = digitalRead(JOY_SWITCH);
    c = 0;

    acc.powerOn();
}

void loop()
{
    byte err;
    byte idle;
    static byte count = 0;
    byte msg[3];
    long touchcount;

    if (acc.isConnected()) {
        int len = acc.read(msg, sizeof(msg), 1);
        int i;
        byte b;
        uint16_t val;
        int x, y;
        char c0;

        if (len > 0) {
            // assumes only one command per packet
            if (msg[0] == 0x2) {
                if (msg[1] == 0x0)
                    analogWrite(LED1_RED, 255 - msg[2]);
                else if (msg[1] == 0x1)
                    analogWrite(LED1_GREEN, 255 - msg[2]);
                else if (msg[1] == 0x2)
                    analogWrite(LED1_BLUE, 255 - msg[2]);
                else if (msg[1] == 0x3)
                    analogWrite(LED2_RED, 255 - msg[2]);
                else if (msg[1] == 0x4)
                    analogWrite(LED2_GREEN, 255 - msg[2]);
                else if (msg[1] == 0x5)
                    analogWrite(LED2_BLUE, 255 - msg[2]);
                else if (msg[1] == 0x6)
                    analogWrite(LED3_RED, 255 - msg[2]);
                else if (msg[1] == 0x7)
                    analogWrite(LED3_GREEN, 255 - msg[2]);
                else if (msg[1] == 0x8)
                    analogWrite(LED3_BLUE, 255 - msg[2]);
                else if (msg[1] == 0x10)
                    servos[0].write(map(msg[2], 0, 255, 0, 180));
                else if (msg[1] == 0x11)
                    servos[1].write(map(msg[2], 0, 255, 0, 180));
                else if (msg[1] == 0x12)
                    servos[2].write(map(msg[2], 0, 255, 0, 180));
            } else if (msg[0] == 0x3) {
                if (msg[1] == 0x0)
                    digitalWrite(RELAY1, msg[2] ? HIGH : LOW);
                else if (msg[1] == 0x1)
                    digitalWrite(RELAY2, msg[2] ? HIGH : LOW);
            }
        }

        msg[0] = 0x1;

        b = digitalRead(BUTTON1);
        if (b != b1) {
            msg[1] = 0;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b1 = b;
        }

        b = digitalRead(BUTTON2);
        if (b != b2) {
            msg[1] = 1;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b2 = b;
        }

        b = digitalRead(BUTTON3);
        if (b != b3) {
            msg[1] = 2;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b3 = b;
        }

        b = digitalRead(JOY_SWITCH);
        if (b != b4) {
            msg[1] = 4;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b4 = b;
        }

        switch (count++ % 0x10) {
        case 0:
            val = analogRead(TEMP_SENSOR);
            msg[0] = 0x4;
            msg[1] = val >> 8;
            msg[2] = val & 0xff;
            acc.write(msg, 3);
            break;

        case 0x4:
            val = analogRead(LIGHT_SENSOR);
            msg[0] = 0x5;
            msg[1] = val >> 8;
            msg[2] = val & 0xff;
            acc.write(msg, 3);
            break;

        case 0x8:
            read_joystick(&x, &y);
            msg[0] = 0x6;
            msg[1] = constrain(x, -128, 127);
            msg[2] = constrain(y, -128, 127);
            acc.write(msg, 3);
            break;

        case 0xc:
            touchcount = touch_robot.capSense(5);

            c0 = touchcount > 750;

            if (c0 != c) {
                msg[0] = 0x1;
                msg[1] = 3;
                msg[2] = c0;
                acc.write(msg, 3);
                c = c0;
            }

            break;
        }
    }
    else {
        // reset outputs to default values on disconnect
        analogWrite(LED1_RED, 255);
        analogWrite(LED1_GREEN, 255);
        analogWrite(LED1_BLUE, 255);
        analogWrite(LED2_RED, 255);
        analogWrite(LED2_GREEN, 255);
        analogWrite(LED2_BLUE, 255);
        analogWrite(LED3_RED, 255);
        analogWrite(LED3_GREEN, 255);
        analogWrite(LED3_BLUE, 255);
        servos[0].write(90);
        servos[0].write(90);
        servos[0].write(90);
        digitalWrite(RELAY1, LOW);
        digitalWrite(RELAY2, LOW);
    }

    delay(10);
}

// ==============================================================================
// Austria Microsystems i2c Joystick
void init_joystick(int threshold)
{
    byte status = 0;

    pinMode(JOY_SWITCH, INPUT);
    digitalWrite(JOY_SWITCH, HIGH);

    pinMode(JOY_nINT, INPUT);
    digitalWrite(JOY_nINT, HIGH);

    pinMode(JOY_nRESET, OUTPUT);

    digitalWrite(JOY_nRESET, 1);
    delay(1);
    digitalWrite(JOY_nRESET, 0);
    delay(1);
    digitalWrite(JOY_nRESET, 1);

    Wire.begin();

    do {
        status = read_joy_reg(0x0f);
    } while ((status & 0xf0) != 0xf0);

    // invert magnet polarity setting, per datasheet
    write_joy_reg(0x2e, 0x86);

    calibrate_joystick(threshold);
}


int offset_X, offset_Y;

void calibrate_joystick(int dz)
{
    char iii;
    int x_cal = 0;
    int y_cal = 0;

    // Low Power Mode, 20ms auto wakeup
    // INTn output enabled
    // INTn active after each measurement
    // Normal (non-Reset) mode
    write_joy_reg(0x0f, 0x00);
    delay(1);

    // dummy read of Y_reg to reset interrupt
    read_joy_reg(0x11);

    for(iii = 0; iii != 16; iii++) {
        while(!joystick_interrupt()) {}

        x_cal += read_joy_reg(0x10);
        y_cal += read_joy_reg(0x11);
    }

    // Divide by 16 to get average
    offset_X = -(x_cal>>4);
    offset_Y = -(y_cal>>4);

    write_joy_reg(0x12, dz - offset_X);  // Xp, LEFT threshold for INTn
    write_joy_reg(0x13, -dz - offset_X);  // Xn, RIGHT threshold for INTn
    write_joy_reg(0x14, dz - offset_Y);  // Yp, UP threshold for INTn
    write_joy_reg(0x15, -dz - offset_Y);  // Yn, DOWN threshold for INTn

    // Dead zone threshold detect requested?
    if (dz)
        write_joy_reg(0x0f, 0x04);
}

void read_joystick(int *x, int *y)
{
    *x = read_joy_reg(0x10) + offset_X;
    *y = read_joy_reg(0x11) + offset_Y;  // reading Y clears the interrupt
}

char joystick_interrupt()
{
    return digitalRead(JOY_nINT) == 0;
}

#define  JOY_I2C_ADDR    0x40

char read_joy_reg(char reg_addr)
{
    char c;

    Wire.beginTransmission(JOY_I2C_ADDR);
    Wire.send(reg_addr);
    Wire.endTransmission();

    Wire.requestFrom(JOY_I2C_ADDR, 1);

    while(Wire.available())
        c = Wire.receive();

    return c;
}

void write_joy_reg(char reg_addr, char val)
{
    Wire.beginTransmission(JOY_I2C_ADDR);
    Wire.send(reg_addr);
    Wire.send(val);
    Wire.endTransmission();
}

顺便说一句,我什至尝试复制我的 arduino 目录中的 ADK_relsease_0512 文件夹,但仍然不起作用。提前致谢!

I have a pretty good understanding of Arduino and Java, and I decided to take a stab at trying to control my Arduino ATMega with my Samsung Galaxy 10.1 tab. I have installed API 12 with SDK manager, the ADT plugin for Eclipse, and now I am following the instructions from Installing the Arduino software and necessary libraries (at Android Open Accessory Development Kit) to install the firmware for the ADK board. When I hit compile it gives me two errors:

demokit:146: error: 'acc' was not declared in this scope

demokit:249: error: 'touch_robot' was not declared in this scope

and says

'AndroidAccessory' does not name a type.

The code looks like this:

#include <Wire.h>
#include <Servo.h>

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

#include <CapSense.h>

#define  LED3_RED       2
#define  LED3_GREEN     4
#define  LED3_BLUE      3

#define  LED2_RED       5
#define  LED2_GREEN     7
#define  LED2_BLUE      6

#define  LED1_RED       8
#define  LED1_GREEN     10
#define  LED1_BLUE      9

#define  SERVO1         11
#define  SERVO2         12
#define  SERVO3         13

#define  TOUCH_RECV     14
#define  TOUCH_SEND     15

#define  RELAY1         A0
#define  RELAY2         A1

#define  LIGHT_SENSOR   A2
#define  TEMP_SENSOR    A3

#define  BUTTON1        A6
#define  BUTTON2        A7
#define  BUTTON3        A8

#define  JOY_SWITCH     A9      // pulls line down when pressed
#define  JOY_nINT       A10     // active low interrupt input
#define  JOY_nRESET     A11     // active low reset output

AndroidAccessory acc("Google, Inc.",
                     "DemoKit",
                     "DemoKit Arduino Board",
                     "1.0",
                     "http://www.android.com",
                     "0000000012345678");
Servo servos[3];

// 10 Mohm resistor on demo shield
CapSense   touch_robot = CapSense(TOUCH_SEND, TOUCH_RECV);

void setup();
void loop();

void init_buttons()
{
    pinMode(BUTTON1, INPUT);
    pinMode(BUTTON2, INPUT);
    pinMode(BUTTON3, INPUT);
    pinMode(JOY_SWITCH, INPUT);

    // enable the internal pullups
    digitalWrite(BUTTON1, HIGH);
    digitalWrite(BUTTON2, HIGH);
    digitalWrite(BUTTON3, HIGH);
    digitalWrite(JOY_SWITCH, HIGH);
}

void init_relays()
{
    pinMode(RELAY1, OUTPUT);
    pinMode(RELAY2, OUTPUT);
}

void init_LEDs()
{
    digitalWrite(LED1_RED, 1);
    digitalWrite(LED1_GREEN, 1);
    digitalWrite(LED1_BLUE, 1);

    pinMode(LED1_RED, OUTPUT);
    pinMode(LED1_GREEN, OUTPUT);
    pinMode(LED1_BLUE, OUTPUT);

    digitalWrite(LED2_RED, 1);
    digitalWrite(LED2_GREEN, 1);
    digitalWrite(LED2_BLUE, 1);

    pinMode(LED2_RED, OUTPUT);
    pinMode(LED2_GREEN, OUTPUT);
    pinMode(LED2_BLUE, OUTPUT);

    digitalWrite(LED3_RED, 1);
    digitalWrite(LED3_GREEN, 1);
    digitalWrite(LED3_BLUE, 1);

    pinMode(LED3_RED, OUTPUT);
    pinMode(LED3_GREEN, OUTPUT);
    pinMode(LED3_BLUE, OUTPUT);
}

void init_joystick(int threshold);

byte b1, b2, b3, b4, c;
void setup()
{
    Serial.begin(115200);
    Serial.print("\r\nStart");

    init_LEDs();
    init_relays();
    init_buttons();
    init_joystick( 5 );

    // autocalibrate OFF
    touch_robot.set_CS_AutocaL_Millis(0xFFFFFFFF);

    servos[0].attach(SERVO1);
    servos[0].write(90);
    servos[1].attach(SERVO2);
    servos[1].write(90);
    servos[2].attach(SERVO3);
    servos[2].write(90);

    b1 = digitalRead(BUTTON1);
    b2 = digitalRead(BUTTON2);
    b3 = digitalRead(BUTTON3);
    b4 = digitalRead(JOY_SWITCH);
    c = 0;

    acc.powerOn();
}

void loop()
{
    byte err;
    byte idle;
    static byte count = 0;
    byte msg[3];
    long touchcount;

    if (acc.isConnected()) {
        int len = acc.read(msg, sizeof(msg), 1);
        int i;
        byte b;
        uint16_t val;
        int x, y;
        char c0;

        if (len > 0) {
            // assumes only one command per packet
            if (msg[0] == 0x2) {
                if (msg[1] == 0x0)
                    analogWrite(LED1_RED, 255 - msg[2]);
                else if (msg[1] == 0x1)
                    analogWrite(LED1_GREEN, 255 - msg[2]);
                else if (msg[1] == 0x2)
                    analogWrite(LED1_BLUE, 255 - msg[2]);
                else if (msg[1] == 0x3)
                    analogWrite(LED2_RED, 255 - msg[2]);
                else if (msg[1] == 0x4)
                    analogWrite(LED2_GREEN, 255 - msg[2]);
                else if (msg[1] == 0x5)
                    analogWrite(LED2_BLUE, 255 - msg[2]);
                else if (msg[1] == 0x6)
                    analogWrite(LED3_RED, 255 - msg[2]);
                else if (msg[1] == 0x7)
                    analogWrite(LED3_GREEN, 255 - msg[2]);
                else if (msg[1] == 0x8)
                    analogWrite(LED3_BLUE, 255 - msg[2]);
                else if (msg[1] == 0x10)
                    servos[0].write(map(msg[2], 0, 255, 0, 180));
                else if (msg[1] == 0x11)
                    servos[1].write(map(msg[2], 0, 255, 0, 180));
                else if (msg[1] == 0x12)
                    servos[2].write(map(msg[2], 0, 255, 0, 180));
            } else if (msg[0] == 0x3) {
                if (msg[1] == 0x0)
                    digitalWrite(RELAY1, msg[2] ? HIGH : LOW);
                else if (msg[1] == 0x1)
                    digitalWrite(RELAY2, msg[2] ? HIGH : LOW);
            }
        }

        msg[0] = 0x1;

        b = digitalRead(BUTTON1);
        if (b != b1) {
            msg[1] = 0;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b1 = b;
        }

        b = digitalRead(BUTTON2);
        if (b != b2) {
            msg[1] = 1;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b2 = b;
        }

        b = digitalRead(BUTTON3);
        if (b != b3) {
            msg[1] = 2;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b3 = b;
        }

        b = digitalRead(JOY_SWITCH);
        if (b != b4) {
            msg[1] = 4;
            msg[2] = b ? 0 : 1;
            acc.write(msg, 3);
            b4 = b;
        }

        switch (count++ % 0x10) {
        case 0:
            val = analogRead(TEMP_SENSOR);
            msg[0] = 0x4;
            msg[1] = val >> 8;
            msg[2] = val & 0xff;
            acc.write(msg, 3);
            break;

        case 0x4:
            val = analogRead(LIGHT_SENSOR);
            msg[0] = 0x5;
            msg[1] = val >> 8;
            msg[2] = val & 0xff;
            acc.write(msg, 3);
            break;

        case 0x8:
            read_joystick(&x, &y);
            msg[0] = 0x6;
            msg[1] = constrain(x, -128, 127);
            msg[2] = constrain(y, -128, 127);
            acc.write(msg, 3);
            break;

        case 0xc:
            touchcount = touch_robot.capSense(5);

            c0 = touchcount > 750;

            if (c0 != c) {
                msg[0] = 0x1;
                msg[1] = 3;
                msg[2] = c0;
                acc.write(msg, 3);
                c = c0;
            }

            break;
        }
    }
    else {
        // reset outputs to default values on disconnect
        analogWrite(LED1_RED, 255);
        analogWrite(LED1_GREEN, 255);
        analogWrite(LED1_BLUE, 255);
        analogWrite(LED2_RED, 255);
        analogWrite(LED2_GREEN, 255);
        analogWrite(LED2_BLUE, 255);
        analogWrite(LED3_RED, 255);
        analogWrite(LED3_GREEN, 255);
        analogWrite(LED3_BLUE, 255);
        servos[0].write(90);
        servos[0].write(90);
        servos[0].write(90);
        digitalWrite(RELAY1, LOW);
        digitalWrite(RELAY2, LOW);
    }

    delay(10);
}

// ==============================================================================
// Austria Microsystems i2c Joystick
void init_joystick(int threshold)
{
    byte status = 0;

    pinMode(JOY_SWITCH, INPUT);
    digitalWrite(JOY_SWITCH, HIGH);

    pinMode(JOY_nINT, INPUT);
    digitalWrite(JOY_nINT, HIGH);

    pinMode(JOY_nRESET, OUTPUT);

    digitalWrite(JOY_nRESET, 1);
    delay(1);
    digitalWrite(JOY_nRESET, 0);
    delay(1);
    digitalWrite(JOY_nRESET, 1);

    Wire.begin();

    do {
        status = read_joy_reg(0x0f);
    } while ((status & 0xf0) != 0xf0);

    // invert magnet polarity setting, per datasheet
    write_joy_reg(0x2e, 0x86);

    calibrate_joystick(threshold);
}


int offset_X, offset_Y;

void calibrate_joystick(int dz)
{
    char iii;
    int x_cal = 0;
    int y_cal = 0;

    // Low Power Mode, 20ms auto wakeup
    // INTn output enabled
    // INTn active after each measurement
    // Normal (non-Reset) mode
    write_joy_reg(0x0f, 0x00);
    delay(1);

    // dummy read of Y_reg to reset interrupt
    read_joy_reg(0x11);

    for(iii = 0; iii != 16; iii++) {
        while(!joystick_interrupt()) {}

        x_cal += read_joy_reg(0x10);
        y_cal += read_joy_reg(0x11);
    }

    // Divide by 16 to get average
    offset_X = -(x_cal>>4);
    offset_Y = -(y_cal>>4);

    write_joy_reg(0x12, dz - offset_X);  // Xp, LEFT threshold for INTn
    write_joy_reg(0x13, -dz - offset_X);  // Xn, RIGHT threshold for INTn
    write_joy_reg(0x14, dz - offset_Y);  // Yp, UP threshold for INTn
    write_joy_reg(0x15, -dz - offset_Y);  // Yn, DOWN threshold for INTn

    // Dead zone threshold detect requested?
    if (dz)
        write_joy_reg(0x0f, 0x04);
}

void read_joystick(int *x, int *y)
{
    *x = read_joy_reg(0x10) + offset_X;
    *y = read_joy_reg(0x11) + offset_Y;  // reading Y clears the interrupt
}

char joystick_interrupt()
{
    return digitalRead(JOY_nINT) == 0;
}

#define  JOY_I2C_ADDR    0x40

char read_joy_reg(char reg_addr)
{
    char c;

    Wire.beginTransmission(JOY_I2C_ADDR);
    Wire.send(reg_addr);
    Wire.endTransmission();

    Wire.requestFrom(JOY_I2C_ADDR, 1);

    while(Wire.available())
        c = Wire.receive();

    return c;
}

void write_joy_reg(char reg_addr, char val)
{
    Wire.beginTransmission(JOY_I2C_ADDR);
    Wire.send(reg_addr);
    Wire.send(val);
    Wire.endTransmission();
}

By the way, I even tried to copy the ADK_relsease_0512 folder in my arduino directory at that still didn't work. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

雪化雨蝶 2024-12-29 11:22:13

现在我在 Arduino 1.0 上取得了成功,我想分享解决方案:

  1. 我使用了 CapSense04。 zip 库:
  2. 我将以下文件中的类型从 void 更改为 size_t href="http://labs.arduino.cc/uploads/ADK/GettingStarted/arduino_bundle_ADK.zip" rel="noreferrer">arduino_bundle_ADK.zip:

AndroidAccessory.cpp 第 280 行:size_t AndroidAccessory::写(uint8_t b)
AndroidAccessory.h 第 71 行:size_t write(uint8_t b);

Max_LCD.cpp 第 257 行:内联 size_t Max_LCD::write(uint8_t value)
Max_LCD.h第101行:virtual size_t write(uint8_t);

我还将send更改为write,将receive更改为阅读,在 demokit.pde 中(您可以在 adk_release_0512.zip 中找到它)

Demokit.pde 第 377 行: Wire.write(reg_addr);
第 383 行:c = Wire.read();
第391行:Wire.write(reg_addr);
第 392 行:Wire.write(val);

Now I reached sucess with Arduino 1.0 , and I want to share the solution:

  1. I used the CapSense04.zip library:
  2. I changed the type from void to size_t in following files from arduino_bundle_ADK.zip:

AndroidAccessory.cpp line 280: size_t AndroidAccessory::write(uint8_t b)
AndroidAccessory.h line 71: size_t write(uint8_t b);

Max_LCD.cpp line 257: inline size_t Max_LCD::write(uint8_t value)
Max_LCD.h line 101: virtual size_t write(uint8_t);

I also changed send to write and receive to read, in the demokit.pde (you will find it in adk_release_0512.zip)

Demokit.pde line 377: Wire.write(reg_addr);
line 383: c = Wire.read();
line 391: Wire.write(reg_addr);
line 392: Wire.write(val);

拔了角的鹿 2024-12-29 11:22:13

也许尝试使用早期版本的 Arduino(即不是 arduino 1.0)——据我所知,最近的更新更改了一些类名称。

我遇到了此处详细说明的错误,因此这为我修复了它: http://www.jjoe64.com/2011/12/adk-arduino-wprogramh-not-found.html

Perhaps try using an earlier version of Arduino (i.e. not arduino 1.0) - a recent update has changed some class names as far as I can see.

I was experiencing the errors detailed here and so this fixed it for me: http://www.jjoe64.com/2011/12/adk-arduino-wprogramh-not-found.html

披肩女神 2024-12-29 11:22:13

Arduino 1.0 IDE 中没有 WProgram.h。 include 语句应该是:

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

这将修复 Arduino 1.0 下找不到标头的问题。

There is no WProgram.h in Arduino 1.0 IDE. The include statement should be:

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

This will fix the header not found problem under Arduino 1.0.

愁以何悠 2024-12-29 11:22:13

更高版本的代码(arduino_bundle_ADK_02)不需要修补。

免责声明:除了 ADK 应用程序弹出之外,我仍然无法使这个动物园与 Nexus S 一起工作(初始连接后几秒钟后出现可怕的“设置数据包错误:D”),但我认为原因在其他地方。

Later version of the code (arduino_bundle_ADK_02) doesn't need to be patched.

Disclaimer: I still can't make this zoo work with Nexus S beyond ADK app popping up (dreaded "Setup packet error: D" after a few seconds after initial connection), but I think the reason for that is elsewhere.

猫九 2024-12-29 11:22:13

我已将错误行“CapSense”更改为“CapacitiveSensor”
考虑到该类现在在 CapSense 库 v.04 中被命名为 (CapacitiveSensor)
该库现在也称为 CapacitiveSensor
然后按验证后,我必须将属性“touch_robot.capSense”更改为“touch_robot.capacitiveSensor”

I've changed in the lines with errors "CapSense" to "CapacitiveSensor"
considering that the class is now named (CapacitiveSensor) at CapSense library v.04
and the library is now called CapacitiveSensor as well
then after pressing verify I had to change a property "touch_robot.capSense" to "touch_robot.capacitiveSensor"

围归者 2024-12-29 11:22:13

只是为了分享信息,如果您使用 arduino uno (Mega328),请查看此网站。 uno 的固件位于此处。注意它使用arduino IDE v0.22并且需要添加库。

快乐的微控制器编程...

最诚挚的问候,

Just to share info, if you use arduino uno (Mega328), check this site. The firmware for the uno is here. Note it uses arduino IDE v0.22 and need to add libraries.

Happy microcontroller programming...

Best regards,
pak

可爱暴击 2024-12-29 11:22:13

ADK 软件最近刚刚更新,与 Arduino 1.0 兼容。

检查developer.android.com 上的ADK 页面:
http://developer.android.com/guide/topics/usb/adk.html

新的下载链接是:
https://dl-ssl.google.com/android/adk/adk_release_20120606.zip

The ADK software was just recently updated to be compatible with Arduino 1.0.

Check the ADK page on developer.android.com:
http://developer.android.com/guide/topics/usb/adk.html

New download link is:
https://dl-ssl.google.com/android/adk/adk_release_20120606.zip

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文