예제 #1
0
import time
from OmegaExpansion import oledExp
import configure, keypad
import dlmode

k = keypad.KEYPAD()


def welcomeMessage():
    oledExp.setVerbosity(0)
    oledExp.driverInit()
    oledExp.clear()
    oledExp.setCursor(3, 0)
    oledExp.write("Welcome to OnionOmega")
    oledExp.setCursor(4, 0)
    oledExp.write("Data Logger Project")
    time.sleep(5)


def displayModes():
    oledExp.clear()
    oledExp.setCursor(2, 0)
    oledExp.write("Select mode(1,2,3):")
    oledExp.setCursor(3, 0)
    oledExp.write("1. CONFIGURE MODE")
    oledExp.setCursor(4, 0)
    oledExp.write("2. RUN MODE")
    oledExp.setCursor(5, 0)
    oledExp.write("3. BACKUP MODE")
    oledExp.setCursor(6, 0)
    oledExp.write("Mode of Operation:")
# gnd rq 3.3v sda scl
import microbit as ubit 
import keypad

ubit.i2c.init()
switch = ubit.button_a

keypad = keypad.KEYPAD(ubit.i2c, ubit.pin0)
ALL_KEYS = [ j+1 for j in range(9) ] + ['*', 0, '#']

while not switch.is_pressed():

    if keypad.keypad.is_near():
        print("P", end = ' ')
    else:
        print("-", end = ' ')
                
    for i in ALL_KEYS:
        if keypad.key[i].is_pressed():
            print(str(keypad.key[i]), end = ' ')
        else:
            print('.', end = ' ')

    print('', end = '\r')
                    
    keypad.sleep(100)


print("")

for i in ALL_KEYS: