Commit 394ae277 authored by Klint Youngmeyer's avatar Klint Youngmeyer
Browse files

Add Dan's test script, in preparation for re-making the public repo

parent 2973ba7c
import os
import pyb
import battery
highdrive0 = pyb.Pin('G0', pyb.Pin.OUT_PP)
highdrive1 = pyb.Pin('G1', pyb.Pin.OUT_PP)
highdrive2 = pyb.Pin('G2', pyb.Pin.OUT_PP)
highdrive3 = pyb.Pin('G3', pyb.Pin.OUT_PP)
highdrive4 = pyb.Pin('G4', pyb.Pin.OUT_PP)
highdrive5 = pyb.Pin('G5', pyb.Pin.OUT_PP)
highdrive6 = pyb.Pin('G6', pyb.Pin.OUT_PP)
highdrive7 = pyb.Pin('G10', pyb.Pin.OUT_PP)
highdrives = [highdrive0, highdrive1, highdrive2, highdrive3,
highdrive4, highdrive5, highdrive6, highdrive7]
rtc = pyb.RTC()
batt = battery.Battery()
lcd = pyb.LCD()
while(True):
print('\nCutipy Test Menu:\n')
print('1: Battery Voltage Test')
print('2: Battery Charger Test')
print('3: RTC Set Test')
print('4: SD Card Test')
print('5: Buttons Test')
print('6: LCD Test')
print('7: High Drive Outputs') #done
print('CTRL-D to Exit')
#Need test for CAN
#Need tests for all 4 serial ports
option = input('\nSelect an option or press CTRL-D to exit: ')
if option == '1':
print('Voltage = ' + str(batt.batteryVoltage()))
elif option == '2':
print('Is the battery charging: ' + str(batt.batteryConnected()))
elif option == '3':
print('\nRunning Configure RTC...')
print('\nConfiguring Real Time Clock...')
year = input('Enter the year (4 digits): ')
month = input('Enter the month (1-12): ')
day = input('Enter the day (1-31): ')
weekday = input('Enter the weekday (1-7 [Monday = 1, Sunday = 7]): ')
hour = input('Enter the hour (24-hour format): ')
minute = input('Enter the minute (0-59): ')
rtc.datetime((int(year), int(month), int(day), int(weekday), int(hour), int(minute), 0, 0))
print(rtc.datetime())
elif option == '4':
sd = pyb.SDCard()
os.mount(sd, '/sd')
f = open('/sd/data.txt', 'w+')
f.write('hello SD card')
f.close()
print('Reading file from SD')
f = open('/sd/data.txt', 'r')
resp = f.read()
f.close()
os.remove('/sd/data.txt')
os.umount('/sd')
flsh = open('/flash/test_results.txt', 'a+')
if resp == 'hello SD card':
print('SD card test passed')
print('File written to SD card')
flsh.write('SD card test passed\n')
else:
print('SD card test failed')
flsh.write('SD card test failed\n')
flsh.close()
elif option == '5':
switch1 = pyb.Switch(1)
switch2 = pyb.Switch(2)
switch3 = pyb.Switch(3)
switch4 = pyb.Switch(4)
def cb1():
print("This is callback #1")
def cb2():
print("This is callback #2")
def cb3():
print("This is callback #3")
def cb4():
print("This is callback #4")
switch1.callback(cb1)
switch2.callback(cb2)
switch3.callback(cb3)
switch4.callback(cb4)
elif option == '6':
print('Writing to the LCD...')
lcd.light(True)
lcd.write('Hello world!\n')
elif option == '7':
i=0
pins = ['PG0', 'PG1', 'PG2', 'PG3', 'PG4', 'PG5', 'PG6', 'PG10']
while True:
for drive in highdrives:
drive.value(0)
print("Turning on drive " + pins[i])
highdrives[i].value(1)
cont = input("Press 'y' to continue, any other key to exit loop")
if cont == 'y':
if i == 7:
i = 0;
else:
i += 1
else:
print('Exiting highdrive loop')
else:
print('Invalid Option')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment