# ninedof = sensor.sensor() # ninedof.start() #except IOError: # logging.error("9dof sensor init error", exc_info=True) # ninedof = None ninedof = None logging.getLogger().setLevel(logging.INFO) logging.info("Logging started") signal.signal(signal.SIGINT, signal_quitting) # Configuration parameters # I2C Address, Port, Enable pin, RW pin, RS pin, Data 4 pin, Data 5 pin, Data 6 pin, Data 7 pin, Backlight pin (optional) i2cLock.acquire() try: lcd = i2c_lcd.i2c_lcd(0x27, 1, 2, 1, 0, 4, 5, 6, 7, 3) lcd.backLightOn() except IOError: #logging.error("LCD IO Error", exc_info=True) lcd = None finally: i2cLock.release() try: strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS) strip.begin() except: logging.error("LED Error", exc_info=True) strip = None
while True: for i in range(0, len(my_long_string)): lcd_text = my_long_string[i:(i + 17)] lcd.setPosition(1, 0) lcd.writeString(lcd_text) time.sleep(0.1) lcd.writeString(str_pad) channel = 12 data = [] j = 0 # Configuration parameters # I2C Address, Port, Enable pin, RW pin, RS pin, Data 4 pin, Data 5 pin, Data 6 pin, Data 7 pin, Backlight pin (optional) lcd = i2c_lcd.i2c_lcd(0x27, 1, 2, 1, 0, 4, 5, 6, 7, 3) lcd.backLightOn() lcd.command(lcd.CMD_Display_Control | lcd.OPT_Enable_Display) # If you want to disable the cursor, uncomment the following line # lcd.command(lcd.CMD_Display_Control | lcd.OPT_Enable_Display) #lcd.writeString("TEST") #time.sleep(1) GPIO.setmode(GPIO.BOARD) time.sleep(1) try: while True: data = [] j = 0
# 設定の取得 ini = configparser.SafeConfigParser() ini.read(configfile) p = subprocess.Popen(os.path.dirname(os.path.abspath(__file__)) + "/geti2caddress.sh ", stdout=subprocess.PIPE, shell=True) i2c_addr = p.stdout.readline().strip().decode('utf-8') #print (i2c_addr) logging.basicConfig( format='%(asctime)s %(filename)s %(lineno)d %(levelname)s %(message)s', filename='/home/pi/LOG/clock_note.engine.log', level=logging.DEBUG) lcd = i2c_lcd.i2c_lcd(int("0x" + i2c_addr, 0), 0, 2, 1, 0, 4, 5, 6, 7, 3) def msg_log(msg_str): print(str(inspect.currentframe().f_lineno) + " " + msg_str) logging.info(str(inspect.currentframe().f_lineno) + " " + msg_str) def msg_err_log(msg_str): print(str(inspect.currentframe().f_lineno) + " " + msg_str) logging.error(str(inspect.currentframe().f_lineno) + " " + msg_str) def say(phrase): try: if ini.get("path", "say_path"): # settings is NOT null then
import inspect import requests import configparser # 定数 configfile = os.path.dirname(os.path.abspath(__file__))+'/clock_note.ini' # 設定の取得 ini = configparser.SafeConfigParser() ini.read(configfile) p = subprocess.Popen( os.path.dirname(os.path.abspath(__file__))+"/geti2caddress.sh ", stdout=subprocess.PIPE, shell=True) i2c_addr = p.stdout.readline().strip().decode('utf-8') #print (i2c_addr) logging.basicConfig(format='%(asctime)s %(filename)s %(lineno)d %(levelname)s %(message)s',filename='/home/pi/LOG/clock_note.engine.log',level=logging.DEBUG) lcd = i2c_lcd.i2c_lcd(int("0x" + i2c_addr,0),0, 2, 1, 0, 4, 5, 6, 7, 3) def msg_log(msg_str): print (str(inspect.currentframe().f_lineno) + " " + msg_str) logging.info(str(inspect.currentframe().f_lineno) + " " + msg_str) def msg_err_log(msg_str): print (str(inspect.currentframe().f_lineno) + " " + msg_str) logging.error(str(inspect.currentframe().f_lineno) + " " + msg_str) def say(phrase): try: if ini.get("path", "say_path"): # settings is NOT null then payload = {'phrase': phrase} r = requests.post(ini.get("path", "say_path"), data=payload, timeout=10, verify=False) except: