Fix MIFARE card enrollment and login
[uccvend-vendserver.git] / VendServer / VendServer.py
index 6dfbfe1..6c52933 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-# vim:ts=4
+# vim: ts=4 sts=4 sw=4 noexpandtab
 
 USE_MIFARE = 1
 
@@ -140,6 +140,7 @@ class VendServer():
                # If the user has just logged in, show them their balance
                if welcome:
                        balance = self.dispense.getBalance()
+                       balance = balance[:-4] + '.' + balance[-4] + balance[-2:]   # Work around display bug
                        
                        msg = [(self.center('WELCOME'), False, TEXT_SPEED),
                                   (self.center(self.dispense.getUsername()), False, TEXT_SPEED),
@@ -391,7 +392,11 @@ class VendServer():
                                        self.vstatus.last_timeout_refresh = None
                                else:
                                        # Price check mode.
-                                       self.dispense.getItemInfo(self.vstatus.cur_selection)
+                                       (name,price) = self.dispense.getItemInfo(self.vstatus.cur_selection)
+                                       dollarprice = "$%.2f" % ( price / 100.0 )
+                                       dollarprice = dollarprice[:-4] + '.' + dollarprice[-4] + dollarprice[-2:]   # Work around display bug
+                                       self.v.display( self.vstatus.cur_selection+' - %s'%dollarprice)
+
                                        self.vstatus.cur_selection = ''
                                        self.vstatus.time_to_autologout = None
                                        self.vstatus.last_timeout_refresh = None
@@ -476,6 +481,7 @@ class VendServer():
                        if len(self.vstatus.cur_pin) == PIN_LENGTH:
                                self.dispense.authUserIdPin(self.vstatus.cur_user, self.vstatus.cur_pin)
                                if self.dispense.getUsername():
+                                       self.vstatus.username = self.dispense.getUsername()
                                        self.v.beep(0, False)
                                        self.vstatus.cur_selection = ''
                                        self.vstatus.change_state(STATE_GET_SELECTION)

UCC git Repository :: git.ucc.asn.au