first commit
This commit is contained in:
BIN
lib/bananapi/dynamic/libpi4j.so
Normal file
BIN
lib/bananapi/dynamic/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/bananapi/static/libpi4j.so
Normal file
BIN
lib/bananapi/static/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/bananapro/dynamic/libpi4j.so
Normal file
BIN
lib/bananapro/dynamic/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/bananapro/static/libpi4j.so
Normal file
BIN
lib/bananapro/static/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/bpi/dynamic/libpi4j.so
Normal file
BIN
lib/bpi/dynamic/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/bpi/static/libpi4j.so
Normal file
BIN
lib/bpi/static/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/hidapi/darwin/libhidapi.dylib
Normal file
BIN
lib/hidapi/darwin/libhidapi.dylib
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-aarch64/libhidapi-libusb.so
Normal file
BIN
lib/hidapi/linux-aarch64/libhidapi-libusb.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-aarch64/libhidapi.so
Normal file
BIN
lib/hidapi/linux-aarch64/libhidapi.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-amd64/libhidapi-libusb.so
Normal file
BIN
lib/hidapi/linux-amd64/libhidapi-libusb.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-amd64/libhidapi.so
Normal file
BIN
lib/hidapi/linux-amd64/libhidapi.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-arm/libhidapi-libusb.so
Normal file
BIN
lib/hidapi/linux-arm/libhidapi-libusb.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-arm/libhidapi.so
Normal file
BIN
lib/hidapi/linux-arm/libhidapi.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-armel/libhidapi-libusb.so
Normal file
BIN
lib/hidapi/linux-armel/libhidapi-libusb.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-armel/libhidapi.so
Normal file
BIN
lib/hidapi/linux-armel/libhidapi.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-x86-64/libhidapi-libusb.so
Normal file
BIN
lib/hidapi/linux-x86-64/libhidapi-libusb.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-x86-64/libhidapi.so
Normal file
BIN
lib/hidapi/linux-x86-64/libhidapi.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-x86/libhidapi-libusb.so
Normal file
BIN
lib/hidapi/linux-x86/libhidapi-libusb.so
Normal file
Binary file not shown.
BIN
lib/hidapi/linux-x86/libhidapi.so
Normal file
BIN
lib/hidapi/linux-x86/libhidapi.so
Normal file
Binary file not shown.
BIN
lib/hidapi/win32-x86-64/hidapi.dll
Normal file
BIN
lib/hidapi/win32-x86-64/hidapi.dll
Normal file
Binary file not shown.
BIN
lib/hidapi/win32-x86/hidapi.dll
Normal file
BIN
lib/hidapi/win32-x86/hidapi.dll
Normal file
Binary file not shown.
BIN
lib/nanopi/dynamic/libpi4j.so
Normal file
BIN
lib/nanopi/dynamic/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/nanopi/static/libpi4j.so
Normal file
BIN
lib/nanopi/static/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/odroid/dynamic/libpi4j.so
Normal file
BIN
lib/odroid/dynamic/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/odroid/static/libpi4j.so
Normal file
BIN
lib/odroid/static/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/orangepi/dynamic/libpi4j.so
Normal file
BIN
lib/orangepi/dynamic/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/orangepi/static/libpi4j.so
Normal file
BIN
lib/orangepi/static/libpi4j.so
Normal file
Binary file not shown.
BIN
lib/raspberrypi/dynamic/libpi4j.so
Normal file
BIN
lib/raspberrypi/dynamic/libpi4j.so
Normal file
Binary file not shown.
22
src/ModbusWrapper/jModbusCoil.java
Normal file
22
src/ModbusWrapper/jModbusCoil.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package ModbusWrapper;
|
||||||
|
|
||||||
|
import com.intelligt.modbus.jlibmodbus.data.ModbusCoils;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("ModbusCoils")
|
||||||
|
/***
|
||||||
|
* ModbusCoil dataholder
|
||||||
|
* by default, create 1024 coils
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class jModbusCoil extends ModbusCoils {
|
||||||
|
public jModbusCoil() {
|
||||||
|
super(1024);
|
||||||
|
}
|
||||||
|
public jModbusCoil(int size) {
|
||||||
|
super(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
22
src/ModbusWrapper/jModbusHoldingRegister.java
Normal file
22
src/ModbusWrapper/jModbusHoldingRegister.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package ModbusWrapper;
|
||||||
|
|
||||||
|
import com.intelligt.modbus.jlibmodbus.data.ModbusHoldingRegisters;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("ModbusHoldingRegisters")
|
||||||
|
/**
|
||||||
|
* ModbusHoldingRegister dataholder
|
||||||
|
* by default create 1024 registers
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class jModbusHoldingRegister extends ModbusHoldingRegisters {
|
||||||
|
public jModbusHoldingRegister(){
|
||||||
|
super(1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
public jModbusHoldingRegister(int size){
|
||||||
|
super(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
447
src/ModbusWrapper/jModbusMaster.java
Normal file
447
src/ModbusWrapper/jModbusMaster.java
Normal file
@@ -0,0 +1,447 @@
|
|||||||
|
package ModbusWrapper;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import com.fazecast.jSerialComm.SerialPort;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.Modbus;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.exception.ModbusIOException;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.exception.ModbusNumberException;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.exception.ModbusProtocolException;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.master.ModbusMaster;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialParameters;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialUtils;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialPort.BaudRate;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialPort.Parity;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialPortException;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.tcp.TcpParameters;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.utils.FrameEvent;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.utils.FrameEventListener;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.Bit;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
|
||||||
|
@BA.ShortName("jModbusMaster")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"datasent(bb() as byte)",
|
||||||
|
"datareceived(bb() as byte)"
|
||||||
|
})
|
||||||
|
//@BA.DependsOn(values = { "jSerialComm-2.6.2","jlibmodbus-1.2.9.7" })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Modbus Master
|
||||||
|
* in Modbus, Master is actually a client that request data from server (Slave)
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class jModbusMaster {
|
||||||
|
private Object caller;
|
||||||
|
private String event;
|
||||||
|
private BA ba;
|
||||||
|
private final Object Me = this;
|
||||||
|
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_datasent_event = false;
|
||||||
|
private boolean need_datareceived_event = false;
|
||||||
|
|
||||||
|
private ModbusMaster modbus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize ModbusSerialSlaveRTU
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object callerobject, String eventname) {
|
||||||
|
this.ba = ba;
|
||||||
|
event = eventname.trim();
|
||||||
|
caller = callerobject;
|
||||||
|
|
||||||
|
if (this.ba!=null) {
|
||||||
|
if (caller!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = this.ba.subExists(event+"_log");
|
||||||
|
need_datasent_event = this.ba.subExists(event+"_datasent");
|
||||||
|
need_datareceived_event = this.ba.subExists(event+"_datareceived");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get available Serial Port Names
|
||||||
|
* @return List of port names. If exists, List size > 0
|
||||||
|
*/
|
||||||
|
public List GetSerialPortNames() {
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
|
||||||
|
|
||||||
|
SerialPort[] sp = SerialPort.getCommPorts();
|
||||||
|
if (sp!=null) {
|
||||||
|
if (sp.length>0) {
|
||||||
|
for(SerialPort xx : sp) {
|
||||||
|
result.Add(xx.getSystemPortName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Modbus Master in Serial ASCII format
|
||||||
|
* @param serialname : serial port name
|
||||||
|
* @param baudrate : baud rate, typically 4800, 9600, 144400, 19200, 38400, 57600, 115200
|
||||||
|
* @param databit : data bit length , typically 8
|
||||||
|
* @param stopbit : typically 1
|
||||||
|
* @param parity : 0 = None, 1 = Odd, 2 = Even, 3 = Mark, 4 = Space
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean OpenSerial_ASCII(String serialname, int baudrate, int databit, int stopbit, int parity) {
|
||||||
|
SerialParameters sp = new SerialParameters();
|
||||||
|
|
||||||
|
sp.setDataBits(databit);
|
||||||
|
sp.setDevice(serialname);
|
||||||
|
sp.setStopBits(stopbit);
|
||||||
|
sp.setBaudRate(BaudRate.getBaudRate(baudrate));
|
||||||
|
sp.setParity(Parity.getParity(parity));
|
||||||
|
|
||||||
|
SerialUtils.setSerialPortFactoryJSerialComm();
|
||||||
|
|
||||||
|
try {
|
||||||
|
modbus = ModbusMasterFactory.createModbusMasterASCII(sp);
|
||||||
|
modbus.addListener(listener);
|
||||||
|
modbus.connect();
|
||||||
|
return true;
|
||||||
|
} catch (SerialPortException e) {
|
||||||
|
raise_log("OpenSerial_ASCII failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Modbus Connect failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Modbus Master in Serial RTU format
|
||||||
|
* @param serialname : serial port name
|
||||||
|
* @param baudrate : baud rate, typically 4800, 9600, 144400, 19200, 38400, 57600, 115200
|
||||||
|
* @param databit : data bit length , typically 8
|
||||||
|
* @param stopbit : typically 1
|
||||||
|
* @param parity : 0 = None, 1 = Odd, 2 = Even, 3 = Mark, 4 = Space
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean OpenSerial_RTU(String serialname, int baudrate, int databit, int stopbit, int parity) {
|
||||||
|
SerialParameters sp = new SerialParameters();
|
||||||
|
|
||||||
|
sp.setDataBits(databit);
|
||||||
|
sp.setDevice(serialname);
|
||||||
|
sp.setStopBits(stopbit);
|
||||||
|
sp.setBaudRate(BaudRate.getBaudRate(baudrate));
|
||||||
|
sp.setParity(Parity.getParity(parity));
|
||||||
|
|
||||||
|
SerialUtils.setSerialPortFactoryJSerialComm();
|
||||||
|
|
||||||
|
try {
|
||||||
|
modbus = ModbusMasterFactory.createModbusMasterRTU(sp);
|
||||||
|
modbus.addListener(listener);
|
||||||
|
modbus.connect();
|
||||||
|
return true;
|
||||||
|
} catch (SerialPortException e) {
|
||||||
|
raise_log("OpenSerial_RTU failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Modbus Connect failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Modbus Master in TCP
|
||||||
|
* @param hostaddress : target slave IP address
|
||||||
|
* @param port : tcp port. if negative, will use default 502
|
||||||
|
* @param enable_keepalive : set true to enable keep alive connection
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean OpenTCP(String hostaddress, int port, boolean enable_keepalive) {
|
||||||
|
InetAddress host;
|
||||||
|
try {
|
||||||
|
host = InetAddress.getByName(hostaddress);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
raise_log("OpenTCP failed, Invalid hostaddress="+hostaddress+", Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port<1) port = Modbus.TCP_PORT;
|
||||||
|
TcpParameters tp = new TcpParameters();
|
||||||
|
tp.setPort(port);
|
||||||
|
tp.setHost(host);
|
||||||
|
tp.setKeepAlive(enable_keepalive);
|
||||||
|
|
||||||
|
modbus = ModbusMasterFactory.createModbusMasterTCP(tp);
|
||||||
|
modbus.addListener(listener);
|
||||||
|
try {
|
||||||
|
modbus.connect();
|
||||||
|
return true;
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Modbus Connect failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Modbus Master connection
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Close() {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
modbus.removeListeners();
|
||||||
|
try {
|
||||||
|
modbus.disconnect();
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Modbus Disconnect failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Write Single Coil (command = 5)
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param coil_address : coil address
|
||||||
|
* @param is_on : true = 1, false = 0
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean WriteSingleCoil(int slave_address, int coil_address, boolean is_on) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
modbus.writeSingleCoil(slave_address, coil_address, is_on);
|
||||||
|
return true;
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("WriteSingleCoil failed, Msg : "+e.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Single Register (command = 6)
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param register_address : register address
|
||||||
|
* @param value : register value , 16 bit
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean WriteSingleRegister(int slave_address, int register_address, int value) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
modbus.writeSingleRegister(slave_address, register_address, value);
|
||||||
|
return true;
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("WriteSingleRegister failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write multiple coils (command = 15)
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param start_address : start address of coils
|
||||||
|
* @param values : array of boolean for coils, true = 1, false = 0
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean WriteMultipleCoils(int slave_address, int start_address, boolean[] values) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
modbus.writeMultipleCoils(slave_address, start_address, values);
|
||||||
|
return true;
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("WriteMultipleCoils failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Multiple Register (command = 16)
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param start_address : start address of register
|
||||||
|
* @param values : array of int (16 bit) for registers
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean WriteMultipleRegisters(int slave_address, int start_address, int[] values) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
modbus.writeMultipleRegisters(slave_address, start_address, values);
|
||||||
|
return true;
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("WriteMultipleRegisters failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read Single coil (command = 1)
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param coil_address : coil address
|
||||||
|
* @return -1 = failed, 0 = false, 1 = true
|
||||||
|
*/
|
||||||
|
public int ReadSingleCoil(int slave_address, int coil_address) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
boolean[] result = modbus.readCoils(slave_address, coil_address, 1);
|
||||||
|
if (result!=null) {
|
||||||
|
if (result.length>0) {
|
||||||
|
if (result[0]) return 1; else return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("ReadSingleCoil failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read single Register (16 bit) (command = 3)
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param register_address : register address
|
||||||
|
* @return -1 = failed, other = register value
|
||||||
|
*/
|
||||||
|
public int ReadSingleRegister(int slave_address, int register_address) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
int[] result = modbus.readHoldingRegisters(slave_address, register_address, 1);
|
||||||
|
if (result!=null) {
|
||||||
|
if (result.length>0) {
|
||||||
|
return Bit.And(result[0], 0xFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("ReadSingleRegister failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read multiple coils
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param start_address : coil start address
|
||||||
|
* @param quantity : how many coils want to be read
|
||||||
|
* @return array of boolean, or null if failed.
|
||||||
|
*/
|
||||||
|
public boolean[] ReadMultipleCoils(int slave_address, int start_address, int quantity) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
boolean[] result = modbus.readCoils(slave_address, start_address, quantity);
|
||||||
|
if (result!=null) {
|
||||||
|
if (result.length>0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("ReadMultipleCoils failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read multiple registers
|
||||||
|
* @param slave_address : slave address
|
||||||
|
* @param start_address : register start address
|
||||||
|
* @param quantity : how many registers want to be read
|
||||||
|
* @return array of int, or null if failed
|
||||||
|
*/
|
||||||
|
public int[] ReadMultipleRegisters(int slave_address, int start_address, int quantity) {
|
||||||
|
if (modbus instanceof ModbusMaster) {
|
||||||
|
if (modbus.isConnected()) {
|
||||||
|
try {
|
||||||
|
int[] result = modbus.readHoldingRegisters(slave_address, start_address, quantity);
|
||||||
|
if (result!=null) {
|
||||||
|
if (result.length>0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ModbusProtocolException | ModbusNumberException | ModbusIOException e) {
|
||||||
|
raise_log("ReadMultipleRegisters failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) ba.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_datasent(byte[] value) {
|
||||||
|
if (need_datasent_event) ba.raiseEventFromDifferentThread(Me, null, 0, event+"_datasent", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_datareceived(byte[] value) {
|
||||||
|
if (need_datareceived_event) ba.raiseEventFromDifferentThread(Me, null, 0, event+"_datareceived", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String printbytes(byte[] bb) {
|
||||||
|
if (bb!=null) {
|
||||||
|
if (bb.length>0) {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
for(byte xx: bb) {
|
||||||
|
str.append(Bit.ToHexString(Bit.And(xx, 0xFF))).append(" ");
|
||||||
|
}
|
||||||
|
return str.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
FrameEventListener listener = new FrameEventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void frameSentEvent(FrameEvent event) {
|
||||||
|
|
||||||
|
raise_log("Data Sent : "+printbytes(event.getBytes()));
|
||||||
|
raise_datasent(event.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void frameReceivedEvent(FrameEvent event) {
|
||||||
|
raise_log("Data Received : "+printbytes(event.getBytes()));
|
||||||
|
raise_datareceived(event.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
345
src/ModbusWrapper/jModbusSlave.java
Normal file
345
src/ModbusWrapper/jModbusSlave.java
Normal file
@@ -0,0 +1,345 @@
|
|||||||
|
package ModbusWrapper;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import com.fazecast.jSerialComm.SerialPort;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.Modbus;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.data.DataHolder;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.exception.ModbusIOException;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialParameters;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialPort.BaudRate;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialPort.Parity;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialPortException;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialUtils;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.slave.ModbusSlave;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.slave.ModbusSlaveFactory;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.tcp.TcpParameters;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.utils.FrameEvent;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.utils.FrameEventListener;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.Bit;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
|
||||||
|
@BA.ShortName("jModbusSlave")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"datasent(bb() as byte)",
|
||||||
|
"datareceived(bb() as byte)"
|
||||||
|
})
|
||||||
|
//@BA.DependsOn(values = { "jSerialComm-2.6.2","jlibmodbus-1.2.9.7" })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Modbus Slave
|
||||||
|
* in Modbus, Slave is actually a server that hold data.
|
||||||
|
* Master is a client, that request data from server.
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class jModbusSlave {
|
||||||
|
|
||||||
|
|
||||||
|
private Object caller;
|
||||||
|
private String event;
|
||||||
|
private BA ba;
|
||||||
|
private final Object Me = this;
|
||||||
|
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_datasent_event = false;
|
||||||
|
private boolean need_datareceived_event = false;
|
||||||
|
|
||||||
|
|
||||||
|
private ModbusSlave modbus = null;
|
||||||
|
private DataHolder dh = null;
|
||||||
|
private jModbusCoil coil = null;
|
||||||
|
private jModbusHoldingRegister reg = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize ModbusSerialSlaveRTU
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object callerobject, String eventname) {
|
||||||
|
this.ba = ba;
|
||||||
|
event = eventname.trim();
|
||||||
|
caller = callerobject;
|
||||||
|
dh = new DataHolder();
|
||||||
|
if (this.ba!=null) {
|
||||||
|
if (caller!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = this.ba.subExists(event+"_log");
|
||||||
|
need_datasent_event = this.ba.subExists(event+"_datasent");
|
||||||
|
need_datareceived_event = this.ba.subExists(event+"_datareceived");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get available Serial Port Names
|
||||||
|
* @return List of port names. If exists, List size > 0
|
||||||
|
*/
|
||||||
|
public List GetSerialPortNames() {
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
|
||||||
|
|
||||||
|
SerialPort[] sp = SerialPort.getCommPorts();
|
||||||
|
if (sp!=null) {
|
||||||
|
if (sp.length>0) {
|
||||||
|
for(SerialPort xx : sp) {
|
||||||
|
result.Add(xx.getSystemPortName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Modbus Slave in Serial ASCII format
|
||||||
|
* @param serialname : serial port name
|
||||||
|
* @param baudrate : baud rate, typically 4800, 9600, 144400, 19200, 38400, 57600, 115200
|
||||||
|
* @param databit : data bit length , typically 8
|
||||||
|
* @param stopbit : typically 1
|
||||||
|
* @param parity : 0 = None, 1 = Odd, 2 = Even, 3 = Mark, 4 = Space
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean OpenSerial_ASCII(String serialname, int baudrate, int databit, int stopbit, int parity) {
|
||||||
|
SerialParameters sp = new SerialParameters();
|
||||||
|
|
||||||
|
sp.setDataBits(databit);
|
||||||
|
sp.setDevice(serialname);
|
||||||
|
sp.setStopBits(stopbit);
|
||||||
|
sp.setBaudRate(BaudRate.getBaudRate(baudrate));
|
||||||
|
sp.setParity(Parity.getParity(parity));
|
||||||
|
|
||||||
|
SerialUtils.setSerialPortFactoryJSerialComm();
|
||||||
|
|
||||||
|
try {
|
||||||
|
modbus = ModbusSlaveFactory.createModbusSlaveASCII(sp);
|
||||||
|
modbus.addListener(listener);
|
||||||
|
if (dh==null) dh = new DataHolder();
|
||||||
|
modbus.setDataHolder(dh);
|
||||||
|
modbus.listen();
|
||||||
|
return true;
|
||||||
|
} catch(SerialPortException e) {
|
||||||
|
raise_log("OpenSerial_ASCII failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Modbus Listen failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Modbus Slave in Serial RTU format
|
||||||
|
* @param serialname : serial port name
|
||||||
|
* @param baudrate : baud rate, typically 4800, 9600, 144400, 19200, 38400, 57600, 115200
|
||||||
|
* @param databit : data bit length , typically 8
|
||||||
|
* @param stopbit : typically 1
|
||||||
|
* @param parity : 0 = None, 1 = Odd, 2 = Even, 3 = Mark, 4 = Space
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean OpenSerial_RTU(String serialname, int baudrate, int databit, int stopbit, int parity) {
|
||||||
|
|
||||||
|
SerialParameters sp = new SerialParameters();
|
||||||
|
|
||||||
|
sp.setDataBits(databit);
|
||||||
|
sp.setDevice(serialname);
|
||||||
|
sp.setStopBits(stopbit);
|
||||||
|
sp.setBaudRate(BaudRate.getBaudRate(baudrate));
|
||||||
|
sp.setParity(Parity.getParity(parity));
|
||||||
|
|
||||||
|
SerialUtils.setSerialPortFactoryJSerialComm();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
modbus = ModbusSlaveFactory.createModbusSlaveRTU(sp);
|
||||||
|
|
||||||
|
modbus.addListener(listener);
|
||||||
|
if (dh==null) dh = new DataHolder();
|
||||||
|
modbus.setDataHolder(dh);
|
||||||
|
modbus.listen();
|
||||||
|
return true;
|
||||||
|
} catch (SerialPortException e) {
|
||||||
|
raise_log("OpenSerial_RTU failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Modbus Listen failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Modbus Slave in TCP
|
||||||
|
* @param hostaddress : network adapter IP address, or empty string for default ip address
|
||||||
|
* @param port : port number, if negative number, will use default TCP port 502
|
||||||
|
* @param enable_keepalive : set true to enable keep alive connection
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean OpenTCP(String hostaddress, int port, boolean enable_keepalive) {
|
||||||
|
InetAddress host;
|
||||||
|
try {
|
||||||
|
if (hostaddress.isEmpty()) {
|
||||||
|
host = InetAddress.getLocalHost();
|
||||||
|
} else {
|
||||||
|
host = InetAddress.getByName(hostaddress);
|
||||||
|
}
|
||||||
|
} catch (UnknownHostException | SecurityException e) {
|
||||||
|
raise_log("Unable to get InetAddress for host="+hostaddress+", Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port<1) port = Modbus.TCP_PORT;
|
||||||
|
|
||||||
|
TcpParameters tp = new TcpParameters();
|
||||||
|
tp.setPort(port);
|
||||||
|
tp.setHost(host);
|
||||||
|
tp.setKeepAlive(enable_keepalive);
|
||||||
|
|
||||||
|
modbus = ModbusSlaveFactory.createModbusSlaveTCP(tp);
|
||||||
|
if (dh==null) dh = new DataHolder();
|
||||||
|
|
||||||
|
modbus.setDataHolder(dh);
|
||||||
|
modbus.addListener(listener);
|
||||||
|
try {
|
||||||
|
modbus.listen();
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Unable to start Modbus Listen, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get / Set Slave ID.
|
||||||
|
* On getting, when returning -1, means modbus not yet opened
|
||||||
|
*/
|
||||||
|
public void setID(int value) {
|
||||||
|
if (modbus!=null) {
|
||||||
|
modbus.setServerAddress(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
if (modbus!=null) {
|
||||||
|
return modbus.getServerAddress();
|
||||||
|
} else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize coils
|
||||||
|
* coil is binary (true/false) value, 1 bit
|
||||||
|
* @param size : how many coils want to initialize. If < 1, default to 1024
|
||||||
|
*/
|
||||||
|
public void Initialize_Coils(int size) {
|
||||||
|
if (size>0)
|
||||||
|
coil = new jModbusCoil(size);
|
||||||
|
else
|
||||||
|
coil = new jModbusCoil();
|
||||||
|
|
||||||
|
if (dh==null) dh = new DataHolder();
|
||||||
|
dh.setCoils(coil);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Coils that already been initialized
|
||||||
|
* @return null if failed
|
||||||
|
*/
|
||||||
|
public jModbusCoil getCoils() {
|
||||||
|
return coil;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Registers that already been initialized
|
||||||
|
* @return null if failed
|
||||||
|
*/
|
||||||
|
public jModbusHoldingRegister getRegisters() {
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Register
|
||||||
|
* Register is 16 bit value, can read and write
|
||||||
|
* @param size : how many registers want to initialize. If < 1, default to 1024
|
||||||
|
*/
|
||||||
|
public void Initialize_Registers(int size) {
|
||||||
|
if (size>0)
|
||||||
|
reg = new jModbusHoldingRegister(size);
|
||||||
|
else
|
||||||
|
reg = new jModbusHoldingRegister();
|
||||||
|
|
||||||
|
if (dh==null) dh = new DataHolder();
|
||||||
|
dh.setHoldingRegisters(reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Modbus Serial Slave RTU
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Close() {
|
||||||
|
if (modbus!=null) {
|
||||||
|
try {
|
||||||
|
modbus.removeListeners();
|
||||||
|
modbus.shutdown();
|
||||||
|
} catch (ModbusIOException e) {
|
||||||
|
raise_log("Modbus Close failed, Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) ba.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_datasent(byte[] value) {
|
||||||
|
if (need_datasent_event) ba.raiseEventFromDifferentThread(Me, null, 0, event+"_datasent", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_datareceived(byte[] value) {
|
||||||
|
if (need_datareceived_event) ba.raiseEventFromDifferentThread(Me, null, 0, event+"_datareceived", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String printbytes(byte[] bb) {
|
||||||
|
if (bb!=null) {
|
||||||
|
if (bb.length>0) {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
for(byte xx: bb) {
|
||||||
|
str.append(Bit.ToHexString(Bit.And(xx, 0xFF))).append(" ");
|
||||||
|
}
|
||||||
|
return str.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
FrameEventListener listener = new FrameEventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void frameSentEvent(FrameEvent event) {
|
||||||
|
|
||||||
|
raise_log("Data Sent : "+printbytes(event.getBytes()));
|
||||||
|
raise_datasent(event.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void frameReceivedEvent(FrameEvent event) {
|
||||||
|
raise_log("Data Received : "+printbytes(event.getBytes()));
|
||||||
|
raise_datareceived(event.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
1275
src/SBC/BasicSBCInfo.java
Normal file
1275
src/SBC/BasicSBCInfo.java
Normal file
File diff suppressed because it is too large
Load Diff
126
src/SBC/NanoPi/Duo2.java
Normal file
126
src/SBC/NanoPi/Duo2.java
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
package SBC.NanoPi;
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Nanopi_Duo2_Pin")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nanopi Duo2
|
||||||
|
* Source : https://wiki.friendlyelec.com/wiki/index.php/NanoPi_Duo2#Hardware_Spec
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Duo2 extends BasicSBCInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 09, shared with Infrared RX port
|
||||||
|
*/
|
||||||
|
public final int pin09 = 363;
|
||||||
|
|
||||||
|
public final int pin11 = 203;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 02, shared with Debug Port UART 0 RX
|
||||||
|
*/
|
||||||
|
public final int pin02 = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 04, shared with Debug Port UART 0 TX
|
||||||
|
*/
|
||||||
|
public final int pin04 = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 08, shared with I2C-0 SCL
|
||||||
|
*/
|
||||||
|
public final int pin08 = 11;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 10, shared with I2C-0 SDA
|
||||||
|
*/
|
||||||
|
public final int pin10 = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 12, shared with UART 3 TX , or SPI 1 CS
|
||||||
|
*/
|
||||||
|
public final int pin12 = 13;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 14, shared with UART 3 RX, or SPI 1 CLK
|
||||||
|
*/
|
||||||
|
public final int pin14 = 14;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 16, shared with UART 3 CTS, or SPI 1 MISO
|
||||||
|
*/
|
||||||
|
public final int pin16 = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 18, shared with UART 3 RTS, or SPI 1 MOSI
|
||||||
|
*/
|
||||||
|
public final int pin18 = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 20, shared with UART 1 RX
|
||||||
|
*/
|
||||||
|
public final int pin20 = 199;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin 22, shared with UART 1 TX
|
||||||
|
*/
|
||||||
|
public final int pin22 = 198;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I2C 0
|
||||||
|
*/
|
||||||
|
public final String i2c_0 = "/dev/i2c-0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ethernet name
|
||||||
|
*/
|
||||||
|
public final String eth_name = "eth0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UART 0 used for Debug Port
|
||||||
|
*/
|
||||||
|
public final String serial0_name = "/dev/ttyS0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UART 1 name
|
||||||
|
*/
|
||||||
|
public final String serial1_name = "/dev/ttyS1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UART 3 name
|
||||||
|
*/
|
||||||
|
public final String serial3_name = "/dev/ttyS3";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPIO-based Infrared Receiver name
|
||||||
|
*/
|
||||||
|
public final String GPIO_IR_Receiver_name = "/dev/input/gpio_ir_recv";
|
||||||
|
|
||||||
|
public final LibFriendlyArmHardware WiringNP;
|
||||||
|
|
||||||
|
public Duo2() {
|
||||||
|
super();
|
||||||
|
WiringNP = new LibFriendlyArmHardware();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
@Override
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Nanopi Duo2
|
||||||
|
* @param callerobject Caller object
|
||||||
|
* @param event Event string
|
||||||
|
*/
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
238
src/SBC/NanoPi/LibFriendlyArmHardware.java
Normal file
238
src/SBC/NanoPi/LibFriendlyArmHardware.java
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
package SBC.NanoPi;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
|
||||||
|
public class LibFriendlyArmHardware {
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Native.register(LibFriendlyArmHardware.class,"fahw");
|
||||||
|
System.out.println("registered to library fahw");
|
||||||
|
}catch(Exception e) {
|
||||||
|
System.out.println("Unable to register fahw library");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Board
|
||||||
|
public final static int BOARD_MINI6410 = 6410;
|
||||||
|
public final static int BOARD_MINI210 = 210;
|
||||||
|
public final static int BOARD_TINY4412 = 4412;
|
||||||
|
public final static int BOARD_NANOPI_M1 = 68330; // H3
|
||||||
|
public final static int BOARD_NANOPI_2 = 44180;
|
||||||
|
public final static int BOARD_NANOPI_2_FIRE = 44184;
|
||||||
|
public final static int BOARD_NANOPI_M2 = 44185;
|
||||||
|
public final static int BOARD_NANOPC_T2 = 44181;
|
||||||
|
public final static int BOARD_NANOPI_M3 = 68187;
|
||||||
|
public final static int BOARD_NANOPC_T3 = 68181;
|
||||||
|
|
||||||
|
native public int boardInit();
|
||||||
|
//void clearLastError(); // gak jelas
|
||||||
|
native public int writeValueToFile(String fileName, byte[] buff);
|
||||||
|
native public int writeIntValueToFile(String fileName, int value);
|
||||||
|
native public int readValueFromFile(String fileName, byte[] buff, int len);
|
||||||
|
native public int readIntValueFromFile(String fileName);
|
||||||
|
|
||||||
|
// Note : const char *devname --> string devName
|
||||||
|
native public int openHW(String devName, int flags);
|
||||||
|
// Note : const void *_data --> Pointer _data
|
||||||
|
native public int writeHW(int fd, final Pointer _data, int len);
|
||||||
|
native public int readHW(int fd, Pointer _data, int len);
|
||||||
|
native public int selectHW(int fd, int sec, int usec);
|
||||||
|
native public void closeHW(int fd);
|
||||||
|
native public int ioctlWithIntValue(int fd, int cmd, int value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// GPIO
|
||||||
|
// GPIO Direction
|
||||||
|
public final static int GPIO_IN = 1;
|
||||||
|
public final static int GPIO_OUT = 2;
|
||||||
|
// GPIO Value
|
||||||
|
public final static int GPIO_LOW = 0;
|
||||||
|
public final static int GPIO_HIGH = 1;
|
||||||
|
|
||||||
|
native public int initPinGPIO(int board);
|
||||||
|
native public int pintoGPIO(int pin);
|
||||||
|
native public int exportGPIOPin(int pin);
|
||||||
|
native public int unexportGPIOPin(int pin);
|
||||||
|
native public int setGPIODirection(int pin, int direction);
|
||||||
|
native public int getGPIODirection(int pin);
|
||||||
|
native public int setGPIOValue(int pin, int value);
|
||||||
|
native public int getGPIOValue(int pin);
|
||||||
|
native public int getLedState(int ledID);
|
||||||
|
native public int setLedState(int ledID, int ledState);
|
||||||
|
|
||||||
|
//I2C
|
||||||
|
native public int I2CReadByte(int fd, int wait_ms);
|
||||||
|
native public int I2CReadByteFrom(int fd, int pos, int wait_ms);
|
||||||
|
// Note : unsigned char byteData --> byte byteData
|
||||||
|
native public int I2CWriteByte(int fd, byte byteData, int wait_ms);
|
||||||
|
// Note : unsigned char byteData --> byte byteData
|
||||||
|
native public int I2CWriteByteTo(int fd, int pos, byte byteData, int wait_ms);
|
||||||
|
native public int setI2CRetries(int fd, int retries);
|
||||||
|
native public int setI2CSlave(int fd, int slave);
|
||||||
|
native public int setI2CTimeout(int fd, int timeout);
|
||||||
|
// gak ada ternyata
|
||||||
|
//native public int openI2CDevice();
|
||||||
|
|
||||||
|
//SPI
|
||||||
|
// SPI Bit Order
|
||||||
|
public static final int LSB_First = 0;
|
||||||
|
public static final int MSB_First = 1;
|
||||||
|
// SPI Mode
|
||||||
|
public static final int SPI_Mode0 = 0 ; ///< CPOL (0, CPHA (0
|
||||||
|
public static final int SPI_Mode1 = 1 ; ///< CPOL (0, CPHA (1
|
||||||
|
public static final int SPI_Mode2 = 2 ; ///< CPOL (1, CPHA (0
|
||||||
|
public static final int SPI_Mode3 = 3 ; ///< CPOL (1, CPHA (1
|
||||||
|
native public int SPItransferBytes(int spi_fd, byte[] writeData, int writeLen, byte[] readBuffer, int readLen, int spi_delay, int spi_speed, int spi_bits);
|
||||||
|
native public int SPItransferOneByte(int spi_fd, byte byteData, int spi_delay, int spi_speed, int spi_bits);
|
||||||
|
native public int readBytesFromSPI(int spi_fd, byte[] readBuffer, int readLen, int spi_delay, int spi_speed, int spi_bits);
|
||||||
|
native public int writeBytesToSPI(int spi_fd, byte[] writeData, int writeLen, int spi_delay, int spi_speed, int spi_bits);
|
||||||
|
native public int setSPIBitOrder( int spi_fd, int order);
|
||||||
|
native public int setSPIDataMode( int spi_fd, int mode);
|
||||||
|
// Note : unsigned int spi_speed --> int spi_speed
|
||||||
|
native public int setSPIMaxSpeed(int spi_fd, int spi_speed);
|
||||||
|
native public int setSPIReadBitsPerWord( int spi_fd, int bits );
|
||||||
|
native public int setSPIWriteBitsPerWord( int spi_fd, int bits );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// OLED
|
||||||
|
native public int OLEDInit(int resetPin, int cmdDatPin);
|
||||||
|
native public int OLEDCleanScreen(int devFD);
|
||||||
|
// Note : char ch[] --> byte[] ch
|
||||||
|
native public int OLEDDisp8x16Str(int devFD, int x, int y, byte[] ch);
|
||||||
|
// Note : char ch --> byte ch
|
||||||
|
native public int OLEDDisp8x16Char(int devFD, int x, int y, byte ch);
|
||||||
|
native public void OLEDDeInit(int devFD);
|
||||||
|
|
||||||
|
// LCD1602
|
||||||
|
|
||||||
|
// LCD1602 Using PCF8574
|
||||||
|
native public int LCD1602Clear(int devFD);
|
||||||
|
native public void LCD1602DeInit(int devFD);
|
||||||
|
// Note : unsigned char x --> byte x, unsigned char y --> byte y, unsigned char data --> byte data
|
||||||
|
native public int LCD1602DispChar(int devFD, byte x, byte y, byte data);
|
||||||
|
// Note : char* line1, line2 --> String line1, line2
|
||||||
|
native public int LCD1602DispLines(int devFD, String line1, String line2);
|
||||||
|
// Note : unsigned char x, y --> byte x, y , char* str --> String str
|
||||||
|
native public int LCD1602DispStr(int devFD, byte x, byte y, String str);
|
||||||
|
native public int LCD1602Init(int i2cDev);
|
||||||
|
|
||||||
|
// LCD1602 using MCP23017
|
||||||
|
native public int LCD1602GetKey(int devFD);
|
||||||
|
native public int LCD1602KeyClear(int devFD);
|
||||||
|
native public void LCD1602KeyDeInit(int devFD);
|
||||||
|
// Note : unsigned char x, y, data --> byte x, y, data
|
||||||
|
native public int LCD1602KeyDispChar(int devFD, byte x, byte y, byte data);
|
||||||
|
// Note : char* line1, line2 --> String line1, line2
|
||||||
|
native public int LCD1602KeyDispLines(int devFD, String line1, String line2);
|
||||||
|
// Note : unsigned char x, y --> byte x, y. char *str --> String str
|
||||||
|
native public int LCD1602KeyDispStr(int devFD, byte x, byte y, String str);
|
||||||
|
native public int LCD1602KeyInit(int i2cDev);
|
||||||
|
|
||||||
|
// HCSR04
|
||||||
|
native public void Hcsr04DeInit();
|
||||||
|
native public int Hcsr04Init(int echoPin);
|
||||||
|
// Note int *data --> int[] data
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hcsr04Read
|
||||||
|
* @param data integer array with length = 1
|
||||||
|
* @return not checked yet
|
||||||
|
*/
|
||||||
|
native public int Hcsr04Read(int[] data);
|
||||||
|
|
||||||
|
// PWM
|
||||||
|
public static final int PWM0 = 96 + 1; // GPIO D1
|
||||||
|
public static final int PWM1 = 64+13; // GPIO C13
|
||||||
|
public static final int PWM2 = 64 + 14; // GPIO C14
|
||||||
|
native public int PWMPlay(int pin, int freq, int duty);
|
||||||
|
native public int PWMStop(int pin);
|
||||||
|
native public int initPwmGPIO(int board);
|
||||||
|
native public int pwmtoGPIO(int pwm);
|
||||||
|
|
||||||
|
//ADXL34X
|
||||||
|
// Note : char *position --> String position
|
||||||
|
native public int adxl34xRead(String position);
|
||||||
|
|
||||||
|
// BMP180
|
||||||
|
// NOte : int *data --> int[] data
|
||||||
|
/**
|
||||||
|
* BMP180 read
|
||||||
|
* @param type what to read
|
||||||
|
* @param data array of integer with length = 1
|
||||||
|
* @return not checked yet
|
||||||
|
*/
|
||||||
|
native public int bmp180Read(int type, int[] data);
|
||||||
|
|
||||||
|
// DHT11
|
||||||
|
public static final int DHT_TEMP = 1;
|
||||||
|
public static final int DHT_HUMIDITY = 2;
|
||||||
|
// Note : int *data --> int[] data
|
||||||
|
/**
|
||||||
|
* DHT read
|
||||||
|
* @param type what to read (DHT_TEMP or DHT_HUMIDITY)
|
||||||
|
* @param data array of integer with length = 1
|
||||||
|
* @return not checked yet
|
||||||
|
*/
|
||||||
|
native public int dht11Read(int type, int[] data);
|
||||||
|
|
||||||
|
// DS18B20
|
||||||
|
// Note : char * temperature --> byte[] temperature
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read from DS18B20
|
||||||
|
* @param temperature array of byte with length = 1
|
||||||
|
* @return not checked yet
|
||||||
|
*/
|
||||||
|
native public int ds18b20Read(byte[] temperature);
|
||||||
|
|
||||||
|
// HMC5883
|
||||||
|
native public void hmc5883DeInit(int devFD);
|
||||||
|
native public int hmc5883Init(int i2cDev);
|
||||||
|
native public double hmc5883Read(int devFD);
|
||||||
|
|
||||||
|
// MCP23017
|
||||||
|
native public void mcpDeInit(int devFD);
|
||||||
|
native public int mcpInit(int i2cDev);
|
||||||
|
// Note : unsigned char command --> byte command
|
||||||
|
native public int mcpWriteCmd4(int devFD, byte command);
|
||||||
|
native public int mcpWriteCmd8(int devFD, byte command);
|
||||||
|
// Note : unsigned char data --> byte data
|
||||||
|
native public int mcpWriteData4(int devFD, byte data);
|
||||||
|
native public int mcpWriteData8(int devFD, byte data);
|
||||||
|
|
||||||
|
// PCF8574
|
||||||
|
native public void pcf8574DeInit(int devFD);
|
||||||
|
native public int pcf8574Init(int i2cDev);
|
||||||
|
// Note : unsigned char command --> byte command
|
||||||
|
native public int pcf8574WriteCmd4(int devFD, byte command);
|
||||||
|
native public int pcf8574WriteCmd8(int devFD, byte command);
|
||||||
|
// Note : unsigned char data --> byte data
|
||||||
|
native public int pcf8574WriteData4(int devFD, byte data);
|
||||||
|
native public int pcf8574WriteData8(int devFD, byte data);
|
||||||
|
|
||||||
|
// PCF8591
|
||||||
|
// Note : int *value --> int[] value
|
||||||
|
/**
|
||||||
|
* Read from PCF8591
|
||||||
|
* @param channel channel number
|
||||||
|
* @param value array of integer with length = 1
|
||||||
|
* @return not checked yet
|
||||||
|
*/
|
||||||
|
native public int pcf8591Read(int channel, int[] value);
|
||||||
|
|
||||||
|
// Rotary Encoder
|
||||||
|
native public int rotaryEncoderDeInit();
|
||||||
|
native public int rotaryEncoderInit(int swPin, int siaPin, int sibPin);
|
||||||
|
// Note : int *data --> int[] data
|
||||||
|
/**
|
||||||
|
* Read from Rotary encodier
|
||||||
|
* @param type what to read
|
||||||
|
* @param data aray of integer with length = 1
|
||||||
|
* @return not checked yet
|
||||||
|
*/
|
||||||
|
native public int rotaryEncoderRead(int type, int[] data);
|
||||||
|
}
|
||||||
114
src/SBC/NanoPi/Nanopi_IR_Receiver.java
Normal file
114
src/SBC/NanoPi/Nanopi_IR_Receiver.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package SBC.NanoPi;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import com.sun.jna.Platform;
|
||||||
|
import com.sun.jna.platform.linux.Fcntl;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import jGPIO.input_event;
|
||||||
|
import jGPIO.mycodes;
|
||||||
|
|
||||||
|
@BA.ShortName("Nanopi_IR_Receiver")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"newvalue(tipe as int, code as int, value as int)"
|
||||||
|
})
|
||||||
|
public class Nanopi_IR_Receiver {
|
||||||
|
private BA ba;
|
||||||
|
private String event;
|
||||||
|
private Object Me;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_newvalue_event = false;
|
||||||
|
private int boardtype;
|
||||||
|
private LibFriendlyArmHardware wiringnp;
|
||||||
|
private static int irFD;
|
||||||
|
private final String driver_module = "matrix_ir_recv";
|
||||||
|
|
||||||
|
public void Initialize(BA bax, LibFriendlyArmHardware wiringNP, String eventname) {
|
||||||
|
this.ba = bax;
|
||||||
|
this.event = eventname;
|
||||||
|
this.wiringnp = wiringNP;
|
||||||
|
Me = this;
|
||||||
|
check_events();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean Open(String IR_Name, int pin) {
|
||||||
|
if (Platform.isLinux()) {
|
||||||
|
if (Platform.isARM()) {
|
||||||
|
if (!Platform.is64Bit()) {
|
||||||
|
if (wiringnp==null) wiringnp = new LibFriendlyArmHardware();
|
||||||
|
boardtype = wiringnp.boardInit();
|
||||||
|
if (boardtype>0) {
|
||||||
|
modprobe(driver_module, pin);
|
||||||
|
|
||||||
|
irFD = wiringnp.openHW(IR_Name, Fcntl.O_RDWR);
|
||||||
|
if (irFD>0) {
|
||||||
|
Thread tt = new Thread(()->{
|
||||||
|
int retsize = 0;
|
||||||
|
input_event event = new input_event();
|
||||||
|
while(true) {
|
||||||
|
if (wiringnp.selectHW(irFD, 0, 0)==1) {
|
||||||
|
retsize = wiringnp.readHW(irFD, event.getPointer(), event.size());
|
||||||
|
// convert dari signed short --> unsigned value
|
||||||
|
raise_newvalue(event.type & 0xFFFF, event.code & 0xFFFF, event.value);
|
||||||
|
raise_log(MessageFormat.format("readHW retsize={0}, type={1}, code={2}, value{3}", retsize, event.type, event.code, event.value));
|
||||||
|
} else break;
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
|
||||||
|
});
|
||||||
|
tt.start();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
raise_log("Nanopi_IR_Receiver Open failed, openHW failed");
|
||||||
|
rmmod(driver_module);
|
||||||
|
}
|
||||||
|
} else raise_log("Nanopi_IR_Receiver Open failed, boardInit failed");
|
||||||
|
} else raise_log("Nanopi_IR_Receiver Open failed, current driver works on 32bit model");
|
||||||
|
} else raise_log("Nanopi_IR_Receiver Open failed, must run on ARM Architecture");
|
||||||
|
} else raise_log("Nanopi_IR_Receiver Open failed, must run on Linux");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() {
|
||||||
|
if (irFD>0) {
|
||||||
|
wiringnp.closeHW(irFD);
|
||||||
|
irFD = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO belum tau caranya
|
||||||
|
private void modprobe(String drivermodule, int pin) {
|
||||||
|
//sprintf(modStr, "modprobe %s gpio=%d", DRIVER_MODULE, pintoGPIO(pin));
|
||||||
|
//system(modStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO belum tau caranya
|
||||||
|
private void rmmod(String drivermodule) {
|
||||||
|
//system("rmmod "DRIVER_MODULE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check_events() {
|
||||||
|
if (ba!=null) {
|
||||||
|
if (mycodes.ValidString(event)) {
|
||||||
|
need_log_event = ba.subExists(event+"_log");
|
||||||
|
need_newvalue_event = ba.subExists(event+"_newvalue");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
ba.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newvalue(int type, int code, int value) {
|
||||||
|
if (need_newvalue_event) {
|
||||||
|
ba.raiseEventFromDifferentThread(Me, null, 0, event+"_newvalue", false, new Object[] {type, code, value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/SBC/NanoPi/Neo1_Pin.java
Normal file
69
src/SBC/NanoPi/Neo1_Pin.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package SBC.NanoPi;
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Nanopi_Neo1_Pin")
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source : http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO#Hardware_Spec
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Neo1_Pin extends BasicSBCInfo {
|
||||||
|
|
||||||
|
public final LibFriendlyArmHardware WiringNP;
|
||||||
|
|
||||||
|
public Neo1_Pin() {
|
||||||
|
super();
|
||||||
|
WiringNP = new LibFriendlyArmHardware();
|
||||||
|
}
|
||||||
|
public final int pin07 = 203;
|
||||||
|
|
||||||
|
public final int pin11 = 0;
|
||||||
|
|
||||||
|
public final int pin13 = 2;
|
||||||
|
|
||||||
|
public final int pin15 = 3;
|
||||||
|
|
||||||
|
public final int pin19 = 64;
|
||||||
|
|
||||||
|
public final int pin21 = 65;
|
||||||
|
|
||||||
|
public final int pin23 = 66;
|
||||||
|
|
||||||
|
public final int pin08 = 198;
|
||||||
|
|
||||||
|
public final int pin10 = 199;
|
||||||
|
|
||||||
|
public final int pin12 = 6;
|
||||||
|
|
||||||
|
public final int pin16 = 200;
|
||||||
|
|
||||||
|
public final int pin18 = 201;
|
||||||
|
|
||||||
|
public final int pin22 = 1;
|
||||||
|
|
||||||
|
public final int pin24 = 67;
|
||||||
|
|
||||||
|
public final String i2c_0 = "/dev/i2c-0";
|
||||||
|
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Belum ketemu, selalu return 0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
// TODO belum ketemu caranya
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
58
src/SBC/NanoPi/Neo2_Pin.java
Normal file
58
src/SBC/NanoPi/Neo2_Pin.java
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
package SBC.NanoPi;
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Nanopi_Neo2_Pin")
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source : http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO2#Hardware_Spec
|
||||||
|
* @author rdkartono
|
||||||
|
*/
|
||||||
|
public class Neo2_Pin extends BasicSBCInfo {
|
||||||
|
public final LibFriendlyArmHardware WiringNP;
|
||||||
|
|
||||||
|
public Neo2_Pin() {
|
||||||
|
super();
|
||||||
|
WiringNP = new LibFriendlyArmHardware();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int pin03 = 12;
|
||||||
|
public final int pin05 = 11;
|
||||||
|
public final int pin07 = 203;
|
||||||
|
public final int pin11 = 0;
|
||||||
|
public final int pin13 = 2;
|
||||||
|
public final int pin15 = 3;
|
||||||
|
public final int pin19 = 64;
|
||||||
|
public final int pin21 = 65;
|
||||||
|
public final int pin23 = 66;
|
||||||
|
public final int pin08 = 198;
|
||||||
|
public final int pin10 = 199;
|
||||||
|
public final int pin12 = 6;
|
||||||
|
public final int pin16 = 200;
|
||||||
|
public final int pin18 = 201;
|
||||||
|
public final int pin22 = 1;
|
||||||
|
public final int pin24 = 67;
|
||||||
|
|
||||||
|
public final String i2c_0= "/dev/i2c-0";
|
||||||
|
|
||||||
|
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Belum ketemu
|
||||||
|
* selalu return 0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
// TODO belum ketemu caranya
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
309
src/SBC/NetworkMeterInfo.java
Normal file
309
src/SBC/NetworkMeterInfo.java
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
package SBC;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.DateTime;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
|
||||||
|
@BA.ShortName("NetworkMeterInfo")
|
||||||
|
public class NetworkMeterInfo {
|
||||||
|
public final String InterfaceName;
|
||||||
|
public final long ticktime;
|
||||||
|
public final long Total_RX_Bytes;
|
||||||
|
public final long Total_TX_Bytes;
|
||||||
|
public final long Total_RX_Packets;
|
||||||
|
public final long Total_TX_Packets;
|
||||||
|
private boolean isvalid = false;
|
||||||
|
|
||||||
|
private long rx_pps = 0;
|
||||||
|
private long tx_pps = 0;
|
||||||
|
private long rx_bps = 0;
|
||||||
|
private long tx_bps = 0;
|
||||||
|
public NetworkMeterInfo() {
|
||||||
|
InterfaceName="";
|
||||||
|
ticktime = DateTime.getNow();
|
||||||
|
Total_RX_Bytes = 0;
|
||||||
|
Total_TX_Bytes = 0;
|
||||||
|
Total_RX_Packets =0;
|
||||||
|
Total_TX_Packets = 0;
|
||||||
|
isvalid = false;
|
||||||
|
}
|
||||||
|
public NetworkMeterInfo(String ifname, long tick, long rx_bytes, long tx_bytes, long rx_packets, long tx_packets){
|
||||||
|
InterfaceName = ifname;
|
||||||
|
ticktime = tick;
|
||||||
|
Total_RX_Bytes = rx_bytes;
|
||||||
|
Total_TX_Bytes = tx_bytes;
|
||||||
|
Total_RX_Packets = rx_packets;
|
||||||
|
Total_TX_Packets = tx_packets;
|
||||||
|
|
||||||
|
if (!InterfaceName.isEmpty()) {
|
||||||
|
if (ticktime>0) {
|
||||||
|
if (Total_TX_Bytes>0) {
|
||||||
|
if (Total_RX_Bytes>0) {
|
||||||
|
if (Total_TX_Packets>0) {
|
||||||
|
if (Total_RX_Packets>0) {
|
||||||
|
isvalid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if contain valid value
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
|
public boolean IsValidValue() {
|
||||||
|
return isvalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RX Bytes per second
|
||||||
|
* @return value in long
|
||||||
|
*/
|
||||||
|
public long RX_BytesPerSecond() {
|
||||||
|
return rx_bps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RX Packets per second
|
||||||
|
* @return value in long
|
||||||
|
*/
|
||||||
|
public long RX_PacketsPerSecond() {
|
||||||
|
return rx_pps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TX Bytes per second
|
||||||
|
* @return value in long
|
||||||
|
*/
|
||||||
|
public long TX_BytesPerSecond() {
|
||||||
|
return tx_bps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TX Packets per second
|
||||||
|
* @return value in long
|
||||||
|
*/
|
||||||
|
public long TX_PacketsPerSecond() {
|
||||||
|
return tx_pps;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void calculate(NetworkMeterInfo prev) {
|
||||||
|
if (prev instanceof NetworkMeterInfo) {
|
||||||
|
if (prev.isvalid) {
|
||||||
|
rx_pps = Total_RX_Packets - prev.Total_RX_Packets;
|
||||||
|
tx_pps = Total_TX_Packets - prev.Total_TX_Packets;
|
||||||
|
rx_bps = Total_RX_Bytes - prev.Total_RX_Bytes;
|
||||||
|
tx_bps = Total_TX_Bytes - prev.Total_TX_Bytes;
|
||||||
|
|
||||||
|
if (rx_pps<1) rx_pps = 0; // tidak boleh negatif
|
||||||
|
if (tx_pps<1) tx_pps = 0;
|
||||||
|
if (rx_bps<1) rx_bps = 0;
|
||||||
|
if (tx_bps<1) tx_bps = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final long kp = 1000;
|
||||||
|
private final long mp = kp * 1000;
|
||||||
|
private final long gp = mp * 1000;
|
||||||
|
private final long tp = gp * 1000;
|
||||||
|
private final long kb = 1024;
|
||||||
|
private final long mb = kb * 1024;
|
||||||
|
private final long gb = mb * 1024;
|
||||||
|
private final long tb = gb * 1024;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current Total received packets, in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_RX_PacketTotal() {
|
||||||
|
if (this.Total_RX_Packets < kp) {
|
||||||
|
return String.valueOf(Total_RX_Packets);
|
||||||
|
} else if (Total_RX_Packets < mp) {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Packets, kp)+" K";
|
||||||
|
} else if (Total_RX_Packets<gp) {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Packets, mp)+" M";
|
||||||
|
} else if (Total_RX_Packets<tp) {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Packets, gp)+" G";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Packets, tp)+" T";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current Total transmitted packets, in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_TX_PacketTotal() {
|
||||||
|
if (this.Total_TX_Packets < kp) {
|
||||||
|
return String.valueOf(Total_TX_Packets);
|
||||||
|
} else if (Total_TX_Packets < mp) {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Packets, kp)+" K";
|
||||||
|
} else if (Total_TX_Packets<gp) {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Packets, mp)+" M";
|
||||||
|
} else if (Total_TX_Packets<tp) {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Packets, gp)+" G";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Packets, tp)+" T";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current Total received bytes, in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_RX_ByteTotal() {
|
||||||
|
if (this.Total_RX_Bytes < kb) {
|
||||||
|
return String.valueOf(Total_RX_Bytes);
|
||||||
|
} else if (Total_RX_Bytes < mb) {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Bytes, kb)+" K";
|
||||||
|
} else if (Total_RX_Bytes<gb) {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Bytes, mb)+" M";
|
||||||
|
} else if (Total_RX_Bytes<tb) {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Bytes, gb)+" G";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(Total_RX_Bytes, tb)+" T";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current Total transmitted bytes, in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_TX_ByteTotal() {
|
||||||
|
if (this.Total_TX_Bytes < kb) {
|
||||||
|
return String.valueOf(Total_TX_Bytes);
|
||||||
|
} else if (Total_TX_Bytes < mb) {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Bytes, kb)+" K";
|
||||||
|
} else if (Total_TX_Bytes<gb) {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Bytes, mb)+" M";
|
||||||
|
} else if (Total_TX_Bytes<tb) {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Bytes, gb)+" G";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(Total_TX_Bytes, tb)+" T";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final long kpps = 1000;
|
||||||
|
private final long mpps = kpps * 1000;
|
||||||
|
private final long gpps = mpps * 1000;
|
||||||
|
private final long kbps = 1024;
|
||||||
|
private final long mbps = kbps * 1024;
|
||||||
|
private final long gbps = mbps * 1024;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current RX Packet per second in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_RX_PacketPerSecond() {
|
||||||
|
if (rx_pps<kpps) {
|
||||||
|
return String.valueOf(rx_pps);
|
||||||
|
} else if (rx_pps < mpps) {
|
||||||
|
return pembulatan_1_desimal(rx_pps, kpps)+" K";
|
||||||
|
} else if (rx_pps < gpps) {
|
||||||
|
return pembulatan_1_desimal(rx_pps, mpps)+" M";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(rx_pps, gpps)+" G";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current TX Packet per second in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_TX_PacketPerSecond() {
|
||||||
|
if (tx_pps<kpps) {
|
||||||
|
return String.valueOf(tx_pps);
|
||||||
|
} else if (tx_pps < mpps) {
|
||||||
|
return pembulatan_1_desimal(tx_pps, kpps)+" K";
|
||||||
|
} else if (tx_pps < gpps) {
|
||||||
|
return pembulatan_1_desimal(tx_pps, mpps)+" M";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(tx_pps, gpps)+" G";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current RX Bytes per second in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_RX_BytePerSecond() {
|
||||||
|
if (rx_bps < kbps) {
|
||||||
|
return String.valueOf(rx_bps);
|
||||||
|
} else if (rx_bps < mbps) {
|
||||||
|
return pembulatan_1_desimal(rx_bps, kbps)+" K";
|
||||||
|
} else if (rx_bps < gbps) {
|
||||||
|
return pembulatan_1_desimal(rx_bps, mbps)+" M";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(rx_bps, gbps)+" G";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current TX Bytes per second in readable string
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Current_TX_BytePerSecond() {
|
||||||
|
if (tx_bps < kbps) {
|
||||||
|
return String.valueOf(tx_bps);
|
||||||
|
} else if (tx_bps < mbps) {
|
||||||
|
return pembulatan_1_desimal(tx_bps, kbps)+" K";
|
||||||
|
} else if (tx_bps < gbps) {
|
||||||
|
return pembulatan_1_desimal(tx_bps, mbps)+" M";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1_desimal(tx_bps, gbps)+" G";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double pembulatan_1_desimal(long val, long divisor) {
|
||||||
|
double vv = (double)val / divisor;
|
||||||
|
long ww = (long)(vv * 10);
|
||||||
|
return (double)(ww / 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complete Summary of this value
|
||||||
|
* @return value in string
|
||||||
|
*/
|
||||||
|
public String Summary() {
|
||||||
|
if (isvalid) {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
str.append("Interface=").append(InterfaceName).append(" ");
|
||||||
|
str.append("Date=").append(DateTime.Date(ticktime)).append(" ").append(DateTime.Time(ticktime)).append(" ");
|
||||||
|
str.append("RX pps=").append(Current_RX_PacketPerSecond()).append(" bps=").append(Current_RX_BytePerSecond()).append(" ");
|
||||||
|
str.append("TX pps=").append(Current_TX_PacketPerSecond()).append(" bps=").append(Current_TX_BytePerSecond());
|
||||||
|
return str.toString();
|
||||||
|
} else return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create values in JSON Map
|
||||||
|
* @return Map value
|
||||||
|
*/
|
||||||
|
public Map MakeJsonMap() {
|
||||||
|
Map result = new Map();
|
||||||
|
result.Initialize();
|
||||||
|
result.Put("interface", InterfaceName);
|
||||||
|
result.Put("datetimetick", ticktime);
|
||||||
|
result.Put("rxbps", rx_bps);
|
||||||
|
result.Put("rxpps", rx_pps);
|
||||||
|
result.Put("txbps", tx_bps);
|
||||||
|
result.Put("txpps", tx_pps);
|
||||||
|
result.Put("rxbtotal", this.Total_RX_Bytes);
|
||||||
|
result.Put("txbtotal", this.Total_TX_Bytes);
|
||||||
|
result.Put("rxptotal", this.Total_RX_Packets);
|
||||||
|
result.Put("txptotal", this.Total_TX_Packets);
|
||||||
|
result.Put("Crxbps", Current_RX_BytePerSecond());
|
||||||
|
result.Put("Crxpps", Current_RX_PacketPerSecond());
|
||||||
|
result.Put("Ctxbps", Current_TX_BytePerSecond());
|
||||||
|
result.Put("Ctxpps", Current_TX_PacketPerSecond());
|
||||||
|
result.Put("Crxpt", Current_RX_PacketTotal());
|
||||||
|
result.Put("Ctxpt", Current_TX_PacketTotal());
|
||||||
|
result.Put("Crxbt", Current_RX_ByteTotal());
|
||||||
|
result.Put("Ctxbt", Current_TX_ByteTotal());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/SBC/Odroid/H2_Pin.java
Normal file
88
src/SBC/Odroid/H2_Pin.java
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
package SBC.Odroid;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Odroid_H2_Pin")
|
||||||
|
|
||||||
|
public class H2_Pin extends BasicSBCInfo {
|
||||||
|
|
||||||
|
|
||||||
|
public H2_Pin() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String eth1_name = "enp3s0";
|
||||||
|
public final String eth0_name = "enp2s0";
|
||||||
|
|
||||||
|
//https://wiki.odroid.com/odroid-h2/application_note/16port_i2c_gpio#tab__old_kernel_version
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No info on pin, internal bus for internal sensors
|
||||||
|
*/
|
||||||
|
public final String i2c_0 = "/dev/i2c-0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No info on pin, internal bus for internal sensors
|
||||||
|
*/
|
||||||
|
public final String i2c_1 = "/dev/i2c-1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New Kernel (4.18 up), Pin #18(SCL) and #20(SDA)
|
||||||
|
*/
|
||||||
|
public final String i2c_2 = "/dev/i2c-2";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New Kernel (4.18 up), Pin #13(SCL) and #15(SDA).
|
||||||
|
*/
|
||||||
|
public final String i2c_3 = "/dev/i2c-3";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No info on pin, internal bus for internal sensors
|
||||||
|
*/
|
||||||
|
public final String i2c_4 = "/dev/i2c-4";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old Kernel, Pin #18(SCL) and #20(SDA).
|
||||||
|
*/
|
||||||
|
public final String i2c_5 = "/dev/i2c-5";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old Kernel, Pin #13(SCL) and #15(SDA)
|
||||||
|
*/
|
||||||
|
public final String i2c_6 = "/dev/i2c-6";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No info on pin, internal bus for internal sensors
|
||||||
|
*/
|
||||||
|
public final String i2c_7 = "/dev/i2c-7";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No info on pin, internal bus for internal sensors
|
||||||
|
*/
|
||||||
|
public final String i2c_8 = "/dev/i2c-8";
|
||||||
|
|
||||||
|
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* Belum tau caranya, selalu return 0
|
||||||
|
*/
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
// TODO belum ketemu caranya
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
89
src/SBC/Odroid/N2_Pin.java
Normal file
89
src/SBC/Odroid/N2_Pin.java
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
package SBC.Odroid;
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
|
||||||
|
@BA.ShortName("Odroid_N2_Pin")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source : https://wiki.odroid.com/odroid-n2/hardware/expansion_connectors
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class N2_Pin extends BasicSBCInfo{
|
||||||
|
|
||||||
|
public N2_Pin() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int pin03 = 493;
|
||||||
|
public final int pin05 = 494;
|
||||||
|
public final int pin07 = 473;
|
||||||
|
public final int pin11 = 479;
|
||||||
|
public final int pin13 = 480;
|
||||||
|
public final int pin15 = 483;
|
||||||
|
public final int pin19 = 484;
|
||||||
|
public final int pin21 = 485;
|
||||||
|
public final int pin23 = 487;
|
||||||
|
public final int pin27 = 474;
|
||||||
|
public final int pin29 = 490;
|
||||||
|
public final int pin31 = 491;
|
||||||
|
public final int pin33 = 481;
|
||||||
|
public final int pin35 = 482;
|
||||||
|
public final int pin08 = 488;
|
||||||
|
public final int pin10 = 489;
|
||||||
|
public final int pin12 = 492;
|
||||||
|
public final int pin16 = 476;
|
||||||
|
public final int pin18 = 477;
|
||||||
|
public final int pin22 = 478;
|
||||||
|
public final int pin24 = 486;
|
||||||
|
public final int pin26 = 464;
|
||||||
|
public final int pin28 = 475;
|
||||||
|
public final int pin32 = 472;
|
||||||
|
public final int pin36 = 495;
|
||||||
|
|
||||||
|
// Source : https://wiki.odroid.com/odroid-n2/software/gpio_register_map
|
||||||
|
// for use in "/dev/gpiomem"
|
||||||
|
// Example : https://wiki.odroid.com/odroid-n2/application_note/gpio/memory_mapped_gpio
|
||||||
|
public final long GPIO_BASE_ADDRESS = 0xFF634400;
|
||||||
|
// GPIO_X is 20 pin , numbered 0 to 19
|
||||||
|
public final long GPIO_X_SET_DIRECTION_REGISTER = GPIO_BASE_ADDRESS + (0x16 * 4); // [19 : 0] , '0' = Output, '1' = Input
|
||||||
|
public final long GPIO_X_WRITE_REGISTER = GPIO_BASE_ADDRESS + (0x17 * 4); // [19 : 0] , '0' = Low, '1' = High
|
||||||
|
public final long GPIO_X_READ_REGISTER = GPIO_BASE_ADDRESS + (0x18 * 4); // [19 : 0] ,
|
||||||
|
public final long GPIO_X_ENABLE_PULL_REGISTER = GPIO_BASE_ADDRESS + (0x4A * 4); // [19 : 0] , '0' = Disable Pull-Mode, '1' = Enable Pull-Mode
|
||||||
|
public final long GPIO_X_MODE_PULL_REGISTER = GPIO_BASE_ADDRESS + (0x3C * 4); // [19 : 0] , '0' = Pull-Down , '1' = Pull-Up
|
||||||
|
|
||||||
|
// GPIO_A is 11 pin, numbered 0 to 5, and 11 to 15
|
||||||
|
public final long GPIO_A_SET_DIRECTION_REGISTER = GPIO_BASE_ADDRESS + (0x20 * 4); // [15 : 0] , '0' = Output, '1' = Input
|
||||||
|
public final long GPIO_A_WRITE_REGISTER = GPIO_BASE_ADDRESS + (0x21 * 4); // [15 : 0] , '0' = Low, '1' = High
|
||||||
|
public final long GPIO_A_READ_REGISTER = GPIO_BASE_ADDRESS + (0x22 * 4); // [19 : 0] ,
|
||||||
|
public final long GPIO_A_ENABLE_PULL_REGISTER = GPIO_BASE_ADDRESS + (0x4D * 4); // [19 : 0] , '0' = Disable Pull-Mode, '1' = Enable Pull-Mode
|
||||||
|
public final long GPIO_A_MODE_PULL_REGISTER = GPIO_BASE_ADDRESS + (0x3F * 4); // [19 : 0] , '0' = Pull-Down , '1' = Pull-Up
|
||||||
|
|
||||||
|
|
||||||
|
// I2C
|
||||||
|
// Source : https://wiki.odroid.com/odroid-n2/application_note/gpio/i2c
|
||||||
|
// Net Name I2C Register PCB Location SDA(#GPIO) SCL(#GPIO) Default Speed Device Node
|
||||||
|
// I2C-2 0xFFD1D000 J2 (2×20 pins) GPIOX.17(#493) GPIOX.18(#494) 400 KHz /dev/i2c-2
|
||||||
|
// I2C-3 0xFFD1C000 J2 (2×20 pins) GPIOA.14(#474) GPIOA.15(#475) 100 KHz /dev/i2c-3
|
||||||
|
public final String i2c_2 = "/dev/i2c-2";
|
||||||
|
public final String i2c_3 = "/dev/i2c-3";
|
||||||
|
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Belum tau caranya
|
||||||
|
* selalu return 0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
// TODO belum tau caranya
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
125
src/SBC/Odroid/XU4_Pin.java
Normal file
125
src/SBC/Odroid/XU4_Pin.java
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
package SBC.Odroid;
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Odroid_XU4_Pin")
|
||||||
|
public class XU4_Pin extends BasicSBCInfo {
|
||||||
|
|
||||||
|
public final String eth_name = "eth0";
|
||||||
|
|
||||||
|
public XU4_Pin(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Belum tau caranya, selalu return 0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
// TODO belum tau caranya
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source : https://wiki.odroid.com/odroid-xu4/hardware/expansion_connectors#con_10_-_2x15_pins
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static class XU4_CON11 {
|
||||||
|
public final int pin05 = 34;
|
||||||
|
public final int pin07 = 225;
|
||||||
|
public final int pin09 = 226;
|
||||||
|
public final int pin11 = 227;
|
||||||
|
public final int pin04 = 187;
|
||||||
|
public final int pin06 = 188;
|
||||||
|
public final int pin10 = 229;
|
||||||
|
public final int pin12 = 228;
|
||||||
|
|
||||||
|
// Register Map
|
||||||
|
// Source : https://wiki.odroid.com/odroid-xu4/software/gpio_register_map
|
||||||
|
|
||||||
|
// I2C
|
||||||
|
// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/i2c_speed
|
||||||
|
// At ubuntu-16.04-mate-odroid-xu3-20170731.img (Kernel Version 3.10.105-141)
|
||||||
|
// Net Name I2C Register PCB Location SDA(#GPIO) SCL(#GPIO) Default Speed Device Node
|
||||||
|
/// I2C_1 0x12C70000 CON10 GPB3.2(#209) GPB3.3(#210) 400Khz /dev/i2c-4
|
||||||
|
// I2C_5 0x12CB0000 CON11 GPA2.2(#187) GPA2.3(#188) 400Khz /dev/i2c-1
|
||||||
|
//
|
||||||
|
// At ubuntu-18.04-4.14-mate-odroid-xu4-20180501.img (Kernel Version 4.14.37-135)
|
||||||
|
// Net Name I2C Register PCB Location SDA(#GPIO) SCL(#GPIO) Default Speed Device Node
|
||||||
|
// I2C_1 0x12C70000 CON10 GPB3.2(#209) GPB3.3(#210) 400Khz /dev/i2c-1
|
||||||
|
// I2C_5 0x12CB0000 CON11 GPA2.2(#187) GPA2.3(#188) 400Khz /dev/i2c-5
|
||||||
|
public final String i2c_5 = "/dev/i2c-5";
|
||||||
|
|
||||||
|
// UART
|
||||||
|
// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/uart
|
||||||
|
// Port Name : /dev/ttySAC0
|
||||||
|
// Pin 6 UART_0.RXD GPA0.0 (#171) I(PUDN)
|
||||||
|
// Pin 8 UART_0.TXD GPA0.1 (#172) I(PUDN)
|
||||||
|
// I/O voltage range is 0~1.8Volt. Otherwise your ODROID will be damaged permanently.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source : https://wiki.odroid.com/odroid-xu4/hardware/expansion_connectors#con_10_-_2x15_pins
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static class XU4_CON10{
|
||||||
|
public final int pin05 = 174;
|
||||||
|
public final int pin07 = 192;
|
||||||
|
public final int pin09 = 191;
|
||||||
|
public final int pin11 = 190;
|
||||||
|
public final int pin13 = 21;
|
||||||
|
public final int pin15 = 18;
|
||||||
|
public final int pin17 = 22;
|
||||||
|
public final int pin19 = 30;
|
||||||
|
public final int pin21 = 29;
|
||||||
|
public final int pin25 = 23;
|
||||||
|
public final int pin27 = 33;
|
||||||
|
public final int pin04 = 173;
|
||||||
|
public final int pin06 = 171;
|
||||||
|
public final int pin08 = 172;
|
||||||
|
public final int pin10 = 189;
|
||||||
|
public final int pin14 = 210;
|
||||||
|
public final int pin16 = 209;
|
||||||
|
public final int pin18 = 19;
|
||||||
|
public final int pin20 = 28;
|
||||||
|
public final int pin22 = 31;
|
||||||
|
public final int pin24 = 25;
|
||||||
|
public final int pin26 = 24;
|
||||||
|
|
||||||
|
|
||||||
|
// Register Map
|
||||||
|
// Source : https://wiki.odroid.com/odroid-xu4/software/gpio_register_map
|
||||||
|
|
||||||
|
// I2C
|
||||||
|
// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/i2c_speed
|
||||||
|
// At ubuntu-16.04-mate-odroid-xu3-20170731.img (Kernel Version 3.10.105-141)
|
||||||
|
// Net Name I2C Register PCB Location SDA(#GPIO) SCL(#GPIO) Default Speed Device Node
|
||||||
|
/// I2C_1 0x12C70000 CON10 GPB3.2(#209) GPB3.3(#210) 400Khz /dev/i2c-4
|
||||||
|
// I2C_5 0x12CB0000 CON11 GPA2.2(#187) GPA2.3(#188) 400Khz /dev/i2c-1
|
||||||
|
//
|
||||||
|
// At ubuntu-18.04-4.14-mate-odroid-xu4-20180501.img (Kernel Version 4.14.37-135)
|
||||||
|
// Net Name I2C Register PCB Location SDA(#GPIO) SCL(#GPIO) Default Speed Device Node
|
||||||
|
// I2C_1 0x12C70000 CON10 GPB3.2(#209) GPB3.3(#210) 400Khz /dev/i2c-1
|
||||||
|
// I2C_5 0x12CB0000 CON11 GPA2.2(#187) GPA2.3(#188) 400Khz /dev/i2c-5
|
||||||
|
public final String i2c_1 = "/dev/i2c-1";
|
||||||
|
|
||||||
|
// UART
|
||||||
|
// Source : https://wiki.odroid.com/odroid-xu4/application_note/gpio/uart
|
||||||
|
// Port Name : /dev/ttySAC0
|
||||||
|
// Pin 6 UART_0.RXD GPA0.0 (#171) I(PUDN)
|
||||||
|
// Pin 8 UART_0.TXD GPA0.1 (#172) I(PUDN)
|
||||||
|
// I/O voltage range is 0~1.8Volt. Otherwise your ODROID will be damaged permanently.
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
50
src/SBC/OrangePi/ZeroLTS.java
Normal file
50
src/SBC/OrangePi/ZeroLTS.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package SBC.OrangePi;
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("OrangePi_ZeroLTS_Pin")
|
||||||
|
public class ZeroLTS extends BasicSBCInfo {
|
||||||
|
public final int pin03 = 12;
|
||||||
|
public final int pin05 = 11;
|
||||||
|
public final int pin07 = 6;
|
||||||
|
public final int pin11 = 1;
|
||||||
|
public final int pin13 = 0;
|
||||||
|
public final int pin15 = 3;
|
||||||
|
public final int pin19 = 15;
|
||||||
|
public final int pin21 = 16;
|
||||||
|
public final int pin23 = 14;
|
||||||
|
public final int pin08 = 198;
|
||||||
|
public final int pin10 = 199;
|
||||||
|
public final int pin12 = 7;
|
||||||
|
public final int pin16 = 19;
|
||||||
|
public final int pin18 = 18;
|
||||||
|
public final int pin22 = 2;
|
||||||
|
public final int pin24 = 13;
|
||||||
|
public final int pin26 = 10;
|
||||||
|
|
||||||
|
public final String i2c_0= "/dev/i2c-0";
|
||||||
|
public final String i2c_1= "/dev/i2c-1";
|
||||||
|
public final String i2c_2= "/dev/i2c-2";
|
||||||
|
|
||||||
|
public ZeroLTS() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Belum ketemu
|
||||||
|
* selalu return 0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
// TODO belum ketemu caranya
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
90
src/SBC/RAM_Info.java
Normal file
90
src/SBC/RAM_Info.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package SBC;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
|
||||||
|
@BA.ShortName("RAM_Info")
|
||||||
|
public class RAM_Info {
|
||||||
|
|
||||||
|
public final double JVMTotalMemory_KB;
|
||||||
|
public final double JVMFreeMemory_KB;
|
||||||
|
public final double JVMMaxMemory_KB;
|
||||||
|
public final double JVMFreePercentage;
|
||||||
|
public final double MemTotal_KB;
|
||||||
|
public final double MemFree_KB;
|
||||||
|
public final double MemAvailable_KB;
|
||||||
|
public final double MemFreePercentage;
|
||||||
|
public final double SwapTotal_KB;
|
||||||
|
public final double SwapFree_KB;
|
||||||
|
public final double SwapFreePercentage; // tambahan
|
||||||
|
public RAM_Info() {
|
||||||
|
JVMTotalMemory_KB = 0;
|
||||||
|
JVMFreeMemory_KB = 0;
|
||||||
|
JVMMaxMemory_KB = 0;
|
||||||
|
JVMFreePercentage = 0;
|
||||||
|
MemTotal_KB = 0;
|
||||||
|
MemFree_KB = 0;
|
||||||
|
MemFreePercentage = 0;
|
||||||
|
MemAvailable_KB = 0;
|
||||||
|
SwapTotal_KB = 0;
|
||||||
|
SwapFree_KB = 0;
|
||||||
|
SwapFreePercentage = 0;
|
||||||
|
}
|
||||||
|
public RAM_Info(Map value) {
|
||||||
|
JVMTotalMemory_KB = (double) value.GetDefault("JVMTotalMemory", 0);
|
||||||
|
JVMFreeMemory_KB = (double) value.GetDefault("JVMFreeMemory", 0);
|
||||||
|
JVMMaxMemory_KB = (double) value.GetDefault("JVMMaxMemory", 0);
|
||||||
|
JVMFreePercentage = (double) value.GetDefault("JVMFreePercentage", 0); // sudah pembulatan
|
||||||
|
MemTotal_KB = (double) value.GetDefault("MemTotal", 0);
|
||||||
|
MemFree_KB = (double) value.GetDefault("MemFree", 0);
|
||||||
|
MemFreePercentage = (double) value.GetDefault("MemFreePercentage", 0); // sudah pembulatan
|
||||||
|
MemAvailable_KB = (double) value.GetDefault("MemAvailable", 0);
|
||||||
|
SwapTotal_KB = (double) value.GetDefault("SwapTotal", 0);
|
||||||
|
SwapFree_KB = (double) value.GetDefault("SwapFree", 0);
|
||||||
|
SwapFreePercentage = pembulatan_1desimal((SwapFree_KB * 100.0) / SwapTotal_KB );
|
||||||
|
}
|
||||||
|
|
||||||
|
private double pembulatan_1desimal(double value) {
|
||||||
|
int temp = (int)(value * 10);
|
||||||
|
return (temp / 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final double memory_MB = 1024;
|
||||||
|
private final double memory_GB = memory_MB * 1024;
|
||||||
|
private final double memory_TB = memory_GB * 1024;
|
||||||
|
/**
|
||||||
|
* Return an easy to read from values inside this class
|
||||||
|
* @param value : Member of this class, example MemTotal_KB, or MemAvailable_KB
|
||||||
|
* @return String value
|
||||||
|
*/
|
||||||
|
public String EasyRead_Value(double value) {
|
||||||
|
if (value < memory_MB) {
|
||||||
|
return pembulatan_1desimal(value)+ " KB";
|
||||||
|
} else if (value < memory_GB) {
|
||||||
|
return pembulatan_1desimal(value / memory_MB)+" MB";
|
||||||
|
} else if (value < memory_TB) {
|
||||||
|
return pembulatan_1desimal(value / memory_GB)+" GB";
|
||||||
|
} else return pembulatan_1desimal(value / memory_TB)+" TB";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create values in JSON Map
|
||||||
|
* @return Map value
|
||||||
|
*/
|
||||||
|
public Map MakeJSONMap() {
|
||||||
|
Map result = new Map();
|
||||||
|
result.Initialize();
|
||||||
|
result.Put("JVMTotalMemory", EasyRead_Value(this.JVMTotalMemory_KB));
|
||||||
|
result.Put("JVMFreeMemory", EasyRead_Value(this.JVMFreeMemory_KB));
|
||||||
|
result.Put("JVMMaxMemory", EasyRead_Value(this.JVMMaxMemory_KB));
|
||||||
|
result.Put("JVMFreePercentage", this.JVMFreePercentage);
|
||||||
|
result.Put("MemTotal", EasyRead_Value(this.MemTotal_KB));
|
||||||
|
result.Put("MemFree", EasyRead_Value(this.MemFree_KB));
|
||||||
|
result.Put("MemFreePercentage", this.MemFreePercentage);
|
||||||
|
result.Put("MemAvailable", EasyRead_Value(this.MemAvailable_KB));
|
||||||
|
result.Put("SwapTotal", EasyRead_Value(this.SwapTotal_KB));
|
||||||
|
result.Put("SwapFree", EasyRead_Value(this.SwapFree_KB));
|
||||||
|
result.Put("SwapFreePercentage", this.SwapFreePercentage);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
263
src/SBC/RaspberryPi/Pi3_Pin.java
Normal file
263
src/SBC/RaspberryPi/Pi3_Pin.java
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
package SBC.RaspberryPi;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import SBC.BasicSBCInfo;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Raspberry_Pi3_Pin")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source :
|
||||||
|
* https://docs.particle.io/datasheets/discontinued/raspberrypi-datasheet/
|
||||||
|
* Source : https://www.raspberrypi.org/documentation/usage/gpio/
|
||||||
|
*
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
* GPIO14 TX UART hardware serial transmit GPIO15 RX UART hardware
|
||||||
|
* serial receive Disabled by default on the Raspberry Pi 3. Must be
|
||||||
|
* enabled by adding enable_uart=1 to /boot/config.txt
|
||||||
|
*
|
||||||
|
* GPIO2 SDA I2C data line GPIO3 SCL I2C clock line Disabled by default
|
||||||
|
* on the Raspberry Pi 3. Must be enabled by adding dtparam=i2c_arm=on
|
||||||
|
* to /boot/config.txt
|
||||||
|
*
|
||||||
|
* GPIO9 MISO SPI master-in slave-out GPIO10 MOSI SPI master-out
|
||||||
|
* slave-in Disabled by default on the Raspberry Pi 3. Must be enabled
|
||||||
|
* by adding dtparam=spi=on to /boot/config.txt
|
||||||
|
*
|
||||||
|
* Compatible with Pi-Zero, Pi-Zero-W,
|
||||||
|
*/
|
||||||
|
public class Pi3_Pin extends BasicSBCInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 8
|
||||||
|
*/
|
||||||
|
public final int pin03 = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 9
|
||||||
|
*/
|
||||||
|
public final int pin05 = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 7
|
||||||
|
*/
|
||||||
|
public final int pin07 = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 0
|
||||||
|
*/
|
||||||
|
public final int pin11 = 17;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 2
|
||||||
|
*/
|
||||||
|
public final int pin13 = 27;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 3
|
||||||
|
*/
|
||||||
|
public final int pin15 = 22;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 12
|
||||||
|
*/
|
||||||
|
public final int pin19 = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 13
|
||||||
|
*/
|
||||||
|
public final int pin21 = 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 14
|
||||||
|
*/
|
||||||
|
public final int pin23 = 11;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 30
|
||||||
|
*/
|
||||||
|
public final int pin27 = 0;
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 21
|
||||||
|
*/
|
||||||
|
public final int pin29 = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 22
|
||||||
|
*/
|
||||||
|
public final int pin31 = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 23
|
||||||
|
*/
|
||||||
|
public final int pin33 = 13;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 24
|
||||||
|
*/
|
||||||
|
public final int pin35 = 19;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 25
|
||||||
|
*/
|
||||||
|
public final int pin37 = 26;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 15
|
||||||
|
*/
|
||||||
|
public final int pin08 = 14;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 16
|
||||||
|
*/
|
||||||
|
public final int pin10 = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 1
|
||||||
|
*/
|
||||||
|
public final int pin12 = 18;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 4
|
||||||
|
*/
|
||||||
|
public final int pin16 = 23;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 5
|
||||||
|
*/
|
||||||
|
public final int pin18 = 24;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 6
|
||||||
|
*/
|
||||||
|
public final int pin22 = 25;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 10
|
||||||
|
*/
|
||||||
|
public final int pin24 = 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 11
|
||||||
|
*/
|
||||||
|
public final int pin26 = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 26
|
||||||
|
*/
|
||||||
|
public final int pin32 = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 27
|
||||||
|
*/
|
||||||
|
public final int pin36 = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 28
|
||||||
|
*/
|
||||||
|
public final int pin38 = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equal Pi4J GPIO 29
|
||||||
|
*/
|
||||||
|
public final int pin40 = 21;
|
||||||
|
|
||||||
|
public final String wlan_name = "wlan0";
|
||||||
|
public final String eth_name = "eth0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Raspbian Serial Name untuk port 0.
|
||||||
|
* akan symbolic-link ke /dev/ttyAMA0 --> hardware based UART
|
||||||
|
* RXD = pin 10, TXD = pin 8
|
||||||
|
*
|
||||||
|
* Di Pi3 standard, ttyAMA0 handle bluetooth. Kalau mau dijadikan hardware UART biasa
|
||||||
|
* mesti setting dtoverlay=pi3-disable-bt di /boot/config.txt
|
||||||
|
*/
|
||||||
|
public final String serial0_name = "/dev/serial0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Raspbian Serial name untuk port 1
|
||||||
|
* akan symbolic-link ke /dev/ttyS0 --> software based UART
|
||||||
|
*
|
||||||
|
* di Pi3 standard ttyS0 handle serial, tapi akurasi kurang pas.
|
||||||
|
* kalau mau swap ttyS0 handle bluetooth, mesti setting dtoverlay=pi3-miniuart-bt
|
||||||
|
* di /boot/config.txt
|
||||||
|
*/
|
||||||
|
public final String serial1_name = "/dev/serial1";
|
||||||
|
|
||||||
|
|
||||||
|
public Pi3_Pin() {
|
||||||
|
|
||||||
|
super();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I2C SDA : pin 3 SCL : pin 5
|
||||||
|
*/
|
||||||
|
public final String i2c_1 = "/dev/i2c-1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SPI Dev 0.0 MOSI : pin 19 MISO : pin 21 SCLOCK : pin 23 CE : pin 24
|
||||||
|
*/
|
||||||
|
public final String spi0 = "/dev/spidev0.0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SPI Dev 0.1 MOSI : pin 38 MISO : pin 35 SCLOCK : pin 40 CE : pin 26
|
||||||
|
*/
|
||||||
|
public final String spi1 = "/dev/spidev0.1";
|
||||||
|
|
||||||
|
|
||||||
|
public void Initialize(BA bax, Object callerobject, String event) {
|
||||||
|
setup_events(bax, callerobject, event, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get RPi Core Temperature
|
||||||
|
*
|
||||||
|
* @return value in xx.y value
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double Get_CPU_CoreVolt() {
|
||||||
|
try {
|
||||||
|
Process process = Runtime.getRuntime().exec("vcgencmd measure_volts core");
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
String result = reader.readLine();
|
||||||
|
if (result!=null) {
|
||||||
|
result = result.trim();
|
||||||
|
if (result.startsWith("volt=")) {
|
||||||
|
int startindex = result.indexOf(61); // tanda =
|
||||||
|
if (startindex < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int stopindex = result.indexOf(86); // tanda V
|
||||||
|
if (stopindex < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
double value = Double.parseDouble(result.substring(startindex + 1, stopindex));
|
||||||
|
int exitvalue = process.waitFor();
|
||||||
|
if (exitvalue == 0)
|
||||||
|
return Math.round(value * 10.0) / 10.0; // pembulatan 1 desimal
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
} else
|
||||||
|
return -1;
|
||||||
|
} else return -1;
|
||||||
|
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
BA.Log("Get_RPI_Temp Exception, Msg : " + e.getMessage() + ", Caused: " + e.getCause());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
128
src/SBC/RockPi/RockPi4B.java
Normal file
128
src/SBC/RockPi/RockPi4B.java
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
80
src/SBC/Storage_Info.java
Normal file
80
src/SBC/Storage_Info.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package SBC;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
|
||||||
|
@BA.ShortName("Storage_Info")
|
||||||
|
public class Storage_Info {
|
||||||
|
public final String Path;
|
||||||
|
public final double Total;
|
||||||
|
public final double Free;
|
||||||
|
public final double FreePercentage;
|
||||||
|
public final boolean isvalid;
|
||||||
|
|
||||||
|
public Storage_Info() {
|
||||||
|
Path="";
|
||||||
|
Total=0;
|
||||||
|
Free=0;
|
||||||
|
FreePercentage=0;
|
||||||
|
isvalid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Storage_Info(Map value) {
|
||||||
|
Path = (String) value.GetDefault("Path", "");
|
||||||
|
Total = (double) value.GetDefault("Total", 0);
|
||||||
|
Free = (double) value.GetDefault("Free", 0);
|
||||||
|
FreePercentage = (double) value.GetDefault("FreePercentage", 0); // sudah pembulatan 1 desimal
|
||||||
|
if (!Path.isEmpty()) {
|
||||||
|
if (Total>0) {
|
||||||
|
isvalid = true;
|
||||||
|
} else isvalid = false;
|
||||||
|
} else isvalid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final double file_KB = 1024;
|
||||||
|
private final double file_MB = file_KB * 1024;
|
||||||
|
private final double file_GB = file_MB * 1024;
|
||||||
|
private final double file_TB = file_GB * 1024;
|
||||||
|
|
||||||
|
private double pembulatan_1desimal(double value) {
|
||||||
|
int temp = (int)(value * 10);
|
||||||
|
return (temp / 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an easy to read from values inside this class
|
||||||
|
* @param value : Member of this class, either Total or Free
|
||||||
|
* @return String value
|
||||||
|
*/
|
||||||
|
public String EasyRead_Value(double value) {
|
||||||
|
if (value < file_KB) {
|
||||||
|
return pembulatan_1desimal(value)+ " B";
|
||||||
|
} else if (value < file_MB) {
|
||||||
|
return pembulatan_1desimal(value / file_KB)+" KB";
|
||||||
|
} else if (value < file_GB) {
|
||||||
|
return pembulatan_1desimal(value / file_MB)+" MB";
|
||||||
|
} else if (value < file_TB) {
|
||||||
|
return pembulatan_1desimal(value / file_GB)+" GB";
|
||||||
|
} else {
|
||||||
|
return pembulatan_1desimal(value / file_TB)+" TB";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create values in JSON Map
|
||||||
|
* @return Map value
|
||||||
|
*/
|
||||||
|
public Map MakeJSONMap() {
|
||||||
|
Map result = new Map();
|
||||||
|
result.Initialize();
|
||||||
|
|
||||||
|
result.Put("Path", this.Path);
|
||||||
|
result.Put("Total", EasyRead_Value(this.Total));
|
||||||
|
result.Put("Free", EasyRead_Value(this.Free));
|
||||||
|
result.Put("FreePercentage", this.FreePercentage);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
109
src/SBC/cpudata.java
Normal file
109
src/SBC/cpudata.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package SBC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Untuk olah data dari /proc/stat
|
||||||
|
* Mencari CPU usage
|
||||||
|
* https://stackoverflow.com/questions/23367857/accurate-calculation-of-cpu-usage-given-in-percentage-in-linux
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class cpudata {
|
||||||
|
public String name;
|
||||||
|
public long user;
|
||||||
|
public long nice;
|
||||||
|
public long system;
|
||||||
|
public long idle;
|
||||||
|
public long iowait;
|
||||||
|
public long irq;
|
||||||
|
public long softirq;
|
||||||
|
public long steal;
|
||||||
|
public long guest;
|
||||||
|
public long guest_nice;
|
||||||
|
public boolean correct_data;
|
||||||
|
|
||||||
|
public cpudata(String vv) {
|
||||||
|
String ww[] = vv.split("\\s+");
|
||||||
|
|
||||||
|
try {
|
||||||
|
name=ww[0].trim();
|
||||||
|
|
||||||
|
if (name.startsWith("cpu")) {
|
||||||
|
user=getlong(ww[1]);
|
||||||
|
nice=getlong(ww[2]);
|
||||||
|
system=getlong(ww[3]);
|
||||||
|
idle=getlong(ww[4]);
|
||||||
|
iowait=getlong(ww[5]);
|
||||||
|
irq=getlong(ww[6]);
|
||||||
|
softirq=getlong(ww[7]);
|
||||||
|
steal=getlong(ww[8]);
|
||||||
|
guest=getlong(ww[9]);
|
||||||
|
guest_nice=getlong(ww[10]);
|
||||||
|
correct_data = true;
|
||||||
|
} else {
|
||||||
|
correct_data = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(ArrayIndexOutOfBoundsException | NumberFormatException e) {
|
||||||
|
correct_data = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getlong(String ss) throws NumberFormatException {
|
||||||
|
ss = ss.trim();
|
||||||
|
return Long.parseLong(ss);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IdleData = idle + iowait
|
||||||
|
* @return IdleData (Long)
|
||||||
|
*/
|
||||||
|
public long getIdleData() {
|
||||||
|
if (correct_data) {
|
||||||
|
return idle+iowait;
|
||||||
|
} else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BusyData = user + nice + system + irq + softirq + steal
|
||||||
|
* @return BusyData (Long)
|
||||||
|
*/
|
||||||
|
public long getBusyData() {
|
||||||
|
if (correct_data) {
|
||||||
|
return user+nice+system+irq+softirq+steal;
|
||||||
|
} else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TotalData = IdleData + BusyData
|
||||||
|
* @return TotalData (Long)
|
||||||
|
*/
|
||||||
|
public long getTotalData() {
|
||||||
|
if (correct_data) {
|
||||||
|
return getIdleData()+getBusyData();
|
||||||
|
} else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get CPU Usage, in percentage
|
||||||
|
* @param prev : previous cpudata. if null, then will calculate total average cpu_usage since boot
|
||||||
|
* @return CPU Usage (double)
|
||||||
|
*/
|
||||||
|
public double getCPU_Usage(cpudata prev) {
|
||||||
|
long prev_total = 0;
|
||||||
|
long prev_idle = 0;
|
||||||
|
if (prev != null) {
|
||||||
|
if (prev.correct_data) {
|
||||||
|
prev_total = prev.getTotalData();
|
||||||
|
prev_idle =prev.getIdleData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long delta_total = getTotalData() - prev_total;
|
||||||
|
long delta_idle = getIdleData() - prev_idle;
|
||||||
|
|
||||||
|
double result = delta_total - delta_idle;
|
||||||
|
result = (result / delta_total) * 100;
|
||||||
|
return Math.round(result * 10.0) / 10.0; // pembulatan 1 desimal
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/UVC/Aver_VC520.java
Normal file
34
src/UVC/Aver_VC520.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package UVC;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
// gak jadi kepake
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class Aver_VC520 {
|
||||||
|
|
||||||
|
public final int VendorID = 0x2574;
|
||||||
|
public final int ProductID = 0x0901;
|
||||||
|
|
||||||
|
private BA bax;
|
||||||
|
private Object caller;
|
||||||
|
private String event;
|
||||||
|
private final Object Me = this;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
public void Initialize(BA ba, Object callerobject, String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
caller = callerobject;
|
||||||
|
event = eventname.trim();
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (caller != null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String value) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/UVC/UVC_Control.java
Normal file
68
src/UVC/UVC_Control.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
package UVC;
|
||||||
|
|
||||||
|
import jGPIO.Linux_C_lib_DirectMapping;
|
||||||
|
import jGPIO.jGPIO;
|
||||||
|
|
||||||
|
// https://github.com/allanbian1017/uvc-ctrl/blob/master/uvc-ctrl.c
|
||||||
|
// https://github.com/makenai/node-uvc-control/blob/master/lib/constants.js
|
||||||
|
// https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/user-func.html
|
||||||
|
// https://github.com/spotify/linux/blob/master/include/asm-generic/ioctl.h
|
||||||
|
// https://developer.sony.com/develop/spresense/developer-tools/api-reference/api-references-spresense-sdk/group__video__ioctl.html
|
||||||
|
// https://developer.sony.com/develop/spresense/developer-tools/api-reference/api-references-spresense-sdk/video_8h_source.html
|
||||||
|
|
||||||
|
// gak jadi kepake
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class UVC_Control {
|
||||||
|
private final String devicepath;
|
||||||
|
|
||||||
|
// request
|
||||||
|
|
||||||
|
private final int RC_UNDEFINED=0x00;
|
||||||
|
private final int SET_CUR=0x01;
|
||||||
|
private final int GET_CUR=0x81;
|
||||||
|
private final int GET_MIN=0x82;
|
||||||
|
private final int GET_MAX=0x83;
|
||||||
|
private final int GET_RES=0x84;
|
||||||
|
private final int GET_LEN=0x85;
|
||||||
|
private final int GET_INFO=0x86;
|
||||||
|
private final int GET_DEF=0x87;
|
||||||
|
|
||||||
|
// control
|
||||||
|
private final int CT_CONTROL_UNDEFINED = 0;
|
||||||
|
private final int CT_FOCUS_ABSOLUTE_CONTROL=0x06;
|
||||||
|
private final int CT_FOCUS_AUTO_CONTROL=0x08;
|
||||||
|
private final int CT_ZOOM_ABSOLUTE_CONTROL=0x0B;
|
||||||
|
private final int CT_ZOOM_RELATIVE_CONTROL=0x0C;
|
||||||
|
private final int CT_PANTILT_ABSOLUTE_CONTROL=0x0D;
|
||||||
|
private final int CT_PANTILT_RELATIVE_CONTROL=0x0E;
|
||||||
|
|
||||||
|
int camerahandle = -1;
|
||||||
|
private final int O_RDWR = 0x00000002;
|
||||||
|
Linux_C_lib_DirectMapping linuxmap;
|
||||||
|
|
||||||
|
public UVC_Control(String path) {
|
||||||
|
devicepath = path.trim();
|
||||||
|
linuxmap = new Linux_C_lib_DirectMapping();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean Open() {
|
||||||
|
camerahandle = linuxmap.open(devicepath, O_RDWR);
|
||||||
|
return camerahandle<0 ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() {
|
||||||
|
if (camerahandle>=0) {
|
||||||
|
jGPIO.libC.close(camerahandle);
|
||||||
|
}
|
||||||
|
camerahandle = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IsOpened() {
|
||||||
|
return (camerahandle >=0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
98
src/customsocket/AckRequestWrapper.java
Normal file
98
src/customsocket/AckRequestWrapper.java
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import com.corundumstudio.socketio.AckRequest;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
|
||||||
|
@BA.ShortName("AckRequest")
|
||||||
|
public class AckRequestWrapper {
|
||||||
|
private final AckRequest request;
|
||||||
|
|
||||||
|
public AckRequestWrapper(AckRequest req) {
|
||||||
|
request = req;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Acknowledge is required
|
||||||
|
* @return true if required
|
||||||
|
*/
|
||||||
|
public boolean isAckRequested() {
|
||||||
|
if (request!=null) {
|
||||||
|
return request.isAckRequested();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reply with array of object
|
||||||
|
* @param value array of object
|
||||||
|
*/
|
||||||
|
public void Reply_Array(Object[] value) {
|
||||||
|
if (value!=null) {
|
||||||
|
if (value.length>0) {
|
||||||
|
request.sendAckData(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notify_this();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reply with a String
|
||||||
|
* @param value String value
|
||||||
|
*/
|
||||||
|
public void Reply_String(String value) {
|
||||||
|
if (value != null) {
|
||||||
|
if (value.length()>0) {
|
||||||
|
request.sendAckData(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notify_this();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reply with a Map
|
||||||
|
* @param value Map value
|
||||||
|
*/
|
||||||
|
public void Reply_Map(Map value) {
|
||||||
|
|
||||||
|
if (value!=null) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
if (value.getSize()>0) {
|
||||||
|
request.sendAckData(value.getObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notify_this();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reply with a List
|
||||||
|
* @param value List value
|
||||||
|
*/
|
||||||
|
public void Reply_List(List value) {
|
||||||
|
|
||||||
|
if (value!=null) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
if (value.getSize()>0) {
|
||||||
|
request.sendAckData(value.getObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notify_this();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notify_this() {
|
||||||
|
synchronized(this) {
|
||||||
|
try {
|
||||||
|
this.notify();
|
||||||
|
} catch(IllegalMonitorStateException e) {
|
||||||
|
System.out.println("this.notify exception = "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
597
src/customsocket/JsonArray.java
Normal file
597
src/customsocket/JsonArray.java
Normal file
@@ -0,0 +1,597 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
import anywheresoftware.b4a.objects.streams.File;
|
||||||
|
import anywheresoftware.b4a.objects.streams.File.InputStreamWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON Array Object
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@BA.ShortName("JsonArray")
|
||||||
|
public class JsonArray {
|
||||||
|
|
||||||
|
private JSONArray ja;
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
/**
|
||||||
|
* Get Native JSONArray Object
|
||||||
|
* @return JSONArray object
|
||||||
|
*/
|
||||||
|
public JSONArray getObject() {
|
||||||
|
return ja;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
/**
|
||||||
|
* Set Native JSONArray object
|
||||||
|
* @param value : source value
|
||||||
|
*/
|
||||||
|
public void setObject(JSONArray value) {
|
||||||
|
ja = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize empty JsonArray
|
||||||
|
*/
|
||||||
|
public void InitializeEmpty() {
|
||||||
|
ja = new JSONArray();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize JsonArray from String
|
||||||
|
* @param value : string with format of Json Array
|
||||||
|
* @return true if can be initialized
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromString(String value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
try {
|
||||||
|
ja = new JSONArray(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to InitializeFromString, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Initialize JsonArray from a file containing plain string
|
||||||
|
* Reading result from file, will be used in InitializeFromString function
|
||||||
|
* @param directory : directory path
|
||||||
|
* @param filename : filename
|
||||||
|
* @return true if value can be translated to JsonArray
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromFile(String directory, String filename) {
|
||||||
|
try {
|
||||||
|
if (File.Exists(directory, filename)) {
|
||||||
|
InputStreamWrapper isw = File.OpenInput(directory, filename);
|
||||||
|
if (isw.IsInitialized()) {
|
||||||
|
int bytecount = isw.BytesAvailable();
|
||||||
|
if (bytecount>0) {
|
||||||
|
byte[] bb = new byte[bytecount];
|
||||||
|
isw.ReadBytes(bb, 0, bytecount);
|
||||||
|
isw.Close();
|
||||||
|
String value = new String(bb);
|
||||||
|
return InitializeFromString(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
BA.Log("Unable to InitializeFromFile, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize JsonArray from B4X List
|
||||||
|
* @param value : B4X List
|
||||||
|
* @return true if value can be translated to JsonArray
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromList(List value) {
|
||||||
|
if (value instanceof List) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
if (value.getSize()>0) {
|
||||||
|
try {
|
||||||
|
ja = new JSONArray(value.getObject());
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to InitializeFromList, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize JsonArray from array of Object
|
||||||
|
* @param value : array of object, which can be anything from String, int, long, etc.
|
||||||
|
* @return true if value can be translated to JsonArray
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromObject(Object... value) {
|
||||||
|
if (value != null) {
|
||||||
|
if (value.length>0) {
|
||||||
|
try {
|
||||||
|
ja = new JSONArray(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to InitializeFromObject, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if JsonArray is initialized
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
if (ja instanceof JSONArray) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear content of JsonArray
|
||||||
|
*/
|
||||||
|
public void Clear() {
|
||||||
|
if (IsInitialized()) ja.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if JsonArray has some value
|
||||||
|
* @return true if has value
|
||||||
|
*/
|
||||||
|
public boolean HasSomeValue() {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
|
||||||
|
return !ja.isEmpty();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Size of JsonArray
|
||||||
|
* @return 0 if empty or not initialized
|
||||||
|
*/
|
||||||
|
public int getSize() {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
return ja.length();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get JsonArray in string format
|
||||||
|
* @return String value
|
||||||
|
*/
|
||||||
|
public String ToString() {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
return ja.toString();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get JsonArray in pretty string format
|
||||||
|
* @param indentvalue how many space to indent string
|
||||||
|
* @return String value
|
||||||
|
*/
|
||||||
|
public String ToStringWithIndent(int indentvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
return ja.toString(indentvalue);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write JsonArray to a File
|
||||||
|
* @param directory : directory path
|
||||||
|
* @param filename : filename
|
||||||
|
* @return true if can be written
|
||||||
|
*/
|
||||||
|
public boolean WriteToFile(String directory, String filename) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
Writer ww = new FileWriter(File.Combine(directory, filename));
|
||||||
|
ja.write(ww);
|
||||||
|
ww.close();
|
||||||
|
return true;
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
BA.Log("Unable to WriteToFile, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write JsonArray to a file with indentation for pretty string
|
||||||
|
* @param directory : directory path
|
||||||
|
* @param filename : filename
|
||||||
|
* @param indentvalue : how many spaces added for indentation
|
||||||
|
* @return true if can be written
|
||||||
|
*/
|
||||||
|
public boolean WriteToFileWithIndent(String directory, String filename, int indentvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
Writer ww = new FileWriter(File.Combine(directory, filename));
|
||||||
|
ja.write(ww, indentvalue, indentvalue);
|
||||||
|
ww.close();
|
||||||
|
return true;
|
||||||
|
}catch (IOException | JSONException e) {
|
||||||
|
BA.Log("Unable to WriteToFileWithIndent, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an Object at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @return null if index not found
|
||||||
|
*/
|
||||||
|
public Object Get(int index) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
Object result = ja.get(index);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to Get, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an Object to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean Put(Object value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
try {
|
||||||
|
ja.put(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to Put, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a boolean at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index not found, will return this value
|
||||||
|
* @return boolean value
|
||||||
|
*/
|
||||||
|
public boolean GetBoolean(int index, boolean defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
boolean result = ja.getBoolean(index);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to GetBoolean, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an boolean to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutBoolean(boolean value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
try {
|
||||||
|
ja.put(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutBoolean, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a double at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index not found, will return this value
|
||||||
|
* @return double value
|
||||||
|
*/
|
||||||
|
public double GetDouble(int index, double defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
double result = ja.getDouble(index);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to GetDouble, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an double to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutDouble(double value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
try {
|
||||||
|
ja.put(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutDouble, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a float at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index not found, will return this value
|
||||||
|
* @return float value
|
||||||
|
*/
|
||||||
|
public float GetFloat(int index, float defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
float result = ja.getFloat(index);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to GetFloat, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an float to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutFloat(float value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
try {
|
||||||
|
ja.put(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutFloat, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a int at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index not found, will return this value
|
||||||
|
* @return int value
|
||||||
|
*/
|
||||||
|
public int GetInt(int index, int defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
int result = ja.getInt(index);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to GetInt, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an int to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutInt(int value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
try {
|
||||||
|
ja.put(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutInt, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a long at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index not found, will return this value
|
||||||
|
* @return long value
|
||||||
|
*/
|
||||||
|
public long GetLong(int index, long defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
long result = ja.getLong(index);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to GetLong, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an long to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutLong(long value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
try {
|
||||||
|
ja.put(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutLong, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a JsonObject at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index nt found, will return this value
|
||||||
|
* @return JsonObject value
|
||||||
|
*/
|
||||||
|
public JsonObject GetJsonObject(int index, JsonObject defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
JSONObject jo = ja.getJSONObject(index);
|
||||||
|
JsonObject result = new JsonObject();
|
||||||
|
result.setObject(jo);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to GetJsonObject, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an JsonObject to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutJsonObject(JsonObject value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (value instanceof JsonObject) {
|
||||||
|
if (value.HasSomeValue()) {
|
||||||
|
JSONObject xx = value.getObject();
|
||||||
|
if (xx instanceof JSONObject) {
|
||||||
|
try {
|
||||||
|
ja.put(xx);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutJsonObject, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a String at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index not found, will return this value
|
||||||
|
* @return String value
|
||||||
|
*/
|
||||||
|
public String GetString(int index, String defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
String result = ja.getString(index);
|
||||||
|
return result;
|
||||||
|
} catch(JSONException e){
|
||||||
|
BA.Log("Unable to GetString, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a String to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutString(String value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
try {
|
||||||
|
ja.put(value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutString, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a B4X List to JsonArray
|
||||||
|
* @param value : value to put
|
||||||
|
* @return true if can be put
|
||||||
|
*/
|
||||||
|
public boolean PutList(List value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (value instanceof List) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
if (value.getSize()>0) {
|
||||||
|
try {
|
||||||
|
ja.put(value.getObject());
|
||||||
|
return true;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to PutList, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
/**
|
||||||
|
* Get a B4X List at index
|
||||||
|
* @param index : zero-based index
|
||||||
|
* @param defaultvalue : if index not found, will return this value
|
||||||
|
* @return List value
|
||||||
|
*/
|
||||||
|
public List GetList(int index, List defaultvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
Object xx = ja.get(index);
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
if (xx instanceof java.util.List<?>) {
|
||||||
|
java.util.List<Object> mm = (java.util.List<Object>) xx;
|
||||||
|
mm.forEach((vv)->{
|
||||||
|
result.Add(vv);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
result.Add(xx);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetList, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
726
src/customsocket/JsonObject.java
Normal file
726
src/customsocket/JsonObject.java
Normal file
@@ -0,0 +1,726 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map.MyMap;
|
||||||
|
import anywheresoftware.b4a.objects.streams.File;
|
||||||
|
import anywheresoftware.b4a.objects.streams.File.InputStreamWrapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JsonObject is almost like a Map
|
||||||
|
* it contain key and value pair
|
||||||
|
* used mainly in SocketIO javascript
|
||||||
|
*
|
||||||
|
* Source : https://github.com/stleary/JSON-java
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@BA.ShortName("JsonObject")
|
||||||
|
public class JsonObject {
|
||||||
|
private JSONObject jo;
|
||||||
|
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
/**
|
||||||
|
* Get Native JSONObject object from org.json java
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
public JSONObject getObject() {
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
/**
|
||||||
|
* Set Native JSONObject
|
||||||
|
* @param vv : other value
|
||||||
|
*/
|
||||||
|
public void setObject(JSONObject vv) {
|
||||||
|
jo = vv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize empty JsonObject
|
||||||
|
*/
|
||||||
|
public void InitializeEmpty() {
|
||||||
|
jo = new JSONObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize JsonObject from B4X Map
|
||||||
|
* @param value : B4X Map
|
||||||
|
* @return true if value can be translated to JsonObject
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromMap(Map value) {
|
||||||
|
if (value instanceof Map) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
MyMap mm = value.getObject();
|
||||||
|
if (mm instanceof MyMap) {
|
||||||
|
try {
|
||||||
|
jo = new JSONObject(mm);
|
||||||
|
return (!jo.isEmpty()); // kalau empty, return false. kalau gak empty return true
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to Initialize JsonObject from Map, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize JsonObject from JSON String
|
||||||
|
* @param value : String
|
||||||
|
* @return true if value can be translated to JsonObject
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromString(String value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jo = new JSONObject(value);
|
||||||
|
return (!jo.isEmpty());
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to Initialize JsonObject from String, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize JsonObject from a file containing plain string
|
||||||
|
* Reading result from file, will be used in InitializeFromString function
|
||||||
|
* @param directory : directory path
|
||||||
|
* @param filename : filename
|
||||||
|
* @return true if value can be translated to JsonObject
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromFile(String directory, String filename) {
|
||||||
|
try {
|
||||||
|
if (File.Exists(directory, filename)) {
|
||||||
|
InputStreamWrapper isw = File.OpenInput(directory, filename);
|
||||||
|
if (isw.IsInitialized()) {
|
||||||
|
int bytecount = isw.BytesAvailable();
|
||||||
|
if (bytecount>0) {
|
||||||
|
byte[] bb = new byte[bytecount];
|
||||||
|
isw.ReadBytes(bb, 0, bytecount);
|
||||||
|
isw.Close();
|
||||||
|
String value = new String(bb);
|
||||||
|
return InitializeFromString(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
BA.Log("InitializeFromFile failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Initialize JsonObject from another JsonObject .
|
||||||
|
* @param othervalue : other JsonObject as copy source
|
||||||
|
* @param keys : array of string, containing keys to copy from other JsonObject
|
||||||
|
* @return true if othervalue can be copied
|
||||||
|
*/
|
||||||
|
public boolean InitializeFromOtherJsonObject(JsonObject othervalue, String... keys) {
|
||||||
|
if (keys!=null) {
|
||||||
|
if (keys.length>0) {
|
||||||
|
if (othervalue instanceof JsonObject) {
|
||||||
|
if (othervalue.HasSomeValue()) {
|
||||||
|
jo = new JSONObject(othervalue.getObject(), keys);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if JsonObject is initialized
|
||||||
|
* @return true if inited
|
||||||
|
*/
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
if (jo instanceof JSONObject) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if JsonObject has been initialized and has some value
|
||||||
|
* @return true if has value
|
||||||
|
*/
|
||||||
|
public boolean HasSomeValue() {
|
||||||
|
if (jo instanceof JSONObject) {
|
||||||
|
if (!jo.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get List of Keys in this JsonObject
|
||||||
|
* @return B4X List
|
||||||
|
*/
|
||||||
|
public List GetListofKeys() {
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
Iterator<String> iter = jo.keys();
|
||||||
|
iter.forEachRemaining(value->{
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
result.Add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this JsonObject contain spesific key
|
||||||
|
* @param value : String key to search
|
||||||
|
* @return true if it has
|
||||||
|
*/
|
||||||
|
public boolean ContainKey(String value) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
return jo.has(value);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get JsonObject size
|
||||||
|
* @return -1 if not initialized yet, 0 if empty, positive numbers if has value
|
||||||
|
*/
|
||||||
|
public int Size() {
|
||||||
|
if (jo instanceof JSONObject) {
|
||||||
|
return jo.length();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear JsonObject contents and keys
|
||||||
|
* @return true if can be cleared
|
||||||
|
*/
|
||||||
|
public boolean Clear() {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
jo.clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a content with specific key
|
||||||
|
* @param key : String key to remove
|
||||||
|
* @return Object removed from JsonObject, or null if not available or not initialized
|
||||||
|
*/
|
||||||
|
public Object Remove(String key) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
return jo.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get JsonObject key-value in string
|
||||||
|
* @return empty string if JsonObject not initialized, or is empty
|
||||||
|
*/
|
||||||
|
public String ToString() {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
return jo.toString();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get JsonObject key-value in pretty string
|
||||||
|
* @param indentvalue : how many spaces for indentation to be added
|
||||||
|
* @return empty string if JsonObject not initialized or is empty
|
||||||
|
*/
|
||||||
|
public String ToStringWithIndent(int indentvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
return jo.toString(indentvalue);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write JsonObject to a file , in plain string value
|
||||||
|
* @param directory : directory path
|
||||||
|
* @param filename : filename
|
||||||
|
* @return true if write operation succesful
|
||||||
|
*/
|
||||||
|
public boolean WriteToFile(String directory, String filename) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
Writer ww = new FileWriter(File.Combine(directory, filename));
|
||||||
|
jo.write(ww);
|
||||||
|
ww.close();
|
||||||
|
return true;
|
||||||
|
} catch(IOException | JSONException e) {
|
||||||
|
BA.Log("WriteToFile failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write JsonObject to a file, in plain string value
|
||||||
|
* @param directory : directory path
|
||||||
|
* @param filename : filename
|
||||||
|
* @param indentvalue : how many spaces for indentation to be added
|
||||||
|
* @return true if write operation succesful
|
||||||
|
*/
|
||||||
|
public boolean WriteToFileWithIndent(String directory, String filename, int indentvalue) {
|
||||||
|
if (HasSomeValue()) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Writer ww = new FileWriter(File.Combine(directory, filename));
|
||||||
|
jo.write(ww, indentvalue, indentvalue);
|
||||||
|
ww.close();
|
||||||
|
return true;
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
BA.Log("WriteToFileWithIndent failed, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a boolean value in JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : boolean value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutBoolean(String key, boolean value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutBoolean, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a double value in JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : double value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutDouble(String key, double value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutDouble, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a float value in JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : float value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutFloat(String key, float value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutFloat, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an Int value in JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : Int value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutInt(String key, int value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutInt, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a long value in JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : long value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutLong(String key, long value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutLong, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put an Object value in JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : Object value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutObject(String key, Object value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutObject, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a String value in JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : String value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutString(String key, String value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutString, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a B4X Map value to JsonObject with specific kety
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : B4X Map value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutMap(String key, Map value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
if (value instanceof Map) {
|
||||||
|
|
||||||
|
MyMap obj = value.getObject();
|
||||||
|
if (obj instanceof MyMap) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
jo.put(key, obj);
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutMap, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a B4X List value to JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : B4X List value
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutList(String key, List value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
if (value instanceof List) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
if (value.getSize()>0) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value.getObject());
|
||||||
|
return true;
|
||||||
|
} catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutList, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put other JsonObject to this JsonObject with specific key
|
||||||
|
* @param key : String key
|
||||||
|
* @param value : other JsonObject
|
||||||
|
* @return true if can be added
|
||||||
|
*/
|
||||||
|
public boolean PutJsonObject(String key, JsonObject value) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
if (!key.isEmpty()) {
|
||||||
|
if (value instanceof JsonObject) {
|
||||||
|
if (value.HasSomeValue()) {
|
||||||
|
try {
|
||||||
|
jo.put(key, value.getObject());
|
||||||
|
return true;
|
||||||
|
}catch(JSONException | NullPointerException e) {
|
||||||
|
BA.Log("Unable to PutJsonObject, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this JsonObject is similar key-value with other JsonObject
|
||||||
|
* @param othervalue : other JsonObject to compare
|
||||||
|
* @return true if similar
|
||||||
|
*/
|
||||||
|
public boolean IsSimilar(JsonObject othervalue) {
|
||||||
|
if (IsInitialized()) {
|
||||||
|
return jo.similar(othervalue);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a String value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return String value
|
||||||
|
*/
|
||||||
|
public String GetStringValue(String key, String defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
String value = jo.getString(key);
|
||||||
|
return value;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetStringValue, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Long value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return long value
|
||||||
|
*/
|
||||||
|
public long GetLongValue(String key, long defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
long value = jo.getLong(key);
|
||||||
|
return value;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetLongValue, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a JsonObject value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return JsonObject value
|
||||||
|
*/
|
||||||
|
public JsonObject GetJsonObject(String key, JsonObject defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
JSONObject value = jo.getJSONObject(key);
|
||||||
|
JsonObject jvalue = new JsonObject();
|
||||||
|
jvalue.setObject(value);
|
||||||
|
return jvalue;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetJsonObject, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an int value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return int value
|
||||||
|
*/
|
||||||
|
public int GetInt(String key, int defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
int value = jo.getInt(key);
|
||||||
|
return value;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetInt, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an float value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return float value
|
||||||
|
*/
|
||||||
|
public float GetFloat(String key, float defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
float value = jo.getFloat(key);
|
||||||
|
return value;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetFloat, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an double value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return double value
|
||||||
|
*/
|
||||||
|
public double GetDouble(String key, double defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
double value = jo.getDouble(key);
|
||||||
|
return value;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetDouble, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an boolean value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return boolean value
|
||||||
|
*/
|
||||||
|
public boolean GetBoolean(String key, boolean defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
boolean value = jo.getBoolean(key);
|
||||||
|
return value;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetBoolean, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an Object value matched with the key
|
||||||
|
* @param key : key linked to value
|
||||||
|
* @param defaultvalue : if specific key not found, return this value
|
||||||
|
* @return Object value
|
||||||
|
*/
|
||||||
|
public Object GetObject(String key, Object defaultvalue) {
|
||||||
|
if (ContainKey(key)) {
|
||||||
|
try {
|
||||||
|
Object value = jo.get(key);
|
||||||
|
return value;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
BA.Log("Unable to GetObject, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
386
src/customsocket/NettySocketWrapper.java
Normal file
386
src/customsocket/NettySocketWrapper.java
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
|
|
||||||
|
import com.corundumstudio.socketio.AckCallback;
|
||||||
|
import com.corundumstudio.socketio.SocketIOClient;
|
||||||
|
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
import io.socket.engineio.client.Socket;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NettySocketWrapper dipakai di class jSocketIOServer
|
||||||
|
* sebagai client yang connected ke jSocketIOServer
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@BA.ShortName("NettySocketWrapper")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)"
|
||||||
|
})
|
||||||
|
public class NettySocketWrapper implements SocketIOClientInterface {
|
||||||
|
|
||||||
|
private final SocketIOClient _socket;
|
||||||
|
|
||||||
|
private final String _id;
|
||||||
|
private final String _namespace;
|
||||||
|
private final String _remote;
|
||||||
|
private final String _local;
|
||||||
|
private final boolean _isvalid;
|
||||||
|
|
||||||
|
private final Object Me = this;
|
||||||
|
private BA bax;
|
||||||
|
private Object callerobject;
|
||||||
|
private String event;
|
||||||
|
private boolean _inited = false;
|
||||||
|
private boolean _connected = false;
|
||||||
|
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public NettySocketWrapper() {
|
||||||
|
// gak ngapa-ngapain, nyediain B4X doang
|
||||||
|
_socket = null;
|
||||||
|
|
||||||
|
_id = "";
|
||||||
|
_namespace = "";
|
||||||
|
_remote = "N/A";
|
||||||
|
_isvalid = false;
|
||||||
|
_local = "N/A";
|
||||||
|
_connected = false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public NettySocketWrapper(SocketIOClient sock) {
|
||||||
|
_socket = sock;
|
||||||
|
if (_socket instanceof SocketIOClient) {
|
||||||
|
|
||||||
|
_id = _socket.getSessionId().toString();
|
||||||
|
_namespace = _socket.getNamespace().getName();
|
||||||
|
InetSocketAddress xx = _socket.getHandshakeData().getAddress();
|
||||||
|
_remote = xx.getHostString()+":"+xx.getPort();
|
||||||
|
InetSocketAddress yy = _socket.getHandshakeData().getLocal();
|
||||||
|
_local = yy.getHostString()+":"+yy.getPort();
|
||||||
|
_isvalid = true;
|
||||||
|
_connected = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_isvalid = false;
|
||||||
|
_id = "";
|
||||||
|
_remote = "N/A";
|
||||||
|
_local = "N/A";
|
||||||
|
_namespace ="";
|
||||||
|
_connected = false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup Events
|
||||||
|
* @param caller : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void SetupEvent(BA ba, Object caller, String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
callerobject = caller;
|
||||||
|
event = eventname;
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (callerobject!=null) {
|
||||||
|
if (event instanceof String) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
_inited = true;
|
||||||
|
if (need_log_event) raise_log("Will raise log event");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Event is Initialized
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
|
public boolean EventInited() {
|
||||||
|
return _inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Disconnect() {
|
||||||
|
if (_isvalid) {
|
||||||
|
_socket.disconnect();
|
||||||
|
}
|
||||||
|
_connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean IsConnected() {
|
||||||
|
return _connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getID() {
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRemote() {
|
||||||
|
return _remote;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLocal() {
|
||||||
|
return _local;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Namespace in String
|
||||||
|
* @return Namespace
|
||||||
|
*/
|
||||||
|
public String getNamespace() {
|
||||||
|
return _namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description string in format ID=[ID], Remote=[Remote], Namespace=[Namespace]
|
||||||
|
* @return Description String
|
||||||
|
*/
|
||||||
|
public String CompleteDescription() {
|
||||||
|
return "ID="+getID()+", Remote="+getRemote()+", Namespace="+getNamespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit List to target socket
|
||||||
|
* @param emitname : event name
|
||||||
|
* @param value : value in B4X List Object
|
||||||
|
* @param showtype : if true, then will show each object type of List members
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Emit_List(String emitname, List value, boolean showtype) {
|
||||||
|
if (value instanceof List) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
|
||||||
|
int valuesize = value.getSize();
|
||||||
|
if (valuesize>0) {
|
||||||
|
return Emit(emitname, value.getObject());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit a command with List value to target socket, but expect return value
|
||||||
|
* <br/>will raise event <b>emitname_complete(valueback as Object)</b>
|
||||||
|
* <br/>Must check valueback type using <b>GetType(valueback)</b> or using <b>If (valueback Is ...) Then</b>
|
||||||
|
* @param emitname emint name
|
||||||
|
* @return true if can be emitted
|
||||||
|
*/
|
||||||
|
public boolean Emit_List_withCallback(final BA ba,String emitname, List value) {
|
||||||
|
|
||||||
|
if (emitname != null && emitname.length()>0) {
|
||||||
|
final String callbackevent = emitname+"_complete";
|
||||||
|
if (_connected) {
|
||||||
|
_socket.sendEvent(emitname, new AckCallback<Object>(Object.class,5000) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object result) {
|
||||||
|
ba.raiseEventFromDifferentThread(Me, null, 0, callbackevent, false, new Object[] {result});
|
||||||
|
}
|
||||||
|
|
||||||
|
}, value.getObject());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit Map to target socket
|
||||||
|
* @param emitname : event name
|
||||||
|
* @param value : value in B4X Map object
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Emit_Map(String emitname, Map value) {
|
||||||
|
if (value instanceof Map) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
|
||||||
|
int valuesize = value.getSize();
|
||||||
|
if (valuesize>0) {
|
||||||
|
return Emit(emitname, value.getObject());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit a command with Map value to target socket, but expect return value
|
||||||
|
* <br/>will raise event <b>emitname_complete(valueback as Object)</b>
|
||||||
|
* <br/>Must check valueback type using <b>GetType(valueback)</b> or using <b>If (valueback Is ...) Then</b>
|
||||||
|
* @param emitname emint name
|
||||||
|
* @return true if can be emitted
|
||||||
|
*/
|
||||||
|
public boolean Emit_Map_withCallback(final BA ba,String emitname, Map value) {
|
||||||
|
if (emitname != null && emitname.length()>0) {
|
||||||
|
final String callbackevent = emitname+"_complete";
|
||||||
|
if (_connected) {
|
||||||
|
|
||||||
|
_socket.sendEvent(emitname, new AckCallback<Object>(Object.class, 5000) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object result) {
|
||||||
|
ba.raiseEventFromDifferentThread(Me, null, 0, callbackevent, false, new Object[] {result});
|
||||||
|
}
|
||||||
|
|
||||||
|
}, value.getObject());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit a command without value to target socket
|
||||||
|
* @param emitname : event name
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Emit_noValue(String emitname) {
|
||||||
|
return Emit(emitname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit a command with no value to target socket, but expect return value
|
||||||
|
* <br/>will raise event <b>emitname_complete(valueback as Object)</b>
|
||||||
|
* <br/>Must check valueback type using <b>GetType(valueback)</b> or using <b>If (valueback Is ...) Then</b>
|
||||||
|
* @param emitname emint name
|
||||||
|
* @return true if can be emitted
|
||||||
|
*/
|
||||||
|
public boolean Emit_noValue_withCallback(final BA ba,String emitname) {
|
||||||
|
if (emitname != null && emitname.length()>0) {
|
||||||
|
final String callbackevent = emitname+"_complete";
|
||||||
|
if (_connected) {
|
||||||
|
_socket.sendEvent(emitname, new AckCallback<Object>(Object.class,5000) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object result) {
|
||||||
|
ba.raiseEventFromDifferentThread(Me, null, 0, callbackevent, false, new Object[] {result});
|
||||||
|
}
|
||||||
|
|
||||||
|
}, new Object[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit a String to target socket
|
||||||
|
* @param emitname : event name
|
||||||
|
* @param value : String to send
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Emit_String(String emitname, String value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
return Emit(emitname, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit a command with String value to target socket, but expect return value
|
||||||
|
* <br/>will raise event <b>emitname_complete(valueback as Object)</b>
|
||||||
|
* <br/>Must check valueback type using <b>GetType(valueback)</b> or using <b>If (valueback Is ...) Then</b>
|
||||||
|
* @param emitname emint name
|
||||||
|
* @return true if can be emitted
|
||||||
|
*/
|
||||||
|
public boolean Emit_String_withCallback(final BA ba,String emitname, String value) {
|
||||||
|
if (emitname != null && emitname.length()>0) {
|
||||||
|
final String callbackevent = emitname+"_complete";
|
||||||
|
if (_connected) {
|
||||||
|
_socket.sendEvent(emitname, new AckCallback<Object>(Object.class,5000) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object result) {
|
||||||
|
ba.raiseEventFromDifferentThread(Me, null, 0, callbackevent, false, new Object[] {result});
|
||||||
|
}
|
||||||
|
|
||||||
|
}, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean Emit(String emitname, Object... value) {
|
||||||
|
if (_connected) {
|
||||||
|
_socket.sendEvent(emitname, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit a command with Object value to target socket, but expect return value
|
||||||
|
* <br/>will raise event <b>emitname_complete(valueback as Object)</b>
|
||||||
|
* <br/>Must check valueback type using <b>GetType(valueback)</b> or using <b>If (valueback Is ...) Then</b>
|
||||||
|
* @param emitname emint name
|
||||||
|
* @return true if can be emitted
|
||||||
|
*/
|
||||||
|
public boolean Emit_withCallback(final BA ba,String emitname, Object... value) {
|
||||||
|
if (emitname != null && emitname.length()>0) {
|
||||||
|
final String callbackevent = emitname+"_complete";
|
||||||
|
if (_connected) {
|
||||||
|
_socket.sendEvent(emitname, new AckCallback<Object>(Object.class,5000) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object result) {
|
||||||
|
ba.raiseEventFromDifferentThread(Me, null, 0, callbackevent, false, new Object[] {result});
|
||||||
|
}
|
||||||
|
|
||||||
|
}, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean SendMessage(String value) {
|
||||||
|
return Emit(Socket.EVENT_MESSAGE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void printlog(String... strings) {
|
||||||
|
if (strings!=null) {
|
||||||
|
if (strings.length==1) {
|
||||||
|
BA.Log(strings[0]);
|
||||||
|
} else {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
for(String xx : strings) str.append(xx);
|
||||||
|
BA.Log(str.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
419
src/customsocket/SimpleTCPSocket.java
Normal file
419
src/customsocket/SimpleTCPSocket.java
Normal file
@@ -0,0 +1,419 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.DateTime;
|
||||||
|
|
||||||
|
@BA.ShortName("SimpleTCPSocket")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"connected(targetip as string, targetport as int)",
|
||||||
|
"disconnected(targetip as string, targetport as int, duration as long)",
|
||||||
|
"newbytesdata(value() as byte)",
|
||||||
|
"txrxstatus(packetsent as int, packetreceived as int, totalsent as long, totalreceived as long)"
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
public class SimpleTCPSocket {
|
||||||
|
private BA bax;
|
||||||
|
private Object Me = this;
|
||||||
|
private String event;
|
||||||
|
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_connected_event = false;
|
||||||
|
private boolean need_disconnected_event = false;
|
||||||
|
private boolean need_newbytesdata_event = false;
|
||||||
|
private boolean need_txrxstatus_event = false;
|
||||||
|
|
||||||
|
|
||||||
|
private Socket _socket = null;
|
||||||
|
private boolean isprefix = false;
|
||||||
|
private Integer packetsent = 0;
|
||||||
|
private Integer packetreceived = 0;
|
||||||
|
private Long totalsent = 0l;
|
||||||
|
private Long totalreceived = 0l;
|
||||||
|
/**
|
||||||
|
* Initialize Simple TCP Socket universal
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, String event) {
|
||||||
|
this.bax = ba;
|
||||||
|
this.event = event;
|
||||||
|
need_log_event = bax.subExists(this.event+"_log");
|
||||||
|
need_connected_event = bax.subExists(this.event+"_connected");
|
||||||
|
need_disconnected_event = bax.subExists(this.event+"_disconnected");
|
||||||
|
need_newbytesdata_event = bax.subExists(this.event+"_newbytesdata");
|
||||||
|
need_txrxstatus_event = bax.subExists(this.event+"_txrxstatus");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Socket
|
||||||
|
*/
|
||||||
|
public void Close() {
|
||||||
|
if (_socket != null) {
|
||||||
|
try {
|
||||||
|
_socket.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_event("Close failed, exception="+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_socket = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Still connected
|
||||||
|
* @return true if connected
|
||||||
|
*/
|
||||||
|
public boolean IsConnected() {
|
||||||
|
if (_socket != null) {
|
||||||
|
if (!_socket.isClosed()) {
|
||||||
|
if (!_socket.isInputShutdown()) {
|
||||||
|
if (!_socket.isOutputShutdown()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write bytes to Socket
|
||||||
|
* @param data : array of bytes to write
|
||||||
|
* @return -1 if failed, or number of bytes written
|
||||||
|
*/
|
||||||
|
public int Write(byte[] data) {
|
||||||
|
if (IsConnected()) {
|
||||||
|
if (data instanceof byte[] && data.length>0) {
|
||||||
|
int length = data.length;
|
||||||
|
byte[] newdata;
|
||||||
|
if (isprefix) {
|
||||||
|
newdata = new byte[length+4];
|
||||||
|
newdata[0] = (byte)(length & 0xFF);
|
||||||
|
newdata[1] = (byte)((length & 0xFF00)>>8);
|
||||||
|
newdata[2] = (byte)((length & 0xFF0000)>>16);
|
||||||
|
newdata[3] = (byte)((length& 0xFF000000)>>24);
|
||||||
|
System.arraycopy(data, 0, newdata, 4, length);
|
||||||
|
} else {
|
||||||
|
newdata = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
_socket.getOutputStream().write(newdata);
|
||||||
|
packetsent = packetsent < Integer.MAX_VALUE ? packetsent+1 : 0;
|
||||||
|
totalsent = ((Long.MAX_VALUE - totalsent) > newdata.length) ? (totalsent + newdata.length) : newdata.length;
|
||||||
|
raise_txrxstatus_event();
|
||||||
|
return newdata.length;
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_event("Write failed, exception="+e.getMessage()+", closing socket");
|
||||||
|
if (_socket!=null) {
|
||||||
|
String remoteip = _socket.getInetAddress().getHostAddress();
|
||||||
|
int remoteport = _socket.getPort();
|
||||||
|
raise_disconnected_event(remoteip, remoteport,0);
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class socketprefixrunnable implements Runnable{
|
||||||
|
private final Socket trysocket;
|
||||||
|
private final String remoteip;
|
||||||
|
private final int remoteport;
|
||||||
|
private final String localip;
|
||||||
|
private final int localport;
|
||||||
|
private final long _now;
|
||||||
|
private InputStream sock_is = null;
|
||||||
|
private boolean validrun = false;
|
||||||
|
|
||||||
|
public socketprefixrunnable(Socket _sock) {
|
||||||
|
trysocket = _sock;
|
||||||
|
remoteip = trysocket.getInetAddress().getHostAddress();
|
||||||
|
remoteport = trysocket.getPort();
|
||||||
|
localip = trysocket.getLocalAddress().getHostAddress();
|
||||||
|
localport = trysocket.getLocalPort();
|
||||||
|
_now = DateTime.getNow();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
validrun = false;
|
||||||
|
try {
|
||||||
|
_socket = trysocket;
|
||||||
|
sock_is = _socket.getInputStream();
|
||||||
|
validrun = true;
|
||||||
|
} catch (IOException e1) {
|
||||||
|
raise_log_event("getInputStream failed, exception="+e1.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
if (validrun) {
|
||||||
|
raise_connected_event(remoteip, remoteport);
|
||||||
|
raise_log_event("socket prefix connected to "+remoteip+":"+remoteport+", binded with "+localip+":"+localport);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int readcount = 0;
|
||||||
|
boolean need_continue = true;
|
||||||
|
while(need_continue) {
|
||||||
|
if (_socket==null) break;
|
||||||
|
if (_socket.isClosed()) break;
|
||||||
|
if (_socket.isInputShutdown()) break;
|
||||||
|
ByteBuffer buf = ByteBuffer.allocate(0);
|
||||||
|
do {
|
||||||
|
readcount = -1;
|
||||||
|
byte[] bb = new byte[1024];
|
||||||
|
try {
|
||||||
|
readcount = sock_is.read(bb);
|
||||||
|
|
||||||
|
if (readcount>0) {
|
||||||
|
if (readcount>buf.capacity()) {
|
||||||
|
ByteBuffer newbuf = ByteBuffer.allocate(buf.capacity()+readcount);
|
||||||
|
if (buf.capacity()>0) newbuf.put(buf);
|
||||||
|
newbuf.put(bb,0,readcount);
|
||||||
|
buf = newbuf;
|
||||||
|
raise_log_event("Updating ByteBuffer with "+readcount+" bytes, now capacity="+buf.capacity()+", position="+buf.position()+", limit="+buf.limit());
|
||||||
|
}
|
||||||
|
|
||||||
|
packetreceived = packetreceived < Integer.MAX_VALUE ? packetreceived+1 : 0;
|
||||||
|
totalreceived = ((Long.MAX_VALUE - totalreceived) > readcount) ? (totalreceived+readcount) : readcount;
|
||||||
|
raise_txrxstatus_event();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_event("InputStream read failed, exception="+e.getMessage());
|
||||||
|
need_continue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while(readcount!=-1);
|
||||||
|
|
||||||
|
if (buf.capacity()>0) {
|
||||||
|
raise_log_event("Final ByteBuffer got capacity="+buf.capacity()+", position="+buf.position()+", limit="+buf.limit());
|
||||||
|
byte[] bufdata = buf.array();
|
||||||
|
int bufdatalength = bufdata.length;
|
||||||
|
if (bufdatalength>4) {
|
||||||
|
int p_len = Byte.toUnsignedInt(bufdata[0]);
|
||||||
|
p_len |= Byte.toUnsignedInt(bufdata[1])<<8;
|
||||||
|
p_len |= Byte.toUnsignedInt(bufdata[2])<<16;
|
||||||
|
p_len |= Byte.toUnsignedInt(bufdata[3])<<24;
|
||||||
|
if (p_len==(bufdatalength-4)) {
|
||||||
|
byte[] newbuf = new byte[p_len];
|
||||||
|
System.arraycopy(bufdata, 4, newbuf, 0, p_len);
|
||||||
|
raise_newbytesdata_event(newbuf);
|
||||||
|
} else raise_log_event("Received ByteBuffer prefix length="+p_len+", packetlength="+(bufdatalength-4)+", not valid prefix");
|
||||||
|
} else raise_log_event("Received ByteBuffer length less than 4, not valid prefix");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_disconnected_event(remoteip, remoteport, (DateTime.getNow()-_now));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class socketrunnable implements Runnable{
|
||||||
|
private final Socket trysocket;
|
||||||
|
private final String remoteip;
|
||||||
|
private final int remoteport;
|
||||||
|
private final String localip;
|
||||||
|
private final int localport;
|
||||||
|
private final long _now;
|
||||||
|
private InputStream sock_is = null;
|
||||||
|
private boolean validrun = false;
|
||||||
|
|
||||||
|
|
||||||
|
public socketrunnable(Socket _sock) {
|
||||||
|
|
||||||
|
trysocket = _sock;
|
||||||
|
remoteip = trysocket.getInetAddress().getHostAddress();
|
||||||
|
remoteport = trysocket.getPort();
|
||||||
|
localip = trysocket.getLocalAddress().getHostAddress();
|
||||||
|
localport = trysocket.getLocalPort();
|
||||||
|
_now = DateTime.getNow();
|
||||||
|
try {
|
||||||
|
sock_is = trysocket.getInputStream();
|
||||||
|
|
||||||
|
validrun = true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_event("Unable to getInputStream from socket, exception="+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
|
||||||
|
validrun = false;
|
||||||
|
try {
|
||||||
|
_socket = trysocket;
|
||||||
|
sock_is = _socket.getInputStream();
|
||||||
|
validrun = true;
|
||||||
|
} catch (IOException e1) {
|
||||||
|
raise_log_event("getInputStream failed, exception="+e1.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validrun) {
|
||||||
|
raise_connected_event(remoteip, remoteport);
|
||||||
|
raise_log_event("socket connected to "+remoteip+":"+remoteport+", binded with "+localip+":"+localport);
|
||||||
|
|
||||||
|
int readcount = 0;
|
||||||
|
boolean need_continue = true;
|
||||||
|
while(need_continue) {
|
||||||
|
if (_socket==null) break;
|
||||||
|
if (_socket.isClosed()) break;
|
||||||
|
if (_socket.isInputShutdown()) break;
|
||||||
|
ByteBuffer buf = ByteBuffer.allocate(0);
|
||||||
|
do {
|
||||||
|
readcount = -1;
|
||||||
|
byte[] bb = new byte[1024];
|
||||||
|
try {
|
||||||
|
readcount = sock_is.read(bb);
|
||||||
|
if (readcount>0) {
|
||||||
|
if (readcount>buf.capacity()) {
|
||||||
|
ByteBuffer newbuf = ByteBuffer.allocate(buf.capacity()+readcount);
|
||||||
|
if (buf.capacity()>0) newbuf.put(buf);
|
||||||
|
newbuf.put(bb,0,readcount);
|
||||||
|
buf = newbuf;
|
||||||
|
raise_log_event("Updating ByteBuffer with "+readcount+" bytes, now capacity="+buf.capacity()+", position="+buf.position()+", limit="+buf.limit());
|
||||||
|
}
|
||||||
|
|
||||||
|
packetreceived = packetreceived < Integer.MAX_VALUE ? packetreceived+1 : 0;
|
||||||
|
totalreceived = ((Long.MAX_VALUE - totalreceived) > readcount) ? (totalreceived+readcount) : readcount;
|
||||||
|
raise_txrxstatus_event();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_event("InputStream read failed, exception="+e.getMessage());
|
||||||
|
need_continue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while(readcount!=-1);
|
||||||
|
|
||||||
|
if (buf.capacity()>0) {
|
||||||
|
raise_log_event("Final ByteBuffer got capacity="+buf.capacity()+", position="+buf.position()+", limit="+buf.limit());
|
||||||
|
byte[] result = new byte[buf.capacity()];
|
||||||
|
System.arraycopy(buf.array(), 0, result, 0, buf.capacity());
|
||||||
|
raise_newbytesdata_event(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_disconnected_event(remoteip, remoteport, (DateTime.getNow()-_now));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to Remote socket
|
||||||
|
* will raise event connected
|
||||||
|
* @param targetip : target remote ip
|
||||||
|
* @param targetport : target remote port
|
||||||
|
* @param timeout : how many miliseconds to wait for connection, put 0 for unlimited
|
||||||
|
* @param isprefix: if true, will connect in prefix mode
|
||||||
|
*/
|
||||||
|
public void ConnectTo(String targetip, int targetport, int timeout, boolean isprefix) {
|
||||||
|
totalsent = 0l;
|
||||||
|
totalreceived =0l;
|
||||||
|
packetsent = 0;
|
||||||
|
packetreceived = 0;
|
||||||
|
Socket trysocket = null;
|
||||||
|
if (targetip instanceof String && !targetip.isEmpty()) {
|
||||||
|
if (targetport>0 && targetport<65536) {
|
||||||
|
try {
|
||||||
|
trysocket = new Socket();
|
||||||
|
InetSocketAddress rem = new InetSocketAddress(targetip, targetport);
|
||||||
|
trysocket.connect(rem, timeout);
|
||||||
|
|
||||||
|
if (trysocket.isConnected()) {
|
||||||
|
this.isprefix = isprefix;
|
||||||
|
if (isprefix) {
|
||||||
|
BA.submitRunnable(new socketprefixrunnable(trysocket), null, 0);
|
||||||
|
} else {
|
||||||
|
BA.submitRunnable(new socketrunnable(trysocket), null, 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_event("ConnectTo failed, exception="+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_connected_event("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to Remote Socket, with local IP address bind
|
||||||
|
* will raise event connected
|
||||||
|
* @param targetip : target remote ip
|
||||||
|
* @param targetport : target remote port
|
||||||
|
* @param localip : local ip address to bind
|
||||||
|
* @param localport : local port to bind, put 0 to set random number
|
||||||
|
* @param timeout : how many milisecods to wait for connection
|
||||||
|
* @param isprefix : if true, will connect in prefix mode
|
||||||
|
*/
|
||||||
|
public void ConnectTo_withBind(String targetip, int targetport, String localip, int localport, int timeout, boolean isprefix) {
|
||||||
|
totalsent = 0l;
|
||||||
|
totalreceived =0l;
|
||||||
|
packetsent = 0;
|
||||||
|
packetreceived = 0;
|
||||||
|
Socket trysocket = null;
|
||||||
|
if (targetip instanceof String && !targetip.isEmpty()) {
|
||||||
|
if (targetport>0 && targetport<65536) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
trysocket = new Socket();
|
||||||
|
InetSocketAddress loc = new InetSocketAddress(localip, localport);
|
||||||
|
InetSocketAddress rem = new InetSocketAddress(targetip, targetport);
|
||||||
|
trysocket.bind(loc);
|
||||||
|
trysocket.connect(rem, timeout);
|
||||||
|
if (trysocket.isConnected()) {
|
||||||
|
this.isprefix = isprefix;
|
||||||
|
if (isprefix) {
|
||||||
|
BA.submitRunnable(new socketprefixrunnable(trysocket), null, 0);
|
||||||
|
} else {
|
||||||
|
BA.submitRunnable(new socketrunnable(trysocket), null, 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_event("ConnectTo_withBind failed, exception="+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_connected_event("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log_event(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_connected_event(String targetip, int targetport) {
|
||||||
|
if (need_connected_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_connected", false, new Object[] {targetip, targetport});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_disconnected_event(String targetip, int targetport, long duration) {
|
||||||
|
if (need_disconnected_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_disconnected", false, new Object[] {targetip, targetport, duration});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newbytesdata_event(byte[] value) {
|
||||||
|
if (need_newbytesdata_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_newbytesdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
private void raise_txrxstatus_event() {
|
||||||
|
if (need_txrxstatus_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_txrxstatus", false, new Object[] {packetsent, packetreceived, totalsent, totalreceived});
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/customsocket/SocketIOClientInterface.java
Normal file
48
src/customsocket/SocketIOClientInterface.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
|
||||||
|
public interface SocketIOClientInterface {
|
||||||
|
/**
|
||||||
|
* Send String to target with standard EVENT_MESSAGE command
|
||||||
|
* @param value : string to send
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean SendMessage(String value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect socket
|
||||||
|
*/
|
||||||
|
public void Disconnect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit an event to target socketio
|
||||||
|
* @param emitname : event name
|
||||||
|
* @param value : array of objects
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Emit(String emitname, Object... value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get SocketIO ID
|
||||||
|
* @return ID as string
|
||||||
|
*/
|
||||||
|
public String getID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Remote Target information
|
||||||
|
* @return String in format [ip]:[port]
|
||||||
|
*/
|
||||||
|
public String getRemote();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if connected
|
||||||
|
* @return true if connected
|
||||||
|
*/
|
||||||
|
public boolean IsConnected();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Local IP and Port
|
||||||
|
* @return in format [IP]:[Port] or N/A if Not connected
|
||||||
|
*/
|
||||||
|
public String getLocal() ;
|
||||||
|
}
|
||||||
428
src/customsocket/SocketIOClientWrapper.java
Normal file
428
src/customsocket/SocketIOClientWrapper.java
Normal file
@@ -0,0 +1,428 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
|
import io.socket.client.IO;
|
||||||
|
import io.socket.client.Socket;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@BA.ShortName("jSocketIOClient")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"connected(socketid as string, remote as string)",
|
||||||
|
"disconnected(socketid as string, remote as string, reason as string)",
|
||||||
|
"message(socketid as string, remote as string, value as string)"
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ini adalah Socket.io client yang inisiatif konek ke Socket.io server
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SocketIOClientWrapper implements SocketIOClientInterface {
|
||||||
|
|
||||||
|
private final Object Me = this;
|
||||||
|
|
||||||
|
private BA bax;
|
||||||
|
private Object caller;
|
||||||
|
private String event;
|
||||||
|
private boolean _inited = false;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_connected_event = false;
|
||||||
|
private boolean need_disconnected_event = false;
|
||||||
|
private boolean need_message_event = false;
|
||||||
|
private Socket _client;
|
||||||
|
|
||||||
|
private String _remote;
|
||||||
|
private String _id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Events for Socket.IO Client
|
||||||
|
* This is client side Socket that to be use to connect with SocketIO Server
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(final BA ba, final Object callerobject, final String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
caller = callerobject;
|
||||||
|
event = eventname;
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (caller != null) {
|
||||||
|
if (event instanceof String) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_connected_event = bax.subExists(event+"_connected");
|
||||||
|
need_disconnected_event = bax.subExists(event+"_disconnected");
|
||||||
|
need_message_event = bax.subExists(event+"_message");
|
||||||
|
_inited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
public void run() {
|
||||||
|
BA.Log("ShutdownHook for SocketIOClient");
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_id = "";
|
||||||
|
_remote = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Socket.IO Client is initialized
|
||||||
|
* @return true if inited
|
||||||
|
*/
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
return _inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printvaluedebug(String eventname, Object...value) {
|
||||||
|
if (value!=null) {
|
||||||
|
String valuetype = value.getClass().getTypeName();
|
||||||
|
int length = value.length;
|
||||||
|
String valuestring = Arrays.toString(value);
|
||||||
|
if (length>0) {
|
||||||
|
BA.Log("Event="+eventname+", type="+valuetype+", length="+length+", value="+valuestring);
|
||||||
|
} else {
|
||||||
|
BA.Log("Event="+eventname+" has no value");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
BA.Log("Event="+eventname+" value is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to SocketIO Server
|
||||||
|
* Will raise connected event or disconnected event
|
||||||
|
* @param uri : valid uri string, example ws://192.168.31.2:8080
|
||||||
|
* @param debugmode : if true, will dislay debug log
|
||||||
|
* @param events : array of string, containing event name that want to be intercepted as soon as possible
|
||||||
|
* @return true if socket can be created or false if parameters invalid
|
||||||
|
*/
|
||||||
|
public boolean ConnectTo(String uri, boolean debugmode, String...events ) {
|
||||||
|
|
||||||
|
if (!_id.isEmpty()) Disconnect(); //kalau ID sudah ada, berarti dah connected. Kalau gitu, disconnect dulu
|
||||||
|
|
||||||
|
if (uri instanceof String) {
|
||||||
|
if (!uri.isEmpty()) {
|
||||||
|
try {
|
||||||
|
Socket newsock = IO.socket(uri);
|
||||||
|
newsock.on(Socket.EVENT_CONNECT,(value)->{
|
||||||
|
// di sini, gak ada value, tandanya value.length = 0
|
||||||
|
//if (debugmode) printvaluedebug(Socket.EVENT_CONNECT, value);
|
||||||
|
|
||||||
|
_id = newsock.id();
|
||||||
|
_remote = uri;
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
_client.off();
|
||||||
|
_client.disconnect();
|
||||||
|
_client = null;
|
||||||
|
}
|
||||||
|
_client = newsock;
|
||||||
|
raise_connected(_id, _remote);
|
||||||
|
});
|
||||||
|
newsock.on(Socket.EVENT_CONNECT_ERROR, (value)->{
|
||||||
|
// di sini, ada 1 value, tandanya value.length = 1
|
||||||
|
// isinya keterangan kenapa gagal connect
|
||||||
|
//if (debugmode) printvaluedebug(Socket.EVENT_CONNECT_ERROR, value);
|
||||||
|
|
||||||
|
String _reason = "";
|
||||||
|
if (value!=null) {
|
||||||
|
|
||||||
|
if (value.length>0) {
|
||||||
|
_reason = String.valueOf(value[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
raise_disconnected(_id, _remote,_reason);
|
||||||
|
_id = "";
|
||||||
|
_remote = "";
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
_client.off();
|
||||||
|
_client.disconnect();
|
||||||
|
_client = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
newsock.on(Socket.EVENT_DISCONNECT, (value)->{
|
||||||
|
// di sini ada 1 value, tandanya value.length = 1
|
||||||
|
// isinya keterangan kenapa disconnect
|
||||||
|
// disconnect artinya sudah pernah connect, beda dengan connect_error
|
||||||
|
//if (debugmode) printvaluedebug(Socket.EVENT_DISCONNECT, value);
|
||||||
|
|
||||||
|
String _reason = "";
|
||||||
|
if (value!=null) {
|
||||||
|
|
||||||
|
if (value.length>0) {
|
||||||
|
_reason = String.valueOf(value[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
raise_disconnected(_id, _remote,_reason);
|
||||||
|
_id = "";
|
||||||
|
_remote = "";
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
_client.off();
|
||||||
|
_client.disconnect();
|
||||||
|
_client = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
newsock.on(Socket.EVENT_MESSAGE, (value)->{
|
||||||
|
if (debugmode) printvaluedebug(Socket.EVENT_MESSAGE, value);
|
||||||
|
|
||||||
|
if (value!=null) {
|
||||||
|
if (value.length>0) {
|
||||||
|
String msg = String.valueOf(value[0]);
|
||||||
|
raise_message(_id, _remote, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (events!=null) {
|
||||||
|
if (events.length>0) {
|
||||||
|
for(String ev : events) {
|
||||||
|
if (!ev.isEmpty()) {
|
||||||
|
final String eventtoraise = event+"_"+ev;
|
||||||
|
final boolean need_event = bax.subExists(eventtoraise);
|
||||||
|
if (need_event) BA.Log("Will raise event "+eventtoraise);
|
||||||
|
newsock.on(ev,(value)->{
|
||||||
|
if (debugmode) printvaluedebug(ev, value);
|
||||||
|
if (need_event) bax.raiseEventFromDifferentThread(Me, null, 0, eventtoraise, false, new Object[] {value});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
newsock.connect();
|
||||||
|
return true;
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
raise_log("ConnectTo failed, URISyntaxException for "+uri+", Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect Socket
|
||||||
|
*/
|
||||||
|
public void Disconnect() {
|
||||||
|
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
Remove_All_Events(); // remove semua event
|
||||||
|
_client.disconnect(); // disconnect
|
||||||
|
}
|
||||||
|
_client = null;
|
||||||
|
|
||||||
|
//TODO : konfirmasi di Log nanti, ini perlu di clear di Disconnect() atau di onDisconnect()
|
||||||
|
_remote = "";
|
||||||
|
_id = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all Socket Events
|
||||||
|
*/
|
||||||
|
public void Remove_All_Events() {
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
_client.off();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Check if Client is still connected
|
||||||
|
* @return true if connected
|
||||||
|
*/
|
||||||
|
public boolean IsConnected() {
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
return _client.connected();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add Custom Event to Socket
|
||||||
|
* If data arrived, will raise event_eventname(value as Object)
|
||||||
|
* @param eventname : eventname, lowercase characters and numbers only
|
||||||
|
* @param debugmode : if true, will give debug output
|
||||||
|
* @return true if event added
|
||||||
|
*/
|
||||||
|
public boolean Add_Event(final String eventname, boolean debugmode) {
|
||||||
|
if (is_correct_eventname(eventname)) {
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
if (_client.hasListeners(eventname)) {
|
||||||
|
_client.off(eventname);
|
||||||
|
raise_log("Add_Event with eventname = "+eventname+" already exist, removing the previous");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String eventtoraise = event+"_"+eventname;
|
||||||
|
final boolean need_event = bax.subExists(eventtoraise);
|
||||||
|
if (need_event && debugmode) BA.Log("Will raise "+eventtoraise);
|
||||||
|
|
||||||
|
_client.on(eventname, (value)->{
|
||||||
|
if (debugmode) printvaluedebug(eventname, value);
|
||||||
|
|
||||||
|
if (need_event) bax.raiseEventFromDifferentThread(Me, null, 0, eventtoraise, false, new Object[] {value});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else raise_log("Add_Event failed, Socket not connected");
|
||||||
|
} else raise_log("Add_Event failed, eventname is invalid");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove specified eventname from socket
|
||||||
|
* @param eventname : eventname to remove, lowercase characters and numbers only
|
||||||
|
* @return true if removed
|
||||||
|
*/
|
||||||
|
public boolean Remove_Event(String eventname) {
|
||||||
|
if (is_correct_eventname(eventname)) {
|
||||||
|
if (_client instanceof Socket) {
|
||||||
|
if (_client.hasListeners(eventname)) {
|
||||||
|
_client.off(eventname);
|
||||||
|
return true;
|
||||||
|
} else raise_log("Remove_Event failed, Socket dont have event : "+eventname);
|
||||||
|
} else raise_log("Remove_Event failed, Socket not connected");
|
||||||
|
} else raise_log("Remove_Event failed, eventname is invalid");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit JsonObject to target socket
|
||||||
|
* @param emitname : event name
|
||||||
|
* @param value : JsonObject
|
||||||
|
* @return true if value can be send
|
||||||
|
*/
|
||||||
|
public boolean Emit_JsonObject(String emitname, JsonObject value) {
|
||||||
|
if (emitname instanceof String) {
|
||||||
|
if (!emitname.isEmpty()) {
|
||||||
|
if (value instanceof JsonObject) {
|
||||||
|
if (value.HasSomeValue()) {
|
||||||
|
_client.emit(emitname, value.getObject());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit JsonArray to target socket
|
||||||
|
* @param emitname : event name
|
||||||
|
* @param value : JsonArray
|
||||||
|
* @return true if value can be send
|
||||||
|
*/
|
||||||
|
public boolean Emit_JsonArray(String emitname, JsonArray value) {
|
||||||
|
if (emitname instanceof String) {
|
||||||
|
if (!emitname.isEmpty()) {
|
||||||
|
if (value instanceof JsonArray) {
|
||||||
|
if (value.HasSomeValue()) {
|
||||||
|
_client.emit(emitname, value.getObject().toList());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send simple String to event 'message'
|
||||||
|
* @param value : String to send
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean SendMessage(String value) {
|
||||||
|
if (IsConnected()) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
_client.emit(io.socket.engineio.client.Socket.EVENT_MESSAGE, value);
|
||||||
|
return true;
|
||||||
|
} else raise_log("SendMessage failed, value is zero length");
|
||||||
|
} else raise_log("SendMessage failed, value is not String");
|
||||||
|
} else raise_log("SendMessage failed, Socket not connected");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean is_correct_eventname(String value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
return Pattern.matches("^[a-z0-9]+$", value);// hanya lowercase dan angka
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get SessionID from socket
|
||||||
|
* @return empty string if socket not connected
|
||||||
|
*/
|
||||||
|
public String getID() {
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get RemoteSocket info, in form of [IP]:[Port]
|
||||||
|
* @return empty string if socket not connected
|
||||||
|
*/
|
||||||
|
public String getRemote() {
|
||||||
|
return _remote;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////// Events ///////////////
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_connected(String id, String remote){
|
||||||
|
if (need_connected_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_connected", false, new Object[] {id, remote});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_disconnected(String id, String remote, String reason) {
|
||||||
|
if (need_disconnected_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_disconnected", false, new Object[] {id,remote, reason});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_message(String id, String remote, String value) {
|
||||||
|
if (need_message_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_message", false, new Object[] {id,remote, value});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean Emit(String emitname, Object... value) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLocal() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
726
src/customsocket/SocketIOServerWrapper.java
Normal file
726
src/customsocket/SocketIOServerWrapper.java
Normal file
@@ -0,0 +1,726 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.validator.routines.InetAddressValidator;
|
||||||
|
|
||||||
|
import com.corundumstudio.socketio.AckRequest;
|
||||||
|
import com.corundumstudio.socketio.Configuration;
|
||||||
|
|
||||||
|
import com.corundumstudio.socketio.SocketIOClient;
|
||||||
|
import com.corundumstudio.socketio.SocketIOServer;
|
||||||
|
import com.corundumstudio.socketio.listener.ConnectListener;
|
||||||
|
import com.corundumstudio.socketio.listener.DataListener;
|
||||||
|
import com.corundumstudio.socketio.listener.DisconnectListener;
|
||||||
|
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
import jGPIO.mycodes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@BA.ShortName("jSocketIOServer")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"clientconnected(sock as NettySocketWrapper)",
|
||||||
|
"clientdisconnected(sock as NettySocketWrapper)",
|
||||||
|
"clientmessage(sock as NettySocketWrapper, value as string)"
|
||||||
|
})
|
||||||
|
//@BA.DependsOn(values= {
|
||||||
|
// "netty-socketio-1.7.23",
|
||||||
|
// "slf4j-api-1.7.33",
|
||||||
|
// "netty-transport-4.1.80.Final",
|
||||||
|
// "netty-common-4.1.80.Final",
|
||||||
|
// "netty-handler-4.1.80.Final",
|
||||||
|
// "netty-codec-4.1.80.Final",
|
||||||
|
// "netty-buffer-4.1.80.Final",
|
||||||
|
// "netty-codec-http-4.1.80.Final",
|
||||||
|
// "netty-resolver-4.1.80.Final",
|
||||||
|
// "netty-transport-classes-epoll-4.1.80.Final",
|
||||||
|
// "netty-transport-native-epoll-4.1.80.Final",
|
||||||
|
// "netty-transport-native-unix-common-4.1.80.Final",
|
||||||
|
// "jackson-core-2.13.4",
|
||||||
|
// "jackson-annotations-2.14.0-rc1",
|
||||||
|
// "jackson-databind-2.14.0-rc1"
|
||||||
|
//})
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Socket.io Server for JAVA
|
||||||
|
* Compatible with Socket.io V2, not with V3/V4
|
||||||
|
* Latest Socket.io from NPM is 2.4.0
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SocketIOServerWrapper {
|
||||||
|
private BA bax;
|
||||||
|
private Object caller;
|
||||||
|
private String event;
|
||||||
|
private final Object Me = this;
|
||||||
|
private boolean _inited = false;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_clientconnected_event = false;
|
||||||
|
private boolean need_clientdisconnected_event = false;
|
||||||
|
private boolean need_clientmessage_event = false;
|
||||||
|
|
||||||
|
|
||||||
|
private SocketIOServer _server;
|
||||||
|
|
||||||
|
// source : https://github.com/socketio/engine.io-client-java/blob/master/src/main/java/io/socket/engineio/client/Socket.java
|
||||||
|
private final String EVENT_MESSAGE = "message";
|
||||||
|
private final String EVENT_ERROR = "error";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize SocketIO Server
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object callerobject, String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
caller = callerobject;
|
||||||
|
event = eventname;
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (caller != null) {
|
||||||
|
if (event instanceof String) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_clientconnected_event = bax.subExists(event+"_clientconnected");
|
||||||
|
need_clientdisconnected_event = bax.subExists(event+"_clientdisconnected");
|
||||||
|
need_clientmessage_event = bax.subExists(event+"_clientmessage");
|
||||||
|
_inited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
public void run() {
|
||||||
|
BA.Log("ShutdownHook for jSocketIOServer is running");
|
||||||
|
StopListen();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if SocketIO Server is initialized or not
|
||||||
|
* @return true if initalized
|
||||||
|
*/
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
return _inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ConnectListener callback
|
||||||
|
*/
|
||||||
|
private ConnectListener cl = new ConnectListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnect(SocketIOClient client) {
|
||||||
|
NettySocketWrapper _netty = new NettySocketWrapper(client);
|
||||||
|
|
||||||
|
raise_clientconnected(_netty);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private DisconnectListener dl = new DisconnectListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisconnect(SocketIOClient client) {
|
||||||
|
NettySocketWrapper _netty = new NettySocketWrapper(client);
|
||||||
|
raise_clientdisconnected(_netty);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private DataListener<String> messagelistener = new DataListener<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onData(SocketIOClient client, String valuestring, AckRequest arg2) throws Exception {
|
||||||
|
NettySocketWrapper _netty = new NettySocketWrapper(client);
|
||||||
|
raise_clientmessage(_netty, valuestring);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private DataListener<String> errorlistener = new DataListener<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onData(SocketIOClient client, String reasonstring, AckRequest arg2) throws Exception {
|
||||||
|
NettySocketWrapper _netty = new NettySocketWrapper(client);
|
||||||
|
|
||||||
|
raise_log("Error happened on "+_netty.CompleteDescription()+", Reason = "+reasonstring);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start Listening at specified port
|
||||||
|
* @param hostip : Host IP, set valid IP address if want to listen at specific network interface
|
||||||
|
* @param Port : Port number
|
||||||
|
* @return true if server can listening
|
||||||
|
*/
|
||||||
|
public boolean StartListen(String hostip, int Port) {
|
||||||
|
|
||||||
|
if (ServerReady()) {
|
||||||
|
raise_log("Closing previous SocketIOServer instance");
|
||||||
|
StopListen();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Port < 1 || Port > 65535) {
|
||||||
|
raise_log("StartListen failed, invalid Port="+Port);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mycodes.ValidString(hostip)==false) {
|
||||||
|
raise_log("StartListen failed, hostip is not valid string");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
InetAddressValidator validator = InetAddressValidator.getInstance();
|
||||||
|
if (validator.isValid(hostip)==false) {
|
||||||
|
raise_log("StartListen failed, hostip is not valid ip format");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InetAddress ip;
|
||||||
|
try {
|
||||||
|
ip = InetAddress.getByName(hostip);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
raise_log("StartListen failed, UnknownHostException="+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Configuration _config = new Configuration();
|
||||||
|
|
||||||
|
_config.setPort(Port);
|
||||||
|
// example : https://levelup.gitconnected.com/comparing-java-websockets-jetty-vs-netty-ba128ddca313
|
||||||
|
|
||||||
|
if (hostip!=null && hostip.length()>0) {
|
||||||
|
if (ip!=null) {
|
||||||
|
_config.setHostname(ip.getHostAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketIOServer newserver = new SocketIOServer(_config);
|
||||||
|
|
||||||
|
newserver.addConnectListener(cl);
|
||||||
|
|
||||||
|
|
||||||
|
newserver.addDisconnectListener(dl);
|
||||||
|
|
||||||
|
newserver.addEventListener(EVENT_MESSAGE, String.class, messagelistener);
|
||||||
|
|
||||||
|
newserver.addEventListener(EVENT_ERROR, String.class, errorlistener);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_server = newserver;
|
||||||
|
_server.start();
|
||||||
|
|
||||||
|
raise_log("jSocketIOServer StartListen at Port = "+Port);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop SocketIO Server Listening
|
||||||
|
* @return true if can be stopped
|
||||||
|
*/
|
||||||
|
public void StopListen() {
|
||||||
|
raise_log("jSocketIOServer StopListening");
|
||||||
|
Disconnect_Clients();
|
||||||
|
if (_server!=null) {
|
||||||
|
_server.stop();
|
||||||
|
_server = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Server Port
|
||||||
|
* @return -1 if server is invalid, or configuration is invalid
|
||||||
|
*/
|
||||||
|
public int getServerPort() {
|
||||||
|
if (ServerReady()) {
|
||||||
|
Configuration _config = _server.getConfiguration();
|
||||||
|
if (_config instanceof Configuration) {
|
||||||
|
return _config.getPort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Server Host Name
|
||||||
|
* @return null if invalid, or host name if valid
|
||||||
|
*/
|
||||||
|
public String getHostName() {
|
||||||
|
if (ServerReady()) {
|
||||||
|
Configuration _config = _server.getConfiguration();
|
||||||
|
if (_config instanceof Configuration) {
|
||||||
|
return _config.getHostname();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Server ready or not
|
||||||
|
* @return true if server ready
|
||||||
|
*/
|
||||||
|
public boolean ServerReady() {
|
||||||
|
if (_server != null && _server instanceof SocketIOServer) {
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Namespace
|
||||||
|
* @param namespace : value in string
|
||||||
|
* @return true if namespace can be added
|
||||||
|
*/
|
||||||
|
public boolean Add_Namespace(String namespace) {
|
||||||
|
if (ServerReady() && Valid_String(namespace)) {
|
||||||
|
_server.addNamespace(namespace);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a Namespace
|
||||||
|
* @param namespace : value in string
|
||||||
|
* @return true if namespace can be removed
|
||||||
|
*/
|
||||||
|
public boolean Remove_Namespace(String namespace) {
|
||||||
|
if (ServerReady() && Valid_String(namespace)) {
|
||||||
|
_server.removeNamespace(namespace);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Server Namespaces
|
||||||
|
* @return List of String , containing namespace
|
||||||
|
*/
|
||||||
|
public List getServerNameSpaces() {
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
if (ServerReady()) {
|
||||||
|
_server.getAllNamespaces().forEach(xx -> result.Add(xx.getName()));
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of NettySocketWrapper
|
||||||
|
* @return List of String, containing connected client's ID
|
||||||
|
*/
|
||||||
|
public List getConnectedClientsID() {
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
|
||||||
|
if (ServerReady()) {
|
||||||
|
_server.getAllClients().forEach(xx -> result.Add(xx.getSessionId().toString()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Server has client connected with specific ID
|
||||||
|
* @param ID ID to check
|
||||||
|
* @return true if has client with that ID
|
||||||
|
*/
|
||||||
|
public boolean HasClientWithID(String ID) {
|
||||||
|
if (ServerReady() && Valid_String(ID)) {
|
||||||
|
SocketIOClient result =_server.getAllClients().stream().filter(xx -> xx.getSessionId().toString()==ID).findFirst().orElse(null);
|
||||||
|
return (result!=null);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Client with specific ID
|
||||||
|
* @param ID ID string
|
||||||
|
* @return null if not found
|
||||||
|
*/
|
||||||
|
public NettySocketWrapper GetClient(String ID) {
|
||||||
|
if (ServerReady() && Valid_String(ID)) {
|
||||||
|
SocketIOClient cl = _server.getClient(UUID.fromString(ID));
|
||||||
|
if (cl != null) {
|
||||||
|
return new NettySocketWrapper(cl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a String to all clients connected
|
||||||
|
* @param emitname event name of the broadcast
|
||||||
|
* @param value data to send
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Broadcast_String(String emitname, String value) {
|
||||||
|
if (ServerReady() && Valid_String(emitname) && Valid_String(value)) {
|
||||||
|
_server.getAllClients().forEach(cl -> cl.sendEvent(emitname, value));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a Map to all clients connected
|
||||||
|
* @param emitname event name of the broadcast
|
||||||
|
* @param value data to send
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Broadcast_Map(String emitname, Map value) {
|
||||||
|
if (ServerReady() && Valid_String(emitname) && Valid_Map(value)) {
|
||||||
|
_server.getAllClients().forEach(cl -> cl.sendEvent(emitname, value.getObject()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a List to all clients connected
|
||||||
|
* @param emitname event name of the broadcast
|
||||||
|
* @param value data to send
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Broadcast_List(String emitname, List value) {
|
||||||
|
if (ServerReady() && Valid_String(emitname) && Valid_List(value)) {
|
||||||
|
_server.getAllClients().forEach(cl -> cl.sendEvent(emitname, value.getObject()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an Array to all clients connected
|
||||||
|
* @param emitname event name of the broadcast
|
||||||
|
* @param value data to send
|
||||||
|
* @return true if can be send
|
||||||
|
*/
|
||||||
|
public boolean Broadcast_Array(String emitname, Object[] value) {
|
||||||
|
if (ServerReady() && Valid_String(emitname) && Valid_Array(value)) {
|
||||||
|
_server.getAllClients().forEach(cl -> cl.sendEvent(emitname, value));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Add Custom Event
|
||||||
|
* <br/>will raise event <b>[event at initalize]_[eventname](netty as NettySocketWrapper, value as Object)</b>
|
||||||
|
* <br/>Value : kalau dari JSON object, value akan dalam bentuk <b>Map</b> --> test pakai <b>Is</b> di B4X
|
||||||
|
* <br/>value lain , value akan dalam bentuk <b>String</b> --> test pakai <b>Is</b> di B4X
|
||||||
|
* <br/>example : at Initialization , event = testserver.
|
||||||
|
* <br/>Add_Event(devicehealth)
|
||||||
|
* <br/>Later will raise event <b>testserver_devicehealth(netty as NettySocketWrapper, value as Object, ack as AckRequestWrapper)</b>
|
||||||
|
* @param eventname eventname
|
||||||
|
* @param printdebug if true , then will print incoming data from this event, for examination
|
||||||
|
* @return true if Custom Event can be added
|
||||||
|
*/
|
||||||
|
public boolean Add_Event(final String eventname, boolean printdebug) {
|
||||||
|
if (ServerReady()) {
|
||||||
|
final String eventtoraise = event+"_"+eventname;
|
||||||
|
final boolean need_custom_event = bax.subExists(eventtoraise);
|
||||||
|
if (printdebug) {
|
||||||
|
if (need_custom_event) {
|
||||||
|
printlog("will raise ",eventtoraise);
|
||||||
|
} else {
|
||||||
|
printlog("Sub ",eventtoraise," is not exists, event will not raised");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Remove_Event(eventname); // remove dulu yang sebelumnya, penting ini !
|
||||||
|
|
||||||
|
_server.addEventListener(eventname, Object.class, new DataListener<Object>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onData(SocketIOClient client, Object value, AckRequest ackSender) throws Exception {
|
||||||
|
NettySocketWrapper _netty = new NettySocketWrapper(client);
|
||||||
|
AckRequestWrapper ack = new AckRequestWrapper(ackSender);
|
||||||
|
|
||||||
|
if (value!=null) {
|
||||||
|
String valuetype = value.getClass().getTypeName();
|
||||||
|
if (printdebug) {
|
||||||
|
printlog("Got event ",eventname,", valuetype =",valuetype,", value =",value.toString());
|
||||||
|
}
|
||||||
|
if (valuetype.contains("LinkedHashMap")) {
|
||||||
|
// untuk javascript tipe JSON Object
|
||||||
|
if (need_custom_event) {
|
||||||
|
LinkedHashMap<?,?> lhm = (LinkedHashMap<?, ?>) value;
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, eventtoraise, false, new Object[] {_netty,LinkedHashMap_to_B4XMap(lhm).getObject(), ack });
|
||||||
|
if (ack.isAckRequested()) waitfor_ack(eventname,ack, 5000, printdebug);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (valuetype.contains("ArrayList")) {
|
||||||
|
// untuk javascript tipe array
|
||||||
|
if (need_custom_event) {
|
||||||
|
ArrayList<?> arr = (ArrayList<?>) value;
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, eventtoraise, false, new Object[] {_netty, ArrayList_to_B4XList(arr).getObject(), ack});
|
||||||
|
if (ack.isAckRequested()) waitfor_ack(eventname, ack, 5000, printdebug);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// java.lang.String
|
||||||
|
// java.lang.Integer
|
||||||
|
// java.lang.Boolean
|
||||||
|
// java.lang.Double
|
||||||
|
// javascript Infinity dan NaN --> null
|
||||||
|
if (need_custom_event) {
|
||||||
|
if (printdebug) printlog("Raising ",eventtoraise," with "+valuetype+" value and waiting for returnvalue");
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, eventtoraise, false, new Object[] {_netty,value, ack });
|
||||||
|
if (ack.isAckRequested()) waitfor_ack(eventname,ack, 5000, printdebug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// value = null
|
||||||
|
if (printdebug) printlog("Got event ", eventname, ", value = null");
|
||||||
|
if (need_custom_event) {
|
||||||
|
if (printdebug) printlog("Raising ",eventtoraise," with null value and waiting for returnvalue");
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, eventtoraise, false, new Object[] {_netty, null, ack});
|
||||||
|
if (ack.isAckRequested()) waitfor_ack(eventname,ack,5000, printdebug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printlog(String... str) {
|
||||||
|
if (str!=null) {
|
||||||
|
if (str.length==1) {
|
||||||
|
BA.Log(str[0]);
|
||||||
|
} else if (str.length>1) {
|
||||||
|
StringBuilder strbuild = new StringBuilder();
|
||||||
|
|
||||||
|
for(String xx : str) strbuild.append(xx);
|
||||||
|
BA.Log(strbuild.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitfor_ack(String functionname, AckRequestWrapper ack, long timeout, boolean printdebug) {
|
||||||
|
if (ack != null) {
|
||||||
|
synchronized(ack) {
|
||||||
|
try {
|
||||||
|
ack.wait(timeout);
|
||||||
|
if (printdebug) printlog("Function ", functionname," ack.wait finished");
|
||||||
|
} catch(IllegalMonitorStateException | InterruptedException | IllegalArgumentException e) {
|
||||||
|
printlog("Function ", functionname," ack.wait exception = ", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map LinkedHashMap_to_B4XMap(LinkedHashMap<?,?> value) {
|
||||||
|
Map result = new Map();
|
||||||
|
result.Initialize();
|
||||||
|
|
||||||
|
// MyMap mmresult = new MyMap();
|
||||||
|
// if (value!=null) {
|
||||||
|
// if (value.size()>0) {
|
||||||
|
// mmresult.putAll(value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// result.setObject(mmresult);
|
||||||
|
if (value!=null) {
|
||||||
|
if (value.size()>0) {
|
||||||
|
value.forEach((kk,vv)->{
|
||||||
|
if (vv!=null) {
|
||||||
|
String vvtype = vv.getClass().getTypeName();
|
||||||
|
if (vvtype.contains("LinkedHashMap")) {
|
||||||
|
// map di dalam map
|
||||||
|
result.Put(kk, LinkedHashMap_to_B4XMap((LinkedHashMap<?, ?>) vv).getObject());
|
||||||
|
} else if (vvtype.contains("ArrayList")) {
|
||||||
|
// array di dalam map
|
||||||
|
result.Put(kk, ArrayList_to_B4XList((ArrayList<?>) vv).getObject());
|
||||||
|
} else {
|
||||||
|
// tipe biasa, masukin langsung
|
||||||
|
result.Put(kk, vv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List ArrayList_to_B4XList(ArrayList<?> value) {
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
if (value != null) {
|
||||||
|
if (value.size()>0) {
|
||||||
|
value.forEach(xx -> {
|
||||||
|
if (xx != null) {
|
||||||
|
String xxtype = xx.getClass().getTypeName();
|
||||||
|
if (xxtype.contains("LinkedHashMap")) {
|
||||||
|
// array of maps
|
||||||
|
result.Add(LinkedHashMap_to_B4XMap((LinkedHashMap<?, ?>) xx).getObject());
|
||||||
|
} else if (xxtype.contains("ArrayList")) {
|
||||||
|
// array of array, kayaknya gak pernah ada
|
||||||
|
result.Add(ArrayList_to_B4XList((ArrayList<?>) xx).getObject());
|
||||||
|
} else {
|
||||||
|
// tipe biasa, masukin langsung
|
||||||
|
result.Add(xx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove Custom Event
|
||||||
|
* @param eventname : event name yang mau diremove
|
||||||
|
* @return true kalau bisa di remove
|
||||||
|
*/
|
||||||
|
public boolean Remove_Event(String eventname) {
|
||||||
|
if (ServerReady() && Valid_String(eventname)) {
|
||||||
|
_server.removeAllListeners(eventname);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a string is valid and have content
|
||||||
|
* @param xx String to check
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
|
private boolean Valid_String(String xx) {
|
||||||
|
if (xx != null) {
|
||||||
|
if (xx instanceof String) {
|
||||||
|
return xx.length()>0 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Map is valid and has content
|
||||||
|
* @param xx Map to check
|
||||||
|
* @return true if valid and have content
|
||||||
|
*/
|
||||||
|
private boolean Valid_Map(Map xx) {
|
||||||
|
if (xx != null) {
|
||||||
|
if (xx instanceof Map) {
|
||||||
|
if (xx.IsInitialized()) {
|
||||||
|
if (xx.getSize()>0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a LIst is valid and has content
|
||||||
|
* @param xx List to check
|
||||||
|
* @return true if valid and have content
|
||||||
|
*/
|
||||||
|
private boolean Valid_List(List xx) {
|
||||||
|
if (xx != null) {
|
||||||
|
if (xx instanceof List) {
|
||||||
|
if (xx.IsInitialized()) {
|
||||||
|
if (xx.getSize()>0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an array is not null and have length
|
||||||
|
* @param xx Array to check
|
||||||
|
* @return true if not null and have length
|
||||||
|
*/
|
||||||
|
private boolean Valid_Array(Object[] xx) {
|
||||||
|
if (xx != null) {
|
||||||
|
if (xx.length>0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////// Private methods //////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect all SocketIOClient in this SocketIOServer
|
||||||
|
*/
|
||||||
|
private void Disconnect_Clients() {
|
||||||
|
if (_server!=null) {
|
||||||
|
_server.getAllClients().forEach(xx -> xx.disconnect());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////// Event ////////////////////
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_clientdisconnected(NettySocketWrapper netty) {
|
||||||
|
if (need_clientdisconnected_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_clientdisconnected", false, new Object[] {netty});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_clientconnected(NettySocketWrapper netty) {
|
||||||
|
if (need_clientconnected_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_clientconnected", false, new Object[] {netty});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void raise_clientmessage(NettySocketWrapper netty, String value) {
|
||||||
|
if (need_clientmessage_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_clientmessage", false, new Object[] {netty, value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
817
src/customsocket/TCPSocket.java
Normal file
817
src/customsocket/TCPSocket.java
Normal file
@@ -0,0 +1,817 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.Bit;
|
||||||
|
import anywheresoftware.b4a.keywords.DateTime;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map.MyMap;
|
||||||
|
import anywheresoftware.b4a.randomaccessfile.B4XSerializator;
|
||||||
|
import jGPIO.mycodes;
|
||||||
|
|
||||||
|
@BA.ShortName("TCPSocket")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"connected(targetip as string, targetport as int)",
|
||||||
|
"disconnected(targetip as string, targetport as int, duration as long)",
|
||||||
|
"newmapdata(value as Map)",
|
||||||
|
"newbytesdata(value() as byte)",
|
||||||
|
"newstringdata(value as String)",
|
||||||
|
"newintsdata(value() as int)",
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
//@BA.DependsOn(values= {"jRandomAccessFile.jar"})
|
||||||
|
|
||||||
|
public class TCPSocket {
|
||||||
|
private BA bax;
|
||||||
|
private Object caller;
|
||||||
|
private Object Me = this;
|
||||||
|
private String event;
|
||||||
|
private TcpSocketJavaEvent _javaevent = null;
|
||||||
|
|
||||||
|
private boolean _inited = false;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_connected_event = false;
|
||||||
|
private boolean need_disconnected_event = false;
|
||||||
|
private boolean need_newmapdata_event = false;
|
||||||
|
private boolean need_newbytesdata_event = false;
|
||||||
|
private boolean need_newstringdata_event = false;
|
||||||
|
private boolean need_newintsdata_event = false;
|
||||||
|
|
||||||
|
|
||||||
|
private Socket _socket;
|
||||||
|
private ObjectOutputStream _output;
|
||||||
|
private ObjectInputStream _input;
|
||||||
|
private B4XSerializator _converter;
|
||||||
|
|
||||||
|
private String _remoteip = "";
|
||||||
|
private int _remoteport = 0;
|
||||||
|
private String _localip = "";
|
||||||
|
private int _localport = 0;
|
||||||
|
|
||||||
|
private long _connected_tick = 0;
|
||||||
|
|
||||||
|
private int _txokcount = 0;
|
||||||
|
private long _txbytescount = 0;
|
||||||
|
private int _rxokcount = 0;
|
||||||
|
private long _rxbytescount = 0;
|
||||||
|
|
||||||
|
private Timer onesecondtimer;
|
||||||
|
private int _rxtimercount;
|
||||||
|
private int _txtimercount;
|
||||||
|
|
||||||
|
private String _mapkey = "";
|
||||||
|
|
||||||
|
public TCPSocket() {
|
||||||
|
// nothing to do here
|
||||||
|
_converter = new B4XSerializator();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public TCPSocket(Socket newsocket, Object event) {
|
||||||
|
this();
|
||||||
|
_javaevent = (TcpSocketJavaEvent) event;
|
||||||
|
Thread tx = new Thread(new tcpsocketrun(newsocket));
|
||||||
|
tx.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get / Set Identifier Key
|
||||||
|
* by default, identifier key is RemoteIPAddress:RemotePort
|
||||||
|
* if identifier key is empty, then TCPSocket has never been connected yet
|
||||||
|
* User may change IdentifierKey to any String value , and used it for matching Map
|
||||||
|
* @return key as string
|
||||||
|
*/
|
||||||
|
public String getIdentifierKey() {
|
||||||
|
return _mapkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get / Set Identifier Key
|
||||||
|
* by default, identifier key is RemoteIPAddress:RemotePort
|
||||||
|
* if identifier key is empty, then TCPSocket has never been connected yet
|
||||||
|
* User may change IdentifierKey to any String value , and used it for matching Map
|
||||||
|
* @param value as string
|
||||||
|
*/
|
||||||
|
public void setIdentifierKey(String value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
if (_javaevent instanceof TcpSocketJavaEvent) {
|
||||||
|
_javaevent.renameidentifier(_mapkey, value);
|
||||||
|
}
|
||||||
|
_mapkey = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize TCPSocket events
|
||||||
|
* Necessary to call this, so event log, connected, disconnected will be called
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param eventname : eventname
|
||||||
|
*/
|
||||||
|
public void InitializeEvents(BA ba, final Object callerobject, final String eventname) {
|
||||||
|
|
||||||
|
bax = ba;
|
||||||
|
caller = callerobject;
|
||||||
|
event = eventname;
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (caller != null) {
|
||||||
|
if (event instanceof String) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_connected_event = bax.subExists(event+"_connected");
|
||||||
|
need_disconnected_event = bax.subExists(event+"_disconnected");
|
||||||
|
need_newmapdata_event = bax.subExists(event+"_newmapdata");
|
||||||
|
need_newbytesdata_event = bax.subExists(event+"_newbytesdata");
|
||||||
|
need_newstringdata_event = bax.subExists(event+"_newstringdata");
|
||||||
|
need_newintsdata_event = bax.subExists(event+"_newintsdata");
|
||||||
|
|
||||||
|
_inited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Events already Initialized for this TCPSocket
|
||||||
|
* @return true if already initialized
|
||||||
|
*/
|
||||||
|
public boolean EventsInitialized() {
|
||||||
|
return _inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if TCPSocket is connected
|
||||||
|
* @return true if connected
|
||||||
|
*/
|
||||||
|
public boolean IsConnected() {
|
||||||
|
if (_socket instanceof Socket) {
|
||||||
|
if (!_socket.isClosed()) {
|
||||||
|
return _socket.isConnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to Target Ip and Target Port
|
||||||
|
* Will raise Connected(remoteip as string, remoteport as int) event
|
||||||
|
* if TCPSocket connected, remoteip has ip address, and remoteport != 0;
|
||||||
|
* @param targetip : target ip
|
||||||
|
* @param port : target port
|
||||||
|
*/
|
||||||
|
public void ConnectTo(String targetip, int port) {
|
||||||
|
if (targetip instanceof String) {
|
||||||
|
if (!targetip.isEmpty()) {
|
||||||
|
if (port>0) {
|
||||||
|
try {
|
||||||
|
Socket trysock = new Socket();
|
||||||
|
SocketAddress rem = new InetSocketAddress(targetip, port);
|
||||||
|
trysock.connect(rem);
|
||||||
|
Thread tx = new Thread(new tcpsocketrun(trysock));
|
||||||
|
tx.start();
|
||||||
|
return;
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
raise_log_error("UnknownHostException on ConnectTo ["+targetip+":"+port+"]",e);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on ConnectTo ["+targetip+"]:["+port+"]",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_connected("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to Target IP and Target Port , and specifically bind to Local IP address
|
||||||
|
* Will raise Connected(remoteip as string, remoteport as int) event
|
||||||
|
* if TCPSocket connected, remoteip has ip address, and remoteport != 0;
|
||||||
|
* @param targetip remote IP address
|
||||||
|
* @param port remote port
|
||||||
|
* @param localip local IP address
|
||||||
|
*/
|
||||||
|
public void ConnectTo_withBind(String targetip, int port, String localip) {
|
||||||
|
if (targetip instanceof String && !targetip.isEmpty()) {
|
||||||
|
if (port>0) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
SocketAddress loc = new InetSocketAddress(localip, port);
|
||||||
|
SocketAddress rem = new InetSocketAddress (targetip,port);
|
||||||
|
Socket trysocket = new Socket();
|
||||||
|
trysocket.bind(loc);
|
||||||
|
trysocket.connect(rem);
|
||||||
|
Thread tx = new Thread(new tcpsocketrun(trysocket));
|
||||||
|
tx.start();
|
||||||
|
return;
|
||||||
|
} catch(IOException e) {
|
||||||
|
raise_log_error("IOException on ConnectTO ["+targetip+"]:]"+port+"] Bind="+localip,e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_connected("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class tcpsocketrun implements Runnable{
|
||||||
|
private boolean validrun = false;
|
||||||
|
private ByteBuffer bytebuf ;
|
||||||
|
public tcpsocketrun(Socket xx) {
|
||||||
|
// reset
|
||||||
|
_remoteip = "";
|
||||||
|
_remoteport = 0;
|
||||||
|
_localip = "";
|
||||||
|
_localport = 0;
|
||||||
|
_connected_tick = 0;
|
||||||
|
_rxbytescount = 0;
|
||||||
|
_rxokcount = 0;
|
||||||
|
_txbytescount = 0;
|
||||||
|
_txokcount = 0;
|
||||||
|
_txtimercount = 0;
|
||||||
|
_rxtimercount = 0;
|
||||||
|
_mapkey = "";
|
||||||
|
if (onesecondtimer instanceof Timer) {
|
||||||
|
onesecondtimer.cancel();
|
||||||
|
}
|
||||||
|
onesecondtimer = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
BA.Log("tcpsocketrun about to call Disconnect on previous _socket if available");
|
||||||
|
if (_socket instanceof Socket) Disconnect();
|
||||||
|
_socket = xx;
|
||||||
|
|
||||||
|
|
||||||
|
ObjectInputStream _in = new ObjectInputStream(_socket.getInputStream());
|
||||||
|
ObjectOutputStream _out = new ObjectOutputStream(_socket.getOutputStream());
|
||||||
|
|
||||||
|
|
||||||
|
bytebuf = ByteBuffer.allocate(1024);
|
||||||
|
_input = _in;
|
||||||
|
_output = _out;
|
||||||
|
|
||||||
|
|
||||||
|
_remoteip = _socket.getInetAddress() == null ? "" : _socket.getInetAddress().getHostAddress();
|
||||||
|
_localip = _socket.getLocalAddress() == null ? "" : _socket.getLocalAddress().getHostAddress();
|
||||||
|
_remoteport = _socket.isClosed() ? 0 : _socket.getPort();
|
||||||
|
_localport = _socket.getLocalPort();
|
||||||
|
_mapkey = _remoteip+":"+String.valueOf(_remoteport);
|
||||||
|
validrun = true;
|
||||||
|
|
||||||
|
} catch(IOException e) {
|
||||||
|
raise_log_error("IOException on tcpsocketrun",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validrun) {
|
||||||
|
/// shutdownhook taruh di sini, buat auto close ketika socket connected
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
public void run() {
|
||||||
|
BA.Log("ShutdownHook on TCPSocket identifier="+_mapkey);
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
if (validrun) {
|
||||||
|
raise_log("tcpsocketrun running");
|
||||||
|
raise_connected(_socket.getInetAddress().getHostAddress(), _socket.getPort());
|
||||||
|
_connected_tick = DateTime.getNow();
|
||||||
|
// create new timer
|
||||||
|
onesecondtimer = new Timer();
|
||||||
|
onesecondtimer.scheduleAtFixedRate(checktxrxtimercounter, 1000, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
// selama _input masih ObjectInputStream, coba looping lagi
|
||||||
|
// Kalau Disconnect dipanggil, _input akan jadi null
|
||||||
|
// maka while ini jadi break
|
||||||
|
|
||||||
|
if (_input instanceof ObjectInputStream) {
|
||||||
|
int readcount = 0;
|
||||||
|
while(true) {
|
||||||
|
// coba ambil data di sini , loop terus sampe break
|
||||||
|
// kondisi terus, kalau readcount = buf.length, artinya bisa ambil data banyak
|
||||||
|
// mungkin masih ada data lagi setelahnya
|
||||||
|
//
|
||||||
|
// kondisi break, kalau readcount < buf.length, artinya buffernya aja gak sampe penuh
|
||||||
|
// berarti datanya cuma dikit
|
||||||
|
|
||||||
|
byte[] buf = new byte[1024];
|
||||||
|
|
||||||
|
try {
|
||||||
|
readcount = _input.read(buf); // ngeblok di sini
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException from input.read", e);
|
||||||
|
|
||||||
|
// kalau gak online, connection closed
|
||||||
|
String msg = e.getMessage();
|
||||||
|
|
||||||
|
// Network disconnect
|
||||||
|
if (msg.equalsIgnoreCase("connection reset")) {
|
||||||
|
Disconnect(); // Disconnect di sini nutup _input, _output, dan _socket
|
||||||
|
break; // keluar dari while(true) dalam
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readcount>0) { // perlu disimpen apa nggak
|
||||||
|
_rxtimercount = 0; // kalau berhasil terima something, reset jadi zero
|
||||||
|
if (readcount>bytebuf.remaining()) {
|
||||||
|
// gak cukup, gedein byte buffer
|
||||||
|
ByteBuffer newbytebuf = ByteBuffer.allocate(bytebuf.capacity()+readcount);
|
||||||
|
newbytebuf.put(bytebuf);
|
||||||
|
bytebuf = newbytebuf; // alokasikan ke sini
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// sampe sini , size cukup
|
||||||
|
bytebuf.put(buf,0,readcount);
|
||||||
|
|
||||||
|
// kalau readcount = 1024, artinya datanya cukup banyak, mungkin perlu baca lagi
|
||||||
|
// kalau readcount < 1024, artinya datanya sedikit, cukup sekali baca aja
|
||||||
|
if (readcount!=buf.length) break;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytebuf.position()>0) {
|
||||||
|
bytebuf.flip();
|
||||||
|
byte[] totalbytes = new byte[bytebuf.remaining()];
|
||||||
|
bytebuf.get(totalbytes);
|
||||||
|
//printbytes("TotalBytes",totalbytes);
|
||||||
|
try {
|
||||||
|
Object rxobject = _converter.ConvertBytesToObject(totalbytes);
|
||||||
|
if (rxobject instanceof MyMap) {
|
||||||
|
// MyMap adalah class asli Map Java , diwrapping oleh Erel
|
||||||
|
Map result = new Map(); // Map ini adalah B4X object
|
||||||
|
result.setObject((MyMap)rxobject);
|
||||||
|
raise_newmapdata(result);
|
||||||
|
} else if (rxobject instanceof String) {
|
||||||
|
String result = (String) rxobject;
|
||||||
|
raise_newstringdata(result);
|
||||||
|
} else if (rxobject instanceof ArrayList) {
|
||||||
|
ArrayList<?> tempresult = (ArrayList<?>) rxobject;
|
||||||
|
if (tempresult.size()>0) {
|
||||||
|
Object _firstobject = tempresult.get(0);
|
||||||
|
if (_firstobject instanceof Byte) {
|
||||||
|
byte[] result = new byte[tempresult.size()];
|
||||||
|
for(int ii=0;ii<result.length;ii++) result[ii] = (byte)tempresult.get(ii);
|
||||||
|
raise_newbytesdata(result);
|
||||||
|
} else if (_firstobject instanceof Integer) {
|
||||||
|
int[] result = new int[tempresult.size()];
|
||||||
|
for(int ii=0;ii<result.length;ii++) result[ii] = (int)tempresult.get(ii);
|
||||||
|
raise_newintsdata(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
raise_log("rxobject is unknown data");
|
||||||
|
}
|
||||||
|
|
||||||
|
// sampe sini gak ada salah proses, rxokcount++, rxbytescount++
|
||||||
|
if (_rxokcount<Integer.MAX_VALUE) _rxokcount++; else _rxokcount = 0;
|
||||||
|
if (Long.sum(_rxbytescount, totalbytes.length)<0) {
|
||||||
|
// overflow
|
||||||
|
_rxbytescount = totalbytes.length;
|
||||||
|
} else {
|
||||||
|
// not overflow
|
||||||
|
_rxbytescount += totalbytes.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on converter.ReadObject",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// bersihin untuk proses selanjutnya
|
||||||
|
bytebuf.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BA.Log("_input is not ObjectInputStream");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_disconnected(_remoteip, _remoteport);
|
||||||
|
|
||||||
|
// matiin timer di sini
|
||||||
|
if (onesecondtimer instanceof Timer) {
|
||||||
|
onesecondtimer.cancel();
|
||||||
|
}
|
||||||
|
onesecondtimer = null;
|
||||||
|
|
||||||
|
} else raise_disconnected("",0);
|
||||||
|
raise_log("tcpsocketrun ended");
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void printbytes(String prefix, byte[] value) {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
str.append(prefix).append(" : ");
|
||||||
|
if (value!=null) {
|
||||||
|
if (value.length>0) {
|
||||||
|
for (int ii=0;ii<value.length;ii++) {
|
||||||
|
str.append(Bit.ToHexString(Bit.And(value[ii], 0xFF))).append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BA.Log(str.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect from Remote IP and Remote Port
|
||||||
|
* Will raise Disconnected(remoteip as string, remoteport as int) event
|
||||||
|
* If TCPSocket never connected yet, remoteip = "" , and remoteport = 0
|
||||||
|
*/
|
||||||
|
public void Disconnect() {
|
||||||
|
Close_ObjectOutputStream();
|
||||||
|
Close_ObjectInputStream();
|
||||||
|
|
||||||
|
if (_socket instanceof Socket) {
|
||||||
|
try {
|
||||||
|
_socket.close();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on Disconnect",e);
|
||||||
|
raise_disconnected("",0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
raise_log("Disconnect has not effect, Socket is not created yet");
|
||||||
|
raise_disconnected("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_socket = null;
|
||||||
|
_remoteip = "";
|
||||||
|
_localip = "";
|
||||||
|
_remoteport =0;
|
||||||
|
_localport = 0;
|
||||||
|
|
||||||
|
if (_javaevent instanceof TcpSocketJavaEvent) {
|
||||||
|
_javaevent.disconnected(getIdentifierKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Map Object to TCPSocket
|
||||||
|
* @param value : Map value
|
||||||
|
* @return true if can be sent
|
||||||
|
*/
|
||||||
|
public boolean WriteMap(Map value) {
|
||||||
|
if (value instanceof Map) {
|
||||||
|
if (value.IsInitialized()) {
|
||||||
|
if (value.getSize()>0) {
|
||||||
|
try {
|
||||||
|
return WriteObject(value);
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on WriteMap",e);
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
} else raise_log("WriteMap canceled, value Size = 0");
|
||||||
|
} else raise_log("WriteMap canceled, value is not initialized");
|
||||||
|
} else raise_log("WriteMap canceled, value is not Map");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write bytes array to TCPSocket
|
||||||
|
* @param value : bytes array
|
||||||
|
* @return true if can be sent
|
||||||
|
*/
|
||||||
|
public boolean WriteBytes(byte[] value) {
|
||||||
|
if (value instanceof byte[]) {
|
||||||
|
if (value.length>0) {
|
||||||
|
try {
|
||||||
|
ArrayList<Byte> result = new ArrayList<Byte>();
|
||||||
|
for(int ii=0;ii<value.length;ii++) result.add(value[ii]);
|
||||||
|
return WriteObject(result);
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on WriteBytes",e);
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
} else raise_log("WriteBytes canceled, value size = 0");
|
||||||
|
} else raise_log("WriteBytes canceled, value is not byte array");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write String to TCPSocket
|
||||||
|
* @param value : String value
|
||||||
|
* @return true if can be sent
|
||||||
|
*/
|
||||||
|
public boolean WriteString(String value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
if (!value.isEmpty()) {
|
||||||
|
try {
|
||||||
|
return WriteObject(value);
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on WriteString",e);
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
} else raise_log("WriteString canceled, value size = 0");
|
||||||
|
} else raise_log("WriteString canceled, value is not String");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Int array to TCPSocket
|
||||||
|
* @param value : int array
|
||||||
|
* @return true if can be sent
|
||||||
|
*/
|
||||||
|
public boolean WriteInts(int[] value) {
|
||||||
|
if (value instanceof int[]) {
|
||||||
|
if (value.length>0) {
|
||||||
|
try {
|
||||||
|
ArrayList<Integer> result = new ArrayList<Integer>();
|
||||||
|
for(int ii=0;ii<value.length;ii++) result.add(value[ii]);
|
||||||
|
return WriteObject(result);
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on WriteInts",e);
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
} else raise_log("WriteInts canceled, value size = 0");
|
||||||
|
} else raise_log("WriteInts canceled, value is not int array");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class utama untuk Kirim ke Socket
|
||||||
|
* @param value : Object yang akan dikirim
|
||||||
|
* @return true kalau success
|
||||||
|
* @throws IOException kalau gagal
|
||||||
|
*/
|
||||||
|
private boolean WriteObject(Object value) throws IOException {
|
||||||
|
if (IsConnected()) {
|
||||||
|
if (_output instanceof ObjectOutputStream) {
|
||||||
|
byte[] outputbyte = _converter.ConvertObjectToBytes(value);
|
||||||
|
_output.write(outputbyte);
|
||||||
|
_output.flush();
|
||||||
|
//printbytes("WriteObject",outputbyte);
|
||||||
|
|
||||||
|
// sampe sini semua ok, gak ada exception
|
||||||
|
if (_txokcount<Integer.MAX_VALUE) _txokcount++; else _txokcount = 0;
|
||||||
|
if (Long.sum(_txbytescount, outputbyte.length)<0) {
|
||||||
|
// overflow
|
||||||
|
_txbytescount = outputbyte.length;
|
||||||
|
} else {
|
||||||
|
// not overflow
|
||||||
|
_txbytescount+= outputbyte.length;
|
||||||
|
}
|
||||||
|
_txtimercount=0; // kalau berhasil kirim, reset to zero
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return Remote IP Address
|
||||||
|
* @return empty string if disconnected
|
||||||
|
*/
|
||||||
|
public String getRemoteIPAddress() {
|
||||||
|
return _remoteip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return Remote TCP Port
|
||||||
|
* @return zero if disconnected
|
||||||
|
*/
|
||||||
|
public int getRemotePort() {
|
||||||
|
return _remoteport;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Local IP address used by TCPSocket
|
||||||
|
* @return empty string if not available
|
||||||
|
*/
|
||||||
|
public String getLocalIPAddress() {
|
||||||
|
return _localip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Local TCP Port used by TCPSocket
|
||||||
|
* @return zero if not available
|
||||||
|
*/
|
||||||
|
public int getLocalPort() {
|
||||||
|
return _localport;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get InputStream object of TCPSocket
|
||||||
|
* @return InputStream if valid, or null if invalid
|
||||||
|
*/
|
||||||
|
public InputStream getInputStream() {
|
||||||
|
if (IsConnected()) {
|
||||||
|
try {
|
||||||
|
return _socket.getInputStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on getInputStream",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get OutputStream object of TCPSocket
|
||||||
|
* @return OutputStream if valid, or null if invalid
|
||||||
|
*/
|
||||||
|
public OutputStream getOutputStream() {
|
||||||
|
if (IsConnected()) {
|
||||||
|
try {
|
||||||
|
return _socket.getOutputStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on getOutputStream",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return how many seconds since first time connected
|
||||||
|
* @return duration in seconds
|
||||||
|
*/
|
||||||
|
public long ConnectionDuration() {
|
||||||
|
if (_connected_tick>0) {
|
||||||
|
long now = DateTime.getNow();
|
||||||
|
if ((now - _connected_tick)>0) {
|
||||||
|
return ((now - _connected_tick) / DateTime.TicksPerSecond);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Date and Time when the socket is connected
|
||||||
|
* String will formatted as DD-MM-YYYY HH:MM:SS
|
||||||
|
* @return empty string if not yet connected
|
||||||
|
*/
|
||||||
|
public String Connected_DateTime_String() {
|
||||||
|
if (_connected_tick>0) {
|
||||||
|
return mycodes.Tick_To_DDMMYYYY_HHMMSS(_connected_tick);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get how many succesful Sending package
|
||||||
|
* @return zero to 2,147,483,647
|
||||||
|
*/
|
||||||
|
public int getTX_OK_Counter() {
|
||||||
|
|
||||||
|
return _txokcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get how many succesful Receiving package
|
||||||
|
* @return zero to 2,147,483,647
|
||||||
|
*/
|
||||||
|
public int getRX_OK_Counter() {
|
||||||
|
return _rxokcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get how much bytes has been sucesfully sent
|
||||||
|
* @return value in bytes, from zero to 9,223,372,036,854,775,807
|
||||||
|
*/
|
||||||
|
public long getTX_Bytes_Counter() {
|
||||||
|
return _txbytescount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get how much bytes has been sucesfully received
|
||||||
|
* @return value in bytes, from zero to 9,223,372,036,854,775,807
|
||||||
|
*/
|
||||||
|
public long getRX_Bytes_Counter() {
|
||||||
|
return _rxbytescount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TimerTask to execute, for checking txtimercounter and rxtimercounter
|
||||||
|
* this TimerTask will execute every 1000 ms
|
||||||
|
*/
|
||||||
|
private TimerTask checktxrxtimercounter = new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (_txtimercount>5) {
|
||||||
|
raise_log("Not sending more than 5 seconds, sending [PING] to check connection");
|
||||||
|
WriteString("[PING]"); // pancingan aja, gak penting hasilnya
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_rxtimercount>10) {
|
||||||
|
raise_log("Not receiving more than 10 seconds, connection have problem");
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private void Close_ObjectOutputStream() {
|
||||||
|
if (_output instanceof ObjectOutputStream) {
|
||||||
|
try {
|
||||||
|
_output.close();
|
||||||
|
raise_log("ObjectOutputStream closed");
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on Close_ObjectOutputStream",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_output = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Close_ObjectInputStream() {
|
||||||
|
if (_input instanceof ObjectInputStream) {
|
||||||
|
try {
|
||||||
|
_input.close();
|
||||||
|
raise_log("ObjectInputStream closed");
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on Close_ObjectInputStream",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_input = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log_error(String msg, Exception e) {
|
||||||
|
StringBuffer sbf = new StringBuffer();
|
||||||
|
sbf.append(msg);
|
||||||
|
if (e instanceof Exception) {
|
||||||
|
if (e.getMessage() instanceof String) {
|
||||||
|
sbf.append("\r\n");
|
||||||
|
sbf.append("Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
if (e.getCause() instanceof Throwable) {
|
||||||
|
sbf.append("\r\n");
|
||||||
|
sbf.append(e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_log(sbf.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_connected(String remoteip, int remoteport) {
|
||||||
|
if (need_connected_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_connected", false, new Object[] {remoteip, remoteport});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_disconnected(String remoteip, int remoteport) {
|
||||||
|
if (need_disconnected_event) {
|
||||||
|
long tt = 0;
|
||||||
|
if (_connected_tick > 0) {
|
||||||
|
tt = (DateTime.getNow() - _connected_tick) / DateTime.TicksPerSecond;
|
||||||
|
}
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_disconnected", false, new Object[] {remoteip,remoteport, tt / DateTime.TicksPerSecond });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newmapdata(Map value) {
|
||||||
|
if (need_newmapdata_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_newmapdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newbytesdata(byte[] value) {
|
||||||
|
if (need_newbytesdata_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_newbytesdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newstringdata(String value) {
|
||||||
|
if (need_newstringdata_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_newstringdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newintsdata(int[] value) {
|
||||||
|
if (need_newintsdata_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_newintsdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
418
src/customsocket/TCPSocketPrefixMode.java
Normal file
418
src/customsocket/TCPSocketPrefixMode.java
Normal file
@@ -0,0 +1,418 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.nio.BufferUnderflowException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.DateTime;
|
||||||
|
import jGPIO.mycodes;
|
||||||
|
|
||||||
|
@BA.ShortName("TCPSocketPrefixMode")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"connected(targetip as string, targetport as int)",
|
||||||
|
"disconnected(targetip as string, targetport as int, duration as long)",
|
||||||
|
"newbytesdata(value() as byte)",
|
||||||
|
"newstringdata(value as String)",
|
||||||
|
|
||||||
|
})
|
||||||
|
public class TCPSocketPrefixMode {
|
||||||
|
private BA bax;
|
||||||
|
private String event;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_connected_event = false;
|
||||||
|
private boolean need_disconnected_event = false;
|
||||||
|
private boolean need_newbytesdata_event = false;
|
||||||
|
private boolean need_newstringdata_event = false;
|
||||||
|
private boolean inited = false;
|
||||||
|
private Socket _socket;
|
||||||
|
|
||||||
|
private long _connected_tick = 0;
|
||||||
|
|
||||||
|
private int _txokcount = 0;
|
||||||
|
private long _txbytescount = 0;
|
||||||
|
private int _rxokcount = 0;
|
||||||
|
private long _rxbytescount = 0;
|
||||||
|
|
||||||
|
private String _remoteip = "";
|
||||||
|
private int _remoteport = 0;
|
||||||
|
private String _localip = "";
|
||||||
|
private int _localport = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize TCP Socket Prefix Mode
|
||||||
|
* @param EventName Eventname
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, String EventName) {
|
||||||
|
this.bax = ba;
|
||||||
|
this.event = EventName.toLowerCase();
|
||||||
|
if (bax!=null) {
|
||||||
|
if (event != null && event.length() > 0) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_connected_event = bax.subExists(event+"_connected");
|
||||||
|
need_disconnected_event = bax.subExists(event+"_disconnected");
|
||||||
|
need_newbytesdata_event = bax.subExists(event+"_newbytesdata");
|
||||||
|
need_newstringdata_event = bax.subExists(event+"_newstringdata");
|
||||||
|
inited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
return inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoteIP() {
|
||||||
|
return _remoteip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRemotePort() {
|
||||||
|
return _remoteport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalIP() {
|
||||||
|
return _localip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLocalPort() {
|
||||||
|
return _localport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConnectTo(String targetip, int port) {
|
||||||
|
if (targetip != null && targetip.length()>0) {
|
||||||
|
if (port>0 && port < 65536) {
|
||||||
|
BA.runAsync(bax, TCPSocketPrefixMode.this, event+"_connected", new Object[] {"",0}, new Callable<Object[]>(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] call() throws Exception {
|
||||||
|
try {
|
||||||
|
Socket trysock = new Socket();
|
||||||
|
SocketAddress rem = new InetSocketAddress(targetip, port);
|
||||||
|
trysock.connect(rem);
|
||||||
|
Thread tx = new Thread(new tcpsocketrun(trysock));
|
||||||
|
tx.start();
|
||||||
|
return new Object[] {targetip,port};
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
raise_log_error("UnknownHostException on ConnectTo ["+targetip+":"+port+"]",e);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on ConnectTo ["+targetip+"]:["+port+"]",e);
|
||||||
|
}
|
||||||
|
return new Object[] {"",0};
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else raise_log("ConnectTo failed, invalid targetport");
|
||||||
|
} else raise_log("ConnectTo failed, Invalid targetip");
|
||||||
|
raise_connected("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConnectTo_withBind(String targetip, int port, String localip) {
|
||||||
|
if (targetip != null && !targetip.isEmpty()) {
|
||||||
|
if (port>0 && port < 65536) {
|
||||||
|
if (localip!=null && !localip.isEmpty()) {
|
||||||
|
BA.runAsync(bax, TCPSocketPrefixMode.this, event+"_connected", new Object[] {"",0}, new Callable<Object[]>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] call() throws Exception {
|
||||||
|
try {
|
||||||
|
SocketAddress loc = new InetSocketAddress(localip, port);
|
||||||
|
SocketAddress rem = new InetSocketAddress (targetip,port);
|
||||||
|
Socket trysocket = new Socket();
|
||||||
|
trysocket.bind(loc);
|
||||||
|
trysocket.connect(rem);
|
||||||
|
Thread tx = new Thread(new tcpsocketrun(trysocket));
|
||||||
|
tx.start();
|
||||||
|
return new Object[] {targetip,port};
|
||||||
|
} catch(IOException e) {
|
||||||
|
raise_log_error("IOException on ConnectTo_withBind ["+targetip+"]:]"+port+"] Bind="+localip,e);
|
||||||
|
}
|
||||||
|
return new Object[] {"",0};
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} else raise_log("ConnectTo_withBind failed, invalid localip");
|
||||||
|
} else raise_log("ConnectTo_withBind failed, invalid targetport");
|
||||||
|
} else raise_log("ConnectTo_withBind failed, Invalid targetip");
|
||||||
|
raise_connected("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Disconnect() {
|
||||||
|
|
||||||
|
|
||||||
|
if (_socket != null) {
|
||||||
|
try {
|
||||||
|
_socket.close();
|
||||||
|
raise_disconnected(_remoteip, _remoteport);
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on Disconnect",e);
|
||||||
|
raise_disconnected("",0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
raise_log("Disconnect has not effect, Socket is not created yet");
|
||||||
|
raise_disconnected("",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_socket = null;
|
||||||
|
_remoteip = "";
|
||||||
|
_localip = "";
|
||||||
|
_remoteport =0;
|
||||||
|
_localport = 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean WriteBytes(byte[] data) {
|
||||||
|
if (IsConnected()) {
|
||||||
|
if (data != null && data.length>0) {
|
||||||
|
ByteBuffer bb = ByteBuffer.allocate(data.length+4);
|
||||||
|
bb.order(ByteOrder.BIG_ENDIAN);
|
||||||
|
bb.putInt(data.length);
|
||||||
|
bb.put(data);
|
||||||
|
try {
|
||||||
|
_socket.getOutputStream().write(bb.array());
|
||||||
|
|
||||||
|
_txokcount++;
|
||||||
|
_txbytescount += data.length;
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on WriteBytes", e);
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
} else raise_log("WriteBytes failed, data is null or empty");
|
||||||
|
} else raise_log("WriteBytes failed, Socket is not connected");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean WriteString(String data) {
|
||||||
|
try {
|
||||||
|
byte[] xx = data.getBytes("UTF-8");
|
||||||
|
return WriteBytes(xx);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
raise_log_error("UnsupportedEncodingException on WriteString", e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long ConnectionDuration() {
|
||||||
|
if (_connected_tick>0) {
|
||||||
|
long now = DateTime.getNow();
|
||||||
|
if ((now - _connected_tick)>0) {
|
||||||
|
return ((now - _connected_tick) / DateTime.TicksPerSecond);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String Connected_DateTime_String() {
|
||||||
|
if (_connected_tick>0) {
|
||||||
|
return mycodes.Tick_To_DDMMYYYY_HHMMSS(_connected_tick);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTX_OK_Counter() {
|
||||||
|
|
||||||
|
return _txokcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRX_OK_Counter() {
|
||||||
|
return _rxokcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTX_Bytes_Counter() {
|
||||||
|
return _txbytescount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRX_Bytes_Counter() {
|
||||||
|
return _rxbytescount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Socket is connected
|
||||||
|
* @return true if connected
|
||||||
|
*/
|
||||||
|
public boolean IsConnected() {
|
||||||
|
if (_socket != null) {
|
||||||
|
if (_socket.isConnected()) {
|
||||||
|
if (!_socket.isInputShutdown()) {
|
||||||
|
if (!_socket.isOutputShutdown()) {
|
||||||
|
return !_socket.isClosed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class tcpsocketrun implements Runnable{
|
||||||
|
private boolean validrun = false;
|
||||||
|
private InputStream _input;
|
||||||
|
public tcpsocketrun(Socket xx) {
|
||||||
|
// reset
|
||||||
|
_remoteip = "";
|
||||||
|
_remoteport = 0;
|
||||||
|
_localip = "";
|
||||||
|
_localport = 0;
|
||||||
|
_connected_tick = 0;
|
||||||
|
_rxbytescount = 0;
|
||||||
|
_rxokcount = 0;
|
||||||
|
_txbytescount = 0;
|
||||||
|
_txokcount = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
BA.Log("tcpsocketrun about to call Disconnect on previous _socket if available");
|
||||||
|
if (_socket != null) Disconnect();
|
||||||
|
_socket = xx;
|
||||||
|
_input = _socket.getInputStream();
|
||||||
|
|
||||||
|
_remoteip = _socket.getInetAddress() == null ? "" : _socket.getInetAddress().getHostAddress();
|
||||||
|
_localip = _socket.getLocalAddress() == null ? "" : _socket.getLocalAddress().getHostAddress();
|
||||||
|
_remoteport = _socket.isClosed() ? 0 : _socket.getPort();
|
||||||
|
_localport = _socket.getLocalPort();
|
||||||
|
|
||||||
|
validrun = true;
|
||||||
|
|
||||||
|
} catch(IOException e) {
|
||||||
|
raise_log_error("IOException on tcpsocketrun",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validrun) {
|
||||||
|
/// shutdownhook taruh di sini, buat auto close ketika socket connected
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
if (validrun) {
|
||||||
|
raise_log("tcpsocketrun running");
|
||||||
|
//raise_connected(_socket.getInetAddress().getHostAddress(), _socket.getPort());
|
||||||
|
_connected_tick = DateTime.getNow();
|
||||||
|
|
||||||
|
int readcount;
|
||||||
|
byte[] xx;
|
||||||
|
while(IsConnected()) {
|
||||||
|
xx = new byte[15000];
|
||||||
|
readcount = 0;
|
||||||
|
try {
|
||||||
|
|
||||||
|
readcount = _input.read(xx); // ngeblok di sini sampai dapat data
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on tcpsocketrun read",e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prefix mode, 4 byte awal adalah size, sisanya adalah data
|
||||||
|
// jadi minimal length = 4
|
||||||
|
if (readcount>4) {
|
||||||
|
ByteBuffer bb = ByteBuffer.wrap(xx);
|
||||||
|
bb.order(ByteOrder.BIG_ENDIAN);
|
||||||
|
try {
|
||||||
|
int datasize = bb.getInt();
|
||||||
|
byte[] data = new byte[datasize];
|
||||||
|
bb.get(data);
|
||||||
|
_rxokcount++;
|
||||||
|
_rxbytescount += readcount;
|
||||||
|
byte[] yy = new byte[readcount];
|
||||||
|
System.arraycopy(xx, 0, yy, 0, readcount);
|
||||||
|
raise_newbytesdata(yy);
|
||||||
|
try {
|
||||||
|
String zz = new String(yy, "UTF-8");
|
||||||
|
raise_newstringdata(zz);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
raise_log_error("UnsupportedEncodingException on tcpsocketrun read", e);
|
||||||
|
}
|
||||||
|
} catch (BufferUnderflowException e) {
|
||||||
|
|
||||||
|
raise_log_error("BufferUnderflowException on tcpsocketrun read, prefix invalid", e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Disconnect();
|
||||||
|
|
||||||
|
|
||||||
|
} else raise_disconnected("",0);
|
||||||
|
raise_log("tcpsocketrun ended");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void raise_log_error(String msg, Exception e) {
|
||||||
|
StringBuffer sbf = new StringBuffer();
|
||||||
|
sbf.append(msg);
|
||||||
|
if (e instanceof Exception) {
|
||||||
|
if (e.getMessage() instanceof String) {
|
||||||
|
sbf.append("\r\n");
|
||||||
|
sbf.append("Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
if (e.getCause() instanceof Throwable) {
|
||||||
|
sbf.append("\r\n");
|
||||||
|
sbf.append(e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_log(sbf.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(TCPSocketPrefixMode.this, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_connected(String remoteip, int remoteport) {
|
||||||
|
if (need_connected_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(TCPSocketPrefixMode.this, null, 0, event+"_connected", false, new Object[] {remoteip, remoteport});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_disconnected(String remoteip, int remoteport) {
|
||||||
|
if (need_disconnected_event) {
|
||||||
|
if (remoteport > 0 && remoteip.length() > 0) {
|
||||||
|
// pernah connect
|
||||||
|
long tt = 0;
|
||||||
|
if (_connected_tick > 0) {
|
||||||
|
tt = (DateTime.getNow() - _connected_tick) / DateTime.TicksPerSecond;
|
||||||
|
}
|
||||||
|
bax.raiseEventFromDifferentThread(TCPSocketPrefixMode.this, null, 0, event+"_disconnected", false, new Object[] {remoteip,remoteport, tt / DateTime.TicksPerSecond });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newbytesdata(byte[] value) {
|
||||||
|
if (need_newbytesdata_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(TCPSocketPrefixMode.this, null, 0, event+"_newbytesdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newstringdata(String value) {
|
||||||
|
if (need_newstringdata_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(TCPSocketPrefixMode.this, null, 0, event+"_newstringdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
380
src/customsocket/TCPSocketServer.java
Normal file
380
src/customsocket/TCPSocketServer.java
Normal file
@@ -0,0 +1,380 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.List;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
|
||||||
|
@BA.ShortName("TCPSocketServer")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"newtcpsocket(value as TCPSocket)",
|
||||||
|
"listeningstatus(islistening as boolean)",
|
||||||
|
"connectedclients(value as int, keys as List)"
|
||||||
|
})
|
||||||
|
public class TCPSocketServer implements TcpSocketJavaEvent {
|
||||||
|
|
||||||
|
private BA bax;
|
||||||
|
private Object caller;
|
||||||
|
private Object Me = this;
|
||||||
|
private String event;
|
||||||
|
private boolean _inited = false;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_newtcpsocket_event = false;
|
||||||
|
private boolean need_listeningstatus_event = false;
|
||||||
|
private boolean need_connectedclients_event = false;
|
||||||
|
private ServerSocket _server;
|
||||||
|
|
||||||
|
private Map _socketmap = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize TCP Socket Server
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param eventname : eventname
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object callerobject, String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
caller = callerobject;
|
||||||
|
event = eventname;
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (caller != null) {
|
||||||
|
if (event instanceof String) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
_inited = true;
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_newtcpsocket_event = bax.subExists(event+"_newtcpsocket");
|
||||||
|
need_listeningstatus_event = bax.subExists(event+"_listeningstatus");
|
||||||
|
need_connectedclients_event = bax.subExists(event+"_connectedclients");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
public void run() {
|
||||||
|
BA.Log("ShutdownHook on TCPSocketServer at "+getLocalIPAddress()+":"+getLocalPort());
|
||||||
|
StopListening();
|
||||||
|
Disconnect_All_TCPSocket();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_socketmap.Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if TCPSocketServer is initialized
|
||||||
|
* @return true if inited
|
||||||
|
*/
|
||||||
|
public boolean Initialized() {
|
||||||
|
return _inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop Listening for Connections
|
||||||
|
*/
|
||||||
|
public void StopListening() {
|
||||||
|
if (_server instanceof ServerSocket) {
|
||||||
|
try {
|
||||||
|
_server.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on StopListening",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_server = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Local IP Address used for listening
|
||||||
|
* @return empty string if failed
|
||||||
|
*/
|
||||||
|
public String getLocalIPAddress() {
|
||||||
|
if (_server instanceof ServerSocket) {
|
||||||
|
if (_server.getInetAddress()!=null) {
|
||||||
|
return _server.getInetAddress().getHostAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Local Port used for Listening
|
||||||
|
* @return zero if failed
|
||||||
|
*/
|
||||||
|
public int getLocalPort() {
|
||||||
|
if (_server instanceof ServerSocket) {
|
||||||
|
if (_server.getLocalPort()>0) {
|
||||||
|
return _server.getLocalPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start Listening
|
||||||
|
* @param port : listen port
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean StartListening(int port) {
|
||||||
|
if (_server instanceof ServerSocket) StopListening();
|
||||||
|
try {
|
||||||
|
ServerSocket newserver = new ServerSocket(port);
|
||||||
|
Thread tx = new Thread(new tcpsocketserverrun(newserver));
|
||||||
|
tx.start();
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on StartListening at port "+port,e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get how many TCPSockets has been received
|
||||||
|
* @return value as integer
|
||||||
|
*/
|
||||||
|
public int getConnectedTCPSocket() {
|
||||||
|
return _socketmap.IsInitialized() ? _socketmap.getSize() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get List of IdentifierKey from all connected TCPSockets
|
||||||
|
* @return List of IdentifierKey, or empty List of none connected
|
||||||
|
*/
|
||||||
|
public List getListOfTCPSocketKeys() {
|
||||||
|
List result = new List();
|
||||||
|
result.Initialize();
|
||||||
|
if (_socketmap.IsInitialized()) {
|
||||||
|
if (_socketmap.getSize()>0) {
|
||||||
|
for(int ii=0;ii<_socketmap.getSize();ii++) {
|
||||||
|
result.Add((String)_socketmap.GetKeyAt(ii));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect all TCPSocket in Map
|
||||||
|
*/
|
||||||
|
public void Disconnect_All_TCPSocket() {
|
||||||
|
List result = getListOfTCPSocketKeys();
|
||||||
|
if (result.getSize()>0) {
|
||||||
|
for(int ii=0;ii<result.getSize();ii++) {
|
||||||
|
Disconnect_TCPSocket((String)result.Get(ii));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_socketmap.Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Socket Map contain specific IP address
|
||||||
|
* @param ipvalue : Ip address
|
||||||
|
* @return TCPSocket object, or null if not available
|
||||||
|
*/
|
||||||
|
public TCPSocket Have_TCPSocket_with_IPAddress(String ipvalue) {
|
||||||
|
if (_socketmap instanceof Map) {
|
||||||
|
if (_socketmap.IsInitialized()) {
|
||||||
|
if (_socketmap.getSize()>0) {
|
||||||
|
for (int ii=0;ii<_socketmap.getSize();ii++) {
|
||||||
|
String key = (String) _socketmap.GetKeyAt(ii);
|
||||||
|
if (key.startsWith(ipvalue)) {
|
||||||
|
Object xx = _socketmap.Get(key);
|
||||||
|
if (xx instanceof TCPSocket) {
|
||||||
|
return (TCPSocket)xx;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect TCPSocket and remove it from Map
|
||||||
|
* @param identifierkey : identifierkey in string
|
||||||
|
* @return true if identifierkey can be found
|
||||||
|
*/
|
||||||
|
public boolean Disconnect_TCPSocket(String identifierkey) {
|
||||||
|
if (identifierkey instanceof String) {
|
||||||
|
if (!identifierkey.isEmpty()) {
|
||||||
|
if (_socketmap.ContainsKey(identifierkey)) {
|
||||||
|
Object xx = _socketmap.Get(identifierkey);
|
||||||
|
if (xx instanceof TCPSocket) {
|
||||||
|
TCPSocket tcp = (TCPSocket)xx;
|
||||||
|
tcp.Disconnect();
|
||||||
|
tcp = null;
|
||||||
|
}
|
||||||
|
xx = null;
|
||||||
|
_socketmap.Remove(identifierkey);
|
||||||
|
raise_connectedclients(_socketmap.getSize(), getListOfTCPSocketKeys());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename Map identifier from old_id to new_id, but retain the same TCPSocket object
|
||||||
|
* @param old_id : old identifier
|
||||||
|
* @param new_id : new identifier
|
||||||
|
* @return true if Map contain old_id and succesfully renamed, or false if otherwise
|
||||||
|
*/
|
||||||
|
public boolean Rename_Identifier(String old_id, String new_id) {
|
||||||
|
if (_socketmap instanceof Map) {
|
||||||
|
if (_socketmap.IsInitialized()) {
|
||||||
|
if (_socketmap.ContainsKey(old_id)) {
|
||||||
|
Object xx = _socketmap.Get(old_id);
|
||||||
|
if (xx instanceof TCPSocket) {
|
||||||
|
TCPSocket tcp = (TCPSocket) xx;
|
||||||
|
|
||||||
|
_socketmap.Remove(old_id);
|
||||||
|
_socketmap.Put(new_id, tcp);
|
||||||
|
if (tcp.getIdentifierKey().equals(new_id)==false) {
|
||||||
|
tcp.setIdentifierKey(new_id);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class tcpsocketserverrun implements Runnable{
|
||||||
|
private boolean validrun = false;
|
||||||
|
public tcpsocketserverrun(ServerSocket xx) {
|
||||||
|
_server = xx;
|
||||||
|
if (_server instanceof ServerSocket) {
|
||||||
|
if (!_server.isClosed()) {
|
||||||
|
validrun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
if (validrun) {
|
||||||
|
raise_listeningstatus(true);
|
||||||
|
while(true) {
|
||||||
|
if (_server instanceof ServerSocket) {
|
||||||
|
if (!_server.isClosed()) {
|
||||||
|
try {
|
||||||
|
Socket newsocket = _server.accept();
|
||||||
|
raise_log("New connection from "+newsocket.getInetAddress().getHostAddress()+":"+newsocket.getPort()+" to TCPSocketServer");
|
||||||
|
TCPSocket newtcp = new TCPSocket(newsocket, Me);
|
||||||
|
|
||||||
|
raise_newtcpsocket(newtcp);
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log_error("IOException on server.accept", e);
|
||||||
|
}
|
||||||
|
} else break;
|
||||||
|
} else break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
raise_listeningstatus(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log_error(String msg, Exception e) {
|
||||||
|
StringBuffer sbf = new StringBuffer();
|
||||||
|
sbf.append(msg);
|
||||||
|
if (e instanceof Exception) {
|
||||||
|
if (e.getMessage() instanceof String) {
|
||||||
|
sbf.append("\r\n");
|
||||||
|
sbf.append("Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
if (e.getCause() instanceof Throwable) {
|
||||||
|
sbf.append("\r\n");
|
||||||
|
sbf.append(e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_log(sbf.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newtcpsocket(TCPSocket value) {
|
||||||
|
if (need_newtcpsocket_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_newtcpsocket", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_listeningstatus(boolean value) {
|
||||||
|
if (need_listeningstatus_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_listeningstatus", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_connectedclients(int value, List keys) {
|
||||||
|
if (need_connectedclients_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_connectedclients", false, new Object[] {value, keys});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////// Event from TcpSocketJavaEvent /////////////////////////
|
||||||
|
@Override
|
||||||
|
@BA.Hide
|
||||||
|
public void newidentifierkey(String identifier, TCPSocket Sender) {
|
||||||
|
if (!_socketmap.IsInitialized()) _socketmap.Initialize();
|
||||||
|
if (identifier instanceof String) {
|
||||||
|
if (!identifier.isEmpty()) {
|
||||||
|
Object prev_in_map = null;
|
||||||
|
if (identifier.contains(":")) {
|
||||||
|
// mengandung ip:port
|
||||||
|
// coba cek apakah ip nya pernah ada
|
||||||
|
String ipnya = identifier.substring(0, identifier.indexOf(":"));
|
||||||
|
prev_in_map = Have_TCPSocket_with_IPAddress(ipnya);
|
||||||
|
if (prev_in_map instanceof TCPSocket) {
|
||||||
|
TCPSocket oldsock = (TCPSocket) prev_in_map;
|
||||||
|
// ada
|
||||||
|
raise_log("Found another TCPSocket with same IP. ID 1 = "+identifier+", ID 2="+ oldsock.getIdentifierKey());
|
||||||
|
_socketmap.Remove(oldsock.getIdentifierKey());
|
||||||
|
raise_log("Removing Old TCPSocket with identifier="+oldsock.getIdentifierKey());
|
||||||
|
_socketmap.Put(identifier, Sender);
|
||||||
|
raise_log("Save New TCPSocket with identifer="+Sender.getIdentifierKey());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prev_in_map = _socketmap.Put(identifier, Sender);
|
||||||
|
raise_log("Save TCPSocket with identifier="+identifier+" to Map");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (prev_in_map != null) {
|
||||||
|
if (prev_in_map instanceof TCPSocket) {
|
||||||
|
TCPSocket prevsock = (TCPSocket) prev_in_map;
|
||||||
|
prevsock.Disconnect();
|
||||||
|
prevsock = null;
|
||||||
|
raise_log("Disconnect old TCPSocket with the identifier="+identifier);
|
||||||
|
}
|
||||||
|
prev_in_map = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
raise_connectedclients(_socketmap.getSize(), getListOfTCPSocketKeys());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BA.Hide
|
||||||
|
public void disconnected(String identifier) {
|
||||||
|
Disconnect_TCPSocket(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BA.Hide
|
||||||
|
public void renameidentifier(String oldvalue, String newvalue) {
|
||||||
|
Rename_Identifier(oldvalue, newvalue);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/customsocket/TcpSocketJavaEvent.java
Normal file
8
src/customsocket/TcpSocketJavaEvent.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package customsocket;
|
||||||
|
|
||||||
|
public interface TcpSocketJavaEvent {
|
||||||
|
public void newidentifierkey(String identifier, TCPSocket Sender);
|
||||||
|
public void disconnected(String identifier);
|
||||||
|
public void renameidentifier(String oldvalue, String newvalue);
|
||||||
|
|
||||||
|
}
|
||||||
273
src/customsocket/UDPSocket.java
Normal file
273
src/customsocket/UDPSocket.java
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
package customsocket;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.DatagramPacket;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.SocketException;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.*;
|
||||||
|
|
||||||
|
//@BA.ShortName("UDPSocketNew")
|
||||||
|
@BA.Permissions(values = {"android.permission.INTERNET"})
|
||||||
|
@BA.Events(values={"PacketArrived (Packet As UDPPacket)"})
|
||||||
|
@BA.Hide
|
||||||
|
public class UDPSocket {
|
||||||
|
private UDPReader reader;
|
||||||
|
private DatagramSocket ds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize UDPSocket
|
||||||
|
* @param EventName eventname
|
||||||
|
* @param Port listening port
|
||||||
|
* @param ReceiveBufferSize size of buffer
|
||||||
|
* @throws SocketException
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, String EventName, int Port, int ReceiveBufferSize) throws SocketException {
|
||||||
|
Close();
|
||||||
|
DatagramSocket newds = null;
|
||||||
|
try {
|
||||||
|
if (Port==0) {
|
||||||
|
newds = new DatagramSocket();
|
||||||
|
} else {
|
||||||
|
newds = new DatagramSocket(Port);
|
||||||
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
BA.Log("UDPSocketNew Initialize failed, exception = "+e.getMessage());
|
||||||
|
} finally {
|
||||||
|
if (newds instanceof DatagramSocket) {
|
||||||
|
init(ba, EventName, ReceiveBufferSize, newds);
|
||||||
|
} else BA.Log("Not calling init");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize UDPSocket with specific bind
|
||||||
|
* @param EventName eventname
|
||||||
|
* @param Port listening port
|
||||||
|
* @param ReceiveBufferSize size of buffer
|
||||||
|
* @param localip Local IP Address bind to UDPSocket
|
||||||
|
* @throws SocketException
|
||||||
|
*/
|
||||||
|
public void Initialize_withBind(BA ba, String EventName, int Port, int ReceiveBufferSize, String localip) throws SocketException {
|
||||||
|
Close();
|
||||||
|
DatagramSocket newds = null;
|
||||||
|
try {
|
||||||
|
InetSocketAddress bindadd = new InetSocketAddress(localip, Port);
|
||||||
|
newds = new DatagramSocket(bindadd);
|
||||||
|
|
||||||
|
} catch(IOException e) {
|
||||||
|
BA.Log("UDPSocketNew Initialize_withBind failed, exception="+e.getMessage());
|
||||||
|
} finally {
|
||||||
|
if (newds instanceof DatagramSocket) {
|
||||||
|
BA.Log("UDPSocketNew Initialize_withBind will call init");
|
||||||
|
init(ba, EventName, ReceiveBufferSize, newds);
|
||||||
|
} else BA.Log("UDPSocketNew Initialize_withBind not calling init");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public void init(BA ba, String EventName, int ReceiveBufferSize, DatagramSocket ds) {
|
||||||
|
this.ds = ds;
|
||||||
|
if (ReceiveBufferSize > 0) {
|
||||||
|
reader = new UDPReader();
|
||||||
|
reader.working = true;
|
||||||
|
reader.socket = ds;
|
||||||
|
reader.receiveLength = ReceiveBufferSize;
|
||||||
|
reader.ba = ba;
|
||||||
|
reader.eventName = EventName.toLowerCase(BA.cul);
|
||||||
|
Thread t = new Thread(reader);
|
||||||
|
t.setDaemon(true);
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
return ds != null && !ds.isClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Local Port where UDPSocket is listening
|
||||||
|
* @return -1 if UDPsocket closed, or 0 if not bound
|
||||||
|
*/
|
||||||
|
public int getPort() {
|
||||||
|
return ds.getLocalPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Local IP Address where UDPSocket is bound
|
||||||
|
* @return null if UDPSocket is closed
|
||||||
|
*/
|
||||||
|
public String getLocalIP() {
|
||||||
|
return ds.getLocalAddress().getHostAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Remote Port where UDPSocket is connected
|
||||||
|
* @return -1 if not connected
|
||||||
|
*/
|
||||||
|
public int getRemotePort() {
|
||||||
|
return ds.getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Remote IP where UDPSocket is connected
|
||||||
|
* @return null if not connnected
|
||||||
|
*/
|
||||||
|
public String getRemoteIP() {
|
||||||
|
return ds.getInetAddress().getHostAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send UDP Packet
|
||||||
|
* @param Packet packet to send
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void Send(final UDPPacket Packet) throws IOException {
|
||||||
|
BA.submitRunnable(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Packet.getObject().packet.setSocketAddress(new InetSocketAddress(Packet.getObject().host, Packet.getObject().port));
|
||||||
|
ds.send(Packet.getObject().packet);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, this, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() {
|
||||||
|
if (ds!=null) {
|
||||||
|
ds.close();
|
||||||
|
}
|
||||||
|
ds = null;
|
||||||
|
if (reader!=null) {
|
||||||
|
reader.working = false;
|
||||||
|
}
|
||||||
|
reader = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if (ds == null)
|
||||||
|
return "Not initialized";
|
||||||
|
return getLocalIP()+":"+getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class UDPReader implements Runnable {
|
||||||
|
volatile boolean working;
|
||||||
|
DatagramSocket socket;
|
||||||
|
int receiveLength;
|
||||||
|
BA ba;
|
||||||
|
String eventName;
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (working) {
|
||||||
|
try {
|
||||||
|
DatagramPacket p = new DatagramPacket(new byte[receiveLength], receiveLength);
|
||||||
|
socket.receive(p);
|
||||||
|
UDPPacket u = new UDPPacket();
|
||||||
|
u.setObject(new MyDatagramPacket("", 0, p));
|
||||||
|
ba.raiseEventFromDifferentThread(null, null, 0, eventName + "_packetarrived", false, new Object[] {u});
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (working) {
|
||||||
|
try {
|
||||||
|
e.printStackTrace();
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A packet of data that is being sent or received.
|
||||||
|
*To send a packet call one of the Initialize methods and then send the packet by passing it to UDPSocket.Send.
|
||||||
|
*When a packet arrives you can get the data in the packet from the available properties.
|
||||||
|
*/
|
||||||
|
// @BA.ShortName("UDPPacket")
|
||||||
|
@BA.Hide
|
||||||
|
public static class UDPPacket extends AbsObjectWrapper<MyDatagramPacket> {
|
||||||
|
/**
|
||||||
|
* Initializes the packet and makes it ready for sending.
|
||||||
|
*Data - The data that will be send.
|
||||||
|
*Host - The target host name or IP address.
|
||||||
|
*Port - The target port.
|
||||||
|
*/
|
||||||
|
public void Initialize(byte[] Data, String Host, int Port) throws SocketException {
|
||||||
|
Initialize2(Data, 0, Data.length, Host, Port);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Similar to Initialize. The data sent is based on the Offset and Length values.
|
||||||
|
*/
|
||||||
|
public void Initialize2(byte[] Data, int Offset, int Length, String Host, int Port) throws SocketException {
|
||||||
|
|
||||||
|
DatagramPacket d = new DatagramPacket(Data, Offset, Length);
|
||||||
|
MyDatagramPacket m = new MyDatagramPacket(Host, Port, d);
|
||||||
|
setObject(m);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the length of available bytes in the data. This can be shorter than the array length.
|
||||||
|
*/
|
||||||
|
public int getLength() {
|
||||||
|
return getObject().packet.getLength();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the data array received.
|
||||||
|
*/
|
||||||
|
public byte[] getData() {
|
||||||
|
return getObject().packet.getData();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the offset in the data array where the available data starts.
|
||||||
|
*/
|
||||||
|
public int getOffset() {
|
||||||
|
return getObject().packet.getOffset();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the port of the sending machine.
|
||||||
|
*/
|
||||||
|
public int getPort() {
|
||||||
|
return getObject().packet.getPort();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*<b>This method is deprecated and will not work properly on Android 4+ device.</b>
|
||||||
|
*Use HostAddress instead.
|
||||||
|
*/
|
||||||
|
public String getHost() {
|
||||||
|
return getObject().packet.getAddress().getHostName();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the IP address of the sending machine.
|
||||||
|
*/
|
||||||
|
public String getHostAddress() {
|
||||||
|
return getObject().packet.getAddress().getHostAddress();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if (getObjectOrNull() == null)
|
||||||
|
return super.toString();
|
||||||
|
return "Length=" + getLength() + ", Offset=" + getOffset() + ", Host=" + getHost() + ", Port=" + getPort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@BA.Hide
|
||||||
|
public static class MyDatagramPacket {
|
||||||
|
public final String host;
|
||||||
|
public final int port;
|
||||||
|
public final DatagramPacket packet;
|
||||||
|
public MyDatagramPacket(String host, int port, DatagramPacket packet) {
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.packet = packet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
219
src/devices/AT24C32.java
Normal file
219
src/devices/AT24C32.java
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
package devices;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import jGPIO.jGPIO;
|
||||||
|
import jGPIO.I2C.I2C_BUS;
|
||||||
|
import jGPIO.I2C.I2C_BUS_Event;
|
||||||
|
import jGPIO.I2C.I2C_Device;
|
||||||
|
import jGPIO.I2C.I2C_Device_Event;
|
||||||
|
|
||||||
|
|
||||||
|
// belum bisa
|
||||||
|
@BA.ShortName("AT24C32")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)"
|
||||||
|
})
|
||||||
|
public class AT24C32 implements I2C_BUS_Event, I2C_Device_Event {
|
||||||
|
private BA bax;
|
||||||
|
private Object myobject;
|
||||||
|
private String event;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
|
||||||
|
private int dev_address = 0x57;
|
||||||
|
private I2C_BUS i2cbus;
|
||||||
|
private I2C_Device i2cdev;
|
||||||
|
|
||||||
|
private boolean iscorrect = false;
|
||||||
|
|
||||||
|
public AT24C32() {
|
||||||
|
if (jGPIO.osname.isEmpty()) jGPIO.detectOS();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a AT24C32. Used in B4J only
|
||||||
|
* @param caller : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object caller, String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
myobject = caller;
|
||||||
|
event = eventname.trim();
|
||||||
|
if (bax!=null) {
|
||||||
|
if (myobject!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() {
|
||||||
|
if (i2cdev!=null) {
|
||||||
|
i2cdev.CloseDevice();
|
||||||
|
}
|
||||||
|
i2cdev = null;
|
||||||
|
|
||||||
|
if (i2cbus!=null) {
|
||||||
|
i2cbus.Close_Bus();
|
||||||
|
}
|
||||||
|
i2cbus = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Slave
|
||||||
|
* @param index : I2C bus Index
|
||||||
|
* @param slave_address : slave address of this PCF
|
||||||
|
* @return true if succcess
|
||||||
|
*/
|
||||||
|
public boolean Open(String bus_name, int slave_address) {
|
||||||
|
iscorrect = false;
|
||||||
|
if (!jGPIO.IsLinux) return iscorrect;
|
||||||
|
|
||||||
|
i2cbus = new I2C_BUS(bus_name);
|
||||||
|
i2cbus.SetJavaEvent(this);
|
||||||
|
if (i2cbus.Open_Bus()) {
|
||||||
|
i2cdev = new I2C_Device(i2cbus.I2C_Handle(), slave_address);
|
||||||
|
i2cdev.SetJavaEvent(this);
|
||||||
|
if (i2cdev.OpenDevice_SLAVE()) {
|
||||||
|
iscorrect = true;
|
||||||
|
this.dev_address = slave_address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iscorrect) {
|
||||||
|
raise_log("AT24C32 is Opened");
|
||||||
|
} else {
|
||||||
|
raise_log("AT24C32 failed to Open");
|
||||||
|
}
|
||||||
|
return iscorrect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check associated Slave Address
|
||||||
|
* @return -1 if no address
|
||||||
|
*/
|
||||||
|
public int getSlaveAddress() {
|
||||||
|
return this.dev_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if I2C to this AT24C32 is opened
|
||||||
|
* @return true if opened
|
||||||
|
*/
|
||||||
|
public boolean getIsOpened() {
|
||||||
|
return iscorrect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write bytes to AT24C32
|
||||||
|
* AT24C32 only have 4096 bytes, addressed from 0 to 4095.
|
||||||
|
* @param start_address : 0 ~ 4095
|
||||||
|
* @param bb : bytes to write
|
||||||
|
* @return true if success
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
public boolean Write(int start_address, byte[] bb) {
|
||||||
|
if (start_address<0) {
|
||||||
|
raise_log("AT24C32 Write Fail, start_address invalid");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (start_address>4095) {
|
||||||
|
raise_log("AT24C32 Write Fail, start_address invalid");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bb==null) {
|
||||||
|
raise_log("AT24C32 Write Fail, bytes to write is null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bb.length<1) {
|
||||||
|
raise_log("AT24C32 Write Fail, bytes to write is less than 1");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bb.length>32) {
|
||||||
|
raise_log("AT24C32 Write Fail, bytes to write more than 32 bytes");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!iscorrect) {
|
||||||
|
raise_log("AT24C32 Write Fail, I2C not opened");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean result = false;
|
||||||
|
byte[] towrite = new byte[2+bb.length];
|
||||||
|
towrite[1] = (byte) (start_address);
|
||||||
|
towrite[0] = (byte) (start_address >> 8); // MSB di index 0
|
||||||
|
for(int ii=0;ii<bb.length;ii++) towrite[2+ii] = bb[ii];
|
||||||
|
|
||||||
|
int wr_result = i2cdev.WriteBytes(towrite);
|
||||||
|
if (wr_result==towrite.length) {
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
raise_log("AT24C32 Address+Data="+towrite.length+" bytes, Write Result="+wr_result+" bytes");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read bytes from AT24C32
|
||||||
|
* AT24C32 only have 4096 bytes, addressed from 0 to 4095
|
||||||
|
* @param start_address :: 0 ~ 4095
|
||||||
|
* @param readcount : number of bytes to read
|
||||||
|
* @return bytes array if success, or null if failed
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
public byte[] Read(int start_address, int readcount) {
|
||||||
|
if (start_address<0) {
|
||||||
|
raise_log("AT24C32 Read Fail, start_address invalid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (start_address>4095) {
|
||||||
|
raise_log("AT24C32 Read Fail, start_address invalid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!iscorrect) {
|
||||||
|
raise_log("AT24C32 Read Fail, I2C not opened");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] address = new byte[2];
|
||||||
|
address[1] = (byte) (start_address);
|
||||||
|
address[0] = (byte) (start_address>>8);
|
||||||
|
|
||||||
|
if (i2cdev.WriteBytes(address)==2) {
|
||||||
|
byte[] result = i2cdev.ReadBytes(readcount);
|
||||||
|
if (result!=null) {
|
||||||
|
if (result.length==readcount) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(myobject, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
///from I2C_BUS_Event and I2C_Device_Event
|
||||||
|
public void Log(String msg) {
|
||||||
|
raise_log(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
215
src/devices/Button.java
Normal file
215
src/devices/Button.java
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
package devices;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.DateTime;
|
||||||
|
import jGPIO.jGPIO;
|
||||||
|
import jGPIO.DigitalInput.DigitalInput;
|
||||||
|
import jGPIO.DigitalInput.DigitalInputEvent;
|
||||||
|
|
||||||
|
|
||||||
|
@BA.ShortName("HardwareButton")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"shortpressed(tick as long)",
|
||||||
|
"longpressed(tick as long)",
|
||||||
|
"currentstate(isON as boolean, tick as long)"
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button class
|
||||||
|
* use class DigitalInput
|
||||||
|
* Button is always Active Low, so Pin need to be Pull Up using Resistor to VCC
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Button implements DigitalInputEvent {
|
||||||
|
private DigitalInput di;
|
||||||
|
private BA bax;
|
||||||
|
private Object myobject;
|
||||||
|
private String event;
|
||||||
|
private int mypinnumber;
|
||||||
|
|
||||||
|
private Timer tt; // scan DigitalInput using timer
|
||||||
|
private final int timerms = 50; // timer trigger per 50 ms
|
||||||
|
private int statecounter = 0; // for detecting shortpressed or longpressed
|
||||||
|
private final int shortpresslimit = 4; // 4 x 50ms = 200ms
|
||||||
|
private final int longpresslimit = 40; // 40 x 50ms = 2000ms = 2 seconds
|
||||||
|
|
||||||
|
|
||||||
|
private boolean initialized = false;
|
||||||
|
|
||||||
|
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_shortpressed_event = false;
|
||||||
|
private boolean need_longpressed_event = false;
|
||||||
|
private boolean need_currentstate_event = false;
|
||||||
|
|
||||||
|
public Button() {
|
||||||
|
if (jGPIO.osname=="") jGPIO.detectOS();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean Initialize(BA ba, Object caller, String buttonname, int pin_number) {
|
||||||
|
myobject = caller;
|
||||||
|
bax = ba;
|
||||||
|
|
||||||
|
event = buttonname.trim();
|
||||||
|
mypinnumber = pin_number;
|
||||||
|
initialized = false;
|
||||||
|
|
||||||
|
if (bax!=null) {
|
||||||
|
if (caller!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_shortpressed_event = bax.subExists(event+"_shortpressed");
|
||||||
|
need_longpressed_event = bax.subExists(event+"_longpressed");
|
||||||
|
need_currentstate_event = bax.subExists(event+"_currentstate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (jGPIO.IsLinux==false) {
|
||||||
|
raise_log("Target device is not Linux");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
di = new DigitalInput();
|
||||||
|
di.SetJavaEvent(this); // link javaevent to this class
|
||||||
|
|
||||||
|
di.Initialize(bax, caller, event, pin_number);
|
||||||
|
|
||||||
|
if (di.getIsInitialized()) {
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TimerTask task = new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (di == null) {
|
||||||
|
cancel(); // stop timer
|
||||||
|
raise_log("DigitalInput is null, Button Timer stopped");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (di.getIsInitialized()==false) {
|
||||||
|
cancel(); // stop timer
|
||||||
|
raise_log("DigitalInput is not initialized, Button Timer stopped");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int value = di.ReadState();
|
||||||
|
|
||||||
|
if (value==-1) {
|
||||||
|
cancel(); // stop timer
|
||||||
|
raise_log("DigitalInput ReadState failed, Button Timer stopped");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (value==1) {
|
||||||
|
// high
|
||||||
|
if (statecounter>=shortpresslimit) {
|
||||||
|
if (statecounter<longpresslimit) {
|
||||||
|
raise_shortpressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statecounter = 0;
|
||||||
|
} else {
|
||||||
|
// low
|
||||||
|
if (statecounter<longpresslimit) {
|
||||||
|
statecounter+=1;
|
||||||
|
if (statecounter==longpresslimit) {
|
||||||
|
raise_longpressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
tt = new Timer();
|
||||||
|
tt.scheduleAtFixedRate(task, timerms, timerms);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
} else {
|
||||||
|
raise_log("Failed to Initialize DigitalInput on pinnumber="+pin_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsInitialized() {
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release() {
|
||||||
|
if (di instanceof DigitalInput) {
|
||||||
|
di.Release();
|
||||||
|
di = null;
|
||||||
|
}
|
||||||
|
if (tt != null) {
|
||||||
|
tt.cancel();
|
||||||
|
tt = null;
|
||||||
|
}
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getButtonName() {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPinNumber() {
|
||||||
|
return mypinnumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(myobject, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_shortpressed() {
|
||||||
|
if (need_shortpressed_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(myobject, null, 0, event+"_shortpressed", false, new Object[] {DateTime.getNow()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_longpressed() {
|
||||||
|
if (need_longpressed_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(myobject, null, 0, event+"_longpressed", false, new Object[] {DateTime.getNow()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_currentstate(boolean state) {
|
||||||
|
if (need_currentstate_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(myobject, null, 0, event+"_currentstate", false, new Object[] {state,DateTime.getNow()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public void error(int pinnumber, String Msg) {
|
||||||
|
// event from class DigitalInput
|
||||||
|
raise_log("Button error, pin="+pinnumber+", Msg = "+Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public void newinstate(int pinnumber, boolean isOn) {
|
||||||
|
// event from class DigitalInput
|
||||||
|
if (BA.debugMode) {
|
||||||
|
raise_log("Button pin="+pinnumber+" value = "+isOn);
|
||||||
|
}
|
||||||
|
raise_currentstate(isOn);
|
||||||
|
}
|
||||||
|
}
|
||||||
213
src/devices/Buzzer.java
Normal file
213
src/devices/Buzzer.java
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
package devices;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import jGPIO.jGPIO;
|
||||||
|
import jGPIO.DigitalOutput.DigitalOutput;
|
||||||
|
|
||||||
|
@BA.ShortName("buzzer")
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Buzzer class
|
||||||
|
* use class DigitalOutput
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Buzzer {
|
||||||
|
private DigitalOutput dox;
|
||||||
|
private int mypinnumber;
|
||||||
|
private BA ba;
|
||||||
|
private boolean initialized = false;
|
||||||
|
private boolean continuebuzzing = false;
|
||||||
|
private boolean activelow = false;
|
||||||
|
|
||||||
|
public Buzzer() {
|
||||||
|
if (jGPIO.osname=="") jGPIO.detectOS();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initialize buzzer Object
|
||||||
|
* @param pin_number : pin number connected to buzzer
|
||||||
|
* @param activelow : if true, logic low will turn ON buzzer, logic high will turn OFF buzzer
|
||||||
|
* @return true if Initialized
|
||||||
|
*/
|
||||||
|
public boolean Initialize(BA bax, int pin_number, boolean activelow) {
|
||||||
|
this.mypinnumber = pin_number;
|
||||||
|
this.ba = bax;
|
||||||
|
this.activelow = activelow;
|
||||||
|
initialized = false;
|
||||||
|
if (jGPIO.IsLinux==false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dox = new DigitalOutput();
|
||||||
|
dox.Initialize(this.ba, null, "digitalout", mypinnumber, false);
|
||||||
|
initialized = dox.getIsInitialized();
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
CloseBuzzer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Initialzied
|
||||||
|
* @return true if already initialized
|
||||||
|
*/
|
||||||
|
public boolean getIsInitialized() {
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop buzzing
|
||||||
|
*/
|
||||||
|
public void Stop_Buzzing() {
|
||||||
|
continuebuzzing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start continuous buzzing
|
||||||
|
*/
|
||||||
|
public void Start_Continuous_Buzzing() {
|
||||||
|
|
||||||
|
Thread tx = new Thread() {
|
||||||
|
public void run() {
|
||||||
|
if (digitaloutputready())
|
||||||
|
if (activelow) // turn ON
|
||||||
|
dox.SetLow();
|
||||||
|
else
|
||||||
|
dox.SetHigh();
|
||||||
|
else
|
||||||
|
return; // digital output not ready
|
||||||
|
|
||||||
|
continuebuzzing = true;
|
||||||
|
while (continuebuzzing) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break; // exit while
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (digitaloutputready())
|
||||||
|
if (activelow) // turn OFF
|
||||||
|
dox.SetHigh();
|
||||||
|
else
|
||||||
|
dox.SetLow();
|
||||||
|
|
||||||
|
continuebuzzing = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tx.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start pulsing with 1s ON and 2s OFF
|
||||||
|
*/
|
||||||
|
public void Start_LongPulse_Buzzing() {
|
||||||
|
Thread tx = new Thread() {
|
||||||
|
public void run() {
|
||||||
|
continuebuzzing = true;
|
||||||
|
while (continuebuzzing) {
|
||||||
|
if (digitaloutputready()) {
|
||||||
|
if (activelow) // turn ON
|
||||||
|
dox.SetLow();
|
||||||
|
else
|
||||||
|
dox.SetHigh();
|
||||||
|
} else {
|
||||||
|
break; // digital output not ready
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (digitaloutputready()) {
|
||||||
|
if (activelow) // turn OFF
|
||||||
|
dox.SetHigh();
|
||||||
|
else
|
||||||
|
dox.SetLow();
|
||||||
|
} else {
|
||||||
|
break; // digital output not ready
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuebuzzing = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tx.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start pulsing with 1s ON and 1s OFF
|
||||||
|
*/
|
||||||
|
public void Start_MediumPulse_Buzzing() {
|
||||||
|
Thread tx = new Thread() {
|
||||||
|
public void run() {
|
||||||
|
continuebuzzing = true;
|
||||||
|
while (continuebuzzing) {
|
||||||
|
if (digitaloutputready()) {
|
||||||
|
if (activelow) // turn ON
|
||||||
|
dox.SetLow();
|
||||||
|
else
|
||||||
|
dox.SetHigh();
|
||||||
|
} else {
|
||||||
|
break; // digital output not ready
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (digitaloutputready()) {
|
||||||
|
if (activelow) // turn OFF
|
||||||
|
dox.SetHigh();
|
||||||
|
else
|
||||||
|
dox.SetLow();
|
||||||
|
} else {
|
||||||
|
break; // digital output not ready
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuebuzzing = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tx.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean digitaloutputready() {
|
||||||
|
if (initialized==false) return false;
|
||||||
|
if (dox==null) return false;
|
||||||
|
return dox.getIsInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close buzzer
|
||||||
|
*/
|
||||||
|
public void CloseBuzzer() {
|
||||||
|
if (dox instanceof DigitalOutput) {
|
||||||
|
dox.Release();
|
||||||
|
dox = null;
|
||||||
|
}
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
132
src/devices/DHT/DHT_Data.java
Normal file
132
src/devices/DHT/DHT_Data.java
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
package devices.DHT;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.DateTime;
|
||||||
|
|
||||||
|
@BA.ShortName("DHT_Data")
|
||||||
|
public class DHT_Data {
|
||||||
|
|
||||||
|
private long tick;
|
||||||
|
private double temp;
|
||||||
|
private double hum;
|
||||||
|
private boolean isvalid;
|
||||||
|
|
||||||
|
public DHT_Data() {
|
||||||
|
tick = DateTime.getNow();
|
||||||
|
temp = -1;
|
||||||
|
hum = -1;
|
||||||
|
isvalid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DHT_Data(long raw_value){
|
||||||
|
tick = DateTime.getNow();
|
||||||
|
BA.Log("Raw Data = "+raw_value);
|
||||||
|
byte checkbyte = ((byte) raw_value);
|
||||||
|
int T_koma = ((byte) (raw_value>>8)) & 0xFF;
|
||||||
|
int T_int = ((byte) raw_value >> 16) & 0xFF;
|
||||||
|
int H_koma = ((byte) raw_value >> 24) & 0xFF;
|
||||||
|
int H_int = ((byte) raw_value >> 32) & 0xFF;
|
||||||
|
|
||||||
|
byte checkvalue = (byte)(T_koma + T_int + H_koma + H_int);
|
||||||
|
isvalid = (checkbyte == checkvalue ? true:false);
|
||||||
|
temp = (double)T_int + (T_koma / 10.0);
|
||||||
|
hum = (double)H_int + (H_koma / 10.0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DHT_Data(double temperature, double humidity){
|
||||||
|
tick = DateTime.getNow();
|
||||||
|
this.temp = temperature;
|
||||||
|
this.hum = humidity;
|
||||||
|
if (this.temp> 0) {
|
||||||
|
if (this.hum > 0) {
|
||||||
|
this.isvalid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Temperature
|
||||||
|
* @return -1 if invalid
|
||||||
|
*/
|
||||||
|
public double getTemperature() {
|
||||||
|
if (isvalid) {
|
||||||
|
return this.temp;
|
||||||
|
} else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Temperature in String
|
||||||
|
* @return N/A if not available
|
||||||
|
*/
|
||||||
|
public String getTemperatureString() {
|
||||||
|
if (isvalid) {
|
||||||
|
return temp+" C";
|
||||||
|
} else return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Humidity in String
|
||||||
|
* @return N/A if not available
|
||||||
|
*/
|
||||||
|
public String getHumidityString() {
|
||||||
|
if (isvalid) {
|
||||||
|
return hum+" %";
|
||||||
|
} else return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Humidity
|
||||||
|
* @return -1 if invalid
|
||||||
|
*/
|
||||||
|
public double getHumidity() {
|
||||||
|
if (isvalid)
|
||||||
|
return this.hum;
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Measurement Tick time
|
||||||
|
* @return tick in long
|
||||||
|
*/
|
||||||
|
public long getMeasurementTick() {
|
||||||
|
return this.tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Date of Measurement
|
||||||
|
* @return Date in string
|
||||||
|
*/
|
||||||
|
public String getMeasurement_Date() {
|
||||||
|
return DateTime.Date(tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Time of Measurement
|
||||||
|
* @return Time in String
|
||||||
|
*/
|
||||||
|
public String getMeasurement_Time() {
|
||||||
|
return DateTime.Time(tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if measurement data is valid
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
|
public boolean getIsValidMeasurement() {
|
||||||
|
return isvalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Summary in String
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
str.append("[").append(getMeasurement_Date()).append(" ").append(getMeasurement_Time()).append("] ");
|
||||||
|
str.append("Temperature:").append(this.temp).append(" C, ");
|
||||||
|
str.append("Humidity:").append(this.hum).append(" %, ");
|
||||||
|
str.append("Valid:").append(this.isvalid);
|
||||||
|
return str.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
199
src/devices/DHT/SensorDHT.java
Normal file
199
src/devices/DHT/SensorDHT.java
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
package devices.DHT;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import jGPIO.jGPIO;
|
||||||
|
|
||||||
|
|
||||||
|
@BA.ShortName("SensorDHT")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"measurement(value as DHT_Data)"
|
||||||
|
})
|
||||||
|
public class SensorDHT {
|
||||||
|
|
||||||
|
private BA bax;
|
||||||
|
private Object caller;
|
||||||
|
private String event;
|
||||||
|
private Object Me = this;
|
||||||
|
|
||||||
|
private boolean inited = false;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_measurement_event = false;
|
||||||
|
|
||||||
|
private File sensorpath;
|
||||||
|
private File humiditypath;
|
||||||
|
private File temperaturepath;
|
||||||
|
|
||||||
|
public SensorDHT() {
|
||||||
|
if (jGPIO.osname=="") jGPIO.detectOS();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize DHT Sensor
|
||||||
|
* @param callerobject : callback object
|
||||||
|
* @param eventname : eventname
|
||||||
|
* @param pinnumber : pin number
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object callerobject, String eventname, int pinnumber) {
|
||||||
|
this.bax = ba;
|
||||||
|
this.caller = callerobject;
|
||||||
|
this.event = eventname;
|
||||||
|
inited = false;
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (caller!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
if (bax.subExists(event+"_log")) {
|
||||||
|
need_log_event = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (bax.subExists(event+"_measurement")) {
|
||||||
|
need_measurement_event = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!jGPIO.IsLinux) {
|
||||||
|
raise_log("System is not Linux, SensorDHT can't be used");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String path = "/sys/devices/platform/dht11@"+pinnumber+"/iio:device0";
|
||||||
|
sensorpath = new File(path);
|
||||||
|
if (sensorpath.exists()) {
|
||||||
|
humiditypath = new File(path,"in_humidityrelative_input");
|
||||||
|
temperaturepath = new File(path, "in_temp_input");
|
||||||
|
if (humiditypath.exists()) {
|
||||||
|
if (temperaturepath.exists()) {
|
||||||
|
inited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inited) {
|
||||||
|
if (!humiditypath.exists()) raise_log("Humidity Path is invalid");
|
||||||
|
if (!temperaturepath.exists()) raise_log("Temperature Path is invalid");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
raise_log("DHT Sensor not found, put dtoverlay=dht11,gpiopin=pinnumber at /boot/config.txt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if Already Initialized
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
return inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Measure Temperature and Humidity
|
||||||
|
* Will raise event measurement(value as DHT_Data)
|
||||||
|
* Between Read, must interval at least 2 seconds
|
||||||
|
* @return true if measurement success
|
||||||
|
*/
|
||||||
|
public boolean Read_Measurement() {
|
||||||
|
if (inited) {
|
||||||
|
try {
|
||||||
|
double tt = Read_DHT_Value(temperaturepath);
|
||||||
|
double hh = Read_DHT_Value(humiditypath);
|
||||||
|
DHT_Data result = new DHT_Data(tt, hh);
|
||||||
|
raise_measurement(result);
|
||||||
|
return result.getIsValidMeasurement();
|
||||||
|
} catch (Exception e) {
|
||||||
|
raise_log("Failed Measurement, Exception="+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read DHT Sensor
|
||||||
|
*
|
||||||
|
* @param path : path of sensor
|
||||||
|
* @return -1 if failed
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private double Read_DHT_Value(File path) {
|
||||||
|
double result = -1;
|
||||||
|
if (path != null) {
|
||||||
|
if (path.exists()) {
|
||||||
|
if (path.canRead()) {
|
||||||
|
String stringresult;
|
||||||
|
BufferedReader reader;
|
||||||
|
try {
|
||||||
|
reader = new BufferedReader(new FileReader(path.getAbsolutePath()));
|
||||||
|
stringresult = reader.readLine();
|
||||||
|
reader.close();
|
||||||
|
if (stringresult!=null) {
|
||||||
|
if (!stringresult.isEmpty()) {
|
||||||
|
result = Double.valueOf(stringresult)/1000.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e1) {
|
||||||
|
raise_log("Read_DHT_Value exception, Msg : "+e1.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read current Temperature
|
||||||
|
* Between Read , must interval at least 2 seconds
|
||||||
|
* @return -1 if failed
|
||||||
|
*/
|
||||||
|
public double Read_Temperature() {
|
||||||
|
if (inited) {
|
||||||
|
try {
|
||||||
|
double tt = Read_DHT_Value(temperaturepath);
|
||||||
|
return tt;
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read current Humidity
|
||||||
|
* Between Read, must interval at least 2 seconds
|
||||||
|
* @return -1 if failed
|
||||||
|
*/
|
||||||
|
public double Read_Humidity() {
|
||||||
|
if (inited) {
|
||||||
|
try {
|
||||||
|
double hh = Read_DHT_Value(humiditypath);
|
||||||
|
return hh;
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_measurement(DHT_Data value) {
|
||||||
|
if (need_measurement_event) {
|
||||||
|
|
||||||
|
bax.raiseEventFromDifferentThread(Me, null, 0, event+"_measurement", false, new Object[] {value});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
197
src/devices/FA/Simplex4100/Simplex4100.java
Normal file
197
src/devices/FA/Simplex4100/Simplex4100.java
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
package devices.FA.Simplex4100;
|
||||||
|
|
||||||
|
import com.fazecast.jSerialComm.SerialPort;
|
||||||
|
import com.fazecast.jSerialComm.SerialPortEvent;
|
||||||
|
import com.fazecast.jSerialComm.SerialPortInvalidPortException;
|
||||||
|
import com.fazecast.jSerialComm.SerialPortMessageListener;
|
||||||
|
import com.intelligt.modbus.jlibmodbus.serial.SerialPort.Parity;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.objects.collections.Map;
|
||||||
|
|
||||||
|
@BA.ShortName("Simplex4100")
|
||||||
|
//@BA.DependsOn(values = { "jSerialComm-2.6.2" })
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"rxbytes(portname as string, bb() as byte)",
|
||||||
|
"newdata(value as Simplex4100Data)",
|
||||||
|
"statuschanged(oldvalue as Simplex4100Data, newvalue as Simplex4100Data)"
|
||||||
|
})
|
||||||
|
public class Simplex4100 {
|
||||||
|
|
||||||
|
private BA bax;
|
||||||
|
private String event = "";
|
||||||
|
private Object caller;
|
||||||
|
private final Object Me = this;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_rxbytes_event = false;
|
||||||
|
private boolean need_newdata_event = false;
|
||||||
|
private boolean need_statuschanged_event = false;
|
||||||
|
|
||||||
|
private boolean inited = false;
|
||||||
|
private boolean isopened = false;
|
||||||
|
private String portname;
|
||||||
|
private SerialPort myport;
|
||||||
|
private Map EventMap = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Simplex 4100 Protocol Listener
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param eventname : eventname
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object callerobject, String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
caller = callerobject;
|
||||||
|
event = eventname.trim();
|
||||||
|
EventMap.Initialize();
|
||||||
|
|
||||||
|
if (bax instanceof BA) {
|
||||||
|
if (caller!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_rxbytes_event = bax.subExists(event+"_rxbytes");
|
||||||
|
need_newdata_event = bax.subExists(event+"_newdata");
|
||||||
|
need_statuschanged_event = bax.subExists(event+"_statuschanged");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SerialPort.getVersion()!="") inited = true; else inited = false;
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ClosePort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Simplex 4100 already initalized
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
|
public boolean IsInitialized() {
|
||||||
|
return inited;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if SerialPort is opened
|
||||||
|
* @return true if opened
|
||||||
|
*/
|
||||||
|
public boolean PortIsOpened() {
|
||||||
|
return isopened;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SimplexEvent implements SerialPortMessageListener{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getListeningEvents() {
|
||||||
|
// tertarik sama event ini doang
|
||||||
|
return SerialPort.LISTENING_EVENT_DATA_RECEIVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialEvent(SerialPortEvent event) {
|
||||||
|
if (event instanceof SerialPortEvent) {
|
||||||
|
if (event.getEventType()== SerialPort.LISTENING_EVENT_DATA_RECEIVED) {
|
||||||
|
byte[] msg = event.getReceivedData();
|
||||||
|
if (msg!=null) {
|
||||||
|
if (msg.length>0) {
|
||||||
|
raise_rxbytes(msg); // raise event for raw bytes
|
||||||
|
Simplex4100Data vv = new Simplex4100Data(new String(msg));
|
||||||
|
raise_newdata(vv); // taruh di sini dulu , supaya keluar event
|
||||||
|
|
||||||
|
if (vv.getIsValid()) {
|
||||||
|
if (EventMap.IsInitialized()==false) EventMap.Initialize();
|
||||||
|
Object old = EventMap.Put(vv.getDetectorLocation(), vv);
|
||||||
|
if (old instanceof Simplex4100Data) {
|
||||||
|
raise_statuschanged((Simplex4100Data)old,vv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getMessageDelimiter() {
|
||||||
|
// CR - LF
|
||||||
|
return new byte[] {(byte) 13, (byte) 10};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delimiterIndicatesEndOfMessage() {
|
||||||
|
// delimiter adalah akhir dari message
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open SerialPort for communication with Simplex 4100
|
||||||
|
* @param portname : portname
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean OpenPort(String portname) {
|
||||||
|
if (!portname.isEmpty()) {
|
||||||
|
try {
|
||||||
|
myport = SerialPort.getCommPort(portname);
|
||||||
|
} catch(SerialPortInvalidPortException e) {
|
||||||
|
myport = null;
|
||||||
|
raise_log("Error getCommPort for "+portname+", Msg : "+e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myport instanceof SerialPort) {
|
||||||
|
if (myport.openPort()) {
|
||||||
|
this.portname = portname;
|
||||||
|
if (myport.setBaudRate(9600)) {
|
||||||
|
if (myport.setNumDataBits(8)) {
|
||||||
|
if (myport.setNumStopBits(1)) {
|
||||||
|
if (myport.setParity(Parity.NONE.getValue())) {
|
||||||
|
myport.addDataListener(new SimplexEvent());
|
||||||
|
|
||||||
|
isopened = true;
|
||||||
|
return true; // success
|
||||||
|
} else raise_log("Unable to set Parity None");
|
||||||
|
} else raise_log("Unable to set Stopbit 1");
|
||||||
|
} else raise_log("Unable to set Databits 8");
|
||||||
|
} else raise_log("Unable to set Baudrate 9600");
|
||||||
|
} else raise_log("Unable to OpenPort");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Serial Port connected to Simplex 4100
|
||||||
|
*/
|
||||||
|
public void ClosePort() {
|
||||||
|
isopened = false;
|
||||||
|
if (myport instanceof SerialPort) {
|
||||||
|
myport.removeDataListener();
|
||||||
|
myport.closePort();
|
||||||
|
myport = null;
|
||||||
|
raise_log("Serial Port Closed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_rxbytes(byte[] bb) {
|
||||||
|
if (need_rxbytes_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_rxbytes", false, new Object[] {portname, bb});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_newdata(Simplex4100Data value) {
|
||||||
|
if (need_newdata_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_newdata", false, new Object[] {value});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_statuschanged(Simplex4100Data oldvalue, Simplex4100Data newvalue) {
|
||||||
|
if (need_statuschanged_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_statuschanged", false, new Object[] {oldvalue, newvalue});
|
||||||
|
}
|
||||||
|
}
|
||||||
214
src/devices/FA/Simplex4100/Simplex4100Data.java
Normal file
214
src/devices/FA/Simplex4100/Simplex4100Data.java
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
package devices.FA.Simplex4100;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.Bit;
|
||||||
|
import anywheresoftware.b4a.keywords.DateTime;
|
||||||
|
import anywheresoftware.b4a.keywords.Regex;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
|
||||||
|
@BA.ShortName("Simplex4100Data")
|
||||||
|
public class Simplex4100Data {
|
||||||
|
|
||||||
|
private boolean valid_data = false;
|
||||||
|
private String datastring;
|
||||||
|
private String exceptionmsg;
|
||||||
|
private long datetimetick = 0;
|
||||||
|
private String _detectorlocation="";
|
||||||
|
private String _detectorstatus="";
|
||||||
|
|
||||||
|
public Simplex4100Data() {
|
||||||
|
datastring = "";
|
||||||
|
exceptionmsg = "";
|
||||||
|
}
|
||||||
|
public Simplex4100Data(String msg) {
|
||||||
|
this();
|
||||||
|
Analyze(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to analyze a string
|
||||||
|
* @param msg : Simplex String
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
|
public boolean Analyze(String msg) {
|
||||||
|
valid_data = false;
|
||||||
|
|
||||||
|
if (msg!=null) {
|
||||||
|
if (msg.length()>0) {
|
||||||
|
datastring = msg.trim();
|
||||||
|
Check_Validity();
|
||||||
|
} else datastring = "";
|
||||||
|
} else datastring = "";
|
||||||
|
|
||||||
|
return valid_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Data is valid
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
|
public boolean getIsValid() {
|
||||||
|
return valid_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Contoh :
|
||||||
|
// -134424-6250108 @2-2-0 T1* --> trouble
|
||||||
|
// -134319-6250108 @2-2-0 T1- --> trouble acknowledged
|
||||||
|
// -134335-6250108 @2-2-0 T0- --> trouble selesai
|
||||||
|
// -134424-6250108 @2-2-0 F1* --> ada fire
|
||||||
|
// -134430-6250108 @2-2-0 F1- --> fire acknowledged
|
||||||
|
// -134515-6250108 @2-2-0 F0- --> fire sudah normal
|
||||||
|
|
||||||
|
private void Check_Validity() {
|
||||||
|
valid_data = false;
|
||||||
|
if (datastring == null) {
|
||||||
|
exceptionmsg = "Data is null";
|
||||||
|
} else if (datastring.isEmpty()) {
|
||||||
|
exceptionmsg = "Data is empty";
|
||||||
|
} else {
|
||||||
|
String[] cmds = Regex.Split(" ", datastring);
|
||||||
|
if (cmds.length>=3) {
|
||||||
|
if (cmds[0].startsWith("-")) {
|
||||||
|
if (cmds[1].startsWith("@")) {
|
||||||
|
if (cmds[2].length()>=3) {
|
||||||
|
|
||||||
|
// Date and Time part
|
||||||
|
boolean valid_date = false;
|
||||||
|
this.datetimetick = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
String timereceived = cmds[0].substring(1, 7); // skip '-' awal, sampai sebelum '-' di tengah
|
||||||
|
String datereceived = cmds[0].substring(9); // skip '-6'
|
||||||
|
|
||||||
|
String old_dateformat = DateTime.getDateFormat();
|
||||||
|
String old_timeformat = DateTime.getTimeFormat();
|
||||||
|
|
||||||
|
DateTime.setDateFormat("ddMMyy");
|
||||||
|
DateTime.setTimeFormat("HHmmss");
|
||||||
|
|
||||||
|
datetimetick = DateTime.DateTimeParse(datereceived, timereceived);
|
||||||
|
|
||||||
|
// sampe sini sudah berhasil parse
|
||||||
|
// balikin ke format awal
|
||||||
|
DateTime.setDateFormat(old_dateformat);
|
||||||
|
DateTime.setTimeFormat(old_timeformat);
|
||||||
|
|
||||||
|
valid_date = true;
|
||||||
|
|
||||||
|
} catch(IndexOutOfBoundsException e) {
|
||||||
|
exceptionmsg = "Invalid Date Time String";
|
||||||
|
return;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
exceptionmsg = "Failed parsing Date Time";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valid_date) return;
|
||||||
|
|
||||||
|
// Detector Address Part
|
||||||
|
this._detectorlocation = cmds[1].substring(1).trim();
|
||||||
|
if (this._detectorlocation.isEmpty()) {
|
||||||
|
exceptionmsg = "Empty Detector Location";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detector Status Part
|
||||||
|
_detectorstatus = cmds[2].trim();
|
||||||
|
if (this._detectorstatus.isEmpty()) {
|
||||||
|
exceptionmsg = "Empty Detector Status";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid_data = true;
|
||||||
|
|
||||||
|
} else exceptionmsg = "Invalid Detector Status Part";
|
||||||
|
} else exceptionmsg = "Invalid Detector Address Part";
|
||||||
|
} else exceptionmsg = "Invalid Date Time Part";
|
||||||
|
} else exceptionmsg = "Regex is not 3";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print original protocol string to byte string for ASCII examination
|
||||||
|
* @param mode : 0 = desimal, 1 = hexadesimal
|
||||||
|
* @return "null" if data is null, "0" if data length 0, or data bytes separated with space(32)
|
||||||
|
*/
|
||||||
|
public String GetByteString(int mode) {
|
||||||
|
if (datastring==null) {
|
||||||
|
return "null";
|
||||||
|
} else if (datastring.isEmpty()) {
|
||||||
|
return "0";
|
||||||
|
} else {
|
||||||
|
byte[] datanya = datastring.getBytes();
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
for(byte xx : datanya) {
|
||||||
|
if (str.length()>0) str.append(" ");
|
||||||
|
if (mode>0)
|
||||||
|
str.append(Bit.ToHexString(Bit.And(xx, 0xFF)));
|
||||||
|
else
|
||||||
|
str.append(Bit.And(xx, 0xFF));
|
||||||
|
}
|
||||||
|
return str.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Original Protocol String
|
||||||
|
* @return protocol string
|
||||||
|
*/
|
||||||
|
public String GetOriginalProtocolString() {
|
||||||
|
return datastring;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if IsValid() return false, check Exception message here
|
||||||
|
* @return exception message if available, or null if not available
|
||||||
|
*/
|
||||||
|
public String getExceptionMessage() {
|
||||||
|
return exceptionmsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Date Received
|
||||||
|
* @return if not valid, return empty string
|
||||||
|
*/
|
||||||
|
public String getDateReceived() {
|
||||||
|
if (datetimetick>0) return DateTime.Date(datetimetick); else return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Time Received
|
||||||
|
* @return if not valid, return empty string
|
||||||
|
*/
|
||||||
|
public String getTimeReceived() {
|
||||||
|
if (datetimetick>0) return DateTime.Time(datetimetick); else return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Detector Location
|
||||||
|
* Detector Location is device(FA sensor) identification
|
||||||
|
* @return if not valid, return empty string
|
||||||
|
*/
|
||||||
|
public String getDetectorLocation() {
|
||||||
|
return _detectorlocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Detector Status
|
||||||
|
* status =
|
||||||
|
* T1* --> Detector have trouble
|
||||||
|
* T1- --> Trouble have been acknowledged
|
||||||
|
* T0- --> Trouble have been solved
|
||||||
|
* F1* --> Fire detected
|
||||||
|
* F1- --> Fire have been acknowledged
|
||||||
|
* F0- --> Fire have been solved
|
||||||
|
* @return if not valid, return empty string
|
||||||
|
*/
|
||||||
|
public String getDetectorStatus() {
|
||||||
|
return _detectorstatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/devices/IntPointer.java
Normal file
16
src/devices/IntPointer.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package devices;
|
||||||
|
|
||||||
|
import com.sun.jna.ptr.IntByReference;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.keywords.Bit;
|
||||||
|
|
||||||
|
public class IntPointer extends IntByReference {
|
||||||
|
|
||||||
|
public IntPointer() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toHex() {
|
||||||
|
return Bit.ToHexString(super.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
574
src/devices/JSecureDongleV2.java
Normal file
574
src/devices/JSecureDongleV2.java
Normal file
@@ -0,0 +1,574 @@
|
|||||||
|
package devices;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import com.sun.jna.Memory;
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.ptr.IntByReference;
|
||||||
|
import com.sun.jna.ptr.ShortByReference;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import jGPIO.mycodes;
|
||||||
|
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"finddongle(success as boolean , harwareID as int, message as string)",
|
||||||
|
"opendongle(success as boolean, hardwareID as int, SessionHandle as int, message as string)",
|
||||||
|
"closedongle(success as boolean, SessionHandle as int, message as string)",
|
||||||
|
"readuserdatazone(success as boolean, SessionHandle as int, data() as byte, message as string)",
|
||||||
|
"writeuserdatazone(success as boolean, SessionHandle as int, message as string)",
|
||||||
|
"readuserid(success as boolean, SessionHandle as int, UserID as int, message as string)",
|
||||||
|
"writeuserid(success as boolean, SessionHandle as int, message as string)"
|
||||||
|
})
|
||||||
|
@BA.ShortName("JSecureDongleV2")
|
||||||
|
public class JSecureDongleV2 {
|
||||||
|
private final int SD_FIND = 1;//Find Dongle
|
||||||
|
private final int SD_FIND_NEXT = 2;//Find Next Dongle
|
||||||
|
private final int SD_OPEN = 3;//Open Dongle
|
||||||
|
private final int SD_CLOSE = 4;//Close Dongle
|
||||||
|
private final int SD_READ = 5 ; //Read Dongle
|
||||||
|
private final int SD_WRITE = 6 ; //Write Dongle
|
||||||
|
private final int SD_RANDOM = 7;//Generate Random Number
|
||||||
|
private final int SD_SEED = 8;//Generate Seed Code
|
||||||
|
private final int SD_WRITE_USERID=9;//Write User ID
|
||||||
|
private final int SD_READ_USERID= 10;//Read User ID
|
||||||
|
private final int SD_SET_MODULE= 11;//Set Module
|
||||||
|
private final int SD_CHECK_MODULE=12;//Check Module
|
||||||
|
private final int SD_WRITE_ARITHMETIC=13;//Write Algorithm
|
||||||
|
private final int SD_CALCULATE1= 14;//Calculate 1
|
||||||
|
private final int SD_CALCULATE2= 15;//Calculate 2
|
||||||
|
private final int SD_CALCULATE3= 16;//Calculate 3
|
||||||
|
private final int SD_CALCULATE4= 18;//Calculate 4
|
||||||
|
private final int SD_CALCULATE5= 19;//Calculate 5
|
||||||
|
private final int SD_DECREASE= 17;//Decrease Module Unit
|
||||||
|
|
||||||
|
private final int SD_SETPASSWORDID =0xf0;
|
||||||
|
private final int SD_AGENTBURN =0xf3;
|
||||||
|
private final int SD_GETVERSION=0xf7;
|
||||||
|
|
||||||
|
private final int SD_SET_COUNTER=20;//Set Counter
|
||||||
|
private final int SD_GET_COUNTER= 21;//Get Counter
|
||||||
|
private final int SD_DEC_COUNTER=22;
|
||||||
|
private final int SD_SET_TIMER=23;//Set Timer
|
||||||
|
private final int SD_GET_TIMER= 24;//Get Timer
|
||||||
|
private final int SD_ADJUST_TIMER=25; //Adjust System Clock
|
||||||
|
private final int SD_SET_TIMER_ITV=26;
|
||||||
|
private final int SD_GET_TIMER_ITV=27;
|
||||||
|
private final int SD_DEC_TIMER=28;
|
||||||
|
private final int SD_SET_RSAKEY_N=29;//Write N into RSA keypair
|
||||||
|
private final int SD_SET_RSAKEY_D=30;//Write D into RSA keypair
|
||||||
|
private final int SD_UPDATE_GEN_HEADER= 31;//Generate header of cipher-text file
|
||||||
|
private final int SD_UPDATE_GEN=32;//Generate cipher-text file
|
||||||
|
private final int SD_UPDATE_CHECK=33;//Check and Upgrade cipher-text file
|
||||||
|
private final int SD_UPDATE=34;//Upgrade cipher-text file
|
||||||
|
private final int SD_UNPACK= 35;
|
||||||
|
|
||||||
|
|
||||||
|
private final int SD_FREEEPROM= 89;
|
||||||
|
|
||||||
|
// private final int SD_TESTXU= 0xA1 //jw test cos
|
||||||
|
|
||||||
|
//private final int SD_GET_DES_KEY==41
|
||||||
|
private final int SD_SET_DES_KEY= 41;//Set DES Key
|
||||||
|
private final int SD_DES_ENC=42;//DES Encryption
|
||||||
|
private final int SD_DES_DEC=43;//DES Decryption
|
||||||
|
private final int SD_RSA_ENC=44;//RSA Encryption=
|
||||||
|
private final int SD_RSA_DEC=45;//RSA Decryption
|
||||||
|
|
||||||
|
private final int SD_READ_EX =46;
|
||||||
|
private final int SD_WRITE_EX=47;
|
||||||
|
|
||||||
|
private final int SD_SET_COUNTER_EX=0xA0; //Set value to Count Unit (DWORD)
|
||||||
|
private final int SD_GET_COUNTER_EX=0xA1; //Get value from Count Unit (DWORD)
|
||||||
|
private final int SD_SET_TIMER_EX= 0xA2; //Set value to Time Unit (DWORD)
|
||||||
|
private final int SD_GET_TIMER_EX= 0xA3; //Get value from Time Unit (DWORD)
|
||||||
|
private final int SD_ADJUST_TIMER_EX=0xA4; //Adjust Timer in Dongle
|
||||||
|
|
||||||
|
private final int SD_UPDATE_GEN_EX=0xA6; //Generate Update File
|
||||||
|
|
||||||
|
private final int SD_UPDATE_EX= 0xA8; //Update Dongle
|
||||||
|
private final int SD_SET_UPDATE_KEY=0xA9; //Set RSA Keys for Generate Update File
|
||||||
|
private final int SD_ADD_UPDATE_HEADER= 0xAA; //Fill in the content of Update File Head
|
||||||
|
private final int SD_ADD_UPDATE_CONTENT= 0xAB; //Fill in the content of Update File Body
|
||||||
|
private final int SD_GET_TIME_DWORD=0xAC; //Translate Time to DWORD value (the minutes from 2006.1.1)
|
||||||
|
|
||||||
|
private final int SD_VERSION= 100; //Get COS Version
|
||||||
|
|
||||||
|
//add by bgc on 09/2006
|
||||||
|
private final int DES_SINGLE_MODE=0;
|
||||||
|
private final int DES_TRIPLE_MODE=1;
|
||||||
|
|
||||||
|
private final int RSA_PRIVATE_KEY=0;
|
||||||
|
private final int RSA_PUBLIC_KEY=1;
|
||||||
|
|
||||||
|
private final int RSA_DONGLE_PADDING=0;
|
||||||
|
private final int RSA_USER_PADDING=1;
|
||||||
|
//end
|
||||||
|
|
||||||
|
private String GetErrorMessage(int code) {
|
||||||
|
switch(code) {
|
||||||
|
case ERR_SUCCESS :
|
||||||
|
return "Success";
|
||||||
|
case ERR_NO_DONGLE :
|
||||||
|
return "No Driver installed";
|
||||||
|
case ERR_INVALID_PASSWORD :
|
||||||
|
return "Found Dongle, but basic passwords (pass1, pass2) are wrong";
|
||||||
|
case ERR_INVALID_PASSWORD_OR_ID :
|
||||||
|
return "Wrong password or Hardware ID";
|
||||||
|
case ERR_SETID :
|
||||||
|
return "Error in Hardware ID setting";
|
||||||
|
case ERR_INVALID_ADDR_OR_SIZE :
|
||||||
|
return "Error in read/write address or length";
|
||||||
|
case ERR_UNKNOWN_COMMAND :
|
||||||
|
return "No such command";
|
||||||
|
case ERR_NOTBELEVEL3 :
|
||||||
|
return "Internal Error";
|
||||||
|
case ERR_READ :
|
||||||
|
return "Read Error";
|
||||||
|
case ERR_WRITE :
|
||||||
|
return "Write Error";
|
||||||
|
case ERR_RANDOM :
|
||||||
|
return "Random Number Error";
|
||||||
|
case ERR_SEED :
|
||||||
|
return "Seed Code Error";
|
||||||
|
case ERR_CALCULATE :
|
||||||
|
return "Error in Calculation";
|
||||||
|
case ERR_NO_OPEN :
|
||||||
|
return "Unopen dongle before operation";
|
||||||
|
case ERR_OPEN_OVERFLOW :
|
||||||
|
return "Too many open dongles (>16)";
|
||||||
|
case ERR_NOMORE :
|
||||||
|
return "No more dongles";
|
||||||
|
case ERR_NEED_FIND :
|
||||||
|
return "No 'Find' function called before using 'FindNext'";
|
||||||
|
case ERR_DECREASE :
|
||||||
|
return "Decrease Error";
|
||||||
|
case ERR_AR_BADCOMMAND :
|
||||||
|
return "Error in Arithmetic Instruction";
|
||||||
|
case ERR_AR_UNKNOWN_OPCODE :
|
||||||
|
return "Error in Arithmetic Operator";
|
||||||
|
case ERR_AR_WRONGBEGIN :
|
||||||
|
return "Constant cannot be used in the first arithmetic instruction";
|
||||||
|
case ERR_AR_WRONG_END :
|
||||||
|
return "Constant cannot be used in the last arithmetic instruction";
|
||||||
|
case ERR_AR_VALUEOVERFLOW :
|
||||||
|
return "The value of Constant cannot be greater than 63";
|
||||||
|
case ERR_TOOMUCHTHREAD :
|
||||||
|
return "The threads opened in the same process cannot be greater than 100";
|
||||||
|
case ERR_SET_DES_KEY :
|
||||||
|
return "Set DES Key Error";
|
||||||
|
case ERR_DES_ENCRYPT :
|
||||||
|
return "DES Encryption Error";
|
||||||
|
case ERR_DES_DECRYPT :
|
||||||
|
return "DES Decryption Error";
|
||||||
|
case ERR_SET_RSAKEY_N :
|
||||||
|
return "Error in writing N into RSA keypair";
|
||||||
|
case ERR_SET_RSAKEY_D :
|
||||||
|
return "Error in writing D into RSA keypair";
|
||||||
|
case ERR_RSA_ENCRYPT :
|
||||||
|
return "RSA Encryption Error";
|
||||||
|
case ERR_RSA_DECRYPT :
|
||||||
|
return "RSA Decryption Error";
|
||||||
|
case ERR_INVALID_LENGTH :
|
||||||
|
return "Invalid data length";
|
||||||
|
case ERR_RECEIVE_NULL :
|
||||||
|
return "Receive nothing";
|
||||||
|
case ERR_UNKNOWN_SYSTEM :
|
||||||
|
return "Unknown Operating System";
|
||||||
|
case ERROR_UNINIT_TIME_UNIT :
|
||||||
|
return "Time uint uninitialized";
|
||||||
|
case ERR_UNKNOWN :
|
||||||
|
return "Unknown Error";
|
||||||
|
default :
|
||||||
|
return "Misterious Error, code = "+String.valueOf(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Error Codes
|
||||||
|
private final int ERR_SUCCESS = 0; //Success
|
||||||
|
private final int ERR_NO_DONGLE = 3; // No driver installed
|
||||||
|
private final int ERR_INVALID_PASSWORD = 4; //Found Dongle, but basic passwords (pass1, pass2) are wrong
|
||||||
|
private final int ERR_INVALID_PASSWORD_OR_ID = 5; //Wrong password or Hardware ID
|
||||||
|
private final int ERR_SETID=6; //Error in Hardware ID setting
|
||||||
|
private final int ERR_INVALID_ADDR_OR_SIZE = 7; //Error in read/write address or length
|
||||||
|
private final int ERR_UNKNOWN_COMMAND=8; //No such command
|
||||||
|
private final int ERR_NOTBELEVEL3= 9; //Internal Error
|
||||||
|
private final int ERR_READ=10; //Read Error
|
||||||
|
private final int ERR_WRITE=11; //Write Error
|
||||||
|
private final int ERR_RANDOM=12; //Random Number Error
|
||||||
|
private final int ERR_SEED=13; //Seed Code Error
|
||||||
|
private final int ERR_CALCULATE=14; //Error in Calculation
|
||||||
|
private final int ERR_NO_OPEN= 15; //Unopen dongle before operation
|
||||||
|
private final int ERR_OPEN_OVERFLOW=16; //Too many open dongles (>16)
|
||||||
|
private final int ERR_NOMORE=17; //No more dongles
|
||||||
|
private final int ERR_NEED_FIND=18; //No "Find" function called before using "FindNext"
|
||||||
|
private final int ERR_DECREASE=19; //Decrease Error
|
||||||
|
private final int ERR_AR_BADCOMMAND=20; //Error in Arithmetic Instruction
|
||||||
|
private final int ERR_AR_UNKNOWN_OPCODE=21; //Error in Arithmetic Operator
|
||||||
|
private final int ERR_AR_WRONGBEGIN=22; //Constant cannot be used in the first arithmetic instruction
|
||||||
|
private final int ERR_AR_WRONG_END=23; //Constant cannot be used in the last arithmetic instruction
|
||||||
|
private final int ERR_AR_VALUEOVERFLOW=24; //The value of Constant cannot be greater than 63
|
||||||
|
private final int ERR_TOOMUCHTHREAD=25; //The threads opened in the same process cannot be greater than 100
|
||||||
|
|
||||||
|
private final int ERR_INVALID_SD=30; //Try to handle non-Securedongle
|
||||||
|
private final int ERR_INVALID_PARAMETER= 31 ;//Invalid parameter
|
||||||
|
private final int ERR_INVALID_TIMEVALUE= 32; //Invalid Date-Time value
|
||||||
|
|
||||||
|
//Set DES Key Error
|
||||||
|
private final int ERR_SET_DES_KEY= 40;
|
||||||
|
|
||||||
|
//DES Encryption Error
|
||||||
|
private final int ERR_DES_ENCRYPT= 41;
|
||||||
|
|
||||||
|
//DES Decryption Error
|
||||||
|
private final int ERR_DES_DECRYPT= 42;
|
||||||
|
|
||||||
|
//Error in writing N into RSA keypair
|
||||||
|
private final int ERR_SET_RSAKEY_N=43;
|
||||||
|
|
||||||
|
//Error in writing D into RSA keypair
|
||||||
|
private final int ERR_SET_RSAKEY_D=44;
|
||||||
|
|
||||||
|
//RSA Encryption Error
|
||||||
|
private final int ERR_RSA_ENCRYPT= 45;
|
||||||
|
|
||||||
|
//RSA Decryption Error
|
||||||
|
private final int ERR_RSA_DECRYPT= 46;
|
||||||
|
|
||||||
|
//Invalid data length
|
||||||
|
private final int ERR_INVALID_LENGTH=47;
|
||||||
|
|
||||||
|
private final int ERR_RECEIVE_NULL=0x100; //Receive nothing
|
||||||
|
private final int ERR_UNKNOWN_SYSTEM=0x102; //Unknown Operating System
|
||||||
|
private final int ERROR_UNINIT_TIME_UNIT = 0x103; //Time uint uninitialized
|
||||||
|
private final int ERR_UNKNOWN= 0xffff; //Unknown Error
|
||||||
|
|
||||||
|
private final int ERR_XUTEST=0xAA;
|
||||||
|
|
||||||
|
native short SecureDongle(short function, ShortByReference handle, IntByReference lp1, IntByReference lp2, ShortByReference p1, ShortByReference p2, ShortByReference p3, ShortByReference p4, Memory buffer);
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Native.register(JSecureDongleV2.class,"SecureDongle");
|
||||||
|
System.out.println("SecureDongle library loaded");
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.out.println("Unable to register SecureDongle Library");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Secure Dongle session address
|
||||||
|
* 16 bit pointer
|
||||||
|
*/
|
||||||
|
ShortPointer handle;
|
||||||
|
/**
|
||||||
|
* Parameter 1
|
||||||
|
* 16 bit pointer
|
||||||
|
*/
|
||||||
|
ShortPointer p1;
|
||||||
|
/**
|
||||||
|
* Parameter 2
|
||||||
|
* 16 bit pointer
|
||||||
|
*/
|
||||||
|
ShortPointer p2;
|
||||||
|
/**
|
||||||
|
* Parameter 3
|
||||||
|
* 16 bit pointer
|
||||||
|
*/
|
||||||
|
ShortPointer p3;
|
||||||
|
/**
|
||||||
|
* Parameter 4
|
||||||
|
* 16 bit pointer
|
||||||
|
*/
|
||||||
|
ShortPointer p4;
|
||||||
|
/**
|
||||||
|
* Return Code
|
||||||
|
* 16 bit value
|
||||||
|
*/
|
||||||
|
Short retcode;
|
||||||
|
/**
|
||||||
|
* Long Parameter 1
|
||||||
|
* 32 bit pointer
|
||||||
|
*/
|
||||||
|
IntPointer lp1;
|
||||||
|
/**
|
||||||
|
* Long Parameter 2
|
||||||
|
* 32 bit pointer
|
||||||
|
*/
|
||||||
|
IntPointer lp2;
|
||||||
|
/**
|
||||||
|
* Byte array buffer
|
||||||
|
* 1024 bytes 8 bit
|
||||||
|
*/
|
||||||
|
Memory buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single thread executor untuk run function secure dongle
|
||||||
|
*/
|
||||||
|
private ExecutorService exec ;
|
||||||
|
|
||||||
|
public JSecureDongleV2() {
|
||||||
|
buffer = new Memory(1024);
|
||||||
|
lp1 = new IntPointer();
|
||||||
|
lp2 = new IntPointer();
|
||||||
|
p1 = new ShortPointer();
|
||||||
|
p2 = new ShortPointer();
|
||||||
|
p3 = new ShortPointer();
|
||||||
|
p4 = new ShortPointer();
|
||||||
|
handle = new ShortPointer();
|
||||||
|
exec = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BA bax;
|
||||||
|
private String event;
|
||||||
|
private Object Me;
|
||||||
|
|
||||||
|
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_finddongle_event = false;
|
||||||
|
private boolean need_opendongle_event = false;
|
||||||
|
private boolean need_closedongle_event = false;
|
||||||
|
private boolean need_readuserdatazone_event = false;
|
||||||
|
private boolean need_writeuserdatazone_event = false;
|
||||||
|
private boolean need_readuserid_event = false;
|
||||||
|
private boolean need_writeuserid_event = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize JSecureDongleV2
|
||||||
|
* @param eventname Eventname
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, String eventname) {
|
||||||
|
this.bax = ba;
|
||||||
|
this.event = eventname;
|
||||||
|
Me = this;
|
||||||
|
check_events();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check_events() {
|
||||||
|
if (bax!=null) {
|
||||||
|
if (mycodes.ValidString(event)) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
need_finddongle_event = bax.subExists(event+"_finddongle");
|
||||||
|
need_opendongle_event = bax.subExists(event+"_opendongle");
|
||||||
|
need_closedongle_event =bax.subExists(event+"_closedongle");
|
||||||
|
need_readuserdatazone_event = bax.subExists(event+"_readuserdatazone");
|
||||||
|
need_writeuserdatazone_event = bax.subExists(event+"_writeuserdatazone");
|
||||||
|
need_readuserid_event = bax.subExists(event+"_readuserid");
|
||||||
|
need_writeuserid_event = bax.subExists(event+"_writeuserid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a specific SecureDongle is attached to USB port
|
||||||
|
* will raise event finddongle
|
||||||
|
* @param password1 Basic Password 1
|
||||||
|
* @param password2 Basic Password 2
|
||||||
|
* @param password3 Advanced Password 1 (optional)
|
||||||
|
* @param password4 Advanced Password 2 (optional)
|
||||||
|
*/
|
||||||
|
public void Find_SecureDongle(int password1, int password2, int password3, int password4) {
|
||||||
|
p1.setValue(ShortPointer.ShortValue_FromInt(password1));
|
||||||
|
p2.setValue(ShortPointer.ShortValue_FromInt(password2));
|
||||||
|
p3.setValue(ShortPointer.ShortValue_FromInt(password3));
|
||||||
|
p4.setValue(ShortPointer.ShortValue_FromInt(password4));
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_FIND), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_finddongle(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
retcode==0 ? lp1.getValue() : 0,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To check if another specific SecureDongle is attached to USB port
|
||||||
|
* Must call Find_SecureDongle first before calling this function
|
||||||
|
* will raise event finddongle
|
||||||
|
* @param password1 Basic Password 1
|
||||||
|
* @param password2 Basic Password 2
|
||||||
|
* @param password3 Advanced Password 1 (optional)
|
||||||
|
* @param password4 Advanced Password 2 (optional)
|
||||||
|
*/
|
||||||
|
public void Find_Next_SecureDongle(int password1, int password2, int password3, int password4) {
|
||||||
|
p1.setValue(ShortPointer.ShortValue_FromInt(password1));
|
||||||
|
p2.setValue(ShortPointer.ShortValue_FromInt(password2));
|
||||||
|
p3.setValue(ShortPointer.ShortValue_FromInt(password3));
|
||||||
|
p4.setValue(ShortPointer.ShortValue_FromInt(password4));
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_FIND_NEXT), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_finddongle(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
retcode==0 ? lp1.getValue() : 0,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open SecureDongle with specific password or HardwareID
|
||||||
|
* will raise event opendongle
|
||||||
|
* @param password1 Basic Password 1
|
||||||
|
* @param password2 Basic Password 2
|
||||||
|
* @param password3 Advanced Password 1 (optional)
|
||||||
|
* @param password4 Advanced Password 2 (optional)
|
||||||
|
* @param HardwareID Hardware ID
|
||||||
|
*/
|
||||||
|
public void Open_SecureDongle(int password1, int password2, int password3, int password4, final int HardwareID) {
|
||||||
|
p1.setValue(ShortPointer.ShortValue_FromInt(password1));
|
||||||
|
p2.setValue(ShortPointer.ShortValue_FromInt(password2));
|
||||||
|
p3.setValue(ShortPointer.ShortValue_FromInt(password3));
|
||||||
|
p4.setValue(ShortPointer.ShortValue_FromInt(password4));
|
||||||
|
lp1.setValue(HardwareID);
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_OPEN), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_opendongle(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
HardwareID,
|
||||||
|
retcode==0 ? handle.toInt() : 0,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close SecureDongle with specific Handle
|
||||||
|
* will raise event closedongle
|
||||||
|
* @param Handle Session Handle
|
||||||
|
*/
|
||||||
|
public void Close_SecureDongle(final int Handle) {
|
||||||
|
handle.setValue(ShortPointer.ShortValue_FromInt(Handle));
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_CLOSE), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_closedongle(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
Handle,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read content from User Data Zone
|
||||||
|
* will raise event readuserdatazone
|
||||||
|
* @param Handle Session Handle
|
||||||
|
* @param offset from zero (0)
|
||||||
|
* @param length max 1000 bytes
|
||||||
|
*/
|
||||||
|
public void Read_UserDataZone(final int Handle,final int offset, final int length) {
|
||||||
|
|
||||||
|
handle.setValue(ShortPointer.ShortValue_FromInt(Handle));
|
||||||
|
p1.setValue(ShortPointer.ShortValue_FromInt(offset));
|
||||||
|
p2.setValue(ShortPointer.ShortValue_FromInt(length));
|
||||||
|
buffer.clear();
|
||||||
|
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_READ), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_readuserdatazone(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
Handle,
|
||||||
|
retcode==0 ? buffer.getByteArray(offset, length) : null,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write content to User Data Zone
|
||||||
|
* will raise event writeuserdatazone
|
||||||
|
* @param Handle Session Handle
|
||||||
|
* @param offset offset of User Data Zone
|
||||||
|
* @param length length of content to be written
|
||||||
|
* @param content content to write
|
||||||
|
*/
|
||||||
|
public void Write_UserDataZone(final int Handle, final int offset, final int length, final byte[] content) {
|
||||||
|
handle.setValue(ShortPointer.ShortValue_FromInt(Handle));
|
||||||
|
p1.setValue(ShortPointer.ShortValue_FromInt(offset));
|
||||||
|
p2.setValue(ShortPointer.ShortValue_FromInt(length));
|
||||||
|
buffer.clear();
|
||||||
|
buffer.write(0, content, 0, length);
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_WRITE), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_writeuserdatazone(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
Handle,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write UserID
|
||||||
|
* will raise event writeuserid
|
||||||
|
* @param Handle Session Handle
|
||||||
|
* @param UserID value of User ID
|
||||||
|
*/
|
||||||
|
public void Write_UserID(final int Handle, int UserID) {
|
||||||
|
handle.setValue(ShortPointer.ShortValue_FromInt(Handle));
|
||||||
|
lp1.setValue(UserID);
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_WRITE_USERID), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_writeuserid(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
Handle,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read UserID
|
||||||
|
* will raise event readuserid
|
||||||
|
* @param Handle Session Handle
|
||||||
|
*/
|
||||||
|
public void Read_UserID(final int Handle) {
|
||||||
|
handle.setValue(ShortPointer.ShortValue_FromInt(Handle));
|
||||||
|
exec.submit(()->{
|
||||||
|
retcode = this.SecureDongle(ShortPointer.ShortValue_FromInt(SD_READ_USERID), handle, lp1, lp2, p1, p2, p3, p4, buffer);
|
||||||
|
raise_readuserid(
|
||||||
|
retcode==0 ? true : false,
|
||||||
|
Handle,
|
||||||
|
retcode==0 ? lp1.getValue() : 0,
|
||||||
|
GetErrorMessage(retcode)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_finddongle(boolean success, int HardwareID, String message ) {
|
||||||
|
if (need_finddongle_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_finddongle", false, new Object[] {success, HardwareID, message});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_opendongle(boolean success, int HardwareID, int SessionHandle, String message) {
|
||||||
|
if (need_opendongle_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_opendongle", false, new Object[] {success, HardwareID, SessionHandle, message});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_closedongle(boolean success, int SessionHandle, String message) {
|
||||||
|
if (need_closedongle_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_closedongle", false, new Object[] {success, SessionHandle, message});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_readuserdatazone(boolean success, int SessionHandle, byte[] data, String message) {
|
||||||
|
if (need_readuserdatazone_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_readuserdatazone", false, new Object[] {success, SessionHandle, data, message});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_writeuserdatazone(boolean success, int SessionHandle, String message) {
|
||||||
|
if (need_writeuserdatazone_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_writeuserdatazone", false, new Object[] {success, SessionHandle, message});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_readuserid(boolean success, int SessionHandle, int UserID, String message) {
|
||||||
|
if (need_readuserid_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_readuserid", false, new Object[] {success, SessionHandle, UserID, message});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_writeuserid(boolean success, int SessionHandle, String message) {
|
||||||
|
if (need_writeuserid_event) bax.raiseEventFromDifferentThread(Me, null, 0, event+"_writeuserid", false, new Object[] {success, SessionHandle, message});
|
||||||
|
}
|
||||||
|
}
|
||||||
118
src/devices/Kernel32.java
Normal file
118
src/devices/Kernel32.java
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
package devices;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Structure;
|
||||||
|
import com.sun.jna.win32.StdCallLibrary;
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
public interface Kernel32 extends StdCallLibrary {
|
||||||
|
public Kernel32 INSTANCE = (Kernel32) Native.load("Kernel32", Kernel32.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill the structure.
|
||||||
|
*/
|
||||||
|
public int GetSystemPowerStatus(SYSTEM_POWER_STATUS result);
|
||||||
|
|
||||||
|
public class SYSTEM_POWER_STATUS extends Structure{
|
||||||
|
public byte ACLineStatus;
|
||||||
|
public byte BatteryFlag;
|
||||||
|
public byte BatteryLifePercent;
|
||||||
|
public byte Reserved1;
|
||||||
|
public int BatteryLifeTime;
|
||||||
|
public int BatteryFullLifeTime;
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public void autoRead() {
|
||||||
|
if (getAutoRead()) {
|
||||||
|
read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public void autoWrite() {
|
||||||
|
if (getAutoWrite()) {
|
||||||
|
write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected java.util.List<String> getFieldOrder() {
|
||||||
|
return java.util.Arrays.asList(new String[] { "ACLineStatus", "BatteryFlag", "BatteryLifePercent", "Reserved1",
|
||||||
|
"BatteryLifeTime", "BatteryFullLifeTime" });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get AC power status
|
||||||
|
* @return Offline, Online or Unknown
|
||||||
|
*/
|
||||||
|
public String GetACLineStatusString() {
|
||||||
|
switch (ACLineStatus) {
|
||||||
|
case 0:
|
||||||
|
return "Offline";
|
||||||
|
case 1:
|
||||||
|
return "Online";
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Battery Flag Status
|
||||||
|
* @return High, Low, Critical, Charging, No system battery or Unknown
|
||||||
|
*/
|
||||||
|
public String GetBatteryFlagString() {
|
||||||
|
switch (BatteryFlag) {
|
||||||
|
case 1:
|
||||||
|
return "High";
|
||||||
|
case 2:
|
||||||
|
return "Low";
|
||||||
|
case 4:
|
||||||
|
return "Critical";
|
||||||
|
case 8:
|
||||||
|
return "Charging";
|
||||||
|
case (byte)128:
|
||||||
|
return "No system battery";
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Battery Life Percent
|
||||||
|
*
|
||||||
|
* @return Battery Life Percent or Unknown
|
||||||
|
*/
|
||||||
|
public String GetBatteryLifePercentString() {
|
||||||
|
return (BatteryLifePercent==(byte)255) ? "Unknown" : String.valueOf(BatteryLifePercent)+" %";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Battery Life Time
|
||||||
|
* @return Battery Life Time in seconds or Unknown
|
||||||
|
*/
|
||||||
|
public String GetBatteryLifeTimeString() {
|
||||||
|
return (BatteryLifeTime == (int) -1) ? "Unknown" : String.valueOf(BatteryLifeTime)+ " seconds";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Battery Full Life Time
|
||||||
|
*
|
||||||
|
* @return Battery Full Life Time in seconds or Unknown
|
||||||
|
*/
|
||||||
|
public String GetBatteryFullLifeTimeString() {
|
||||||
|
return (BatteryFullLifeTime == (int) -1) ? "Unknown" : String.valueOf(BatteryFullLifeTime) + " seconds";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* Get all information
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return "ACLineStatus: " + GetACLineStatusString() + "\n" + "BatteryFlag: " + GetBatteryFlagString() + "\n"
|
||||||
|
+ "BatteryLifePercent: " + GetBatteryLifePercentString() + "\n" + "BatteryLifeTime: "
|
||||||
|
+ GetBatteryLifeTimeString() + "\n" + "BatteryFullLifeTime: " + GetBatteryFullLifeTimeString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
574
src/devices/LCDDotMatrix/LCD.java
Normal file
574
src/devices/LCDDotMatrix/LCD.java
Normal file
@@ -0,0 +1,574 @@
|
|||||||
|
package devices.LCDDotMatrix;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import devices.PCF8574;
|
||||||
|
import jGPIO.jGPIO;
|
||||||
|
|
||||||
|
@BA.ShortName("LCD")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"lcdupdated(row as int, msg as string)"
|
||||||
|
})
|
||||||
|
|
||||||
|
public class LCD implements LCDStringEvent {
|
||||||
|
|
||||||
|
private BA ba;
|
||||||
|
private Object myobject;
|
||||||
|
private String event;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_lcdupdated_event = false;
|
||||||
|
|
||||||
|
private int rowcount = 2; // default value
|
||||||
|
private int columncount = 16; // default value
|
||||||
|
private PCF8574 pcf;
|
||||||
|
private boolean opened = false;
|
||||||
|
private LCDString[] messages;
|
||||||
|
private int menuindex = 0;
|
||||||
|
|
||||||
|
private final int BL_Pin = 8;
|
||||||
|
private final int RS_pin = 1;
|
||||||
|
private final int RW_pin= 2;
|
||||||
|
private final int EN_pin = 4;
|
||||||
|
private final int D7_pin = 128;
|
||||||
|
private final int D6_pin = 64;
|
||||||
|
private final int D5_pin = 32;
|
||||||
|
private final int D4_pin = 16;
|
||||||
|
private int bufdata = 0;
|
||||||
|
|
||||||
|
private int backlightcounter = 0;
|
||||||
|
private Timer backlighttimer ;
|
||||||
|
private int backlightdefault = 60;
|
||||||
|
|
||||||
|
|
||||||
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
|
public LCD() {
|
||||||
|
if (jGPIO.osname=="") jGPIO.detectOS();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initialize LCD object in B4J
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param Eventname : eventname
|
||||||
|
*/
|
||||||
|
public void Initialize(BA bax, Object callerobject, String Eventname) {
|
||||||
|
ba = bax;
|
||||||
|
myobject = callerobject;
|
||||||
|
event = Eventname.trim();
|
||||||
|
|
||||||
|
if (ba instanceof BA) {
|
||||||
|
if (myobject!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = ba.subExists(event+"_log");
|
||||||
|
need_lcdupdated_event = ba.subExists(event+"_lcdupdated");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto close kalau java program closed
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open LCD
|
||||||
|
* @param bus_name : i2c bus name
|
||||||
|
* @param slave_address : i2c address
|
||||||
|
* @param row : row count. default value = 2
|
||||||
|
* @param column : column count. default value = 16
|
||||||
|
* @return true if opened
|
||||||
|
*/
|
||||||
|
public boolean Open(String bus_name, int slave_address, int row, int column) {
|
||||||
|
if (!jGPIO.IsLinux) return false;
|
||||||
|
opened = false;
|
||||||
|
if (row>0) rowcount = row;
|
||||||
|
if (column>0) columncount = column;
|
||||||
|
pcf = new PCF8574();
|
||||||
|
//pcf.Initialize(ba, caller, eventname); No need to call this, only for B4J
|
||||||
|
opened = pcf.Open(bus_name, slave_address);
|
||||||
|
if (opened) {
|
||||||
|
messages = new LCDString[row];
|
||||||
|
for(int ii=0;ii<messages.length;ii++) {
|
||||||
|
messages[ii] = new LCDString(ii,columncount);
|
||||||
|
messages[ii].SetJavaEvent(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
backlighttimer = new Timer();
|
||||||
|
backlighttimer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (backlightcounter>0) {
|
||||||
|
backlightcounter -= 1;
|
||||||
|
if (backlightcounter==0) {
|
||||||
|
BackLight(false); // turn off backlight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 1000, 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return opened;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close LCD
|
||||||
|
*/
|
||||||
|
public void Close() {
|
||||||
|
|
||||||
|
//if (executor instanceof ExecutorService) {
|
||||||
|
// executor.shutdownNow();
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (messages!=null) {
|
||||||
|
for(int ii=0;ii<rowcount;ii++) {
|
||||||
|
LCDString xx = messages[ii];
|
||||||
|
if (xx instanceof LCDString) {
|
||||||
|
xx.Close();
|
||||||
|
xx = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messages=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pcf instanceof PCF8574) {
|
||||||
|
pcf.Close();
|
||||||
|
pcf = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backlighttimer instanceof Timer) {
|
||||||
|
backlighttimer.cancel();
|
||||||
|
backlighttimer.purge();
|
||||||
|
backlighttimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
opened = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if LCD is opened
|
||||||
|
* @return true if opened
|
||||||
|
*/
|
||||||
|
public boolean getIsOpened() {
|
||||||
|
return opened;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get LCD rows
|
||||||
|
* @return row count, default is 2.
|
||||||
|
*/
|
||||||
|
public int getRows() {
|
||||||
|
return rowcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get LCD columns
|
||||||
|
* @return column count, default is 16
|
||||||
|
*/
|
||||||
|
public int getColumns() {
|
||||||
|
return columncount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
/**
|
||||||
|
* Set LCD Content
|
||||||
|
* @param row : row index, start from 0
|
||||||
|
* @param msg : String message
|
||||||
|
* @param menutag : Menuindex which this message belong to.
|
||||||
|
* @return true if content stored (not yet displayed)
|
||||||
|
*/
|
||||||
|
public boolean SetContent(int row, String msg, int menutag) {
|
||||||
|
|
||||||
|
if (messages==null) return false;
|
||||||
|
if (row > messages.length-1) return false;
|
||||||
|
menuindex = menutag;
|
||||||
|
messages[row].UpdateContent(msg, menutag);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set LCD Content, and crop the message if length more than colum size
|
||||||
|
* @param row : row index, start from 0
|
||||||
|
* @param msg : Message to display
|
||||||
|
* @param menutag : menuindex which this message belong to
|
||||||
|
* @return true if content stored
|
||||||
|
*/
|
||||||
|
public boolean SetContentCrop(int row, String msg, int menutag) {
|
||||||
|
if (messages != null) {
|
||||||
|
if (row < messages.length) {
|
||||||
|
menuindex = menutag;
|
||||||
|
if (msg.length()>columncount) {
|
||||||
|
msg = msg.substring(0,columncount);
|
||||||
|
}
|
||||||
|
messages[row].UpdateContent(msg, menutag);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current LCD row content
|
||||||
|
* @param row : row index, start from 0
|
||||||
|
* @return empty string if not found
|
||||||
|
*/
|
||||||
|
public String GetContent(int row) {
|
||||||
|
if (messages!=null) {
|
||||||
|
if (row < messages.length) {
|
||||||
|
return messages[row].CurrentContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare content with row content, and return true if same value
|
||||||
|
* @param row : row index, start from 0
|
||||||
|
* @param content : content to compare with internal row content
|
||||||
|
* @return true if the same (case sensitive)
|
||||||
|
*/
|
||||||
|
public boolean CompareContent(int row, String content) {
|
||||||
|
if (messages!=null) {
|
||||||
|
if (row<messages.length) {
|
||||||
|
if (content instanceof String) {
|
||||||
|
return messages[row].CurrentContent().compareTo(content) == 0 ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current LCD menuindex
|
||||||
|
*/
|
||||||
|
public int getMenuIndex() {
|
||||||
|
return menuindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Hardware LCD
|
||||||
|
* Must be called after Open
|
||||||
|
*/
|
||||||
|
public void LCD_Initialize() {
|
||||||
|
//if (executor instanceof ExecutorService) executor.execute(new LCD_INIT());
|
||||||
|
|
||||||
|
try {
|
||||||
|
RS(false);
|
||||||
|
RW(false);
|
||||||
|
EN(false);
|
||||||
|
Nibble(false,false,true,true);
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
Nibble(false,false,true,false);
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
LCD_write(0x28);
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
LCD_write(0x0C);
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
LCD_write(0x06);
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
LCD_write(0x01);
|
||||||
|
Thread.sleep(5);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear LCD Display
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
public void LCD_clear() {
|
||||||
|
//if (executor instanceof ExecutorService) executor.execute(new LCD_CLEAR());
|
||||||
|
|
||||||
|
try {
|
||||||
|
RS(false);
|
||||||
|
LCD_write(1);
|
||||||
|
Thread.sleep(5);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set LCD Backlight ON or OFF
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
public void BackLight(boolean isON) {
|
||||||
|
|
||||||
|
if (isON) {
|
||||||
|
BitSet(BL_Pin);
|
||||||
|
backlightcounter = backlightdefault;
|
||||||
|
} else {
|
||||||
|
BitReset(BL_Pin);
|
||||||
|
backlightcounter = 0;
|
||||||
|
}
|
||||||
|
PCFWrite((byte) bufdata);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Backlight is ON or OFF
|
||||||
|
* @return true if ON
|
||||||
|
*/
|
||||||
|
public boolean getBackLightIsOn() {
|
||||||
|
if (backlightcounter>0) return true; else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get / Set Default Backlight timeout , in seconds
|
||||||
|
*/
|
||||||
|
public int getBackLightInterval() {
|
||||||
|
return backlightdefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackLightInterval(int value) {
|
||||||
|
backlightdefault = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BitSet(int pin) {
|
||||||
|
bufdata |= pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BitReset(int pin) {
|
||||||
|
bufdata &= ~pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LCD_gotoxy(int x, int y) {
|
||||||
|
RS(false);
|
||||||
|
switch(y) {
|
||||||
|
case 0 :
|
||||||
|
LCD_write(0x80+x);
|
||||||
|
break;
|
||||||
|
case 1 :
|
||||||
|
LCD_write(0xC0 + x );
|
||||||
|
break;
|
||||||
|
case 2 :
|
||||||
|
LCD_write(0x94 + x );
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
LCD_write(0xD4 + x );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LCD_write(int bx) {
|
||||||
|
EN(false);
|
||||||
|
Nibble((bx & 0x80)>0, (bx & 0x40)>0, (bx & 0x20)>0, (bx & 0x10)>0);
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Nibble((bx & 0x08)>0, (bx & 0x04)>0, (bx & 0x02)>0, (bx & 0x01)>0);
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Nibble(boolean D7 , boolean D6 , boolean D5 , boolean D4 ) {
|
||||||
|
if (D7) BitSet(D7_pin); else BitReset(D7_pin);
|
||||||
|
if (D6) BitSet(D6_pin); else BitReset(D6_pin);
|
||||||
|
if (D5) BitSet(D5_pin); else BitReset(D5_pin);
|
||||||
|
if (D4) BitSet(D4_pin); else BitReset(D4_pin);
|
||||||
|
PCFWrite((byte) bufdata);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RW(boolean isON) {
|
||||||
|
if (isON) {
|
||||||
|
BitSet(RW_pin);
|
||||||
|
} else {
|
||||||
|
BitReset(RW_pin);
|
||||||
|
}
|
||||||
|
PCFWrite((byte) bufdata);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void RS(boolean isON) {
|
||||||
|
if (isON) {
|
||||||
|
BitSet(RS_pin);
|
||||||
|
} else {
|
||||||
|
BitReset(RS_pin);
|
||||||
|
}
|
||||||
|
PCFWrite((byte) bufdata);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EN(boolean isON) {
|
||||||
|
if (isON) {
|
||||||
|
BitSet(EN_pin);
|
||||||
|
} else {
|
||||||
|
BitReset(EN_pin);
|
||||||
|
}
|
||||||
|
PCFWrite((byte) bufdata);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PCFWrite(byte bb) {
|
||||||
|
if (pcf instanceof PCF8574) {
|
||||||
|
pcf.Write(bb); // gak perlu cek isopen, dah dilakuin di dalam
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
ba.raiseEventFromDifferentThread(myobject, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_lcdupdated(int row, String msg) {
|
||||||
|
if (need_lcdupdated_event) {
|
||||||
|
ba.raiseEventFromDifferentThread(myobject, null, 0, event+"_lcdupdated", false, new Object[] {row,msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private class LCD_UPDATE implements Runnable{
|
||||||
|
private int row;
|
||||||
|
private String msg;
|
||||||
|
public LCD_UPDATE(int row, String msg) {
|
||||||
|
this.row = row;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
LCD_gotoxy(0,row);
|
||||||
|
RS(true);
|
||||||
|
|
||||||
|
byte[] bbm = msg.getBytes();
|
||||||
|
for(int ii=0;ii<bbm.length;ii++) {
|
||||||
|
LCD_write(bbm[ii]);
|
||||||
|
}
|
||||||
|
|
||||||
|
raise_lcdupdated(row,msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private class LCD_INIT implements Runnable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
RS(false);
|
||||||
|
RW(false);
|
||||||
|
EN(false);
|
||||||
|
Nibble(false,false,true,true);
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
Nibble(false,false,true,false);
|
||||||
|
EN(true);
|
||||||
|
EN(false);
|
||||||
|
Thread.sleep(10);
|
||||||
|
|
||||||
|
LCD_write(0x28);
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
LCD_write(0x0C);
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
LCD_write(0x06);
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
LCD_write(0x01);
|
||||||
|
Thread.sleep(5);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private class LCD_CLEAR implements Runnable{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
RS(false);
|
||||||
|
LCD_write(1);
|
||||||
|
Thread.sleep(5);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BA.Hide
|
||||||
|
public synchronized void UpdateLCD(int row, String msg, int menutag) {
|
||||||
|
if (menuindex != menutag) {
|
||||||
|
raise_log("[DISCARDED] Row="+row+", Menu="+menutag+", Content="+msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (executor instanceof ExecutorService) executor.execute(new LCD_UPDATE(row, msg));
|
||||||
|
|
||||||
|
LCD_gotoxy(0,row);
|
||||||
|
RS(true);
|
||||||
|
|
||||||
|
byte[] bbm = msg.getBytes();
|
||||||
|
for(int ii=0;ii<bbm.length;ii++) {
|
||||||
|
LCD_write(bbm[ii]);
|
||||||
|
}
|
||||||
|
|
||||||
|
raise_lcdupdated(row,msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
164
src/devices/LCDDotMatrix/LCDString.java
Normal file
164
src/devices/LCDDotMatrix/LCDString.java
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
package devices.LCDDotMatrix;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
|
||||||
|
public class LCDString {
|
||||||
|
private int rowindex;
|
||||||
|
private int maxchar = 16;
|
||||||
|
private LCDStringEvent javaevent;
|
||||||
|
private String message;
|
||||||
|
private Timer lcdtimer;
|
||||||
|
private TimerTask lcdtask;
|
||||||
|
private int menutag = 0;
|
||||||
|
private final long scrolltime = 1000; // ms
|
||||||
|
private int startindex = 0;
|
||||||
|
private boolean arahmaju = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create LCD String object
|
||||||
|
* @param row_index : which row, start from 0
|
||||||
|
* @param maximum_char : how much characters per row. Default value is 16
|
||||||
|
*/
|
||||||
|
public LCDString(int row_index, int maximum_char) {
|
||||||
|
this.rowindex = row_index;
|
||||||
|
if (maximum_char > 0) this.maxchar = maximum_char;
|
||||||
|
lcdtimer = new Timer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Row index associated
|
||||||
|
* @return row index
|
||||||
|
*/
|
||||||
|
public int RowIndex() {
|
||||||
|
return rowindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Maximum characters in this row
|
||||||
|
* @return maximum characters
|
||||||
|
*/
|
||||||
|
public int MaximumChars() {
|
||||||
|
return maxchar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close LCDString and cancel all timer tasks
|
||||||
|
*/
|
||||||
|
public void Close() {
|
||||||
|
if (lcdtimer instanceof Timer) {
|
||||||
|
lcdtimer.cancel();
|
||||||
|
lcdtimer = null;
|
||||||
|
}
|
||||||
|
if (lcdtask instanceof TimerTask) {
|
||||||
|
lcdtask.cancel();
|
||||||
|
lcdtask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String CurrentContent() {
|
||||||
|
if (message!=null) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update this row content
|
||||||
|
* @param msg : string message
|
||||||
|
* @param currentmenutag : menu tag, for multiple menu selection. If not sure, set 0
|
||||||
|
*/
|
||||||
|
public void UpdateContent(String msg, int currentmenutag) {
|
||||||
|
this.message = msg;
|
||||||
|
this.menutag = currentmenutag;
|
||||||
|
int msglen = this.message.length();
|
||||||
|
|
||||||
|
if (lcdtimer instanceof Timer) {
|
||||||
|
lcdtimer.cancel();
|
||||||
|
lcdtimer.purge();
|
||||||
|
lcdtimer = null;
|
||||||
|
}
|
||||||
|
if (lcdtask instanceof TimerTask) {
|
||||||
|
lcdtask.cancel();
|
||||||
|
lcdtask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msglen<maxchar) {
|
||||||
|
// lebih pendek dari maxchar, harus padding
|
||||||
|
byte[] bb1 = this.message.getBytes(); // source
|
||||||
|
byte[] bb2 = new byte[maxchar]; // destination
|
||||||
|
|
||||||
|
// isi bb2 dengan spasi
|
||||||
|
for(int ii=0;ii<bb2.length;ii++) bb2[ii] = 32;
|
||||||
|
|
||||||
|
// copy dari bb1 ke bb2 sesuai panjang bb1
|
||||||
|
for(int ii=0;ii<bb1.length;ii++) bb2[ii] = bb1[ii];
|
||||||
|
|
||||||
|
raise_update_lcd(new String(bb2));
|
||||||
|
} else if (msglen == maxchar) {
|
||||||
|
// sama dengan maxchar
|
||||||
|
raise_update_lcd(this.message);
|
||||||
|
} else {
|
||||||
|
// lebih panjang, butuh timer untuk scrolling
|
||||||
|
|
||||||
|
startindex = 0; // will start from column 0
|
||||||
|
|
||||||
|
// re-create timertask
|
||||||
|
lcdtask = new TimerTask() {
|
||||||
|
@Override
|
||||||
|
// Pattern String scroll ke kiri
|
||||||
|
public void run() {
|
||||||
|
if (arahmaju) {
|
||||||
|
int count = maxchar;
|
||||||
|
String result = "";
|
||||||
|
int startbaca = startindex;
|
||||||
|
while (count>0) {
|
||||||
|
result+= message.charAt(startbaca);
|
||||||
|
count-= 1;
|
||||||
|
if (startbaca < (message.length()-1)) {
|
||||||
|
startbaca+=1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startbaca=0;
|
||||||
|
startindex = message.length(); // stop, dan mulai dari awal
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
raise_update_lcd(result);
|
||||||
|
//BA.Log("LCD TimerTask row="+rowindex+", hasil="+result);
|
||||||
|
|
||||||
|
if (startindex< (message.length()-1))
|
||||||
|
startindex+=1;
|
||||||
|
else
|
||||||
|
startindex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// recreate lcdtimer
|
||||||
|
lcdtimer = new Timer();
|
||||||
|
lcdtimer.scheduleAtFixedRate(lcdtask, 0, scrolltime);
|
||||||
|
//BA.Log("Message panjang "+msglen+" character, pakai timer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Event handler for this object
|
||||||
|
* @param lcd_event : LCDStringEvent object
|
||||||
|
*/
|
||||||
|
public void SetJavaEvent(LCDStringEvent lcd_event) {
|
||||||
|
this.javaevent = lcd_event;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_update_lcd(String msg) {
|
||||||
|
if (javaevent instanceof LCDStringEvent) {
|
||||||
|
javaevent.UpdateLCD(rowindex, msg, menutag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/devices/LCDDotMatrix/LCDStringEvent.java
Normal file
5
src/devices/LCDDotMatrix/LCDStringEvent.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package devices.LCDDotMatrix;
|
||||||
|
|
||||||
|
public interface LCDStringEvent {
|
||||||
|
void UpdateLCD(int row, String msg, int menutag);
|
||||||
|
}
|
||||||
451
src/devices/LCDSPI/LcdSpi.java
Normal file
451
src/devices/LCDSPI/LcdSpi.java
Normal file
@@ -0,0 +1,451 @@
|
|||||||
|
package devices.LCDSPI;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import jGPIO.mycodes;
|
||||||
|
|
||||||
|
//@BA.ShortName("LCDSPI")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)"
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LCD SPI Low level
|
||||||
|
* Source : https://github.com/gitcnd/LCDWIKI_SPI
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class LcdSpi {
|
||||||
|
private BA ba;
|
||||||
|
private String event;
|
||||||
|
private Object Me;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
|
||||||
|
public enum LCD_Mode_Identifiers{
|
||||||
|
ILI9325("ILI9325",0),
|
||||||
|
ILI9328("ILI9328 ",1),
|
||||||
|
ILI9341("ILI9341 ",2),
|
||||||
|
HX8357D("HX8357D ",3),
|
||||||
|
HX8347G("HX8347G ",4),
|
||||||
|
HX8347I("HX8347I ",5),
|
||||||
|
ILI9486("ILI9486 ",6),
|
||||||
|
ST7735S("ST7735S ",7),
|
||||||
|
SSD1283A("SSD1283A ",8);
|
||||||
|
public final String label;
|
||||||
|
public final int mode_identifiers;
|
||||||
|
|
||||||
|
private LCD_Mode_Identifiers(String label, int mode_identifier) {
|
||||||
|
this.label = label;
|
||||||
|
this.mode_identifiers = mode_identifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LCD_Identifiers{
|
||||||
|
ID_932X("ID_932X",0),
|
||||||
|
ID_7575("ID_7575",1),
|
||||||
|
ID_9341("ID_9341",2),
|
||||||
|
ID_HX8357D("ID_HX8357D",3),
|
||||||
|
ID_4535("ID_4535",4),
|
||||||
|
ID_9486("ID_9486",5),
|
||||||
|
ID_7735("ID_7735",6),
|
||||||
|
ID_1283A("ID_1283A",7),
|
||||||
|
ID_UNKNOWN("ID_UNKNOWN",0xFF);
|
||||||
|
|
||||||
|
public final String label;
|
||||||
|
public final int identifier;
|
||||||
|
private LCD_Identifiers(String label, int identifier) {
|
||||||
|
this.label = label;
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected short WIDTH, HEIGHT, width, height, rotation, lcd_driver, lcd_model;
|
||||||
|
protected boolean hw_spi=false;
|
||||||
|
|
||||||
|
|
||||||
|
private short XC, YC, CC, RC, SC1, SC2, MD, VL, R24BIT;
|
||||||
|
private volatile static byte spicsPort, spicdPort, spimisoPort, spimosiPort, spiclkPort;
|
||||||
|
private volatile static byte spicsPinSet, spicdPinSet, spimisoPinSet, spimosiPinSet, spiclkPinSet;
|
||||||
|
private volatile static byte spicsPinUnset, spicdPinUnset, spimisoPinUnset, spimosiPinUnset, spiclkPinUnset;
|
||||||
|
private volatile byte _cs, _cd, _miso, _mosi, _clk, _reset, _led;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize SPI LCD
|
||||||
|
* @param event Event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, String event) {
|
||||||
|
this.ba = ba;
|
||||||
|
this.event = event;
|
||||||
|
Me = this;
|
||||||
|
check_events();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_LCD() {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void start(short ID) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draw_Pixel(short x, short y, int color) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spi_Write(byte data) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
byte Spi_Read() {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Write_Cmd(int cmd) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Write_Data(int data) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Write_Cmd_Data(int cmd, int data) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_table8(cmd_data[] table, int size) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_table16(cmd_data[] table, int size) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Push_Command(byte cmd, byte[] block, int size) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
short Color_To_565(byte R, byte G, byte B) {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
short Read_ID() {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fill_Rect(int x, int y, int w, int h, int color) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set_Rotation(byte r) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
byte Get_Rotation() {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Invert_Display(boolean i) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
int Read_Reg(int reg, byte index) {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Read_GRAM(int x, int y, byte[] block, int w, int h) {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set_Addr_Window(int x1, int y1, int x2, int y2) {
|
||||||
|
//TODO lanjutin
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Push_Any_Color(short[] block, int n, boolean first, byte flags) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vert_Scroll(short top, short scrolllines, short offset) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
short Get_Height() {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
short Get_Width() {
|
||||||
|
//TODO lanjutin
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set_LR() {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
void Let_control(boolean i) {
|
||||||
|
//TODO lanjutin
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@BA.ShortName("SPI_CMD_DATA")
|
||||||
|
class cmd_data{
|
||||||
|
public int cmd;
|
||||||
|
public int data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class lcd_info{
|
||||||
|
short lcd_id;
|
||||||
|
int lcd_wid;
|
||||||
|
int lcd_heg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class mcu_spi_magic{
|
||||||
|
public static void CD_COMMAND() {
|
||||||
|
spicdPort &= spicdPinUnset;
|
||||||
|
}
|
||||||
|
public static void CD_DATA() {
|
||||||
|
spicdPort |= spicdPinSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CS_ACTIVE() {
|
||||||
|
spicsPort &= spicsPinUnset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CS_IDLE() {
|
||||||
|
spicsPort |= spicsPinSet;
|
||||||
|
}
|
||||||
|
public static byte MISO_STATE() {
|
||||||
|
return (byte)(spimisoPort & spimisoPinSet);
|
||||||
|
}
|
||||||
|
public static void MOSI_LOW() {
|
||||||
|
spimosiPort &= spimosiPinUnset;
|
||||||
|
}
|
||||||
|
public static void MOSI_HIGH() {
|
||||||
|
spimosiPort |= spimosiPinSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CLK_LOW() {
|
||||||
|
spiclkPort &= spiclkPinUnset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CLK_HIGH() {
|
||||||
|
spiclkPort |= spiclkPinSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static class lcd_spi_register{
|
||||||
|
public final static int ILI932X_START_OSC = 0x00;
|
||||||
|
public final static int ILI932X_DRIV_OUT_CTRL = 0x01;
|
||||||
|
public final static int ILI932X_DRIV_WAV_CTRL = 0x02;
|
||||||
|
public final static int ILI932X_ENTRY_MOD = 0x03;
|
||||||
|
public final static int ILI932X_RESIZE_CTRL = 0x04;
|
||||||
|
public final static int ILI932X_DISP_CTRL1 = 0x07;
|
||||||
|
public final static int ILI932X_DISP_CTRL2 = 0x08;
|
||||||
|
public final static int ILI932X_DISP_CTRL3 = 0x09;
|
||||||
|
public final static int ILI932X_DISP_CTRL4 = 0x0A;
|
||||||
|
public final static int ILI932X_RGB_DISP_IF_CTRL1 = 0x0C;
|
||||||
|
public final static int ILI932X_FRM_MARKER_POS = 0x0D;
|
||||||
|
public final static int ILI932X_RGB_DISP_IF_CTRL2 = 0x0F;
|
||||||
|
public final static int ILI932X_POW_CTRL1 = 0x10;
|
||||||
|
public final static int ILI932X_POW_CTRL2 = 0x11;
|
||||||
|
public final static int ILI932X_POW_CTRL3 = 0x12;
|
||||||
|
public final static int ILI932X_POW_CTRL4 = 0x13;
|
||||||
|
public final static int ILI932X_GRAM_HOR_AD = 0x20;
|
||||||
|
public final static int ILI932X_GRAM_VER_AD = 0x21;
|
||||||
|
public final static int ILI932X_RW_GRAM = 0x22;
|
||||||
|
public final static int ILI932X_POW_CTRL7 = 0x29;
|
||||||
|
public final static int ILI932X_FRM_RATE_COL_CTRL = 0x2B;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL1 = 0x30;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL2 = 0x31;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL3 = 0x32;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL4 = 0x35;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL5 = 0x36;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL6 = 0x37;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL7 = 0x38;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL8 = 0x39;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL9 = 0x3C;
|
||||||
|
public final static int ILI932X_GAMMA_CTRL10 = 0x3D;
|
||||||
|
public final static int ILI932X_HOR_START_AD = 0x50;
|
||||||
|
public final static int ILI932X_HOR_END_AD = 0x51;
|
||||||
|
public final static int ILI932X_VER_START_AD = 0x52;
|
||||||
|
public final static int ILI932X_VER_END_AD = 0x53;
|
||||||
|
public final static int ILI932X_GATE_SCAN_CTRL1 = 0x60;
|
||||||
|
public final static int ILI932X_GATE_SCAN_CTRL2 = 0x61;
|
||||||
|
public final static int ILI932X_GATE_SCAN_CTRL3 = 0x6A;
|
||||||
|
public final static int ILI932X_PART_IMG1_DISP_POS = 0x80;
|
||||||
|
public final static int ILI932X_PART_IMG1_START_AD = 0x81;
|
||||||
|
public final static int ILI932X_PART_IMG1_END_AD = 0x82;
|
||||||
|
public final static int ILI932X_PART_IMG2_DISP_POS = 0x83;
|
||||||
|
public final static int ILI932X_PART_IMG2_START_AD = 0x84;
|
||||||
|
public final static int ILI932X_PART_IMG2_END_AD = 0x85;
|
||||||
|
public final static int ILI932X_PANEL_IF_CTRL1 = 0x90;
|
||||||
|
public final static int ILI932X_PANEL_IF_CTRL2 = 0x92;
|
||||||
|
public final static int ILI932X_PANEL_IF_CTRL3 = 0x93;
|
||||||
|
public final static int ILI932X_PANEL_IF_CTRL4 = 0x95;
|
||||||
|
public final static int ILI932X_PANEL_IF_CTRL5 = 0x97;
|
||||||
|
public final static int ILI932X_PANEL_IF_CTRL6 = 0x98;
|
||||||
|
|
||||||
|
public final static int HX8347G_COLADDRSTART_HI = 0x02;
|
||||||
|
public final static int HX8347G_COLADDRSTART_LO = 0x03;
|
||||||
|
public final static int HX8347G_COLADDREND_HI = 0x04;
|
||||||
|
public final static int HX8347G_COLADDREND_LO = 0x05;
|
||||||
|
public final static int HX8347G_ROWADDRSTART_HI = 0x06;
|
||||||
|
public final static int HX8347G_ROWADDRSTART_LO = 0x07;
|
||||||
|
public final static int HX8347G_ROWADDREND_HI = 0x08;
|
||||||
|
public final static int HX8347G_ROWADDREND_LO = 0x09;
|
||||||
|
public final static int HX8347G_MEMACCESS = 0x16;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public final static int ILI9341_SOFTRESET = 0x01;
|
||||||
|
public final static int ILI9341_SLEEPIN = 0x10;
|
||||||
|
public final static int ILI9341_SLEEPOUT = 0x11;
|
||||||
|
public final static int ILI9341_NORMALDISP = 0x13;
|
||||||
|
public final static int ILI9341_INVERTOFF = 0x20;
|
||||||
|
public final static int ILI9341_INVERTON = 0x21;
|
||||||
|
public final static int ILI9341_GAMMASET = 0x26;
|
||||||
|
public final static int ILI9341_DISPLAYOFF = 0x28;
|
||||||
|
public final static int ILI9341_DISPLAYON = 0x29;
|
||||||
|
public final static int ILI9341_COLADDRSET = 0x2A;
|
||||||
|
public final static int ILI9341_PAGEADDRSET = 0x2B;
|
||||||
|
public final static int ILI9341_MEMORYWRITE = 0x2C;
|
||||||
|
public final static int ILI9341_MEMORYACCESS = 0x36;
|
||||||
|
public final static int ILI9341_PIXELFORMAT = 0x3A;
|
||||||
|
public final static int ILI9341_RGBSIGNAL = 0xB0;
|
||||||
|
public final static int ILI9341_FRAMECONTROL = 0xB1;
|
||||||
|
public final static int ILI9341_INVERSIONCONRTOL = 0xB4;
|
||||||
|
public final static int ILI9341_DISPLAYFUNC = 0xB6;
|
||||||
|
public final static int ILI9341_ENTRYMODE = 0xB7;
|
||||||
|
public final static int ILI9341_POWERCONTROL1 = 0xC0;
|
||||||
|
public final static int ILI9341_POWERCONTROL2 = 0xC1;
|
||||||
|
public final static int ILI9341_VCOMCONTROL1 = 0xC5;
|
||||||
|
public final static int ILI9341_VCOMCONTROL2 = 0xC7;
|
||||||
|
public final static int ILI9341_POWERCONTROLB = 0xCF;
|
||||||
|
public final static int ILI9341_POWERCONTROLA = 0xCB;
|
||||||
|
public final static int ILI9341_UNDEFINE0 = 0xE0;
|
||||||
|
public final static int ILI9341_UNDEFINE1 = 0xE1;
|
||||||
|
public final static int ILI9341_DRIVERTIMINGA = 0xE8;
|
||||||
|
public final static int ILI9341_DRIVERTIMINGB = 0xEA;
|
||||||
|
public final static int ILI9341_POWERONSEQ = 0xED;
|
||||||
|
public final static int ILI9341_ENABLE3G = 0xF2;
|
||||||
|
public final static int ILI9341_INTERFACECONTROL = 0xF6;
|
||||||
|
public final static int ILI9341_RUMPRATIO = 0xF7;
|
||||||
|
public final static int ILI9341_MEMCONTROL = 0x36;
|
||||||
|
public final static int ILI9341_MADCTL = 0x36;
|
||||||
|
|
||||||
|
public final static int ILI9341_MADCTL_MY = 0x80;
|
||||||
|
public final static int ILI9341_MADCTL_MX = 0x40;
|
||||||
|
public final static int ILI9341_MADCTL_MV = 0x20;
|
||||||
|
public final static int ILI9341_MADCTL_ML = 0x10;
|
||||||
|
public final static int ILI9341_MADCTL_RGB = 0x00;
|
||||||
|
public final static int ILI9341_MADCTL_BGR = 0x08;
|
||||||
|
public final static int ILI9341_MADCTL_MH = 0x04;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public final static int HX8357_NOP = 0x00;
|
||||||
|
public final static int HX8357_SWRESET = 0x01;
|
||||||
|
public final static int HX8357_RDDID = 0x04;
|
||||||
|
public final static int HX8357_RDDST = 0x09;
|
||||||
|
|
||||||
|
public final static int HX8357B_RDPOWMODE = 0x0A;
|
||||||
|
public final static int HX8357B_RDMADCTL = 0x0B;
|
||||||
|
public final static int HX8357B_RDCOLMOD = 0x0C;
|
||||||
|
public final static int HX8357B_RDDIM = 0x0D;
|
||||||
|
public final static int HX8357B_RDDSDR = 0x0F;
|
||||||
|
|
||||||
|
public final static int HX8357_SLPIN = 0x10;
|
||||||
|
public final static int HX8357_SLPOUT = 0x11;
|
||||||
|
public final static int HX8357B_PTLON = 0x12;
|
||||||
|
public final static int HX8357B_NORON = 0x13;
|
||||||
|
|
||||||
|
public final static int HX8357_INVOFF = 0x20;
|
||||||
|
public final static int HX8357_INVON = 0x21;
|
||||||
|
public final static int HX8357_DISPOFF = 0x28;
|
||||||
|
public final static int HX8357_DISPON = 0x29;
|
||||||
|
|
||||||
|
public final static int HX8357_CASET = 0x2A;
|
||||||
|
public final static int HX8357_PASET = 0x2B;
|
||||||
|
public final static int HX8357_RAMWR = 0x2C;
|
||||||
|
public final static int HX8357_RAMRD = 0x2E;
|
||||||
|
|
||||||
|
public final static int HX8357B_PTLAR = 0x30;
|
||||||
|
public final static int HX8357_TEON = 0x35;
|
||||||
|
public final static int HX8357_TEARLINE = 0x44;
|
||||||
|
public final static int HX8357_MADCTL = 0x36;
|
||||||
|
public final static int HX8357_COLMOD = 0x3A;
|
||||||
|
|
||||||
|
public final static int HX8357_SETOSC = 0xB0;
|
||||||
|
public final static int HX8357_SETPWR1 = 0xB1;
|
||||||
|
public final static int HX8357B_SETDISPLAY = 0xB2;
|
||||||
|
public final static int HX8357_SETRGB = 0xB3;
|
||||||
|
public final static int HX8357D_SETCOM = 0xB6;
|
||||||
|
|
||||||
|
public final static int HX8357B_SETDISPMODE = 0xB4;
|
||||||
|
public final static int HX8357D_SETCYC = 0xB4;
|
||||||
|
public final static int HX8357B_SETOTP = 0xB7;
|
||||||
|
public final static int HX8357D_SETC = 0xB9;
|
||||||
|
|
||||||
|
public final static int HX8357B_SET_PANEL_DRIVING = 0xC0;
|
||||||
|
public final static int HX8357D_SETSTBA = 0xC0;
|
||||||
|
public final static int HX8357B_SETDGC = 0xC1;
|
||||||
|
public final static int HX8357B_SETID = 0xC3;
|
||||||
|
public final static int HX8357B_SETDDB = 0xC4;
|
||||||
|
public final static int HX8357B_SETDISPLAYFRAME = 0xC5;
|
||||||
|
public final static int HX8357B_GAMMASET = 0xC8;
|
||||||
|
public final static int HX8357B_SETCABC = 0xC9;
|
||||||
|
public final static int HX8357_SETPANEL = 0xCC;
|
||||||
|
|
||||||
|
|
||||||
|
public final static int HX8357B_SETPOWER = 0xD0;
|
||||||
|
public final static int HX8357B_SETVCOM = 0xD1;
|
||||||
|
public final static int HX8357B_SETPWRNORMAL = 0xD2;
|
||||||
|
|
||||||
|
public final static int HX8357B_RDID1 = 0xDA;
|
||||||
|
public final static int HX8357B_RDID2 = 0xDB;
|
||||||
|
public final static int HX8357B_RDID3 = 0xDC;
|
||||||
|
public final static int HX8357B_RDID4 = 0xDD;
|
||||||
|
|
||||||
|
public final static int HX8357D_SETGAMMA = 0xE0;
|
||||||
|
|
||||||
|
public final static int HX8357B_SETGAMMA = 0xC8;
|
||||||
|
public final static int HX8357B_SETPANELRELATED = 0xE9;
|
||||||
|
|
||||||
|
public final static int HX8357B_MADCTL_MY = 0x80;
|
||||||
|
public final static int HX8357B_MADCTL_MX = 0x40;
|
||||||
|
public final static int HX8357B_MADCTL_MV = 0x20;
|
||||||
|
public final static int HX8357B_MADCTL_ML = 0x10;
|
||||||
|
public final static int HX8357B_MADCTL_RGB = 0x00;
|
||||||
|
public final static int HX8357B_MADCTL_BGR = 0x08;
|
||||||
|
public final static int HX8357B_MADCTL_MH = 0x04;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check_events() {
|
||||||
|
if (ba!=null) {
|
||||||
|
if (mycodes.ValidString(event)) {
|
||||||
|
need_log_event = ba.subExists(event+"_log");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) ba.raiseEventFromDifferentThread(Me, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
109
src/devices/LEDMax7219/Graphic_Max7219.java
Normal file
109
src/devices/LEDMax7219/Graphic_Max7219.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package devices.LEDMax7219;
|
||||||
|
|
||||||
|
import com.sun.jna.Memory;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Graphic_Max7219")
|
||||||
|
public class Graphic_Max7219 {
|
||||||
|
private Pointer mem;
|
||||||
|
private final int blocks;
|
||||||
|
private final int size;
|
||||||
|
private final LEDBlock[][] ledblock;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize 1 block 8x8 pixel
|
||||||
|
*/
|
||||||
|
public Graphic_Max7219() {
|
||||||
|
this.blocks = 1;
|
||||||
|
|
||||||
|
this.size = this.blocks * 8;
|
||||||
|
mem = new Memory(this.size);
|
||||||
|
|
||||||
|
ledblock = new LEDBlock[1][1];
|
||||||
|
ledblock[0][0] = new LEDBlock();
|
||||||
|
|
||||||
|
for(int ii=0;ii<8;ii++) {
|
||||||
|
ledblock[0][0].setpointer(ii, mem.getPointer(ii));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize n block 8x8 pixel, dianggap 1 row dan n column
|
||||||
|
* @param blocks : banyaknya block, dianggap sebagai column
|
||||||
|
*/
|
||||||
|
public Graphic_Max7219(int blocks) {
|
||||||
|
|
||||||
|
this.blocks = blocks>0 ? blocks : 1;
|
||||||
|
this.size = this.blocks * 8;
|
||||||
|
mem = new Memory(this.size);
|
||||||
|
BA.Log("MemSize = "+this.size);
|
||||||
|
|
||||||
|
ledblock = new LEDBlock[blocks][1];
|
||||||
|
for(int ii=0;ii<blocks;ii++) {
|
||||||
|
ledblock[ii][0] = new LEDBlock();
|
||||||
|
for(int jj=0;jj<8;jj++) {
|
||||||
|
int memindex = jj*blocks + ii;
|
||||||
|
ledblock[ii][0].setpointer(jj, mem.share(memindex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set All bytes to OFF (0x00)
|
||||||
|
*/
|
||||||
|
public void All_OFF() {
|
||||||
|
if (mem!=null) {
|
||||||
|
for (int ii=0;ii<size;ii++) mem.setByte(ii, (byte)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set all bytes to ON (0xFF)
|
||||||
|
*/
|
||||||
|
public void All_ON() {
|
||||||
|
if (mem!=null) {
|
||||||
|
for(int ii=0;ii<size;ii++) mem.setByte(ii, (byte) 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many blocks
|
||||||
|
* @return number of block, minimum is 1
|
||||||
|
*/
|
||||||
|
public int getBlocks() {
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @BA.Hide
|
||||||
|
// /**
|
||||||
|
// * Get short(16 bits) from specific block number
|
||||||
|
// * 1 short = [row code] [row bytes]
|
||||||
|
// * @param blocknumber : start from 0, until (getBlocks() -1)
|
||||||
|
// * @return short array, or null if invalid blocknumber
|
||||||
|
// */
|
||||||
|
// public short[] GetBlockBytes(int blocknumber) {
|
||||||
|
// if (blocknumber<0) return null;
|
||||||
|
// if (blocknumber > (blocks-1)) return null;
|
||||||
|
// if (mem==null) return null;
|
||||||
|
//
|
||||||
|
// short[] result = new short[8];
|
||||||
|
// for(int ii=0;ii<8;ii++) {
|
||||||
|
// int tmp = get_mask(ii) | (mem.getByte(ii*blocks + blocknumber) & 0xFF);
|
||||||
|
// result[ii] = (short)tmp;
|
||||||
|
// }
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public LEDBlock GetLEDBlock(int x, int y) {
|
||||||
|
return ledblock[x][y];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
58
src/devices/LEDMax7219/LEDBlock.java
Normal file
58
src/devices/LEDMax7219/LEDBlock.java
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
package devices.LEDMax7219;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("LEDBlock")
|
||||||
|
public class LEDBlock {
|
||||||
|
private Pointer[] rows = new Pointer[8];
|
||||||
|
|
||||||
|
@BA.Hide
|
||||||
|
public void setpointer(int row, Pointer value) {
|
||||||
|
rows[row] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPixel(int rownumber, int cellnumber, boolean value) {
|
||||||
|
Pointer vv = rows[rownumber];
|
||||||
|
|
||||||
|
int mask = (1 << cellnumber);
|
||||||
|
int prev = vv.getByte(0);
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
prev = prev | mask;
|
||||||
|
} else {
|
||||||
|
prev = prev & ~(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
vv.setByte(0, (byte) prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
public short GetRowValue(int rownumber) {
|
||||||
|
Pointer vv = rows[rownumber];
|
||||||
|
short result = (short)(get_mask(rownumber) | (vv.getByte(0) & 0xFF));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private short get_mask(int baris) {
|
||||||
|
switch(baris) {
|
||||||
|
case 1: // baris 1
|
||||||
|
return 0x200;
|
||||||
|
case 2:
|
||||||
|
return 0x300;
|
||||||
|
case 3:
|
||||||
|
return 0x400;
|
||||||
|
case 4:
|
||||||
|
return 0x500;
|
||||||
|
case 5:
|
||||||
|
return 0x600;
|
||||||
|
case 6:
|
||||||
|
return 0x700;
|
||||||
|
case 7:
|
||||||
|
return 0x800;
|
||||||
|
default : // baris 0
|
||||||
|
return 0x100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
291
src/devices/LEDMax7219/LEDMax7219.java
Normal file
291
src/devices/LEDMax7219/LEDMax7219.java
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
package devices.LEDMax7219;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.pi4j.io.spi.SpiChannel;
|
||||||
|
import com.pi4j.io.spi.SpiDevice;
|
||||||
|
import com.pi4j.io.spi.SpiFactory;
|
||||||
|
import com.pi4j.io.spi.SpiMode;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import jGPIO.SPI.SPI_BitBang;
|
||||||
|
|
||||||
|
@BA.ShortName("LEDMax7219")
|
||||||
|
//@BA.DependsOn(values = { "pi4j-core" })
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)",
|
||||||
|
"updateresult(success as boolean)"
|
||||||
|
})
|
||||||
|
|
||||||
|
public class LEDMax7219 {
|
||||||
|
static {
|
||||||
|
|
||||||
|
}
|
||||||
|
private BA ba;
|
||||||
|
private Object myobject;
|
||||||
|
private String event;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean need_updateresult_event = false;
|
||||||
|
|
||||||
|
private SPI_BitBang spi_bitbang;
|
||||||
|
private SpiDevice spidev;
|
||||||
|
|
||||||
|
private boolean is_open = false;
|
||||||
|
|
||||||
|
public Graphic_Max7219 graphic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize LEDMax7219
|
||||||
|
* @param callerobject : caller object
|
||||||
|
* @param Eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA bax, Object callerobject, String Eventname) {
|
||||||
|
ba = bax;
|
||||||
|
myobject = callerobject;
|
||||||
|
event = Eventname.trim();
|
||||||
|
if (ba!=null) {
|
||||||
|
if (myobject!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = ba.subExists(event+"_log");
|
||||||
|
need_updateresult_event =ba.subExists(event+"_updateresult");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto close kalau java program closed
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open SPI Device using Pi4J
|
||||||
|
* @param channel : 0 or 1
|
||||||
|
* @param blocks : how many led blocks
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Open_SpiDevice(int channel, int blocks) {
|
||||||
|
if (is_open) { // sebelumnya terbuka pake metode lain
|
||||||
|
Close(); // tutup dulu, is_open jadi false
|
||||||
|
}
|
||||||
|
if (blocks<0) blocks = 1; // default 1
|
||||||
|
|
||||||
|
graphic = new Graphic_Max7219(blocks);
|
||||||
|
SpiChannel channelspi = SpiChannel.getByNumber(channel);
|
||||||
|
|
||||||
|
if (channelspi!=null) {
|
||||||
|
int mode = 0;
|
||||||
|
SpiMode modespi = SpiMode.getByNumber(mode); // mode 0 = idle di low (0), active rising edge
|
||||||
|
int speed = 500000; // speed max di 10 Mhz
|
||||||
|
if (modespi!=null) {
|
||||||
|
try {
|
||||||
|
spidev = SpiFactory.getInstance(channelspi, speed, modespi);
|
||||||
|
is_open = true;
|
||||||
|
raise_log("SpiDev opened at channel "+channel+", mode="+mode+", speed="+speed);
|
||||||
|
} catch (IOException e) {
|
||||||
|
raise_log("Unable to SPIFactory GetInstance, Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
} else raise_log("Invalid SPI Mode "+mode);
|
||||||
|
} else raise_log("Invalid SPI Channel "+channel);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open in SPI BitBang mode for compatibility
|
||||||
|
* @param pin_do : pin for Serial Data
|
||||||
|
* @param pin_cs : pin for Chip Select
|
||||||
|
* @param pin_clk : pin for Clock
|
||||||
|
* @param led_blocks : how many led blocks in cascaded
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Open_BitBang(int pin_do, int pin_cs, int pin_clk, int blocks) {
|
||||||
|
if (is_open) { // sebelumnya terbuka pake metode lain
|
||||||
|
Close(); // tutup dulu, is_open jadi false
|
||||||
|
}
|
||||||
|
if (blocks<0) blocks = 1; // default 1
|
||||||
|
|
||||||
|
graphic = new Graphic_Max7219(blocks);
|
||||||
|
spi_bitbang = new SPI_BitBang(-1, pin_do, pin_cs, pin_clk);
|
||||||
|
if (spi_bitbang.IsOpened()) {
|
||||||
|
// initialize
|
||||||
|
is_open = true;
|
||||||
|
DecodeMode_None();
|
||||||
|
ScanLimiter_All();
|
||||||
|
}
|
||||||
|
|
||||||
|
return spi_bitbang.IsOpened();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void DecodeMode_None() {
|
||||||
|
|
||||||
|
if (is_open) {
|
||||||
|
|
||||||
|
short command = 0x900; // decode mode = 0 --> no decode
|
||||||
|
boolean result = WriteSPI(command);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
raise_log("DecodeMode_None success");
|
||||||
|
else
|
||||||
|
raise_log("DecodeMode_None failed");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
raise_log("DecodeMode_None failed, no SPI opened");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ScanLimiter_All() {
|
||||||
|
if (is_open) {
|
||||||
|
short command = 0xB07;
|
||||||
|
boolean result = WriteSPI(command);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
raise_log("ScanLimiter_All success");
|
||||||
|
else
|
||||||
|
raise_log("ScanLimiter_All failed");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
raise_log("ScanLimiter_All failed, no SPI opened");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display testing mode
|
||||||
|
* @param testing : if true, will turn on all LED. If false, normal operation
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Test_Display(boolean testing) {
|
||||||
|
short command = 0;
|
||||||
|
if (testing) {
|
||||||
|
command = 0xF01; // all LED should ON
|
||||||
|
} else {
|
||||||
|
command = 0xF00; // normal operation
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_open) {
|
||||||
|
boolean result = WriteSPI(command);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
} else raise_log("Test_Display failed, no SPI opened");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display Shutdown mode
|
||||||
|
* @param shutdown : if true, will shutdown display. If false, normal operation
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Shutdown_Display(boolean shutdown) {
|
||||||
|
short command = 0;
|
||||||
|
if (shutdown) {
|
||||||
|
command = 0xC00; // shutdown display
|
||||||
|
} else {
|
||||||
|
command = 0xC01; // normal operation
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_open) {
|
||||||
|
|
||||||
|
boolean result = WriteSPI(command);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} else raise_log("Shutdown_Display failed, no SPI opened");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if LEDMax7219 is opened or not
|
||||||
|
* @return true if opened
|
||||||
|
*/
|
||||||
|
public boolean getIsOpened() {
|
||||||
|
return is_open;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean WriteSPI(short value) {
|
||||||
|
boolean result = true;
|
||||||
|
if (spi_bitbang!=null) {
|
||||||
|
spi_bitbang.setCS(true);
|
||||||
|
result = spi_bitbang.Write16(value);
|
||||||
|
spi_bitbang.setCS(false);
|
||||||
|
} else if (spidev!=null) {
|
||||||
|
try {
|
||||||
|
spidev.write(value);
|
||||||
|
} catch (IOException e) {
|
||||||
|
result = false;
|
||||||
|
raise_log("WriteSPI spidev value= "+value+", exception, Msg = "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
raise_log("Error WriteSPI value="+value);
|
||||||
|
result =false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Buffer to LED Max7219
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Update_Display() {
|
||||||
|
boolean result = true;
|
||||||
|
if (is_open) {
|
||||||
|
if (graphic!=null) {
|
||||||
|
int blockcount = graphic.getBlocks();
|
||||||
|
for(int row=0;row<8;row++) {
|
||||||
|
for(int ii=0;ii<blockcount;ii++) {
|
||||||
|
LEDBlock ledblock = graphic.GetLEDBlock(ii, 0);
|
||||||
|
WriteSPI(ledblock.GetRowValue(ii));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else result = false;
|
||||||
|
} else result = false;
|
||||||
|
raise_updateresult(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close LEDMax7219
|
||||||
|
*/
|
||||||
|
public void Close() {
|
||||||
|
if (is_open) {
|
||||||
|
graphic.All_OFF();
|
||||||
|
Update_Display();
|
||||||
|
Shutdown_Display(true);
|
||||||
|
|
||||||
|
if (spi_bitbang!=null) {
|
||||||
|
spi_bitbang.Close();
|
||||||
|
spi_bitbang = null;
|
||||||
|
} else if (spidev!=null) {
|
||||||
|
spidev = null;
|
||||||
|
}
|
||||||
|
is_open = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
raise_log("LEDMax7219 closed");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
ba.raiseEventFromDifferentThread(myobject, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_updateresult(boolean result) {
|
||||||
|
if (need_updateresult_event) {
|
||||||
|
ba.raiseEventFromDifferentThread(myobject, null, 0, event+"_updateresult", false, new Object[] {result});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
114
src/devices/Oled/SSD1306/Font12X16.java
Normal file
114
src/devices/Oled/SSD1306/Font12X16.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font12X16")
|
||||||
|
public class Font12X16 extends FontPack {
|
||||||
|
|
||||||
|
public Font12X16() {
|
||||||
|
super("Font12X16", 12, 16, 13, 18, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <space>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // !
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // "
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // #
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // $
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // %
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // &
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // '
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // (
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // )
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // *
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // +
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ,
|
||||||
|
0x0000,0x0000,0x0100,0x0380,0x0380,0x0380,0x0380,0x0380,0x0380,0x0100,0x0000,0x0000, // -
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0xc000,0xc000,0x0000,0x0000,0x0000,0x0000,0x0000, // .
|
||||||
|
0x0000,0x0000,0x8102,0xc386,0xc386,0xc386,0xc386,0xc386,0xc386,0x8102,0x0000,0x0000, // /
|
||||||
|
|
||||||
|
0x0000,0x7efc,0xbc7a,0xc006,0xc006,0xc006,0xc006,0xc006,0xc006,0xbc7a,0x7efc,0x0000, // 0
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3c78,0x7efc,0x0000, // 1
|
||||||
|
0x0000,0x7e00,0xbd02,0xc386,0xc386,0xc386,0xc386,0xc386,0xc386,0x817a,0x00fc,0x0000, // 2
|
||||||
|
0x0000,0x0000,0x8102,0xc386,0xc386,0xc386,0xc386,0xc386,0xc386,0xbd7a,0x7efc,0x0000, // 3
|
||||||
|
0x0000,0x00fc,0x0178,0x0380,0x0380,0x0380,0x0380,0x0380,0x0380,0x3d78,0x7efc,0x0000, // 4
|
||||||
|
0x0000,0x00fc,0x817a,0xc386,0xc386,0xc386,0xc386,0xc386,0xc386,0xbd02,0x7e00,0x0000, // 5
|
||||||
|
0x0000,0x7efc,0xbd7a,0xc386,0xc386,0xc386,0xc386,0xc386,0xc386,0xbd02,0x7e00,0x0000, // 6
|
||||||
|
0x0000,0x0000,0x0002,0x0006,0x0006,0x0006,0x0006,0x0006,0x0006,0x3c7a,0x7efc,0x0000, // 7
|
||||||
|
0x0000,0x7efc,0xbd7a,0xc386,0xc386,0xc386,0xc386,0xc386,0xc386,0xbd7a,0x7efc,0x0000, // 8
|
||||||
|
0x0000,0x00fc,0x817a,0xc386,0xc386,0xc386,0xc386,0xc386,0xc386,0xbd7a,0x7efc,0x0000, // 9
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // :
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ;
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // =
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // >
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ?
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // @
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // A
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // B
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // C
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // D
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // E
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // F
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // G
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // H
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // I
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // J
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // K
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // L
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // M
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // N
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // O
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // P
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // R
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // S
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // T
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // U
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // V
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // W
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // X
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Y
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // Z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // [
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // \ <backslash>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ]
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ^
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // _
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ` <grave accent>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // a
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // b
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // c
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // d
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // e
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // f
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // g
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // h
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // i
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // j
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // k
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // l
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // m
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // n
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // o
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // p
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // r
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // s
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // t
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // u
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // v
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // w
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // x
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // y
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // |
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // }
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
112
src/devices/Oled/SSD1306/Font16X16.java
Normal file
112
src/devices/Oled/SSD1306/Font16X16.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font16X16")
|
||||||
|
public class Font16X16 extends FontPack {
|
||||||
|
public Font16X16() {
|
||||||
|
super("Font16X16",16,16,16,16,32,126);
|
||||||
|
data = new int[] {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <space>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x00f8,0x73fc,0x73fc,0x73fc,0x00f8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // !
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x001e,0x003e,0x003e,0x0000,0x0000,0x0000,0x003e,0x003e,0x001e,0x0000,0x0000,0x0000, // "
|
||||||
|
0x0000,0x0c30,0x0c30,0x0c30,0x7ffe,0x7ffe,0x0c30,0x0c30,0x0c30,0x0c30,0x7ffe,0x7ffe,0x0c30,0x0c30,0x0c30,0x0000, // #
|
||||||
|
0x0000,0x0000,0x0000,0x18f0,0x19f8,0x1998,0x7ffe,0x1998,0x1998,0x7ffe,0x1998,0x1f98,0x0f18,0x0000,0x0000,0x0000, // $
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1c38,0x0e38,0x0738,0x0380,0x01c0,0x1ce0,0x1c70,0x1c38,0x0000,0x0000,0x0000,0x0000, // %
|
||||||
|
0x0000,0x0000,0x0000,0x1e38,0x3ffc,0x21c4,0x21c4,0x33fc,0x3f38,0x1e00,0x1e00,0x3700,0x2380,0x0000,0x0000,0x0000, // &
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0020,0x003c,0x003c,0x001c,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // '
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x03c0,0x07e0,0x0ff0,0x1c38,0x381c,0x300c,0x2004,0x2004,0x0000,0x0000,0x0000,0x0000, // (
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2004,0x2004,0x300c,0x381c,0x1c38,0x0ff0,0x07e0,0x03c0,0x0000,0x0000,0x0000,0x0000, // )
|
||||||
|
0x0000,0x0000,0x0180,0x1188,0x0990,0x07e0,0x07e0,0x3ffc,0x3ffc,0x07e0,0x07e0,0x0990,0x1188,0x0180,0x0000,0x0000, // *
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0180,0x0180,0x0180,0x0ff0,0x0ff0,0x0180,0x0180,0x0180,0x0000,0x0000,0x0000,0x0000, // +
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x4000,0x7800,0x7800,0x3800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ,
|
||||||
|
0x0000,0x0000,0x0000,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0000,0x0000,0x0000, // -
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x3800,0x3800,0x3800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // .
|
||||||
|
0x0000,0x0000,0x0000,0x2000,0x3000,0x3800,0x1c00,0x0e00,0x0700,0x0380,0x01c0,0x00e0,0x0070,0x0038,0x001c,0x0000, // /
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x1ff8,0x3ffc,0x3ffc,0x2e04,0x2784,0x21e4,0x2074,0x3ffc,0x3ffc,0x1ff8,0x0000,0x0000,0x0000, // 0
|
||||||
|
0x0000,0x0000,0x0000,0x2060,0x2060,0x2060,0x3ff0,0x3ffc,0x3ffc,0x2000,0x2000,0x2000,0x0000,0x0000,0x0000,0x0000, // 1
|
||||||
|
0x0000,0x0000,0x0000,0x3018,0x381c,0x3c1c,0x2e04,0x2704,0x2384,0x21cc,0x38fc,0x3878,0x3830,0x0000,0x0000,0x0000, // 2
|
||||||
|
0x0000,0x0000,0x0000,0x1818,0x381c,0x381c,0x2184,0x2184,0x2184,0x33cc,0x3e7c,0x1e78,0x0c30,0x0000,0x0000,0x0000, // 3
|
||||||
|
0x0000,0x0000,0x0000,0x0380,0x03c0,0x0360,0x2330,0x2318,0x3ffc,0x3ffc,0x3ffc,0x2300,0x2300,0x0000,0x0000,0x0000, // 4
|
||||||
|
0x0000,0x0000,0x0000,0x19fc,0x39fc,0x39fc,0x2184,0x2184,0x2184,0x3384,0x3f84,0x1f04,0x0e04,0x0000,0x0000,0x0000, // 5
|
||||||
|
0x0000,0x0000,0x0000,0x1fe0,0x3ff0,0x3ff8,0x219c,0x218c,0x2184,0x2184,0x3f84,0x3f80,0x1f00,0x0000,0x0000,0x0000, // 6
|
||||||
|
0x0000,0x0000,0x0000,0x003c,0x003c,0x003c,0x3804,0x3c04,0x3e04,0x0704,0x0384,0x01fc,0x00fc,0x007c,0x0000,0x0000, // 7
|
||||||
|
0x0000,0x0000,0x0000,0x1e78,0x3e7c,0x3ffc,0x21c4,0x21c4,0x2384,0x2384,0x3ffc,0x3e7c,0x1e78,0x0000,0x0000,0x0000, // 8
|
||||||
|
0x0000,0x0000,0x0000,0x00f8,0x01fc,0x21fc,0x2184,0x2184,0x3184,0x3984,0x1ffc,0x0ffc,0x07f8,0x0000,0x0000,0x0000, // 9
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0e70,0x0e70,0x0e70,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // :
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x1000,0x1e70,0x1e70,0x0e70,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ;
|
||||||
|
0x0000,0x0000,0x0000,0x0180,0x03c0,0x07e0,0x0e70,0x1c38,0x381c,0x700e,0x6006,0x4002,0x0000,0x0000,0x0000,0x0000, // <
|
||||||
|
0x0000,0x0000,0x0660,0x0660,0x0660,0x0660,0x0660,0x0660,0x0660,0x0660,0x0660,0x0660,0x0660,0x0660,0x0000,0x0000, // =
|
||||||
|
0x0000,0x0000,0x0000,0x4002,0x6006,0x700e,0x381c,0x1c38,0x0e70,0x07e0,0x03c0,0x0180,0x0000,0x0000,0x0000,0x0000, // >
|
||||||
|
0x0000,0x0000,0x0000,0x0018,0x001c,0x000c,0x000e,0x7306,0x7386,0x73ce,0x00fc,0x007c,0x0038,0x0000,0x0000,0x0000, // ?
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x3ffc,0x3ffe,0x7ffe,0x6002,0x6002,0x63c2,0x63c2,0x63c2,0x63fe,0x43fe,0x03fc,0x0000,0x0000, // @
|
||||||
|
0x0000,0x0000,0x0000,0x3fe0,0x3ff0,0x3ff8,0x021c,0x020c,0x020c,0x021c,0x3ff8,0x3ff0,0x3fe0,0x0000,0x0000,0x0000, // A
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2184,0x2184,0x2184,0x3ffc,0x3ffc,0x1e78,0x0000,0x0000,0x0000, // B
|
||||||
|
0x0000,0x0000,0x0000,0x0ff0,0x1ff8,0x3ffc,0x300c,0x2004,0x2004,0x2004,0x381c,0x381c,0x1818,0x0000,0x0000,0x0000, // C
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2004,0x2004,0x300c,0x3ffc,0x1ff8,0x0ff0,0x0000,0x0000,0x0000, // D
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2184,0x2184,0x2184,0x23c4,0x33cc,0x381c,0x0000,0x0000,0x0000, // E
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2184,0x0184,0x0184,0x03c4,0x03cc,0x001c,0x0000,0x0000,0x0000, // F
|
||||||
|
0x0000,0x0000,0x0000,0x0ff0,0x1ff8,0x3ffc,0x300c,0x2004,0x2204,0x2204,0x3e3c,0x3e3c,0x3e38,0x0000,0x0000,0x0000, // G
|
||||||
|
0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x3ffc,0x0180,0x0180,0x0180,0x3ffc,0x3ffc,0x3ffc,0x0000,0x0000,0x0000,0x0000, // H
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2004,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2004,0x2004,0x0000,0x0000,0x0000,0x0000,0x0000, // I
|
||||||
|
0x0000,0x0000,0x1e00,0x1e00,0x3e00,0x2000,0x2000,0x2004,0x2004,0x3ffc,0x3ffc,0x1ffc,0x0004,0x0004,0x0000,0x0000, // J
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x03c0,0x07e0,0x0e70,0x3c3c,0x381c,0x300c,0x0000,0x0000,0x0000, // K
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2004,0x2000,0x2000,0x3000,0x3800,0x3c00,0x0000,0x0000,0x0000, // L
|
||||||
|
0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x3ffc,0x0078,0x00f0,0x01e0,0x00f0,0x0078,0x3ffc,0x3ffc,0x3ffc,0x0000,0x0000, // M
|
||||||
|
0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x3ffc,0x0070,0x00e0,0x01c0,0x0380,0x0700,0x3ffc,0x3ffc,0x3ffc,0x0000,0x0000, // N
|
||||||
|
0x0000,0x0000,0x0000,0x07e0,0x0ff0,0x1ff8,0x381c,0x300c,0x300c,0x300c,0x381c,0x1ff8,0x0ff0,0x07e0,0x0000,0x0000, // O
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2184,0x0184,0x0184,0x01fc,0x01fc,0x0078,0x0000,0x0000,0x0000, // P
|
||||||
|
0x0000,0x0000,0x0000,0x07e0,0x1ff8,0x1ff8,0x181c,0x180c,0x5c04,0x5e0c,0x7e1c,0x7ff8,0x7ff8,0x47e0,0x0000,0x0000, // Q
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x0184,0x0184,0x0384,0x3ffc,0x3ffc,0x3c78,0x0000,0x0000,0x0000, // R
|
||||||
|
0x0000,0x0000,0x0000,0x1c78,0x3cfc,0x3dfc,0x2184,0x2184,0x2184,0x2184,0x3fbc,0x3f3c,0x1e38,0x0000,0x0000,0x0000, // S
|
||||||
|
0x0000,0x0000,0x0000,0x001c,0x000c,0x2004,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2004,0x2004,0x000c,0x001c,0x0000,0x0000, // T
|
||||||
|
0x0000,0x0000,0x0000,0x1ffc,0x3ffc,0x3ffc,0x2000,0x2000,0x2000,0x3ffc,0x3ffc,0x1ffc,0x0000,0x0000,0x0000,0x0000, // U
|
||||||
|
0x0000,0x0000,0x0000,0x07fc,0x0ffc,0x1ffc,0x3800,0x3000,0x3800,0x1ffc,0x0ffc,0x07fc,0x0000,0x0000,0x0000,0x0000, // V
|
||||||
|
0x0000,0x0000,0x0000,0x03fc,0x0ffc,0x3ffc,0x3c00,0x3c00,0x0f80,0x3c00,0x3c00,0x3ffc,0x0ffc,0x03fc,0x0000,0x0000, // W
|
||||||
|
0x0000,0x0000,0x0000,0x381c,0x3c3c,0x3e7c,0x07e0,0x03c0,0x07e0,0x3e7c,0x3c3c,0x381c,0x0000,0x0000,0x0000,0x0000, // X
|
||||||
|
0x0000,0x0000,0x0000,0x007c,0x20fc,0x21fc,0x3f80,0x3f00,0x3f80,0x21fc,0x20fc,0x007c,0x0000,0x0000,0x0000,0x0000, // Y
|
||||||
|
0x0000,0x0000,0x0000,0x383c,0x3c1c,0x3e0c,0x2704,0x2384,0x21c4,0x20e4,0x307c,0x383c,0x3c1c,0x0000,0x0000,0x0000, // Z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x3ffc,0x2004,0x2004,0x2004,0x2004,0x0000,0x0000,0x0000,0x0000, // [
|
||||||
|
0x0000,0x0000,0x0000,0x001c,0x0038,0x0070,0x00e0,0x01c0,0x0380,0x0700,0x0e00,0x1c00,0x1800,0x3000,0x2000,0x2000, // <backslash>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x2004,0x2004,0x2004,0x2004,0x3ffc,0x3ffc,0x3ffc,0x0000,0x0000,0x0000,0x0000, // ]
|
||||||
|
0x0000,0x0000,0x0000,0x0020,0x0030,0x0038,0x001c,0x000e,0x000e,0x001c,0x0038,0x0030,0x0020,0x0000,0x0000,0x0000, // ^
|
||||||
|
0x0000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000, // _
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x000c,0x000c,0x003c,0x0030,0x0030,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // `
|
||||||
|
0x0000,0x0000,0x0000,0x1c00,0x3e40,0x3e40,0x2240,0x2240,0x2240,0x3fc0,0x1fc0,0x3f80,0x2000,0x0000,0x0000,0x0000, // a
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x1ffc,0x3ffc,0x2040,0x2040,0x2040,0x3fc0,0x3fc0,0x1f80,0x0000,0x0000,0x0000, // b
|
||||||
|
0x0000,0x0000,0x0000,0x1f80,0x3fc0,0x3fc0,0x2040,0x2040,0x2040,0x39c0,0x39c0,0x1980,0x0000,0x0000,0x0000,0x0000, // c
|
||||||
|
0x0000,0x0000,0x0000,0x1f80,0x3fc0,0x3fc0,0x2040,0x2040,0x2044,0x3ffc,0x1ffc,0x3ffc,0x2004,0x0000,0x0000,0x0000, // d
|
||||||
|
0x0000,0x0000,0x0000,0x1f80,0x3fc0,0x3fc0,0x2240,0x2240,0x2240,0x3bc0,0x3bc0,0x1b80,0x0000,0x0000,0x0000,0x0000, // e
|
||||||
|
0x0000,0x0000,0x0000,0x2180,0x2180,0x3ff8,0x3ffc,0x3ffc,0x2184,0x219c,0x019c,0x0018,0x0000,0x0000,0x0000,0x0000, // f
|
||||||
|
0x0000,0x0000,0x0000,0x4780,0xcfc0,0xdfc0,0x9840,0x9840,0x9840,0xffc0,0xff80,0x7fc0,0x0040,0x0000,0x0000,0x0000, // g
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x0180,0x0040,0x0040,0x3fc0,0x3fc0,0x3f80,0x0000,0x0000,0x0000, // h
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2040,0x2040,0x2040,0x3fdc,0x3fdc,0x3fdc,0x2000,0x2000,0x2000,0x0000,0x0000,0x0000, // i
|
||||||
|
0x0000,0x0000,0x0000,0x2000,0x6000,0xe000,0x8040,0x8040,0xc040,0xffdc,0xffdc,0x7fdc,0x0000,0x0000,0x0000,0x0000, // j
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x3ffc,0x3ffc,0x3ffc,0x0200,0x0700,0x0f80,0x3dc0,0x38c0,0x3040,0x0000,0x0000,0x0000, // k
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2004,0x2004,0x2004,0x3ffc,0x3ffc,0x3ffc,0x2000,0x2000,0x2000,0x0000,0x0000,0x0000, // l
|
||||||
|
0x0000,0x0000,0x0000,0x3fc0,0x3fc0,0x3fc0,0x0040,0x0040,0x3fc0,0x0040,0x0040,0x3fc0,0x3fc0,0x3f80,0x0000,0x0000, // m
|
||||||
|
0x0000,0x0000,0x0000,0x3fc0,0x3fc0,0x3fc0,0x0040,0x0040,0x0040,0x3fc0,0x3fc0,0x3f80,0x0000,0x0000,0x0000,0x0000, // n
|
||||||
|
0x0000,0x0000,0x0000,0x1f80,0x3fc0,0x3fc0,0x2040,0x2040,0x2040,0x3fc0,0x3fc0,0x1f80,0x0000,0x0000,0x0000,0x0000, // o
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x8040,0xffc0,0xff80,0xffc0,0x9040,0x1040,0x1040,0x1fc0,0x1fc0,0x0f80,0x0000,0x0000,0x0000, // p
|
||||||
|
0x0000,0x0000,0x0f80,0x1fc0,0x1fc0,0x1040,0x1040,0x9040,0xffc0,0xff80,0xffc0,0x8040,0x0000,0x0000,0x0000,0x0000, // q
|
||||||
|
0x0000,0x0000,0x0000,0x2040,0x3fc0,0x3fc0,0x3fc0,0x2180,0x00c0,0x00c0,0x01c0,0x01c0,0x0180,0x0000,0x0000,0x0000, // r
|
||||||
|
0x0000,0x0000,0x0000,0x1980,0x3bc0,0x23c0,0x2640,0x2640,0x2640,0x3c40,0x3dc0,0x1980,0x0000,0x0000,0x0000,0x0000, // s
|
||||||
|
0x0000,0x0000,0x0000,0x0040,0x0040,0x1fe0,0x3ff0,0x3ff8,0x2040,0x3840,0x3840,0x1840,0x0000,0x0000,0x0000,0x0000, // t
|
||||||
|
0x0000,0x0000,0x0000,0x1fc0,0x3fc0,0x3fc0,0x2000,0x2000,0x2000,0x3fc0,0x1fc0,0x3fc0,0x2000,0x0000,0x0000,0x0000, // u
|
||||||
|
0x0000,0x0000,0x0000,0x07c0,0x0fc0,0x1fc0,0x3800,0x3000,0x3800,0x1fc0,0x0fc0,0x07c0,0x0000,0x0000,0x0000,0x0000, // v
|
||||||
|
0x0000,0x0000,0x0000,0x07c0,0x0fc0,0x3fc0,0x3800,0x3800,0x0e00,0x3800,0x3800,0x3fc0,0x0fc0,0x07c0,0x0000,0x0000, // w
|
||||||
|
0x0000,0x0000,0x0000,0x30c0,0x39c0,0x3fc0,0x0f00,0x0f00,0x3fc0,0x39c0,0x30c0,0x0000,0x0000,0x0000,0x0000,0x0000, // x
|
||||||
|
0x0000,0x0000,0x0000,0x8000,0x87c0,0x8fc0,0x9fc0,0xd800,0xf800,0x7800,0x3fc0,0x0fc0,0x07c0,0x0000,0x0000,0x0000, // y
|
||||||
|
0x0000,0x0000,0x0000,0x31c0,0x38c0,0x3c40,0x2e40,0x2740,0x23c0,0x31c0,0x38c0,0x0000,0x0000,0x0000,0x0000,0x0000, // z
|
||||||
|
0x0000,0x0000,0x0000,0x0180,0x0180,0x03c0,0x1e78,0x3e7c,0x3c3c,0x2004,0x2004,0x2004,0x2004,0x0000,0x0000,0x0000, // {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7ffe,0x7ffe,0x7ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // |
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x2004,0x2004,0x2004,0x3c3c,0x3e7c,0x1e78,0x03c0,0x0180,0x0180,0x0000,0x0000,0x0000, // }
|
||||||
|
0x0000,0x0000,0x0038,0x003c,0x003c,0x0004,0x000c,0x001c,0x0038,0x0030,0x0020,0x003c,0x003c,0x001c,0x0000,0x0000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
112
src/devices/Oled/SSD1306/Font5X7.java
Normal file
112
src/devices/Oled/SSD1306/Font5X7.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font5X7")
|
||||||
|
public class Font5X7 extends FontPack {
|
||||||
|
|
||||||
|
public Font5X7() {
|
||||||
|
super("Font_5X7", 5, 7, 6, 9, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // char ' ' (0x20/32)
|
||||||
|
0x00, 0x00, 0x2E, 0x00, 0x00, // char '!' (0x21/33)
|
||||||
|
0x06, 0x00, 0x06, 0x00, 0x00, // char '"' (0x22/34)
|
||||||
|
0x14, 0x7F, 0x14, 0x7F, 0x14, // char '#' (0x23/35)
|
||||||
|
0x06, 0x49, 0x7F, 0x49, 0x30, // char '$' (0x24/36)
|
||||||
|
0x24, 0x10, 0x08, 0x24, 0x00, // char '%' (0x25/37)
|
||||||
|
0x36, 0x49, 0x36, 0x50, 0x00, // char '&' (0x26/38)
|
||||||
|
0x00, 0x00, 0x00, 0x06, 0x00, // char ''' (0x27/39)
|
||||||
|
0x00, 0x41, 0x36, 0x00, 0x00, // char '(' (0x28/40)
|
||||||
|
0x00, 0x36, 0x41, 0x00, 0x00, // char ')' (0x29/41)
|
||||||
|
0x00, 0x08, 0x00, 0x00, 0x00, // char '*' (0x2A/42)
|
||||||
|
0x00, 0x08, 0x1C, 0x08, 0x00, // char '+' (0x2B/43)
|
||||||
|
0x40, 0x20, 0x00, 0x00, 0x00, // char ',' (0x2C/44)
|
||||||
|
0x00, 0x08, 0x08, 0x00, 0x00, // char '-' (0x2D/45)
|
||||||
|
0x20, 0x00, 0x00, 0x00, 0x00, // char '.' (0x2E/46)
|
||||||
|
0x00, 0x30, 0x06, 0x00, 0x00, // char '/' (0x2F/47)
|
||||||
|
0x36, 0x41, 0x41, 0x36, 0x00, // char '0' (0x30/48)
|
||||||
|
0x00, 0x00, 0x00, 0x36, 0x00, // char '1' (0x31/49)
|
||||||
|
0x30, 0x49, 0x49, 0x06, 0x00, // char '2' (0x32/50)
|
||||||
|
0x00, 0x49, 0x49, 0x36, 0x00, // char '3' (0x33/51)
|
||||||
|
0x06, 0x08, 0x08, 0x36, 0x00, // char '4' (0x34/52)
|
||||||
|
0x06, 0x49, 0x49, 0x30, 0x00, // char '5' (0x35/53)
|
||||||
|
0x36, 0x49, 0x49, 0x30, 0x00, // char '6' (0x36/54)
|
||||||
|
0x00, 0x01, 0x01, 0x36, 0x00, // char '7' (0x37/55)
|
||||||
|
0x36, 0x49, 0x49, 0x36, 0x00, // char '8' (0x38/56)
|
||||||
|
0x06, 0x49, 0x49, 0x36, 0x00, // char '9' (0x39/57)
|
||||||
|
0x00, 0x14, 0x00, 0x00, 0x00, // char ':' (0x3A/58)
|
||||||
|
0x20, 0x14, 0x00, 0x00, 0x00, // char ';' (0x3B/59)
|
||||||
|
0x00, 0x08, 0x14, 0x22, 0x00, // char '<' (0x3C/60)
|
||||||
|
0x00, 0x14, 0x14, 0x14, 0x00, // char '=' (0x3D/61)
|
||||||
|
0x00, 0x22, 0x14, 0x08, 0x00, // char '>' (0x3E/62)
|
||||||
|
0x00, 0x01, 0x31, 0x06, 0x00, // char '?' (0x3F/63)
|
||||||
|
0x36, 0x49, 0x55, 0x59, 0x2E, // char '@' (0x40/64)
|
||||||
|
0x36, 0x09, 0x09, 0x36, 0x00, // char 'A' (0x41/65)
|
||||||
|
0x77, 0x49, 0x49, 0x36, 0x00, // char 'B' (0x42/66)
|
||||||
|
0x36, 0x41, 0x41, 0x00, 0x00, // char 'C' (0x43/67)
|
||||||
|
0x77, 0x41, 0x41, 0x36, 0x00, // char 'D' (0x44/68)
|
||||||
|
0x36, 0x49, 0x49, 0x00, 0x00, // char 'E' (0x45/69)
|
||||||
|
0x36, 0x09, 0x09, 0x00, 0x00, // char 'F' (0x46/70)
|
||||||
|
0x36, 0x41, 0x51, 0x30, 0x00, // char 'G' (0x47/71)
|
||||||
|
0x36, 0x08, 0x08, 0x36, 0x00, // char 'H' (0x48/72)
|
||||||
|
0x00, 0x00, 0x36, 0x00, 0x00, // char 'I' (0x49/73)
|
||||||
|
0x00, 0x40, 0x40, 0x36, 0x00, // char 'J' (0x4A/74)
|
||||||
|
0x36, 0x08, 0x14, 0x22, 0x00, // char 'K' (0x4B/75)
|
||||||
|
0x36, 0x40, 0x40, 0x00, 0x00, // char 'L' (0x4C/76)
|
||||||
|
0x36, 0x01, 0x06, 0x01, 0x36, // char 'M' (0x4D/77)
|
||||||
|
0x36, 0x04, 0x10, 0x36, 0x00, // char 'N' (0x4E/78)
|
||||||
|
0x36, 0x41, 0x41, 0x36, 0x00, // char 'O' (0x4F/79)
|
||||||
|
0x36, 0x09, 0x09, 0x06, 0x00, // char 'P' (0x50/80)
|
||||||
|
0x36, 0x41, 0x21, 0x56, 0x00, // char 'Q' (0x51/81)
|
||||||
|
0x36, 0x09, 0x19, 0x26, 0x00, // char 'R' (0x52/82)
|
||||||
|
0x06, 0x49, 0x49, 0x30, 0x00, // char 'S' (0x53/83)
|
||||||
|
0x00, 0x01, 0x37, 0x01, 0x00, // char 'T' (0x54/84)
|
||||||
|
0x36, 0x40, 0x40, 0x36, 0x00, // char 'U' (0x55/85)
|
||||||
|
0x36, 0x40, 0x36, 0x00, 0x00, // char 'V' (0x56/86)
|
||||||
|
0x36, 0x40, 0x30, 0x40, 0x36, // char 'W' (0x57/87)
|
||||||
|
0x36, 0x08, 0x08, 0x36, 0x00, // char 'X' (0x58/88)
|
||||||
|
0x06, 0x48, 0x48, 0x36, 0x00, // char 'Y' (0x59/89)
|
||||||
|
0x20, 0x51, 0x49, 0x45, 0x02, // char 'Z' (0x5A/90)
|
||||||
|
0x77, 0x41, 0x41, 0x00, 0x00, // char '[' (0x5B/91)
|
||||||
|
0x00, 0x06, 0x30, 0x00, 0x00, // char '\' (0x5C/92)
|
||||||
|
0x00, 0x41, 0x41, 0x77, 0x00, // char ']' (0x5D/93)
|
||||||
|
0x00, 0x02, 0x01, 0x02, 0x00, // char '^' (0x5E/94)
|
||||||
|
0x00, 0x40, 0x40, 0x00, 0x00, // char '_' (0x5F/95)
|
||||||
|
0x00, 0x01, 0x02, 0x00, 0x00, // char '`' (0x60/96)
|
||||||
|
0x20, 0x54, 0x54, 0x38, 0x40, // char 'a' (0x61/97)
|
||||||
|
0x00, 0x36, 0x48, 0x30, 0x00, // char 'b' (0x62/98)
|
||||||
|
0x30, 0x48, 0x48, 0x00, 0x00, // char 'c' (0x63/99)
|
||||||
|
0x30, 0x48, 0x48, 0x76, 0x00, // char 'd' (0x64/100)
|
||||||
|
0x38, 0x54, 0x54, 0x08, 0x00, // char 'e' (0x65/101)
|
||||||
|
0x08, 0x6C, 0x0A, 0x00, 0x00, // char 'f' (0x66/102)
|
||||||
|
0x08, 0x54, 0x54, 0x38, 0x00, // char 'g' (0x67/103)
|
||||||
|
0x36, 0x08, 0x08, 0x30, 0x00, // char 'h' (0x68/104)
|
||||||
|
0x00, 0x34, 0x00, 0x00, 0x00, // char 'i' (0x69/105)
|
||||||
|
0x00, 0x40, 0x34, 0x00, 0x00, // char 'j' (0x6A/106)
|
||||||
|
0x36, 0x10, 0x28, 0x00, 0x00, // char 'k' (0x6B/107)
|
||||||
|
0x36, 0x00, 0x00, 0x00, 0x00, // char 'l' (0x6C/108)
|
||||||
|
0x30, 0x08, 0x10, 0x08, 0x30, // char 'm' (0x6D/109)
|
||||||
|
0x30, 0x08, 0x08, 0x30, 0x00, // char 'n' (0x6E/110)
|
||||||
|
0x30, 0x48, 0x48, 0x30, 0x00, // char 'o' (0x6F/111)
|
||||||
|
0x78, 0x14, 0x14, 0x08, 0x00, // char 'p' (0x70/112)
|
||||||
|
0x08, 0x14, 0x14, 0x68, 0x00, // char 'q' (0x71/113)
|
||||||
|
0x30, 0x08, 0x08, 0x00, 0x00, // char 'r' (0x72/114)
|
||||||
|
0x08, 0x54, 0x54, 0x20, 0x00, // char 's' (0x73/115)
|
||||||
|
0x08, 0x2C, 0x48, 0x00, 0x00, // char 't' (0x74/116)
|
||||||
|
0x30, 0x40, 0x40, 0x30, 0x00, // char 'u' (0x75/117)
|
||||||
|
0x30, 0x40, 0x30, 0x00, 0x00, // char 'v' (0x76/118)
|
||||||
|
0x30, 0x40, 0x20, 0x40, 0x30, // char 'w' (0x77/119)
|
||||||
|
0x28, 0x10, 0x10, 0x28, 0x00, // char 'x' (0x78/120)
|
||||||
|
0x08, 0x50, 0x50, 0x38, 0x00, // char 'y' (0x79/121)
|
||||||
|
0x24, 0x34, 0x2C, 0x24, 0x00, // char 'z' (0x7A/122)
|
||||||
|
0x08, 0x36, 0x41, 0x00, 0x00, // char '{' (0x7B/123)
|
||||||
|
0x00, 0x36, 0x00, 0x00, 0x00, // char '|' (0x7C/124)
|
||||||
|
0x00, 0x41, 0x36, 0x08, 0x00, // char '}' (0x7D/125)
|
||||||
|
0x08, 0x08, 0x10, 0x10, 0x00, // char '~' (0x7E/126)
|
||||||
|
0x36, 0x41, 0x36, 0x00, 0x00, // char '' (0x7F/127)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
111
src/devices/Oled/SSD1306/Font6X8.java
Normal file
111
src/devices/Oled/SSD1306/Font6X8.java
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font6X8")
|
||||||
|
public class Font6X8 extends FontPack {
|
||||||
|
|
||||||
|
public Font6X8() {
|
||||||
|
super("Font6X8", 6, 8, 7, 9, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp
|
||||||
|
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // !
|
||||||
|
0x00, 0x00, 0x07, 0x00, 0x07, 0x00, // "
|
||||||
|
0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14, // #
|
||||||
|
0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12, // $
|
||||||
|
0x00, 0x23, 0x13, 0x08, 0x64, 0x62, // %
|
||||||
|
0x00, 0x36, 0x49, 0x55, 0x22, 0x50, // &
|
||||||
|
0x00, 0x00, 0x05, 0x03, 0x00, 0x00, // '
|
||||||
|
0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, // (
|
||||||
|
0x00, 0x00, 0x41, 0x22, 0x1c, 0x00, // )
|
||||||
|
0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, // *
|
||||||
|
0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, // +
|
||||||
|
0x00, 0x00, 0x00, 0xA0, 0x60, 0x00, // ,
|
||||||
|
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, // -
|
||||||
|
0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // .
|
||||||
|
0x00, 0x20, 0x10, 0x08, 0x04, 0x02, // /
|
||||||
|
0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
|
||||||
|
0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, // 1
|
||||||
|
0x00, 0x42, 0x61, 0x51, 0x49, 0x46, // 2
|
||||||
|
0x00, 0x21, 0x41, 0x45, 0x4B, 0x31, // 3
|
||||||
|
0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, // 4
|
||||||
|
0x00, 0x27, 0x45, 0x45, 0x45, 0x39, // 5
|
||||||
|
0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, // 6
|
||||||
|
0x00, 0x01, 0x71, 0x09, 0x05, 0x03, // 7
|
||||||
|
0x00, 0x36, 0x49, 0x49, 0x49, 0x36, // 8
|
||||||
|
0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, // 9
|
||||||
|
0x00, 0x00, 0x36, 0x36, 0x00, 0x00, // :
|
||||||
|
0x00, 0x00, 0x56, 0x36, 0x00, 0x00, // ;
|
||||||
|
0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // <
|
||||||
|
0x00, 0x14, 0x14, 0x14, 0x14, 0x14, // =
|
||||||
|
0x00, 0x00, 0x41, 0x22, 0x14, 0x08, // >
|
||||||
|
0x00, 0x02, 0x01, 0x51, 0x09, 0x06, // ?
|
||||||
|
0x00, 0x32, 0x49, 0x59, 0x51, 0x3E, // @
|
||||||
|
0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, // A
|
||||||
|
0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, // B
|
||||||
|
0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, // C
|
||||||
|
0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, // D
|
||||||
|
0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, // E
|
||||||
|
0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, // F
|
||||||
|
0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, // G
|
||||||
|
0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, // H
|
||||||
|
0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, // I
|
||||||
|
0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, // J
|
||||||
|
0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, // K
|
||||||
|
0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, // L
|
||||||
|
0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
|
||||||
|
0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, // N
|
||||||
|
0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, // O
|
||||||
|
0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, // P
|
||||||
|
0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, // Q
|
||||||
|
0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, // R
|
||||||
|
0x00, 0x46, 0x49, 0x49, 0x49, 0x31, // S
|
||||||
|
0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, // T
|
||||||
|
0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, // U
|
||||||
|
0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, // V
|
||||||
|
0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, // W
|
||||||
|
0x00, 0x63, 0x14, 0x08, 0x14, 0x63, // X
|
||||||
|
0x00, 0x07, 0x08, 0x70, 0x08, 0x07, // Y
|
||||||
|
0x00, 0x61, 0x51, 0x49, 0x45, 0x43, // Z
|
||||||
|
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // [
|
||||||
|
0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55, // 55
|
||||||
|
0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, // ]
|
||||||
|
0x00, 0x04, 0x02, 0x01, 0x02, 0x04, // ^
|
||||||
|
0x00, 0x40, 0x40, 0x40, 0x40, 0x40, // _
|
||||||
|
0x00, 0x00, 0x01, 0x02, 0x04, 0x00, // '
|
||||||
|
0x00, 0x20, 0x54, 0x54, 0x54, 0x78, // a
|
||||||
|
0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, // b
|
||||||
|
0x00, 0x38, 0x44, 0x44, 0x44, 0x20, // c
|
||||||
|
0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, // d
|
||||||
|
0x00, 0x38, 0x54, 0x54, 0x54, 0x18, // e
|
||||||
|
0x00, 0x08, 0x7E, 0x09, 0x01, 0x02, // f
|
||||||
|
0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, // g
|
||||||
|
0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, // h
|
||||||
|
0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, // i
|
||||||
|
0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, // j
|
||||||
|
0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // k
|
||||||
|
0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, // l
|
||||||
|
0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, // m
|
||||||
|
0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, // n
|
||||||
|
0x00, 0x38, 0x44, 0x44, 0x44, 0x38, // o
|
||||||
|
0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, // p
|
||||||
|
0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, // q
|
||||||
|
0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, // r
|
||||||
|
0x00, 0x48, 0x54, 0x54, 0x54, 0x20, // s
|
||||||
|
0x00, 0x04, 0x3F, 0x44, 0x40, 0x20, // t
|
||||||
|
0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, // u
|
||||||
|
0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, // v
|
||||||
|
0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, // w
|
||||||
|
0x00, 0x44, 0x28, 0x10, 0x28, 0x44, // x
|
||||||
|
0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, // y
|
||||||
|
0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, // z
|
||||||
|
0x00, 0x00, 0x08, 0x77, 0x00, 0x00, // {
|
||||||
|
0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, // |
|
||||||
|
0x00, 0x00, 0x77, 0x08, 0x00, 0x00, // }
|
||||||
|
0x00, 0x10, 0x08, 0x10, 0x08, 0x00, // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
112
src/devices/Oled/SSD1306/Font8X12.java
Normal file
112
src/devices/Oled/SSD1306/Font8X12.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font8X12")
|
||||||
|
public class Font8X12 extends FontPack{
|
||||||
|
public Font8X12() {
|
||||||
|
super("Font8X12", 8, 12, 8, 12, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, // <space>
|
||||||
|
0x000,0x000,0x2fc,0x000,0x000,0x000,0x000,0x000, // !
|
||||||
|
0x000,0x00c,0x002,0x00c,0x002,0x000,0x000,0x000, // "
|
||||||
|
0x090,0x3d0,0x0bc,0x3d0,0x0bc,0x090,0x000,0x000, // #
|
||||||
|
0x318,0x224,0x7fe,0x244,0x18c,0x000,0x000,0x000, // $
|
||||||
|
0x018,0x324,0x0d8,0x1b0,0x24c,0x180,0x000,0x000, // %
|
||||||
|
0x1c0,0x238,0x2e4,0x138,0x2e0,0x200,0x000,0x000, // &
|
||||||
|
0x008,0x006,0x000,0x000,0x000,0x000,0x000,0x000, // '
|
||||||
|
0x000,0x000,0x000,0x1f8,0x204,0x402,0x000,0x000, // (
|
||||||
|
0x000,0x402,0x204,0x1f8,0x000,0x000,0x000,0x000, // )
|
||||||
|
0x090,0x060,0x1f8,0x060,0x090,0x000,0x000,0x000, // *
|
||||||
|
0x020,0x020,0x1fc,0x020,0x020,0x000,0x000,0x000, // +
|
||||||
|
0x800,0x600,0x000,0x000,0x000,0x000,0x000,0x000, // ,
|
||||||
|
0x020,0x020,0x020,0x020,0x020,0x000,0x000,0x000, // -
|
||||||
|
0x000,0x200,0x000,0x000,0x000,0x000,0x000,0x000, // .
|
||||||
|
0x400,0x380,0x060,0x01c,0x002,0x000,0x000,0x000, // /
|
||||||
|
|
||||||
|
0x1f8,0x204,0x204,0x204,0x1f8,0x000,0x000,0x000, // 0
|
||||||
|
0x000,0x208,0x3fc,0x200,0x000,0x000,0x000,0x000, // 1
|
||||||
|
0x318,0x284,0x244,0x224,0x218,0x000,0x000,0x000, // 2
|
||||||
|
0x108,0x204,0x224,0x224,0x1d8,0x000,0x000,0x000, // 3
|
||||||
|
0x040,0x0b0,0x088,0x3fc,0x280,0x000,0x000,0x000, // 4
|
||||||
|
0x13c,0x224,0x224,0x224,0x1c4,0x000,0x000,0x000, // 5
|
||||||
|
0x1f8,0x224,0x224,0x22c,0x1c0,0x000,0x000,0x000, // 6
|
||||||
|
0x00c,0x004,0x3e4,0x01c,0x004,0x000,0x000,0x000, // 7
|
||||||
|
0x1d8,0x224,0x224,0x224,0x1d8,0x000,0x000,0x000, // 8
|
||||||
|
0x038,0x344,0x244,0x244,0x1f8,0x000,0x000,0x000, // 9
|
||||||
|
0x000,0x000,0x210,0x000,0x000,0x000,0x000,0x000, // :
|
||||||
|
0x000,0x000,0x620,0x000,0x000,0x000,0x000,0x000, // ;
|
||||||
|
0x000,0x020,0x050,0x088,0x104,0x202,0x000,0x000, // <
|
||||||
|
0x090,0x090,0x090,0x090,0x090,0x000,0x000,0x000, // =
|
||||||
|
0x000,0x202,0x104,0x088,0x050,0x020,0x000,0x000, // >
|
||||||
|
0x018,0x004,0x2c4,0x024,0x018,0x000,0x000,0x000, // ?
|
||||||
|
|
||||||
|
0x1f8,0x204,0x2e4,0x294,0x2f8,0x000,0x000,0x000, // @
|
||||||
|
0x200,0x3e0,0x09c,0x0f0,0x380,0x200,0x000,0x000, // A
|
||||||
|
0x204,0x3fc,0x224,0x224,0x1d8,0x000,0x000,0x000, // B
|
||||||
|
0x1f8,0x204,0x204,0x204,0x10c,0x000,0x000,0x000, // C
|
||||||
|
0x204,0x3fc,0x204,0x204,0x1f8,0x000,0x000,0x000, // D
|
||||||
|
0x204,0x3fc,0x224,0x274,0x30c,0x000,0x000,0x000, // E
|
||||||
|
0x204,0x3fc,0x224,0x074,0x00c,0x000,0x000,0x000, // F
|
||||||
|
0x0f0,0x108,0x204,0x244,0x1cc,0x040,0x000,0x000, // G
|
||||||
|
0x204,0x3fc,0x020,0x020,0x3fc,0x204,0x000,0x000, // H
|
||||||
|
0x204,0x204,0x3fc,0x204,0x204,0x000,0x000,0x000, // I
|
||||||
|
0x600,0x404,0x404,0x3fc,0x004,0x004,0x000,0x000, // J
|
||||||
|
0x204,0x3fc,0x224,0x0d0,0x30c,0x204,0x000,0x000, // K
|
||||||
|
0x204,0x3fc,0x204,0x200,0x200,0x300,0x000,0x000, // L
|
||||||
|
0x3fc,0x03c,0x3c0,0x03c,0x3fc,0x000,0x000,0x000, // M
|
||||||
|
0x204,0x3fc,0x230,0x0c4,0x3fc,0x004,0x000,0x000, // N
|
||||||
|
0x1f8,0x204,0x204,0x204,0x1f8,0x000,0x000,0x000, // O
|
||||||
|
|
||||||
|
0x204,0x3fc,0x224,0x024,0x018,0x000,0x000,0x000, // P
|
||||||
|
0x1f8,0x284,0x284,0x704,0x5f8,0x000,0x000,0x000, // Q
|
||||||
|
0x204,0x3fc,0x224,0x064,0x398,0x200,0x000,0x000, // R
|
||||||
|
0x318,0x224,0x224,0x244,0x18c,0x000,0x000,0x000, // S
|
||||||
|
0x00c,0x204,0x3fc,0x204,0x00c,0x000,0x000,0x000, // T
|
||||||
|
0x004,0x1fc,0x200,0x200,0x1fc,0x004,0x000,0x000, // U
|
||||||
|
0x004,0x07c,0x380,0x0e0,0x01c,0x004,0x000,0x000, // V
|
||||||
|
0x01c,0x3e0,0x03c,0x3e0,0x01c,0x000,0x000,0x000, // W
|
||||||
|
0x204,0x39c,0x060,0x39c,0x204,0x000,0x000,0x000, // X
|
||||||
|
0x004,0x21c,0x3e0,0x21c,0x004,0x000,0x000,0x000, // Y
|
||||||
|
0x20c,0x384,0x264,0x21c,0x304,0x000,0x000,0x000, // Z
|
||||||
|
0x000,0x000,0x7fe,0x402,0x402,0x000,0x000,0x000, // [
|
||||||
|
0x000,0x00e,0x030,0x1c0,0x200,0x000,0x000,0x000, // <backslash>
|
||||||
|
0x000,0x402,0x402,0x7fe,0x000,0x000,0x000,0x000, // ]
|
||||||
|
0x000,0x004,0x002,0x004,0x000,0x000,0x000,0x000, // ^
|
||||||
|
0x800,0x800,0x800,0x800,0x800,0x800,0x000,0x000, // _
|
||||||
|
|
||||||
|
0x000,0x000,0x002,0x000,0x000,0x000,0x000,0x000, // `
|
||||||
|
0x000,0x140,0x2a0,0x2a0,0x3c0,0x200,0x000,0x000, // a
|
||||||
|
0x004,0x3fc,0x220,0x220,0x1c0,0x000,0x000,0x000, // b
|
||||||
|
0x000,0x1c0,0x220,0x220,0x260,0x000,0x000,0x000, // c
|
||||||
|
0x000,0x1c0,0x220,0x224,0x3fc,0x200,0x000,0x000, // d
|
||||||
|
0x000,0x1c0,0x2a0,0x2a0,0x2c0,0x000,0x000,0x000, // e
|
||||||
|
0x000,0x220,0x3f8,0x224,0x224,0x004,0x000,0x000, // f
|
||||||
|
0x000,0x740,0xaa0,0xaa0,0xa60,0x420,0x000,0x000, // g
|
||||||
|
0x204,0x3fc,0x220,0x020,0x3c0,0x200,0x000,0x000, // h
|
||||||
|
0x000,0x220,0x3e4,0x200,0x000,0x000,0x000,0x000, // i
|
||||||
|
0x800,0x800,0x820,0x7e4,0x000,0x000,0x000,0x000, // j
|
||||||
|
0x204,0x3fc,0x280,0x0e0,0x320,0x220,0x000,0x000, // k
|
||||||
|
0x204,0x204,0x3fc,0x200,0x200,0x000,0x000,0x000, // l
|
||||||
|
0x3e0,0x020,0x3e0,0x020,0x3c0,0x000,0x000,0x000, // m
|
||||||
|
0x220,0x3e0,0x220,0x020,0x3c0,0x200,0x000,0x000, // n
|
||||||
|
0x000,0x1c0,0x220,0x220,0x1c0,0x000,0x000,0x000, // o
|
||||||
|
|
||||||
|
0x820,0xfe0,0xa20,0x220,0x1c0,0x000,0x000,0x000, // p
|
||||||
|
0x000,0x1c0,0x220,0xa20,0xfe0,0x800,0x000,0x000, // q
|
||||||
|
0x220,0x3e0,0x240,0x020,0x020,0x000,0x000,0x000, // r
|
||||||
|
0x000,0x260,0x2a0,0x2a0,0x320,0x000,0x000,0x000, // s
|
||||||
|
0x000,0x020,0x1f8,0x220,0x200,0x000,0x000,0x000, // t
|
||||||
|
0x020,0x1e0,0x200,0x220,0x3e0,0x200,0x000,0x000, // u
|
||||||
|
0x020,0x0e0,0x320,0x180,0x060,0x020,0x000,0x000, // v
|
||||||
|
0x060,0x380,0x0e0,0x380,0x060,0x000,0x000,0x000, // w
|
||||||
|
0x220,0x360,0x080,0x360,0x220,0x000,0x000,0x000, // x
|
||||||
|
0x820,0x8e0,0x720,0x180,0x060,0x020,0x000,0x000, // y
|
||||||
|
0x000,0x220,0x3a0,0x260,0x220,0x000,0x000,0x000, // z
|
||||||
|
0x000,0x000,0x020,0x7de,0x402,0x000,0x000,0x000, // {
|
||||||
|
0x000,0x000,0x000,0xfff,0x000,0x000,0x000,0x000, // |
|
||||||
|
0x000,0x402,0x7de,0x020,0x000,0x000,0x000,0x000, // }
|
||||||
|
0x002,0x001,0x002,0x004,0x004,0x002,0x000,0x000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
114
src/devices/Oled/SSD1306/Font8X16.java
Normal file
114
src/devices/Oled/SSD1306/Font8X16.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font8X16")
|
||||||
|
public class Font8X16 extends FontPack {
|
||||||
|
|
||||||
|
public Font8X16() {
|
||||||
|
super("Font8X16", 8, 16, 9, 18, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <space>
|
||||||
|
0x0000,0x0000,0x0000,0x33ff,0x0000,0x0000,0x0000,0x0000, // !
|
||||||
|
0x0000,0x0000,0x003f,0x0000,0x0000,0x003f,0x0000,0x0000, // "
|
||||||
|
0x0000,0x0330,0x3fff,0x0330,0x0330,0x3fff,0x0330,0x0000, // #
|
||||||
|
0x0000,0x0c30,0x0ccc,0x3fff,0x0ccc,0x030c,0x0000,0x0000, // $
|
||||||
|
0x0000,0x303c,0x0c3c,0x0300,0x00c0,0x3c30,0x3c0c,0x0000, // %
|
||||||
|
0x0000,0x0f3c,0x30c3,0x30c3,0x333c,0x0c00,0x3300,0x0000, // &
|
||||||
|
0x0000,0x0000,0x0000,0x003f,0x0000,0x0000,0x0000,0x0000, // '
|
||||||
|
0x0000,0x03f0,0x0c0c,0x3003,0x0000,0x0000,0x0000,0x0000, // (
|
||||||
|
0x0000,0x0000,0x0000,0x3003,0x0c0c,0x03f0,0x0000,0x0000, // )
|
||||||
|
0x0000,0x0c0c,0x0330,0x3fff,0x0330,0x0c0c,0x0000,0x0000, // *
|
||||||
|
0x0000,0x00c0,0x00c0,0x0ffc,0x00c0,0x00c0,0x0000,0x0000, // +
|
||||||
|
0x0000,0x0000,0x0000,0x3000,0x0f00,0x0000,0x0000,0x0000, // ,
|
||||||
|
0x0000,0x00c0,0x00c0,0x00c0,0x00c0,0x00c0,0x00c0,0x0000, // -
|
||||||
|
0x0000,0x0000,0x0000,0x3000,0x0000,0x0000,0x0000,0x0000, // .
|
||||||
|
0x0000,0x3000,0x0c00,0x0300,0x00c0,0x0030,0x000c,0x0000, // /
|
||||||
|
|
||||||
|
0x0000,0x0ffc,0x3303,0x30c3,0x30c3,0x3033,0x0ffc,0x0000, // 0
|
||||||
|
0x0000,0x0000,0x0000,0x300c,0x3fff,0x3000,0x0000,0x0000, // 1
|
||||||
|
0x0000,0x3c0c,0x3303,0x30c3,0x30c3,0x30c3,0x303c,0x0000, // 2
|
||||||
|
0x0000,0x0c03,0x3003,0x30c3,0x30c3,0x30f3,0x0f0f,0x0000, // 3
|
||||||
|
0x0000,0x0300,0x03c0,0x0330,0x030c,0x3fff,0x0300,0x0000, // 4
|
||||||
|
0x0000,0x0c3f,0x3033,0x3033,0x3033,0x3033,0x0fc3,0x0000, // 5
|
||||||
|
0x0000,0x0ff0,0x30cc,0x30c3,0x30c3,0x30c3,0x0f03,0x0000, // 6
|
||||||
|
0x0000,0x0003,0x0003,0x3f03,0x00c3,0x0033,0x000f,0x0000, // 7
|
||||||
|
0x0000,0x0f3c,0x30c3,0x30c3,0x30c3,0x30c3,0x0f3c,0x0000, // 8
|
||||||
|
0x0000,0x303c,0x30c3,0x30c3,0x30c3,0x0cc3,0x03fc,0x0000, // 9
|
||||||
|
0x0000,0x0000,0x0000,0x0330,0x0000,0x0000,0x0000,0x0000, // :
|
||||||
|
0x0000,0x0000,0x0000,0x1000,0x0f30,0x0000,0x0000,0x0000, // ;
|
||||||
|
0x0000,0x0000,0x00c0,0x0330,0x0c0c,0x3003,0x0000,0x0000, // <
|
||||||
|
0x0000,0x0330,0x0330,0x0330,0x0330,0x0330,0x0330,0x0000, // =
|
||||||
|
0x0000,0x0000,0x3003,0x0c0c,0x0330,0x00c0,0x0000,0x0000, // >
|
||||||
|
0x0000,0x000c,0x0003,0x0000,0x0000,0x0000,0x0000,0x0000, // ?
|
||||||
|
|
||||||
|
0x0000,0x0ffc,0x3003,0x30c3,0x3333,0x33c3,0x30fc,0x0000, // @
|
||||||
|
0x0000,0x3ff0,0x030c,0x0303,0x0303,0x030c,0x3ff0,0x0000, // A
|
||||||
|
0x0000,0x3fff,0x30c3,0x30c3,0x30c3,0x30c3,0x0f3c,0x0000, // B
|
||||||
|
0x0000,0x0ffc,0x3003,0x3003,0x3003,0x3003,0x0c0c,0x0000, // C
|
||||||
|
0x0000,0x3fff,0x3003,0x3003,0x3003,0x3003,0x0ffc,0x0000, // D
|
||||||
|
0x0000,0x3fff,0x30c3,0x30c3,0x30c3,0x30c3,0x3003,0x0000, // E
|
||||||
|
0x0000,0x3fff,0x00c3,0x00c3,0x00c3,0x00c3,0x0003,0x0000, // F
|
||||||
|
0x0000,0x0ffc,0x3003,0x3003,0x3183,0x3183,0x3f83,0x0000, // G
|
||||||
|
0x0000,0x3fff,0x00c0,0x00c0,0x00c0,0x00c0,0x3fff,0x0000, // H
|
||||||
|
0x0000,0x0000,0x3003,0x3fff,0x3003,0x0000,0x0000,0x0000, // I
|
||||||
|
0x0000,0x0c00,0x3000,0x3000,0x3000,0x3000,0x0fff,0x0000, // J
|
||||||
|
0x0000,0x3fff,0x00c0,0x00c0,0x0330,0x0c0c,0x3003,0x0000, // K
|
||||||
|
0x0000,0x3fff,0x3000,0x3000,0x3000,0x3000,0x3000,0x0000, // L
|
||||||
|
0x0000,0x3fff,0x000c,0x00f0,0x00f0,0x000c,0x3fff,0x0000, // M
|
||||||
|
0x0000,0x3fff,0x000c,0x00f0,0x03c0,0x0c00,0x3fff,0x0000, // N
|
||||||
|
0x0000,0x0ffc,0x3003,0x3003,0x3003,0x3003,0x0ffc,0x0000, // O
|
||||||
|
|
||||||
|
0x0000,0x3fff,0x00c3,0x00c3,0x00c3,0x00c3,0x003c,0x0000, // P
|
||||||
|
0x0000,0x0ffc,0x3003,0x3003,0x3303,0x0c03,0x33fc,0x0000, // Q
|
||||||
|
0x0000,0x3fff,0x00c3,0x00c3,0x03c3,0x0cc3,0x303c,0x0000, // R
|
||||||
|
0x0000,0x0c3c,0x30c3,0x30c3,0x30c3,0x30c3,0x0f0c,0x0000, // S
|
||||||
|
0x0000,0x0003,0x0003,0x3fff,0x0003,0x0003,0x0000,0x0000, // T
|
||||||
|
0x0000,0x0fff,0x3000,0x3000,0x3000,0x3000,0x0fff,0x0000, // U
|
||||||
|
0x0000,0x03ff,0x0c00,0x3000,0x3000,0x0c00,0x03ff,0x0000, // V
|
||||||
|
0x0000,0x3fff,0x0c00,0x03c0,0x03c0,0x0c00,0x3fff,0x0000, // W
|
||||||
|
0x0000,0x3c0f,0x0330,0x00c0,0x00c0,0x0330,0x3c0f,0x0000, // X
|
||||||
|
0x0000,0x000f,0x0030,0x3fc0,0x0030,0x000f,0x0000,0x0000, // Y
|
||||||
|
0x0000,0x3c03,0x3303,0x30c3,0x30c3,0x3033,0x300f,0x0000, // Z
|
||||||
|
0x0000,0x3fff,0x3fff,0x3003,0x3003,0x3003,0x3003,0x0000, // [
|
||||||
|
0x0000,0x000c,0x0030,0x00c0,0x0300,0x0c00,0x3000,0x0000, // <backslash>
|
||||||
|
0x0000,0x3003,0x3003,0x3003,0x3003,0x3fff,0x3fff,0x0000, // ]
|
||||||
|
0x0000,0x0300,0x00c0,0x0030,0x00c0,0x0300,0x0000,0x0000, // ^
|
||||||
|
0x0000,0x3000,0x3000,0x3000,0x3000,0x3000,0x3000,0x0000, // _
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0003,0x000c,0x0030,0x0000,0x0000,0x0000, // `
|
||||||
|
0x0000,0x0c00,0x3330,0x3330,0x3330,0x3330,0x3fc0,0x0000, // a
|
||||||
|
0x0000,0x3fff,0x3030,0x3030,0x3030,0x3030,0x0fc0,0x0000, // b
|
||||||
|
0x0000,0x0fc0,0x3030,0x3030,0x3030,0x3030,0x3030,0x0000, // c
|
||||||
|
0x0000,0x0fc0,0x3030,0x3030,0x3030,0x3030,0x3fff,0x0000, // d
|
||||||
|
0x0000,0x0fc0,0x3330,0x3330,0x3330,0x3330,0x33c0,0x0000, // e
|
||||||
|
0x0000,0x00c0,0x3ffc,0x00c3,0x00c3,0x00c3,0x000c,0x0000, // f
|
||||||
|
0x0000,0x03c0,0xcc30,0xcc30,0xcc30,0xcc30,0x3fc0,0x0000, // g
|
||||||
|
0x0000,0x3fff,0x0030,0x0030,0x0030,0x0030,0x3fc0,0x0000, // h
|
||||||
|
0x0000,0x0000,0x3030,0x3ff3,0x3000,0x0000,0x0000,0x0000, // i
|
||||||
|
0x0000,0x3000,0xc030,0xc030,0xc030,0x3ff3,0x0000,0x0000, // j
|
||||||
|
0x0000,0x3fff,0x0300,0x0300,0x0300,0x0cc0,0x3030,0x0000, // k
|
||||||
|
0x0000,0x0000,0x3003,0x3fff,0x3000,0x0000,0x0000,0x0000, // l
|
||||||
|
0x0000,0x3ff0,0x0030,0x0fc0,0x0fc0,0x0030,0x3ff0,0x0000, // m
|
||||||
|
0x0000,0x3ff0,0x0030,0x0030,0x0030,0x0030,0x3fc0,0x0000, // n
|
||||||
|
0x0000,0x0fc0,0x3030,0x3030,0x3030,0x3030,0x0fc0,0x0000, // o
|
||||||
|
|
||||||
|
0x0000,0xfff0,0x0c30,0x0c30,0x0c30,0x0c30,0x03c0,0x0000, // p
|
||||||
|
0x0000,0x03c0,0x0c30,0x0c30,0x0c30,0x0c30,0xfff0,0x0000, // q
|
||||||
|
0x0000,0x3ff0,0x00c0,0x0030,0x0030,0x0030,0x0030,0x0000, // r
|
||||||
|
0x0000,0x30c0,0x3330,0x3330,0x3330,0x3330,0x0c30,0x0000, // s
|
||||||
|
0x0000,0x0030,0x0030,0x0fff,0x3030,0x3030,0x0c00,0x0000, // t
|
||||||
|
0x0000,0x0ff0,0x3000,0x3000,0x3000,0x0c00,0x3ff0,0x0000, // u
|
||||||
|
0x0000,0x03f0,0x0c00,0x3000,0x3000,0x0c00,0x03f0,0x0000, // v
|
||||||
|
0x0000,0x3ff0,0x3000,0x0f00,0x0f00,0x3000,0x3ff0,0x0000, // w
|
||||||
|
0x0000,0x3030,0x0cc0,0x0300,0x0300,0x0cc0,0x3030,0x0000, // x
|
||||||
|
0x0000,0x03f0,0xcc00,0xcc00,0xcc00,0xcc00,0x3ff0,0x0000, // y
|
||||||
|
0x0000,0x3030,0x3c30,0x3330,0x3330,0x30f0,0x3030,0x0000, // z
|
||||||
|
0x0000,0x00c0,0x00c0,0x0ffc,0x3f3f,0x3003,0x3003,0x0000, // {
|
||||||
|
0x0000,0x0000,0x0000,0x3fff,0x0000,0x0000,0x0000,0x0000, // |
|
||||||
|
0x0000,0x3003,0x3003,0x3f3f,0x0ffc,0x00c0,0x00c0,0x0000, // }
|
||||||
|
0x0000,0x03c0,0x0030,0x00c0,0x0300,0x00f0,0x0000,0x0000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
134
src/devices/Oled/SSD1306/FontPack.java
Normal file
134
src/devices/Oled/SSD1306/FontPack.java
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Source : https://lexus2k.github.io/ssd1306/ssd1306__fonts_8c_source.html
|
||||||
|
// Source : https://github.com/lynniemagoo/oled-font-pack/tree/master/fonts
|
||||||
|
// Source : http://www.rinkydinkelectronics.com/r_fonts.php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base Class for OLED Fonts
|
||||||
|
* Do not create variable from it in B4X
|
||||||
|
* @author rdkartono
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class FontPack {
|
||||||
|
private final String fontname;
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
private final int outer_width;
|
||||||
|
private final int outer_height;
|
||||||
|
private final int min_ascii_code;
|
||||||
|
private final int max_ascii_code;
|
||||||
|
protected int[] data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize FontPack
|
||||||
|
* @param name Name of font
|
||||||
|
* @param width width of a character in pixel
|
||||||
|
* @param height height of a character in pixel
|
||||||
|
* @param outerwidth width plus extra pixel for spacing , of a character
|
||||||
|
* @param outerheight height plus extra pixel for spacing, of a character
|
||||||
|
* @param minchar minimum ASCII code value, usually 32 (space)
|
||||||
|
* @param maxchar maximum ASCII code value, usually 127
|
||||||
|
*/
|
||||||
|
public FontPack(String name, int width, int height, int outerwidth, int outerheight, int minchar, int maxchar) {
|
||||||
|
this.fontname = name;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.outer_width = outerwidth;
|
||||||
|
this.outer_height = outerheight;
|
||||||
|
this.min_ascii_code = minchar;
|
||||||
|
this.max_ascii_code = maxchar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Font Name
|
||||||
|
* @return font name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return fontname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get width of a character
|
||||||
|
* @return width in pixel
|
||||||
|
*/
|
||||||
|
public int getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get height of a character
|
||||||
|
* @return height in pixel
|
||||||
|
*/
|
||||||
|
public int getHeight() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get width + extra pixel for spacing, of a character
|
||||||
|
* @return width in pixel
|
||||||
|
*/
|
||||||
|
public int getOuterWidth() {
|
||||||
|
return outer_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Height + extra pixel for spacing, of a character
|
||||||
|
* @return height in pixel
|
||||||
|
*/
|
||||||
|
public int getOuterHeight() {
|
||||||
|
return outer_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get minimum supported ascii code, usually 32 , which is space
|
||||||
|
* @return ascii code
|
||||||
|
*/
|
||||||
|
public int getMinChar() {
|
||||||
|
return min_ascii_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get maximum supported ascii code, usually 127
|
||||||
|
* @return ascii code
|
||||||
|
*/
|
||||||
|
public int getMaxChar() {
|
||||||
|
return max_ascii_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a character on specific coordinate
|
||||||
|
* @param display OLED display to draw the character
|
||||||
|
* @param c character to display
|
||||||
|
* @param x top left coordinate
|
||||||
|
* @param y top left coordinate
|
||||||
|
* @param on if true, will turn ON the pixel at character X Y
|
||||||
|
*/
|
||||||
|
public void drawChar(OLEDDisplay display, char c, int x, int y, boolean on) {
|
||||||
|
if (c < getMinChar()) return;
|
||||||
|
if (c > getMaxChar()) return;
|
||||||
|
if (display==null) return;
|
||||||
|
if (x < 1) return;
|
||||||
|
if (y < 1) return;
|
||||||
|
if (x > display.getWidth()) return;
|
||||||
|
if (y > display.getHeight()) return;
|
||||||
|
|
||||||
|
//System.out.println("Drawing char "+c);
|
||||||
|
c-= getMinChar(); // if c = min_ascii_code , will point to index 0 at data
|
||||||
|
//System.out.println("Ascii code = "+(int)c);
|
||||||
|
for(int ii=0;ii<getWidth();ii++) {
|
||||||
|
// ambil data 1 barix
|
||||||
|
int line = data[(c * getWidth()) + ii];
|
||||||
|
//System.out.println("ii="+ii+", line = "+Integer.toHexString(line));
|
||||||
|
for(int jj=0;jj< getHeight(); jj++) {
|
||||||
|
if ((line & 0x01)>0) {
|
||||||
|
display.setPixel(x+ii, y+jj, on);
|
||||||
|
}
|
||||||
|
line >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
114
src/devices/Oled/SSD1306/Font_Arial_16X16.java
Normal file
114
src/devices/Oled/SSD1306/Font_Arial_16X16.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Arial_16X16")
|
||||||
|
public class Font_Arial_16X16 extends FontPack {
|
||||||
|
|
||||||
|
public Font_Arial_16X16() {
|
||||||
|
super("Font_Arial_16X16", 16, 16, 16, 16, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <space>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2ffc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // !
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x003c,0x0000,0x0000,0x003c,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // "
|
||||||
|
0x0000,0x0000,0x0440,0x3440,0x0f40,0x04f0,0x344c,0x0f40,0x04f0,0x044c,0x0440,0x0000,0x0000,0x0000,0x0000,0x0000, // #
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0870,0x1088,0x2084,0x7ffe,0x2104,0x1104,0x0e18,0x0000,0x0000,0x0000,0x0000,0x0000, // $
|
||||||
|
0x0000,0x0000,0x00f8,0x0104,0x0104,0x3104,0x0cf8,0x0200,0x0180,0x0060,0x1f18,0x2084,0x2080,0x2080,0x1f00,0x0000, // %
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0e00,0x1100,0x20b8,0x20c4,0x2184,0x2644,0x1838,0x1400,0x2200,0x0000,0x0000,0x0000, // &
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x003c,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // '
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x07f0,0x180c,0x2002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // (
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2002,0x180c,0x07f0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // )
|
||||||
|
0x0000,0x0000,0x0000,0x0080,0x00c0,0x0c80,0x0f80,0x03f0,0x03f0,0x0780,0x0d80,0x00c0,0x0080,0x0000,0x0000,0x0000, // *
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0100,0x0100,0x0100,0x0fe0,0x0100,0x0100,0x0100,0x0000,0x0000,0x0000,0x0000, // +
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ,
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0100,0x0100,0x0100,0x0100,0x0100,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // -
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // .
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3000,0x0e00,0x01c0,0x0038,0x0004,0x0000,0x0000,0x0000,0x0000,0x0000, // /
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0ff0,0x1008,0x2004,0x2004,0x2004,0x1008,0x0ff0,0x0000,0x0000,0x0000,0x0000,0x0000, // 0
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0020,0x0010,0x0008,0x3ffc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // 1
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2010,0x3008,0x2804,0x2404,0x2204,0x218c,0x2070,0x0000,0x0000,0x0000,0x0000,0x0000, // 2
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1810,0x1008,0x2084,0x2084,0x20c4,0x1138,0x0e00,0x0000,0x0000,0x0000,0x0000,0x0000, // 3
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0600,0x0500,0x04c0,0x0430,0x0408,0x3ffc,0x0400,0x0400,0x0000,0x0000,0x0000,0x0000, // 4
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x08e0,0x105c,0x2044,0x2044,0x2044,0x1084,0x0f04,0x0000,0x0000,0x0000, // 5
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0ff0,0x1088,0x2044,0x2044,0x2044,0x1088,0x0f18,0x0000,0x0000,0x0000,0x0000,0x0000, // 6
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0004,0x0004,0x3804,0x0784,0x0064,0x001c,0x0004,0x0000,0x0000,0x0000, // 7
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0e30,0x1148,0x2084,0x2084,0x2084,0x1148,0x0e30,0x0000,0x0000,0x0000, // 8
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x08f0,0x3108,0x2204,0x2204,0x2204,0x1108,0x0ff0,0x0000,0x0000,0x0000,0x0000,0x0000, // 9
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0808,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // :
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3808,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ;
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0080,0x0140,0x0140,0x0220,0x0220,0x0410,0x0410,0x0808,0x0000,0x0000,0x0000,0x0000, // <
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0220,0x0220,0x0220,0x0220,0x0220,0x0220,0x0220,0x0220,0x0000,0x0000,0x0000,0x0000, // =
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0808,0x0410,0x0410,0x0220,0x0220,0x0140,0x0140,0x0080,0x0000,0x0000,0x0000, // >
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0030,0x0008,0x0004,0x2e04,0x0104,0x0088,0x0070,0x0000,0x0000,0x0000,0x0000,0x0000, // ?
|
||||||
|
|
||||||
|
0x0000,0x0000,0x03e0,0x0418,0x09c4,0x1224,0x1212,0x1212,0x13e2,0x1232,0x0a04,0x090c,0x04f0,0x0000,0x0000,0x0000, // @
|
||||||
|
0x0000,0x0000,0x3000,0x0c00,0x0300,0x02e0,0x0218,0x0204,0x0218,0x02e0,0x0300,0x0c00,0x3000,0x0000,0x0000,0x0000, // A
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x2084,0x2084,0x2084,0x2084,0x2084,0x2084,0x11c8,0x0e30,0x0000,0x0000,0x0000, // B
|
||||||
|
0x0000,0x0000,0x0000,0x07e0,0x0810,0x1008,0x2004,0x2004,0x2004,0x2004,0x2004,0x1008,0x0810,0x0000,0x0000,0x0000, // C
|
||||||
|
0x0000,0x0000,0x0000,0x3ffc,0x2004,0x2004,0x2004,0x2004,0x2004,0x2004,0x1008,0x0810,0x07e0,0x0000,0x0000,0x0000, // D
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x2084,0x2084,0x2084,0x2084,0x2084,0x2084,0x2084,0x2004,0x0000,0x0000,0x0000, // E
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x0084,0x0084,0x0084,0x0084,0x0084,0x0084,0x0004,0x0000,0x0000,0x0000,0x0000, // F
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07e0,0x0810,0x1008,0x2004,0x2004,0x2104,0x2104,0x1108,0x0910,0x0700,0x0000,0x0000, // G
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x0080,0x0080,0x0080,0x0080,0x0080,0x0080,0x0080,0x3ffc,0x0000,0x0000,0x0000, // H
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3ffc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // I
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0c00,0x3000,0x2000,0x2000,0x2000,0x1000,0x0ffc,0x0000,0x0000,0x0000,0x0000,0x0000, // J
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x0200,0x0100,0x0080,0x00c0,0x0120,0x0610,0x1808,0x2004,0x0000,0x0000,0x0000, // K
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x0000,0x0000,0x0000,0x0000,0x0000, // L
|
||||||
|
0x0000,0x0000,0x3ffc,0x0018,0x0060,0x0380,0x0c00,0x3000,0x0e00,0x0180,0x0060,0x0018,0x3ffc,0x0000,0x0000,0x0000, // M
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x0008,0x0030,0x0040,0x0180,0x0200,0x0c00,0x1000,0x3ffc,0x0000,0x0000,0x0000, // N
|
||||||
|
0x0000,0x0000,0x0000,0x07e0,0x0810,0x1008,0x2004,0x2004,0x2004,0x2004,0x1008,0x0810,0x07e0,0x0000,0x0000,0x0000, // O
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x0104,0x0104,0x0104,0x0104,0x0104,0x0104,0x0088,0x0070,0x0000,0x0000,0x0000, // P
|
||||||
|
0x0000,0x0000,0x0000,0x07e0,0x0810,0x1008,0x2004,0x2004,0x2804,0x2804,0x1008,0x3810,0x2fe0,0x0000,0x0000,0x0000, // Q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x0104,0x0104,0x0104,0x0104,0x0304,0x0d04,0x1088,0x2070,0x0000,0x0000,0x0000, // R
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0c30,0x1048,0x2084,0x2084,0x2084,0x2104,0x2104,0x1108,0x0e10,0x0000,0x0000,0x0000, // S
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0004,0x0004,0x0004,0x0004,0x3ffc,0x0004,0x0004,0x0004,0x0004,0x0000,0x0000,0x0000, // T
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0ffc,0x1000,0x2000,0x2000,0x2000,0x2000,0x2000,0x1000,0x0ffc,0x0000,0x0000,0x0000, // U
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x000c,0x0070,0x0380,0x0c00,0x3000,0x0c00,0x0380,0x0070,0x000c,0x0000,0x0000,0x0000, // V
|
||||||
|
0x0000,0x0000,0x000c,0x00f0,0x0f00,0x3000,0x0f00,0x00f8,0x000c,0x00f0,0x0f00,0x3000,0x0f00,0x00f0,0x000c,0x0000, // W
|
||||||
|
0x0000,0x0000,0x2000,0x1004,0x0808,0x0630,0x0140,0x0080,0x0140,0x0630,0x0808,0x1004,0x2000,0x0000,0x0000,0x0000, // X
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0004,0x0018,0x0020,0x00c0,0x3f00,0x00c0,0x0020,0x0018,0x0004,0x0000,0x0000,0x0000, // Y
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2000,0x3004,0x2c04,0x2204,0x2184,0x2044,0x2034,0x200c,0x2004,0x0000,0x0000,0x0000, // Z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7ffe,0x4002,0x4002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // [
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0004,0x0038,0x01c0,0x0e00,0x3000,0x0000,0x0000,0x0000,0x0000,0x0000, // <backslash>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4002,0x4002,0x7ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ]
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0080,0x0070,0x000c,0x0002,0x000c,0x0070,0x0080,0x0000,0x0000,0x0000,0x0000,0x0000, // ^
|
||||||
|
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000, // _
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0004,0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // `
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0e40,0x1120,0x1110,0x1110,0x1090,0x0890,0x1fe0,0x0000,0x0000,0x0000,0x0000,0x0000, // a
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffe,0x0820,0x1010,0x1010,0x1010,0x0820,0x07c0,0x0000,0x0000,0x0000,0x0000,0x0000, // b
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0820,0x1010,0x1010,0x1010,0x0820,0x0440,0x0000,0x0000,0x0000,0x0000,0x0000, // c
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0820,0x1010,0x1010,0x1010,0x0820,0x1ffe,0x0000,0x0000,0x0000,0x0000,0x0000, // d
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0920,0x1110,0x1110,0x1110,0x0920,0x05c0,0x0000,0x0000,0x0000,0x0000,0x0000, // e
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0010,0x1ffc,0x0012,0x0012,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // f
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x23e0,0x4410,0x4808,0x4808,0x4808,0x2410,0x1ff8,0x0000,0x0000,0x0000,0x0000,0x0000, // g
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffe,0x0020,0x0010,0x0010,0x0010,0x0010,0x1fe0,0x0000,0x0000,0x0000,0x0000,0x0000, // h
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1fe4,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // i
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,0x8000,0x7fe4,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // j
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x1ffe,0x0200,0x0100,0x0180,0x0240,0x0c20,0x1010,0x0000,0x0000,0x0000,0x0000, // k
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // l
|
||||||
|
0x0000,0x0000,0x1ff0,0x0020,0x0010,0x0010,0x0010,0x1fe0,0x0020,0x0010,0x0010,0x0010,0x1fe0,0x0000,0x0000,0x0000, // m
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff0,0x0020,0x0010,0x0010,0x0010,0x0010,0x1fe0,0x0000,0x0000,0x0000,0x0000,0x0000, // n
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0820,0x1010,0x1010,0x1010,0x0820,0x07c0,0x0000,0x0000,0x0000,0x0000,0x0000, // o
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0xfff0,0x0820,0x1010,0x1010,0x1010,0x0820,0x07c0,0x0000,0x0000,0x0000,0x0000,0x0000, // p
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0820,0x1010,0x1010,0x1010,0x0820,0xfff0,0x0000,0x0000,0x0000,0x0000,0x0000, // q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1ff0,0x0020,0x0010,0x0010,0x0010,0x0000,0x0000,0x0000,0x0000,0x0000, // r
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x08e0,0x1110,0x1110,0x1110,0x1110,0x0e20,0x0000,0x0000,0x0000,0x0000,0x0000, // s
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0010,0x1ffe,0x1010,0x1010,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // t
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0ff0,0x1000,0x1000,0x1000,0x1000,0x0800,0x1ff0,0x0000,0x0000,0x0000,0x0000,0x0000, // u
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0030,0x01c0,0x0600,0x1800,0x0600,0x01c0,0x0030,0x0000,0x0000,0x0000,0x0000,0x0000, // v
|
||||||
|
0x0000,0x0000,0x0030,0x07c0,0x1800,0x0700,0x00c0,0x0030,0x00c0,0x0700,0x1800,0x07c0,0x0030,0x0000,0x0000,0x0000, // w
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1010,0x0820,0x06c0,0x0100,0x06c0,0x0820,0x1010,0x0000,0x0000,0x0000,0x0000,0x0000, // x
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x8070,0x8380,0x4c00,0x3000,0x0e00,0x0380,0x0070,0x0000,0x0000,0x0000,0x0000,0x0000, // y
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x1010,0x1810,0x1610,0x1110,0x10d0,0x1030,0x1010,0x0000,0x0000,0x0000,0x0000, // z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0080,0x0080,0x3f7e,0x4001,0x4001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xffff,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // |
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4001,0x4001,0x3f7e,0x0080,0x0080,0x0000,0x0000,0x0000,0x0000,0x0000, // }
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0008,0x0004,0x0004,0x0004,0x000c,0x0008,0x0008,0x0008,0x0004,0x0000,0x0000,0x0000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
113
src/devices/Oled/SSD1306/Font_Arial_16X24.java
Normal file
113
src/devices/Oled/SSD1306/Font_Arial_16X24.java
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Arial_16X24")
|
||||||
|
public class Font_Arial_16X24 extends FontPack{
|
||||||
|
|
||||||
|
public Font_Arial_16X24() {
|
||||||
|
super("Font_Arial_16X24", 16,24,16,24,32,126);
|
||||||
|
data = new int[] {
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // <space>
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0303fe,0x079fff,0x079fff,0x0301fe,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // !
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0001fc,0x0001cc,0x000000,0x000000,0x0000f0,0x0001fc,0x0001cc,0x000000,0x000000,0x000000,0x000000, // "
|
||||||
|
0x000000,0x000000,0x0030c0,0x07f0c0,0x07fec0,0x01fff0,0x003ffc,0x0030fc,0x07f0c0,0x07ffc0,0x00fff0,0x0037fc,0x0030fc,0x0030c0,0x000000,0x000000, // #
|
||||||
|
0x000000,0x000000,0x01e1e0,0x03e3f8,0x03c7f8,0x07073c,0x060e1c,0x3fffff,0x3fffff,0x060c1c,0x071c78,0x03fcf8,0x03f8f0,0x00f000,0x000000,0x000000, // $
|
||||||
|
0x0000fc,0x0001fe,0x000106,0x018106,0x00e1fe,0x0070f8,0x001c00,0x000700,0x0001c0,0x007c70,0x01fe1c,0x018206,0x018200,0x01fe00,0x007c00,0x000000, // %
|
||||||
|
0x000000,0x01e000,0x03f000,0x03f9c0,0x071be0,0x060ff0,0x061e30,0x067e30,0x07f3f0,0x03e3e0,0x01c1c0,0x03f000,0x077800,0x071000,0x020000,0x000000, // &
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00000c,0x00000f,0x000007,0x000001,0x000000,0x000000,0x000000,0x000000,0x000000, // '
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x003fc0,0x00fff0,0x03fffc,0x07c03e,0x0e0007,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // (
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0e0007,0x07c03e,0x03fffc,0x00fff0,0x003fc0,0x000000,0x000000,0x000000,0x000000,0x000000, // )
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000c00,0x00cc00,0x00e800,0x003f80,0x003f80,0x006800,0x00cc00,0x000c00,0x000000,0x000000,0x000000, // *
|
||||||
|
0x000000,0x000000,0x000000,0x000c00,0x000c00,0x000c00,0x000c00,0x00ffc0,0x00ffc0,0x000c00,0x000c00,0x000c00,0x000c00,0x000000,0x000000,0x000000, // +
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x270000,0x3f0000,0x1e0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ,
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000c00,0x000c00,0x000c00,0x000c00,0x000c00,0x000c00,0x000c00,0x000c00,0x000000,0x000000,0x000000,0x000000, // -
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x070000,0x070000,0x070000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // .
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x070000,0x07f000,0x03ff00,0x007ff0,0x0007fe,0x00007f,0x000007,0x000000,0x000000,0x000000,0x000000, // /
|
||||||
|
|
||||||
|
0x000000,0x000000,0x007fe0,0x01fff8,0x03fffc,0x07801e,0x07000e,0x07000e,0x07000e,0x07000e,0x07801e,0x03fffc,0x01fff8,0x007fe0,0x000000,0x000000, // 0
|
||||||
|
0x000000,0x000000,0x000000,0x0001c0,0x0001c0,0x0000e0,0x000070,0x000078,0x07fffc,0x07fffe,0x07fffe,0x000000,0x000000,0x000000,0x000000,0x000000, // 1
|
||||||
|
0x000000,0x000000,0x078070,0x07c07c,0x07e07c,0x07f01e,0x07780e,0x07380e,0x071c0e,0x070e0e,0x070f1e,0x0707fc,0x0703fc,0x0600f0,0x000000,0x000000, // 2
|
||||||
|
0x000000,0x000000,0x00f030,0x01f038,0x03e03c,0x07801e,0x07000e,0x07030e,0x07070e,0x07879e,0x07cffe,0x03fffc,0x01fcf8,0x007800,0x000000,0x000000, // 3
|
||||||
|
0x000000,0x000000,0x007800,0x007c00,0x007f00,0x006780,0x0061e0,0x0060f0,0x00603c,0x07fffe,0x07fffe,0x07fffc,0x006000,0x006000,0x000000,0x000000, // 4
|
||||||
|
0x000000,0x000000,0x01c000,0x03c7fe,0x03c7fe,0x0787fe,0x07038e,0x07038e,0x07038e,0x07038e,0x07878e,0x03ff0e,0x01fe0e,0x007c06,0x000000,0x000000, // 5
|
||||||
|
0x000000,0x000000,0x007fe0,0x01fff8,0x03fffc,0x038e3c,0x07070e,0x07070e,0x07070e,0x07070e,0x078f1e,0x03fe3c,0x01fc38,0x00f800,0x000000,0x000000, // 6
|
||||||
|
0x000000,0x000000,0x000006,0x00000e,0x00000e,0x07e00e,0x07fc0e,0x03ff0e,0x003f8e,0x0003ee,0x0000fe,0x00007e,0x00001e,0x00000e,0x000000,0x000000, // 7
|
||||||
|
0x000000,0x000000,0x00f800,0x01fcf8,0x03fffc,0x0787fe,0x07039e,0x07030e,0x07030e,0x07039e,0x0787fe,0x03fffc,0x01fcf8,0x00f800,0x000000,0x000000, // 8
|
||||||
|
0x000000,0x000000,0x0001f0,0x01c3f8,0x03c7fc,0x078f1e,0x070e0e,0x070e0e,0x070e0e,0x070e0e,0x03c71c,0x03fffc,0x01fff8,0x007fe0,0x000000,0x000000, // 9
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x01c0e0,0x01c0e0,0x01c0e0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // :
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x670380,0x3f0380,0x1e0380,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ;
|
||||||
|
0x000000,0x000000,0x000000,0x000e00,0x001f00,0x001f00,0x003b80,0x003b80,0x0071c0,0x0071c0,0x00e0e0,0x00e0e0,0x01e0f0,0x000000,0x000000,0x000000, // <
|
||||||
|
0x000000,0x000000,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x00e700,0x000000,0x000000, // =
|
||||||
|
0x000000,0x000000,0x000000,0x00f078,0x007070,0x007070,0x0038e0,0x0038e0,0x001dc0,0x001dc0,0x000f80,0x000f80,0x000700,0x000000,0x000000,0x000000, // >
|
||||||
|
0x000000,0x000000,0x000078,0x00007c,0x00003e,0x00000f,0x079c07,0x07be07,0x079f07,0x00078f,0x0003fe,0x0001fe,0x000078,0x000000,0x000000,0x000000, // ?
|
||||||
|
|
||||||
|
0x000000,0x01fc00,0x070300,0x0cf8c0,0x19fc60,0x130e60,0x330330,0x330330,0x318330,0x33fe30,0x33ff30,0x330760,0x198060,0x1cc1c0,0x043f00,0x000000, // @
|
||||||
|
0x000000,0x070000,0x07e000,0x03fc00,0x00ff80,0x007fe0,0x0063f8,0x00607c,0x00607c,0x0067f8,0x007fe0,0x00ff00,0x07fc00,0x07e000,0x070000,0x000000, // A
|
||||||
|
0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x06060c,0x06060c,0x06060c,0x06060c,0x06061c,0x070ffc,0x07fff8,0x03f9f0,0x01f000,0x000000,0x000000, // B
|
||||||
|
0x000000,0x003f80,0x00ffe0,0x01fff0,0x03c0f8,0x07803c,0x07001c,0x06000c,0x06000c,0x07001c,0x07803c,0x03c078,0x01f0f0,0x00f0e0,0x000000,0x000000, // C
|
||||||
|
0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x06000c,0x06000c,0x06000c,0x07001c,0x07803c,0x03c078,0x03fff8,0x00ffe0,0x003f80,0x000000,0x000000, // D
|
||||||
|
0x000000,0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x06060c,0x06060c,0x06060c,0x06060c,0x06060c,0x06060c,0x06060c,0x06000c,0x000000,0x000000, // E
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x00060c,0x00060c,0x00060c,0x00060c,0x00060c,0x00060c,0x00000c,0x000000,0x000000, // F
|
||||||
|
0x000000,0x003f80,0x00ffe0,0x01fff0,0x03c078,0x030018,0x06000c,0x06000c,0x060c0c,0x060c0c,0x070c1c,0x070c38,0x03fcf8,0x03fcf0,0x01fc40,0x000000, // G
|
||||||
|
0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x000600,0x000600,0x000600,0x000600,0x000600,0x000600,0x07fffc,0x07fffc,0x07fffc,0x000000,0x000000, // H
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // I
|
||||||
|
0x000000,0x00f000,0x03f000,0x03f000,0x078000,0x070000,0x070000,0x078000,0x03fffc,0x03fffc,0x00fffc,0x000000,0x000000,0x000000,0x000000,0x000000, // J
|
||||||
|
0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x001e00,0x000f00,0x000780,0x000fc0,0x003fe0,0x00fcf0,0x01f878,0x07e03c,0x07c01c,0x070000,0x000000, // K
|
||||||
|
0x000000,0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x060000,0x060000,0x060000,0x060000,0x060000,0x060000,0x060000,0x000000,0x000000,0x000000, // L
|
||||||
|
0x07fffc,0x07fffc,0x07fffc,0x00007c,0x0007fc,0x007ff0,0x03ff00,0x07f000,0x07f000,0x03ff00,0x007ff0,0x0007fc,0x00007c,0x07fffc,0x07fffc,0x07fffc, // M
|
||||||
|
0x000000,0x000000,0x07fff8,0x07fffc,0x07fffc,0x0000f8,0x0003e0,0x000f80,0x003e00,0x00f800,0x03e000,0x07fffc,0x07fffc,0x07fffc,0x000000,0x000000, // N
|
||||||
|
0x000000,0x003f80,0x00ffe0,0x01fff0,0x03e0f8,0x07803c,0x07001c,0x07001c,0x07001c,0x07001c,0x07803c,0x03e0f8,0x01fff0,0x00ffe0,0x003f80,0x000000, // O
|
||||||
|
|
||||||
|
0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x000c0c,0x000c0c,0x000c0c,0x000c0c,0x000c0c,0x000e1c,0x0007fc,0x0007f8,0x0001f0,0x000000,0x000000, // P
|
||||||
|
0x000000,0x003f80,0x00ffe0,0x01fff0,0x03e0f8,0x07803c,0x07001c,0x07201c,0x07601c,0x07c01c,0x07c03c,0x03e078,0x07fff0,0x0effe0,0x0e3f80,0x0c0000, // Q
|
||||||
|
0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x00060c,0x00060c,0x00060c,0x000e0c,0x003e0c,0x00fe0c,0x01f71c,0x07e3fc,0x07c3f8,0x0701f0,0x000000, // R
|
||||||
|
0x000000,0x000000,0x01e1e0,0x03e3f8,0x03c7f8,0x07079c,0x06070c,0x060f0c,0x060e0c,0x060e0c,0x071e3c,0x03fc78,0x03fc70,0x00f000,0x000000,0x000000, // S
|
||||||
|
0x000000,0x00000c,0x00000c,0x00000c,0x00000c,0x00000c,0x07fffc,0x07fffc,0x07fffc,0x00000c,0x00000c,0x00000c,0x00000c,0x00000c,0x000000,0x000000, // T
|
||||||
|
0x000000,0x000000,0x00fffc,0x01fffc,0x03fffc,0x078000,0x070000,0x070000,0x070000,0x070000,0x078000,0x03fffc,0x01fffc,0x007ffc,0x000000,0x000000, // U
|
||||||
|
0x000000,0x000000,0x00001c,0x0000fc,0x000ffc,0x007fe0,0x03ff00,0x07f000,0x078000,0x07f000,0x01fe00,0x003fe0,0x0007f8,0x0000fc,0x00001c,0x000000, // V
|
||||||
|
0x00007c,0x000ffc,0x01fff0,0x07fc00,0x07e000,0x03ff00,0x001ff8,0x0000fc,0x0000fc,0x001ff8,0x03ff00,0x07e000,0x07fc00,0x01fff0,0x000ffc,0x00007c, // W
|
||||||
|
0x000000,0x070000,0x07801c,0x07e07c,0x03f0f8,0x00fbf0,0x007fc0,0x003f80,0x003f80,0x007fc0,0x00fbe0,0x03f1f8,0x07e07c,0x07803c,0x070008,0x000000, // X
|
||||||
|
0x000000,0x000008,0x00003c,0x0000fc,0x0001f8,0x0007e0,0x07ff80,0x07fe00,0x07ff80,0x0007c0,0x0001f0,0x0000fc,0x00003c,0x000008,0x000000,0x000000, // Y
|
||||||
|
0x000000,0x070000,0x07800c,0x07e00c,0x07f00c,0x06fc0c,0x067e0c,0x061f8c,0x060fcc,0x0603fc,0x0601fc,0x0600fc,0x06003c,0x060000,0x000000,0x000000, // Z
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x3ffffe,0x3ffffe,0x300006,0x300006,0x000000,0x000000,0x000000,0x000000,0x000000, // [
|
||||||
|
0x000000,0x000000,0x000000,0x000008,0x00003c,0x0001fc,0x000ff8,0x007fe0,0x03ff00,0x07f800,0x07c000,0x060000,0x000000,0x000000,0x000000,0x000000, // <backslash>
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x300006,0x300006,0x300006,0x3ffffe,0x3ffffe,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ]
|
||||||
|
0x000000,0x000000,0x000400,0x000700,0x0007c0,0x0003f8,0x00007c,0x00003c,0x0001fc,0x0007e0,0x000780,0x000400,0x000000,0x000000,0x000000,0x000000, // ^
|
||||||
|
0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000,0x080000, // _
|
||||||
|
|
||||||
|
0x000000,0x000070,0x0000f8,0x00018c,0x00018c,0x00018c,0x0000f8,0x000070,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // `
|
||||||
|
0x000000,0x000000,0x01c000,0x03e700,0x07f380,0x063180,0x063180,0x021180,0x031980,0x03ff80,0x07ff00,0x07fe00,0x040000,0x000000,0x000000,0x000000, // a
|
||||||
|
0x000000,0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x038700,0x060180,0x060180,0x060180,0x070380,0x03ff80,0x03ff00,0x00fc00,0x000000,0x000000, // b
|
||||||
|
0x000000,0x000000,0x00fc00,0x01fe00,0x03ff00,0x078780,0x060180,0x060180,0x060180,0x070380,0x038700,0x03cf00,0x018400,0x000000,0x000000,0x000000, // c
|
||||||
|
0x000000,0x000000,0x00fc00,0x03ff00,0x03ff80,0x070380,0x060180,0x060180,0x060180,0x038700,0x07fffc,0x07fffc,0x07fffc,0x000000,0x000000,0x000000, // d
|
||||||
|
0x000000,0x000000,0x00fc00,0x01fe00,0x03ff00,0x073380,0x063180,0x063180,0x063180,0x063380,0x033f00,0x03be00,0x011c00,0x000000,0x000000,0x000000, // e
|
||||||
|
0x000000,0x000000,0x000000,0x000180,0x000180,0x07fff8,0x07fffc,0x07fffc,0x00018c,0x00018c,0x00000c,0x000000,0x000000,0x000000,0x000000,0x000000, // f
|
||||||
|
0x000000,0x000000,0x10fc00,0x7bff00,0x73ff80,0xe70380,0xc60180,0xc60180,0xc60180,0xe30300,0x7fff80,0x7fff80,0x1fff80,0x000000,0x000000,0x000000, // g
|
||||||
|
0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x000300,0x000180,0x000180,0x000380,0x07ff80,0x07ff00,0x07fe00,0x000000,0x000000,0x000000,0x000000, // h
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x07ff9c,0x07ff9c,0x07ff9c,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // i
|
||||||
|
0x000000,0x000000,0x000000,0xc00000,0xc00000,0xc00000,0xffff9c,0xffff9c,0x7fff9c,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // j
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x003800,0x001c00,0x007e00,0x01f700,0x03e380,0x078180,0x060000,0x000000,0x000000, // k
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x07fffc,0x07fffc,0x07fffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // l
|
||||||
|
0x07ff80,0x07ff80,0x07ff80,0x000300,0x000180,0x000180,0x000180,0x07ff80,0x07ff80,0x07ff00,0x000300,0x000180,0x000180,0x07ff80,0x07ff80,0x07ff00, // m
|
||||||
|
0x000000,0x000000,0x000000,0x07ff80,0x07ff80,0x07ff80,0x000300,0x000180,0x000180,0x000380,0x07ff80,0x07ff00,0x07fe00,0x000000,0x000000,0x000000, // n
|
||||||
|
0x000000,0x00fc00,0x01fe00,0x03ff00,0x070380,0x060180,0x060180,0x060180,0x070380,0x03ff00,0x01fe00,0x00fc00,0x000000,0x000000,0x000000,0x000000, // o
|
||||||
|
|
||||||
|
0x000000,0x000000,0xffff80,0xffff80,0xffff80,0x038700,0x060180,0x060180,0x060180,0x070380,0x03ff00,0x03ff00,0x00fc00,0x000000,0x000000,0x000000, // p
|
||||||
|
0x000000,0x000000,0x00fc00,0x03ff00,0x03ff00,0x070380,0x060180,0x060180,0x060180,0x038700,0xffff80,0xffff80,0xffff80,0x000000,0x000000,0x000000, // q
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x07ff80,0x07ff80,0x07ff80,0x000300,0x000180,0x000180,0x000180,0x000300,0x000000,0x000000,0x000000,0x000000, // r
|
||||||
|
0x000000,0x000000,0x000000,0x018e00,0x039f00,0x079f80,0x073980,0x063980,0x063180,0x067380,0x07f700,0x03e700,0x01c000,0x000000,0x000000,0x000000, // s
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000100,0x000180,0x03fffc,0x07fffc,0x07fffc,0x060180,0x060180,0x060000,0x000000,0x000000,0x000000,0x000000, // t
|
||||||
|
0x000000,0x000000,0x000000,0x01ff80,0x03ff80,0x07ff80,0x070000,0x060000,0x060000,0x030000,0x07ff80,0x07ff80,0x07ff80,0x000000,0x000000,0x000000, // u
|
||||||
|
0x000000,0x000000,0x000000,0x000380,0x001f80,0x007f00,0x03f800,0x07c000,0x07c000,0x03f800,0x007f00,0x001f80,0x000380,0x000000,0x000000,0x000000, // v
|
||||||
|
0x000380,0x001f80,0x00ff00,0x07f000,0x078000,0x07f800,0x00ff00,0x000f80,0x000f80,0x00ff00,0x07f800,0x078000,0x07f000,0x00ff00,0x001f80,0x000380, // w
|
||||||
|
0x000000,0x000000,0x070180,0x078380,0x03e780,0x01ff00,0x00fe00,0x003c00,0x00fe00,0x01ff00,0x07e780,0x078380,0x070180,0x000000,0x000000,0x000000, // x
|
||||||
|
0x000000,0x000000,0x000000,0xc00380,0xc01f80,0xc0ff00,0xf7f800,0x7fc000,0x3f8000,0x07f800,0x00ff00,0x001f80,0x000380,0x000000,0x000000,0x000000, // y
|
||||||
|
0x000000,0x000000,0x060180,0x070180,0x078180,0x07e180,0x07f180,0x067980,0x063d80,0x061f80,0x060f80,0x060780,0x060380,0x000000,0x000000,0x000000, // z
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000c00,0x001e00,0x0ffffc,0x1ffffe,0x3fe1ff,0x380007,0x380007,0x000000,0x000000,0x000000,0x000000, // {
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x3fffff,0x3fffff,0x3fffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // |
|
||||||
|
0x000000,0x000000,0x000000,0x380007,0x380007,0x3fe1ff,0x1ffffe,0x0ffffc,0x001e00,0x000c00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // }
|
||||||
|
0x000000,0x000000,0x000070,0x000038,0x000038,0x000038,0x000038,0x000030,0x000070,0x000070,0x000070,0x000070,0x000038,0x000000,0x000000,0x000000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
211
src/devices/Oled/SSD1306/Font_Dingbats_32X24.java
Normal file
211
src/devices/Oled/SSD1306/Font_Dingbats_32X24.java
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Dingbats_32X24")
|
||||||
|
public class Font_Dingbats_32X24 extends FontPack {
|
||||||
|
|
||||||
|
public final char kosong = 32;
|
||||||
|
public final char horse_head = 33;
|
||||||
|
public final char dog_head = 34;
|
||||||
|
public final char pig_head = 35;
|
||||||
|
public final char panda_head = 36;
|
||||||
|
public final char elephant_head = 37;
|
||||||
|
public final char gorilla_head = 38;
|
||||||
|
public final char crocodile = 39;
|
||||||
|
public final char lion_head = 40;
|
||||||
|
public final char penguin = 41;
|
||||||
|
public final char whale = 42;
|
||||||
|
public final char fish1 = 43;
|
||||||
|
public final char fish2 = 44;
|
||||||
|
public final char turtle = 45;
|
||||||
|
public final char lobster = 46;
|
||||||
|
public final char dinosaur = 47;
|
||||||
|
public final char telephone_lingkaran = 48;
|
||||||
|
public final char map = 49;
|
||||||
|
public final char lembar_cek = 50;
|
||||||
|
public final char uang_cash = 51;
|
||||||
|
public final char plug_male = 52;
|
||||||
|
public final char plug_female = 53;
|
||||||
|
public final char trees = 54;
|
||||||
|
public final char tulip = 55;
|
||||||
|
public final char tree = 56;
|
||||||
|
public final char house = 57;
|
||||||
|
public final char office1 = 58;
|
||||||
|
public final char office2 = 59;
|
||||||
|
public final char gereja = 60;
|
||||||
|
public final char pabrik = 61;
|
||||||
|
public final char mercusuar = 62;
|
||||||
|
public final char clocktower = 63;
|
||||||
|
public final char melody1 = 64;
|
||||||
|
public final char camera_filmmaker = 65;
|
||||||
|
public final char gakjelas1 = 66;
|
||||||
|
public final char gakjelas2 = 67;
|
||||||
|
public final char gakjelas3 = 68;
|
||||||
|
public final char gakjelas4 = 69;
|
||||||
|
public final char gakjelas5 = 70;
|
||||||
|
public final char gakjelas6 = 71;
|
||||||
|
public final char gakjelas7 = 72;
|
||||||
|
public final char ufo = 73;
|
||||||
|
public final char tank = 74;
|
||||||
|
public final char conductor = 75;
|
||||||
|
public final char melody2 = 76;
|
||||||
|
public final char melody3 = 77;
|
||||||
|
public final char televisi_tabung = 78;
|
||||||
|
public final char radio = 79;
|
||||||
|
public final char microphone = 80;
|
||||||
|
public final char telephone = 81;
|
||||||
|
public final char mailbox_isi = 82;
|
||||||
|
public final char mailbox_kosong = 83;
|
||||||
|
public final char folder = 84;
|
||||||
|
public final char briefcase = 85;
|
||||||
|
public final char camera = 86;
|
||||||
|
public final char time = 87;
|
||||||
|
public final char gunting = 88;
|
||||||
|
public final char gembok = 89;
|
||||||
|
public final char kunci = 90;
|
||||||
|
public final char mobil = 91;
|
||||||
|
public final char taksi = 92;
|
||||||
|
public final char bus = 93;
|
||||||
|
public final char kereta = 94;
|
||||||
|
public final char pesawat = 95;
|
||||||
|
public final char truk = 96;
|
||||||
|
public final char pulpen = 97;
|
||||||
|
public final char handwriting = 98;
|
||||||
|
public final char pena_bulu = 99;
|
||||||
|
public final char lemari_dokumen = 100;
|
||||||
|
public final char jam_pasir = 101;
|
||||||
|
public final char buku_terbuka = 102;
|
||||||
|
public final char kertas_kosong = 103;
|
||||||
|
public final char kertas_isi = 104;
|
||||||
|
public final char kertas_banyak = 105;
|
||||||
|
public final char amplop_depan = 106;
|
||||||
|
public final char amplop_belakang = 107;
|
||||||
|
public final char disket_kecil = 108;
|
||||||
|
public final char disket_besar = 109;
|
||||||
|
public final char cassete = 110;
|
||||||
|
public final char cd1 = 111;
|
||||||
|
public final char cd2 = 112;
|
||||||
|
public final char laptop = 113;
|
||||||
|
public final char keyboard = 114;
|
||||||
|
public final char mouse = 115;
|
||||||
|
public final char diskdrive =116;
|
||||||
|
public final char tang_potong = 117;
|
||||||
|
public final char palu = 118;
|
||||||
|
public final char kunci_pas = 119;
|
||||||
|
public final char obeng = 120;
|
||||||
|
public final char tempat_dokumen = 121;
|
||||||
|
public final char printer = 122;
|
||||||
|
public final char kapal = 123;
|
||||||
|
public final char pesawat_luarangkasa = 124;
|
||||||
|
public final char sepeda_motor = 125;
|
||||||
|
public final char sepeda = 126;
|
||||||
|
/**
|
||||||
|
* Source : http://www.rinkydinkelectronics.com/images/fonts/Dingbats1_XL.png
|
||||||
|
*/
|
||||||
|
public Font_Dingbats_32X24() {
|
||||||
|
super("Font_Dingbats_32X24", 32, 24, 32, 24, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // <space>
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x001000,0x001800,0x003c00,0x006700,0x004380,0x0040c0,0x00406c,0x002338,0x0ff338,0x0ff86c,0x0c00d8,0x0c01b8,0x0c0330,0x0c0e60,0x0ffcc0,0x0ff380,0x000f00,0x0ffc00,0x0ff000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // !
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x0003fe,0x0007fe,0x000e06,0x001c06,0x003806,0x003006,0x0e3006,0x0ff006,0x09f066,0x0a0066,0x0e0006,0x0a0006,0x0a0006,0x0e7fe6,0x0affe6,0x0ac006,0x0ec006,0x00fffe,0x007ffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // "
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x003e00,0x00ff80,0x01c1fc,0x030078,0x070018,0x060030,0x0ccc18,0x0c8c18,0x0ce018,0x0ca018,0x0c8c18,0x0ccc18,0x060030,0x070018,0x030078,0x01c1fc,0x00ff80,0x003e00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // #
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x003e78,0x00fff8,0x01c1fc,0x03107c,0x073e7c,0x063f38,0x0c3910,0x0c1f18,0x0c0018,0x0c0618,0x0c0a18,0x0c3910,0x063f38,0x073e7c,0x03107c,0x01c1fc,0x00fffc,0x003e78,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // $
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x03ff00,0x0c00c0,0x080020,0x13c010,0x144188,0x144188,0x1c4004,0x004004,0x004004,0x03f004,0x040004,0x040004,0x04000c,0x040008,0x040008,0x040008,0x030008,0x00fe08,0x0003f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // %
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x01ff00,0x07ffc0,0x0639f0,0x0c00f8,0x0c42fc,0x0c2efc,0x0c6efe,0x0c42fe,0x0c42fe,0x0c6efe,0x0c2efc,0x0c42fc,0x0c00f8,0x0639f0,0x07ffe0,0x01ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // &
|
||||||
|
0x000000,0x000000,0x000000,0x038000,0x06c200,0x04e3c0,0x048340,0x048420,0x04d860,0x04e1e0,0x048600,0x040800,0x0e0400,0x0a3400,0x0a4400,0x087800,0x0e1000,0x043000,0x0c3000,0x0a1000,0x0a3000,0x081000,0x081dc0,0x0e2640,0x020080,0x018300,0x00fc00,0x000000,0x000000,0x000000,0x000000,0x000000, // '
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x01ff00,0x01ffe0,0x07fff8,0x07c1cc,0x0e00ec,0x0e006c,0x0ccc78,0x0c8c38,0x18a038,0x18e038,0x0c8c38,0x0ccc78,0x0e006c,0x0e00ec,0x07c1cc,0x07fff8,0x01fff0,0x01fb80,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // (
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000040,0x0cf8a0,0x0b8ff0,0x0b00f8,0x0a01cc,0x0bffcc,0x0ffffc,0x0ffffc,0x0ffff8,0x0ffff0,0x0ffe00,0x0c3800,0x002000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // )
|
||||||
|
0x000000,0x000000,0x000000,0x000f80,0x003180,0x006d80,0x007180,0x00ed80,0x00d980,0x00d780,0x00ff80,0x00ff80,0x00ff80,0x01ff80,0x01ff80,0x01ff80,0x03ff80,0x007f80,0x003f80,0x003f80,0x001f80,0x000780,0x000380,0x000780,0x000fe0,0x001fe0,0x001830,0x000000,0x000000,0x000000,0x000000,0x000000, // *
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x001000,0x003800,0x007c00,0x006600,0x00e700,0x00ff00,0x00ff00,0x01a180,0x01cfe0,0x018fe0,0x00ffc0,0x00ffc0,0x00ff80,0x00ff80,0x00ff00,0x01fe00,0x003c00,0x001800,0x003c00,0x007e00,0x006600,0x008200,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // +
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000800,0x000c00,0x001200,0x003300,0x002d00,0x004c80,0x008040,0x010020,0x038070,0x07c0f8,0x0fc0fc,0x002100,0x001200,0x000c00,0x000c00,0x001e00,0x001e00,0x003f00,0x007f80,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ,
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x00fc00,0x0fff80,0x087ec0,0x083ee0,0x083ef0,0x087ef0,0x0f9a28,0x02ff88,0x0381d8,0x0300d8,0x0300d8,0x02e6d8,0x02e688,0x0fb1a8,0x087ff0,0x083ef0,0x083ee0,0x087ec0,0x0fff80,0x00fe00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // -
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0001e0,0x0001e0,0x0069fc,0x0c6ae4,0x0efe0c,0x0ffff0,0x0dff80,0x0ffff0,0x0efe0c,0x0c6ae4,0x0069fc,0x0001e0,0x0001f0,0x0000e0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // .
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x001f80,0x0fffe0,0x0ffff0,0x0ffff0,0x00fe78,0x0ffc78,0x0ffe38,0x0ffe7c,0x03fe7c,0x03fe6c,0x03fe78,0x0ffc00,0x0ff800,0x0fe000,0x070000,0x040000,0x080000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // /
|
||||||
|
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x003f00,0x00c0c0,0x010030,0x000018,0x000008,0x0ec004,0x09f804,0x10fe02,0x137f82,0x10c3c2,0x1001e2,0x1000f2,0x100172,0x0801e4,0x080064,0x040008,0x060018,0x030030,0x00c0c0,0x003f00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 0
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x03ffe0,0x020320,0x0203e0,0x0203a0,0x0203a0,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x020320,0x03ffe0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 1
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x01ff00,0x017fc0,0x014040,0x015b40,0x015b40,0x015b40,0x015b40,0x015b40,0x015b40,0x015b40,0x014840,0x015840,0x015840,0x015940,0x015940,0x015940,0x015940,0x015940,0x01c040,0x007fc0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 2
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x07fc00,0x05ff00,0x050100,0x050100,0x050100,0x050100,0x057900,0x054900,0x058500,0x058500,0x058500,0x0549e0,0x057a20,0x050410,0x050410,0x050410,0x050220,0x0501e0,0x070100,0x01ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 3
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0003e0,0x0007bc,0x0007a0,0x03ffa0,0x0607a0,0x0407bc,0x0403e0,0x060000,0x03e000,0x003000,0x001000,0x001000,0x003000,0x0fe000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 4
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0007c0,0x000a20,0x000a20,0x03f8e0,0x060a20,0x040a20,0x0407c0,0x060000,0x03e000,0x003000,0x001000,0x001000,0x003000,0x0fe000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 5
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x040000,0x032000,0x03f900,0x03ff80,0x0fffe0,0x0e6ff0,0x0eb640,0x02ee80,0x00ffe0,0x0ffff0,0x0ffffc,0x0ffff0,0x00ffe0,0x02ee80,0x0eb640,0x0e6ff0,0x0fffe0,0x03ff80,0x03f900,0x032000,0x040000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 6
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000800,0x001800,0x003800,0x007800,0x00f07c,0x01e0fc,0x03c1f0,0x0781fc,0x0ffffc,0x0ffffc,0x0781fc,0x03c1f0,0x01e0fc,0x00f07c,0x007800,0x003800,0x001800,0x000800,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 7
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x020000,0x010000,0x018000,0x01d000,0x01c800,0x01ed00,0x01fe80,0x01fe80,0x0fffd8,0x0fffee,0x0fffd8,0x01fec0,0x01fe80,0x01ed00,0x01c800,0x01d000,0x018000,0x010000,0x020000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 8
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffe00,0x0fff00,0x0fff80,0x0c63fc,0x0c63fc,0x0c63f0,0x0c63f8,0x0ffffc,0x0c63f8,0x0c63f0,0x0c63e0,0x0c63c0,0x0fff80,0x0fff00,0x0ffe00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // 9
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x080004,0x083334,0x083334,0x080004,0x080004,0x0f3334,0x0f3334,0x080004,0x083334,0x083334,0x080004,0x0ffffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // :
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffffe,0x080002,0x085aaa,0x085aaa,0x0f5aaa,0x0f5aaa,0x0f5aaa,0x0f5aaa,0x0f5aaa,0x085aaa,0x085aaa,0x080002,0x0ffffe,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ;
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ff800,0x0ffc00,0x0ffe00,0x0ffe00,0x0fff00,0x0fff98,0x001f98,0x000ffe,0x000ffe,0x001f98,0x0fff98,0x0fff00,0x0ffe00,0x0ffe00,0x0ffc00,0x0ff800,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // <
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0fff38,0x0fff0c,0x0f8004,0x0fc084,0x0fe0cc,0x0ff084,0x0ff884,0x0f8084,0x0fc048,0x0fe084,0x0ff084,0x0ff884,0x0fc0cc,0x0fc084,0x0fe084,0x0ff0cc,0x0ff878,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // =
|
||||||
|
0x000000,0x000000,0x000000,0x0000fc,0x000084,0x000088,0x000088,0x000088,0x000048,0x000058,0x000030,0x0ffff8,0x0fff8c,0x0fff8c,0x0fff8c,0x0ffffe,0x0fff8c,0x0fff8c,0x0fc1f8,0x000030,0x000058,0x000048,0x000088,0x000088,0x000088,0x000084,0x0000fc,0x000000,0x000000,0x000000,0x000000,0x000000, // >
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ff000,0x0ff000,0x0ffe00,0x0ffe00,0x0ffe00,0x0ffffc,0x003f8c,0x001f04,0x001f34,0x001f24,0x003f8c,0x0ffffc,0x0ffe00,0x0ffe00,0x0ffe00,0x0ff000,0x0ff000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ?
|
||||||
|
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x070000,0x078000,0x07c000,0x07c000,0x03c000,0x01fffe,0x000044,0x0000cc,0x1800cc,0x3c0088,0x3e0198,0x3e0198,0x1e0110,0x0ffff0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // @
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x003f80,0x001f00,0x001f00,0x080e38,0x0e0e7c,0x039f7c,0x00ff7c,0x003f38,0x0fff00,0x0fff00,0x003f38,0x00ff7c,0x039f7c,0x0e007c,0x080038,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // A
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0807f0,0x0fb928,0x0f4ff4,0x0bf10c,0x084104,0x084104,0x084104,0x084104,0x084104,0x084104,0x084104,0x084184,0x0c5f7c,0x0bebe4,0x07fc1c,0x008004,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // B
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0007c0,0x000740,0x000540,0x03fd40,0x03fde0,0x03ffe0,0x03ffe0,0x03ffa0,0x03fda0,0x03fd50,0x03ff70,0x03ff70,0x03ff50,0x03fd50,0x03fd28,0x03fd38,0x03ff38,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // C
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x007ffc,0x034aa4,0x054aa4,0x04caa4,0x054ba4,0x0dfba4,0x091bbc,0x0bfae4,0x0a2a84,0x0a2a84,0x0ffffc,0x0c4000,0x078000,0x068000,0x038000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // D
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x008000,0x008000,0x008000,0x014000,0x0e3870,0x01438c,0x008470,0x0089a0,0x009340,0x002440,0x00a8c0,0x015b00,0x00b400,0x00d800,0x00fc00,0x01e800,0x03e000,0x03c000,0x03c000,0x01c000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // E
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x008000,0x01e1e0,0x01e618,0x03e408,0x03c804,0x07f804,0x07a804,0x07b804,0x0f8408,0x0fc618,0x03e5e0,0x01fe00,0x00fb00,0x0071c0,0x0013e0,0x000c20,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // F
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000400,0x000600,0x000f00,0x001f80,0x00bf80,0x08fe40,0x0dbc20,0x137af8,0x095708,0x0ce5e4,0x07aaf8,0x03e558,0x0435e4,0x04fb48,0x07b278,0x003ec0,0x003d80,0x003c00,0x002000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // G
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x020200,0x010408,0x010410,0x008420,0x004040,0x001e00,0x303f00,0x0c7d06,0x04f898,0x01f480,0x07e5f0,0x07c3f0,0x77c3f0,0x07c3e0,0x07c7f8,0x07c7c6,0x07df82,0x303f80,0x00bf40,0x011e20,0x060010,0x040010,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // H
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x008000,0x00c000,0x03e000,0x07e000,0x07ef00,0x07ef80,0x03e9c0,0x00e9e0,0x03efe0,0x07e9f8,0x07e9f8,0x03efe0,0x00e9e0,0x03e9c0,0x07ef80,0x07ef00,0x07e000,0x03e000,0x00c000,0x008000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // I
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000100,0x000100,0x000100,0x0fc300,0x1be300,0x13e300,0x13e200,0x13e200,0x13e200,0x13ef00,0x13ef80,0x13ef80,0x13ef80,0x13ef80,0x13ef80,0x13ef80,0x13ef80,0x13ef00,0x13e000,0x1be000,0x0fc000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // J
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x006000,0x007d00,0x00fe80,0x00fc80,0x00fe40,0x0ff1e0,0x0ff010,0x0fe388,0x0fc440,0x0fb820,0x0e2820,0x0fb820,0x0fc440,0x0fe38c,0x0ff014,0x0ff864,0x01fbc4,0x00fff8,0x007fe0,0x003f80,0x001c00,0x001000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // K
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x007800,0x01fc00,0x198600,0x3b3b60,0x3a4b9c,0x22fd8e,0x1f0cc6,0x011c78,0x01f800,0x007000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // L
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0e0000,0x0e0000,0x0f0000,0x0f0000,0x070000,0x03fffc,0x000038,0x000070,0x002060,0x0010c0,0x000f80,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // M
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x080004,0x0affe4,0x0afff4,0x08fff4,0x08fff4,0x0afff4,0x0afff4,0x08fff4,0x0afff4,0x0afff4,0x0afe34,0x0afe34,0x08fe34,0x08fe34,0x08f034,0x08fff4,0x08ffe4,0x080004,0x0ffffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // N
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x07ff00,0x080100,0x080100,0x0fff00,0x0fc980,0x0fc940,0x0fff20,0x0f0f10,0x0cf308,0x0dfb04,0x0bfd06,0x0bfd02,0x0bfd00,0x0df900,0x0cf300,0x0f0f00,0x07ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // O
|
||||||
|
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00fe00,0x013ff8,0x097a94,0x097b6c,0x0f7b6c,0x0f7a94,0x0f7b6c,0x097b6c,0x097a94,0x013ff8,0x00fe00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // P
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000580,0x0005c0,0x0005c0,0x0f05c0,0x0fc5e0,0x0fe1e0,0x0ff8e0,0x0f9ce0,0x0e06e0,0x0c06e0,0x0c02e0,0x0c02e0,0x0c06e0,0x0e06e0,0x0f9ce0,0x0ff8e0,0x0fe1e0,0x0fc5e0,0x0f05c0,0x0005c0,0x0005c0,0x000580,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // Q
|
||||||
|
0x003800,0x006400,0x008400,0x014400,0x024400,0x044400,0x084600,0x084980,0x0850c0,0x089040,0x083040,0x084c60,0x08f460,0x090a60,0x0a0aa0,0x0e0990,0x0ffe10,0x080010,0x083ff8,0x043ff8,0x0401e8,0x0400e8,0x020044,0x020004,0x020004,0x020004,0x010004,0x010008,0x010010,0x00ffe0,0x000000,0x000000, // R
|
||||||
|
0x003800,0x006400,0x008400,0x014400,0x024400,0x044400,0x084600,0x084980,0x085080,0x089040,0x082040,0x084040,0x088060,0x090060,0x0a00a0,0x0c0190,0x0ffe10,0x080010,0x083010,0x043008,0x041808,0x041808,0x021804,0x023804,0x027c04,0x027c04,0x011c04,0x010208,0x010010,0x00ffe0,0x000000,0x000000, // S
|
||||||
|
0x000000,0x0fffe0,0x0e0020,0x098020,0x08603c,0x081004,0x080c04,0x080304,0x080104,0x080104,0x080104,0x08011c,0x080120,0x080120,0x080120,0x080120,0x080120,0x080120,0x080120,0x080120,0x080120,0x080120,0x0801e0,0x060100,0x018100,0x004100,0x003100,0x000d00,0x000300,0x000000,0x000000,0x000000, // T
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x0fffc0,0x0fffc0,0x0fffc0,0x0fffc0,0x0fffc0,0x0ffff8,0x0ffffc,0x0fffcc,0x0fffcc,0x0fffcc,0x0fffcc,0x0fffcc,0x0fffcc,0x0ffffc,0x0ffff8,0x0fffc0,0x0fffc0,0x0fffc0,0x0fffc0,0x0fffc0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // U
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x0fffe0,0x0fffe0,0x0fffe0,0x0fff80,0x0fffc0,0x0fffa0,0x0f07b0,0x0e03b8,0x0c01b8,0x0c01b8,0x0c01b8,0x0c01b8,0x0c01b8,0x0e03b8,0x0f07b0,0x0fffa0,0x0fffc0,0x0fff80,0x0fff80,0x0fff80,0x0fff80,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // V
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x003f00,0x00c0c0,0x010020,0x020010,0x040008,0x040008,0x080004,0x080004,0x080fe4,0x080fe4,0x080c04,0x080c04,0x040c08,0x040c08,0x020c10,0x010020,0x00c0c0,0x003f00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // W
|
||||||
|
0x000000,0x000000,0x000000,0x070380,0x088440,0x088440,0x088440,0x088440,0x078780,0x008400,0x00cc00,0x00fc00,0x007800,0x007800,0x007800,0x007800,0x007800,0x00fc00,0x00fc00,0x01ce00,0x01ce00,0x018600,0x038700,0x038700,0x030300,0x030300,0x020200,0x000000,0x000000,0x000000,0x000000,0x000000, // X
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00fc00,0x01ffc0,0x03fc30,0x07ffd8,0x07fc28,0x0ffc24,0x0fdc14,0x0e0c14,0x0fdc14,0x0ffc34,0x07fc28,0x07ffd8,0x03fc30,0x01ffc0,0x00fc00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // Y
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0f0000,0x0f0000,0x0fc000,0x0fc000,0x07f000,0x03f000,0x01fe00,0x00ffe0,0x007ff0,0x003ff8,0x001ffc,0x001ffc,0x001f1c,0x001f1c,0x001f1c,0x000ff8,0x0007f0,0x0003e0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // Z
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x01f000,0x01f800,0x0f9c00,0x0f0b80,0x0f0860,0x019820,0x01f820,0x01f820,0x01f820,0x01f820,0x01f820,0x01f820,0x019820,0x0f0860,0x0f0b80,0x0f9c00,0x01f800,0x01f800,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // [
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x01f000,0x01f800,0x0f9c00,0x0f0b80,0x0f0840,0x019820,0x01f820,0x01f838,0x01f828,0x01f828,0x01f838,0x01f820,0x019820,0x0f08c0,0x0f0b00,0x0f9c00,0x01f800,0x01f800,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // <backslash>
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x01fff0,0x01f83c,0x0f983c,0x0f083c,0x0f0824,0x019824,0x01f824,0x01f824,0x01f824,0x01f824,0x019824,0x0f0824,0x0f083c,0x0f983c,0x01f83c,0x01fff0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ]
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x080000,0x080000,0x04fffc,0x03880c,0x01880c,0x00880c,0x00f80c,0x00f80c,0x00f80c,0x00f80c,0x00880c,0x00880c,0x01880c,0x03f80c,0x04fffc,0x080000,0x080000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // ^
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff80,0x007f00,0x001c00,0x001c00,0x001c00,0x001c00,0x0ffffc,0x0ffffc,0x0ffffc,0x01ffe0,0x003f00,0x001c00,0x001c00,0x001c00,0x001c00,0x001c00,0x001c00,0x001c00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // _
|
||||||
|
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x03dfe0,0x03dfe0,0x01dfe0,0x06dfe0,0x0f5fe0,0x0f5fe0,0x065fe0,0x005fe0,0x065fe0,0x0f5fe0,0x0f5fe0,0x06dfe0,0x01dfe0,0x03dfe0,0x03ff00,0x01ff00,0x06ff00,0x0f6100,0x0f6100,0x06e100,0x01ee00,0x03f000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // `
|
||||||
|
0x000000,0x000000,0x000000,0x100000,0x0c0000,0x0e0000,0x090000,0x08c000,0x044000,0x07a000,0x055000,0x02a800,0x01a800,0x015400,0x00aa00,0x006a00,0x005500,0x002a80,0x001980,0x001540,0x000ae0,0x0005d0,0x0002d0,0x000308,0x000108,0x000098,0x000070,0x000000,0x000000,0x000000,0x000000,0x000000, // a
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x070000,0x04e000,0x039800,0x018600,0x00c100,0x013080,0x013c40,0x013e40,0x013f20,0x0123a0,0x0111e0,0x0110e0,0x0100f0,0x01013c,0x010118,0x010210,0x010200,0x008200,0x01ff00,0x010100,0x010100,0x03ff00,0x03ff00,0x03ff00,0x000000,0x000000,0x000000,0x000000, // b
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x1e0000,0x098000,0x087800,0x08be00,0x07eb80,0x047fe0,0x00d7f8,0x007ff8,0x002ffc,0x0007fe,0x0000fc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // c
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffff0,0x081018,0x081018,0x085054,0x085054,0x085054,0x081014,0x081014,0x0ffff4,0x04000c,0x02000c,0x01fffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // d
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x078078,0x0861a4,0x0e1244,0x0f0cc4,0x0f03c4,0x0fffc4,0x0f0dc4,0x0e12e4,0x086184,0x078078,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // e
|
||||||
|
0x000000,0x000000,0x07fff0,0x07fff0,0x070018,0x04fffc,0x048004,0x048004,0x048004,0x048004,0x048004,0x048004,0x0c8004,0x09000c,0x0ffff8,0x09000c,0x0c8004,0x048004,0x048004,0x048004,0x048004,0x048004,0x048004,0x05fffc,0x060018,0x07fff0,0x07fff0,0x000000,0x000000,0x000000,0x000000,0x000000, // f
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x080004,0x080004,0x080004,0x080004,0x080004,0x080004,0x080004,0x080004,0x080004,0x0f8004,0x048004,0x028004,0x018004,0x00fffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // g
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x080004,0x08ab24,0x08ab24,0x08ab24,0x08ab24,0x08ab24,0x08ab24,0x08ab24,0x082b04,0x0fab04,0x04ab04,0x02ab04,0x018004,0x00fffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // h
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffff80,0x800080,0xaa54e0,0xaa54a0,0xaa54a0,0xaa54bc,0xaa54a4,0xaa54a4,0x8a54a4,0x8a54a4,0x8000a4,0x8000a4,0xffffa4,0x400024,0x7fffe4,0x080004,0x080004,0x0ffffc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // i
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x080004,0x080004,0x0950a4,0x0950a4,0x0950a4,0x0950a4,0x0950a4,0x0950a4,0x0950a4,0x095004,0x095004,0x095004,0x095004,0x095004,0x095004,0x095004,0x080004,0x0801f4,0x0801f4,0x0801f4,0x080004,0x0ffffc,0x000000,0x000000,0x000000,0x000000,0x000000, // j
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x0c000c,0x0a0014,0x090024,0x088044,0x084084,0x082104,0x081204,0x081c04,0x080804,0x083004,0x082004,0x083004,0x080804,0x081c04,0x081204,0x082104,0x084084,0x088044,0x090024,0x0a0014,0x0c000c,0x0ffffc,0x000000,0x000000,0x000000,0x000000,0x000000, // k
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x0ffffc,0x0803fc,0x0803fc,0x080204,0x080204,0x080204,0x080204,0x080204,0x0802f4,0x0802f4,0x080204,0x0803fc,0x0803fc,0x0ffffc,0x0ffff8,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // l
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ffffc,0x0fff84,0x0fff84,0x0fff84,0x0fff84,0x0fff84,0x0fe384,0x0fc184,0x084184,0x084184,0x0fe384,0x0fff84,0x0fff84,0x0fff84,0x0fff84,0x0fff84,0x0ffffc,0x0fffbc,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // m
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x01ffe0,0x01c0e0,0x00cce0,0x01ffe0,0x01f1e0,0x01f1e0,0x01f1e0,0x01ffe0,0x01dee0,0x01c0e0,0x01c0e0,0x01dee0,0x01ffe0,0x01f1e0,0x01f1e0,0x01f1e0,0x01ffe0,0x00cce0,0x01c0e0,0x01ffe0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // n
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x003f00,0x00cec0,0x010fa0,0x020ff0,0x041ff8,0x0463f8,0x08417c,0x0880bc,0x089cbc,0x0f9c84,0x0f8084,0x0fc104,0x07e308,0x07fe08,0x03f810,0x01f820,0x00f8c0,0x003f00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // o
|
||||||
|
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x001e00,0x00ffc0,0x01ffe0,0x03f950,0x07fea8,0x07c158,0x0f8154,0x0f80b4,0x0f9cb4,0x0a9cfc,0x0a80fc,0x0b80fc,0x05e1f8,0x055ff8,0x02fff0,0x013fe0,0x00efc0,0x001e00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // p
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0f0000,0x09fffc,0x0a6004,0x0b7ff4,0x097014,0x0a7014,0x0b7014,0x0b7014,0x0b7014,0x0b7014,0x0a7014,0x097014,0x0b7014,0x0b7014,0x0b7014,0x0a7ff4,0x087ffc,0x09c000,0x0f0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // q
|
||||||
|
0x000000,0x000000,0x000000,0x0ffe00,0x080200,0x095200,0x095200,0x0953c0,0x085220,0x090220,0x095220,0x095220,0x095220,0x095220,0x090230,0x08521c,0x095200,0x095200,0x095200,0x080200,0x095200,0x095200,0x080200,0x095200,0x095200,0x0ffe00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // r
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000400,0x000400,0x000400,0x0003f0,0x000008,0x000008,0x000008,0x000008,0x000008,0x000008,0x03ff08,0x060488,0x0c0488,0x080488,0x0807f0,0x080480,0x0c0480,0x060580,0x03ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // s
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0ff000,0x081000,0x081000,0x085000,0x085000,0x085000,0x085000,0x085000,0x085000,0x085000,0x085000,0x085000,0x085000,0x095000,0x081000,0x081000,0x0ff000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // t
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x03fc00,0x0fe4f0,0x1fe30c,0x181d3c,0x000bfe,0x00113c,0x182108,0x1fe6f0,0x0ff800,0x03e000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // u
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000300,0x000f80,0x000fc0,0x000fd8,0x0007e4,0x0003e4,0x0003f8,0x000df0,0x0031f8,0x00c3f0,0x01047c,0x06187c,0x08603c,0x088018,0x0b0000,0x040000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // v
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x012000,0x033000,0x052800,0x05e800,0x048800,0x040800,0x031000,0x008800,0x004800,0x002400,0x002400,0x001200,0x001100,0x0008c0,0x001020,0x001220,0x001520,0x001520,0x000dc0,0x000500,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // w
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0c0000,0x120000,0x110000,0x090000,0x068000,0x014000,0x00a000,0x005000,0x002800,0x001500,0x000b00,0x0007e0,0x000ff0,0x0003f8,0x0003fc,0x0001fc,0x0000fc,0x00007c,0x000038,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // x
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x0fffc0,0x0fffc0,0x0c0040,0x0c0040,0x0fffc0,0x080040,0x0ffc40,0x0807ff,0x0b8401,0x0b8555,0x0b8555,0x080555,0x0bf455,0x0bf455,0x080455,0x0bf451,0x0bf457,0x0bf456,0x0bf404,0x0807f8,0x0fffc0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // y
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x07f000,0x041000,0x0c1c00,0x0cf400,0x0c97fc,0x0c9404,0x0cf404,0x0c9404,0x0c9404,0x0cf404,0x0c9404,0x0c9404,0x0cf404,0x0c1404,0x0c143c,0x0c143c,0x0c1438,0x0c17f0,0x0c1400,0x0c1c00,0x041000,0x07f000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // z
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0x079000,0x0f9c00,0x0f87e0,0x0f97e0,0x0f97e0,0x0f97e0,0x0f9400,0x0f9780,0x0f9080,0x0f8080,0x0f9080,0x0f9780,0x0f9400,0x0f8400,0x079c00,0x019000,0x00f000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // {
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f800,0x00c400,0x00c600,0x00c300,0x13c100,0x1b3ef0,0x3b2018,0x13cd6c,0x60dfd4,0x13cd6c,0x3b2018,0x1b3ef0,0x13c100,0x00c300,0x00c600,0x00c400,0x00f800,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // |
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x03c000,0x042000,0x091000,0x0b9000,0x09d000,0x093300,0x043f80,0x03c780,0x001980,0x003e40,0x007e40,0x00fe40,0x01fe00,0x01fe00,0x01be00,0x03ce00,0x05ae00,0x099600,0x099200,0x081600,0x042600,0x03c600,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000, // }
|
||||||
|
0x000000,0x000000,0x000000,0x000000,0x03e000,0x063000,0x0c1800,0x080800,0x08c800,0x087800,0x0c1c00,0x063600,0x01e380,0x000e80,0x003280,0x00c280,0x00e200,0x009a00,0x01c600,0x06b600,0x049800,0x08f800,0x08c800,0x080800,0x0c1800,0x063000,0x03e000,0x000000,0x000000,0x000000,0x000000,0x000000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
112
src/devices/Oled/SSD1306/Font_FranklinGothic_16X16.java
Normal file
112
src/devices/Oled/SSD1306/Font_FranklinGothic_16X16.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_FranklinGothic_16X16")
|
||||||
|
public class Font_FranklinGothic_16X16 extends FontPack {
|
||||||
|
public Font_FranklinGothic_16X16() {
|
||||||
|
super("Font_FranklinGothic_16X16", 16, 16, 16, 16, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <space>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x37fc,0x37fc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // !
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x007c,0x007c,0x0000,0x007c,0x007c,0x0000,0x0000,0x0000,0x0000,0x0000, // "
|
||||||
|
0x0000,0x0000,0x0600,0x3e60,0x3fe0,0x07fc,0x067c,0x3e60,0x3fe0,0x07fc,0x067c,0x0060,0x0000,0x0000,0x0000,0x0000, // #
|
||||||
|
0x0000,0x0000,0x0000,0x0800,0x18f0,0x31f8,0x2188,0x7ffc,0x2308,0x3f18,0x1e10,0x0000,0x0000,0x0000,0x0000,0x0000, // $
|
||||||
|
0x0000,0x0078,0x00fc,0x2084,0x3084,0x1cfc,0x0e78,0x0380,0x01c0,0x1e70,0x3f38,0x210c,0x2104,0x3f00,0x1e00,0x0000, // %
|
||||||
|
0x0000,0x0000,0x0000,0x0e00,0x1f38,0x39fc,0x30cc,0x31cc,0x37fc,0x1e38,0x1c00,0x3f80,0x3380,0x0000,0x0000,0x0000, // &
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x007c,0x007c,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // '
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03e0,0x0ff8,0x1c1c,0x1004,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // (
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1004,0x1c1c,0x0ff8,0x03e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // )
|
||||||
|
0x0000,0x0000,0x0000,0x0060,0x0060,0x0460,0x0ec0,0x07c0,0x01fc,0x01fc,0x07c0,0x0ec0,0x0460,0x0060,0x0060,0x0000, // *
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0300,0x0300,0x0300,0x3ff0,0x3ff0,0x0300,0x0300,0x0300,0x0000,0x0000,0x0000, // +
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2c00,0x1c00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ,
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0180,0x0180,0x0180,0x0180,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // -
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1800,0x1800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // .
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0xc000,0x3000,0x0c00,0x0300,0x00c0,0x0030,0x000c,0x0002,0x0000,0x0000,0x0000,0x0000, // /
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07e0,0x1ff8,0x381c,0x300c,0x300c,0x381c,0x1ff8,0x07e0,0x0000,0x0000,0x0000,0x0000, // 0
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3060,0x3030,0x3018,0x3ffc,0x3ffc,0x3000,0x3000,0x3000,0x0000,0x0000,0x0000,0x0000, // 1
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3030,0x3838,0x3c1c,0x3e0c,0x370c,0x339c,0x31f8,0x30f0,0x0000,0x0000,0x0000,0x0000, // 2
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0c30,0x1c38,0x381c,0x318c,0x318c,0x318c,0x1ff8,0x0e70,0x0000,0x0000,0x0000,0x0000, // 3
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0700,0x0780,0x06e0,0x0670,0x061c,0x3ffc,0x3ffc,0x0600,0x0600,0x0000,0x0000,0x0000, // 4
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x19fc,0x19fc,0x318c,0x30cc,0x30cc,0x39cc,0x1f8c,0x0f00,0x0000,0x0000,0x0000, // 5
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07e0,0x1ff8,0x399c,0x30cc,0x30cc,0x39cc,0x1f9c,0x0f18,0x0000,0x0000,0x0000,0x0000, // 6
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x000c,0x000c,0x3c0c,0x3f8c,0x03cc,0x007c,0x003c,0x000c,0x0000,0x0000,0x0000, // 7
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0e70,0x1ff8,0x318c,0x318c,0x318c,0x318c,0x1ff8,0x0e70,0x0000,0x0000,0x0000, // 8
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x08f0,0x19f8,0x339c,0x330c,0x330c,0x199c,0x1ff8,0x07e0,0x0000,0x0000,0x0000,0x0000, // 9
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0c30,0x0c30,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // :
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2c30,0x1c30,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ;
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0100,0x0380,0x0380,0x06c0,0x06c0,0x0c60,0x0c60,0x1830,0x0000,0x0000,0x0000,0x0000, // <
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0360,0x0360,0x0360,0x0360,0x0360,0x0360,0x0360,0x0360,0x0000,0x0000,0x0000,0x0000, // =
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x1830,0x0c60,0x0c60,0x06c0,0x06c0,0x0380,0x0380,0x0100,0x0000,0x0000,0x0000, // >
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0030,0x0038,0x000c,0x360c,0x370c,0x019c,0x00f8,0x0070,0x0000,0x0000,0x0000,0x0000, // ?
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x07c0,0x0820,0x1390,0x2448,0x2448,0x2248,0x23c8,0x2418,0x1230,0x01e0,0x0000,0x0000,0x0000, // @
|
||||||
|
0x0000,0x0000,0x2000,0x3c00,0x3f80,0x0ff0,0x02fc,0x021c,0x02fc,0x0ff0,0x3f80,0x3c00,0x2000,0x0000,0x0000,0x0000, // A
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x318c,0x318c,0x318c,0x318c,0x1ff8,0x0e70,0x0000,0x0000,0x0000,0x0000, // B
|
||||||
|
0x0000,0x0000,0x0000,0x07e0,0x1ff8,0x1c38,0x300c,0x300c,0x300c,0x300c,0x1c38,0x0c30,0x0000,0x0000,0x0000,0x0000, // C
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x300c,0x300c,0x300c,0x381c,0x1c38,0x0ff0,0x07e0,0x0000,0x0000,0x0000, // D
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x318c,0x318c,0x318c,0x318c,0x300c,0x0000,0x0000,0x0000,0x0000,0x0000, // E
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x018c,0x018c,0x018c,0x018c,0x000c,0x0000,0x0000,0x0000,0x0000,0x0000, // F
|
||||||
|
0x0000,0x0000,0x07e0,0x1ff8,0x1818,0x300c,0x300c,0x330c,0x1b1c,0x1f38,0x3f30,0x0000,0x0000,0x0000,0x0000,0x0000, // G
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x0180,0x0180,0x0180,0x0180,0x3ffc,0x3ffc,0x0000,0x0000,0x0000,0x0000, // H
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // I
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x3000,0x3000,0x3ffc,0x1ffc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // J
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x0300,0x01c0,0x03f0,0x0f38,0x3c0c,0x3004,0x0000,0x0000,0x0000,0x0000, // K
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x3000,0x3000,0x3000,0x3000,0x0000,0x0000,0x0000,0x0000,0x0000, // L
|
||||||
|
0x0000,0x0000,0x3ffc,0x3ffc,0x003c,0x01f0,0x0f80,0x3c00,0x0f80,0x01f0,0x003c,0x3ffc,0x3ffc,0x0000,0x0000,0x0000, // M
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x0078,0x01e0,0x0780,0x1e00,0x3ffc,0x3ffc,0x0000,0x0000,0x0000,0x0000, // N
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07e0,0x0ff0,0x1818,0x300c,0x300c,0x300c,0x300c,0x1818,0x0ff0,0x07e0,0x0000,0x0000, // O
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x018c,0x018c,0x018c,0x018c,0x00f8,0x0070,0x0000,0x0000,0x0000, // P
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07e0,0x1ff8,0x1818,0x300c,0x300c,0x300c,0x700c,0xd818,0xcff8,0xc7e0,0x0000,0x0000, // Q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffc,0x3ffc,0x018c,0x018c,0x018c,0x078c,0x1f8c,0x38f8,0x2070,0x0000,0x0000,0x0000, // R
|
||||||
|
0x0000,0x0000,0x0000,0x0c00,0x1c70,0x38f8,0x30dc,0x31cc,0x318c,0x3b8c,0x1f18,0x0e10,0x0000,0x0000,0x0000,0x0000, // S
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x000c,0x000c,0x000c,0x3ffc,0x3ffc,0x000c,0x000c,0x000c,0x0000,0x0000,0x0000,0x0000, // T
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0ffc,0x1ffc,0x3000,0x3000,0x3000,0x1ffc,0x0ffc,0x0000,0x0000,0x0000,0x0000,0x0000, // U
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x001c,0x03fc,0x3fe0,0x3c00,0x3fe0,0x03fc,0x001c,0x0000,0x0000,0x0000,0x0000,0x0000, // V
|
||||||
|
0x0000,0x0000,0x003c,0x03fc,0x3fc0,0x3c00,0x3fc0,0x03fc,0x003c,0x03fc,0x3fc0,0x3c00,0x3fc0,0x03fc,0x003c,0x0000, // W
|
||||||
|
0x0000,0x0000,0x0000,0x2004,0x381c,0x1e38,0x07e0,0x01c0,0x07e0,0x1e38,0x381c,0x2004,0x0000,0x0000,0x0000,0x0000, // X
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x000c,0x003c,0x00f0,0x3fc0,0x3fc0,0x00f0,0x003c,0x000c,0x0000,0x0000,0x0000,0x0000, // Y
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x300c,0x3c0c,0x3e0c,0x338c,0x31cc,0x307c,0x303c,0x300c,0x0000,0x0000,0x0000,0x0000, // Z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7ffe,0x7ffe,0x4002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // [
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0006,0x0018,0x0060,0x0180,0x0600,0x1800,0x6000,0x8000,0x0000,0x0000,0x0000, // <backslash>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4002,0x7ffe,0x7ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ]
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0040,0x0060,0x0038,0x001e,0x0006,0x001e,0x0038,0x0060,0x0040,0x0000,0x0000,0x0000, // ^
|
||||||
|
0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000, // _
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0038,0x0044,0x0044,0x0038,0x0000,0x0000,0x0000, // `
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0e60,0x1f70,0x1930,0x19b0,0x09b0,0x1ff0,0x1fe0,0x0000,0x0000,0x0000,0x0000,0x0000, // a
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffe,0x0ffe,0x1820,0x1830,0x1830,0x0fe0,0x07c0,0x0000,0x0000,0x0000,0x0000,0x0000, // b
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x07c0,0x0fe0,0x1c70,0x1830,0x1830,0x1c70,0x0c60,0x0000,0x0000,0x0000,0x0000, // c
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0fe0,0x1830,0x1830,0x0820,0x1ffe,0x1ffe,0x0000,0x0000,0x0000,0x0000,0x0000, // d
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0fe0,0x19b0,0x19b0,0x19b0,0x0de0,0x05c0,0x0000,0x0000,0x0000,0x0000,0x0000, // e
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0030,0x1ffc,0x1ffe,0x0036,0x0036,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // f
|
||||||
|
0x0000,0x0000,0x3000,0x7ef0,0x6ff8,0x6d98,0x6d98,0x6d98,0x6dfc,0x3cf4,0x1804,0x0000,0x0000,0x0000,0x0000,0x0000, // g
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffe,0x1ffe,0x0060,0x0030,0x0030,0x1ff0,0x1fe0,0x0000,0x0000,0x0000,0x0000,0x0000, // h
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1fec,0x1fec,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // i
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,0x8000,0xffec,0x7fec,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // j
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffe,0x1ffe,0x0300,0x0380,0x0fe0,0x1c70,0x1010,0x0000,0x0000,0x0000,0x0000,0x0000, // k
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1ffe,0x1ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // l
|
||||||
|
0x0000,0x0000,0x1ff0,0x1ff0,0x0060,0x0030,0x0030,0x1ff0,0x1fe0,0x0060,0x0030,0x0030,0x1ff0,0x1fe0,0x0000,0x0000, // m
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff0,0x1ff0,0x0060,0x0030,0x0030,0x1ff0,0x1fe0,0x0000,0x0000,0x0000,0x0000,0x0000, // n
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0fe0,0x1830,0x1830,0x1830,0x0fe0,0x07c0,0x0000,0x0000,0x0000,0x0000,0x0000, // o
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0xfff0,0xfff0,0x0820,0x1830,0x1830,0x0fe0,0x07c0,0x0000,0x0000,0x0000,0x0000,0x0000, // p
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x07c0,0x0fe0,0x1830,0x1830,0x0830,0xffe0,0xfff0,0x0000,0x0000,0x0000,0x0000,0x0000, // q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1ff0,0x1ff0,0x0060,0x0030,0x0030,0x0000,0x0000,0x0000,0x0000,0x0000, // r
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0ce0,0x1df0,0x19b0,0x1b30,0x1f70,0x0e60,0x0000,0x0000,0x0000,0x0000,0x0000, // s
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0030,0x0ffc,0x1ffc,0x1830,0x1830,0x0000,0x0000,0x0000,0x0000,0x0000, // t
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0ff0,0x1ff0,0x1800,0x1800,0x0c00,0x1ff0,0x1ff0,0x0000,0x0000,0x0000,0x0000,0x0000, // u
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0030,0x01f0,0x0fc0,0x1e00,0x0fc0,0x01f0,0x0030,0x0000,0x0000,0x0000,0x0000,0x0000, // v
|
||||||
|
0x0000,0x0000,0x0030,0x03f0,0x1fc0,0x1c00,0x0f80,0x01f0,0x01f0,0x0f80,0x1c00,0x1fc0,0x03f0,0x0030,0x0000,0x0000, // w
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1010,0x1c70,0x0fe0,0x0380,0x0fe0,0x1c70,0x1010,0x0000,0x0000,0x0000,0x0000,0x0000, // x
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0030,0xc3f0,0xffc0,0x7c00,0x1fc0,0x03f0,0x0030,0x0000,0x0000,0x0000,0x0000,0x0000, // y
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1c30,0x1e30,0x1bb0,0x18f0,0x1870,0x0000,0x0000,0x0000,0x0000,0x0000, // z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0080,0x3f7c,0x7f7e,0x4002,0x4002,0x0000,0x0000,0x0000,0x0000,0x0000, // {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7fff,0x7fff,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // |
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4002,0x4002,0x7f7e,0x3f7c,0x0080,0x0000,0x0000,0x0000,0x0000,0x0000, // }
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0018,0x001c,0x000c,0x001c,0x0018,0x0018,0x001c,0x000c,0x0000,0x0000,0x0000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
113
src/devices/Oled/SSD1306/Font_Grotesk_16X32.java
Normal file
113
src/devices/Oled/SSD1306/Font_Grotesk_16X32.java
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Grotesk_16X32")
|
||||||
|
public class Font_Grotesk_16X32 extends FontPack {
|
||||||
|
public Font_Grotesk_16X32() {
|
||||||
|
super("Font_Grotesk_16X32", 16, 32, 16, 32, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <space>
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0f07fff8,0x0f07fff8,0x0f07fff8,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // !
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000fc0,0x00000ff0,0x00000ffc,0x0000007c,0x00000000,0x00000000,0x00000fc0,0x00000ff0,0x00000ffc,0x0000007c,0x00000000,0x00000000,0x00000000, // "
|
||||||
|
0x001c0000,0x001c0000,0x0e1c0e00,0x0ffc0e00,0x07ff8e00,0x003ffe00,0x001cfff0,0x0c1c0ff8,0x0ffc0e38,0x0fff0e00,0x007ffe00,0x001dffc0,0x001c1ff8,0x001c0e78,0x00180e00,0x00000e00, // #
|
||||||
|
0x00000000,0x00000000,0x01c00e00,0x03c03fc0,0x03807fe0,0x0300f0e0,0x0300e070,0x0701e070,0xffffffff,0x0701c070,0x0301c070,0x0383c070,0x01ff80e0,0x00ff00c0,0x003c0000,0x00000000, // $
|
||||||
|
0x00080780,0x000c1fe0,0x000e38f0,0x00067070,0x00077030,0x00037070,0x0003b8f0,0x01f19fe0,0x07f9cf80,0x0f1cc000,0x0e0ee000,0x0c0e6000,0x0e0e7000,0x071c3000,0x03f83800,0x01e01000, // %
|
||||||
|
0x00000000,0x01ff0000,0x03ff8000,0x07c3e7e0,0x0f00fff0,0x0e007ff8,0x1c00f83c,0x1c03e01c,0x0c0f801c,0x0e3f001c,0x0e7c0038,0x07f00038,0x07e00000,0x0fff8000,0x0e7f8000,0x080f8000, // &
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000f80,0x00000ff0,0x00000ffc,0x0000007c,0x00000004,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // '
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x000ff800,0x01ffffc0,0x0ffffff0,0x3fc001fe,0x7c00001f,0x60000003,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // (
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x60000003,0x7c00001f,0x3fe003fe,0x07fffff0,0x00ffff80,0x000ff000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // )
|
||||||
|
0x00000000,0x00180c00,0x001c1c00,0x001c1800,0x000e3800,0x00077000,0x0003e000,0x01ffffc0,0x03ffffc0,0x0003e000,0x00076000,0x00063000,0x000e3800,0x001c1c00,0x00380c00,0x00000000, // *
|
||||||
|
0x00000000,0x0000c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x00ffffc0,0x00ffffc0,0x00ffff80,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x00000000, // +
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x80000000,0xfc000000,0xfff00000,0x7ff00000,0x0ff00000,0x03f00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ,
|
||||||
|
0x00000000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x0001c000,0x00000000, // -
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0fe00000,0x0fe00000,0x0fe00000,0x0fe00000,0x0fe00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // .
|
||||||
|
0x00000000,0x00000000,0x0c000000,0x0f800000,0x07e00000,0x01f80000,0x007f0000,0x000fc000,0x0003f800,0x0000fe00,0x00001f80,0x000007e0,0x000001f0,0x00000030,0x00000000,0x00000000, // /
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x007fff00,0x01ffffe0,0x07fffff0,0x0ffc00f8,0x0e1f0038,0x1c07c01c,0x1c01f01c,0x0e007c3c,0x0f000f78,0x07f80ff0,0x03ffffe0,0x00ffff80,0x0001e000,0x00000000, // 0
|
||||||
|
0x00000000,0x00000000,0x00000000,0x040001e0,0x0e0000e0,0x0e0000f0,0x0e000070,0x0e000078,0x0ffffff8,0x0ffffff8,0x0e7ffff8,0x0e000000,0x0e000000,0x0e000000,0x04000000,0x00000000, // 1
|
||||||
|
0x00000000,0x00000000,0x0f000070,0x0f800078,0x0fc00038,0x0fe0003c,0x0ef0001c,0x0e3c001c,0x0e1e001c,0x0e0f001c,0x0e07c038,0x0e01f078,0x0e00fff0,0x0e003fe0,0x0e000f80,0x00000000, // 2
|
||||||
|
0x00000000,0x00000000,0x0f000030,0x0e000038,0x0e000038,0x0e00e03c,0x1e00e01c,0x1e00e01c,0x1e00e01c,0x0e00e03c,0x0f01f078,0x0f87bff8,0x07ff1ff0,0x03fe0fc0,0x00780000,0x00000000, // 3
|
||||||
|
0x00000000,0x003c0000,0x003f0000,0x003fc000,0x0039f000,0x00387c00,0x00381f00,0x003807c0,0x003800f0,0x0779fc78,0x0ffffff8,0x0ffffff8,0x00380000,0x00380000,0x00380000,0x00000000, // 4
|
||||||
|
0x00000000,0x00000000,0x0f000000,0x0e007ff8,0x0e007ff8,0x1e003ff8,0x1e003838,0x1e003838,0x1e003838,0x0e007838,0x0f00f038,0x0781f038,0x07ffe038,0x01ffc000,0x007e0000,0x00000000, // 5
|
||||||
|
0x00000000,0x00000000,0x007ffe00,0x03ffffc0,0x07ffeff0,0x0f00e0f8,0x0e007038,0x1c00383c,0x1c00381c,0x1c00381c,0x0e00781c,0x0f81f03c,0x07ffe038,0x01ffc000,0x003c0000,0x00000000, // 6
|
||||||
|
0x00000000,0x00000000,0x00000038,0x00000038,0x08000038,0x0f000038,0x0fe00038,0x07fc0038,0x00ff8038,0x001ff838,0x0003ff38,0x00003ff8,0x000007f8,0x000000f8,0x00000018,0x00000000, // 7
|
||||||
|
0x00000000,0x00000000,0x01fc0780,0x07ff1ff0,0x0fffbff8,0x0f03f878,0x0e01e03c,0x1c00e01c,0x1c00e01c,0x1e01e01c,0x0e01f038,0x0f87bff8,0x07ff1ff0,0x03fe0fc0,0x00780000,0x00000000, // 8
|
||||||
|
0x00000000,0x00000000,0x0000ffc0,0x0e03fff0,0x0e07f3f8,0x0e070038,0x1e0f001c,0x1e0e001c,0x0e0e001c,0x0e07003c,0x0f838078,0x07f1fff8,0x01ffffe0,0x007fff80,0x0001e000,0x00000000, // 9
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03f03f80,0x03f03f80,0x03f03f80,0x03f03f80,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // :
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x78000000,0x7ff03f80,0x7ff03f80,0x1ff03f80,0x03f03f80,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ;
|
||||||
|
0x00000000,0x0001c000,0x0003e000,0x0003e000,0x0007f000,0x00077000,0x000f3800,0x000e3800,0x001e1c00,0x001c1c00,0x003c0e00,0x00380e00,0x00780700,0x00700700,0x00f00380,0x00000000, // <
|
||||||
|
0x00000000,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x00000000, // =
|
||||||
|
0x00000000,0x00e00380,0x00f00780,0x00700700,0x00380f00,0x00380e00,0x001c1e00,0x001c1c00,0x000e3c00,0x000e3800,0x00077800,0x00077000,0x0003f000,0x0003e000,0x0001e000,0x00000000, // >
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000070,0x00000078,0x00000038,0x0700001c,0x0f1f801c,0x0f1fe01c,0x001bf01c,0x0000783c,0x00003ff8,0x00001ff0,0x000007e0,0x00000000,0x00000000, // ?
|
||||||
|
|
||||||
|
0x003ff000,0x01fffe00,0x07e01f80,0x1f0003e0,0x3c0000f0,0x781fc070,0x707ff038,0x60f87818,0xe0e01c18,0xe1c01c18,0xe1c01c38,0xe0e01c38,0xe07038f0,0xe0ffffe0,0x40ffff80,0x00000000, // @
|
||||||
|
0x0c000000,0x0fc00000,0x0ffc0000,0x03ffc000,0x003ffe00,0x003dffe0,0x003c0ff8,0x003c0078,0x003c01f8,0x003c3ff8,0x003fff80,0x007ff800,0x0fff8000,0x0ff80000,0x0f000000,0x00000000, // A
|
||||||
|
0x00000000,0x00000000,0x0ffffff8,0x0ffffff8,0x0ffffff8,0x0e007038,0x0e007038,0x0e007038,0x0e007038,0x0e00f038,0x0f00f878,0x0783fff0,0x07ff9fe0,0x01ff07c0,0x00780000,0x00000000, // B
|
||||||
|
0x00000000,0x0003f000,0x007fff00,0x01ffffc0,0x03fc1ff0,0x078000f8,0x0f000038,0x0e00003c,0x1c00001c,0x1c00001c,0x1e00001c,0x0e00003c,0x0f000038,0x07000070,0x00000000,0x00000000, // C
|
||||||
|
0x00000000,0x07fffff8,0x0ffffff8,0x0ffffff8,0x0e000038,0x0e000038,0x0e000038,0x0e000038,0x0f000038,0x07000078,0x07c001f0,0x03ffffe0,0x01ffffc0,0x003fff00,0x00000000,0x00000000, // D
|
||||||
|
0x00000000,0x00000000,0x0ffffff8,0x0ffffff8,0x0ffffff8,0x0e007038,0x0e007038,0x0e007038,0x0e007038,0x0e007038,0x0e007038,0x0e007038,0x0e007038,0x0e006038,0x00000000,0x00000000, // E
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0ffffff8,0x0ffffff8,0x0ffffff8,0x00007038,0x00007038,0x00007038,0x00007038,0x00007038,0x00007038,0x00007038,0x00006038,0x00000000,0x00000000, // F
|
||||||
|
0x00000000,0x000ff800,0x00ffff80,0x03ffffe0,0x07f007f0,0x0f000078,0x0e000038,0x0e00001c,0x1c00001c,0x1c03801c,0x0e03801c,0x0f738038,0x0fff8078,0x07ff8070,0x00000000,0x00000000, // G
|
||||||
|
0x00000000,0x07fffff8,0x0ffffff8,0x0ffffff8,0x0000f000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x0ffffff8,0x0ffffff8,0x0ffffff8,0x00000000,0x00000000, // H
|
||||||
|
0x00000000,0x00000000,0x0e000038,0x0e000038,0x0e000038,0x0e000038,0x0ffffff8,0x0ffffff8,0x0ffffff8,0x0e000038,0x0e000038,0x0e000038,0x0e000038,0x00000000,0x00000000,0x00000000, // I
|
||||||
|
0x00000000,0x07800000,0x0f000000,0x0e000000,0x0e000018,0x1c000038,0x1c000038,0x1e000038,0x0e000038,0x0fefffb8,0x07fffff8,0x03fffff8,0x00000000,0x00000000,0x00000000,0x00000000, // J
|
||||||
|
0x00000000,0x07fffff8,0x0ffffff8,0x0ffffff8,0x0003e000,0x0000f000,0x0000f800,0x0003fe00,0x000fcf00,0x003f0780,0x00fc03e0,0x03f000f0,0x0fc00078,0x0f800038,0x0e000008,0x08000000, // K
|
||||||
|
0x00000000,0x00000000,0x07fffff8,0x0ffffff8,0x0ffffff8,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x00000000, // L
|
||||||
|
0x0ffffff8,0x0ffffff8,0x0ffffff8,0x000001f8,0x00001fe0,0x0001fe00,0x0007e000,0x0007c000,0x0003fc00,0x00007f80,0x000003f8,0x000000f8,0x0ffffff8,0x0ffffff8,0x00000000,0x00000000, // M
|
||||||
|
0x0ffffff8,0x0ffffff8,0x0ffffff8,0x000001f8,0x00000fe0,0x00007f80,0x0001fc00,0x000fe000,0x007f8000,0x03fc0000,0x0fe00000,0x0ffffff8,0x0ffffff8,0x0ffffff8,0x00000000,0x00000000, // N
|
||||||
|
0x00000000,0x000ff800,0x00ffffc0,0x03fffff0,0x07f003f8,0x0f000078,0x0e00003c,0x1c00001c,0x1c00001c,0x0e00003c,0x0f000078,0x07ffdff0,0x03ffffe0,0x00ffff80,0x0001e000,0x00000000, // O
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x0ffffff8,0x0ffffff8,0x0ffffff8,0x00038038,0x00038038,0x00038038,0x00038038,0x00038038,0x0003c038,0x0001e0f8,0x0001fff0,0x0000ffe0,0x00001f80,0x00000000, // P
|
||||||
|
0x00000000,0x000ffc00,0x00ffffc0,0x03fffff0,0x07f003f8,0x07000038,0x0e00001c,0x0e00001c,0x0e00001c,0x1f00003c,0x7f800078,0xf3fedff8,0x61ffffe0,0x007fff80,0x0001e000,0x00000000, // Q
|
||||||
|
0x00000000,0x00000000,0x0ffffff8,0x0ffffff8,0x07fbdfb8,0x0003c038,0x0003c038,0x0003c038,0x0003c038,0x0007c038,0x001fe0f8,0x00fefff0,0x07f87fe0,0x0fe01f80,0x0f000000,0x08000000, // R
|
||||||
|
0x00000000,0x00000600,0x07003fe0,0x0f007ff0,0x0e00f8f8,0x0e00f038,0x1c01e01c,0x1c01e01c,0x1c01e01c,0x0e03c01c,0x0f03c03c,0x0fdf8038,0x07ff0078,0x01fe0000,0x00000000,0x00000000, // S
|
||||||
|
0x00000018,0x00000038,0x00000038,0x00000038,0x00000038,0x00000038,0x07ffffb8,0x0ffffff8,0x0ffffff8,0x00000038,0x00000038,0x00000038,0x00000038,0x00000038,0x00000038,0x00000018, // T
|
||||||
|
0x00000000,0x00000000,0x01fffff8,0x07fffff8,0x0ffffff8,0x0e000000,0x0e000000,0x1c000000,0x1c000000,0x0e000000,0x0e000000,0x0ffffff8,0x07fffff8,0x01fffff8,0x00000000,0x00000000, // U
|
||||||
|
0x00000000,0x00000078,0x000007f8,0x0000fff8,0x000fff80,0x01fff000,0x0ffe0000,0x0f800000,0x0f800000,0x0ffe0000,0x01fff000,0x000fff80,0x0000fff8,0x000007f8,0x00000078,0x00000000, // V
|
||||||
|
0x000000f8,0x0001fff8,0x03fffff8,0x0ffff000,0x0fe00000,0x0fff0000,0x003ffc00,0x00007e00,0x0000fe00,0x003ffc00,0x0fff0000,0x0fe00000,0x0ffff000,0x03fffff8,0x0001fff8,0x000000f8, // W
|
||||||
|
0x08000000,0x0e000008,0x0f800038,0x07e000f8,0x01f803f0,0x007e0fc0,0x001fbf00,0x0007f800,0x0003f800,0x000ffe00,0x007f1f80,0x01f807e0,0x07e001f8,0x0f800078,0x0e000018,0x08000000, // X
|
||||||
|
0x00000000,0x00000018,0x000000f8,0x000003f8,0x00000fc0,0x00003f00,0x07fdfc00,0x0fffe000,0x0fffe000,0x0000fc00,0x00003f00,0x00000fe0,0x000003f8,0x00000078,0x00000018,0x00000000, // Y
|
||||||
|
0x00000000,0x00000000,0x0f000038,0x0fc00038,0x0ff00038,0x0efc0038,0x0e3f0038,0x0e0fc038,0x0e03f038,0x0e00fc38,0x0e003f38,0x0e000ff8,0x0e0003f8,0x0e0000f8,0x0e000038,0x00000000, // Z
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0fffffff,0x0c000003,0x0c000003,0x0c000003,0x00000000,0x00000000,0x00000000, // [
|
||||||
|
0x00000000,0x00000010,0x00000070,0x000001f0,0x00000fe0,0x00003f80,0x0000fc00,0x0007f000,0x001fc000,0x007e0000,0x03f80000,0x0fe00000,0x0f000000,0x0c000000,0x00000000,0x00000000, // <backslash>
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0c000003,0x0c000003,0x0c000003,0x0fffffff,0x0fffffff,0x07fffffe,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ]
|
||||||
|
0x00000000,0x00030000,0x00038000,0x0003e000,0x0000f000,0x00007c00,0x00003f00,0x00000f00,0x00000f00,0x00003f00,0x00007c00,0x0000f800,0x0003e000,0x00038000,0x00030000,0x00000000, // ^
|
||||||
|
0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0e000000, // _
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000fc0,0x00000ff8,0x00000ffc,0x0000003c,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // `
|
||||||
|
0x00000000,0x00e00000,0x07fc1c00,0x0ffe1e00,0x0f0e0e00,0x1e070e00,0x1c070600,0x1c070700,0x0e070600,0x0e070e00,0x03871e00,0x0ffffc00,0x0ffff800,0x0fffc000,0x00000000,0x00000000, // a
|
||||||
|
0x00000000,0x00000000,0x0ffffffc,0x0ffffffc,0x0ffffffc,0x07001c00,0x0e000e00,0x1c000600,0x1c000700,0x1e000e00,0x0f001e00,0x0fe0fc00,0x03fff800,0x00ffe000,0x00000000,0x00000000, // b
|
||||||
|
0x00000000,0x00000000,0x003f8000,0x01fff000,0x03fff800,0x07803c00,0x0f001e00,0x0e000e00,0x1c000600,0x1c000700,0x1c000600,0x0e000e00,0x0e001e00,0x07001c00,0x00000000,0x00000000, // c
|
||||||
|
0x00000000,0x001f0000,0x01fff000,0x07fffc00,0x0f807e00,0x0e000e00,0x1c000e00,0x1c000700,0x0c000e00,0x0e000e00,0x07803c00,0x0ffffffc,0x0ffffffc,0x0ffffffc,0x00000000,0x00000000, // d
|
||||||
|
0x00000000,0x001f0000,0x00ffe000,0x03fff800,0x07c77c00,0x0f071e00,0x0e070e00,0x1c070600,0x1c070700,0x1c070e00,0x0e070e00,0x0e073c00,0x0e07f800,0x0707f000,0x00038000,0x00000000, // e
|
||||||
|
0x00000000,0x00000000,0x00000600,0x00000e00,0x00000e00,0x00000e00,0x0fffffe0,0x0ffffff8,0x0ffffffc,0x00000e1c,0x00000e1c,0x00000e1c,0x00000e1c,0x0000060c,0x00000000,0x00000000, // f
|
||||||
|
0x00000000,0x00078000,0x007ff000,0x60fffc00,0xe1e03e00,0xe3c00e00,0xc3800600,0xc3800700,0xe3800600,0xe1800e00,0x70e01c00,0x7ffffe00,0x1ffffe00,0x07fffe00,0x00000000,0x00000000, // g
|
||||||
|
0x00000000,0x00000000,0x0ffffffc,0x0ffffffc,0x0ffffffc,0x00001800,0x00000e00,0x00000e00,0x00000e00,0x00000f00,0x00001e00,0x0ffffe00,0x0ffff800,0x0fffc000,0x00000000,0x00000000, // h
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0c000000,0x0e000e00,0x0e000e00,0x0e000e00,0x0e000e00,0x0ffffe3c,0x0ffffe3c,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x0c000000,0x00000000, // i
|
||||||
|
0x00000000,0x00000000,0xc0000000,0xe0000600,0xe0000600,0xe0000600,0xe0000600,0xfbffee38,0x7ffffe3c,0x1ffffe38,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // j
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0ffffffc,0x0ffffffc,0x07df3ffc,0x00070000,0x0007c000,0x001fe000,0x007ef000,0x00f83c00,0x03e01e00,0x0f800e00,0x0f000600,0x0c000000,0x00000000, // k
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0000000c,0x0000000e,0x0000000e,0x0000000e,0x01fffffe,0x07fffffe,0x0f800000,0x0e000000,0x0e000000,0x0e000000,0x0e000000,0x04000000,0x00000000, // l
|
||||||
|
0x00000000,0x0ffffe00,0x0ffffe00,0x07ff7c00,0x00000e00,0x00000600,0x00001e00,0x0ffffe00,0x0ffffc00,0x00000e00,0x00000600,0x00000f00,0x0ffffe00,0x0ffffc00,0x0ffff000,0x00000000, // m
|
||||||
|
0x00000000,0x00000000,0x0ffffe00,0x0ffffe00,0x0ffffe00,0x00001800,0x00000e00,0x00000e00,0x00000e00,0x00000f00,0x00001e00,0x0ffffe00,0x0ffff800,0x0fffc000,0x00000000,0x00000000, // n
|
||||||
|
0x00000000,0x000e0000,0x01fff000,0x03fff800,0x0fc07c00,0x0f001e00,0x0e000e00,0x1c000700,0x1c000600,0x0e000e00,0x0f001e00,0x07f7fc00,0x03fff800,0x00ffe000,0x00000000,0x00000000, // o
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0xfffffe00,0xfffffe00,0xfffffe00,0x01c01c00,0x03800e00,0x03000600,0x03000700,0x03800600,0x03c00e00,0x01f87e00,0x00fffc00,0x003ff000,0x00000000,0x00000000, // p
|
||||||
|
0x00000000,0x00070000,0x007ff000,0x00fffc00,0x01f03e00,0x03800e00,0x03800600,0x03000700,0x03800600,0x01800e00,0x01e01c00,0xfffffe00,0xfffffe00,0xfffffe00,0x00000000,0x00000000, // q
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x07fffc00,0x0ffffe00,0x0ffffe00,0x00007800,0x00001c00,0x00000e00,0x00000e00,0x00000f00,0x00000e00,0x00000e00,0x00001e00,0x00000000, // r
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0f03f800,0x0e07fc00,0x0e079e00,0x1c0f0e00,0x1c0e0600,0x1c0e0700,0x0e1e0600,0x0f1e0e00,0x07fc0e00,0x03f81c00,0x00400000,0x00000000,0x00000000, // s
|
||||||
|
0x00000000,0x00000400,0x00000e00,0x00000e00,0x00000e00,0x00fffff0,0x07fffff0,0x07fffff0,0x0f000e00,0x0e000e00,0x0e000e00,0x0e000e00,0x0e000e00,0x00000000,0x00000000,0x00000000, // t
|
||||||
|
0x00000000,0x00000000,0x007ffe00,0x07fffe00,0x0ffffe00,0x0f000000,0x1e000000,0x1c000000,0x0c000000,0x0e000000,0x07000000,0x0ffffe00,0x0ffffe00,0x0ffffe00,0x00000000,0x00000000, // u
|
||||||
|
0x00000000,0x00000600,0x00003e00,0x0003fe00,0x001ff000,0x01ff8000,0x0ff80000,0x0f800000,0x0f800000,0x0ff80000,0x01ff8000,0x001ff800,0x0001fe00,0x00003e00,0x00000200,0x00000000, // v
|
||||||
|
0x00001e00,0x0003fe00,0x00fffc00,0x0fff8000,0x0fc00000,0x0fc00000,0x01ff0000,0x000fc000,0x000fc000,0x01ff0000,0x0fc00000,0x0fc00000,0x0fff8000,0x00fffc00,0x0003fe00,0x00001e00, // w
|
||||||
|
0x00000000,0x08000000,0x0e000600,0x0f801e00,0x07c07c00,0x01f0f800,0x007fe000,0x001f8000,0x001f8000,0x007fe000,0x01f0f800,0x07c07c00,0x0f801e00,0x0e000600,0x08000000,0x00000000, // x
|
||||||
|
0x00000000,0x00000200,0xc0001e00,0xe000fe00,0xe007f800,0xe01fc000,0x78fe0000,0x3ff00000,0x0fe00000,0x03fc0000,0x007f8000,0x000ff000,0x0001fe00,0x00003e00,0x00000600,0x00000000, // y
|
||||||
|
0x00000000,0x00000000,0x06000000,0x0f000e00,0x0fc00e00,0x0ff00e00,0x0ef80e00,0x0e3e0e00,0x0e0f8e00,0x0e07ce00,0x0e01fe00,0x0e007e00,0x0e003e00,0x0c000e00,0x00000000,0x00000000, // z
|
||||||
|
0x00000000,0x00000000,0x00006000,0x0000e000,0x0000e000,0x0000e000,0x0001f000,0x03ffbffc,0x07ff1ffe,0x0ffe0fff,0x0e000007,0x0c000003,0x0c000003,0x0c000002,0x00000000,0x00000000, // {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0fffffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // |
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0c000003,0x0c000003,0x0e000007,0x0f7803ef,0x07ff1ffe,0x03ffbffc,0x0003f800,0x0000e000,0x0000e000,0x0000e000,0x0000e000,0x00000000,0x00000000, // }
|
||||||
|
0x0000c000,0x0001f000,0x00007c00,0x00001c00,0x00001e00,0x00001e00,0x00003c00,0x0000f800,0x0001e000,0x0003c000,0x00070000,0x00070000,0x00078000,0x0003e000,0x0001f000,0x00006000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
112
src/devices/Oled/SSD1306/Font_Helvetica_16X16.java
Normal file
112
src/devices/Oled/SSD1306/Font_Helvetica_16X16.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Helvetica_16X16")
|
||||||
|
public class Font_Helvetica_16X16 extends FontPack {
|
||||||
|
public Font_Helvetica_16X16() {
|
||||||
|
super("Font_Helvetica_16X16", 16, 16, 16, 16, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <space>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x27f8,0x27f8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // !
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0038,0x0038,0x0000,0x0038,0x0038,0x0000,0x0000,0x0000,0x0000,0x0000, // "
|
||||||
|
0x0000,0x0000,0x0000,0x0480,0x0480,0x0fe0,0x0fe0,0x0480,0x0fe0,0x0fe0,0x0480,0x0000,0x0000,0x0000,0x0000,0x0000, // #
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x10e0,0x19f8,0x1998,0x3ff8,0x3ff8,0x1998,0x1f98,0x0f18,0x0018,0x0000,0x0000,0x0000, // $
|
||||||
|
0x0000,0x0078,0x00fc,0x2084,0x3084,0x1cfc,0x0e78,0x0380,0x01c0,0x1e70,0x3f38,0x210c,0x2104,0x3f00,0x1e00,0x0000, // %
|
||||||
|
0x0000,0x0000,0x0000,0x0e00,0x1f38,0x39fc,0x30cc,0x31cc,0x37fc,0x1e38,0x1c00,0x3f80,0x3380,0x0000,0x0000,0x0000, // &
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0038,0x0038,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // '
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03e0,0x0ff8,0x1c1c,0x1004,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // (
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1004,0x1c1c,0x0ff8,0x03e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // )
|
||||||
|
0x0000,0x0000,0x0000,0x0060,0x02e0,0x06e0,0x0fe0,0x07f8,0x03f8,0x03f0,0x07c0,0x0fe0,0x06e0,0x00e0,0x0000,0x0000, // *
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0400,0x0400,0x0400,0x1f80,0x1f80,0x0400,0x0400,0x0400,0x0000,0x0000,0x0000,0x0000, // +
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2c00,0x1c00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ,
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0000,0x0000,0x0000,0x0000,0x0000, // -
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1800,0x1800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // .
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x2000,0x3800,0x1e00,0x0780,0x01e0,0x0078,0x001c,0x0004,0x0000,0x0000,0x0000, // /
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff0,0x3ff8,0x3018,0x2008,0x2008,0x2008,0x3018,0x3ff8,0x1ff0,0x0000,0x0000,0x0000, // 0
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // 1
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3e08,0x3f08,0x2108,0x2108,0x2108,0x2108,0x2108,0x21f8,0x20f0,0x0000,0x0000,0x0000, // 2
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2008,0x2108,0x2108,0x2108,0x2108,0x2108,0x2108,0x3ff8,0x1ff0,0x0000,0x0000,0x0000, // 3
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x01f8,0x03f8,0x0200,0x0200,0x0200,0x3f80,0x3f80,0x0200,0x0200,0x0000,0x0000,0x0000, // 4
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x21f8,0x21f8,0x2108,0x2108,0x2108,0x2108,0x2108,0x3f08,0x1e08,0x0000,0x0000,0x0000, // 5
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff0,0x3ff8,0x3188,0x2088,0x2088,0x2088,0x2088,0x3188,0x1f88,0x1f00,0x0000,0x0000, // 6
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0008,0x0008,0x3008,0x3c08,0x0f08,0x03c8,0x00f8,0x0038,0x0008,0x0000,0x0000,0x0000, // 7
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ef0,0x3ff8,0x2108,0x2108,0x2108,0x2108,0x2108,0x3ff8,0x1ff0,0x0000,0x0000,0x0000, // 8
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x01f0,0x21f8,0x2318,0x2208,0x2208,0x2208,0x2208,0x2318,0x3ff8,0x1ff0,0x0000,0x0000, // 9
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0c30,0x0c30,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // :
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2c30,0x1c30,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ;
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0300,0x0780,0x0780,0x0cc0,0x0840,0x1860,0x1020,0x0000,0x0000,0x0000,0x0000, // <
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0240,0x0240,0x0240,0x0240,0x0240,0x0240,0x0240,0x0240,0x0240,0x0000,0x0000,0x0000, // =
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1020,0x1860,0x0cc0,0x0cc0,0x0780,0x0300,0x0300,0x0000,0x0000,0x0000, // >
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0008,0x0008,0x2708,0x2788,0x0088,0x0088,0x0088,0x00f8,0x0070,0x0000,0x0000,0x0000, // ?
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0ff0,0x1008,0x13c8,0x1428,0x1428,0x1428,0x17e8,0x1408,0x17f0,0x0000,0x0000,0x0000, // @
|
||||||
|
0x0000,0x0000,0x0000,0x2000,0x3c00,0x1f80,0x03f0,0x0278,0x0278,0x03f0,0x1f80,0x3c00,0x2000,0x0000,0x0000,0x0000, // A
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x2108,0x2108,0x2108,0x2108,0x2108,0x3ff8,0x1ff0,0x0000,0x0000,0x0000, // B
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff0,0x3ff8,0x2008,0x2008,0x2008,0x2008,0x2008,0x2008,0x2008,0x0000,0x0000,0x0000, // C
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x2008,0x2008,0x2008,0x2008,0x2008,0x3ff8,0x1ff0,0x0000,0x0000,0x0000, // D
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff0,0x3ff8,0x2108,0x2108,0x2108,0x2108,0x2108,0x2108,0x2108,0x0000,0x0000,0x0000, // E
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff0,0x3ff8,0x0108,0x0108,0x0108,0x0108,0x0108,0x0108,0x0108,0x0000,0x0000,0x0000, // F
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff0,0x3ff8,0x2008,0x2008,0x2088,0x2088,0x2088,0x2088,0x3f88,0x3f88,0x0000,0x0000, // G
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x3ff8,0x3ff8,0x0000,0x0000, // H
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // I
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x3ff8,0x1ff8,0x0000,0x0000,0x0000, // J
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0100,0x0100,0x0180,0x01c0,0x01f0,0x3f38,0x3e18,0x0000,0x0000,0x0000, // K
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff8,0x3ff8,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x0000,0x0000,0x0000, // L
|
||||||
|
0x0000,0x3ff8,0x3ff8,0x0008,0x0008,0x0008,0x0008,0x3ff8,0x3ff8,0x0008,0x0008,0x0008,0x0008,0x3ff8,0x3ff0,0x0000, // M
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x3ff8,0x3ff0,0x0000,0x0000, // N
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x1ff0,0x3ff8,0x2008,0x2008,0x2008,0x2008,0x2008,0x2008,0x3ff8,0x1ff0,0x0000, // O
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0108,0x0108,0x0108,0x0108,0x0108,0x01f8,0x00f0,0x0000,0x0000,0x0000, // P
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0ff8,0x1ffc,0x1004,0x1004,0x7004,0xf004,0xd004,0x9004,0x9ffc,0x8ff8,0x0000, // Q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0108,0x0108,0x0108,0x0108,0x0108,0x3ff8,0x3ff0,0x0000,0x0000,0x0000, // R
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x20f0,0x21f8,0x2108,0x2108,0x2108,0x2108,0x2108,0x3f08,0x1e08,0x0000,0x0000,0x0000, // S
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0008,0x0008,0x0008,0x0008,0x3ff8,0x3ff8,0x0008,0x0008,0x0008,0x0008,0x0000,0x0000, // T
|
||||||
|
0x0000,0x0000,0x0000,0x1ff8,0x3ff8,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x3ff8,0x1ff8,0x0000,0x0000,0x0000, // U
|
||||||
|
0x0000,0x0000,0x0000,0x0008,0x0078,0x03f0,0x1f80,0x3c00,0x3c00,0x1f80,0x03f0,0x0078,0x0008,0x0000,0x0000,0x0000, // V
|
||||||
|
0x0000,0x0000,0x01f8,0x1fe0,0x3e00,0x3f80,0x07f0,0x0078,0x03f8,0x3fc0,0x3c00,0x3fc0,0x03f0,0x0038,0x0000,0x0000, // W
|
||||||
|
0x0000,0x0000,0x0000,0x2008,0x3018,0x3c78,0x0ee0,0x03c0,0x03c0,0x0ee0,0x3c78,0x3018,0x2008,0x0000,0x0000,0x0000, // X
|
||||||
|
0x0000,0x0000,0x0000,0x0008,0x0018,0x0078,0x00e0,0x3fc0,0x3fc0,0x00e0,0x0078,0x0018,0x0008,0x0000,0x0000,0x0000, // Y
|
||||||
|
0x0000,0x0000,0x0000,0x2008,0x3008,0x3c08,0x2e08,0x2388,0x21c8,0x2078,0x2038,0x2008,0x2000,0x0000,0x0000,0x0000, // Z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7ffe,0x7ffe,0x6002,0x6002,0x6002,0x0000,0x0000,0x0000,0x0000,0x0000, // [
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0004,0x003c,0x00f8,0x03f0,0x0fc0,0x3f00,0x7800,0x6000,0x0000,0x0000,0x0000,0x0000, // <backslash>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x6002,0x6002,0x7ffe,0x7ffe,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // ]
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0010,0x0018,0x001c,0x000c,0x001c,0x0018,0x0000,0x0000,0x0000,0x0000,0x0000, // ^
|
||||||
|
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000, // _
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0038,0x007c,0x0044,0x0044,0x0044,0x007c,0x0038,0x0000,0x0000,0x0000,0x0000, // `
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0e20,0x1f20,0x1b20,0x1120,0x1120,0x1120,0x1fe0,0x1fc0,0x0000,0x0000,0x0000,0x0000, // a
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffc,0x1ffc,0x1020,0x1020,0x1020,0x1020,0x1fe0,0x0fc0,0x0000,0x0000,0x0000,0x0000, // b
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0fc0,0x1fe0,0x1020,0x1020,0x1020,0x1020,0x1020,0x1020,0x0000,0x0000,0x0000,0x0000, // c
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0fc0,0x1fe0,0x1020,0x1020,0x1020,0x1020,0x1ffc,0x1ffc,0x0000,0x0000,0x0000,0x0000, // d
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0fc0,0x1fe0,0x1120,0x1120,0x1120,0x1120,0x1120,0x1120,0x0000,0x0000,0x0000,0x0000, // e
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0020,0x1ff8,0x1ffc,0x0024,0x0024,0x0024,0x0004,0x0000,0x0000,0x0000,0x0000,0x0000, // f
|
||||||
|
0x0000,0x0000,0x0000,0x07e0,0x4ff0,0x4810,0x4810,0x4810,0x4810,0x7ff0,0x3ff0,0x0000,0x0000,0x0000,0x0000,0x0000, // g
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffc,0x1ffc,0x0020,0x0020,0x0020,0x0020,0x1fe0,0x1fc0,0x0000,0x0000,0x0000,0x0000, // h
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1fc8,0x1fe8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // i
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x4000,0x6000,0x6000,0x7fe8,0x3fe8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // j
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ffc,0x1ffc,0x0100,0x0100,0x0180,0x01c0,0x1f60,0x1e20,0x0000,0x0000,0x0000,0x0000, // k
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1ffc,0x1ffc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // l
|
||||||
|
0x0000,0x0000,0x1fe0,0x1fe0,0x0020,0x0020,0x0020,0x1fe0,0x1fe0,0x0020,0x0020,0x0020,0x1fe0,0x1fc0,0x0000,0x0000, // m
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1fe0,0x1fe0,0x0020,0x0020,0x0020,0x0020,0x1fe0,0x1fc0,0x0000,0x0000,0x0000,0x0000, // n
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0fc0,0x1fe0,0x1020,0x1020,0x1020,0x1020,0x1fe0,0x0fc0,0x0000,0x0000,0x0000,0x0000, // o
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0xffe0,0xffe0,0x1020,0x1020,0x1020,0x1020,0x1fe0,0x0fc0,0x0000,0x0000,0x0000,0x0000, // p
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0fc0,0x1fe0,0x1020,0x1020,0x1020,0x1020,0xffe0,0xffe0,0x0000,0x0000,0x0000,0x0000, // q
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1fe0,0x1fe0,0x0020,0x0020,0x0020,0x0020,0x00e0,0x00c0,0x0000,0x0000,0x0000,0x0000, // r
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x10c0,0x11e0,0x1120,0x1120,0x1120,0x1120,0x1f20,0x0e20,0x0000,0x0000,0x0000,0x0000, // s
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0020,0x0ffc,0x1ffc,0x1020,0x1020,0x1020,0x1000,0x0000,0x0000,0x0000,0x0000, // t
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0fe0,0x1fe0,0x1000,0x1000,0x1000,0x1000,0x1fe0,0x1fe0,0x0000,0x0000,0x0000,0x0000, // u
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0020,0x01e0,0x07c0,0x1e00,0x1800,0x1f00,0x07c0,0x00e0,0x0020,0x0000,0x0000,0x0000, // v
|
||||||
|
0x0000,0x0000,0x0fe0,0x1fe0,0x1000,0x1000,0x1000,0x1fe0,0x1fe0,0x1000,0x1000,0x1000,0x1fe0,0x1fe0,0x0000,0x0000, // w
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0020,0x1060,0x1ce0,0x0f80,0x0700,0x0fc0,0x18e0,0x1060,0x0000,0x0000,0x0000,0x0000, // x
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x8fe0,0x9fe0,0x9000,0x9000,0x9000,0x9000,0xffe0,0x7fe0,0x0000,0x0000,0x0000,0x0000, // y
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x1020,0x1820,0x1c20,0x1720,0x13a0,0x10e0,0x1060,0x1020,0x1000,0x0000,0x0000, // z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0180,0x3ffe,0x7006,0x6002,0x6002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7fff,0x7fff,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // |
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4002,0x7006,0x7f7e,0x3ffe,0x01c0,0x0000,0x0000,0x0000,0x0000,0x0000, // }
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0018,0x001c,0x0004,0x0004,0x001c,0x0038,0x0020,0x0030,0x0038,0x0018,0x0000,0x0000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
116
src/devices/Oled/SSD1306/Font_Retro_16X32.java
Normal file
116
src/devices/Oled/SSD1306/Font_Retro_16X32.java
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
// Source : https://github.com/lynniemagoo/oled-font-pack/blob/master/fonts/16x32/grotesk-font-16x32.js
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Retro_16X32")
|
||||||
|
public class Font_Retro_16X32 extends FontPack{
|
||||||
|
|
||||||
|
public Font_Retro_16X32() {
|
||||||
|
super("Font_Retro_16X32", 16, 32, 16, 32, 32, 126);
|
||||||
|
data =new int[] {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <space>
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0f0fffff,0x0f0fffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // !
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000fff,0x00000fff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000fff,0x00000fff,0x00000000,0x00000000,0x00000000,0x00000000, // "
|
||||||
|
0x00000000,0x00000000,0x000f0f00,0x000f0f00,0x0fffffff,0x0fffffff,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x0fffffff,0x0fffffff,0x000f0f00,0x000f0f00,0x00000000,0x00000000, // #
|
||||||
|
0x00000000,0x00000000,0x00f00f00,0x00f00f00,0x00f0f0f0,0x00f0f0f0,0x0fffffff,0x0fffffff,0x00f0f0f0,0x00f0f0f0,0x000f00f0,0x000f00f0,0x00000000,0x00000000,0x00000000,0x00000000, // $
|
||||||
|
0x00000000,0x00000000,0x0f000ff0,0x0f000ff0,0x00f00ff0,0x00f00ff0,0x000f0000,0x000f0000,0x0000f000,0x0000f000,0x0ff00f00,0x0ff00f00,0x0ff000f0,0x0ff000f0,0x00000000,0x00000000, // %
|
||||||
|
0x00000000,0x00000000,0x00ff0ff0,0x00ff0ff0,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f0f0ff0,0x0f0f0ff0,0x00f00000,0x00f00000,0x0f0f0000,0x0f0f0000,0x00000000,0x00000000, // &
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000fff,0x00000fff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // '
|
||||||
|
0x00000000,0x00000000,0x000fff00,0x000fff00,0x00f000f0,0x00f000f0,0x0f00000f,0x0f00000f,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // (
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0f00000f,0x0f00000f,0x00f000f0,0x00f000f0,0x000fff00,0x000fff00,0x00000000,0x00000000,0x00000000,0x00000000, // )
|
||||||
|
0x00000000,0x00000000,0x00f000f0,0x00f000f0,0x000f0f00,0x000f0f00,0x0fffffff,0x0fffffff,0x000f0f00,0x000f0f00,0x00f000f0,0x00f000f0,0x00000000,0x00000000,0x00000000,0x00000000, // *
|
||||||
|
0x00000000,0x00000000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x00fffff0,0x00fffff0,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x00000000,0x00000000,0x00000000,0x00000000, // +
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0f000000,0x0f000000,0x00ff0000,0x00ff0000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ,
|
||||||
|
0x00000000,0x00000000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x00000000,0x00000000, // -
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0f000000,0x0f000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // .
|
||||||
|
0x00000000,0x00000000,0x0f000000,0x0f000000,0x00f00000,0x00f00000,0x000f0000,0x000f0000,0x0000f000,0x0000f000,0x00000f00,0x00000f00,0x000000f0,0x000000f0,0x00000000,0x00000000, // /
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00fffff0,0x00fffff0,0x0f0f000f,0x0f0f000f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f000f0f,0x0f000f0f,0x00fffff0,0x00fffff0,0x00000000,0x00000000, // 0
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0f0000f0,0x0f0000f0,0x0fffffff,0x0fffffff,0x0f000000,0x0f000000,0x00000000,0x00000000,0x00000000,0x00000000, // 1
|
||||||
|
0x00000000,0x00000000,0x0ff000f0,0x0ff000f0,0x0f0f000f,0x0f0f000f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f000ff0,0x0f000ff0,0x00000000,0x00000000, // 2
|
||||||
|
0x00000000,0x00000000,0x00f0000f,0x00f0000f,0x0f00000f,0x0f00000f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00ff0f,0x0f00ff0f,0x00ff00ff,0x00ff00ff,0x00000000,0x00000000, // 3
|
||||||
|
0x00000000,0x00000000,0x000f0000,0x000f0000,0x000ff000,0x000ff000,0x000f0f00,0x000f0f00,0x000f00f0,0x000f00f0,0x0fffffff,0x0fffffff,0x000f0000,0x000f0000,0x00000000,0x00000000, // 4
|
||||||
|
0x00000000,0x00000000,0x00f00fff,0x00f00fff,0x0f000f0f,0x0f000f0f,0x0f000f0f,0x0f000f0f,0x0f000f0f,0x0f000f0f,0x0f000f0f,0x0f000f0f,0x00fff00f,0x00fff00f,0x00000000,0x00000000, // 5
|
||||||
|
0x00000000,0x00000000,0x00ffff00,0x00ffff00,0x0f00f0f0,0x0f00f0f0,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x00ff000f,0x00ff000f,0x00000000,0x00000000, // 6
|
||||||
|
0x00000000,0x00000000,0x0000000f,0x0000000f,0x0000000f,0x0000000f,0x0fff000f,0x0fff000f,0x0000f00f,0x0000f00f,0x00000f0f,0x00000f0f,0x000000ff,0x000000ff,0x00000000,0x00000000, // 7
|
||||||
|
0x00000000,0x00000000,0x00ff0ff0,0x00ff0ff0,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x00ff0ff0,0x00ff0ff0,0x00000000,0x00000000, // 8
|
||||||
|
0x00000000,0x00000000,0x0f000ff0,0x0f000ff0,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x00f0f00f,0x00f0f00f,0x000ffff0,0x000ffff0,0x00000000,0x00000000, // 9
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x000f0f00,0x000f0f00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // :
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03000000,0x03000000,0x00ff0f00,0x00ff0f00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ;
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0000f000,0x0000f000,0x000f0f00,0x000f0f00,0x00f000f0,0x00f000f0,0x0f00000f,0x0f00000f,0x00000000,0x00000000,0x00000000,0x00000000, // <
|
||||||
|
0x00000000,0x00000000,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x000f0f00,0x00000000,0x00000000, // =
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0f00000f,0x0f00000f,0x00f000f0,0x00f000f0,0x000f0f00,0x000f0f00,0x0000f000,0x0000f000,0x00000000,0x00000000,0x00000000,0x00000000, // >
|
||||||
|
0x00000000,0x00000000,0x000000f0,0x000000f0,0x0000000f,0x0000000f,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ?
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00fffff0,0x00fffff0,0x0f00000f,0x0f00000f,0x0f00f00f,0x0f00f00f,0x0f0f0f0f,0x0f0f0f0f,0x0f0ff00f,0x0f0ff00f,0x0f00fff0,0x0f00fff0,0x00000000,0x00000000, // @
|
||||||
|
0x00000000,0x00000000,0x0fffff00,0x0fffff00,0x000f00f0,0x000f00f0,0x000f000f,0x000f000f,0x000f000f,0x000f000f,0x000f00f0,0x000f00f0,0x0fffff00,0x0fffff00,0x00000000,0x00000000, // A
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x00ff0ff0,0x00ff0ff0,0x00000000,0x00000000, // B
|
||||||
|
0x00000000,0x00000000,0x00fffff0,0x00fffff0,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x00f000f0,0x00f000f0,0x00000000,0x00000000, // C
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x00fffff0,0x00fffff0,0x00000000,0x00000000, // D
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00000f,0x0f00000f,0x00000000,0x00000000, // E
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000000f,0x0000000f,0x00000000,0x00000000, // F
|
||||||
|
0x00000000,0x00000000,0x00fffff0,0x00fffff0,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f03c00f,0x0f03c00f,0x0f03c00f,0x0f03c00f,0x0fffc00f,0x0fffc00f,0x00000000,0x00000000, // G
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x0fffffff,0x0fffffff,0x00000000,0x00000000, // H
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0f00000f,0x0f00000f,0x0fffffff,0x0fffffff,0x0f00000f,0x0f00000f,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // I
|
||||||
|
0x00000000,0x00000000,0x00f00000,0x00f00000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x00ffffff,0x00ffffff,0x00000000,0x00000000, // J
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x000f0f00,0x000f0f00,0x00f000f0,0x00f000f0,0x0f00000f,0x0f00000f,0x00000000,0x00000000, // K
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x00000000,0x00000000, // L
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x000000f0,0x000000f0,0x0000ff00,0x0000ff00,0x0000ff00,0x0000ff00,0x000000f0,0x000000f0,0x0fffffff,0x0fffffff,0x00000000,0x00000000, // M
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x000000f0,0x000000f0,0x0000ff00,0x0000ff00,0x000ff000,0x000ff000,0x00f00000,0x00f00000,0x0fffffff,0x0fffffff,0x00000000,0x00000000, // N
|
||||||
|
0x00000000,0x00000000,0x00fffff0,0x00fffff0,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x00fffff0,0x00fffff0,0x00000000,0x00000000, // O
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x00000ff0,0x00000ff0,0x00000000,0x00000000, // P
|
||||||
|
0x00000000,0x00000000,0x00fffff0,0x00fffff0,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f0f000f,0x0f0f000f,0x00f0000f,0x00f0000f,0x0f0ffff0,0x0f0ffff0,0x00000000,0x00000000, // Q
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x000ff00f,0x000ff00f,0x00f0f00f,0x00f0f00f,0x0f000ff0,0x0f000ff0,0x00000000,0x00000000, // R
|
||||||
|
0x00000000,0x00000000,0x00f00ff0,0x00f00ff0,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x00ff00f0,0x00ff00f0,0x00000000,0x00000000, // S
|
||||||
|
0x00000000,0x00000000,0x0000000f,0x0000000f,0x0000000f,0x0000000f,0x0fffffff,0x0fffffff,0x0000000f,0x0000000f,0x0000000f,0x0000000f,0x00000000,0x00000000,0x00000000,0x00000000, // T
|
||||||
|
0x00000000,0x00000000,0x00ffffff,0x00ffffff,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x00ffffff,0x00ffffff,0x00000000,0x00000000, // U
|
||||||
|
0x00000000,0x00000000,0x000fffff,0x000fffff,0x00f00000,0x00f00000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x00f00000,0x00f00000,0x000fffff,0x000fffff,0x00000000,0x00000000, // V
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x00f00000,0x00f00000,0x000ff000,0x000ff000,0x000ff000,0x000ff000,0x00f00000,0x00f00000,0x0fffffff,0x0fffffff,0x00000000,0x00000000, // W
|
||||||
|
0x00000000,0x00000000,0x0ff000ff,0x0ff000ff,0x000f0f00,0x000f0f00,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x000f0f00,0x000f0f00,0x0ff000ff,0x0ff000ff,0x00000000,0x00000000, // X
|
||||||
|
0x00000000,0x00000000,0x000000ff,0x000000ff,0x00000f00,0x00000f00,0x0ffff000,0x0ffff000,0x00000f00,0x00000f00,0x000000ff,0x000000ff,0x00000000,0x00000000,0x00000000,0x00000000, // Y
|
||||||
|
0x00000000,0x00000000,0x0ff0000f,0x0ff0000f,0x0f0f000f,0x0f0f000f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f00f00f,0x0f000f0f,0x0f000f0f,0x0f0000ff,0x0f0000ff,0x00000000,0x00000000, // Z
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0fffffff,0x0fffffff,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x00000000,0x00000000, // [
|
||||||
|
0x00000000,0x00000000,0x000000f0,0x000000f0,0x00000f00,0x00000f00,0x0000f000,0x0000f000,0x000f0000,0x000f0000,0x00f00000,0x00f00000,0x0f000000,0x0f000000,0x00000000,0x00000000, // <backslash>
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0fffffff,0x0fffffff,0x0fffffff,0x0fffffff,0x00000000,0x00000000, // ]
|
||||||
|
0x00000000,0x00000000,0x000f0000,0x000f0000,0x0000f000,0x0000f000,0x00000f00,0x00000f00,0x0000f000,0x0000f000,0x000f0000,0x000f0000,0x00000000,0x00000000,0x00000000,0x00000000, // ^
|
||||||
|
0x00000000,0x00000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x00000000,0x00000000, // _
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0000000f,0x0000000f,0x000000f0,0x000000f0,0x00000f00,0x00000f00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // `
|
||||||
|
0x00000000,0x00000000,0x00f00000,0x00f00000,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0ffff000,0x0ffff000,0x00000000,0x00000000, // a
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x00fff000,0x00fff000,0x00000000,0x00000000, // b
|
||||||
|
0x00000000,0x00000000,0x00fff000,0x00fff000,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x00000000,0x00000000, // c
|
||||||
|
0x00000000,0x00000000,0x00fff000,0x00fff000,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0fffffff,0x0fffffff,0x00000000,0x00000000, // d
|
||||||
|
0x00000000,0x00000000,0x00fff000,0x00fff000,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0ff000,0x0f0ff000,0x00000000,0x00000000, // e
|
||||||
|
0x00000000,0x00000000,0x0000f000,0x0000f000,0x0ffffff0,0x0ffffff0,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x0000f00f,0x000000f0,0x000000f0,0x00000000,0x00000000, // f
|
||||||
|
0x00000000,0x00000000,0x000ff000,0x000ff000,0xf0f00f00,0xf0f00f00,0xf0f00f00,0xf0f00f00,0xf0f00f00,0xf0f00f00,0xf0f00f00,0xf0f00f00,0x0ffff000,0x0ffff000,0x00000000,0x00000000, // g
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x0ffff000,0x0ffff000,0x00000000,0x00000000, // h
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0f000f00,0x0f000f00,0x0fffff0f,0x0fffff0f,0x0f000000,0x0f000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // i
|
||||||
|
0x00000000,0x00000000,0x0f000000,0x0f000000,0xf0000f00,0xf0000f00,0xf0000f00,0xf0000f00,0xf0000f00,0xf0000f00,0x0fffff0f,0x0fffff0f,0x00000000,0x00000000,0x00000000,0x00000000, // j
|
||||||
|
0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x000f0000,0x000f0000,0x000f0000,0x000f0000,0x000f0000,0x000f0000,0x00f0f000,0x00f0f000,0x0f000f00,0x0f000f00,0x00000000,0x00000000, // k
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0f00000f,0x0f00000f,0x0fffffff,0x0fffffff,0x0f000000,0x0f000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // l
|
||||||
|
0x00000000,0x00000000,0x0fffff00,0x0fffff00,0x00000f00,0x00000f00,0x00fff000,0x00fff000,0x00fff000,0x00fff000,0x00000f00,0x00000f00,0x0fffff00,0x0fffff00,0x00000000,0x00000000, // m
|
||||||
|
0x00000000,0x00000000,0x0fffff00,0x0fffff00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x0ffff000,0x0ffff000,0x00000000,0x00000000, // n
|
||||||
|
0x00000000,0x00000000,0x00fff000,0x00fff000,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x00fff000,0x00fff000,0x00000000,0x00000000, // o
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0xffffff00,0xffffff00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x000ff000,0x000ff000,0x00000000,0x00000000, // p
|
||||||
|
0x00000000,0x00000000,0x000ff000,0x000ff000,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0x00f00f00,0xffffff00,0xffffff00,0x00000000,0x00000000, // q
|
||||||
|
0x00000000,0x00000000,0x0fffff00,0x0fffff00,0x0000f000,0x0000f000,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00000000,0x00000000, // r
|
||||||
|
0x00000000,0x00000000,0x0f00f000,0x0f00f000,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x00f00f00,0x00f00f00,0x00000000,0x00000000, // s
|
||||||
|
0x00000000,0x00000000,0x00000f00,0x00000f00,0x00000f00,0x00000f00,0x00ffffff,0x00ffffff,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x00f00000,0x00f00000,0x00000000,0x00000000, // t
|
||||||
|
0x00000000,0x00000000,0x00ffff00,0x00ffff00,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x00f00000,0x00f00000,0x0fffff00,0x0fffff00,0x00000000,0x00000000, // u
|
||||||
|
0x00000000,0x00000000,0x000fff00,0x000fff00,0x00f00000,0x00f00000,0x0f000000,0x0f000000,0x0f000000,0x0f000000,0x00f00000,0x00f00000,0x000fff00,0x000fff00,0x00000000,0x00000000, // v
|
||||||
|
0x00000000,0x00000000,0x0fffff00,0x0fffff00,0x0f000000,0x0f000000,0x00ff0000,0x00ff0000,0x00ff0000,0x00ff0000,0x0f000000,0x0f000000,0x0fffff00,0x0fffff00,0x00000000,0x00000000, // w
|
||||||
|
0x00000000,0x00000000,0x0f000f00,0x0f000f00,0x00f0f000,0x00f0f000,0x000f0000,0x000f0000,0x000f0000,0x000f0000,0x00f0f000,0x00f0f000,0x0f000f00,0x0f000f00,0x00000000,0x00000000, // x
|
||||||
|
0x00000000,0x00000000,0x000fff00,0x000fff00,0xf0f00000,0xf0f00000,0xf0f00000,0xf0f00000,0xf0f00000,0xf0f00000,0xf0f00000,0xf0f00000,0x0fffff00,0x0fffff00,0x00000000,0x00000000, // y
|
||||||
|
0x00000000,0x00000000,0x0f000f00,0x0f000f00,0x0ff00f00,0x0ff00f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f0f0f00,0x0f00ff00,0x0f00ff00,0x0f000f00,0x0f000f00,0x00000000,0x00000000, // z
|
||||||
|
0x00000000,0x00000000,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x00fffff0,0x00fffff0,0x0fff0fff,0x0fff0fff,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x00000000,0x00000000, // {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0fffffff,0x0fffffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // |
|
||||||
|
0x00000000,0x00000000,0x0f00000f,0x0f00000f,0x0f00000f,0x0f00000f,0x0fff0fff,0x0fff0fff,0x00fffff0,0x00fffff0,0x0000f000,0x0000f000,0x0000f000,0x0000f000,0x00000000,0x00000000, // }
|
||||||
|
0x00000000,0x00000000,0x000ff000,0x000ff000,0x00000f00,0x00000f00,0x0000f000,0x0000f000,0x000f0000,0x000f0000,0x0000ff00,0x0000ff00,0x00000000,0x00000000,0x00000000,0x00000000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
211
src/devices/Oled/SSD1306/Font_Symbol_16X16.java
Normal file
211
src/devices/Oled/SSD1306/Font_Symbol_16X16.java
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
// Source : http://www.rinkydinkelectronics.com/images/fonts/various_symbols.png
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Symbol_16X16")
|
||||||
|
public class Font_Symbol_16X16 extends FontPack {
|
||||||
|
|
||||||
|
public final char kosong = 32;
|
||||||
|
public final char plus_minus = 33;
|
||||||
|
public final char nol_coret = 34;
|
||||||
|
public final char titik_tiga = 35;
|
||||||
|
public final char persen_gakjelas = 36;
|
||||||
|
public final char persen = 37;
|
||||||
|
public final char ordinal_indicator = 38;
|
||||||
|
public final char pangkat_dua = 39;
|
||||||
|
public final char pangkat_tiga = 40;
|
||||||
|
public final char tidak_samadengan = 41;
|
||||||
|
public final char pembagi_atasbawah = 42;
|
||||||
|
public final char pangkat_satu = 43;
|
||||||
|
public final char yen = 44;
|
||||||
|
public final char section = 45;
|
||||||
|
public final char titik = 46;
|
||||||
|
public final char cent = 47;
|
||||||
|
public final char nol_lingkaran = 48;
|
||||||
|
public final char satu_lingkaran = 49;
|
||||||
|
public final char dua_lingkaran = 50;
|
||||||
|
public final char tiga_lingkaran = 51;
|
||||||
|
public final char empat_lingkaran = 52;
|
||||||
|
public final char lima_lingkaran = 53;
|
||||||
|
public final char enam_lingkaran = 54;
|
||||||
|
public final char tujuh_lingkaran = 55;
|
||||||
|
public final char delapan_lingkaran = 56;
|
||||||
|
public final char sembilan_lingkaran = 57;
|
||||||
|
public final char kotak_isi = 58;
|
||||||
|
public final char lingkaran = 59;
|
||||||
|
public final char disket_save = 60;
|
||||||
|
public final char panah_segitiga_atas = 61;
|
||||||
|
public final char panah_segitiga_bawah = 62;
|
||||||
|
public final char panah_segitiga_kiri = 63;
|
||||||
|
public final char kotak_disilang = 64;
|
||||||
|
public final char kotak_dicentang = 65;
|
||||||
|
public final char surat = 66;
|
||||||
|
public final char kotak_kosong = 67;
|
||||||
|
public final char euro1 = 68;
|
||||||
|
public final char petir = 69;
|
||||||
|
public final char satu_per_empat = 70;
|
||||||
|
public final char satu_per_dua = 71;
|
||||||
|
public final char tiga_per_empat = 72;
|
||||||
|
public final char questionmark_kebalik = 73;
|
||||||
|
public final char n_tilde = 74;
|
||||||
|
public final char face_happy = 75;
|
||||||
|
public final char face_sad = 76;
|
||||||
|
public final char face_neutral = 77;
|
||||||
|
public final char pirate = 78;
|
||||||
|
public final char panah_atas = 79;
|
||||||
|
public final char panah_bawah = 80;
|
||||||
|
public final char panah_kiri = 81;
|
||||||
|
public final char panah_kanan = 82;
|
||||||
|
public final char centang = 83;
|
||||||
|
public final char panah_segitiga_kanan = 84;
|
||||||
|
public final char counter_clockwise = 85;
|
||||||
|
public final char clockwise = 86;
|
||||||
|
public final char heart = 87;
|
||||||
|
public final char copyright = 88;
|
||||||
|
public final char registered = 89;
|
||||||
|
public final char omega = 90;
|
||||||
|
public final char gakjelas1 = 91;
|
||||||
|
public final char infinity = 92;
|
||||||
|
public final char Nomor = 93;
|
||||||
|
public final char Caping = 94;
|
||||||
|
public final char Underscore = 95;
|
||||||
|
public final char derajat = 96;
|
||||||
|
public final char poundsterling = 97;
|
||||||
|
public final char micro = 98;
|
||||||
|
public final char euro2 = 99;
|
||||||
|
public final char media_back = 100;
|
||||||
|
public final char media_play = 101;
|
||||||
|
public final char media_up = 102;
|
||||||
|
public final char media_down = 103;
|
||||||
|
public final char media_rewind = 104;
|
||||||
|
public final char information = 105;
|
||||||
|
public final char media_fastforward = 106;
|
||||||
|
public final char media_previoustrack = 107;
|
||||||
|
public final char media_nexttrack = 108;
|
||||||
|
public final char media_pause = 109;
|
||||||
|
public final char media_stop = 110;
|
||||||
|
public final char media_record = 111;
|
||||||
|
public final char speaker = 112;
|
||||||
|
public final char melody = 113;
|
||||||
|
public final char loop = 114;
|
||||||
|
public final char incomingcall = 115;
|
||||||
|
public final char palu_kuncipas = 116;
|
||||||
|
public final char diamond = 117;
|
||||||
|
public final char bibir = 118;
|
||||||
|
public final char parkir = 119;
|
||||||
|
public final char icon_ngomong = 120;
|
||||||
|
public final char pesawat = 121;
|
||||||
|
public final char pensil = 122;
|
||||||
|
public final char salib = 123;
|
||||||
|
public final char arrowhead = 124;
|
||||||
|
public final char gunting = 125;
|
||||||
|
public final char bintang = 126;
|
||||||
|
|
||||||
|
public Font_Symbol_16X16() {
|
||||||
|
super("Font_Symbol_16X16", 16,16,16,16,32,126);
|
||||||
|
data = new int[] {
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // <space>
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2080,0x2080,0x2080,0x27f0,0x2080,0x2080,0x2080,0x0000,0x0000,0x0000,0x0000,0x0000, // !
|
||||||
|
0x0000,0x0000,0x47c0,0x6ff0,0x1ff8,0x1878,0x341c,0x331c,0x318c,0x384c,0x3c2c,0x1e18,0x1ff8,0x0ff6,0x03e2,0x0000, // "
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3800,0x3800,0x0000,0x0000,0x3800,0x3800,0x0000,0x0000,0x3800,0x3800,0x0000,0x0000, // #
|
||||||
|
0x0000,0x0070,0x2098,0x18c8,0x0670,0x0380,0x1ce0,0x2630,0x3208,0x1c00,0x0000,0x1c00,0x2600,0x3200,0x1c00,0x0000, // $
|
||||||
|
0x0000,0x00e0,0x01f0,0x2118,0x3108,0x1988,0x0ef8,0x0370,0x1d80,0x3ee0,0x2330,0x2118,0x3108,0x1f00,0x0e00,0x0000, // %
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0060,0x00f0,0x0098,0x0048,0x00e8,0x00f8,0x0098,0x0000,0x0000,0x0000,0x0000,0x0000, // &
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0180,0x0184,0x01c4,0x0144,0x0164,0x013c,0x0038,0x0000,0x0000,0x0000,0x0000, // '
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0100,0x0124,0x0134,0x0154,0x01dc,0x00cc,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // (
|
||||||
|
0x0000,0x0000,0x0080,0x0090,0x0c90,0x0f90,0x0ff8,0x01fc,0x009c,0x0090,0x0090,0x0010,0x0000,0x0000,0x0000,0x0000, // )
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0300,0x0300,0x0300,0x3300,0x3b00,0x1b60,0x0370,0x0330,0x0300,0x0300,0x0300,0x0000, // *
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0398,0x03f8,0x007c,0x0004,0x0000,0x0000,0x0000,0x0000, // +
|
||||||
|
0x0000,0x0000,0x0408,0x04b8,0x04f8,0x34f0,0x3fc0,0x3f00,0x0700,0x0780,0x04d0,0x04f8,0x04b8,0x0018,0x0000,0x0000, // ,
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3380,0x63c0,0x6778,0x6678,0x6eec,0x6ccc,0x3ccc,0x3bcc,0x038c,0x0000,0x0000,0x0000, // -
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0300,0x0780,0x0780,0x0300,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // .
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x03c0,0x07e0,0x0ff0,0x3c38,0x0fd8,0x0c3c,0x0418,0x0018,0x0000,0x0000, // /
|
||||||
|
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1c38,0x300c,0x37ec,0x37ec,0x300c,0x1c38,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 0
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1ff8,0x3ffc,0x3fdc,0x380c,0x380c,0x1ff8,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 1
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1ff8,0x39dc,0x38ec,0x3a6c,0x3b0c,0x1b98,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 2
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1ff8,0x37ec,0x376c,0x376c,0x308c,0x1898,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 3
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1cf8,0x3d3c,0x3ddc,0x300c,0x3dfc,0x1ff8,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 4
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1ff8,0x361c,0x36dc,0x30dc,0x39dc,0x1ff8,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 5
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1c38,0x301c,0x374c,0x376c,0x306c,0x18e8,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 6
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1ff8,0x3bdc,0x39dc,0x3edc,0x3f5c,0x1f98,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 7
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1998,0x372c,0x376c,0x366c,0x36ec,0x1998,0x1ff8,0x0ff0,0x03c0,0x0000,0x0000, // 8
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1ff8,0x1f18,0x360c,0x36ec,0x36ec,0x33ec,0x381c,0x1c38,0x1ff8,0x0ff0,0x03c0,0x0000, // 9
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x0000,0x0000, // :
|
||||||
|
0x0000,0x0000,0x03c0,0x0ff0,0x1c38,0x1818,0x300c,0x300c,0x300c,0x300c,0x1818,0x1c38,0x0ff0,0x03c0,0x0000,0x0000, // ;
|
||||||
|
0x0000,0x0000,0x1ffc,0x2004,0x21fc,0x3f04,0x2304,0x2304,0x3f04,0x3f04,0x3f04,0x21fc,0x2004,0x3ffc,0x0000,0x0000, // <
|
||||||
|
0x0000,0x0000,0x1000,0x1c00,0x1300,0x1080,0x1060,0x1018,0x1004,0x100c,0x1010,0x1060,0x1180,0x1200,0x1c00,0x1000, // =
|
||||||
|
0x0000,0x0000,0x0004,0x001c,0x0064,0x0084,0x0304,0x0c04,0x1004,0x1804,0x0404,0x0304,0x00c4,0x0024,0x001c,0x0004, // >
|
||||||
|
0x0000,0x0000,0x0000,0x0180,0x0280,0x0240,0x0420,0x0420,0x0810,0x1010,0x1008,0x2004,0x2004,0x7ffe,0x0000,0x0000, // ?
|
||||||
|
|
||||||
|
0x0000,0x0000,0x3ffc,0x3ffc,0x300c,0x3c0c,0x3eec,0x338c,0x33cc,0x36ec,0x366c,0x300c,0x3ffc,0x3ffc,0x0000,0x0000, // @
|
||||||
|
0x0000,0x0000,0x3ffc,0x3ffc,0x310c,0x318c,0x370c,0x370c,0x318c,0x30cc,0x302c,0x301c,0x3ffc,0x3ffc,0x0002,0x0000, // A
|
||||||
|
0x0000,0x0000,0x1fe0,0x1c20,0x1460,0x12a0,0x13a0,0x1120,0x1220,0x1120,0x1320,0x12a0,0x14a0,0x1c60,0x1fe0,0x0000, // B
|
||||||
|
0x0000,0x0000,0x3ffc,0x3ffc,0x300c,0x300c,0x300c,0x300c,0x300c,0x300c,0x300c,0x300c,0x3ffc,0x3ffc,0x0000,0x0000, // C
|
||||||
|
0x0000,0x0000,0x0040,0x0140,0x07e0,0x0d50,0x1148,0x3144,0x2144,0x2146,0x2146,0x2144,0x2144,0x100c,0x0008,0x0000, // D
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x7800,0x6100,0x39c0,0x2ce0,0x27b8,0x019c,0x008e,0x0046,0x0002,0x0000,0x0000,0x0000, // E
|
||||||
|
0x0000,0x0000,0x1188,0x19fc,0x063c,0x0304,0x01c0,0x0060,0x0638,0x078c,0x05c4,0x1cc0,0x1e40,0x0600,0x0000,0x0000, // F
|
||||||
|
0x0000,0x0000,0x00c8,0x08f8,0x0c3c,0x0604,0x0180,0x00c0,0x0860,0x0c58,0x0c4c,0x0e44,0x0a40,0x0bc0,0x0180,0x0000, // G
|
||||||
|
0x0200,0x0248,0x0268,0x0268,0x23b8,0x3198,0x0c00,0x0600,0x0180,0x0cc0,0x0f70,0x0b98,0x3988,0x3c80,0x0c00,0x0000, // H
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1c00,0x3e00,0x7e00,0x6700,0x63b0,0x61b8,0x6038,0x3000,0x0000,0x0000,0x0000,0x0000, // I
|
||||||
|
0x0000,0x0000,0x1800,0x1fc0,0x1fe0,0x07e0,0x0188,0x00c4,0x1e44,0x1fe8,0x1fe8,0x11cc,0x0000,0x0000,0x0000,0x0000, // J
|
||||||
|
0x0000,0x03e0,0x0c18,0x180c,0x1334,0x2432,0x2802,0x2802,0x2802,0x2432,0x1334,0x180c,0x0c18,0x03e0,0x0000,0x0000, // K
|
||||||
|
0x0000,0x0000,0x03e0,0x0c18,0x180c,0x1634,0x2132,0x2082,0x2082,0x2082,0x2132,0x1634,0x180c,0x0c18,0x03e0,0x0000, // L
|
||||||
|
0x0000,0x03c0,0x0c30,0x1818,0x1208,0x2264,0x2264,0x2204,0x2264,0x2264,0x1208,0x1818,0x0c30,0x03c0,0x0000,0x0000, // M
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x2600,0x2600,0x3438,0x145c,0x09bc,0x09bc,0x145c,0x3438,0x2600,0x0000,0x0000,0x0000, // N
|
||||||
|
0x0000,0x0000,0x0380,0x01c0,0x00e0,0x00f0,0x0078,0xfffc,0xfffe,0xfffc,0x0078,0x00f0,0x00e0,0x01c0,0x0380,0x0000, // O
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0380,0x0700,0x0e00,0x1e00,0x3c00,0x7ffe,0xfffe,0x7ffe,0x3c00,0x1e00,0x0e00,0x0700,0x0380,0x0000, // P
|
||||||
|
0x0080,0x01c0,0x03e0,0x07f0,0x0ff8,0x1ffc,0x3dde,0x31c6,0x21c2,0x01c0,0x01c0,0x01c0,0x01c0,0x01c0,0x01c0,0x0000, // Q
|
||||||
|
0x0000,0x01c0,0x01c0,0x01c0,0x01c0,0x01c0,0x01c0,0x21c2,0x31c6,0x3dde,0x1ffc,0x0ff8,0x07f0,0x03e0,0x01c0,0x0080, // R
|
||||||
|
0x0000,0x0000,0x0080,0x0180,0x0f00,0x0600,0x0380,0x00c0,0x0060,0x0010,0x0008,0x0004,0x0002,0x0000,0x0000,0x0000, // S
|
||||||
|
0x0000,0x0000,0x7ffe,0x2004,0x2004,0x1008,0x1010,0x0810,0x0420,0x0420,0x0240,0x0280,0x0180,0x0000,0x0000,0x0000, // T
|
||||||
|
0x0000,0x0000,0x03c0,0x0c30,0x1000,0x1000,0x2000,0x2000,0x2000,0x2000,0x103c,0x101c,0x0c3c,0x03e0,0x0000,0x0000, // U
|
||||||
|
0x0000,0x0000,0x03e0,0x0c3c,0x101c,0x103c,0x2000,0x2000,0x2000,0x2000,0x1000,0x1000,0x0c30,0x03c0,0x0000,0x0000, // V
|
||||||
|
0x0000,0x0000,0x00f8,0x030c,0x0404,0x0804,0x3008,0x6030,0x1008,0x0804,0x0404,0x030c,0x00f8,0x0000,0x0000,0x0000, // W
|
||||||
|
0x0000,0x0000,0x07e0,0x0810,0x1008,0x23e4,0x2414,0x2414,0x2414,0x2414,0x2414,0x2224,0x1008,0x0810,0x07e0,0x0000, // X
|
||||||
|
0x0000,0x0000,0x07e0,0x0810,0x1008,0x27f4,0x2094,0x2094,0x2194,0x2294,0x2464,0x1008,0x0810,0x07e0,0x0000,0x0000, // Y
|
||||||
|
0x0000,0x0000,0x23e0,0x2c10,0x3008,0x3004,0x2004,0x0004,0x2004,0x3004,0x3008,0x2c10,0x23e0,0x0000,0x0000,0x0000, // Z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0400,0x3ff0,0x2088,0x3078,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // [
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0380,0x0440,0x0440,0x0280,0x0380,0x0440,0x0440,0x0440,0x0380,0x0000,0x0000,0x0000, // <backslash>
|
||||||
|
0x0000,0x3ff8,0x0020,0x0040,0x0180,0x0200,0x0400,0x0800,0x3ff8,0x0000,0x13c0,0x1420,0x1420,0x1420,0x13c0,0x0000, // ]
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0010,0x0008,0x0006,0x0003,0x0006,0x0008,0x0010,0x0000,0x0000,0x0000,0x0000, // ^
|
||||||
|
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, // _
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0038,0x007c,0x004c,0x0044,0x0064,0x007c,0x0038,0x0000, // `
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0800,0x1e00,0x1fe0,0x1bf0,0x19f8,0x199c,0x198c,0x198c,0x198c,0x180c,0x0018,0x0000, // a
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x7000,0x7f80,0x07f0,0x0430,0x0600,0x0380,0x07f0,0x0430,0x0300,0x0000,0x0000,0x0000, // b
|
||||||
|
0x0000,0x0000,0x0000,0x0160,0x07f8,0x0f7c,0x1966,0x1962,0x1162,0x1162,0x1162,0x1866,0x0c0e,0x0000,0x0000,0x0000, // c
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0180,0x03c0,0x07e0,0x0ff0,0x1ff8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // d
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1ff8,0x0ff0,0x07e0,0x03c0,0x0180,0x0000,0x0000,0x0000,0x0000,0x0000, // e
|
||||||
|
0x0000,0x0000,0x0100,0x0180,0x01c0,0x01e0,0x01f0,0x01f0,0x01e0,0x01c0,0x0180,0x0100,0x0000,0x0000,0x0000,0x0000, // f
|
||||||
|
0x0000,0x0000,0x0020,0x0060,0x00e0,0x01e0,0x03e0,0x03e0,0x01e0,0x00e0,0x0060,0x0020,0x0000,0x0000,0x0000,0x0000, // g
|
||||||
|
0x0000,0x0000,0x0300,0x0780,0x0fc0,0x1fe0,0x3ff0,0x0300,0x0780,0x0fc0,0x1fe0,0x3ff0,0x0000,0x0000,0x0000,0x0000, // h
|
||||||
|
0x0000,0x7ffe,0x4002,0x4002,0x4002,0x4092,0x5fbe,0x5fbe,0x5fbe,0x5f9a,0x4002,0x4002,0x4002,0x4002,0x3ffc,0x0000, // i
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff8,0x0ff0,0x07e0,0x03c0,0x0180,0x1ff8,0x0ff0,0x07e0,0x03c0,0x0180,0x0000,0x0000, // j
|
||||||
|
0x0000,0x0000,0x3ff0,0x3ff0,0x0300,0x0780,0x0fc0,0x1fe0,0x3ff0,0x0300,0x0780,0x0fc0,0x1fe0,0x3ff0,0x0000,0x0000, // k
|
||||||
|
0x0000,0x0000,0x3ff0,0x1fe0,0x0fc0,0x0780,0x0300,0x3ff0,0x1fe0,0x0fc0,0x0780,0x0300,0x3ff0,0x3ff0,0x0000,0x0000, // l
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ff8,0x3ff8,0x0000,0x0000,0x3ff8,0x3ff8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // m
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x0000,0x0000, // n
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x03c0,0x0ff0,0x0ff0,0x1ff8,0x1ff8,0x1ff8,0x1ff8,0x0ff0,0x0ff0,0x03c0,0x0000,0x0000, // o
|
||||||
|
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x3ffe,0x1ffc,0x0ff8,0x07f0,0x03e0,0x03e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // p
|
||||||
|
0x0000,0x0000,0x3000,0x3800,0x3800,0x3800,0x1fe0,0x0070,0x0630,0x0738,0x071c,0x070c,0x03fe,0x0000,0x0000,0x0000, // q
|
||||||
|
0x0000,0x0000,0x03e0,0x0ffc,0x1e1c,0x081e,0x0000,0x0000,0x0000,0x1e04,0x0e1e,0x0ffc,0x01f0,0x0000,0x0000,0x0000, // r
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1ff8,0x3c3c,0x381c,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // s
|
||||||
|
0x0040,0x00e0,0x1078,0x481c,0x582c,0x3c76,0x0ee2,0x07c0,0x0380,0x07e0,0x0ef8,0x1c74,0x3834,0x7020,0x2010,0x0000, // t
|
||||||
|
0x00c0,0x01e0,0x03f0,0x07f8,0x0ffc,0x1ffe,0x3fff,0x3fff,0x1ffe,0x0ffc,0x07f8,0x03f0,0x01e0,0x00c0,0x0000,0x0000, // u
|
||||||
|
0x0000,0x0000,0x0080,0x0180,0x03c0,0x03e0,0x06e0,0x06c0,0x06c0,0x06e0,0x06e0,0x03e0,0x03c0,0x0180,0x0080,0x0000, // v
|
||||||
|
0x0000,0x0000,0x07c0,0x1830,0x3018,0x2008,0x5fe4,0x4224,0x4224,0x4224,0x41c4,0x2008,0x3018,0x1830,0x07c0,0x0000, // w
|
||||||
|
0x0000,0x0000,0x21c0,0x3bf0,0x3ff0,0x1ff0,0x0ff8,0x0ff8,0x0ff8,0x0ff8,0x0ff8,0x0ff8,0x0ff8,0x07f8,0x07f0,0x07e0, // x
|
||||||
|
0x0080,0x0000,0x03e0,0x01c0,0x0080,0x0080,0x2082,0x388c,0x1ff8,0x17f8,0x07f0,0x0080,0x0080,0x0080,0x0080,0x0080, // y
|
||||||
|
0x0070,0x008c,0x01b4,0x02b4,0x02ec,0x0518,0x0528,0x0a50,0x0a60,0x14a0,0x1d40,0x1340,0x1180,0x1600,0x1800,0x0000, // z
|
||||||
|
0x0000,0x0000,0x0000,0x0000,0x0030,0x0030,0x0030,0x1ffe,0x1ffe,0x0030,0x0030,0x0030,0x0000,0x0000,0x0000,0x0000, // {
|
||||||
|
0x1008,0x1818,0x1430,0x1270,0x09f0,0x08e0,0x04e0,0x04e0,0x04c0,0x02c0,0x02c0,0x0280,0x0180,0x0180,0x0100,0x0000, // |
|
||||||
|
0x0000,0x0e38,0x0a28,0x0e38,0x0220,0x0140,0x01c0,0x01c0,0x01c0,0x0360,0x0360,0x0220,0x0630,0x0630,0x0410,0x0410, // }
|
||||||
|
0x0000,0x0000,0x0100,0x0280,0x0280,0x02c0,0x06e0,0x0e70,0x781e,0x301c,0x0e70,0x06e0,0x02c0,0x0280,0x0180,0x0100, // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
210
src/devices/Oled/SSD1306/Font_Symbol_16X32.java
Normal file
210
src/devices/Oled/SSD1306/Font_Symbol_16X32.java
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Symbol_16X32")
|
||||||
|
public class Font_Symbol_16X32 extends FontPack {
|
||||||
|
|
||||||
|
public final char kosong = 32;
|
||||||
|
public final char plus_minus = 33;
|
||||||
|
public final char nol_coret = 34;
|
||||||
|
public final char titik_tiga = 35;
|
||||||
|
public final char persen_gakjelas = 36;
|
||||||
|
public final char persen = 37;
|
||||||
|
public final char ordinal_indicator = 38;
|
||||||
|
public final char pangkat_dua = 39;
|
||||||
|
public final char pangkat_tiga = 40;
|
||||||
|
public final char tidak_samadengan = 41;
|
||||||
|
public final char pembagi_atasbawah = 42;
|
||||||
|
public final char akar = 43;
|
||||||
|
public final char yen = 44;
|
||||||
|
public final char section = 45;
|
||||||
|
public final char titik = 46;
|
||||||
|
public final char cent = 47;
|
||||||
|
public final char nol_lingkaran = 48;
|
||||||
|
public final char satu_lingkaran = 49;
|
||||||
|
public final char dua_lingkaran = 50;
|
||||||
|
public final char tiga_lingkaran = 51;
|
||||||
|
public final char empat_lingkaran = 52;
|
||||||
|
public final char lima_lingkaran = 53;
|
||||||
|
public final char enam_lingkaran = 54;
|
||||||
|
public final char tujuh_lingkaran = 55;
|
||||||
|
public final char delapan_lingkaran = 56;
|
||||||
|
public final char sembilan_lingkaran = 57;
|
||||||
|
public final char backspace = 58;
|
||||||
|
public final char lingkaran = 59;
|
||||||
|
public final char disket_save = 60;
|
||||||
|
public final char panah_segitiga_atas = 61;
|
||||||
|
public final char panah_segitiga_bawah = 62;
|
||||||
|
public final char panah_segitiga_kiri = 63;
|
||||||
|
public final char panah_segitiga_kanan = 64;
|
||||||
|
public final char kotak_disilang = 65;
|
||||||
|
public final char kotak_dicentang = 66;
|
||||||
|
public final char surat = 67;
|
||||||
|
public final char kotak = 68;
|
||||||
|
public final char euro = 69;
|
||||||
|
public final char petir = 70;
|
||||||
|
public final char satu_per_empat = 71;
|
||||||
|
public final char satu_per_dua = 72;
|
||||||
|
public final char tiga_per_empat = 73;
|
||||||
|
public final char questionmark_kebalik = 74;
|
||||||
|
public final char n_tilde = 75;
|
||||||
|
public final char face_happy = 76;
|
||||||
|
public final char face_sad = 77;
|
||||||
|
public final char face_neutral = 78;
|
||||||
|
public final char pirate = 79;
|
||||||
|
public final char panah_bawah = 80;
|
||||||
|
public final char panah_atas = 81;
|
||||||
|
public final char panah_kiri = 82;
|
||||||
|
public final char panah_kanan = 83;
|
||||||
|
public final char centang = 84;
|
||||||
|
public final char counter_clockwise = 85;
|
||||||
|
public final char clockwise = 86;
|
||||||
|
public final char heart = 87;
|
||||||
|
public final char copyright = 88;
|
||||||
|
public final char registered = 89;
|
||||||
|
public final char omega = 90;
|
||||||
|
public final char information = 91;
|
||||||
|
public final char derajat = 92;
|
||||||
|
public final char poundsterling = 93;
|
||||||
|
public final char micro = 94;
|
||||||
|
public final char shuffle = 95;
|
||||||
|
public final char media_eject = 96;
|
||||||
|
public final char media_reverse_play = 97;
|
||||||
|
public final char media_play = 98;
|
||||||
|
public final char media_up = 99;
|
||||||
|
public final char media_down = 100;
|
||||||
|
public final char media_rewind = 101;
|
||||||
|
public final char media_fastforward = 102;
|
||||||
|
public final char media_previoustrack = 103;
|
||||||
|
public final char media_nexttrack = 104;
|
||||||
|
public final char media_pause = 105;
|
||||||
|
public final char media_stop = 106;
|
||||||
|
public final char media_record = 107;
|
||||||
|
public final char powerbutton = 108;
|
||||||
|
public final char speaker_mute = 109;
|
||||||
|
public final char speaker_volumedown = 110;
|
||||||
|
public final char speaker_volumeup = 111;
|
||||||
|
public final char melody = 112;
|
||||||
|
public final char media_loop = 113;
|
||||||
|
public final char telephone = 114;
|
||||||
|
public final char sun = 115;
|
||||||
|
public final char diamond = 116;
|
||||||
|
public final char airplane = 117;
|
||||||
|
public final char salib = 118;
|
||||||
|
public final char gunting = 119;
|
||||||
|
public final char silang = 120;
|
||||||
|
public final char bintang = 121;
|
||||||
|
public final char timer = 122;
|
||||||
|
public final char zoom_out = 123;
|
||||||
|
public final char zoom_in = 124;
|
||||||
|
public final char archieve = 125;
|
||||||
|
public final char plus = 126;
|
||||||
|
|
||||||
|
public Font_Symbol_16X32() {
|
||||||
|
super("Font_Symbol_16X32", 16, 32, 16, 32, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <space>
|
||||||
|
0x00000000,0x00000000,0x00183000,0x00183000,0x00183000,0x00183000,0x00183000,0x001bff00,0x001bff00,0x00183000,0x00183000,0x00183000,0x00183000,0x00183000,0x00000000,0x00000000, // !
|
||||||
|
0x00000000,0x00000000,0x0019f000,0x000ffc00,0x000e0600,0x001b0200,0x00198300,0x0010c100,0x00106100,0x00183300,0x000c1b00,0x000e0e00,0x0007fe00,0x0001f300,0x00000000,0x00000000, // "
|
||||||
|
0x00000000,0x00000000,0x001c0000,0x001c0000,0x00000000,0x00000000,0x00000000,0x001c0000,0x001c0000,0x00000000,0x00000000,0x00000000,0x001c0000,0x001c0000,0x00000000,0x00000000, // #
|
||||||
|
0x00000000,0x00000000,0x00003f00,0x00182100,0x000f3f00,0x0003c000,0x00007000,0x001f9e00,0x00108300,0x001f8000,0x00000000,0x001f8000,0x00108000,0x001f8000,0x00000000,0x00000000, // $
|
||||||
|
0x00000000,0x00000000,0x00001e00,0x00002100,0x00182100,0x000e1e00,0x00038000,0x0000e000,0x00007800,0x000f0c00,0x00108700,0x00108100,0x000f0000,0x00000000,0x00000000,0x00000000, // %
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00003200,0x00004900,0x00004900,0x00002900,0x00007e00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // &
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00007818,0x00007c1c,0x00006e0e,0x00006706,0x00006386,0x000061ce,0x000060fc,0x00006078,0x00006030,0x00000000,0x00000000,0x00000000, // '
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00001818,0x0000381c,0x0000700e,0x00006006,0x00006186,0x00006186,0x0000718e,0x00003ffc,0x00001e78,0x00000000,0x00000000,0x00000000, // (
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00031800,0x00031800,0x00031800,0x00031800,0x001fff00,0x001fff00,0x00031800,0x00031800,0x00031800,0x00031800,0x00000000,0x00000000,0x00000000, // )
|
||||||
|
0x00000000,0x00000000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x001cce00,0x001cce00,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x00000000,0x00000000, // *
|
||||||
|
0x00000000,0x00000000,0x00002000,0x00002000,0x0000e000,0x000f0000,0x00300000,0x000f0000,0x0000e000,0x00001c00,0x00000300,0x00000100,0x00000100,0x00000100,0x00000000,0x00000000, // +
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00009100,0x00009700,0x00009c00,0x0000f800,0x003fd000,0x003fd000,0x0000f800,0x00009c00,0x00009700,0x00009100,0x00000000,0x00000000,0x00000000, // ,
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00007000,0x0039fe00,0x0073bf00,0x00671980,0x006608c0,0x006418c0,0x003e39c0,0x001f7380,0x0003e000,0x00000000,0x00000000,0x00000000,0x00000000, // -
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0001c000,0x0003e000,0x0007f000,0x0007f000,0x0007f000,0x0003e000,0x0001c000,0x00000000,0x00000000,0x00000000,0x00000000, // .
|
||||||
|
0x00000000,0x00000000,0x0001f000,0x0003f800,0x00071c00,0x000c0600,0x00180300,0x00180300,0x007fffc0,0x007fffc0,0x00180300,0x00180300,0x001c0700,0x000c0600,0x00000000,0x00000000, // /
|
||||||
|
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007c1f00,0x00f00780,0x00e7f380,0x00cff980,0x00cff980,0x00e7f380,0x00f00780,0x007c1f00,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 0
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00f3cf80,0x00f3c780,0x00f00380,0x00f00380,0x00f00380,0x00f3ff80,0x0073ff00,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 1
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x0073e700,0x00f1e380,0x00f0f380,0x00f07380,0x00f23380,0x00f30380,0x00f38780,0x0073cf00,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 2
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00f9e780,0x00f1e380,0x00f3f380,0x00f33380,0x00f33380,0x00f80780,0x007ccf00,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 3
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00fc0380,0x00fc0380,0x00fcff80,0x00fcff80,0x00f01f80,0x00f01f80,0x007cff00,0x003cfe00,0x001ffc00,0x0007f000,0x00000000, // 4
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00f38380,0x00f38380,0x00f3b380,0x00f33380,0x00f33380,0x00f87380,0x00787300,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 5
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00fc0780,0x00f83380,0x00f7bb80,0x00f7bb80,0x00f7bb80,0x00f87380,0x007cf700,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 6
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00f1f380,0x00f0f380,0x00fe7380,0x00ff3380,0x00ff9380,0x00ffc380,0x007fe300,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 7
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00f8c780,0x00f00380,0x00f33380,0x00f33380,0x00f33380,0x00f00380,0x0078c700,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 8
|
||||||
|
0x00000000,0x0007f000,0x001ffc00,0x003ffe00,0x007fff00,0x00f9c780,0x00f18380,0x00f3b380,0x00f3b380,0x00f3b380,0x00f00380,0x00780700,0x003ffe00,0x001ffc00,0x0007f000,0x00000000, // 9
|
||||||
|
0x00000000,0x00006000,0x0000f000,0x0001f800,0x0003fc00,0x00076e00,0x000e6700,0x000c6300,0x00006000,0x00006000,0x00006000,0x00006000,0x00006000,0x00006000,0x00006000,0x00000000, // :
|
||||||
|
0x00000000,0x00000000,0x0003f000,0x0007f800,0x000e1c00,0x001c0e00,0x00180600,0x00180600,0x00180600,0x00180600,0x001c0e00,0x000e1c00,0x0007f800,0x0003f000,0x00000000,0x00000000, // ;
|
||||||
|
0x00000000,0x001ffe00,0x00100200,0x0010fe00,0x001ef600,0x0012f600,0x001ef600,0x001ef600,0x001ef600,0x001ef600,0x001ef600,0x0010fe00,0x00100200,0x001ffe00,0x00000000,0x00000000, // <
|
||||||
|
0x00000000,0x00000000,0x001c0000,0x001f0000,0x001bc000,0x0018f000,0x00183c00,0x00180e00,0x00183c00,0x0018f000,0x001bc000,0x001f0000,0x001c0000,0x00000000,0x00000000,0x00000000, // =
|
||||||
|
0x00000000,0x00000000,0x00000e00,0x00003e00,0x0000f600,0x0003c600,0x000f0600,0x001c0600,0x000f0600,0x0003c600,0x0000f600,0x00003e00,0x00000e00,0x00000000,0x00000000,0x00000000, // >
|
||||||
|
0x00000000,0x00000000,0x00004000,0x0000e000,0x0000e000,0x0001b000,0x0001b000,0x00031800,0x00031800,0x00060c00,0x00060c00,0x000c0600,0x000ffe00,0x000ffe00,0x00000000,0x00000000, // ?
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x001fff00,0x000ffe00,0x000c0600,0x00060c00,0x00060c00,0x00031800,0x00031800,0x0001b000,0x0001b000,0x0000e000,0x0000e000,0x00004000,0x00000000,0x00000000, // @
|
||||||
|
0x00000000,0x00000000,0x001ffe00,0x00100200,0x00161a00,0x00173a00,0x0011e200,0x0010c200,0x0010c200,0x0011e200,0x00173a00,0x00161a00,0x00100200,0x001ffe00,0x00000000,0x00000000, // A
|
||||||
|
0x00000000,0x00000000,0x001ffe00,0x00100200,0x00110200,0x00130200,0x00160200,0x00170200,0x0011c200,0x00106200,0x00103200,0x00100a00,0x00100200,0x001ffe00,0x00000000,0x00000000, // B
|
||||||
|
0x00000000,0x0007fc00,0x00060c00,0x00071c00,0x0005b400,0x0004f400,0x0004f400,0x0005f400,0x0005f400,0x0004f400,0x0004f400,0x0005b400,0x00071c00,0x00060c00,0x0007fc00,0x00000000, // C
|
||||||
|
0x00000000,0x00000000,0x00000000,0x000ffc00,0x000ffc00,0x000c0c00,0x000c0c00,0x000c0c00,0x000c0c00,0x000c0c00,0x000c0c00,0x000ffc00,0x000ffc00,0x00000000,0x00000000,0x00000000, // D
|
||||||
|
0x00000000,0x00000000,0x00024000,0x00024000,0x0007e000,0x001ff800,0x00324c00,0x00624600,0x00c24300,0x00c24300,0x00c24300,0x00c04300,0x00400200,0x00600600,0x00000000,0x00000000, // E
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00200000,0x00108000,0x0018c000,0x000ce000,0x0006e000,0x0003b000,0x00039800,0x00010800,0x00000400,0x00000000,0x00000000,0x00000000,0x00000000, // F
|
||||||
|
0x00000000,0x00000000,0x00008200,0x0010fe00,0x001c8000,0x00060000,0x00038000,0x0000e000,0x00003000,0x000e1c00,0x000b0600,0x00088200,0x003fc000,0x00080000,0x00000000,0x00000000, // G
|
||||||
|
0x00000000,0x00000000,0x00008200,0x0010fe00,0x001c8000,0x00060000,0x00038000,0x0000e000,0x00003000,0x00319c00,0x00388600,0x002c8200,0x00278000,0x00230000,0x00000000,0x00000000, // H
|
||||||
|
0x00000000,0x00000000,0x00002200,0x00004100,0x00104900,0x001c4900,0x00063600,0x00038000,0x0000e000,0x000e3000,0x000b1c00,0x00088600,0x003fc200,0x00080000,0x00000000,0x00000000, // I
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000c0000,0x001e0000,0x00330000,0x0021ec00,0x0020ec00,0x00300000,0x00180000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // J
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x003fec00,0x003fe600,0x0000c300,0x00006300,0x00002600,0x00006c00,0x003fcc00,0x003f8600,0x00000000,0x00000000,0x00000000,0x00000000, // K
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x00081000,0x00100800,0x00266400,0x00286400,0x00280400,0x00280400,0x00286400,0x00266400,0x00100800,0x00081000,0x0007e000,0x00000000,0x00000000, // L
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x00081000,0x00100800,0x00266400,0x00216400,0x00210400,0x00210400,0x00216400,0x00266400,0x00100800,0x00081000,0x0007e000,0x00000000,0x00000000, // M
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x00081000,0x00100800,0x00226400,0x00226400,0x00220400,0x00220400,0x00226400,0x00226400,0x00100800,0x00081000,0x0007e000,0x00000000,0x00000000, // N
|
||||||
|
0x00000000,0x03838000,0x03838000,0x01831fc0,0x00c63fe0,0x006cf9e0,0x003df9e0,0x0019bfe0,0x0019bfe0,0x003df9e0,0x006cf9e0,0x00c63fe0,0x01831fc0,0x03838000,0x03838000,0x00000000, // O
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00030000,0x00070000,0x000f0000,0x001f0000,0x003fff00,0x003fff00,0x001f0000,0x000f0000,0x00070000,0x00030000,0x00000000,0x00000000,0x00000000, // P
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00003000,0x00003800,0x00003c00,0x00003e00,0x003fff00,0x003fff00,0x00003e00,0x00003c00,0x00003800,0x00003000,0x00000000,0x00000000,0x00000000, // Q
|
||||||
|
0x00000000,0x0000c000,0x0001e000,0x0003f000,0x0007f800,0x000ffc00,0x000ffc00,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x00000000, // R
|
||||||
|
0x00000000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x0000c000,0x000ffc00,0x000ffc00,0x0007f800,0x0003f000,0x0001e000,0x0000c000,0x00000000, // S
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00010000,0x00030000,0x00060000,0x00070000,0x0001c000,0x00006000,0x00003000,0x00000800,0x00000000,0x00000000,0x00000000,0x00000000, // T
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0003e000,0x0007f000,0x000e1800,0x000c0c00,0x000c0c00,0x003f0c00,0x001e0c00,0x000c1800,0x0000f000,0x0000e000,0x00000000,0x00000000,0x00000000, // U
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0007c000,0x000fe000,0x00187000,0x00303000,0x00303000,0x0030fc00,0x00307800,0x00183000,0x000f0000,0x00070000,0x00000000,0x00000000,0x00000000, // V
|
||||||
|
0x00000000,0x00000000,0x0000e000,0x0001f000,0x0003f800,0x0007f800,0x000ff800,0x001ff000,0x003fe000,0x001ff000,0x000ff800,0x0007f800,0x0003f800,0x0001f000,0x0000e000,0x00000000, // W
|
||||||
|
0x00000000,0x0001e000,0x00061800,0x00180600,0x0021e100,0x0027f900,0x00461880,0x004c0c80,0x004c0c80,0x004c0c80,0x004e1c80,0x00261900,0x00200100,0x00180600,0x00061800,0x0001e000, // X
|
||||||
|
0x00000000,0x0001e000,0x00061800,0x00180600,0x00200100,0x00200100,0x004ffc80,0x004ffe80,0x0040c680,0x0040c680,0x004ffc80,0x002fb900,0x00200100,0x00180600,0x00061800,0x0001e000, // Y
|
||||||
|
0x00000000,0x18fe0000,0x1bff8000,0x1f83c000,0x1e01e000,0x1c007000,0x00003000,0x00003000,0x00003000,0x00003000,0x1c007000,0x1e01e000,0x1f83c000,0x1bff8000,0x18fe0000,0x00000000, // Z
|
||||||
|
0x00000000,0x00ffffc0,0x00800040,0x00800040,0x00b00040,0x00b06640,0x00bfef40,0x00bfef40,0x00bfef40,0x00bfe640,0x00b00040,0x00b00040,0x00800040,0x00800040,0x007fff80,0x00000000, // [
|
||||||
|
0x00000000,0x00000000,0x00000000,0x000003e0,0x000007f0,0x00000ff8,0x00001e3c,0x00001c1c,0x00001c1c,0x00001c1c,0x00001e3c,0x00000ff8,0x000007f0,0x000003e0,0x00000000,0x00000000, // <backslash>
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00c30000,0x00c30000,0x00e37c00,0x00fffe00,0x00df8700,0x00c30300,0x00c30300,0x00c30300,0x00c30700,0x00c00600,0x00c00000,0x00000000,0x00000000,0x00000000, // ]
|
||||||
|
0x00000000,0x00000000,0x00000000,0x18000000,0x1fff8000,0x0fff8000,0x00c00000,0x01800000,0x01800000,0x01800000,0x00c00000,0x00ff8000,0x01ff8000,0x01800000,0x00000000,0x00000000, // ^
|
||||||
|
0x00000000,0x00183000,0x00183000,0x001c3000,0x000e7000,0x00076000,0x00038000,0x0001c000,0x0006e000,0x000e7000,0x001c3000,0x00183000,0x007efc00,0x003c7800,0x00183000,0x00000000, // _
|
||||||
|
|
||||||
|
0x00000000,0x001a0000,0x001b0000,0x001b8000,0x001bc000,0x001be000,0x001bf000,0x001bf800,0x001bf800,0x001bf000,0x001be000,0x001bc000,0x001b8000,0x001b0000,0x001a0000,0x00000000, // `
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00010000,0x00038000,0x0007c000,0x000fe000,0x001ff000,0x003ff800,0x007ffc00,0x00000000,0x00000000,0x00000000,0x00000000, // a
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x007ffc00,0x003ff800,0x001ff000,0x000fe000,0x0007c000,0x00038000,0x00010000,0x00000000,0x00000000,0x00000000,0x00000000, // b
|
||||||
|
0x00000000,0x00000000,0x00080000,0x000c0000,0x000e0000,0x000f0000,0x000f8000,0x000fc000,0x000fe000,0x000fc000,0x000f8000,0x000f0000,0x000e0000,0x000c0000,0x00080000,0x00000000, // c
|
||||||
|
0x00000000,0x00000000,0x00002000,0x00006000,0x0000e000,0x0001e000,0x0003e000,0x0007e000,0x000fe000,0x0007e000,0x0003e000,0x0001e000,0x0000e000,0x00006000,0x00002000,0x00000000, // d
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00030000,0x00078000,0x000fc000,0x001fe000,0x003ff000,0x00030000,0x00078000,0x000fc000,0x001fe000,0x003ff000,0x00000000,0x00000000,0x00000000, // e
|
||||||
|
0x00000000,0x00000000,0x00000000,0x003ff000,0x001fe000,0x000fc000,0x00078000,0x00030000,0x003ff000,0x001fe000,0x000fc000,0x00078000,0x00030000,0x00000000,0x00000000,0x00000000, // f
|
||||||
|
0x00000000,0x00000000,0x003ff000,0x003ff000,0x00030000,0x00078000,0x000fc000,0x001fe000,0x003ff000,0x00030000,0x00078000,0x000fc000,0x001fe000,0x003ff000,0x00000000,0x00000000, // g
|
||||||
|
0x00000000,0x00000000,0x003ff000,0x001fe000,0x000fc000,0x00078000,0x00030000,0x003ff000,0x001fe000,0x000fc000,0x00078000,0x00030000,0x003ff000,0x003ff000,0x00000000,0x00000000, // h
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x003ff800,0x003ff800,0x00000000,0x00000000,0x003ff800,0x003ff800,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // i
|
||||||
|
0x00000000,0x00000000,0x00000000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x00000000,0x00000000,0x00000000, // j
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00078000,0x001fe000,0x001fe000,0x003ff000,0x003ff000,0x003ff000,0x003ff000,0x001fe000,0x001fe000,0x00078000,0x00000000,0x00000000,0x00000000, // k
|
||||||
|
0x00000000,0x000fe000,0x001ff000,0x00383800,0x00301800,0x00600000,0x00600000,0x0061fe00,0x0061fe00,0x00600000,0x00600000,0x00301800,0x00383800,0x001ff000,0x000fe000,0x00000000, // l
|
||||||
|
0x00000000,0x00000000,0x0007c000,0x00082000,0x00101000,0x002b8800,0x00478400,0x00438400,0x0047c400,0x004fe400,0x00404400,0x00202800,0x00101000,0x00082000,0x0007c000,0x00000000, // m
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00038000,0x00038000,0x00038000,0x0007c000,0x000fe000,0x00000000,0x00044000,0x00038000,0x00000000,0x00000000,0x00000000,0x00000000, // n
|
||||||
|
0x00000000,0x00038000,0x00038000,0x00038000,0x0007c000,0x000fe000,0x00000000,0x00000000,0x00044000,0x00139000,0x00482400,0x0047c400,0x00301800,0x000fe000,0x00000000,0x00000000, // o
|
||||||
|
|
||||||
|
0x00000000,0x00600000,0x00f00000,0x00f00000,0x00700000,0x003ffc00,0x00002400,0x00003600,0x00001200,0x00301200,0x00781200,0x00781b00,0x00380900,0x001fff00,0x00000000,0x00000000, // p
|
||||||
|
0x00000000,0x0018c000,0x003cf000,0x007e3800,0x00181800,0x00181800,0x00181800,0x00181800,0x00181800,0x00181800,0x00181800,0x00181800,0x001e7e00,0x00073c00,0x00031800,0x00000000, // q
|
||||||
|
0x0000a000,0x00f0b000,0x00fcb800,0x00fe3800,0x00ff9800,0x00f3d800,0x00e1f800,0x00ccd800,0x00ccd800,0x00e1f800,0x00f3d800,0x00ff9800,0x00fe3800,0x00fcb800,0x00f0b000,0x0000a000, // r
|
||||||
|
0x00000000,0x00008000,0x0001c000,0x00c0f000,0x00e03800,0x00705800,0x0038ec00,0x001dc400,0x000f8000,0x00070000,0x000ff000,0x001df800,0x00399800,0x00718000,0x00e1c000,0x0040c000, // s
|
||||||
|
0x00000000,0x00018000,0x0003c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x0003c000,0x00018000,0x00000000, // t
|
||||||
|
0x00000000,0x0007e000,0x0003c000,0x00018000,0x00018000,0x00018000,0x00618600,0x007ffe00,0x003ffc00,0x002ff400,0x0007e000,0x0005a000,0x00018000,0x00018000,0x00018000,0x00000000, // u
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00006000,0x00006000,0x00006000,0x007ffc00,0x007ffc00,0x00006000,0x00006000,0x00006000,0x00000000,0x00000000,0x00000000,0x00000000, // v
|
||||||
|
0x00000000,0x001c7000,0x00145000,0x001c7000,0x00044000,0x00028000,0x00038000,0x00038000,0x00038000,0x0006c000,0x0006c000,0x00044000,0x000c6000,0x000c6000,0x00082000,0x00082000, // w
|
||||||
|
0x00000000,0x00300c00,0x00781e00,0x007c3e00,0x003e7c00,0x001ff800,0x000ff000,0x0007e000,0x0007e000,0x000ff000,0x001ff800,0x003e7c00,0x007c3e00,0x00781e00,0x00300c00,0x00000000, // x
|
||||||
|
0x00004000,0x0000c000,0x0000c000,0x0061c000,0x003fc000,0x001fe000,0x000ff800,0x000ffe00,0x000ff800,0x001fe000,0x003fc000,0x0061c000,0x0000c000,0x00004000,0x00004000,0x00000000, // y
|
||||||
|
0x00000000,0x00000000,0x03e00f80,0x02f81f80,0x02fc3f80,0x02de7680,0x02c7e680,0x02c3c680,0x02c3c680,0x02c7e680,0x02de7680,0x02fc3f80,0x02f81f80,0x03e00f80,0x00000000,0x00000000, // z
|
||||||
|
0x00000000,0x0000f000,0x00010800,0x00026400,0x00026400,0x00026400,0x00026400,0x00030800,0x0007f000,0x000e0000,0x001c0000,0x00380000,0x00700000,0x00600000,0x00000000,0x00000000, // {
|
||||||
|
0x00000000,0x0000f000,0x00010800,0x00026400,0x0002f400,0x0002f400,0x00026400,0x00030800,0x0007f000,0x000e0000,0x001c0000,0x00380000,0x00700000,0x00600000,0x00000000,0x00000000, // |
|
||||||
|
0x00000000,0x003fe800,0x007ff400,0x007ff400,0x007ff400,0x007df400,0x0079f400,0x00700400,0x00700400,0x0079f400,0x007df400,0x007ff400,0x007ff400,0x007ff400,0x003fe800,0x00000000, // }
|
||||||
|
0x00000000,0x00000000,0x00078000,0x00078000,0x00078000,0x00078000,0x007ff800,0x007ff800,0x007ff800,0x007ff800,0x00078000,0x00078000,0x00078000,0x00078000,0x00000000,0x00000000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
220
src/devices/Oled/SSD1306/Font_Symbol_32X32.java
Normal file
220
src/devices/Oled/SSD1306/Font_Symbol_32X32.java
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Symbol_32X32")
|
||||||
|
/**
|
||||||
|
* OLED Symbol 32 x 32 pixel
|
||||||
|
* Source : http://www.rinkydinkelectronics.com/images/fonts/Various_Symbols_32x32.png
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Font_Symbol_32X32 extends FontPack {
|
||||||
|
|
||||||
|
public final char kosong = 32;
|
||||||
|
public final char plus_minus = 33;
|
||||||
|
public final char nol_coret = 34;
|
||||||
|
public final char titik_tiga = 35;
|
||||||
|
public final char persen_gakjelas = 36;
|
||||||
|
public final char persen = 37;
|
||||||
|
public final char ordinal_indicator = 38;
|
||||||
|
public final char pangkat_dua = 39;
|
||||||
|
public final char pangkat_tiga = 40;
|
||||||
|
public final char tidak_samadengan = 41;
|
||||||
|
public final char pembagi_atasbawah = 42;
|
||||||
|
public final char akar = 43;
|
||||||
|
public final char yen = 44;
|
||||||
|
public final char section = 45;
|
||||||
|
public final char titik = 46;
|
||||||
|
public final char cent = 47;
|
||||||
|
public final char nol_lingkaran = 48;
|
||||||
|
public final char satu_lingkaran = 49;
|
||||||
|
public final char dua_lingkaran = 50;
|
||||||
|
public final char tiga_lingkaran = 51;
|
||||||
|
public final char empat_lingkaran = 52;
|
||||||
|
public final char lima_lingkaran = 53;
|
||||||
|
public final char enam_lingkaran = 54;
|
||||||
|
public final char tujuh_lingkaran = 55;
|
||||||
|
public final char delapan_lingkaran = 56;
|
||||||
|
public final char sembilan_lingkaran = 57;
|
||||||
|
public final char backspace = 58;
|
||||||
|
public final char lingkaran = 59;
|
||||||
|
public final char disket_save = 60;
|
||||||
|
public final char panah_segitiga_atas = 61;
|
||||||
|
public final char panah_segitiga_bawah = 62;
|
||||||
|
public final char panah_segitiga_kiri = 63;
|
||||||
|
public final char panah_segitiga_kanan = 64;
|
||||||
|
public final char kotak_disilang = 65;
|
||||||
|
public final char kotak_dicentang = 66;
|
||||||
|
public final char surat = 67;
|
||||||
|
public final char kotak = 68;
|
||||||
|
public final char euro = 69;
|
||||||
|
public final char petir = 70;
|
||||||
|
public final char satu_per_empat = 71;
|
||||||
|
public final char satu_per_dua = 72;
|
||||||
|
public final char tiga_per_empat = 73;
|
||||||
|
public final char questionmark_kebalik = 74;
|
||||||
|
public final char n_tilde = 75;
|
||||||
|
public final char face_happy = 76;
|
||||||
|
public final char face_sad = 77;
|
||||||
|
public final char face_neutral = 78;
|
||||||
|
public final char pirate = 79;
|
||||||
|
public final char panah_bawah = 80;
|
||||||
|
public final char panah_atas = 81;
|
||||||
|
public final char panah_kiri = 82;
|
||||||
|
public final char panah_kanan = 83;
|
||||||
|
public final char centang = 84;
|
||||||
|
public final char counter_clockwise = 85;
|
||||||
|
public final char clockwise = 86;
|
||||||
|
public final char heart = 87;
|
||||||
|
public final char copyright = 88;
|
||||||
|
public final char registered = 89;
|
||||||
|
public final char omega = 90;
|
||||||
|
public final char information = 91;
|
||||||
|
public final char derajat = 92;
|
||||||
|
public final char poundsterling = 93;
|
||||||
|
public final char micro = 94;
|
||||||
|
public final char shuffle = 95;
|
||||||
|
public final char media_eject = 96;
|
||||||
|
public final char media_reverse_play = 97;
|
||||||
|
public final char media_play = 98;
|
||||||
|
public final char media_up = 99;
|
||||||
|
public final char media_down = 100;
|
||||||
|
public final char media_rewind = 101;
|
||||||
|
public final char media_fastforward = 102;
|
||||||
|
public final char media_previoustrack = 103;
|
||||||
|
public final char media_nexttrack = 104;
|
||||||
|
public final char media_pause = 105;
|
||||||
|
public final char media_stop = 106;
|
||||||
|
public final char media_record = 107;
|
||||||
|
public final char powerbutton = 108;
|
||||||
|
public final char speaker_mute = 109;
|
||||||
|
public final char speaker_volumedown = 110;
|
||||||
|
public final char speaker_volumeup = 111;
|
||||||
|
public final char melody = 112;
|
||||||
|
public final char media_loop = 113;
|
||||||
|
public final char telephone = 114;
|
||||||
|
public final char sun = 115;
|
||||||
|
public final char diamond = 116;
|
||||||
|
public final char airplane = 117;
|
||||||
|
public final char salib = 118;
|
||||||
|
public final char gunting = 119;
|
||||||
|
public final char silang = 120;
|
||||||
|
public final char bintang = 121;
|
||||||
|
public final char timer = 122;
|
||||||
|
public final char zoom_out = 123;
|
||||||
|
public final char zoom_in = 124;
|
||||||
|
public final char archieve = 125;
|
||||||
|
public final char plus = 126;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source : http://www.rinkydinkelectronics.com/images/fonts/Various_Symbols_32x32.png
|
||||||
|
*/
|
||||||
|
public Font_Symbol_32X32() {
|
||||||
|
super("Font_Symbol_32X32", 32, 32, 32, 32, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <space>
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e7ffff8,0x1e7ffff8,0x1e7ffff8,0x1e7ffff8,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x1e007800,0x00000000,0x00000000,0x00000000,0x00000000, // !
|
||||||
|
0x00000000,0x00000000,0x00000000,0x1c07e000,0x1e3ffc00,0x1f7ffe00,0x0ff81f80,0x07e007c0,0x03e001c0,0x07f000e0,0x0ff800f0,0x0e7c0070,0x0e3e0070,0x1c1f0038,0x1c0f8038,0x1c07c038,0x1c03e038,0x1c01f038,0x1c00f838,0x0e007c70,0x0e003e70,0x0f001ff0,0x07000fe0,0x038007c0,0x03e007e0,0x01f81ff0,0x007ffef8,0x003ffc78,0x0007e038,0x00000000,0x00000000,0x00000000, // "
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x1f800000,0x1f800000,0x1f800000,0x1f800000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x1f800000,0x1f800000,0x1f800000,0x1f800000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x1f800000,0x1f800000,0x1f800000,0x1f800000,0x00000000,0x00000000,0x00000000,0x00000000, // #
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00001ff0,0x0c007ff8,0x1f006018,0x0fc06018,0x07f07ff8,0x01fc1fe0,0x007e0000,0x001f8000,0x0007e000,0x0001f800,0x00007e00,0x07fc1f80,0x1ffe0fe0,0x180603f0,0x180600f8,0x1ffe0030,0x07f80000,0x00000000,0x00000000,0x07fc0000,0x1ffe0000,0x18060000,0x18060000,0x1ffe0000,0x07f80000,0x00000000,0x00000000,0x00000000,0x00000000, // $
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00001f80,0x0c003fc0,0x1e006060,0x0f806060,0x07c06060,0x03f06060,0x00fc3fc0,0x003e1f80,0x001f8000,0x0007c000,0x0003f000,0x03f0f800,0x07f87e00,0x0c0c1f80,0x0c0c07c0,0x0c0c03f0,0x0c0c00f0,0x07f80060,0x03f00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // %
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x001e1800,0x003f1c00,0x00618e00,0x00618600,0x00618600,0x00618600,0x00618600,0x00318600,0x007ffc00,0x007ff800,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // &
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00781800,0x007c1c00,0x006e0e00,0x00670600,0x00638600,0x0061ce00,0x0060fc00,0x00607800,0x00603000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // '
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00181800,0x00381c00,0x00700e00,0x00600600,0x00618600,0x00618600,0x00718e00,0x003ffc00,0x001e7800,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // (
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00781e00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // )
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x07e3c7e0,0x0ff3cff0,0x0c33cc30,0x0c33cc30,0x0ff3cff0,0x07e3c7e0,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x00000000,0x00000000,0x00000000,0x00000000, // *
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00003000,0x00003000,0x00003000,0x0001f000,0x001fe000,0x01fe0000,0x1fe00000,0x1e000000,0x1fe00000,0x01fc0000,0x003fc000,0x0007f800,0x00007f00,0x00000ff0,0x000001f8,0x00000018,0x00000018,0x00000018,0x00000018,0x00000018,0x00000018,0x00000018,0x00000018,0x00000018,0x00000000,0x00000000,0x00000000,0x00000000, // +
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000018,0x0071c038,0x0071c0f8,0x0071c3f8,0x0071cfe0,0x0071df80,0x0071fe00,0x0073f800,0x3fffe000,0x3fff8000,0x3fff8000,0x3fffe000,0x0073f800,0x0071fe00,0x0071df80,0x0071cfe0,0x0071c3f8,0x0071c0f8,0x0071c038,0x00000018,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ,
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0003e1c0,0x0707f3e0,0x0f0f3ff0,0x1c1e1e78,0x181c1c38,0x18381c18,0x18301818,0x18703818,0x1c707018,0x1cf8f038,0x0fffe0f0,0x07cfc0e0,0x03878000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // -
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0003c000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0003c000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // .
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0007f000,0x001ffc00,0x007fff00,0x00f80780,0x01e003c0,0x01c001c0,0x038000e0,0x038000e0,0x038000e0,0x038000e0,0x1ffffffc,0x1ffffffc,0x1ffffffc,0x038000e0,0x038000e0,0x038000e0,0x03c001e0,0x01f007c0,0x00f00780,0x00700700,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // /
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0ffffff0,0x1fc003f8,0x1f8000f8,0x3e00007c,0x3c7ffe3c,0x3cffff3c,0x3cffff3c,0x3cffff3c,0x3cffff3c,0x3cffff3c,0x3c7ffe3c,0x1e000078,0x1f0000f8,0x0fc003f0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 0
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0c3ffff0,0x1c3ff9f8,0x1c3ff8f8,0x3c3ff87c,0x3c3ff83c,0x3c00003c,0x3c00003c,0x3c00003c,0x3c00003c,0x3c3ffffc,0x3c3ffffc,0x1c3ffff8,0x1c3ffff8,0x0c3ffff0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 1
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0ffffff0,0x1c7ff0f8,0x1c3ff078,0x3c1ffc3c,0x3c0ffe3c,0x3c47fe3c,0x3c63fe3c,0x3c71fe3c,0x3c78fe3c,0x3c7c7c3c,0x3c7e387c,0x1c7f00f8,0x1c7f81f8,0x0ffffff0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 2
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0ffffff0,0x1ffffff8,0x1e3ffc78,0x3c3ffc3c,0x3c7ffe3c,0x38ffff1c,0x38fe3f1c,0x38fe3f1c,0x38fe3f1c,0x387e3e3c,0x3c7c1e3c,0x1e000078,0x1f00c0f8,0x0f81e1f0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 3
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0fc07ff0,0x0fc03ff0,0x1fc01ff8,0x1fc70ff8,0x3fc787fc,0x3fc7c3fc,0x3fc7e1fc,0x3fc7f0fc,0x3fc7f87c,0x3c00003c,0x3c00003c,0x3c00003c,0x1fc7fff8,0x1fc7fff8,0x0fc7fff0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 4
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0ffffff0,0x1f0f8038,0x1e0f0038,0x3c0f003c,0x3c3f1e3c,0x3c7f1e3c,0x3c7f1e3c,0x3c7f1e3c,0x3c7f1e3c,0x3c3e1e3c,0x3c001e3c,0x1e003e38,0x1f007e38,0x0ffffff0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 5
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0fc003f0,0x1f0000f8,0x1e000078,0x3c3e3e3c,0x3c7f1f1c,0x3cff9f1c,0x3cff9f1c,0x3cff9f1c,0x3cff9f1c,0x3c7f1f1c,0x3c3e1e1c,0x1e003838,0x1f007878,0x0f81f9f0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 6
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0ffffff0,0x1ffffc78,0x1ffffc78,0x3ffffc7c,0x38fffc7c,0x383ffc7c,0x380ffc7c,0x3f01fc7c,0x3fc07c7c,0x3ff81c7c,0x3ffe047c,0x1fff8078,0x1fffe078,0x0ffff070,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 7
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0f03e0f0,0x1e018078,0x1c008038,0x38781e1c,0x38fc3f1c,0x39fe7f9c,0x39fe7f9c,0x39fe7f9c,0x38fc3f1c,0x38781e1c,0x3c00803c,0x1e01c078,0x1f03e0f8,0x0ffffff0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 8
|
||||||
|
0x00000000,0x00000000,0x0007e000,0x003ffc00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0ffffff0,0x1f1f01f8,0x1e1e00f8,0x3c7c7c7c,0x3cf8fe3c,0x3cf9ff3c,0x3cf9ff3c,0x3cf9ff3c,0x3cf9ff3c,0x3c78fe3c,0x3e3c7c7c,0x1f0000f8,0x1f8001f8,0x0fc003f0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x003ffc00,0x0007e000,0x00000000,0x00000000, // 9
|
||||||
|
0x00000000,0x00018000,0x0003c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x03ffffe0,0x03ffffe0,0x03ffffe0,0x03ffffe0,0x03fbefe0,0x03f1c7e0,0x03e083e0,0x03c001e0,0x03e003e0,0x03f007e0,0x03f80fe0,0x03f007e0,0x03e003e0,0x03c001e0,0x03e083e0,0x03f1c7e0,0x03fbefe0,0x03ffffe0,0x03ffffe0,0x03ffffe0,0x01ffffc0, // :
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0007e000,0x003ffc00,0x007ffe00,0x01f81f80,0x03e007c0,0x038001c0,0x070000e0,0x0f0000f0,0x0e000070,0x0e000070,0x1c000038,0x1c000038,0x1c000038,0x1c000038,0x1c000038,0x1c000038,0x0e000070,0x0e000070,0x0f0000f0,0x070000e0,0x038001c0,0x03e007c0,0x01f81f80,0x007ffe00,0x003ffc00,0x0007e000,0x00000000,0x00000000,0x00000000, // ;
|
||||||
|
0x00000000,0x00000000,0x00000000,0x1ffffff8,0x1ffffff8,0x18000018,0x18000018,0x18007ff8,0x18007ff8,0x1ff86678,0x1ff86678,0x1c186678,0x1c186678,0x1ff86678,0x1ff86678,0x1ff86678,0x1ff86678,0x1ff86678,0x1ff86678,0x1ff86678,0x1ff86678,0x1ff86678,0x1ff86678,0x18007ff8,0x18007ff8,0x18000018,0x18000018,0x1ffffff8,0x1ffffff8,0x00000000,0x00000000,0x00000000, // <
|
||||||
|
0x00000000,0x00000000,0x18000000,0x1c000000,0x1f000000,0x1fc00000,0x1ff00000,0x1cfc0000,0x1c3f0000,0x1c0fc000,0x1c03f000,0x1c00fc00,0x1c003f00,0x1c000fc0,0x1c0003f0,0x1c0000f8,0x1c0000f8,0x1c0003f0,0x1c000fc0,0x1c003f00,0x1c00fc00,0x1c03f000,0x1c0fc000,0x1c3f0000,0x1cfc0000,0x1ff00000,0x1fc00000,0x1f000000,0x1c000000,0x18000000,0x00000000,0x00000000, // =
|
||||||
|
0x00000000,0x00000000,0x00000018,0x00000038,0x000000f8,0x000003f8,0x00000ff8,0x00003f38,0x0000fc38,0x0003f038,0x000fc038,0x003f0038,0x00fc0038,0x03f00038,0x0fc00038,0x1f000038,0x1f000038,0x0fc00038,0x03f00038,0x00fc0038,0x003f0038,0x000fc038,0x0003f038,0x0000fc38,0x00003f38,0x00000ff8,0x000003f8,0x000000f8,0x00000038,0x00000018,0x00000000,0x00000000, // >
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00018000,0x0003c000,0x0003c000,0x0007e000,0x0007e000,0x000e7000,0x000e7000,0x001c3800,0x001c3800,0x00381c00,0x00381c00,0x00700e00,0x00700e00,0x00e00700,0x00e00700,0x01c00380,0x01c00380,0x038001c0,0x038001c0,0x070000e0,0x070000e0,0x0e000070,0x0e000070,0x1ffffff8,0x3ffffffc,0x3ffffffc,0x00000000,0x00000000,0x00000000, // ?
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x3ffffffc,0x3ffffffc,0x1ffffff8,0x0e000070,0x0e000070,0x070000e0,0x070000e0,0x038001c0,0x038001c0,0x01c00380,0x01c00380,0x00e00700,0x00e00700,0x00700e00,0x00700e00,0x00381c00,0x00381c00,0x001c3800,0x001c3800,0x000e7000,0x000e7000,0x0007e000,0x0007e000,0x0003c000,0x0003c000,0x00018000,0x00000000,0x00000000,0x00000000, // @
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0ffffff0,0x0ffffff0,0x0c000030,0x0dc003b0,0x0de007b0,0x0df00fb0,0x0cf81f30,0x0c7c3e30,0x0c3e7c30,0x0c1e7830,0x0c0ff030,0x0c03c030,0x0c03c030,0x0c0ff030,0x0c1e7830,0x0c3e7c30,0x0c7c3e30,0x0cf81f30,0x0df00fb0,0x0de007b0,0x0dc003b0,0x0c000030,0x0ffffff0,0x0ffffff0,0x00000000,0x00000000,0x00000000,0x00000000, // A
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0ffffff0,0x0ffffff0,0x0c000030,0x0c080030,0x0c1c0030,0x0c3c0030,0x0c780030,0x0ce00030,0x0dc00030,0x0df00030,0x0cfc0030,0x0c3f0030,0x0c0f8030,0x0c03c030,0x0c00e030,0x0c007830,0x0c003c30,0x0c000e30,0x0c000730,0x0c0001b0,0x0c0000b0,0x0c000030,0x0ffffff0,0x0ffffff0,0x00000000,0x00000000,0x00000000,0x00000000, // B
|
||||||
|
0x00000000,0x00000000,0x01ffff80,0x01ffff80,0x01c00380,0x01e00780,0x01f00f80,0x01b81d80,0x019c3980,0x018e7180,0x0187e180,0x0183c180,0x01838180,0x01870180,0x018e0180,0x019c0180,0x019c0180,0x018e0180,0x01870180,0x01838180,0x0183c180,0x0187e180,0x018e7180,0x019c3980,0x01b81d80,0x01f00f80,0x01e00780,0x01c00380,0x01ffff80,0x01ffff80,0x00000000,0x00000000, // C
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0e000070,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x00000000,0x00000000,0x00000000,0x00000000, // D
|
||||||
|
0x00000000,0x00000000,0x00003800,0x000e3800,0x000e3800,0x000e3800,0x003ffc00,0x00ffff00,0x03ffffc0,0x07ce39e0,0x0f0e38f0,0x0e0e3870,0x1c0e3838,0x1c0e3838,0x1c0e3838,0x1c0e3838,0x1c0e3838,0x1c003838,0x1c003838,0x1c003838,0x1c000038,0x1c000038,0x1e000078,0x0f8001f0,0x078001e0,0x038001c0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // E
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x30000000,0x38000000,0x1c000000,0x0e000000,0x0f000000,0x07800000,0x03c00000,0x03e03000,0x01f07c00,0x00f8fe00,0x00fdff80,0x007fffc0,0x003fffe0,0x001ffff8,0x001feffc,0x000fc7fc,0x000783fc,0x000701fc,0x000200fc,0x0000007c,0x0000003c,0x0000001c,0x0000000c,0x00000004,0x00000000,0x00000000,0x00000000,0x00000000, // F
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x000180c0,0x180180e0,0x1c018070,0x0701fff8,0x0381fff8,0x01c18000,0x00f18000,0x00398000,0x001c0000,0x000f0000,0x00038000,0x03c1c000,0x03e0f000,0x03703800,0x031c1c00,0x030e0f00,0x03070380,0x1fff81c0,0x1fff80f0,0x03000038,0x03000018,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // G
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x000180c0,0x180180e0,0x1c018070,0x0701fff8,0x0381fff8,0x01c18000,0x00f18000,0x00398000,0x001c0000,0x000f0000,0x00038000,0x0001c000,0x0000f000,0x00003800,0x1e061c00,0x1f070f00,0x1b838380,0x19c181c0,0x18e180f0,0x18738038,0x183f0018,0x181e0000,0x180c0000,0x00000000,0x00000000,0x00000000,0x00000000, // H
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00006060,0x1800e070,0x1c01c038,0x07018018,0x03818618,0x01c18618,0x00f1c638,0x0038fff0,0x001c79e0,0x000f0000,0x00038000,0x03c1c000,0x03e0f000,0x03703800,0x031c1c00,0x030e0f00,0x03070380,0x1fff81c0,0x1fff80f0,0x03000038,0x03000018,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // I
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00f80000,0x01fc0000,0x03fe0000,0x070700c0,0x0603f9e0,0x0601f9e0,0x0600f9e0,0x060000c0,0x07000000,0x03c00000,0x01c00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // J
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x1ffff380,0x1ffff3c0,0x1ffff1e0,0x1ffff0f0,0x0003c078,0x0001e038,0x0000f038,0x00007070,0x000070e0,0x000071c0,0x00007380,0x0000f380,0x1ffff3c0,0x1fffe1e0,0x1fffc0f0,0x1fff8070,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // K
|
||||||
|
0x00000000,0x00000000,0x001ff800,0x007ffe00,0x01e00780,0x078001c0,0x060000e0,0x0c180070,0x0c38fc30,0x1871fe18,0x18618618,0x30e1860c,0x30c1fe0c,0x30c0fc0c,0x30c0000c,0x30c0000c,0x30c0000c,0x30c0000c,0x30c0fc0c,0x30c1fe0c,0x30e1860c,0x18618618,0x1871fe18,0x0c38fc30,0x0c180070,0x060000e0,0x078001c0,0x01e00780,0x007ffe00,0x001ff800,0x00000000,0x00000000, // L
|
||||||
|
0x00000000,0x00000000,0x001ff800,0x007ffe00,0x01e00780,0x078001c0,0x060000e0,0x0cc00070,0x0ce0fc30,0x1871fe18,0x18318618,0x3039860c,0x3019fe0c,0x3018fc0c,0x3018000c,0x3018000c,0x3018000c,0x3018000c,0x3018fc0c,0x3019fe0c,0x3039860c,0x18318618,0x1871fe18,0x0ce0fc30,0x0cc00070,0x060000e0,0x078001c0,0x01e00780,0x007ffe00,0x001ff800,0x00000000,0x00000000, // M
|
||||||
|
0x00000000,0x00000000,0x001ff800,0x007ffe00,0x01e00780,0x078001c0,0x060000e0,0x0c300070,0x0c30fc30,0x1831fe18,0x18318618,0x3031860c,0x3031fe0c,0x3030fc0c,0x3030000c,0x3030000c,0x3030000c,0x3030000c,0x3030fc0c,0x3031fe0c,0x3031860c,0x18318618,0x1831fe18,0x0c30fc30,0x0c300070,0x060000e0,0x078001c0,0x01e00780,0x007ffe00,0x001ff800,0x00000000,0x00000000, // N
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00180000,0x0c1b0000,0x6c1f0000,0x7c1f1fc0,0x7c3f3fe0,0x7e7873f0,0x0f70e1f8,0x07f3e1fc,0x07e3f3fc,0x03e0fffc,0x03c3cffc,0x01e3cffc,0x04e0fffc,0x0673f3fc,0x0f73e1f8,0x7e38e1f8,0x7c3873f0,0x7c3f3fe0,0x6c3f1fc0,0x0c1f0000,0x001b0000,0x00180000,0x00000000,0x00000000,0x00000000,0x00000000, // O
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x000ff800,0x001ff000,0x003fe000,0x007fc000,0x00ff8000,0x01ff0000,0x03fe0000,0x07fc0000,0x0ffffff8,0x1ffffff8,0x3ffffff8,0x3ffffff8,0x1ffffff8,0x0ffffff8,0x07fc0000,0x03fe0000,0x01ff0000,0x00ff8000,0x007fc000,0x003fe000,0x001ff000,0x000ff800,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // P
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x001ff000,0x000ff800,0x0007fc00,0x0003fe00,0x0001ff00,0x0000ff80,0x00007fc0,0x00003fe0,0x1ffffff0,0x1ffffff8,0x1ffffffc,0x1ffffffc,0x1ffffff8,0x1ffffff0,0x00003fe0,0x00007fc0,0x0000ff80,0x0001ff00,0x0003fe00,0x0007fc00,0x000ff800,0x001ff000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // Q
|
||||||
|
0x00000000,0x00000000,0x00018000,0x0003c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x07ffffe0,0x07f7efe0,0x07e7e7e0,0x07c7e3e0,0x0787e1e0,0x0707e0e0,0x0607e060,0x0407e020,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x00000000,0x00000000,0x00000000, // R
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0007e000,0x0407e020,0x0607e060,0x0707e0e0,0x0787e1e0,0x07c7e3e0,0x07e7e7e0,0x07f7efe0,0x07ffffe0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x0003c000,0x00018000,0x00000000,0x00000000, // S
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00700000,0x01f00000,0x03e00000,0x07c00000,0x0f800000,0x07c00000,0x01e00000,0x00f80000,0x003c0000,0x000f0000,0x00078000,0x0003c000,0x0000e000,0x00007000,0x00003800,0x00001c00,0x00000e00,0x00000700,0x00000380,0x000001c0,0x000000e0,0x00000020,0x00000010,0x00000000,0x00000000,0x00000000,0x00000000, // T
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0007fc00,0x000ffe00,0x001fff00,0x003fff80,0x007c03c0,0x00f801e0,0x00f000f0,0x00f000f0,0x00f000f0,0x00f000f0,0x1fff80f0,0x0fff00f0,0x07fe00f0,0x03fc00f0,0x01f801e0,0x00f003c0,0x0060ff80,0x0000ff00,0x0000fe00,0x0000fc00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // U
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x003fe000,0x007ff000,0x00fff800,0x01fffc00,0x03c03e00,0x07801f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f000f00,0x0f01fff8,0x0f00fff0,0x0f007fe0,0x0f003fc0,0x07801f80,0x03c00f00,0x01ff0600,0x00ff0000,0x007f0000,0x003f0000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // V
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00003c00,0x00007e00,0x0000ff00,0x0001ff80,0x0003ffc0,0x0007ffe0,0x000fffe0,0x001fffe0,0x003fffe0,0x007fffc0,0x00ffff80,0x01ffff00,0x03fffe00,0x03fffe00,0x01ffff00,0x00ffff80,0x007fffc0,0x003fffe0,0x001fffe0,0x000fffe0,0x0007ffe0,0x0003ffc0,0x0001ff80,0x0000ff00,0x00007e00,0x00003c00,0x00000000,0x00000000,0x00000000, // W
|
||||||
|
0x00000000,0x00000000,0x001ff800,0x007ffe00,0x01ffff80,0x03c003c0,0x078001e0,0x0f0000f0,0x0e000070,0x1c1ff838,0x183ffc18,0x387ffe1c,0x38f00f1c,0x39e0079c,0x39c0039c,0x39c0039c,0x39c0039c,0x39c0039c,0x39c0039c,0x39e0079c,0x38f81f1c,0x18781e18,0x1c381c38,0x0e000070,0x0f0000f0,0x078001e0,0x03c003c0,0x01ffff80,0x007ffe00,0x001ff800,0x00000000,0x00000000, // X
|
||||||
|
0x00000000,0x00000000,0x001ff800,0x007ffe00,0x01ffff80,0x03c003c0,0x078001e0,0x0f0000f0,0x0e000070,0x1c000038,0x18000018,0x39ffff1c,0x39ffff9c,0x39ffff9c,0x3803839c,0x3803839c,0x3803839c,0x3807c79c,0x39ffff1c,0x39fefe1c,0x39fc7c1c,0x18000018,0x1c000038,0x0e000070,0x0f0000f0,0x078001e0,0x03c003c0,0x01ffff80,0x007ffe00,0x001ff800,0x00000000,0x00000000, // Y
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0e07e000,0x0e1ff800,0x0e7ffe00,0x0effff00,0x0ef81f00,0x0fe00780,0x0fc003c0,0x0fc003c0,0x0f8001c0,0x0f0001e0,0x000001e0,0x000001e0,0x000001e0,0x000001e0,0x0f0001e0,0x0f8001c0,0x0fc003c0,0x0fc003c0,0x0fe00780,0x0ef81f00,0x0effff00,0x0e3ffe00,0x0e1ff800,0x0e07e000,0x00000000,0x00000000,0x00000000,0x00000000, // Z
|
||||||
|
0x00000000,0x00000000,0x3ffffffc,0x3ffffffc,0x3000000c,0x3000000c,0x3000000c,0x3000000c,0x3780000c,0x3780000c,0x3780000c,0x3780e38c,0x3780e7cc,0x37ffefec,0x37ffefec,0x37ffefec,0x37ffefec,0x37ffefec,0x37ffe7cc,0x3780038c,0x3780000c,0x3780000c,0x3780000c,0x3780000c,0x3000000c,0x3000000c,0x3000000c,0x3000000c,0x1ffffff8,0x0ffffff0,0x00000000,0x00000000, // [
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00007c00,0x0000fe00,0x0001ff00,0x0003c780,0x00038380,0x00038380,0x00038380,0x0003c780,0x0001ff00,0x0000fe00,0x00007c00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <backslash>
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x1e000000,0x1e000000,0x1e078000,0x1e078000,0x1e078000,0x1fffff80,0x1fffffc0,0x1fffffe0,0x1ffffff0,0x1e0781f8,0x1e0780f8,0x1e078078,0x1e078078,0x1e078078,0x1e078078,0x1e000078,0x1e0001f8,0x1e0001f8,0x1e0001f0,0x1e0001e0,0x1e000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ]
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x1e000000,0x1e000000,0x1e000000,0x1ffffff8,0x0ffffff8,0x07fffff8,0x03fffff8,0x001e0000,0x003c0000,0x00780000,0x00780000,0x00780000,0x00780000,0x003c0000,0x001e0000,0x000ffff8,0x001ffff8,0x003ffff8,0x007ffff8,0x00780000,0x00780000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ^
|
||||||
|
0x00000000,0x00000000,0x01e00780,0x01e00780,0x01e00780,0x01e00780,0x01f00780,0x00f80780,0x007c0f80,0x003e1f00,0x001f1e00,0x000f9c00,0x0007c000,0x0003e000,0x0001f000,0x0000f800,0x000c7c00,0x001e3e00,0x003e1f00,0x007c0f80,0x00f80780,0x01f00780,0x01e00780,0x01e00780,0x1ffe7ff8,0x0ffc3ff0,0x07f81fe0,0x03f00fc0,0x01e00780,0x00c00300,0x00000000,0x00000000, // _
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x079c0000,0x079e0000,0x079f0000,0x079f8000,0x079fc000,0x079fe000,0x079ff000,0x079ff800,0x079ffc00,0x079ffe00,0x079fff00,0x079fff80,0x079fffc0,0x079fffc0,0x079fff80,0x079fff00,0x079ffe00,0x079ffc00,0x079ff800,0x079ff000,0x079fe000,0x079fc000,0x079f8000,0x079f0000,0x079e0000,0x079c0000,0x00000000,0x00000000,0x00000000, // `
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00018000,0x0003c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x1ffffff8,0x3ffffffc,0x3ffffffc,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // a
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x3ffffffc,0x3ffffffc,0x1ffffff8,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x0003c000,0x00018000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // b
|
||||||
|
0x00000000,0x00000000,0x00c00000,0x00e00000,0x00f00000,0x00f80000,0x00fc0000,0x00fe0000,0x00ff0000,0x00ff8000,0x00ffc000,0x00ffe000,0x00fff000,0x00fff800,0x00fffc00,0x00fffe00,0x00fffe00,0x00fffc00,0x00fff800,0x00fff000,0x00ffe000,0x00ffc000,0x00ff8000,0x00ff0000,0x00fe0000,0x00fc0000,0x00f80000,0x00f00000,0x00e00000,0x00c00000,0x00000000,0x00000000, // c
|
||||||
|
0x00000000,0x00000000,0x00000600,0x00000e00,0x00001e00,0x00003e00,0x00007e00,0x0000fe00,0x0001fe00,0x0003fe00,0x0007fe00,0x000ffe00,0x001ffe00,0x003ffe00,0x007ffe00,0x00fffe00,0x00fffe00,0x007ffe00,0x003ffe00,0x001ffe00,0x000ffe00,0x0007fe00,0x0003fe00,0x0001fe00,0x0000fe00,0x00007e00,0x00003e00,0x00001e00,0x00000e00,0x00000600,0x00000000,0x00000000, // d
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00018000,0x0003c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x1ffffff8,0x3ffffffc,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x1ffffff8,0x3ffffffc,0x00000000,0x00000000,0x00000000, // e
|
||||||
|
0x00000000,0x00000000,0x00000000,0x3ffffffc,0x1ffffff8,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x3ffffffc,0x1ffffff8,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x0003c000,0x00018000,0x00000000,0x00000000,0x00000000, // f
|
||||||
|
0x00000000,0x00000000,0x3ffffffc,0x3ffffffc,0x3ffffffc,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x1ffffff8,0x3ffffffc,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x1ffffff8,0x3ffffffc,0x00000000,0x00000000,0x00000000, // g
|
||||||
|
0x00000000,0x00000000,0x00000000,0x3ffffffc,0x1ffffff8,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x3ffffffc,0x1ffffff8,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x3ffffffc,0x3ffffffc,0x3ffffffc,0x00000000,0x00000000, // h
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x00000000,0x00000000,0x00000000,0x00000000,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // i
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x00000000,0x00000000,0x00000000,0x00000000, // j
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0007e000,0x003ffc00,0x007ffe00,0x01ffff80,0x03ffffc0,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x0ffffff0,0x0ffffff0,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x03ffffc0,0x01ffff80,0x007ffe00,0x003ffc00,0x0007e000,0x00000000,0x00000000,0x00000000, // k
|
||||||
|
0x00000000,0x00000000,0x001fc000,0x007ff000,0x00fffc00,0x03fffe00,0x07e03f00,0x07800f00,0x0f000780,0x0f0007c0,0x1e0003c0,0x1e0003c0,0x3c000000,0x3c000000,0x3c03fffc,0x3c03fffc,0x3c03fffc,0x3c03fffc,0x3c000000,0x3c000000,0x1e0003c0,0x1e0003c0,0x0f0007c0,0x0f000780,0x07800f00,0x03e03f00,0x03fffe00,0x00fff800,0x007ff000,0x000fc000,0x00000000,0x00000000, // l
|
||||||
|
0x00000000,0x00000000,0x001ff800,0x007ffe00,0x01ffff80,0x07f00fc0,0x07f803e0,0x0fb801f0,0x0e3c0070,0x1e1fe078,0x1c1fe038,0x3c0fe03c,0x380fe01c,0x3807e01c,0x3803e01c,0x3803e01c,0x3807f01c,0x380ff81c,0x381ffc1c,0x383ffe1c,0x3c3ffe3c,0x1c007838,0x1e003878,0x0e003c70,0x0f801df0,0x07c01fe0,0x07f00fc0,0x01ffff80,0x007ffe00,0x001ff800,0x00000000,0x00000000, // m
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0007c000,0x0007c000,0x0007c000,0x0007c000,0x0007c000,0x0007c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x007ffe00,0x00000000,0x00181800,0x00181800,0x001c3800,0x000ff000,0x0007e000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // n
|
||||||
|
0x00000000,0x00000000,0x0007c000,0x0007c000,0x0007c000,0x0007c000,0x0007c000,0x0007c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x007ffe00,0x00000000,0x00181800,0x00181800,0x019c3980,0x018ff180,0x1987e198,0x18c00318,0x18e00718,0x18700e18,0x0c3ffc30,0x0e0ff070,0x070000e0,0x038001c0,0x01e00780,0x007ffe00,0x001ff800,0x00000000,0x00000000, // o
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0c000000,0x1e000000,0x3f000000,0x3f800000,0x3f800000,0x1f800000,0x1f800000,0x0fffff80,0x07ffffc0,0x03ffffc0,0x000071c0,0x000071c0,0x000071e0,0x000038e0,0x000038e0,0x000038e0,0x03003ce0,0x07801c70,0x0fc01c70,0x0fe01c70,0x0fe01e70,0x07e00e38,0x07e00e38,0x03fffe38,0x01fffff8,0x00fffff8,0x00000000,0x00000000,0x00000000, // p
|
||||||
|
0x00000000,0x00000000,0x00000000,0x01807800,0x03c07c00,0x07e07e00,0x0ff07f00,0x1ff80f80,0x3ffc07c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03c003c0,0x03e03ffc,0x01f01ff8,0x00fe0ff0,0x007e07e0,0x003e03c0,0x001e0180,0x00000000,0x00000000,0x00000000, // q
|
||||||
|
0x00000000,0x3f800e80,0x3ff00ec0,0x3ff80ee0,0x3ffc0ef0,0x3ffe0ef8,0x3fff0efc,0x3fff807e,0x3f87c03e,0x3e01fc3e,0x3c00fe3e,0x38787ffe,0x38fc7ffe,0x30fc3ffe,0x31fe3e3e,0x31fe3c3e,0x31fe3c3e,0x31fe3e3e,0x30fc3ffe,0x38fc7ffe,0x38787ffe,0x3c00fe3e,0x3e01fc3e,0x3f87c03e,0x3fff807e,0x3fff0efc,0x3ffe0ef8,0x3ffc0ef0,0x3ff80ee0,0x3ff00ec0,0x3f800e80,0x00000000, // r
|
||||||
|
0x00000000,0x00000000,0x00600c00,0x00701c00,0x00783c00,0x007ffe00,0x00fffe00,0x00f81f00,0x01e00780,0x07c003e0,0x7f8001fe,0x7f0000fe,0x3f03c0fc,0x1e07e078,0x0e0ff070,0x0e0ff070,0x0e0ff070,0x0e0ff070,0x1e07e078,0x3f03c0fc,0x7f0000fe,0x7f8001fe,0x07c003e0,0x01e00780,0x00f81f00,0x00fffe00,0x007ffe00,0x00783c00,0x00701c00,0x00600c00,0x00000000,0x00000000, // s
|
||||||
|
0x00000000,0x00000000,0x00018000,0x0003c000,0x0007e000,0x000ff000,0x001ff800,0x003ffc00,0x007ffe00,0x00ffff00,0x01ffff80,0x03ffffc0,0x07ffffe0,0x0ffffff0,0x1ffffff8,0x3ffffffc,0x3ffffffc,0x1ffffff8,0x0ffffff0,0x07ffffe0,0x03ffffc0,0x01ffff80,0x00ffff00,0x007ffe00,0x003ffc00,0x001ff800,0x000ff000,0x0007e000,0x0003c000,0x00018000,0x00000000,0x00000000, // t
|
||||||
|
0x00000000,0x00000000,0x00000000,0x003ffc00,0x001ff800,0x000ff000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x3803c01c,0x3c03c03c,0x3f87e1fc,0x1ffffff8,0x0ffffff0,0x0dffffb0,0x0cffff30,0x007ffe00,0x003ffc00,0x0033cc00,0x0033cc00,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x0003c000,0x00018000,0x00000000,0x00000000, // u
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x3ffffffc,0x3ffffffc,0x3ffffffc,0x3ffffffc,0x3ffffffc,0x3ffffffc,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x00001f80,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // v
|
||||||
|
0x00000000,0x00000000,0x01f81f80,0x01f81f80,0x01981980,0x01981980,0x01f81f80,0x01f81f80,0x003c3c00,0x001c3800,0x000e7000,0x0007e000,0x0003c000,0x0007e000,0x0007e000,0x0003c000,0x0007f000,0x000e7000,0x001e7800,0x001c3800,0x003c3c00,0x00381c00,0x00700e00,0x00700e00,0x00f00f00,0x00f00f00,0x00e00700,0x00c00300,0x00c00300,0x00800100,0x00000000,0x00000000, // w
|
||||||
|
0x00000000,0x00000000,0x00000000,0x1f0000f8,0x1f8001f8,0x1fc003f8,0x1fe007f8,0x1ff00ff8,0x0ff81ff0,0x07fc3fe0,0x03fe7fc0,0x01fe7f80,0x00ffff00,0x007ffe00,0x003ffc00,0x000ff000,0x000ff000,0x003ffc00,0x007ffe00,0x00ffff00,0x01fe7f80,0x03fe7fc0,0x07fc3fe0,0x0ff81ff0,0x1ff00ff8,0x1fe007f8,0x1fc003f8,0x1f8001f8,0x1f0000f8,0x00000000,0x00000000,0x00000000, // x
|
||||||
|
0x00000000,0x00000400,0x00000c00,0x00001c00,0x00003c00,0x3e007c00,0x1f80fc00,0x0fe1fc00,0x07f3fc00,0x03fffc00,0x03fffc00,0x01ffff00,0x00ffffc0,0x00fffff0,0x007ffff8,0x007ffffe,0x007ffffe,0x007ffff8,0x00fffff0,0x00ffffc0,0x01ffff00,0x03fffc00,0x03fffc00,0x07f3fc00,0x0fe1fc00,0x1f80fc00,0x3e007c00,0x00003c00,0x00001c00,0x00000c00,0x00000400,0x00000000, // y
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x10000004,0x3b80006e,0x3be001ee,0x3bf007ee,0x3bf80fee,0x3bfc1fee,0x3b9e3fee,0x3b8f7bee,0x3b87f3ee,0x3b83e3ee,0x3b81c3ee,0x3b83e3ee,0x3b87f3ee,0x3b8f7bee,0x3b9e3fee,0x3bfc1fee,0x3bf80fee,0x3bf007ee,0x3be001ee,0x3b80006e,0x30000004,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // z
|
||||||
|
0x00000000,0x00000000,0x00003f00,0x0000ffc0,0x0003fff0,0x0003c0f0,0x00078c78,0x00070c38,0x000e0c1c,0x000e0c1c,0x000e0c1c,0x000e0c1c,0x000e0c1c,0x000e0c1c,0x00070c38,0x00038c78,0x0007c0f0,0x000ffff0,0x001f7fc0,0x003e3f00,0x007c0000,0x00f80000,0x01f00000,0x03e00000,0x07c00000,0x0f800000,0x1f000000,0x3e000000,0x3c000000,0x38000000,0x00000000,0x00000000, // {
|
||||||
|
0x00000000,0x00000000,0x00003f00,0x0000ffc0,0x0001ffe0,0x0003c0f0,0x00078c78,0x00070c38,0x000e0c1c,0x000e0c1c,0x000effdc,0x000effdc,0x000e0c1c,0x000e0c1c,0x00070c38,0x00038c78,0x0007c0f0,0x000fffe0,0x001f7fc0,0x003e3f00,0x007c0000,0x00f80000,0x01f00000,0x03e00000,0x07c00000,0x0f800000,0x1f000000,0x3e000000,0x3c000000,0x38000000,0x00000000,0x00000000, // |
|
||||||
|
0x00000000,0x00000000,0x03fffe70,0x07ffff38,0x0fffff9c,0x1fffff9c,0x1fffff9c,0x1fffff9c,0x1fffff9c,0x1ffdff9c,0x1ff9ff9c,0x1ff1ff9c,0x1fe1ff9c,0x1fc1ff9c,0x1f80001c,0x1f00001c,0x1f00001c,0x1f80001c,0x1fc1ff9c,0x1fe1ff9c,0x1ff1ff9c,0x1ff9ff9c,0x1ffdff9c,0x1fffff9c,0x1fffff9c,0x1fffff9c,0x1fffff9c,0x0fffff9c,0x07ffff38,0x03fffe70,0x00000000,0x00000000, // }
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x1ffffff8,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x0007f000,0x00000000,0x00000000,0x00000000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
112
src/devices/Oled/SSD1306/Font_Ubuntu_24X32.java
Normal file
112
src/devices/Oled/SSD1306/Font_Ubuntu_24X32.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
|
||||||
|
@BA.ShortName("Font_Ubuntu_24X32")
|
||||||
|
public class Font_Ubuntu_24X32 extends FontPack {
|
||||||
|
public Font_Ubuntu_24X32() {
|
||||||
|
super("Font_Ubuntu_24X32", 24, 32, 24, 32, 32, 126);
|
||||||
|
data = new int[] {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <space>
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00e00000,0x01f1fffe,0x01f1fffe,0x01f0fffe,0x00e00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // !
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000600,0x00000600,0x0000071c,0x000003be,0x000003fe,0x000001fe,0x0000007c,0x00000000,0x00000000,0x00000600,0x00000600,0x0000071c,0x000003be,0x000003fe,0x000001fe,0x0000007c,0x00000000,0x00000000,0x00000000,0x00000000, // "
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000e0700,0x030e0700,0x03fe0700,0x03ffc700,0x00ffff00,0x000ffff0,0x000e3ffc,0x000e07fc,0x030e070c,0x03fe0700,0x03ffc700,0x00ffff00,0x000ffff0,0x000e3ffc,0x000e07fc,0x000e070c,0x000e0700,0x00000000,0x00000000,0x00000000, // #
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03001f00,0x03807f80,0x0700ffc0,0x0700f1c0,0x0701e0e0,0x7f01c0fe,0x7f01c0fe,0x7f03c0fe,0x070380e0,0x070780e0,0x038f00e0,0x03ff01c0,0x01fe00c0,0x00780000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // $
|
||||||
|
0x00000000,0x00000000,0x00000000,0x010003f0,0x01c00ffc,0x01e01c0e,0x00f81806,0x003e1806,0x001f1c0e,0x0007cffc,0x0001f3f0,0x0000fc00,0x003f3e00,0x00ffcf80,0x01c0e3e0,0x018061f0,0x0180607c,0x01c0e01e,0x00ffc00e,0x003f0002,0x00000000,0x00000000,0x00000000,0x00000000, // %
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x001f0000,0x007f8000,0x00ffe1f0,0x00f0f7f8,0x01e07ffc,0x01c03e1e,0x01c07c0e,0x01c0fc0e,0x01e1ee0e,0x00e3cf1e,0x00f787fc,0x007f03fc,0x003f00f0,0x00fff000,0x01f3f000,0x01c07000,0x01000000,0x00000000,0x00000000,0x00000000, // &
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x0000000e,0x0000001e,0x0000003c,0x00000078,0x00000020,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // '
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x000ff800,0x007fff00,0x01ffffc0,0x07f007f0,0x0f8000f8,0x1e00003e,0x3c00001f,0x7800000f,0xf0000007,0x20000002,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // (
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x20000002,0xf0000007,0x7800000f,0x3c00001e,0x1e00003c,0x0f8000f8,0x07f007f0,0x01ffffc0,0x007fff00,0x000ff800,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // )
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00001000,0x00001c00,0x00043800,0x000e3800,0x001f3800,0x000fb000,0x0003f780,0x00007f80,0x0001f780,0x000fb000,0x001f3800,0x000e3800,0x00043800,0x00001c00,0x00001000,0x00000000,0x00000000,0x00000000,0x00000000, // *
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x003fffe0,0x003fffe0,0x003fffe0,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // +
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x60000000,0x60000000,0x71c00000,0x3be00000,0x1fe00000,0x0fe00000,0x07c00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ,
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00007000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // -
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03800000,0x07c00000,0x07c00000,0x07c00000,0x03800000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // .
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0xc0000000,0xf8000000,0xff000000,0x3ff00000,0x07fe0000,0x00ffc000,0x000ff800,0x0001ff80,0x00003ff0,0x000007fe,0x0000007f,0x0000000f,0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // /
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0007fe00,0x003fffc0,0x00fffff0,0x01f801f8,0x01e00078,0x03c0703c,0x0380f81c,0x0380f81c,0x0380701c,0x03c0003c,0x01e00078,0x01f801f8,0x00fffff0,0x003fffc0,0x0007fe00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 0
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000080,0x038001c0,0x038000c0,0x038000e0,0x03800070,0x03800070,0x03fffffc,0x03fffffc,0x03fffffc,0x03800000,0x03800000,0x03800000,0x03800000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 1
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03c00030,0x03f00078,0x03f80038,0x03bc003c,0x038e001c,0x0387001c,0x0383801c,0x0381c01c,0x0380f03c,0x03807878,0x03803ff8,0x03801ff0,0x038007e0,0x03800000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 2
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01800018,0x01c00038,0x03800038,0x0380001c,0x0380701c,0x0380701c,0x0380701c,0x0380701c,0x0380701c,0x0380f83c,0x01c0fc78,0x01e1fff8,0x00ffcff0,0x007f87c0,0x003f0000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 3
|
||||||
|
0x00000000,0x00000000,0x00000000,0x000f0000,0x000fc000,0x000fe000,0x000ff800,0x000e7e00,0x000e1f00,0x000e0780,0x000e03e0,0x000e01f0,0x000e0078,0x000e003c,0x03fffffc,0x03fffffc,0x03fffffc,0x000e0000,0x000e0000,0x000e0000,0x00000000,0x00000000,0x00000000,0x00000000, // 4
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01c00000,0x01c03e00,0x03803ffc,0x03803ffc,0x0380381c,0x0380381c,0x0380381c,0x0380781c,0x0380701c,0x01c0f01c,0x01e1f01c,0x00ffe01c,0x007fc01c,0x003f0000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 5
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000ff000,0x007ffe00,0x00ffff80,0x01f077c0,0x01c031e0,0x03c038f0,0x03803870,0x03803838,0x03803838,0x03803838,0x03c0781c,0x01e0f01c,0x00fff01c,0x007fe01c,0x001f8000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 6
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0000001c,0x0000001c,0x0000001c,0x0000001c,0x03c0001c,0x03fc001c,0x03ff801c,0x003fe01c,0x0003f81c,0x00007e1c,0x00001f9c,0x000007dc,0x000001fc,0x0000007c,0x0000003c,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 7
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x003c0000,0x00ff07c0,0x01ff9ff0,0x01e1fff8,0x03c0fc38,0x0380f83c,0x0380701c,0x0380701c,0x0380e01c,0x0380f03c,0x03c1f878,0x01e3dff8,0x01ffcff0,0x00ff87e0,0x003e0000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 8
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00001f80,0x03807fe0,0x0380fff0,0x0380f078,0x0381e03c,0x03c1c01c,0x01c1c01c,0x01c1c01c,0x01e1c01c,0x00f1c03c,0x0079c038,0x003ee0f8,0x001ffff0,0x000fffe0,0x0001ff00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // 9
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00e00e00,0x01f01f00,0x01f01f00,0x01f01f00,0x00e00e00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // :
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x30000000,0x30000000,0x38e00e00,0x1df01f00,0x0ff01f00,0x07f01f00,0x03e00e00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ;
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0001c000,0x0003c000,0x0003e000,0x0003e000,0x00077000,0x00077000,0x000e3800,0x000e3800,0x001e3c00,0x001c1c00,0x001c1c00,0x00380e00,0x00380e00,0x00780f00,0x00300600,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x001c1c00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // =
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00300600,0x00780f00,0x00380e00,0x00380e00,0x001c1c00,0x001c1c00,0x001e3c00,0x000e3800,0x000e3800,0x00077000,0x00077000,0x0003e000,0x0003e000,0x0003c000,0x0001c000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // >
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x0000000c,0x0000001c,0x0000000e,0x00e0000e,0x01f1c00e,0x01f1e00e,0x01f1f00e,0x00e0780e,0x00001c1e,0x00000e1c,0x000007fc,0x000003f8,0x000001f0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ?
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000ffc00,0x00ffff80,0x03ffffe0,0x07f003f8,0x0f80007c,0x1f07e01c,0x1c1ff81e,0x3c3ffc0e,0x383c3c0e,0x38701e0e,0x38700e0e,0x38700e1e,0x38700e3c,0x387ffff8,0x007ffff0,0x003fffc0,0x00000000,0x00000000,0x00000000,0x00000000, // @
|
||||||
|
0x00000000,0x00000000,0x00000000,0x01800000,0x01f80000,0x01ff8000,0x00fff800,0x000fff00,0x0007fff0,0x00071ffe,0x000701fe,0x0007003e,0x0007001e,0x000701fe,0x00070ffe,0x0007fff0,0x000fff00,0x00fff800,0x01ff8000,0x01f80000,0x01800000,0x00000000,0x00000000,0x00000000, // A
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x03fffffc,0x03fffffc,0x03fffffc,0x0380701c,0x0380701c,0x0380701c,0x0380701c,0x0380701c,0x0380701c,0x03c0783c,0x01c0fc78,0x01e1fff8,0x00ffcff0,0x00ff83e0,0x003f0000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // B
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0003fe00,0x000fffc0,0x003ffff0,0x007e01f8,0x00f80078,0x00f0003c,0x01e0001e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x00e0001c,0x00c0000c,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // C
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x00e0001c,0x00e0001c,0x00f8007c,0x007e01f8,0x003ffff0,0x000fffc0,0x0003ff00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // D
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x01c0380e,0x01c0380e,0x01c0380e,0x01c0380e,0x01c0380e,0x01c0380e,0x01c0380e,0x01c0380e,0x01c0380e,0x01c0000e,0x01c00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // E
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x0000380e,0x0000380e,0x0000380e,0x0000380e,0x0000380e,0x0000380e,0x0000380e,0x0000380e,0x0000380e,0x0000380e,0x0000000e,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // F
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0003fe00,0x000fffc0,0x003ffff0,0x007e01f8,0x00f8007c,0x00f0003c,0x01e0001e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01ffe01e,0x00ffe03c,0x00ffe008,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // G
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x00003800,0x00003800,0x00003800,0x00003800,0x00003800,0x00003800,0x00003800,0x00003800,0x00003800,0x01fffffe,0x01fffffe,0x01fffffe,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // H
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01fffffe,0x01fffffe,0x01fffffe,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // I
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00400000,0x00f00000,0x00e00000,0x01e0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01e0000e,0x00f0000e,0x007ffffe,0x003ffffe,0x001ffffe,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // J
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x00003800,0x00007c00,0x0000fe00,0x0001ff00,0x0003e780,0x0007c3e0,0x000f81f0,0x003f007c,0x007c003e,0x01f8001e,0x01f00006,0x01c00002,0x01000000,0x00000000,0x00000000,0x00000000,0x00000000, // K
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // L
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01ff8000,0x01fffff8,0x01fffffe,0x0000001e,0x000000fc,0x000007e0,0x00003f80,0x0000fc00,0x0000e000,0x0000fc00,0x00003f80,0x000007e0,0x000000fc,0x0000001e,0x01fffffe,0x01fffffc,0x01ffc000,0x00000000,0x00000000,0x00000000, // M
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x0000007e,0x000001fc,0x000007f0,0x00001fc0,0x00007e00,0x0003f800,0x000fe000,0x003f0000,0x01fc0000,0x01fffffe,0x01fffffe,0x01fffffe,0x00000000,0x00000000,0x00000000,0x00000000, // N
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0003ff00,0x001fffe0,0x003ffff0,0x007c00f8,0x00f0003c,0x00e0001c,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x01c0000e,0x00e0001c,0x00f0003c,0x007e01f8,0x003ffff0,0x001fffe0,0x0003ff00,0x00000000,0x00000000,0x00000000,0x00000000, // O
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x0000e00e,0x0000e00e,0x0000e00e,0x0000e00e,0x0000e00e,0x0000e00e,0x0000701c,0x0000783c,0x00003ff8,0x00001ff0,0x00000fe0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // P
|
||||||
|
0x00000000,0x00000000,0x00000000,0x0003ff00,0x001fffe0,0x003ffff0,0x007c00f8,0x00f0003c,0x01e0001c,0x01c0000e,0x07c0000e,0x0fc0000e,0x1fc0000e,0x3dc0000e,0x39e0001c,0x38f0003c,0x707e01f8,0x703ffff0,0x301fffe0,0x0003ff00,0x00000000,0x00000000,0x00000000,0x00000000, // Q
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01fffffe,0x01fffffe,0x01fffffe,0x0000e00e,0x0000e00e,0x0000e00e,0x0000e00e,0x0001e00e,0x0003e00e,0x000ff01c,0x003f783c,0x00fc3ff8,0x01f01ff0,0x01c007e0,0x01000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // R
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00600000,0x00f003e0,0x00e007f8,0x01e00ffc,0x01c01e1c,0x01c01c1e,0x01c03c0e,0x01c0380e,0x01c0780e,0x01c0700e,0x01e0f00e,0x00f1e00e,0x00ffe01c,0x007fc00c,0x001f0000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // S
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0000000e,0x0000000e,0x0000000e,0x0000000e,0x0000000e,0x0000000e,0x01fffffe,0x01fffffe,0x01fffffe,0x0000000e,0x0000000e,0x0000000e,0x0000000e,0x0000000e,0x0000000e,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // T
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000ffffe,0x003ffffe,0x007ffffe,0x00f80000,0x01e00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01c00000,0x01e00000,0x00f80000,0x007ffffe,0x003ffffe,0x000ffffe,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // U
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000006,0x0000007e,0x000007fe,0x00007ff8,0x0003ff80,0x001ff800,0x01ff8000,0x01fc0000,0x01e00000,0x01fc0000,0x00ffc000,0x001ff800,0x0003ff80,0x00007ff8,0x000007fe,0x0000007e,0x00000006,0x00000000,0x00000000,0x00000000,0x00000000, // V
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x007ffffe,0x01fffffe,0x01fffffe,0x01f80000,0x003f0000,0x0007e000,0x0000fc00,0x00001c00,0x0000fc00,0x0007e000,0x003f0000,0x01f80000,0x01fffffe,0x01fffffe,0x007ffffe,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // W
|
||||||
|
0x00000000,0x00000000,0x00000000,0x01000002,0x01c0000e,0x01f0001e,0x01fc007e,0x007e01f8,0x001f87e0,0x0007cf80,0x0001ff00,0x0000fc00,0x0001ff00,0x0007cf80,0x001f87e0,0x007e01f8,0x01fc007e,0x01f0001e,0x01c0000e,0x01000002,0x00000000,0x00000000,0x00000000,0x00000000, // X
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000002,0x0000001e,0x0000007e,0x000001fc,0x000007f0,0x00001fc0,0x00007f00,0x01fffc00,0x01fff000,0x01fffc00,0x00007e00,0x00001fc0,0x000007f0,0x000001fc,0x0000007e,0x0000001e,0x00000002,0x00000000,0x00000000,0x00000000,0x00000000, // Y
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x01c00000,0x01f0000e,0x01fc000e,0x01ff000e,0x01df800e,0x01c7e00e,0x01c1f80e,0x01c07c0e,0x01c03f0e,0x01c00f8e,0x01c007ee,0x01c001fe,0x01c0007e,0x01c0003e,0x01c0000e,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // Z
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0xffffffff,0xffffffff,0xffffffff,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // [
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000003,0x0000000f,0x0000007f,0x000007fe,0x00003ff0,0x0001ff80,0x000ff800,0x00ffc000,0x07fe0000,0x3ff00000,0xff000000,0xf8000000,0xc0000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // <backslash>
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0xffffffff,0xffffffff,0xffffffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ]
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00001000,0x00001c00,0x00003f00,0x00001fc0,0x000007f0,0x000001fc,0x0000003e,0x0000000e,0x0000003e,0x000001fc,0x000007f0,0x00001fc0,0x00003f00,0x00001c00,0x00001000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // ^
|
||||||
|
0x00000000,0x00000000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x00000000,0x00000000,0x00000000, // _
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x000000f8,0x000001fc,0x0000038e,0x00000306,0x00000306,0x00000306,0x0000038e,0x000001fc,0x000000f8,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // `
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x007c0000,0x00fe0000,0x01ff0e00,0x01c70f00,0x03878700,0x03838700,0x03838700,0x03838700,0x03838700,0x03838f00,0x03839e00,0x03fffe00,0x03fffc00,0x01fff800,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // a
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01ffffff,0x03ffffff,0x03ffffff,0x03800e00,0x03800700,0x03800700,0x03800700,0x03800700,0x03c00700,0x01c00f00,0x01f03e00,0x00fffc00,0x007ff800,0x001fe000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // b
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000fc000,0x003ff000,0x00fffc00,0x00f03c00,0x01e01e00,0x01c00e00,0x03c00f00,0x03800700,0x03800700,0x03800700,0x03800700,0x03800700,0x03800700,0x03c00f00,0x01c00600,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // c
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x001fe000,0x007ff800,0x00fffc00,0x01f03e00,0x01c00f00,0x03c00700,0x03800700,0x03800700,0x03800700,0x03800700,0x03800e00,0x03ffffff,0x01ffffff,0x01ffffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // d
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000fc000,0x007ff800,0x00fffc00,0x01f3be00,0x01c38e00,0x03c38f00,0x03838700,0x03838700,0x03838700,0x03838700,0x03838f00,0x03839e00,0x01c3fc00,0x01c3f800,0x0003e000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // e
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000700,0x00000700,0x00000700,0x00000700,0x03fffff0,0x03fffffc,0x03fffffe,0x0000071e,0x0000070f,0x00000707,0x00000707,0x00000707,0x00000707,0x00000707,0x0000000e,0x0000000e,0x00000000,0x00000000,0x00000000,0x00000000, // f
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x0007f000,0x381ffc00,0x783ffe00,0x70781f00,0x70f00700,0x70e00380,0x70e00380,0x70e00380,0x70e00380,0x78e00380,0x3c700380,0x3fffff80,0x1fffff00,0x07ffff00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // g
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03ffffff,0x03ffffff,0x03ffffff,0x00000700,0x00000700,0x00000700,0x00000700,0x00000700,0x00000f00,0x00001e00,0x03fffe00,0x03fffc00,0x03fff000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // h
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000700,0x00000700,0x00000700,0x00000700,0x0000070c,0x007fff1e,0x01ffff1e,0x01ffff0c,0x03c00000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x01c00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // i
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x60000000,0x70000000,0xf0000700,0xe0000700,0xe0000700,0xe0000700,0xe0000700,0xe0000700,0xf000070c,0x7000071e,0x7fffff1e,0x3fffff0c,0x0fffff00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // j
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03ffffff,0x03ffffff,0x03ffffff,0x00038000,0x0007c000,0x0007e000,0x000ef000,0x001c7800,0x00383c00,0x00f01e00,0x01f00f00,0x03c00700,0x03800300,0x03000100,0x02000000,0x00000000,0x00000000,0x00000000,0x00000000, // k
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000007,0x00000007,0x00000007,0x00000007,0x00000007,0x007fffff,0x01ffffff,0x01ffffff,0x03c00000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x01c00000,0x00000000,0x00000000,0x00000000,0x00000000, // l
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x03fffe00,0x03ffff00,0x03ffff00,0x00000700,0x00000700,0x00000700,0x00000f00,0x0007fe00,0x0007fe00,0x0007fe00,0x00000700,0x00000700,0x00000f00,0x03ffff00,0x03fffe00,0x03fff800,0x00000000,0x00000000,0x00000000,0x00000000, // m
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03fffe00,0x03fffe00,0x03ffff00,0x00000700,0x00000700,0x00000700,0x00000700,0x00000700,0x00000f00,0x00001e00,0x03fffe00,0x03fffc00,0x03fff000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // n
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x000fe000,0x007ff800,0x00fffc00,0x01f03e00,0x01c00e00,0x03800700,0x03800700,0x03800700,0x03800700,0x03800700,0x01c00e00,0x01f03e00,0x00fffc00,0x007ff800,0x001fe000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // o
|
||||||
|
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0xfffffe00,0xfffffe00,0xffffff00,0x01c00700,0x03800700,0x03800700,0x03800700,0x03800700,0x03800f00,0x01c00e00,0x01f03e00,0x00fffc00,0x007ff800,0x001fc000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // p
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x001fc000,0x007ff800,0x00fffc00,0x01f03e00,0x01c00e00,0x03800f00,0x03800700,0x03800700,0x03800700,0x03800700,0x01c00700,0xffffff00,0xfffffe00,0xfffffe00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // q
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03fffe00,0x03fffe00,0x03fffe00,0x00000f00,0x00000700,0x00000700,0x00000700,0x00000700,0x00000700,0x00000700,0x00000700,0x00000f00,0x00000700,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // r
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x01c07800,0x01c0fc00,0x0381fe00,0x0381cf00,0x0383c700,0x03838700,0x03878700,0x03870700,0x03870700,0x03cf0700,0x01fe0f00,0x01fc0e00,0x00780000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // s
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000700,0x00000700,0x00000700,0x00000700,0x007ffff8,0x01fffff8,0x01fffff8,0x03c00700,0x03800700,0x03800700,0x03800700,0x03800700,0x03800700,0x03800700,0x01c00700,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // t
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x003fff00,0x00ffff00,0x01ffff00,0x01e00000,0x03c00000,0x03800000,0x03800000,0x03800000,0x03800000,0x03800000,0x03ffff00,0x01ffff00,0x01ffff00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // u
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000300,0x00001f00,0x0000ff00,0x0007fe00,0x001ff000,0x007f8000,0x03fc0000,0x03f00000,0x03c00000,0x03f00000,0x03fc0000,0x007f8000,0x001ff000,0x0003fe00,0x0000ff00,0x00001f00,0x00000300,0x00000000,0x00000000,0x00000000,0x00000000, // v
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00001f00,0x0007ff00,0x01ffff00,0x03ffc000,0x03c00000,0x01f00000,0x003e0000,0x0007e000,0x0000f000,0x0007e000,0x007e0000,0x03f00000,0x03e00000,0x03ffe000,0x00ffff00,0x0007ff00,0x00001f00,0x00000000,0x00000000,0x00000000,0x00000000, // w
|
||||||
|
0x00000000,0x00000000,0x00000000,0x02000100,0x03800300,0x03c00700,0x03e01f00,0x00f83e00,0x007c7800,0x003ff000,0x000fe000,0x0007c000,0x000ff000,0x001ef800,0x007c3e00,0x01f01f00,0x03e00f00,0x03c00300,0x03000100,0x02000000,0x00000000,0x00000000,0x00000000,0x00000000, // x
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0xe0000300,0xe0001f00,0xe000ff00,0xe007fe00,0xe01ff000,0xf07f8000,0x7dfc0000,0x7ff00000,0x1fc00000,0x0ff80000,0x03ff0000,0x007fe000,0x001ffe00,0x0001ff00,0x00003f00,0x00000300,0x00000000,0x00000000,0x00000000,0x00000000, // y
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x03800700,0x03e00700,0x03f00700,0x03fc0700,0x03be0700,0x039f0700,0x0387c700,0x0383e700,0x0380f700,0x03807f00,0x03803f00,0x03801f00,0x03800700,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // z
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00018000,0x00018000,0x00018000,0x0003c000,0x1ffffff8,0x7ffe7ffc,0x7ffc3ffc,0xe0000004,0xc0000000,0xc0000000,0xc0000000,0xc0000000,0xc0000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // {
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0xffffffff,0xffffffff,0xffffffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // |
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0xc0000003,0xe0000007,0x7ffc3ffe,0x7ffe7ffe,0x1ffffff8,0x0003c000,0x00018000,0x00018000,0x00018000,0x00000000,0x00000000,0x00000000, // }
|
||||||
|
0x00000000,0x00000000,0x00000000,0x00000000,0x00000030,0x00000078,0x0000001c,0x0000000e,0x0000000e,0x0000000e,0x0000001e,0x0000001c,0x00000038,0x00000078,0x00000070,0x00000070,0x00000070,0x00000038,0x0000001e,0x0000000c,0x00000000,0x00000000,0x00000000,0x00000000 // ~
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
535
src/devices/Oled/SSD1306/OLEDDisplay.java
Normal file
535
src/devices/Oled/SSD1306/OLEDDisplay.java
Normal file
@@ -0,0 +1,535 @@
|
|||||||
|
package devices.Oled.SSD1306;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.DataBufferByte;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.Bit;
|
||||||
|
import jGPIO.I2C.I2C_BUS;
|
||||||
|
import jGPIO.I2C.I2C_Device;
|
||||||
|
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)"
|
||||||
|
})
|
||||||
|
@BA.ShortName("SSD1306_OLED")
|
||||||
|
|
||||||
|
//@SuppressWarnings("unused")
|
||||||
|
public class OLEDDisplay {
|
||||||
|
/**
|
||||||
|
* Used to specify the orientation of a display.
|
||||||
|
* This allows mounting the oled display upright or flipping it.
|
||||||
|
* <p>
|
||||||
|
* All rotation values are for clockwise rotation.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
protected enum Rotation {
|
||||||
|
DEG_0,
|
||||||
|
DEG_90,
|
||||||
|
DEG_180,
|
||||||
|
DEG_270
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int DISPLAY_WIDTH = 128;
|
||||||
|
private int DISPLAY_HEIGHT = 64;
|
||||||
|
private final int MAX_INDEX = (DISPLAY_HEIGHT / 8) * DISPLAY_WIDTH;
|
||||||
|
|
||||||
|
private final byte SSD1306_SETCONTRAST = (byte) 0x81;
|
||||||
|
private final byte SSD1306_DISPLAYALLON_RESUME = (byte) 0xA4;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final byte SSD1306_DISPLAYALLON = (byte) 0xA5;
|
||||||
|
private final byte SSD1306_NORMALDISPLAY = (byte) 0xA6;
|
||||||
|
private final byte SSD1306_INVERTDISPLAY = (byte) 0xA7;
|
||||||
|
private final byte SSD1306_DISPLAYOFF = (byte) 0xAE;
|
||||||
|
private final byte SSD1306_DISPLAYON = (byte) 0xAF;
|
||||||
|
|
||||||
|
private final byte SSD1306_SETDISPLAYOFFSET = (byte) 0xD3;
|
||||||
|
private final byte SSD1306_SETCOMPINS = (byte) 0xDA;
|
||||||
|
|
||||||
|
private final byte SSD1306_SETVCOMDETECT = (byte) 0xDB;
|
||||||
|
|
||||||
|
private final byte SSD1306_SETDISPLAYCLOCKDIV = (byte) 0xD5;
|
||||||
|
private final byte SSD1306_SETPRECHARGE = (byte) 0xD9;
|
||||||
|
|
||||||
|
private final byte SSD1306_SETMULTIPLEX = (byte) 0xA8;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final byte SSD1306_SETLOWCOLUMN = (byte) 0x00;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final byte SSD1306_SETHIGHCOLUMN = (byte) 0x10;
|
||||||
|
|
||||||
|
private final byte SSD1306_SETSTARTLINE = (byte) 0x40;
|
||||||
|
|
||||||
|
private final byte SSD1306_MEMORYMODE = (byte) 0x20;
|
||||||
|
private final byte SSD1306_COLUMNADDR = (byte) 0x21;
|
||||||
|
private final byte SSD1306_PAGEADDR = (byte) 0x22;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final byte SSD1306_COMSCANINC = (byte) 0xC0;
|
||||||
|
private final byte SSD1306_COMSCANDEC = (byte) 0xC8;
|
||||||
|
|
||||||
|
private final byte SSD1306_SEGREMAP = (byte) 0xA0;
|
||||||
|
|
||||||
|
private final byte SSD1306_CHARGEPUMP = (byte) 0x8D;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final byte SSD1306_EXTERNALVCC = (byte) 0x1;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final byte SSD1306_SWITCHCAPVCC = (byte) 0x2;
|
||||||
|
|
||||||
|
private final byte SSD1306_ACTIVATE_SCROLL = (byte) 0x2F;
|
||||||
|
private final byte SSD1306_DEACTIVATE_SCROLL = (byte) 0x2E;
|
||||||
|
private final byte SSD1306_SET_VERTICAL_SCROLL_AREA = (byte) 0xA3;
|
||||||
|
private final byte SSD1306_RIGHT_HORIZONTAL_SCROLL = (byte) 0x26;
|
||||||
|
private final byte SSD1306_LEFT_HORIZONTAL_SCROLL = (byte) 0x27;
|
||||||
|
private final byte SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = (byte) 0x29;
|
||||||
|
private final byte SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = (byte) 0x2A;
|
||||||
|
|
||||||
|
private I2C_BUS bus;
|
||||||
|
private I2C_Device device;
|
||||||
|
private Rotation rotation;
|
||||||
|
|
||||||
|
private byte[] imageBuffer;
|
||||||
|
|
||||||
|
private BA ba;
|
||||||
|
private Object caller;
|
||||||
|
private String eventname;
|
||||||
|
private final Object Me = this;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
private boolean device_opened = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize OLED Display
|
||||||
|
* @param caller : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object caller, String eventname) {
|
||||||
|
this.ba = ba;
|
||||||
|
this.caller = caller;
|
||||||
|
this.eventname = eventname.trim();
|
||||||
|
if (this.ba != null) {
|
||||||
|
if (this.caller != null) {
|
||||||
|
if (!this.eventname.isEmpty()) {
|
||||||
|
need_log_event = this.ba.subExists(this.eventname+"_log");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//add shutdown hook that clears the display
|
||||||
|
//and closes the bus correctly when the software
|
||||||
|
//if terminated.
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open
|
||||||
|
* @param busname : i2c bus name
|
||||||
|
* @param default_address : if true, will use default address 0x3C. If false, will use alternate address 0x3D
|
||||||
|
* @param Rotation_Mode : 0, 90, 180, or 270. Default at 0
|
||||||
|
* @param Width : width in pixel, usually 128
|
||||||
|
* @param Height : height in pixel, usually 64
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public boolean Open(String busname, boolean default_address, int Rotation_Mode, int Width, int Height) {
|
||||||
|
if (busname.isEmpty()) {
|
||||||
|
raise_log("Open failed, busname is empty");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Width < 1) {
|
||||||
|
raise_log("Open failed, Width must be positive number");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Height < 1) {
|
||||||
|
raise_log("Open failed, Height must be positive number");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DISPLAY_WIDTH = Width;
|
||||||
|
this.DISPLAY_HEIGHT = Height;
|
||||||
|
this.imageBuffer = new byte[(DISPLAY_WIDTH * DISPLAY_HEIGHT) / 8];
|
||||||
|
|
||||||
|
switch(Rotation_Mode){
|
||||||
|
case 90 :
|
||||||
|
this.rotation = Rotation.DEG_90;
|
||||||
|
break;
|
||||||
|
case 180 :
|
||||||
|
this.rotation = Rotation.DEG_180;
|
||||||
|
break;
|
||||||
|
case 270 :
|
||||||
|
this.rotation = Rotation.DEG_270;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.rotation = Rotation.DEG_0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bus = new I2C_BUS(busname);
|
||||||
|
if (bus.Open_Bus()) {
|
||||||
|
int address = 0x3C;
|
||||||
|
if (!default_address) address = 0x3D;
|
||||||
|
|
||||||
|
device = new I2C_Device(bus.I2C_Handle(), address);
|
||||||
|
if (device.OpenDevice_SLAVE()) {
|
||||||
|
device_opened = true;
|
||||||
|
|
||||||
|
clear();
|
||||||
|
init();
|
||||||
|
|
||||||
|
raise_log("OLEDDisplay opened");
|
||||||
|
return true;
|
||||||
|
} else raise_log("OLEDDisplay failed to create I2C_Device at address "+Bit.ToHexString(address));
|
||||||
|
} else raise_log("OLEDDisplay failed to open I2C_BUS at "+busname);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if OLEDDisplay is opened
|
||||||
|
* @return true if opened
|
||||||
|
*/
|
||||||
|
public boolean getIsOpened() {
|
||||||
|
return device_opened;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the display should be inverted
|
||||||
|
* @param invert Invert state
|
||||||
|
*/
|
||||||
|
public void invertDisplay(boolean invert) {
|
||||||
|
if (device_opened) {
|
||||||
|
if (invert) {
|
||||||
|
writeCommand(SSD1306_INVERTDISPLAY);
|
||||||
|
} else {
|
||||||
|
writeCommand(SSD1306_NORMALDISPLAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) ba.raiseEventFromDifferentThread(Me, null, 0, eventname+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void clear() {
|
||||||
|
if (imageBuffer!=null) Arrays.fill(imageBuffer, (byte) 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
switch (rotation) {
|
||||||
|
case DEG_90:
|
||||||
|
case DEG_270:
|
||||||
|
return DISPLAY_HEIGHT;
|
||||||
|
case DEG_0:
|
||||||
|
case DEG_180:
|
||||||
|
default:
|
||||||
|
return DISPLAY_WIDTH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
switch (rotation) {
|
||||||
|
case DEG_90:
|
||||||
|
case DEG_270:
|
||||||
|
return DISPLAY_WIDTH;
|
||||||
|
case DEG_0:
|
||||||
|
case DEG_180:
|
||||||
|
default:
|
||||||
|
return DISPLAY_HEIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean writeCommand(byte command) {
|
||||||
|
if (device!=null) {
|
||||||
|
if (device.WriteBytes(0, command)>0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean writeCommand(int command) {
|
||||||
|
return writeCommand((byte)command);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
if (device_opened) {
|
||||||
|
writeCommand(SSD1306_DISPLAYOFF); // 0xAE
|
||||||
|
writeCommand(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5
|
||||||
|
writeCommand((byte) 0x80); // the suggested ratio 0x80
|
||||||
|
writeCommand(SSD1306_SETMULTIPLEX); // 0xA8
|
||||||
|
writeCommand((byte) 0x3F);
|
||||||
|
writeCommand(SSD1306_SETDISPLAYOFFSET); // 0xD3
|
||||||
|
writeCommand((byte) 0x0); // no offset
|
||||||
|
writeCommand((byte) (SSD1306_SETSTARTLINE | 0x0)); // line #0
|
||||||
|
writeCommand(SSD1306_CHARGEPUMP); // 0x8D
|
||||||
|
writeCommand((byte) 0x14);
|
||||||
|
writeCommand(SSD1306_MEMORYMODE); // 0x20
|
||||||
|
writeCommand((byte) 0x00); // 0x0 act like ks0108
|
||||||
|
writeCommand((byte) (SSD1306_SEGREMAP | 0x1));
|
||||||
|
writeCommand(SSD1306_COMSCANDEC);
|
||||||
|
writeCommand(SSD1306_SETCOMPINS); // 0xDA
|
||||||
|
writeCommand((byte) 0x12);
|
||||||
|
writeCommand(SSD1306_SETCONTRAST); // 0x81
|
||||||
|
writeCommand((byte) 0xCF);
|
||||||
|
writeCommand(SSD1306_SETPRECHARGE); // 0xd9
|
||||||
|
writeCommand((byte) 0xF1);
|
||||||
|
writeCommand(SSD1306_SETVCOMDETECT); // 0xDB
|
||||||
|
writeCommand((byte) 0x40);
|
||||||
|
writeCommand(SSD1306_DISPLAYALLON_RESUME); // 0xA4
|
||||||
|
writeCommand(SSD1306_NORMALDISPLAY);
|
||||||
|
|
||||||
|
writeCommand(SSD1306_DEACTIVATE_SCROLL);
|
||||||
|
|
||||||
|
writeCommand(SSD1306_DISPLAYON);//--turn on oled panel
|
||||||
|
} else raise_log("Init failed, device not opened");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setPixel(int x, int y, boolean on) {
|
||||||
|
switch (rotation) {
|
||||||
|
default:
|
||||||
|
case DEG_0:
|
||||||
|
updateImageBuffer(x, y, on);
|
||||||
|
break;
|
||||||
|
case DEG_90:
|
||||||
|
updateImageBuffer(y, getWidth() - x - 1, on);
|
||||||
|
break;
|
||||||
|
case DEG_180:
|
||||||
|
updateImageBuffer(getWidth() - x - 1, getHeight() - y - 1, on);
|
||||||
|
break;
|
||||||
|
case DEG_270:
|
||||||
|
updateImageBuffer(getHeight() - y - 1, x, on);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void updateImageBuffer(int x, int y, boolean on) {
|
||||||
|
if (imageBuffer==null) return;
|
||||||
|
|
||||||
|
final int pos = x + (y / 8) * DISPLAY_WIDTH;
|
||||||
|
if (pos >= 0 && pos < MAX_INDEX) {
|
||||||
|
|
||||||
|
if (on) {
|
||||||
|
this.imageBuffer[pos] |= (1 << (y & 0x07));
|
||||||
|
} else {
|
||||||
|
this.imageBuffer[pos] &= ~(1 << (y & 0x07));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected synchronized void drawChar(char c, FontPack font, int x, int y, boolean on) {
|
||||||
|
font.drawChar(this, c, x, y, on);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a String at specific location
|
||||||
|
* x and y define as top-left of the String
|
||||||
|
* @param font : Font used for String
|
||||||
|
* @param string : string value
|
||||||
|
* @param x : coordinate X, start at 1
|
||||||
|
* @param y : coordinate Y, start at 1
|
||||||
|
*/
|
||||||
|
public synchronized void drawString(FontPack font, String string, int x, int y) {
|
||||||
|
if (font==null) return;
|
||||||
|
|
||||||
|
if (x<1) x = 1;
|
||||||
|
if (y<1) y = 1;
|
||||||
|
|
||||||
|
int posX = x;
|
||||||
|
int posY = y;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (char c : string.toCharArray()) {
|
||||||
|
if (c == '\n') {
|
||||||
|
posY += font.getOuterHeight();
|
||||||
|
posX = x;
|
||||||
|
} else {
|
||||||
|
if (posX >= 0 && posX + font.getWidth() < this.getWidth()
|
||||||
|
&& posY >= 0 && posY + font.getHeight() < this.getHeight()) {
|
||||||
|
drawChar(c, font, posX, posY, true);
|
||||||
|
}
|
||||||
|
posX += font.getOuterWidth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw string at centered location of Y
|
||||||
|
* Y is defined as top of the string
|
||||||
|
* @param font : Font used for drawStringCentered
|
||||||
|
* @param string : string value
|
||||||
|
* @param y : coordinate Y, start at 1
|
||||||
|
*/
|
||||||
|
public synchronized void drawStringCentered(FontPack font, String string, int y) {
|
||||||
|
if (font==null) return;
|
||||||
|
if (y<1) y = 1;
|
||||||
|
|
||||||
|
final int strSizeX = string.length() * font.getOuterWidth();
|
||||||
|
final int x = (this.getWidth() - strSizeX) / 2;
|
||||||
|
drawString(font,string, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a Character
|
||||||
|
* @param font FontPack used
|
||||||
|
* @param c character to draw
|
||||||
|
* @param x top left coordinate
|
||||||
|
* @param y top left coordiante
|
||||||
|
* @param on if on, then pixel show
|
||||||
|
*/
|
||||||
|
public synchronized void drawCharacter(FontPack font, char c, int x, int y, boolean on) {
|
||||||
|
if (font==null) return;
|
||||||
|
if (x<1) return;
|
||||||
|
if (y<1) return;
|
||||||
|
if (x>this.getWidth()) return;
|
||||||
|
if (y>this.getHeight()) return;
|
||||||
|
drawChar(c, font, x, y, on);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void clearRect(int x, int y, int width, int height, boolean on) {
|
||||||
|
for (int posX = x; posX < x + width; ++posX) {
|
||||||
|
for (int posY = y; posY < y + height; ++posY) {
|
||||||
|
setPixel(posX, posY, on);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gak guna
|
||||||
|
@BA.Hide
|
||||||
|
public void scrollHorizontally(boolean left, int start, int end) {
|
||||||
|
if (device_opened) {
|
||||||
|
writeCommand(left ? SSD1306_LEFT_HORIZONTAL_SCROLL : SSD1306_RIGHT_HORIZONTAL_SCROLL);
|
||||||
|
writeCommand(0);
|
||||||
|
writeCommand(start);
|
||||||
|
writeCommand(0);
|
||||||
|
writeCommand(end);
|
||||||
|
writeCommand(1);
|
||||||
|
writeCommand(0xFF);
|
||||||
|
writeCommand(SSD1306_ACTIVATE_SCROLL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// gak guna
|
||||||
|
@BA.Hide
|
||||||
|
public void scrollDiagonally(boolean left, int start, int end) {
|
||||||
|
if (device_opened) {
|
||||||
|
writeCommand(SSD1306_SET_VERTICAL_SCROLL_AREA);
|
||||||
|
writeCommand(0);
|
||||||
|
writeCommand(this.getHeight());
|
||||||
|
writeCommand(left ? SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL :
|
||||||
|
SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL);
|
||||||
|
writeCommand(0);
|
||||||
|
writeCommand(start);
|
||||||
|
writeCommand(0);
|
||||||
|
writeCommand(end);
|
||||||
|
writeCommand(1);
|
||||||
|
writeCommand(SSD1306_ACTIVATE_SCROLL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// gak guna
|
||||||
|
@BA.Hide
|
||||||
|
public void stopScroll() {
|
||||||
|
if (device_opened) {
|
||||||
|
writeCommand(SSD1306_DEACTIVATE_SCROLL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws the given image over the current image buffer. The image
|
||||||
|
* is automatically converted to a binary image (if it not already
|
||||||
|
* is).
|
||||||
|
* <p>
|
||||||
|
* Note that the current buffer is not cleared before, so if you
|
||||||
|
* want the image to completely overwrite the current display
|
||||||
|
* content you need to call clear() before.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param image
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
*/
|
||||||
|
public synchronized void drawImage(BufferedImage image, int x, int y) {
|
||||||
|
BufferedImage tmpImage = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_BYTE_BINARY);
|
||||||
|
tmpImage.getGraphics().drawImage(image, x, y, null);
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
int pixelval;
|
||||||
|
final byte[] pixels = ((DataBufferByte) tmpImage.getRaster().getDataBuffer()).getData();
|
||||||
|
for (int posY = 0; posY < DISPLAY_HEIGHT; posY++) {
|
||||||
|
for (int posX = 0; posX < DISPLAY_WIDTH / 8; posX++) {
|
||||||
|
for (int bit = 0; bit < 8; bit++) {
|
||||||
|
pixelval = (byte) ((pixels[index/8] >> (7 - bit)) & 0x01);
|
||||||
|
setPixel(posX * 8 + bit, posY, pixelval > 0);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sends the current buffer to the display
|
||||||
|
*/
|
||||||
|
public synchronized void update() {
|
||||||
|
if (device_opened) {
|
||||||
|
writeCommand(SSD1306_COLUMNADDR);
|
||||||
|
writeCommand((byte) 0); // Column start address (0 = reset)
|
||||||
|
writeCommand((byte) (DISPLAY_WIDTH - 1)); // Column end address (127 = reset)
|
||||||
|
|
||||||
|
writeCommand(SSD1306_PAGEADDR);
|
||||||
|
writeCommand((byte) 0); // Page start address (0 = reset)
|
||||||
|
writeCommand((byte) 7); // Page end address
|
||||||
|
|
||||||
|
for (int i = 0; i < ((DISPLAY_WIDTH * DISPLAY_HEIGHT / 8) / 16); i++) {
|
||||||
|
// send a bunch of data in one xmission
|
||||||
|
|
||||||
|
device.WriteBytes((byte) 0x40, imageBuffer, i * 16, 16);
|
||||||
|
}
|
||||||
|
} else raise_log("Unable to Update, device noot opened");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void shutdown() {
|
||||||
|
|
||||||
|
|
||||||
|
clear();
|
||||||
|
update();
|
||||||
|
|
||||||
|
|
||||||
|
if (device!=null) {
|
||||||
|
device.CloseDevice();
|
||||||
|
device = null;
|
||||||
|
}
|
||||||
|
//now we close the bus
|
||||||
|
if (bus!=null) {
|
||||||
|
bus.Close_Bus();
|
||||||
|
bus = null;
|
||||||
|
}
|
||||||
|
device_opened = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
151
src/devices/PCF8574.java
Normal file
151
src/devices/PCF8574.java
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
package devices;
|
||||||
|
|
||||||
|
import anywheresoftware.b4a.BA;
|
||||||
|
import anywheresoftware.b4a.keywords.Bit;
|
||||||
|
import jGPIO.I2C.I2C_BUS;
|
||||||
|
import jGPIO.I2C.I2C_Device;
|
||||||
|
|
||||||
|
@BA.ShortName("PCF8574")
|
||||||
|
@BA.Events(values= {
|
||||||
|
"log(msg as string)"
|
||||||
|
})
|
||||||
|
public class PCF8574 {
|
||||||
|
|
||||||
|
private BA bax;
|
||||||
|
private Object myobject;
|
||||||
|
private String event;
|
||||||
|
private boolean need_log_event = false;
|
||||||
|
|
||||||
|
private I2C_BUS i2cbus;
|
||||||
|
private I2C_Device i2cdev;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a PCF8574. Used in B4J only
|
||||||
|
* @param caller : caller object
|
||||||
|
* @param eventname : event name
|
||||||
|
*/
|
||||||
|
public void Initialize(BA ba, Object caller, String eventname) {
|
||||||
|
bax = ba;
|
||||||
|
myobject = caller;
|
||||||
|
event = eventname;
|
||||||
|
if (bax!=null) {
|
||||||
|
if (caller!=null) {
|
||||||
|
if (!event.isEmpty()) {
|
||||||
|
need_log_event = bax.subExists(event+"_log");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Slave
|
||||||
|
* @param bus_name : bus name of I2c
|
||||||
|
* @param slave_address : slave address of this PCF
|
||||||
|
* @return true if succcess
|
||||||
|
*/
|
||||||
|
public boolean Open(String bus_name, int slave_address) {
|
||||||
|
if (!jGPIO.jGPIO.IsLinux) return false;
|
||||||
|
i2cbus = new I2C_BUS(bus_name);
|
||||||
|
if (i2cbus.Open_Bus()) {
|
||||||
|
i2cdev = new I2C_Device(i2cbus.I2C_Handle(), slave_address);
|
||||||
|
if (i2cdev.OpenDevice_SLAVE()) {
|
||||||
|
raise_log("PCF8574 Address="+slave_address+" is opened");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raise_log("Failed to open PCF8574 Address="+slave_address);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check associated Slave Address
|
||||||
|
* @return -1 if no address
|
||||||
|
*/
|
||||||
|
public int getSlaveAddress() {
|
||||||
|
if (i2cdev instanceof I2C_Device)
|
||||||
|
return i2cdev.SlaveAddress();
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if I2C to this PCF is opened
|
||||||
|
* @return true if opened
|
||||||
|
*/
|
||||||
|
public boolean getIsOpened() {
|
||||||
|
if (i2cdev instanceof I2C_Device) {
|
||||||
|
return i2cdev.IsOpened();
|
||||||
|
} else return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close PCF8574
|
||||||
|
*/
|
||||||
|
public void Close() {
|
||||||
|
if (i2cdev instanceof I2C_Device) {
|
||||||
|
i2cdev.CloseDevice();
|
||||||
|
i2cdev = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i2cbus instanceof I2C_BUS) {
|
||||||
|
i2cbus.Close_Bus();
|
||||||
|
i2cbus = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a byte to i2C
|
||||||
|
* @param bb : byte to write
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
|
public synchronized boolean Write(byte bb) {
|
||||||
|
if (i2cbus instanceof I2C_BUS) {
|
||||||
|
if (i2cbus.IsOpened()) {
|
||||||
|
if (i2cdev instanceof I2C_Device) {
|
||||||
|
if (i2cdev.IsOpened()) {
|
||||||
|
if (i2cdev.WriteBytes(new byte[] {bb})>0) return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read from I2C. Result in int, but actually value will 0 - 255 (byte size)
|
||||||
|
* @return -1 if failed
|
||||||
|
*/
|
||||||
|
public synchronized int Read() {
|
||||||
|
if (i2cbus instanceof I2C_BUS) {
|
||||||
|
if (i2cbus.IsOpened()) {
|
||||||
|
if (i2cdev instanceof I2C_Device) {
|
||||||
|
if (i2cdev.IsOpened()) {
|
||||||
|
byte[] result = i2cdev.ReadBytes(1);
|
||||||
|
if (result!=null) {
|
||||||
|
return Bit.And(result[0], 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void raise_log(String msg) {
|
||||||
|
if (need_log_event) {
|
||||||
|
bax.raiseEventFromDifferentThread(myobject, null, 0, event+"_log", false, new Object[] {msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user