예제 #1
0
# hello world on SSD1306
# uses version of SSD1306.py and font.py
# https://github.com/jeffmer/micropython-upybbot/blob/master/ssd1306.py
# graphics library lcd_gfx.py from
# http://forum.micropython.org/viewtopic.php?f=5&t=195&p=873&hilit=lcd_gfx#p873

import pyb
from ssd1306 import SSD1306
import lcd_gfx

oled = SSD1306(pinout={'dc': 'X4', 'res': 'X3'}, height=64, external_vcc=False)

oled.poweron()
oled.init_display()

oled.clear()
## text
oled.text('Hello World!', 20, 55)
oled.display()
pyb.delay(2000)

## draw straight lines
for x in [0, 127]:
    for y in range(64):
        oled.pixel(x, y, True)
for y in [0, 47, 48, 63]:
    for x in range(127):
        oled.pixel(x, y, True)

oled.display()
pyb.delay(2000)
예제 #2
0
import pyb
from ssd1306 import SSD1306


display = SSD1306(pinout={'dc': 'PB7',
                          'res': 'PB8'},
                  height=64,
                  external_vcc=False)

display.poweron()
display.init_display()
display.draw_text(1,1,'Hello EveryOne',size=1,space=1)
display.draw_text(1,10,'Micropython F407',size=1,space=1)
display.draw_text(1,20,'Let Us Do it',size=1,space=1)
# 显示出你想要显示的内容
display.display()
 
예제 #3
0
for c in s:
    bits = font.getbitmap_str(ord(c))
    for idx, bit in enumerate(bits):
        if int(bit):
            x, y = x0 + (idx % font.w), y0 + (idx // font.h)
            d.rect(x0 + (x * size), y0 + (y * size), size, size, 1)
    x0 += font.w - 1
d.show()
# --------------------------------------------------------

# --------------------------------------------------------
import machine, math
from ssd1306 import SSD1306
from d2 import rotate

d = SSD1306(machine.I2C(scl=machine.Pin(4), sda=machine.Pin(5)))

cx, cy = d.width // 2 - 1, d.height // 2 - 1
yd = 0
i = 0
di = 1
while True:
    points = []
    for a in range(0, 360, 60):
        points.append(rotate(cx, cy - i, cx, cy, math.radians(a + yd)))
    d.fill(0)
    for p1 in points:
        for p2 in points:
            d.line(p1[0], p1[1], p2[0], p2[1], 1)
    if i % 2:
        d.invert()
예제 #4
0
from ssd1306 import SSD1306

print("---------------------")
print(" Test SSD1306 screen ")
print("---------------------")

screen = SSD1306(2, 3)
screen.DrawScreenText("JC`zic", 10, 10)
예제 #5
0
import pyb
from ssd1306 import SSD1306

display = SSD1306()
display.poweron()
display.init_display()

display.draw_text(10, 10, "Hello Mike")
display.display()
pyb.delay(2000)
예제 #6
0
from ssd1306 import SSD1306
from time import sleep

x = SSD1306()
x.write(0, 'Hi there')
x.commit()
sleep(1)
x.write(1, "whee")
x.commit()
sleep(1)
x.write(3, "wowee")
x.commit()
sleep(1)

예제 #7
0
# UPYBBOT - micropython balaancing robot
# jeffm   - 23.4.2015

import pyb
import graphics
from ssd1306 import SSD1306

lcd = SSD1306(pinout={
    'sda': 'X10',
    'scl': 'X9'
},
              height=64,
              external_vcc=False)
lcd.poweron()
lcd.init_display()

from mpu6050 import MPU6050
imu = MPU6050(2, False)

# set up stepper motors
from nemastepper import Stepper
motor1 = Stepper('Y1', 'Y2', 'Y3')
motor2 = Stepper('X4', 'X5', 'X6')

from pyb import Timer


def issr(t):
    global motor1, motor2
    motor1.do_step()
    motor2.do_step()
예제 #8
0
import pyb
from pyb import Pin, ADC
from ssd1306 import SSD1306

accel = pyb.Accel()
adc = ADC(Pin('X22'))
display = SSD1306(pinout={'sda': 'Y10','scl': 'Y9'},height=64,external_vcc=False)

def sw_callback():
  led_green.toggle()
  print("ButtonPressed")
 
sw = pyb.Switch()
sw.callback(sw_callback)

led_red = pyb.LED(1)
led_red.off()

led_green = pyb.LED(2)
led_green.on()

led_orange = pyb.LED(3)
led_orange.on()

try:
  display.poweron()
  display.init_display()
  
  display.draw_text(32,21,'X')
  display.draw_text(64,56,'Y')
  
예제 #9
0
import machine
import math

#debugled = machine.Pin(25, machine.Pin.OUT)
#debugled.toggle()
#utime.sleep(1)
#debugled.toggle()
#utime.sleep(1)
#debugled.toggle()
#utime.sleep(1)
#debugled.toggle()
#print("Debug complete")

i2c = I2C(0)

oled = SSD1306(128, 64, i2c)

sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

buttonsupply = machine.Pin(14, machine.Pin.OUT)
buttonsupply.value(1)
buttonread = machine.Pin(13, machine.Pin.IN)

headerart = [
    "00000000000000000000000000000000", "01111110000111110000011111111110",
    "01000011100111111100011111111110", "01011101110111111110011111111110",
    "01011101110111111111011111111110", "01000011111111111111011111111110",
    "01011111111111111111011111111110", "01011111110111111111011111111110",
    "01011111110111111111011111111110", "01111111100111111111011111111110",
    "01111110000111111111011111111110", "01110000000111111111011111111110",