aboutsummaryrefslogtreecommitdiffstats
path: root/examples/stub.py
blob: 516b71a53e96992411921af5c7644a535900ed95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""
    This is a script stub, with definitions for all events.
"""


def start(context, argv):
    """
        Called once on script startup, before any other events.
    """
    context.log("start")


def clientconnect(context, root_layer):
    """
        Called when a client initiates a connection to the proxy. Note that a
        connection can correspond to multiple HTTP requests
    """
    context.log("clientconnect")


def request(context, flow):
    """
        Called when a client request has been received.
    """
    context.log("request")


def serverconnect(context, server_conn):
    """
        Called when the proxy initiates a connection to the target server. Note that a
        connection can correspond to multiple HTTP requests
    """
    context.log("serverconnect")


def responseheaders(context, flow):
    """
        Called when the response headers for a server response have been received,
        but the response body has not been processed yet. Can be used to tell mitmproxy
        to stream the response.
    """
    context.log("responseheaders")


def response(context, flow):
    """
       Called when a server response has been received.
    """
    context.log("response")


def error(context, flow):
    """
        Called when a flow error has occured, e.g. invalid server responses, or
        interrupted connections. This is distinct from a valid server HTTP error
        response, which is simply a response with an HTTP error code.
    """
    context.log("error")


def serverdisconnect(context, server_conn):
    """
        Called when the proxy closes the connection to the target server.
    """
    context.log("serverdisconnect")


def clientdisconnect(context, root_layer):
    """
        Called when a client disconnects from the proxy.
    """
    context.log("clientdisconnect")


def done(context):
    """
        Called once on script shutdown, after any other events.
    """
    context.log("done")
="p">{ r = 65535.0f * i/3.0f *(1.0f + s * cos(h) / cosf(1.047196667f - h)); g = 65535.0f * i/3.0f *(1.0f + s *(1.0f - cosf(h) / cos(1.047196667f - h))); b = 65535.0f * i/3.0f *(1.0f - s); } else if(h < 4.188787) { h = h - 2.09439; g = 65535.0f * i/3.0f *(1.0f + s * cosf(h) / cosf(1.047196667f - h)); b = 65535.0f * i/3.0f *(1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); r = 65535.0f * i/3.0f *(1.0f - s); } else { h = h - 4.188787; b = 65535.0f*i/3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h)); r = 65535.0f*i/3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); g = 65535.0f*i/3.0f * (1.0f - s); } *r_out = r > 65535 ? 65535 : r; *g_out = g > 65535 ? 65535 : g; *b_out = b > 65535 ? 65535 : b; } void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity) { uint16_t r, g, b; float hue_f = 360.0f * (float)hue / 255.0f; float saturation_f = (float)saturation / 255.0f; float intensity_f = (float)intensity / 255.0f; intensity_f *= (float)current_brightness / 255.0f; hsi_to_rgb(hue_f, saturation_f, intensity_f, &r, &g, &b); current_hue = hue; current_saturation = saturation; current_intensity = intensity; lcd_backlight_hal_color(r, g, b); } void lcd_backlight_brightness(uint8_t b) { current_brightness = b; lcd_backlight_color(current_hue, current_saturation, current_intensity); } uint8_t lcd_get_backlight_brightness(void) { return current_brightness; }