"""
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Raspberry Pi Pico I2C LCD Display (MicroPython) ┃
┃ ┃
┃ An example of using an I2C LCD display with the ┃
┃ Raspberry Pi Pico. ┃
┃ ┃
┃ Copyright (c) 2023 Anderson Costa ┃
┃ GitHub: github.com/arcostasi ┃
┃ License: MIT ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
"""
import xml.etree.ElementTree as ET
from machine import I2C, Pin
from time import sleep
from pico_i2c_lcd import I2cLcd
def initialize_i2c_lcd(sda_pin, scl_pin, i2c_freq):
"""Initialize the I2C LCD display with the given parameters."""
i2c_bus = I2C(0, sda=Pin(sda_pin), scl=Pin(scl_pin), freq=i2c_freq)
i2c_address = i2c_bus.scan()[0]
return I2cLcd(i2c_bus, i2c_address, 2, 16), i2c_address
def display_address(lcd, i2c_address):
"""Display the I2C address in decimal and hexadecimal formats."""
lcd.blink_cursor_on()
for address_format in (str, hex):
lcd.putstr(f"I2C Address: {address_format(i2c_address)}\n")
lcd.putstr("PI PICO Hardware")
sleep(2)
lcd.clear()
lcd.blink_cursor_off()
def backlight_test(lcd):
"""Perform a backlight test by blinking the backlight 10 times."""
lcd.clear()
lcd.putstr("Backlight Test")
for _ in range(10):
lcd.backlight_on()
sleep(0.2)
lcd.backlight_off()
sleep(0.2)
lcd.backlight_on()
def hide_cursor_count(lcd):
"""Hide the cursor and display a count from 0 to 19."""
lcd.clear()
lcd.hide_cursor()
for count in range(20):
lcd.putstr(str(count))
sleep(0.4)
lcd.clear()
def main():
"""Main function to run the I2C LCD display example."""
lcd_display, i2c_address = initialize_i2c_lcd(sda_pin=0, scl_pin=1, i2c_freq=400000)
while True:
#display_address(lcd_display, i2c_address)
#backlight_test(lcd_display)
#hide_cursor_count(lcd_display)
def process_soap()
soap_response = """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetDepartureBoardResponse xmlns="http://thalesgroup.com/RTTI/2021-11-01/ldb/">
<GetStationBoardResult xmlns:lt="http://thalesgroup.com/RTTI/2012-01-13/ldb/types" xmlns:lt8="http://thalesgroup.com/RTTI/2021-11-01/ldb/types" xmlns:lt6="http://thalesgroup.com/RTTI/2017-02-02/ldb/types" xmlns:lt7="http://thalesgroup.com/RTTI/2017-10-01/ldb/types" xmlns:lt4="http://thalesgroup.com/RTTI/2015-11-27/ldb/types" xmlns:lt5="http://thalesgroup.com/RTTI/2016-02-16/ldb/types" xmlns:lt2="http://thalesgroup.com/RTTI/2014-02-20/ldb/types" xmlns:lt3="http://thalesgroup.com/RTTI/2015-05-14/ldb/types">
<lt4:generatedAt>2024-04-02T13:24:55.3234146+01:00</lt4:generatedAt>
<lt4:locationName>Clapham Junction</lt4:locationName>
<lt4:crs>CLJ</lt4:crs>
<lt4:nrccMessages>
<lt:message>Disruption between Watford Junction and Clapham Junction due to a fault with the signalling system. More details can be found in <a href="https://www.nationalrail.co.uk/service-disruptions/shepherds-bush-20240402/">Latest Travel News.</a></lt:message>
</lt4:nrccMessages>
<lt4:platformAvailable>true</lt4:platformAvailable>
<lt8:trainServices>
<lt8:service>
<lt4:std>13:08</lt4:std>
<lt4:etd>13:24</lt4:etd>
<lt4:platform>12</lt4:platform>
<lt4:operator>Southern</lt4:operator>
<lt4:operatorCode>SN</lt4:operatorCode>
<lt4:serviceType>train</lt4:serviceType>
<lt4:length>8</lt4:length>
<lt4:delayReason>This train has been delayed by congestion</lt4:delayReason>
<lt4:serviceID>754876CLPHMJC_</lt4:serviceID>
<lt5:origin>
<lt4:location>
<lt4:locationName>Bognor Regis</lt4:locationName>
<lt4:crs>BOG</lt4:crs>
</lt4:location>
<lt4:location>
<lt4:locationName>Fratton</lt4:locationName>
<lt4:crs>FTN</lt4:crs>
</lt4:location>
</lt5:origin>
<lt5:destination>
<lt4:location>
<lt4:locationName>London Victoria</lt4:locationName>
<lt4:crs>VIC</lt4:crs>
</lt4:location>
</lt5:destination>
</lt8:service>
<lt8:service>
<lt4:std>13:21</lt4:std>
<lt4:etd>13:27</lt4:etd>
<lt4:platform>12</lt4:platform>
<lt4:operator>Southern</lt4:operator>
<lt4:operatorCode>SN</lt4:operatorCode>
<lt4:serviceType>train</lt4:serviceType>
<lt4:length>8</lt4:length>
<lt4:serviceID>769499CLPHMJC_</lt4:serviceID>
<lt5:origin>
<lt4:location>
<lt4:locationName>Littlehampton</lt4:locationName>
<lt4:crs>LIT</lt4:crs>
</lt4:location>
</lt5:origin>
<lt5:destination>
<lt4:location>
<lt4:locationName>London Victoria</lt4:locationName>
<lt4:crs>VIC</lt4:crs>
</lt4:location>
</lt5:destination>
</lt8:service>
</lt8:trainServices>
</GetStationBoardResult>
</GetDepartureBoardResponse>
</soap:Body>
</soap:Envelope>"""
# Define namespace
ns = {'soap': 'http://schemas.xmlsoap.org/soap/envelope/',
'lt4': 'http://thalesgroup.com/RTTI/2015-11-27/ldb/types',
'lt5': 'http://thalesgroup.com/RTTI/2016-02-16/ldb/types',
'lt8': 'http://thalesgroup.com/RTTI/2021-11-01/ldb/types'}
# Extract values
std = root.find('.//lt4:std', ns).text
etd = root.find('.//lt4:etd', ns).text
origin_location_name = root.find('.//lt5:origin/lt4:location/lt4:locationName', ns).text
destination_location_name = root.find('.//lt5:destination/lt4:location/lt4:locationName', ns).text
# Print values
print("STD:", std)
print("ETD:", etd)
print("Origin Location Name:", origin_location_name)
print("Destination Location Name:", destination_location_name)
if __name__ == '__main__':
main()
#process_soap()