import time
time.sleep(0.1) # Wait for USB to become ready
print("Hello, Pi Pico W!")
import time
time.sleep(0.1) # Wait for USB to become ready
print("Hello, Pi Pico!")
from Buzzer import *
from LightStrip import *
from Displays import *
from Button import *
from modelclasses import *
from DAL import *
class POSSystem:
def __init__(self):
self.buzzer = PassiveBuzzer(pin=15, name='Buzz')
self.lightstrip = LightStrip(pin=2, name='Lights')
self.display = LCDDisplay(sda=0, scl=1)
self.leftbutton = Button(pin=15, name='left', handler=self)
self.rightbutton = Button(pin=14, name='right', handler=self)
self.selectbutton = Button(pin=13, name='select', handler=self)
self.checkoutbutton = Button(pin=12, name='checkout', handler=self)
self.myproducts = []
self.index = 0
#self.addProducts()
self.dal = DAL()
print('Retrieving customer 520...')
self.customer = self.dal.getCustomer(520)
self.showCustomerWelcome()
time.sleep(2)
print('Retrieving products...')
self.myproducts = self.dal.getProducts()
self.showInfo()
def showCustomerWelcome(self):
self.display.showText('Welcome', 0)
self.display.showText(str(self.customer), 1)
def addProducts(self):
product1 = PackagedProduct('1234', 'Oatmeal', 'Organic oatmeal', 100, 'GM', 2.49)
product2 = PackagedProduct('1234', 'Cereal', 'Cheerios', 10, 'Kelloggs', 4.49)
#p3 = BulkProduct(....)
self.myproducts.append(product1)
self.myproducts.append(product2)
def showInfo(self):
self.display.clear()
currentproduct = self.myproducts[self.index]
self.display.showText(currentproduct.line1(), 0)
self.display.showText(currentproduct.line2(), 1)
def previousProduct(self):
if self.index > 0:
self.index = self.index - 1
self.showInfo()
self.buzzer.beep(tone=500)
def nextProduct(self):
if self.index < len(self.myproducts) -1:
self.index = self.index + 1
self.showInfo()
self.buzzer.beep(tone=1000)
def buttonPressed(self, name):
if name == 'left':
self.previousProduct()
else:
self.nextProduct()
def buttonReleased(self, name):
pass
if __name__ == '__main__':
s = POSSystem()