Example #1
0
 def home(self):
     """
     """
     # set cursor position to zero
     self.command(LCD_RETURNHOME)
     # this command takes a long time!
     sys.wait(2)  
Example #2
0
def wait_a_bit():
  global i;
  i= (i+1) & 0xfff
  if(15==i & 15):
    sys.gc()     # clean up
  else:
    sys.wait(4)  # wait a bit
Example #3
0
    def clear(self):
        # clear display, set cursor position to zero
        self.command(LCD_CLEARDISPLAY)
        # this command takes a long time!
        sys.wait(2)  

        # clean up
        sys.gc()
Example #4
0
def thread_in():
	while 1:
		sys.wait(300)
		state1 = len_digIO.getDigIn(len_contr.DEV_CTRL, 0, 0)
		counter1 = len_digIO.getCounterIn_er(len_contr.DEV_CTRL, 0, 0)
		state2 = len_digIO.getDigIn(len_contr.DEV_CTRL, 0, 1)
		counter2 = len_digIO.getCounterIn(len_contr.DEV_CTRL, 0, 1)
		num += 1
		print "Times:",num," State1:",state1," Counter1:",counter1," State2:",state2," Counter2:",counter2
Example #5
0
def print_temperature(sensor):
    tm = Time(True)
    high = False
    while True:
        temp = sensor.read()
        tm.now()
        print "[python]:    Temperature: %f at %s" % (temp, tm.to_string())

        if high:
            avr.port_and(avr.portb, 0x7F)
            high = False
        else:
            avr.port_or(avr.portb, 0x80)
            high = True

        sys.wait(1000)
Example #6
0
def print_eeprom_and_sram():
    while True:
        sram_data = ram.read_list(len(ram_lst), True, addr)
        ee_data = ee.read_list(len(data_ary), True, addr)

        if len(ee_data) is 0:
            continue

        vlength = math.hypot(2.0, 2.0)
        if len(sram_data) is not 0:
            sram_data = math.sin(sram_data[2] / 2.0)
        else:
            sram_data = 0.0

        print "[python]:    EEPROM: %f and %f" % (ee_data[4], ee_data[5])
        print "[python]:    SRAM: %f :: Length of (2, 2): %f" % (sram_data,
                                                                 vlength)
        sys.wait(1000)
Example #7
0
 def pulseEnable(self) :
     """
     """
     self.dg_write(self.enable_pin, gpio.LOW)
     sys.wait(1)
     self.dg_write(self.enable_pin, gpio.HIGH)
     # enable pulse must be >450ns
     sys.wait(1)
     self.dg_write(self.enable_pin, gpio.LOW)
     # commands need > 37us to settle
     sys.wait(1)
Example #8
0
# This file is Copyright 2010 Dean Hall.
#
# This file is part of the Python-on-a-Chip program.
# Python-on-a-Chip is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
#
# Python-on-a-Chip is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
# is seen in the file COPYING up one directory from this.

#
# System Test 290
# Add wait() to sys module
#

import sys

# Really short waits
sys.wait(-1)
sys.wait(0)
sys.wait(1)

# Longer wait
print "Waiting 3 secs..."
sys.wait(3000)
print "done."
Example #9
0
import sys, len_sys, len_contr, len_error, len_mqtt


def MQTT_callback():
    callback_val = len_sys.getCallbackValue()
    print "MQTT callback ip:", callback_val[0], " port:", callback_val[
        1], " topic:", callback_val[2], " message:", callback_val[3]
    len_sys.ClearCallback()


print "\n\rStart"

#Ждем подключения
while (len_mqtt.getStatus() != len_mqtt.MQTT_CONNECTED):
    print "MQTT wait"
    sys.wait(1000)

print "MQTT connected"

#Подписаться на топик
len_mqtt.subTopic("lenp_sub")

#Добавить callback
len_sys.addCallback(MQTT_callback)

while 1:
    len_mqtt.pubMessage("lenp_pub", "from controller")
    sys.wait(1000)
