Skip to content

Instantly share code, notes, and snippets.

@abrahamjso
abrahamjso / gist:2632504
Created May 8, 2012 04:08
comunication android-arduino
//Prendemos LED
public void sendOn(View v){
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.0.110/?L=1");
//Esta es nuestra url donde mandaremos el parametro uno
try {
//List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//Codigo anterior donde tenia el error, pero esto funciona si queremos hacer post
//nameValuePairs.add(new BasicNameValuePair("L", "1"));
//httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
@abrahamjso
abrahamjso / gist:2632706
Created May 8, 2012 04:56
communication ardiono-android2
#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 110 }; // ip in lan
byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(80); //server port
@abrahamjso
abrahamjso / gist:2718425
Created May 17, 2012 12:00
Views iOS example
-(void)ventanaCrear
{
UIView *ventanaFondo = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ventanaFondo.backgroundColor = [UIColor grayColor];
[self.view addSubview:ventanaFondo];
NSString *nombre = @"Creacion de un label";
UILabel *lnombre = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 500, 100)];
lnombre.backgroundColor = [UIColor clearColor];
lnombre.font = [lnombre.font fontWithSize:25];
@abrahamjso
abrahamjso / gist:2718459
Created May 17, 2012 12:04
Views iOS example1
UIView *ventanaFondo = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; //inicializamos la ventana con el
//nombre ventanaFondo, inicializando el frame con los tamanos del delegado
ventanaFondo.backgroundColor = [UIColor grayColor]; //A esta vista, contendra un color gris de fondo
[self.view addSubview:ventanaFondo]; //Agregamos la vista a la vista Padre (por lo general la llamamos con self.view)
@abrahamjso
abrahamjso / gist:2718485
Created May 17, 2012 12:09
Views iOS example2
NSString *nombre = @"Creacion de un label"; //Creamos un string donde sera el nombre del contenido de nuestro label
UILabel *lnombre = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 500, 100)]; //Inicializamos nuestro label
//Nosotros le damos las medidas y la posicion con CGRectMake(margenX, margenY, tamanoX, tamanoY)
lnombre.backgroundColor = [UIColor clearColor]; //nuestro label tendra un fondo sin color
lnombre.font = [lnombre.font fontWithSize:25]; //Podemos dar el tamno de la letre e inclusive el tipo, en este caso su tamano es 25
lnombre.text = [NSString stringWithFormat:@"%@", nombre]; //Le agregamos el contenido que habiamos guardado
[ventanaFondo addSubview:lnombre]; //Agregamos nuestro label a la vista ventanaFondo
@abrahamjso
abrahamjso / gist:2718516
Created May 17, 2012 12:14
Views iOS example3
UIButton *boton = [[UIButton alloc] initWithFrame:CGRectMake(20, 100, 100, 50)]; //Creamos nuestro boton con las medidas dadas
[boton addTarget:self action:@selector(hola:) forControlEvents: UIControlEventTouchDown];
//Al boton le agregados metodo que al pulsar mandara llamar al metodo hola
[boton setTitle:@"Boton" forState:UIControlStateNormal]; //El boton tendra como titulo Boton y tendra un estado normal (parecera como un label)
boton.backgroundColor = [UIColor blackColor]; //Le agregamos un colo negro de fondo, si no le agregamos esto nuestro boton parecera un label como ya mencionado(yo lo puse asi para diferenciarlo).
[boton setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal]; //Le agregamos un color a nuestro titulio
[ventanaFondo addSubview:boton]; //Agregamos el boton a la vistaFondo
@abrahamjso
abrahamjso / gist:2718531
Created May 17, 2012 12:16
Views iOS example4
UIImageView *imagen = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"migesa.jpg"]]]; //Creamos una ImageView, que es una imagen y la inicializaremos con el nombre de migesa.jpg, que esta la tenemos guardada en nuestra carpeta Archivos de Xcode
imagen.frame = CGRectMake(10, 200, 115, 115); //Damos el tamano de nuestra vistaImagen
[ventanaFondo addSubview:imagen]; //Agregamos la imagen a la ventanaFondo
<string>
<real>, <integer>
<true />, or <false />
<date>
<data>
<array>
<dict>
<key>
@abrahamjso
abrahamjso / gist:2779486
Created May 24, 2012 04:42
read plist iOS
-(void)plistVista
{
NSString *path = [[NSBundle mainBundle] bundlePath]; //inicializamos el path
NSString *plistName = @"vistas.plist"; //Guardamos la direccion del archivo a leer
NSString *finalPath = [path stringByAppendingPathComponent:plistName]; //Leemos la direccion,
//guardandola en un string
NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:finalPath]; //inicializamos el diccionario
int cplistData = plistData.count; //Contamos las filas que contiene nuestro plis de nodo padre
//Essto nos servira para leer cada linea
for(int i = 0; i < cplistData; i++) //Inicializamos el for para su lectura
@abrahamjso
abrahamjso / gist:2779593
Created May 24, 2012 05:07
metodos Touch iOS
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event