from oled import Oled from temp_sensor import TempSensor from machine_process import MachineProcess from umqtt.simple import MQTTClient oled = Oled(64, 48, 4, 5) try: temp_sensor = TempSensor(12) except: MachineProcess.show_information_about_problem_with_sensor_on_oled(oled) raise mqtt_client = MQTTClient('machine_1', '192.168.1.133') machine_process = MachineProcess(machine_id='machine_1', oled=oled, temp_sensor=temp_sensor, mqtt=mqtt_client) def start(): machine_process.start_machine_process()
is display as pattern on OxoCard matrix display. 2021-03-27 Claus Kühnel [email protected] ''' from oxocardext import * from machine import Pin, I2C from oled import Oled import time import adafruit_sgp30 # Initialize I2C bus i2c = I2C(scl=Pin(22), sda=Pin(21)) #Initialize OLED oled = Oled() # Create library object on I2C bus sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c) # Retrieve previously stored baselines, if any (helps the compensation algorithm). has_baseline = False baseline_time = 0 #Read sensor values from SHT30 def readSHT30(): buf = bytearray(2) buf[0] = 0x30 buf[1] = 0xA2 i2c.writeto(0x44, buf)
from player import Player from button import Button from oled import Oled from time import sleep PIN_UP = 17 PIN_DOWN = 27 button_up = Button(PIN_UP) button_down = Button(PIN_DOWN) player = Player() player.start() oled = Oled() while True: oled.update(player.get_station(), player.get_info()) if (button_up.pressed()): player.up() if (button_down.pressed()): player.down() sleep(1)
def run(): oled = Oled(12, 2, 15, 14, 13, 4) ssd = oled.ssd #home=14, left=13 right=11 back=7 key = Key(33, 25, 26, 32) key.start() keyvalue = 15 menu_index = 1 menu = Menu(ssd, jsonfile) def lowpower(ssd): ssd.poweroff() machine.deepsleep() wake1 = Pin(33, mode=Pin.IN) #level parameter can be: esp32.WAKEUP_ANY_HIGH or esp32.WAKEUP_ALL_LOW esp32.wake_on_ext0(pin=wake1, level=esp32.WAKEUP_ALL_LOW) time_cnt = 0 clock = Clock(ssd, key) alarm = Alarm(ssd, key, jsonfile) compass = Compass(ssd, key) weather = Weather(ssd, key, jsonfile) appstore = Appstore(ssd, key, jsonfile) sysset = Sysset(ssd, key, jsonfile) menu_dic = { 1: menu.clock, 2: menu.alarm, 3: menu.compass, 4: menu.weather, 5: menu.appstore, 6: menu.sysset } menu_event = { 1: clock.run, 2: alarm.run, 3: compass.run, 4: weather.run, 5: appstore.run, 6: sysset.run } while True: # time.sleep_ms(200) #time_cnt+=1 #if time_cnt>50: # lowpower(ssd) if key.read() == key.LEFT_PRESS: time_cnt = 0 menu_index = menu_index - 1 if menu_index <= 1: menu_index = 1 time.sleep_ms(200) elif key.read() == key.RIGHT_PRESS: time_cnt = 0 menu_index = menu_index + 1 if menu_index >= 6: menu_index = 6 time.sleep_ms(200) menu.disSensor(90, 0, 0.57) menu_dic[menu_index]() if key.read() == key.HOME_PRESS: time_cnt = 0 ssd.fill(0) menu_event[menu_index]() ssd.fill(0) time.sleep_ms(200)
def display(): myScreen = Oled(csPin, dcPin, sdinPin, sclkPin, rstPin) myScreen.screenInit() myScreen.clearAll() lenCommand = len(sys.argv) for i in range(1, lenCommand, 2): if str.upper(sys.argv[i]) == 'IMAGE': myScreen.displayImage( fileName=sys.argv[i + 1] if lenCommand > i + 1 else 'git.png') elif str.upper(sys.argv[i]) == 'CHN': myScreen.displayChn( chnStr=sys.argv[i + 1].decode('utf8') if lenCommand > i + 1 else u'\u6837\u672C') elif str.upper(sys.argv[i]) == 'ASC': myScreen.displayAsc( ascStr=sys.argv[i + 1] if lenCommand > i + 1 else 'example') else: return 0 return 1
#!/usr/bin/python '''Test switch hardware with output to local oled.''' import os import sys # required for sys.exit() import time, datetime, argparse, logging import RPi.GPIO as GPIO from gpio import Gpio from oled import Oled myGpio=Gpio() myOled=Oled(4) myGpio.setup() myOled.writerow(1,'Switch test') a = [17,18,21,22,23,24,25,4] b = [0,0,0,0,0,0,0,0] for i in range(len(a)): GPIO.setup(a[i],GPIO.IN) print a[i]," ", print print 'Next Stop Vol+ Vol- - - - -' time.sleep(1) myOled.writerow(1,str(a[0])+' '+str(a[1])+' '+str(a[2])+' '+str(a[3])+' '+str(a[4])+' '+str(a[5])) myOled.writerow(3,str(a[6])+' '+str(a[7])) while True: for i in range(len(a)): print GPIO.input(a[i])," ", b[i] = GPIO.input(a[i]) print
from gnss_device.ublox import UBlox ublox = UBlox(config_settings['gnss_port'], baudrate=config_settings['gnss_port_baud'], timeout=0.01) def save_config(): with open('./config.yml', 'w') as file: documents = yaml.dump(config_settings, file) dev = not socket.gethostname() == 'raspberrypi' if not dev: import psutil from oled import Oled oled = Oled(dev=dev) def get_ip(): global dev if dev: ip = list( map(int, socket.gethostbyname(socket.gethostname()).split("."))) else: ip = list( map( int, subprocess.check_output( "hostname -I", shell=True).decode("utf-8").split(".")))
going_idle_sequence = [[50,0,50,0],[1,0,1,200],[50,0,50,200]] rgbled = RgbLed.Worker(RGB_PIN_R, RGB_PIN_G, RGB_PIN_B) rgbled.set_sequence(boot_sequence) rgbled.start() ENCODER_PIN_A = 7 ENCODER_PIN_B = 8 encoder = RotaryEncoder.Worker(ENCODER_PIN_A, ENCODER_PIN_B) encoder.start() SWITCH_PIN = 9 switch = Switch(SWITCH_PIN) switch_state = switch.get_state() oled = Oled() contrast = 0 oled.ssd1306.set_contrast(contrast) rgbled.set_sequence(startup_sequence) SPREADSHEET_NAME = 'TimeClock' SPREADSHEET_TEMPLATE = 'TimeClock.ods' ss = Spreadsheet() if not ss.oauth.has_token(): user_code = ss.oauth.get_user_code() print "Go to %s and enter the code %s" % (ss.oauth.verification_url, user_code) # need a font that will show us the full code without scrolling from gaugette.fonts import arial_24 oled.ssd1306.clear_display()