Is there any way to store data in the MLA between frames?

Is there any way to store data in the MLA between frames?

I’d like to be able to treat the first data byte of an I2C bus specially, and I do not mean the address byte. I use the first data byte to specify the context of later bytes and would like to use a lookup table to define what should be displayed instead of the numerical data itself. My first thought was to just use a bool and change it after it is first accessed, then set it again on the next address frame, but this variable seems to just get deleted after each frame.

# High Level Analyzer
# For more information and documentation, please go to https://support.saleae.com/extensions/high-level-analyzer-extensions

from saleae.analyzers import HighLevelAnalyzer, AnalyzerFrame, StringSetting, NumberSetting, ChoicesSetting


# High level analyzers must subclass the HighLevelAnalyzer class.
class Hla(HighLevelAnalyzer):
    
    START = 0
    # An optional list of types this analyzer produces, providing a way to customize the way frames are displayed in Logic 2.
    result_types = {
        'i2c-address': {
            'format': '{{data.description}}'
        },
        'i2c-data': {
            'format': '{{data.description}}'
        }
    }

    

    def __init__(self):
        pass

    def decode(self, frame: AnalyzerFrame):
        if frame.type == 'address':
            direction = 'Read' if frame.data['read'] else 'Write'
            address = (frame.data['address'][0] << 1) | (1 if frame.data['read'] else 0)
            ack = frame.data['ack']
            START = 1
            return AnalyzerFrame('i2c-address', frame.start_time, frame.end_time, {
                'description': 'Setup {} to {} + {}'.format(direction, 'ALL' if (address == 0) else address, 'ACK' if ack else 'NAK')
            })
        elif frame.type == 'data':
            data = frame.data['data'][0]
            ack = frame.data['ack']
            if START:
                START = 0
                if data == 126:
                    DataText = 'ADDR CHANGE'
                elif data == 5:
                    DataText = 'G1'
                elif data == 9:
                    DataText = 'G6'
                elif data == 4:
                    DataText = 'G92'
                elif data == 6:
                    DataText = 'M202'
                elif data == 8:
                    DataText = 'M204'
                elif data == 7:
                    DataText = 'M205'
                return AnalyzerFrame('i2c-data', frame.start_time, frame.end_time, {'description': '{} + {}'.format(DataText, 'ACK' if ack else 'NAK')})
            else:
                return AnalyzerFrame('i2c-data', frame.start_time, frame.end_time, {'description': '0x{:02X} + {}'.format(data, 'ACK' if ack else 'NAK')})

Use your class __init__ to set up member variables. I set up result_types as you have done, but I’d make START a member variable and set it initially in __init__ with

    self.start = 0

then where you use it in your member functions (decode(self, ...) for example) use it the the same way (self.start).