def coins_inserted(): """Actions coins inserted """ global led # Check if we should update prices if config.FIAT == 0: # Our counter is 0, meaning we got no fiat in: config.BTCPRICE = utils.get_btc_price(config.conf["atm"]["cur"]) config.SATPRICE = math.floor((1 / (config.BTCPRICE * 100)) * 1e8) logger.debug("Satoshi price updated") # We must have gotten pulses! print(config.PULSES) config.FIAT += float(config.COINTYPES[config.PULSES]['fiat']) config.COINCOUNT += 1 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("Added {}".format(config.COINTYPES[config.PULSES]['name'])) display.update_amount_screen() # Reset pulse cointer config.PULSES = 0 if config.FIAT > 0 and led == "off": # Turn on the LED after first coin GPIO.output(13, GPIO.HIGH) led = "on" logger.debug("Button-LED turned on (if connected)")
def coins_inserted(): """Actions coins inserted """ global led if config.FIAT == 0: config.BTCPRICE = utils.get_btc_price(config.conf["atm"]["cur"]) config.SATPRICE = math.floor((1 / (config.BTCPRICE * 100)) * 100000000) logger.info("Satoshi price updated") if config.PULSES == 2: config.FIAT += 0.02 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("2 cents added") display.update_amount_screen() if config.PULSES == 3: config.FIAT += 0.05 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("5 cents added") display.update_amount_screen() if config.PULSES == 4: config.FIAT += 0.1 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("10 cents added") display.update_amount_screen() if config.PULSES == 5: config.FIAT += 0.2 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("20 cents added") display.update_amount_screen() if config.PULSES == 6: config.FIAT += 0.5 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("50 cents added") display.update_amount_screen() if config.PULSES == 7: config.FIAT += 1 config.SATS = utils.get_sats() logger.info("100 cents added") display.update_amount_screen() config.PULSES = 0 if config.FIAT > 0 and led == "off": # Turn on the LED after first coin GPIO.output(13, GPIO.HIGH) led = "on" logger.info("Button-LED turned on (if connected)")
def coins_inserted(): """Actions coins inserted """ if config.FIAT == 0: config.BTCPRICE = utils.get_btc_price(config.conf["atm"]["cur"]) config.SATPRICE = math.floor((1 / (config.BTCPRICE * 100)) * 100000000) logger.info("Satoshi price updated") if config.PULSES == 2: config.FIAT += 0.02 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("2 cents added") display.update_amount_screen() if config.PULSES == 3: config.FIAT += 0.05 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("5 cents added") display.update_amount_screen() if config.PULSES == 4: config.FIAT += 0.1 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("10 cents added") display.update_amount_screen() if config.PULSES == 5: config.FIAT += 0.2 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("20 cents added") display.update_amount_screen() if config.PULSES == 6: config.FIAT += 0.5 config.SATS = utils.get_sats() config.SATSFEE = utils.get_sats_with_fee() config.SATS -= config.SATSFEE logger.info("50 cents added") display.update_amount_screen() if config.PULSES == 7: config.FIAT += 1 config.SATS = utils.get_sats() logger.info("100 cents added") display.update_amount_screen() config.PULSES = 0
# TODO: Add variable to set certificate check to true or false # Papirus eInk size is 128 x 96 pixels # WHITE = 1 # BLACK = 0 # PAPIRUSROT = 0 # PAPIRUS = Papirus(rotation=PAPIRUSROT) # API URL for coingecko COINGECKO_URL_BASE = "https://api.coingecko.com/api/v3/" # Fiat and satoshi variables FIAT = 0 SATS = 0 SATSFEE = 0 INVOICE = "" # Set btc and sat price BTCPRICE = utils.get_btc_price(conf["atm"]["cur"]) SATPRICE = math.floor((1 / (BTCPRICE * 100)) * 100000000) # Button / Acceptor Pulses LASTIMPULSE = 0 PULSES = 0 LASTPUSHES = 0 PUSHES = 0 # Lists for different coin counting, not yet implemented # COINLIST = [] # PULSLIST = []
CURRENCY = "EUR" # Add var for fee in % # # Set during initial setup to LND or LNTXBOT ACTIVEWALLET = "" # base64 encoded lntxbot api credentials LNTXBOTCRED = "" # HEX encoded LND macaroon LNDMACAROON = "" # Set sat, fiat FIAT = 0 SATS = 0 INVOICE = "" # Set btc and sat price BTCPRICE = utils.get_btc_price(CURRENCY) SATPRICE = round((1 / (BTCPRICE * 100)) * 100000000, 2) # Button / Acceptor Pulses LASTIMPULSE = 0 PULSES = 0 LASTPUSHES = 0 PUSHES = 0 # lntxbot QRFOLDER = "/home/pi/LightningATM/resources/qr_codes"