package SBC.RockPi;

import anywheresoftware.b4a.BA;
import SBC.BasicSBCInfo;

@BA.ShortName("RockPi4B")

/**
 * Library untuk RockPi 4B
 * 
 * Untuk disable/enable i2c, pwm/ spi, uart
 * sudo nano /boot/hw_intfc.conf
 * 
 * intfc:pwm0=off
 * intfc:pwm1=off
 * intfc:uart2=on
 * intfc:uart4=on
 * intfc:spi1=off
 * intfc:spi2=off
 * intfc:i2c6=on
 * intfc:i2c7=on
 * 
 * edit on/off nya, save, kemudian sudo reboot
 * 
 * https://wiki.radxa.com/Rockpi4/hardware/devtree_overlays
 * https://wiki.radxa.com/Rockpi4/dev/libmraa
 * 
 * Catatan : 
 * UART4 dan SPI1 pin sama. Prioritas di UART4. Kalau mau pake SPI1, UART4 mesti off
 * I2C 6 dan SPI2 pin sama. Prioritas di I2C 6. Kalau mau pake SPI2, I2C 6 mesti off 
 * @author rdkartono
 *
 */
public class RockPi4B extends BasicSBCInfo  {
	//pin1 = +3.3V
	//pin2 = +5V
	public final int pin03 = 71;
	//pin4 = +5V
	public final int pin05 = 72;
	//pin6 = GND
	public final int pin07 = 75;
	public final int pin08 = 148;
	//pin9 = GND
	public final int pin10 = 147;
	public final int pin11 = 146;
	public final int pin12 = 131;
	public final int pin13 = 150;
	//pin14 = GND
	public final int pin15 = 149;
	public final int pin16 = 154;
	//pin17 = +3.3V
	public final int pin18 = 156;
	public final int pin19 = 40;
	//pin20 = GND
	public final int pin21 = 39;
	public final int pin22 = 157;
	public final int pin23 = 41;
	public final int pin24 = 42;
	//pin25 = GND
	// pin26 = ADC
	public final int pin27 = 64;
	public final int pin28 = 65;
	public final int pin29 = 74;
	//pin30 = GND
	public final int pin31 = 73;
	public final int pin32 = 112;
	public final int pin33 = 76;
	//pin34 = GND
	public final int pin35 = 133;
	public final int pin36 = 132;
	public final int pin37 = 158;
	public final int pin38 = 134;
	//pin39 = GND
	public final int pin40 = 135;
	
	public final String wlan_name = "wlan0";
	public final String eth_name = "eth0";
	
	/**
	 * UART2 = /dev/ttyS2
	 * TX = pin 8 (Sama seperti Raspi)
	 * RX = pin10 (Sama seperti Raspi)
	 * jangan lupa nyalakan intfc:uart2=on di /boot/hw_intfc.conf
	 */
	public final String serial2_name = "/dev/ttyS2";
	
	/**
	 * UART4 = /dev/ttyS4
	 * TX = pin19
	 * RX = pin21
	 * jangan lupa nyalakan intfc:uart4=on di /boot/hw_intfc.conf
	 */
	public final String serial4_name = "/dev/ttyS4";
	
	/**
	 * i2c-7
	 * SDA = pin03 (sama seperti Raspi)
	 * SCL = pin05 (sama seperti Raspi)
	 * jangan lupa nyalakan intfc:i2c7=on di /boot/hw_intfc.conf
	 */
	public final String i2c_7 = "/dev/i2c-7";
	
	/**
	 * i2c-6
	 * SDA = pin31
	 * SCL = pin29
	 * jangan lupa nyalakan intfc:i2c6=on di /boot/hw_intfc.conf
	 */
	public final String i2c_6 = "/dev/i2c-6";
	
	
	
	@Override
	public double Get_CPU_CoreVolt() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public RockPi4B() {
		super();
	}
	
	public void Initialize(BA bax, Object callerobject, String event) {
		setup_events(bax, callerobject, event, this);

	}

}
