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 *
class DigitalPriceDisplay:
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=17, name='left', handler=self)
self.rightbutton = Button(pin=16, name='right', handler=self)
self.myproducts = []
self.index = 0
self.addProducts()
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__':
mydisplay = DigitalPriceDisplay()
mydisplay.showInfo()