summaryrefslogtreecommitdiff
path: root/fw/fe310/test/test.c
blob: fc080d2a0bb8ce90db1a1022fc89886eb44c1853 (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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <eos.h>

#include <soc/i2c.h>
#include <dev/bq25895.h>
#include <eve/eve.h>
#include <eve/eve_kbd.h>
#include <eve/eve_font.h>

#include <eve/screen/window.h>
#include <eve/screen/page.h>
#include <eve/screen/form.h>

#include "app/app_root.h"

#include "test.h"

static int reg_read(uint8_t reg, uint8_t *data) {
    return eos_i2c_read8(BQ25895_ADDR, reg, data, 1);
}

static int reg_write(uint8_t reg, uint8_t data) {
    return eos_i2c_write8(BQ25895_ADDR, reg, &data, 1);
}

int app_test_uievt(EVEForm *form, uint16_t evt, void *param) {
    uint8_t data = 0;
    int rv, ret = 0, i;

    switch (evt) {
        case EVE_UIEVT_GEST_TOUCH:
            printf("PAGE TOUCH\n");
            printf("BQ25895:\n");
            for (i=0; i<0x15; i++) {
                rv = reg_read(i, &data);
                if (!rv) printf("REG%02x: %02x\n", i, data);
            }
            break;

        default:
            ret = eve_form_uievt(form, evt, param);
            break;
    }
    return ret;
}

void app_test(EVEWindow *window, EVEViewStack *stack) {
    EVEFormSpec spec[] = {
        {
            .widget.type = EVE_WIDGET_TYPE_SPACER,
            .widget.g.h = 1,
        },
    };
    EVEForm *form = eve_form_create(window, stack, spec, 1, app_test_uievt, NULL, app_test_close);
}

void app_test_close(EVEForm *form) {
    eve_form_destroy(form);
}