Move other projects under "projects" repository.
This commit is contained in:
commit
dc6b429627
33
app/build.gradle
Normal file
33
app/build.gradle
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 19
|
||||||
|
buildToolsVersion "28.0.3"
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
ndkBuild {
|
||||||
|
path "src/main/jni/Android.mk"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmake {
|
||||||
|
version "3.10.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.hardkernel.odroid.weatherboard"
|
||||||
|
minSdkVersion 19
|
||||||
|
targetSdkVersion 19
|
||||||
|
|
||||||
|
ndk {
|
||||||
|
moduleName "weather"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/src/main/AndroidManifest.xml
Normal file
23
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.hardkernel.odroid.weatherboard"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0" >
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme" >
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/app_name" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@ -0,0 +1,120 @@
|
|||||||
|
package com.hardkernel.odroid.weatherboard;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
|
public class MainActivity extends Activity {
|
||||||
|
|
||||||
|
private final static String TAG = "weather";
|
||||||
|
private final static String I2C_1_NODE = "/dev/i2c-1";
|
||||||
|
private boolean mStopWeather;
|
||||||
|
private ToggleButton mBtn_Weather;
|
||||||
|
private TextView mTV_Temperature;
|
||||||
|
private TextView mTV_Humidity;
|
||||||
|
private TextView mTV_Pressure;
|
||||||
|
private TextView mTV_Altitude;
|
||||||
|
private Handler handler = new Handler();
|
||||||
|
Runnable mRunnableWeather = new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
updateWeather();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private TextView mTV_UV_index;
|
||||||
|
private TextView mTV_Visible;
|
||||||
|
private TextView mTV_IR;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
mBtn_Weather = (ToggleButton) findViewById(R.id.tb_weather);
|
||||||
|
mBtn_Weather.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (isChecked) {
|
||||||
|
if (openWeatherBoard(I2C_1_NODE) == -1) {
|
||||||
|
Log.e(TAG, "failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mStopWeather = false;
|
||||||
|
handler.postDelayed(mRunnableWeather, 300);
|
||||||
|
} else {
|
||||||
|
mStopWeather = true;
|
||||||
|
closeWeatherBoard();
|
||||||
|
mTV_Temperature.setText("Temperature :");
|
||||||
|
mTV_Humidity.setText("Humidity :");
|
||||||
|
mTV_Pressure.setText("Pressure :");
|
||||||
|
mTV_Altitude.setText("Altitude :");
|
||||||
|
mTV_UV_index.setText("UV index :");
|
||||||
|
mTV_Visible.setText("Visible :");
|
||||||
|
mTV_IR.setText("IR :");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mTV_Temperature = (TextView) findViewById(R.id.tv_temperature);
|
||||||
|
mTV_Humidity = (TextView) findViewById(R.id.tv_humidity);
|
||||||
|
mTV_Pressure = (TextView) findViewById(R.id.tv_pressure);
|
||||||
|
mTV_Altitude = (TextView) findViewById(R.id.tv_altitude);
|
||||||
|
|
||||||
|
mTV_UV_index = (TextView) findViewById(R.id.tv_uv_index);
|
||||||
|
mTV_Visible = (TextView) findViewById(R.id.tv_visible);
|
||||||
|
mTV_IR = (TextView) findViewById(R.id.tv_ir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onPause();
|
||||||
|
mBtn_Weather.setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWeather() {
|
||||||
|
if (mStopWeather == true)
|
||||||
|
return;
|
||||||
|
mTV_UV_index.setText("UV index : "
|
||||||
|
+ String.format("%.2f", (double)getUVindex() / 100.0));
|
||||||
|
mTV_Visible.setText("Visible : "
|
||||||
|
+ String.format("%.0f", (double)getVisible()) + " Lux");
|
||||||
|
mTV_IR.setText("IR : "
|
||||||
|
+ String.format("%.0f", (double)getIR()) + " Lux");
|
||||||
|
readyData();
|
||||||
|
mTV_Temperature.setText("Temperature : "
|
||||||
|
+ String.format("%.2f", getTemperature() / 100.0) + " °C");
|
||||||
|
mTV_Humidity.setText("Humidity : "
|
||||||
|
+ String.format("%.2f", getHumidity() / 1024.0) + " %");
|
||||||
|
mTV_Pressure.setText("Pressure : "
|
||||||
|
+ String.format("%.2f", getPressure() / 100.0) + " hPa");
|
||||||
|
mTV_Altitude.setText("Altitude : " + getAltitude() + " m");
|
||||||
|
|
||||||
|
if (!mStopWeather)
|
||||||
|
handler.postDelayed(mRunnableWeather, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public native int openWeatherBoard(String dev);
|
||||||
|
public native int closeWeatherBoard();
|
||||||
|
public native void readyData();
|
||||||
|
public native int getUVindex();
|
||||||
|
public native float getVisible();
|
||||||
|
public native float getIR();
|
||||||
|
public native int getTemperature();
|
||||||
|
public native int getPressure();
|
||||||
|
public native int getHumidity();
|
||||||
|
public native int getAltitude();
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.loadLibrary("weather");
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/src/main/jni/Android.mk
Normal file
15
app/src/main/jni/Android.mk
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_C_INCLUDES += \
|
||||||
|
$(NDK_PATH)/platforms/android-21/arch-arm/usr/include
|
||||||
|
|
||||||
|
LOCAL_MODULE := weather
|
||||||
|
LOCAL_SRC_FILES := \
|
||||||
|
weather.c \
|
||||||
|
bme280-i2c.c \
|
||||||
|
bme280.c \
|
||||||
|
si1132.c
|
||||||
|
LOCAL_LDLIBS := -ldl -llog
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
98
app/src/main/jni/bme280-i2c.c
Normal file
98
app/src/main/jni/bme280-i2c.c
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <linux/i2c-dev.h>
|
||||||
|
|
||||||
|
#include "bme280-i2c.h"
|
||||||
|
#include <android/log.h>
|
||||||
|
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
|
||||||
|
#define LOG_TAG "wpi_android"
|
||||||
|
|
||||||
|
|
||||||
|
s32 bme280_begin(const char *device)
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
s32 com_rslt = 0;
|
||||||
|
bme280Fd = -1;
|
||||||
|
|
||||||
|
bme280Fd = open(device, O_RDWR);
|
||||||
|
if (bme280Fd < 0) {
|
||||||
|
printf("ERROR: bme280 open failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
status = ioctl(bme280Fd, I2C_SLAVE, BME280_I2C_ADDRESS1);
|
||||||
|
if (status < 0) {
|
||||||
|
printf("ERROR: bme280 ioctl error\n");
|
||||||
|
close(bme280Fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
I2C_routine();
|
||||||
|
|
||||||
|
if (bme280_init(&bme280) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
com_rslt += bme280_set_power_mode(BME280_NORMAL_MODE);
|
||||||
|
com_rslt += bme280_set_oversamp_humidity(BME280_OVERSAMP_2X);
|
||||||
|
com_rslt += bme280_set_oversamp_pressure(BME280_OVERSAMP_2X);
|
||||||
|
com_rslt += bme280_set_oversamp_temperature(BME280_OVERSAMP_2X);
|
||||||
|
usleep(100000);
|
||||||
|
|
||||||
|
return com_rslt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bme280_end()
|
||||||
|
{
|
||||||
|
if (bme280Fd)
|
||||||
|
close(bme280Fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bme280_readAltitude(int pressure, float *seaLevel, int *result)
|
||||||
|
{
|
||||||
|
float atmospheric = (float)pressure/100.0;
|
||||||
|
*result = (int)(44330.0 * (1.0 - pow(atmospheric/ *seaLevel, 0.1903)));
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 BME280_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
|
||||||
|
{
|
||||||
|
s32 iError = BME280_INIT_VALUE;
|
||||||
|
u8 stringpos = BME280_INIT_VALUE;
|
||||||
|
unsigned char wbuf[2];
|
||||||
|
for (stringpos = BME280_INIT_VALUE; stringpos < cnt; stringpos++) {
|
||||||
|
wbuf[1] = *(reg_data + stringpos);
|
||||||
|
wbuf[0] = reg_addr + stringpos;
|
||||||
|
write(bme280Fd, wbuf, 2);
|
||||||
|
}
|
||||||
|
return (s8)iError;
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 BME280_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
|
||||||
|
{
|
||||||
|
s32 iError = BME280_INIT_VALUE;
|
||||||
|
u8 stringpos = BME280_INIT_VALUE;
|
||||||
|
unsigned char rbuf[2];
|
||||||
|
int i;
|
||||||
|
for (stringpos = BME280_INIT_VALUE; stringpos < cnt; stringpos++) {
|
||||||
|
rbuf[0] = reg_addr + stringpos;
|
||||||
|
write(bme280Fd, rbuf, 1);
|
||||||
|
read(bme280Fd, rbuf, 1);
|
||||||
|
if (rbuf[0] < 0) iError = -1;
|
||||||
|
else *(reg_data + stringpos) = rbuf[0];
|
||||||
|
}
|
||||||
|
return (s8)iError;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BME280_delay_msek(u16 msek)
|
||||||
|
{
|
||||||
|
usleep(msek*1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 I2C_routine(void) {
|
||||||
|
bme280.bus_write = BME280_I2C_bus_write;
|
||||||
|
bme280.bus_read = BME280_I2C_bus_read;
|
||||||
|
bme280.dev_addr = BME280_I2C_ADDRESS1;
|
||||||
|
bme280.delay_msec = BME280_delay_msek;
|
||||||
|
|
||||||
|
return BME280_INIT_VALUE;
|
||||||
|
}
|
||||||
16
app/src/main/jni/bme280-i2c.h
Normal file
16
app/src/main/jni/bme280-i2c.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include "bme280.h"
|
||||||
|
|
||||||
|
int bme280Fd;
|
||||||
|
|
||||||
|
struct bme280_t bme280;
|
||||||
|
|
||||||
|
s32 bme280_begin(const char *device);
|
||||||
|
void bme280_end();
|
||||||
|
void bme280_readAltitude(int pressure, float *seaLevelult, int *result);
|
||||||
|
|
||||||
|
s8 I2C_routine(void);
|
||||||
|
|
||||||
|
s8 BME280_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
|
||||||
|
s8 BME280_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
|
||||||
|
|
||||||
|
void BME280_delay_msek(u16 msek);
|
||||||
2215
app/src/main/jni/bme280.c
Normal file
2215
app/src/main/jni/bme280.c
Normal file
File diff suppressed because it is too large
Load Diff
1704
app/src/main/jni/bme280.h
Normal file
1704
app/src/main/jni/bme280.h
Normal file
File diff suppressed because it is too large
Load Diff
140
app/src/main/jni/si1132.c
Normal file
140
app/src/main/jni/si1132.c
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <linux/i2c-dev.h>
|
||||||
|
#include "si1132.h"
|
||||||
|
|
||||||
|
int si1132_begin(const char *device)
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
si1132Fd = -1;
|
||||||
|
|
||||||
|
si1132Fd = open(device, O_RDWR);
|
||||||
|
if (si1132Fd < 0) {
|
||||||
|
printf("ERROR: si1132 open failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = ioctl(si1132Fd, I2C_SLAVE, Si1132_ADDR);
|
||||||
|
if (status < 0) {
|
||||||
|
printf("ERROR: si1132 ioctl error\n");
|
||||||
|
close(si1132Fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Si1132_I2C_read8(Si1132_REG_PARTID) != 0x32) {
|
||||||
|
printf("ERROR: si1132 read failed the PART ID\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
|
||||||
|
return si1132Fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void si1132_end() {
|
||||||
|
if (si1132Fd)
|
||||||
|
close(si1132Fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initialize(void)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
|
||||||
|
Si1132_I2C_write8(Si1132_REG_UCOEF0, 0x7B);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_UCOEF1, 0x6B);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_UCOEF2, 0x01);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_UCOEF3, 0x00);
|
||||||
|
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_CHLIST, Si1132_PARAM_CHLIST_ENUV |
|
||||||
|
Si1132_PARAM_CHLIST_ENALSIR | Si1132_PARAM_CHLIST_ENALSVIS);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_INTCFG, Si1132_REG_INTCFG_INTOE);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_IRQEN, Si1132_REG_IRQEN_ALSEVERYSAMPLE);
|
||||||
|
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_ALSIRADCMUX, Si1132_PARAM_ADCMUX_SMALLIR);
|
||||||
|
usleep(10000);
|
||||||
|
// fastest clocks, clock div 1
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_ALSIRADCGAIN, 0);
|
||||||
|
usleep(10000);
|
||||||
|
// take 511 clocks to measure
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_ALSIRADCCOUNTER, Si1132_PARAM_ADCCOUNTER_511CLK);
|
||||||
|
// in high range mode
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_ALSIRADCMISC, Si1132_PARAM_ALSIRADCMISC_RANGE);
|
||||||
|
usleep(10000);
|
||||||
|
// fastest clocks
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_ALSVISADCGAIN, 0);
|
||||||
|
usleep(10000);
|
||||||
|
// take 511 clocks to measure
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_ALSVISADCCOUNTER, Si1132_PARAM_ADCCOUNTER_511CLK);
|
||||||
|
//in high range mode (not normal signal)
|
||||||
|
Si1132_I2C_writeParam(Si1132_PARAM_ALSVISADCMISC, Si1132_PARAM_ALSVISADCMISC_VISRANGE);
|
||||||
|
usleep(10000);
|
||||||
|
|
||||||
|
Si1132_I2C_write8(Si1132_REG_MEASRATE0, 0xFF);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_COMMAND, Si1132_ALS_AUTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
Si1132_I2C_write8(Si1132_REG_MEASRATE0, 0);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_MEASRATE1, 0);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_IRQEN, 0);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_IRQMODE1, 0);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_IRQMODE2, 0);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_INTCFG, 0);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_IRQSTAT, 0xFF);
|
||||||
|
|
||||||
|
Si1132_I2C_write8(Si1132_REG_COMMAND, Si1132_RESET);
|
||||||
|
usleep(10000);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_HWKEY, 0x17);
|
||||||
|
|
||||||
|
usleep(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Si1132_readVisible(float *result)
|
||||||
|
{
|
||||||
|
usleep(10000);
|
||||||
|
*result = ((Si1132_I2C_read16(0x22) - 256) / 0.282) * 14.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Si1132_readIR(float *result)
|
||||||
|
{
|
||||||
|
usleep(10000);
|
||||||
|
*result = ((Si1132_I2C_read16(0x24) - 250) / 2.44) * 14.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Si1132_readUV(int *result)
|
||||||
|
{
|
||||||
|
usleep(10000);
|
||||||
|
*result = (int)Si1132_I2C_read16(0x2c);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char Si1132_I2C_read8(unsigned char reg)
|
||||||
|
{
|
||||||
|
unsigned char ret;
|
||||||
|
write(si1132Fd, ®, 1);
|
||||||
|
read(si1132Fd, &ret, 1);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short Si1132_I2C_read16(unsigned char reg)
|
||||||
|
{
|
||||||
|
unsigned char rbuf[2];
|
||||||
|
write(si1132Fd, ®, 1);
|
||||||
|
read(si1132Fd, rbuf, 2);
|
||||||
|
return (unsigned short)(rbuf[0] | rbuf[1] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Si1132_I2C_write8(unsigned char reg, unsigned char val)
|
||||||
|
{
|
||||||
|
unsigned char wbuf[2];
|
||||||
|
wbuf[0] = reg;
|
||||||
|
wbuf[1] = val;
|
||||||
|
write(si1132Fd, wbuf, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Si1132_I2C_writeParam(unsigned char param, unsigned char val)
|
||||||
|
{
|
||||||
|
Si1132_I2C_write8(Si1132_REG_PARAMWR, val);
|
||||||
|
Si1132_I2C_write8(Si1132_REG_COMMAND, param | Si1132_PARAM_SET);
|
||||||
|
}
|
||||||
92
app/src/main/jni/si1132.h
Normal file
92
app/src/main/jni/si1132.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* COMMANDS */
|
||||||
|
#define Si1132_PARAM_QUERY 0x80
|
||||||
|
#define Si1132_PARAM_SET 0xA0
|
||||||
|
#define Si1132_NOP 0x00
|
||||||
|
#define Si1132_RESET 0x01
|
||||||
|
#define Si1132_BUSADDR 0x02
|
||||||
|
#define Si1132_GET_CAL 0x12
|
||||||
|
#define Si1132_ALS_FORCE 0x06
|
||||||
|
#define Si1132_ALS_PAUSE 0x0A
|
||||||
|
#define Si1132_ALS_AUTO 0x0E
|
||||||
|
|
||||||
|
/* Parameters */
|
||||||
|
#define Si1132_PARAM_I2CADDR 0x00
|
||||||
|
#define Si1132_PARAM_CHLIST 0x01
|
||||||
|
#define Si1132_PARAM_CHLIST_ENUV 0x80
|
||||||
|
#define Si1132_PARAM_CHLIST_ENAUX 0x40
|
||||||
|
#define Si1132_PARAM_CHLIST_ENALSIR 0x20
|
||||||
|
#define Si1132_PARAM_CHLIST_ENALSVIS 0x10
|
||||||
|
|
||||||
|
#define Si1132_PARAM_ALSENCODING 0x06
|
||||||
|
|
||||||
|
#define Si1132_PARAM_ALSIRADCMUX 0x0E
|
||||||
|
#define Si1132_PARAM_AUXADCMUX 0x0F
|
||||||
|
|
||||||
|
#define Si1132_PARAM_ALSVISADCCOUNTER 0x10
|
||||||
|
#define Si1132_PARAM_ALSVISADCGAIN 0x11
|
||||||
|
#define Si1132_PARAM_ALSVISADCMISC 0x12
|
||||||
|
#define Si1132_PARAM_ALSVISADCMISC_VISRANGE 0x20
|
||||||
|
|
||||||
|
#define Si1132_PARAM_ALSIRADCCOUNTER 0x1D
|
||||||
|
#define Si1132_PARAM_ALSIRADCGAIN 0x1E
|
||||||
|
#define Si1132_PARAM_ALSIRADCMISC 0x1F
|
||||||
|
#define Si1132_PARAM_ALSIRADCMISC_RANGE 0x20
|
||||||
|
|
||||||
|
#define Si1132_PARAM_ADCCOUNTER_511CLK 0x70
|
||||||
|
|
||||||
|
#define Si1132_PARAM_ADCMUX_SMALLIR 0x00
|
||||||
|
#define Si1132_PARAM_ADCMUX_LARGEIR 0x03
|
||||||
|
|
||||||
|
/* REGISTERS */
|
||||||
|
#define Si1132_REG_PARTID 0x00
|
||||||
|
#define Si1132_REG_REVID 0x01
|
||||||
|
#define Si1132_REG_SEQID 0x02
|
||||||
|
|
||||||
|
#define Si1132_REG_INTCFG 0x03
|
||||||
|
#define Si1132_REG_INTCFG_INTOE 0x01
|
||||||
|
|
||||||
|
#define Si1132_REG_IRQEN 0x04
|
||||||
|
#define Si1132_REG_IRQEN_ALSEVERYSAMPLE 0x01
|
||||||
|
|
||||||
|
#define Si1132_REG_IRQMODE1 0x05
|
||||||
|
#define Si1132_REG_IRQMODE2 0x06
|
||||||
|
|
||||||
|
#define Si1132_REG_HWKEY 0x07
|
||||||
|
#define Si1132_REG_MEASRATE0 0x08
|
||||||
|
#define Si1132_REG_MEASRATE1 0x09
|
||||||
|
#define Si1132_REG_UCOEF0 0x13
|
||||||
|
#define Si1132_REG_UCOEF1 0x14
|
||||||
|
#define Si1132_REG_UCOEF2 0x15
|
||||||
|
#define Si1132_REG_UCOEF3 0x16
|
||||||
|
#define Si1132_REG_PARAMWR 0x17
|
||||||
|
#define Si1132_REG_COMMAND 0x18
|
||||||
|
#define Si1132_REG_RESPONSE 0x20
|
||||||
|
#define Si1132_REG_IRQSTAT 0x21
|
||||||
|
|
||||||
|
#define Si1132_REG_ALSVISDATA0 0x22
|
||||||
|
#define Si1132_REG_ALSVISDATA1 0x23
|
||||||
|
#define Si1132_REG_ALSIRDATA0 0x24
|
||||||
|
#define Si1132_REG_ALSIRDATA1 0x25
|
||||||
|
#define Si1132_REG_UVINDEX0 0x2C
|
||||||
|
#define Si1132_REG_UVINDEX1 0x2D
|
||||||
|
#define Si1132_REG_PARAMRD 0x2E
|
||||||
|
#define Si1132_REG_CHIPSTAT 0x30
|
||||||
|
|
||||||
|
#define Si1132_ADDR 0x60
|
||||||
|
|
||||||
|
int si1132Fd;
|
||||||
|
|
||||||
|
int si1132_begin(const char *device);
|
||||||
|
void si1132_end();
|
||||||
|
void initialize(void);
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void Si1132_readVisible(float *result);
|
||||||
|
void Si1132_readIR(float *result);
|
||||||
|
void Si1132_readUV();
|
||||||
|
|
||||||
|
unsigned char Si1132_I2C_read8(unsigned char reg);
|
||||||
|
unsigned short Si1132_I2C_read16(unsigned char reg);
|
||||||
|
|
||||||
|
void Si1132_I2C_write8(unsigned char reg, unsigned char val);
|
||||||
|
void Si1132_I2C_writeParam(unsigned char param, unsigned char val);
|
||||||
81
app/src/main/jni/weather.c
Normal file
81
app/src/main/jni/weather.c
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include <jni.h>
|
||||||
|
#include <android/log.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
|
||||||
|
#define LOG_TAG "weather"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
int pressure;
|
||||||
|
int temperature;
|
||||||
|
int humidity;
|
||||||
|
|
||||||
|
float SEALEVELPRESSURE_HPA = 1024.25;
|
||||||
|
|
||||||
|
jint Java_com_hardkernel_odroid_weatherboard_MainActivity_openWeatherBoard(JNIEnv* env, jobject obj, jstring str) {
|
||||||
|
const char *i2c_dev = (*env)->GetStringUTFChars(env, str, 0);
|
||||||
|
int result = -1;
|
||||||
|
result = si1132_begin(i2c_dev);
|
||||||
|
if (result == -1)
|
||||||
|
return result;
|
||||||
|
result = bme280_begin(i2c_dev);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, str, i2c_dev);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_com_hardkernel_odroid_weatherboard_MainActivity_closeWeatherBoard(JNIEnv* env, jobject obj) {
|
||||||
|
bme280_end();
|
||||||
|
si1132_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_com_hardkernel_odroid_weatherboard_MainActivity_bme280_end(JNIEnv* env, jobject obj) {
|
||||||
|
bme280_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
jint Java_com_hardkernel_odroid_weatherboard_MainActivity_getUVindex(JNIEnv* env, jobject obj) {
|
||||||
|
int result = 0;
|
||||||
|
Si1132_readUV(&result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
jfloat Java_com_hardkernel_odroid_weatherboard_MainActivity_getVisible(JNIEnv* env, jobject obj) {
|
||||||
|
float result = 0.0;
|
||||||
|
Si1132_readVisible(&result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
jfloat Java_com_hardkernel_odroid_weatherboard_MainActivity_getIR(JNIEnv* env, jobject obj) {
|
||||||
|
float result = 0.0;
|
||||||
|
Si1132_readIR(&result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Java_com_hardkernel_odroid_weatherboard_MainActivity_readyData(JNIEnv* env, jobject obj) {
|
||||||
|
bme280_read_pressure_temperature_humidity(&pressure, &temperature, &humidity);
|
||||||
|
}
|
||||||
|
|
||||||
|
jint Java_com_hardkernel_odroid_weatherboard_MainActivity_getTemperature(JNIEnv* env, jobject obj) {
|
||||||
|
return temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
jint Java_com_hardkernel_odroid_weatherboard_MainActivity_getPressure(JNIEnv* env, jobject obj) {
|
||||||
|
return pressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
jint Java_com_hardkernel_odroid_weatherboard_MainActivity_getHumidity(JNIEnv* env, jobject obj) {
|
||||||
|
return humidity;
|
||||||
|
}
|
||||||
|
|
||||||
|
jint Java_com_hardkernel_odroid_weatherboard_MainActivity_getAltitude(JNIEnv* env, jobject obj) {
|
||||||
|
int result = 0;
|
||||||
|
bme280_readAltitude(pressure, &SEALEVELPRESSURE_HPA, &result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
106
app/src/main/res/layout/activity_main.xml
Normal file
106
app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context="com.hardkernel.odroid.weatherboard.MainActivity" >
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/tb_weather"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center|top" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView8"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/BME280"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_temperature"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="@string/Temperature"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_humidity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/Humidity"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_pressure"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="@string/Pressure"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_altitude"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/altitude"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView9"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/SI1132"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_uv_index"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="@string/UV_index"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_visible"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="@string/visible"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_ir"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:text="@string/IR"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
11
app/src/main/res/menu/main.xml
Normal file
11
app/src/main/res/menu/main.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="com.hardkernel.odroid.weatherboard.MainActivity" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/action_settings"/>
|
||||||
|
|
||||||
|
</menu>
|
||||||
11
app/src/main/res/values-v11/styles.xml
Normal file
11
app/src/main/res/values-v11/styles.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Base application theme for API 11+. This theme completely replaces
|
||||||
|
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||||
|
-->
|
||||||
|
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
|
||||||
|
<!-- API 11 theme customizations can go here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
||||||
12
app/src/main/res/values-v14/styles.xml
Normal file
12
app/src/main/res/values-v14/styles.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Base application theme for API 14+. This theme completely replaces
|
||||||
|
AppBaseTheme from BOTH res/values/styles.xml and
|
||||||
|
res/values-v11/styles.xml on API 14+ devices.
|
||||||
|
-->
|
||||||
|
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||||
|
<!-- API 14 theme customizations can go here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
||||||
10
app/src/main/res/values-w820dp/dimens.xml
Normal file
10
app/src/main/res/values-w820dp/dimens.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Example customization of dimensions originally defined in res/values/dimens.xml
|
||||||
|
(such as screen margins) for screens with more than 820dp of available width. This
|
||||||
|
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
|
||||||
|
-->
|
||||||
|
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||||
|
|
||||||
|
</resources>
|
||||||
7
app/src/main/res/values/dimens.xml
Normal file
7
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
|
||||||
|
</resources>
|
||||||
22
app/src/main/res/values/strings.xml
Normal file
22
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string name="app_name">WeatherBoard</string>
|
||||||
|
<string name="hello_world">Hello world!</string>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
|
||||||
|
<string name="BME280">BME280</string>
|
||||||
|
<string name="SI1132">SI1132</string>
|
||||||
|
<string name="Temperature">Temperature</string>
|
||||||
|
<string name="Pressure">Pressure</string>
|
||||||
|
<string name="UV_index">UV index</string>
|
||||||
|
<string name="visible">Visible</string>
|
||||||
|
<string name="IR">IR</string>
|
||||||
|
<string name="Humidity">Humidity</string>
|
||||||
|
<string name="celcius">°C</string>
|
||||||
|
<string name="altitude">Altitude</string>
|
||||||
|
<string name="i2c_1">/dev/i2c-1</string>
|
||||||
|
<string name="i2c_10">/dev/i2c-10</string>
|
||||||
|
<string name="i2c_3">/dev/i2c-3</string>
|
||||||
|
|
||||||
|
</resources>
|
||||||
20
app/src/main/res/values/styles.xml
Normal file
20
app/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Base application theme, dependent on API level. This theme is replaced
|
||||||
|
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||||
|
-->
|
||||||
|
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||||
|
<!--
|
||||||
|
Theme customizations available in newer API levels can go in
|
||||||
|
res/values-vXX/styles.xml, while customizations related to
|
||||||
|
backward-compatibility can go here.
|
||||||
|
-->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- Application theme. -->
|
||||||
|
<style name="AppTheme" parent="AppBaseTheme">
|
||||||
|
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
||||||
17
build.gradle
Normal file
17
build.gradle
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
172
gradlew
vendored
Normal file
172
gradlew
vendored
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
84
gradlew.bat
vendored
Normal file
84
gradlew.bat
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
43
import-summary.txt
Normal file
43
import-summary.txt
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
ECLIPSE ANDROID PROJECT IMPORT SUMMARY
|
||||||
|
======================================
|
||||||
|
|
||||||
|
Ignored Files:
|
||||||
|
--------------
|
||||||
|
The following files were *not* copied into the new Gradle project; you
|
||||||
|
should evaluate whether these are still needed in your project and if
|
||||||
|
so manually move them:
|
||||||
|
|
||||||
|
* .idea\
|
||||||
|
* .idea\codeStyles\
|
||||||
|
* .idea\codeStyles\Project.xml
|
||||||
|
* .idea\modules.xml
|
||||||
|
* .idea\vcs.xml
|
||||||
|
* .idea\weatherboard.iml
|
||||||
|
* .idea\workspace.xml
|
||||||
|
* ic_launcher-web.png
|
||||||
|
* proguard-project.txt
|
||||||
|
|
||||||
|
Moved Files:
|
||||||
|
------------
|
||||||
|
Android Gradle projects use a different directory structure than ADT
|
||||||
|
Eclipse projects. Here's how the projects were restructured:
|
||||||
|
|
||||||
|
* AndroidManifest.xml => app\src\main\AndroidManifest.xml
|
||||||
|
* jni\ => app\src\main\jni\
|
||||||
|
* res\ => app\src\main\res\
|
||||||
|
* src\ => app\src\main\java\
|
||||||
|
|
||||||
|
Next Steps:
|
||||||
|
-----------
|
||||||
|
You can now build the project. The Gradle project needs network
|
||||||
|
connectivity to download dependencies.
|
||||||
|
|
||||||
|
Bugs:
|
||||||
|
-----
|
||||||
|
If for some reason your project does not build, and you determine that
|
||||||
|
it is due to a bug or limitation of the Eclipse to Gradle importer,
|
||||||
|
please file a bug at http://b.android.com with category
|
||||||
|
Component-Tools.
|
||||||
|
|
||||||
|
(This import summary is for your information only, and can be deleted
|
||||||
|
after import once you are satisfied with the results.)
|
||||||
9
local.properties
Normal file
9
local.properties
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## This file must *NOT* be checked into Version Control Systems,
|
||||||
|
# as it contains information specific to your local configuration.
|
||||||
|
#
|
||||||
|
# Location of the SDK. This is only used by Gradle.
|
||||||
|
# For customization when using a Version Control System, please read the
|
||||||
|
# header note.
|
||||||
|
#Sun Mar 17 17:14:41 KST 2019
|
||||||
|
ndk.dir=C\:\\Android\\sdk\\ndk-bundle
|
||||||
|
sdk.dir=C\:\\Android\\sdk
|
||||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
|||||||
|
include ':app'
|
||||||
Loading…
Reference in New Issue
Block a user