Example #10
0
def wait_BTN_release():
  while 1==x.BTN(): # waiting for release USER BUTTON
    sys.gc()     # clean up
    sys.wait(100)
Example #11
0
import shutil
import os
import datetime
import sys
import time

x = 1
source = 'C:\\adi_tmp_dir\\mock_dir\\'
dest = 'C:\\Save_test\\'

while x:
    timestamp = datetime.datetime.now()
    for adi_dir, dirs, files in os.walk(source):
        for file in files:
            sys.wait(60 * 5)
            source_path = source + file
            file_creation_time = os.path.getmtime(source_path)
            print(file_creation_time)
            dest_path = dest + file + timestamp.strftime('-%Y%m%dT%H%M%S')
            print(dest_path)
            if not os.path.exists(dest_path):
                try:
                    os.makedirs(os.path.dirname(dest_path))
                except OSError as exc:  # Guard against race condition
                    if exc.errno != errno.EEXIST:
                        raise
            shutil.copyfile(source_path, dest_path)
Example #12
0
    def begin(self, cols, lines, dotsize=0):
        """
        """
        if lines > 1 :
            self._displayfunction |= LCD_2LINE

        self._numlines = lines
        self._currline = 0
        
        if dotsize != 0 and lines == 1 :
            self._displayfunction |= LCD_5x10DOTS

        # SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
        # according to datasheet, we need at least 40ms after power rises above 2.7V
        # before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
        # delayMicroseconds(50000); 
        sys.wait(50)

        # Now we pull both RS and R/W low to begin commands
        self.dg_write(self.rs_pin, gpio.LOW)
        self.dg_write(self.enable_pin, gpio.LOW)

        if self.rw_pin != 255 : 
              self.dg_write(self.rw_pin, gpio.LOW)

        # //put the LCD into 4 bit or 8 bit mode
        if not (self._displayfunction & LCD_8BITMODE) :
           # this is according to the hitachi HD44780 datasheet
           # figure 24, pg 46
           # we start in 8bit mode, try to set 4 bit mode
           self.write4bits(0x03)
           # wait min 4.1ms
           sys.wait(4)
           # second try
           self.write4bits(0x03)
           # wait min 4.1ms
           sys.wait(4)
           # third go!
           self.write4bits(0x03) 
           sys.wait(2)

           # finally, set to 4-bit interface
           self.write4bits(0x02) 
        else :
           # this is according to the hitachi HD44780 datasheet
           # page 45 figure 23

           # Send function set command sequence
           self.command(LCD_FUNCTIONSET | self._displayfunction)
           # wait more than 4.1ms
           sys.wait(5)
           # second try
           self.command(LCD_FUNCTIONSET | self._displayfunction)
           sys.wait(1)

           # third go
           self.command(LCD_FUNCTIONSET | self._displayfunction)

        # finally, set # lines, font size, etc.
        self.command(LCD_FUNCTIONSET | self._displayfunction)

        # turn the display on with no cursor or blinking default
        self._displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF

        self.display()

        # clear it off
        self.clear()

        # Initialize to default text direction (for romance languages)
        self._displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT

        # set the entry mode
        self.command(LCD_ENTRYMODESET | self._displaymode)

        # clean up
        sys.gc()
Example #13
0
import sys, len_sys, len_digIO, len_contr, len_error

len_digIO.setModeOut(len_contr.DEV_CTRL, 0, 1, len_digIO.PWM_MODE)

while 1:
    len_digIO.setPwmOut(len_contr.DEV_CTRL, 0, 1, 30)
    sys.wait(500)
    len_digIO.setPwmOut(len_contr.DEV_CTRL, 0, 1, 100)
    sys.wait(500)
Example #14
0
def thread_out():
	while 1:
		len_digIO.setPwmOut(len_contr.DEV_CTRL,0,1,30)
		sys.wait(500)
		len_digIO.setPwmOut(len_contr.DEV_CTRL,0,1,100)
		sys.wait(500)