CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 29 thousand libraries and is used in over 1.8 million apps. CocoaPods can help you scale your projects elegantly.


https://jwkcp.github.io/2017/03/22/cocoapods_with_alamofire/


picker.MaxDate = DateTime.Now;

// 현재날짜 이후 선택불가

picker.MinDate = DateTime.Now;

// 현재날짜 이전 선택불가

'이것저것 > C# winform' 카테고리의 다른 글

String append  (0) 2017.11.28

String Append. 


string value = "abcd"; value += "efg";


Console.WriteLine(value);



--> abcdefg


'이것저것 > C# winform' 카테고리의 다른 글

c# Datetimepicker disable past dates  (0) 2017.12.08

testDialog = new AlertDialog.Builder(mContext) 

 .setCustomTitle(title_tv) .

 setMessage("1번 : 원격제어\n2번 : 센서 모니터링") 

 .create();

testDialog.show(); 


TextView msg_tv = (TextView)speechDialog.findViewById(android.R.id.message);

msg_tv.setTextSize(15);

msg_tv.setBackgroundColor(Color.WHITE);

(Objective-C)
1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@앱번들ID", UIApplicationOpenSettingsURLString]]];
cs

(Swift)

1
UIApplication.sharedApplication().openURL(NSURL(string: "\(UIApplicationOpenSettingsURLString)앱번들ID")!)
cs


PLX-DAQ 이용한 아두이노와 엑셀연동

https://www.parallax.com/downloads/plx-daq 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
int sensorA = A0;    
int sensorA_value = 0;
 
int sensorB = A1;    
int sensorB_value = 0;  
 
int sensorC = A2;    
int sensorC_value = 0;    
 
void setup() { 
  Serial.begin(9600);
  Serial.println("CLEARDATA"); //시작시 데이터 클리어
  Serial.println("LABEL,Time,SenserA,SenserB,SenserC"); // 테이블명  
}
 
void loop() {
  sensorA_value = analogRead(sensorA);
  sensorB_value = analogRead(sensorB);
  sensorC_value = analogRead(sensorC);    
 
 
  Serial.print("DATA,TIME,");                          
  Serial.print(sensorA_value); 
  Serial.print(",");              
  Serial.print(sensorB_value); 
  Serial.print(",");
  Serial.println(sensorC_value);
  
  delay(300000);
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int analogPin = 0;    // 워터센서 analog port 0 연결 선언
int val = 0;          // 전류변화값 변수선언
 
void setup ()
{
  Serial.begin (9600);           // 시리얼모니터 설정
}
 
void loop()
{
  val = analogRead(analogPin);   // analogPin 의 변화값(전류값)을 읽음
 
  Serial.println(val);      // 시리얼모니터에 전류값 표시
  delay (500);
}
 
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
 
void setup() {
  // declare the ledPin as an OUTPUT:
   Serial.begin(9600);  
}
 
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  delay(1000);          
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);                   
}
cs


구글 API 이용하여 원하는 주소값의 위도,경도 받아오기


google 프로젝트 등록 필요.

https://developers.google.com/maps/documentation/geocoding/get-api-key?hl=ko


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
 
public class Geocode {
    
    String response = "";
    
    String run(String address) throws IOException {
        HttpPost httpPost = new HttpPost("https://maps.googleapis.com/maps/api/geocode/json?address="+address+"&components=country:KR");
        
        HttpClient httpclient = new DefaultHttpClient();
        
        HttpResponse httpResponse = httpclient.execute(httpPost);
        
        response = EntityUtils.toString(httpResponse.getEntity());
        
        return response;
    }
}
 
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.IOException;
 
import org.apache.http.ParseException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
 
public class GeoThread extends Thread{
 
    Handler handler;
    boolean isRun = true;
    String address = "";
 
    public GeoThread(Handler handler){
        this.handler = handler;
    }
 
    public void run(){
        Geocode geo = new Geocode();
        Bundle bun = new Bundle();
            String response;
            try {
                response = geo.run(address);
                JSONObject json = new JSONObject(response);
                
                JSONArray results = (JSONArray) json.get("results");
                
                
                JSONObject resultsArray = (JSONObject) results.get(0);
 
                JSONObject jsonObject = (JSONObject) resultsArray.get("geometry");
                
                JSONObject jsonObject2 = (JSONObject) jsonObject.get("location");
 
 
                double address_lat = (double) jsonObject2.get("lat");
                double address_lng = (double) jsonObject2.get("lng");
                
 
                bun.putDouble("address_lat", address_lat);
                bun.putDouble("address_lng", address_lng);
                
                Message msg = handler.obtainMessage();
                msg.setData(bun);
                handler.sendMessage(msg);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
 
    }
 
}
cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
    원하는 Activity에서
 
                GeoThread geo = new GeoThread(addressHandler);
                
                String address = address_edt.getText().toString();
                address = address.replaceAll(" """);
                //주소에 
                geo.address = address;
                geo.start();
 
 
    Handler addressHandler = new Handler() {
        public void handleMessage(Message msg) {
            Bundle bun = msg.getData();
            
            double lat = bun.getDouble("address_lat");
            double lng = bun.getDouble("address_lng");
            
 
        }
    };
    
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
5초마다 반복하며 사진 찍는 코드
from picamera import PiCamera
from time import sleep
 
camera = PiCamera()
 
camera.start_preview()
for i in range(5):
   sleep(5)
   camera.capture('/home/pi/images.jpg' % i)
camera.stop_preview()
 
 
 /////////////////////////////////////////////////////////////////////
 
camera.sharpness = 0
camera.contrast = 0
camera.brightness = 50
camera.saturation = 0
camera.ISO = 0
camera.video_stabilization = False
camera.exposure_compensation = 0
camera.exposure_mode = 'auto'
camera.meter_mode = 'average'
camera.awb_mode = 'auto'
camera.image_effect = 'none'
camera.color_effects = None
camera.rotation = 0
camera.hflip = False
camera.vflip = False
camera.crop = (0.00.01.01.0)
cs

https://www.raspberrypi.org/documentation/usage/camera/python/README.md

AndroidManifest.xml

1
2
3
4
5
6
7
8
9
10
        <service android:name=".MyFcmListenerService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service android:name=".MyInstanceIDListenerService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>
cs

MyFcmListenerService.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public class MyFcmListenerService extends FirebaseMessagingService {
 
    @Override
    public void onMessageReceived(RemoteMessage message) {
        Map<StringString> data = message.getData();
 
        String time = data.get("time");
        String msg = data.get("message");
 
        sendPushNotification(time, msg);
    }
 
    private void sendPushNotification(String title, String message) {
        Intent intent = new Intent(this, LoginActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this0 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);
 
        long[] pattern = {200100500300};
 
 
        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.icon)
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setVibrate(pattern)
                .setSound(defaultSoundUri)
                .setLights(0000002555002000)
                .setContentIntent(pendingIntent);
 
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
        PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wakelock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
        wakelock.acquire(5000);
 
        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }
}
cs

MyInstanceIDListenerService.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class MyInstanceIDListenerService extends FirebaseInstanceIdService {
 
    @Override
    public void onTokenRefresh() {
        // Get updated InstanceID token.
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);
 
        // If you want to send messages to this application instance or
        // manage this apps subscriptions on the server side, send the
        // Instance ID token to your app server.
        sendRegistrationToServer(refreshedToken);
 
    }
 
 
    private void sendRegistrationToServer(String refreshedToken) {
    }
 
 
}
cs


+ Recent posts