Back to project page konashi-android-sdk.
The source code is released under:
Apache License
If you think the Android project konashi-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.uxxu.konashi.lib; /* w w w . j a va 2 s . c o m*/ import android.app.Activity; import android.content.Context; /** * KonashiManager????????????????? * 1?????????konashi???????????????????????????????????????????? * * @author monakaz, YUKAI Engineering * http://konashi.ux-xu.com * ======================================================================== * Copyright 2014 Yukai Engineering Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ public class Konashi { /////////////////////////////////////////// // Pin name /////////////////////////////////////////// /** * PIO???0??? */ public static final int PIO0 = 0; /** * PIO???1??? */ public static final int PIO1 = 1; /** * PIO???2??? */ public static final int PIO2 = 2; /** * PIO???3??? */ public static final int PIO3 = 3; /** * PIO???4??? */ public static final int PIO4 = 4; /** * PIO???5??? */ public static final int PIO5 = 5; /** * PIO???6??? */ public static final int PIO6 = 6; /** * PIO???7??? */ public static final int PIO7 = 7; /** * ????????????? ???????????????????? PIO0 ???????????????? */ public static final int S1 = 0; /** * konashi??????LED????? ???????????????????? PIO1 ???????????????? */ public static final int LED2 = 1; /** * konashi??????LED????? ???????????????????? PIO2 ???????????????? */ public static final int LED3 = 2; /** * konashi??????LED????? ???????????????????? PIO3 ???????????????? */ public static final int LED4 = 3; /** * konashi??????LED????? ???????????????????? PIO4 ???????????????? */ public static final int LED5 = 4; /** * AIO???0??? */ public static final int AIO0 = 0; /** * AIO???1??? */ public static final int AIO1 = 1; /** * AIO???2??? */ public static final int AIO2 = 2; /** * I2C???SDA?????(PIO???6???) */ public static final int I2C_SDA = 6; /** * I2C???SDA?????(PIO???7???) */ public static final int I2C_SCL = 7; /////////////////////////////////////////// // PIO /////////////////////////////////////////// /** * ????????HIGH(3V)??????? */ public static final int HIGH = 1; /** * ????????LOW(0V)??????? */ public static final int LOW = 0; /** * ????????HIGH(3V)???????, HIGH????????? */ public static final int TRUE = 1; /** * ????????LOW(0V)???????, LOW????????? */ public static final int FALSE = 0; /** * ???????????????? */ public static final int OUTPUT = 1; /** * ???????????????? */ public static final int INPUT = 0; /** * ?????????????ON */ public static final int PULLUP = 1; /** * ?????????????OFF */ public static final int NO_PULLS = 0; /////////////////////////////////////////// // AIO /////////////////////////////////////////// /** * ?????????????? 1300mV */ public static final int ANALOG_REFERENCE = 1300; // 1300mV /////////////////////////////////////////// // PWM /////////////////////////////////////////// /** * ????????PIO?PWM????????????????????(????I/O???????????) */ public static final int PWM_DISABLE = 0; /** * ????????PIO?PWM??????????????? */ public static final int PWM_ENABLE = 1; /** * ????????PIO?LED????????????PWM??????????????? */ public static final int PWM_ENABLE_LED_MODE = 2; /** * LED???????PWM????????10ms */ public static final int PWM_LED_PERIOD = 10000; // 10ms /////////////////////////////////////////// // UART /////////////////////////////////////////// /** * UART?? */ public static final int UART_DISABLE = 0; /** * UART?? */ public static final int UART_ENABLE = 1; /** * ????: 2400bps */ public static final int UART_RATE_2K4 = 0x000a; /** * ????: 9600bps */ public static final int UART_RATE_9K6 = 0x0028; /////////////////////////////////////////// // I2C /////////////////////////////////////////// /** * I2C???????????????????????????? */ public static final int I2C_DATA_MAX_LENGTH = 19; /** * I2C?????????? */ public static final int I2C_DISABLE = 0; /** * I2C??????????(100kbps???????????) */ public static final int I2C_ENABLE = 1; /** * 100kbps??????I2C?????????? */ public static final int I2C_ENABLE_100K = 1; /** * 400kbps??????I2C?????????? */ public static final int I2C_ENABLE_400K = 2; /** * ??????????? */ public static final int I2C_STOP_CONDITION = 0; /** * ??????????? */ public static final int I2C_START_CONDITION = 1; /** * ???????????? */ public static final int I2C_RESTART_CONDITION = 2; /** * API???????????? */ public static final int SUCCESS = 0; /** * API??????????? */ public static final int FAILURE = -1; /** * KonashiManager????????? */ private static final KonashiManager sKonashiManager = new KonashiManager(); /** * ????????private??????????????????????????????????????????????? */ private Konashi(){} /** * konashi??????? * @param context konashi????????????????Activity */ public static void initialize(Context context){ sKonashiManager.initialize(context); } /** * ?????? */ public static void close(){ if(sKonashiManager!=null){ sKonashiManager.disconnect(); sKonashiManager.close(); } } /** * Konashi????????????????? * @return KonashiManager??????????????? */ public static KonashiManager getManager(){ return sKonashiManager; } }