当前位置: 首页>>代码示例>>Python>>正文


Python streams.serial函数代码示例

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


在下文中一共展示了serial函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, serialport, baudrate=19200, heatTime=80, heatInterval=2, heatingDots=7):
        self.printer = streams.serial(serialport,baudrate)        
        self.write(self._ESC) # ESC - command
        self.write(chr(64)) # @   - initialize
        self.write(self._ESC) # ESC - command
        self.write(chr(55)) # 7   - print settings
        self.write(chr(heatingDots))  # Heating dots (20=balance of darkness vs no jams) default = 20
        self.write(chr(heatTime)) # heatTime Library default = 255 (max)
        self.write(chr(heatInterval)) # Heat interval (500 uS = slower, but darker) default = 250

        # Description of print density from page 23 of the manual:
        # DC2 # n Set printing density
        # Decimal: 18 35 n
        # D4..D0 of n is used to set the printing density. Density is 50% + 5% * n(D4-D0) printing density.
        # D7..D5 of n is used to set the printing break time. Break time is n(D7-D5)*250us.
        printDensity = 15 # 120% (? can go higher, text is darker but fuzzy)
        printBreakTime = 15 # 500 uS
        self.write(chr(18))
        self.write(chr(35))
        self.write(chr((printDensity << 4) | printBreakTime))
开发者ID:danielemazzei,项目名称:viper-thermal-printer-lib,代码行数:20,代码来源:thermalprinter.py

示例2: print

################################################################################
# Timers Basics
#
# Created by VIPER Team 2015 CC
# Authors: G. Baldi, D. Mazzei
################################################################################

import timers
import streams

#create a serial port with default parameters
streams.serial()

#create a new timer
t=timers.timer()
#start the timer
t.start()

minutes=0
   
while True:
    
    if t.get()>= 60000:        #check if 60 seconds are passed
        t.reset()              #timer can be reset
        minutes +=1
    seconds=t.get()//1000
    print("time is:", minutes,":",seconds) #just print the current value since timer starts or last reset
    print("System time is:", timers.now(), "(millis)") #timers.now() gives the system time in milliseconds since program starts
    print()
    
    sleep(500)                 #run every 500 millisec
开发者ID:viper-dev,项目名称:examples,代码行数:31,代码来源:main.py

示例3: printMessage

# VIPER IoT Notes Printer
#
# Created by VIPER Team 2015 CC
# Authors: G. Baldi, D. Mazzei
################################################################################

# import everything needed
import streams
from drivers.thermalprinter import thermalprinter
from wireless import wifi
from drivers.wifi.cc3000 import cc3000_tiny as cc3000
# and also import the viperapp module
from libs.apps import viperapp
p = thermalprinter.ThermalPrinter(SERIAL1,19200)

s=streams.serial()

# save the template.html in the board flash with new_resource
new_resource("template.html")

# connect to a wifi network
try:
    cc3000.auto_init()

    print("Establishing Link...")
    wifi.link("SSID_WiFi",wifi.WIFI_WPA2,"PWD_WiFi")
    print("Ok!")        
except Exception as e:
    print(e)

def printMessage(msg):
开发者ID:sebastian041965,项目名称:projects,代码行数:31,代码来源:main.py

示例4: connector

#
# Created by VIPER Team 2015 CC
# Authors: D. Mazzei, G. Baldi,  
###############################################################################

import streams

from drivers.thermalprinter import thermalprinter

# create a printer passing to the class the serial port name. Printer RX wire have to be connected 
# to the selected serial port TX pin. The default baudrate for the thermal printers is 19200
# In this case SERIAL1 is used. In Arduino the serial 1 TX pin is D18 while in the Nucleo is on the morphos connector (seventh from the top on the right series)
p = thermalprinter.ThermalPrinter(SERIAL1,19200)

# another serial port for printign on the console
s= streams.serial(SERIAL0)

def test(printer):  
    # print_text(msg,"a","s") takes as input a string containing the massage and two characters for the definition of the a:allignment and s:syle    
    # first character denotes justification (l=left, c=centre, r=right)
    # second character denotes style (n=normal, b=bold, u=undfrom drivers.thermalprinter erline, i=inverse, f=font B)
    # normal style with left alignment is the default
    # \n is required for line termination
    
    p.print_text("Default\n")
    p.print_text("Left and Bold\n","l","b")
    p.print_text("Center and Underlined\n","c","u")
    p.print_text("Right and Inverted\n","r","i")
    p.print_text("Left and Font B\n\n","l","f")    

    #print_text also supports auto line ending giving as input chars_per_line as last parameter
开发者ID:viper-dev,项目名称:examples,代码行数:31,代码来源:main.py


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