• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Uart类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ioio.lib.api.Uart的典型用法代码示例。如果您正苦于以下问题:Java Uart类的具体用法?Java Uart怎么用?Java Uart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Uart类属于ioio.lib.api包,在下文中一共展示了Uart类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createIOIOLooper

import ioio.lib.api.Uart; //导入依赖的package包/类
@Override
protected IOIOLooper createIOIOLooper() {
    return new BaseIOIOLooper(){
        Uart uart;
        OutputStream ostream;

        @Override
        protected void setup() throws ConnectionLostException, InterruptedException {
            Thread.sleep(5000);
            //led_ = ioio_.openDigitalOutput(0, true);
            uart = ioio_.openUart(35,34,57600, Uart.Parity.NONE, Uart.StopBits.ONE);
            ostream = uart.getOutputStream();
        }
        @Override
        public void loop() throws ConnectionLostException, InterruptedException {
            try {
                ostream.write("sending data".getBytes());
                Thread.sleep(100);
            }
            catch (IOException ex) {
                //showToast("CommunicationThread: "+ ex.getMessage());
                Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    };
}
 
开发者ID:mike168m,项目名称:USLI2018,代码行数:27,代码来源:CommuncationService.java


示例2: setup

import ioio.lib.api.Uart; //导入依赖的package包/类
/**
 * Called every time a connection with MOIO has been established.
 * Typically used to open pins.
 */
@Override
protected void setup() throws ConnectionLostException {
	
	// notifies the user when connected to the MOIO, displays a toast that reads 'READY!!!'
	on_notify();
	
	// initialize all of the interface options with specific pin numbers
	analogin_ = ioio_.openAnalogInput(31); //pin31, must not be more than 3.3V	
	led_ = ioio_.openDigitalOutput(0, true); // start with the on board LED off
	pushbutton_ = ioio_.openDigitalInput(1, DigitalInput.Spec.Mode.PULL_UP); //pin1 is digital input, use pullup so that button can be connected to ground
	pwm_ = ioio_.openPwmOutput(2, 50); //pin2 with 50Hz frequency - if using a servo, a greater frequency will create jitter
	sendreceive_ = ioio_.openUart(3, 4, 9600, Uart.Parity.NONE, Uart.StopBits.ONE ); //pin3 tx, pin4 rx, baud rate 9600 
	rx_ = sendreceive_.getInputStream();
	tx_ = sendreceive_.getOutputStream();
}
 
开发者ID:victordiaz,项目名称:MakeWithMotoSampleApp,代码行数:20,代码来源:ActivityMOIO.java


示例3: setup

import ioio.lib.api.Uart; //导入依赖的package包/类
@Override
public void setup() throws ConnectionLostException {
    uart = ioio_.openUart(RX_PIN, TX_PIN, 9600, Uart.Parity.NONE, Uart.StopBits.ONE);
    out = uart.getOutputStream();
    in = uart.getInputStream();

    led = ioio_.openDigitalOutput(0, true);

    toggleUi(true);
    toast("IOIO Connected");
}
 
开发者ID:infil00p,项目名称:ELControl,代码行数:12,代码来源:MainActivity.java


示例4: uartConfigure

import ioio.lib.api.Uart; //导入依赖的package包/类
synchronized public void uartConfigure(int uartNum, int rate,
		boolean speed4x, Uart.StopBits stopbits, Uart.Parity parity)
		throws IOException {
	int parbits = parity == Uart.Parity.EVEN ? 1
			: (parity == Uart.Parity.ODD ? 2 : 0);
	beginBatch();
	writeByte(UART_CONFIG);
	writeByte((uartNum << 6) | (speed4x ? 0x08 : 0x00)
			| (stopbits == Uart.StopBits.TWO ? 0x04 : 0x00) | parbits);
	writeTwoBytes(rate);
	endBatch();
}
 
开发者ID:jrieke,项目名称:ioiometer,代码行数:13,代码来源:IOIOProtocol.java


示例5: openUart

import ioio.lib.api.Uart; //导入依赖的package包/类
@Override
public Uart openUart(int rx, int tx, int baud, Uart.Parity parity,
		Uart.StopBits stopbits) throws ConnectionLostException {
	return openUart(rx == INVALID_PIN ? null : new DigitalInput.Spec(rx),
			tx == INVALID_PIN ? null : new DigitalOutput.Spec(tx), baud,
			parity, stopbits);
}
 
开发者ID:jrieke,项目名称:ioiometer,代码行数:8,代码来源:IOIOImpl.java


示例6: uartConfigure

import ioio.lib.api.Uart; //导入依赖的package包/类
synchronized public void uartConfigure(int uartNum, int rate, boolean speed4x,
                                       Uart.StopBits stopbits, Uart.Parity parity) throws IOException {
    int parbits = parity == Uart.Parity.EVEN ? 1 : (parity == Uart.Parity.ODD ? 2 : 0);
    beginBatch();
    writeByte(UART_CONFIG);
    writeByte((uartNum << 6) | (speed4x ? 0x08 : 0x00)
            | (stopbits == Uart.StopBits.TWO ? 0x04 : 0x00) | parbits);
    writeTwoBytes(rate);
    endBatch();
}
 
开发者ID:flyver,项目名称:Flyver-Apps,代码行数:11,代码来源:IOIOProtocol.java


示例7: openUart

import ioio.lib.api.Uart; //导入依赖的package包/类
@Override
public Uart openUart(int rx, int tx, int baud, Uart.Parity parity,
                     Uart.StopBits stopbits) throws ConnectionLostException {
    return openUart(rx == INVALID_PIN ? null : new DigitalInput.Spec(rx),
            tx == INVALID_PIN ? null : new DigitalOutput.Spec(tx), baud,
            parity, stopbits);
}
 
开发者ID:flyver,项目名称:Flyver-Apps,代码行数:8,代码来源:IOIOImpl.java


示例8: uartConfigure

import ioio.lib.api.Uart; //导入依赖的package包/类
synchronized public void uartConfigure(int uartNum, int rate, boolean speed4x,
		Uart.StopBits stopbits, Uart.Parity parity) throws IOException {
	int parbits = parity == Uart.Parity.EVEN ? 1 : (parity == Uart.Parity.ODD ? 2 : 0);
	beginBatch();
	writeByte(UART_CONFIG);
	writeByte((uartNum << 6) | (speed4x ? 0x08 : 0x00)
			| (stopbits == Uart.StopBits.TWO ? 0x04 : 0x00) | parbits);
	writeTwoBytes(rate);
	endBatch();
}
 
开发者ID:edarn,项目名称:kryp-client,代码行数:11,代码来源:IOIOProtocol.java


示例9: closeConnection

import ioio.lib.api.Uart; //导入依赖的package包/类
/** Closes the UART connection if exists. Does not disconnect the IOIO.
 *
 */
public void closeConnection(){
    if(Uart!=null) Uart.close();
}
 
开发者ID:zaiddabaeen,项目名称:XBeeIOIO,代码行数:7,代码来源:Xbee.java


示例10: createIOIOLooper

import ioio.lib.api.Uart; //导入依赖的package包/类
/** Creates a new connection to an Xbee device.
 *
 * This must be constructed inside a BaseIOIOLooper constructor. Example:
 *<pre>{@code {@literal @}Override
protected IOIOLooper createIOIOLooper() {
return new BaseIOIOLooper() {
{@literal @}Override
protected void setup() throws ConnectionLostException {
Xbee xbee = new Xbee(ioio_, 45, 46, 9600);
}
}
 *}</pre>
 * @param ioio The IOIO device to connect through.
 * @param rX_pin The receiver pin. Must be 3.3V tolerant and must support UART/USART connection.
 * @param tX_pin The transmitter pin. Must be 3.3V tolerant and must support UART/USART connection.
 * @param baud_rate The baud rate of the connection. Must match the baud rate of the Xbee device.
 * The supported standard baud rates are 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 bps, and any non-standard
 * baud rates in the range 0x80 - 0x3D090 bps.
 * @throws ConnectionLostException Thrown when the connection to the IOIO has been lost or disconnected.
 *
 */
public Xbee(IOIO ioio, int rX_pin, int tX_pin, int baud_rate) throws ConnectionLostException{

    this.Ioio = ioio;
    this.Baud_rate = baud_rate;

    Uart = ioio.openUart(rX_pin, tX_pin, baud_rate, Parity.NONE, StopBits.ONE);
    In = Uart.getInputStream();
    Out = Uart.getOutputStream();

    InReader = new BufferedReader(new InputStreamReader(In));
    OutWriter = new BufferedWriter(new OutputStreamWriter(Out));

}
 
开发者ID:zaiddabaeen,项目名称:XBeeIOIO,代码行数:35,代码来源:Xbee.java



注:本文中的ioio.lib.api.Uart类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DescribeAutoScalingGroupsResult类代码示例发布时间:2022-05-22
下一篇:
Java NegatedRequestMatcher类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap